Make WordPress Core

Ticket #25527: 25527.2.diff

File 25527.2.diff, 3.7 KB (added by kpdesign, 11 years ago)

Second pass

  • src/wp-includes/class-oembed.php

     
    2626         * @uses apply_filters() Filters a list of pre-defined oEmbed providers.
    2727         */
    2828        function __construct() {
    29                 // List out some popular sites that support oEmbed.
    30                 // The WP_Embed class disables discovery for non-unfiltered_html users, so only providers in this array will be used for them.
    31                 // Add to this list using the wp_oembed_add_provider() function (see its PHPDoc for details).
     29                /**
     30                 * Filter the list of oEmbed providers.
     31                 *
     32                 * Discovery is disabled for users lacking the unfiltered_html capability.
     33                 * Only providers in this array will be used for those users.
     34                 *
     35                 * Add to the list using wp_oembed_add_provider().
     36                 *
     37                 * @since 2.9.0
     38                 *
     39                 * @param array $providers An array of popular oEmbed providers.
     40                 */
    3241                $this->providers = apply_filters( 'oembed_providers', array(
    3342                        '#https?://(www\.)?youtube\.com/watch.*#i'           => array( 'http://www.youtube.com/oembed',                     true  ),
    3443                        'http://youtu.be/*'                                  => array( 'http://www.youtube.com/oembed',                     false ),
     
    100109                if ( !$provider || false === $data = $this->fetch( $provider, $url, $args ) )
    101110                        return false;
    102111
     112                /**
     113                 * Filter the HTML returned by the oEmbed provider.
     114                 *
     115                 * @since 2.9.0
     116                 *
     117                 * @param string $data The returned oEmbed HTML.
     118                 * @param string $url  The URL of the content to be embedded.
     119                 * @param array  $args Optional arguments, usually passed from a shortcode.
     120                 */
    103121                return apply_filters( 'oembed_result', $this->data2html( $data, $url ), $url, $args );
    104122        }
    105123
     
    115133                // Fetch URL content
    116134                if ( $html = wp_remote_retrieve_body( wp_safe_remote_get( $url ) ) ) {
    117135
    118                         // <link> types that contain oEmbed provider URLs
     136                        /**
     137                         * Filter the link types that contain oEmbed provider URLs.
     138                         *
     139                         * @since 2.9.0
     140                         *
     141                         * @param array $format Array of link types. Accepts 'application/json+oembed',
     142                         *                      'text/xml+oembed', and 'application/xml+oembed' (incorrect,
     143                         *                      used by at least Vimeo).
     144                         */
    119145                        $linktypes = apply_filters( 'oembed_linktypes', array(
    120146                                'application/json+oembed' => 'json',
    121147                                'text/xml+oembed' => 'xml',
    122                                 'application/xml+oembed' => 'xml', // Incorrect, but used by at least Vimeo
     148                                'application/xml+oembed' => 'xml',
    123149                        ) );
    124150
    125151                        // Strip <body>
     
    173199                $provider = add_query_arg( 'maxheight', (int) $args['height'], $provider );
    174200                $provider = add_query_arg( 'url', urlencode($url), $provider );
    175201
     202                /**
     203                 * Filter the oEmbed URL to be fetched.
     204                 *
     205                 * @since 2.9.0
     206                 *
     207                 * @param string $provider The URL of the oEmbed provider.
     208                 * @param string $url      The URL of the content to be embedded.
     209                 * @param array  $args     Optional arguments, usually passed from a shortcode.
     210                 */
    176211                $provider = apply_filters( 'oembed_fetch_url', $provider, $url, $args );
    177212
    178213                foreach( array( 'json', 'xml' ) as $format ) {
     
    309344                                $return = false;
    310345                }
    311346
    312                 // You can use this filter to add support for custom data types or to filter the result
     347                /**
     348                 * Filter the returned oEmbed HTML.
     349                 *
     350                 * Use this filter to add support for custom data types, or to filter the result.
     351                 *
     352                 * @since 2.9.0
     353                 *
     354                 * @param string $return The returned oEmbed HTML.
     355                 * @param object $data   A data object result from an oEmbed provider.
     356                 * @param string $url    The URL of the content to be embedded.
     357                 */
    313358                return apply_filters( 'oembed_dataparse', $return, $data, $url );
    314359        }
    315360