WordPress.org

Make WordPress Core

Ticket #40245: 40245_update.3.diff

File 40245_update.3.diff, 2.1 KB (added by TomHarrigan, 2 years ago)

patch refresh - proper diff

  • wp-includes/default-filters.php

     
    554554add_filter( 'the_excerpt_embed', 'shortcode_unautop' );
    555555add_filter( 'the_excerpt_embed', 'wp_embed_excerpt_attachment' );
    556556
     557
    557558add_filter( 'oembed_dataparse', 'wp_filter_oembed_result', 10, 3 );
    558559add_filter( 'oembed_response_data', 'get_oembed_response_data_rich', 10, 4 );
    559560add_filter( 'pre_oembed_result', 'wp_filter_pre_oembed_result', 10, 3 );
  • wp-includes/embed.php

     
    709709}
    710710
    711711/**
     712 * Filters the given oEmbed HTML to make sure it has a title.
     713 *
     714 * @since x.x.x
     715 *
     716 * @param string $result The oEmbed HTML result.
     717 * @param object $data   A data object result from an oEmbed provider.
     718 * @param string $url    The URL of the content to be embedded.
     719 * @return string The filtered oEmbed result.
     720 */
     721function wp_filter_oembed_title( $result, $data, $url ) {
     722
     723        // Get title from oEmbed data to start.
     724        $title = ! empty( $data->title ) ? $data->title : '';
     725
     726        // If no oEmbed title, search the return markup for a title attribute.
     727        $preg_match     = '/title\=[\"|\\\']{1}([^\"\\\']*)[\"|\\\']{1}/i';
     728        $has_title_attr = preg_match( $preg_match, $result, $matches );
     729        if ( $has_title_attr && ! empty( $matches[1] ) ) {
     730                $title = $matches[1];
     731        }
     732
     733        $title = apply_filters( 'oembed_title', $title, $result, $data, $url );
     734
     735        /*
     736         * If the title attribute already
     737         * exists, replace with new value.
     738         *
     739         * Otherwise, add the title attribute.
     740         */
     741        if ( $has_title_attr ) {
     742                $result = preg_replace( $preg_match, 'title="' . esc_attr( $title ) . '"', $result );
     743        } else {
     744                $result = preg_replace( '/^\<iframe/i', '<iframe title="' . esc_attr( $title ) . '"', $result );
     745        }
     746
     747        return $result;
     748}
     749
     750/**
    712751 * Filters the given oEmbed HTML.
    713752 *
    714753 * If the `$url` isn't on the trusted providers list,