WordPress.org

Make WordPress Core

Changeset 25723


Ignore:
Timestamp:
10/07/2013 11:56:52 PM (7 years ago)
Author:
DrewAPicture
Message:

Inline documentation for hooks in wp-includes/class-oembed.php.

Props swissspidy, kpdesign.
Fixes #25527.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-oembed.php

    r24917 r25723  
    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).
    32         $this->providers = apply_filters( 'oembed_providers', array(
     29        $providers = array(
    3330            '#https?://(www\.)?youtube\.com/watch.*#i'           => array( 'http://www.youtube.com/oembed',                     true  ),
    3431            'http://youtu.be/*'                                  => array( 'http://www.youtube.com/oembed',                     false ),
     
    5754            '#https?://rd\.io/x/.*#i'                            => array( 'http://www.rdio.com/api/oembed/',                   true  ),
    5855            '#https?://(open|play)\.spotify\.com/.*#i'           => array( 'https://embed.spotify.com/oembed/',                 true  ),
    59         ) );
     56        );
     57        /**
     58         * Filter the list of oEmbed providers.
     59         *
     60         * Discovery is disabled for users lacking the unfiltered_html capability.
     61         * Only providers in this array will be used for those users.
     62         *
     63         * @see wp_oembed_add_provider()
     64         *
     65         * @since 2.9.0
     66         *
     67         * @param array $providers An array of popular oEmbed providers.
     68         */
     69        $this->providers = apply_filters( 'oembed_providers', $providers );
    6070
    6171        // Fix any embeds that contain new lines in the middle of the HTML which breaks wpautop().
     
    101111            return false;
    102112
     113        /**
     114         * Filter the HTML returned by the oEmbed provider.
     115         *
     116         * @since 2.9.0
     117         *
     118         * @param string $data The returned oEmbed HTML.
     119         * @param string $url  URL of the content to be embedded.
     120         * @param array  $args Optional arguments, usually passed from a shortcode.
     121         */
    103122        return apply_filters( 'oembed_result', $this->data2html( $data, $url ), $url, $args );
    104123    }
     
    116135        if ( $html = wp_remote_retrieve_body( wp_safe_remote_get( $url ) ) ) {
    117136
    118             // <link> types that contain oEmbed provider URLs
     137            /**
     138             * Filter the link types that contain oEmbed provider URLs.
     139             *
     140             * @since 2.9.0
     141             *
     142             * @param array $format Array of oEmbed link types. Accepts 'application/json+oembed',
     143             *                      'text/xml+oembed', and 'application/xml+oembed' (incorrect,
     144             *                      used by at least Vimeo).
     145             */
    119146            $linktypes = apply_filters( 'oembed_linktypes', array(
    120147                'application/json+oembed' => 'json',
    121148                'text/xml+oembed' => 'xml',
    122                 'application/xml+oembed' => 'xml', // Incorrect, but used by at least Vimeo
     149                'application/xml+oembed' => 'xml',
    123150            ) );
    124151
     
    174201        $provider = add_query_arg( 'url', urlencode($url), $provider );
    175202
     203        /**
     204         * Filter the oEmbed URL to be fetched.
     205         *
     206         * @since 2.9.0
     207         *
     208         * @param string $provider URL of the oEmbed provider.
     209         * @param string $url      URL of the content to be embedded.
     210         * @param array  $args     Optional arguments, usually passed from a shortcode.
     211         */
    176212        $provider = apply_filters( 'oembed_fetch_url', $provider, $url, $args );
    177213
     
    310346        }
    311347
    312         // You can use this filter to add support for custom data types or to filter the result
     348        /**
     349         * Filter the returned oEmbed HTML.
     350         *
     351         * Use this filter to add support for custom data types, or to filter the result.
     352         *
     353         * @since 2.9.0
     354         *
     355         * @param string $return The returned oEmbed HTML.
     356         * @param object $data   A data object result from an oEmbed provider.
     357         * @param string $url    The URL of the content to be embedded.
     358         */
    313359        return apply_filters( 'oembed_dataparse', $return, $data, $url );
    314360    }
Note: See TracChangeset for help on using the changeset viewer.