Make WordPress Core

Ticket #25527: 25527.diff

File 25527.diff, 4.5 KB (added by swissspidy, 11 years ago)
  • src/wp-includes/class-oembed.php

    From 3ce555c0dd08ba6f5f07748d7ed5b982dba54da3 Mon Sep 17 00:00:00 2001
    From: Pascal Birchler <hello@pascalbirchler.ch>
    Date: Mon, 7 Oct 2013 18:38:28 +0200
    Subject: [PATCH] Hooks Docs: wp-includes/class-oembed.php
    
    ---
     src/wp-includes/class-oembed.php | 48 +++++++++++++++++++++++++++++++++++++---
     1 file changed, 45 insertions(+), 3 deletions(-)
    
    diff --git a/src/wp-includes/class-oembed.php b/src/wp-includes/class-oembed.php
    index a880448..e62de0d 100644
    a b class WP_oEmbed { 
    2929                // List out some popular sites that support oEmbed.
    3030                // The WP_Embed class disables discovery for non-unfiltered_html users, so only providers in this array will be used for them.
    3131                // Add to this list using the wp_oembed_add_provider() function (see its PHPDoc for details).
     32
     33                /**
     34                 * Filters the list of oEmbed providers.
     35                 *
     36                 * @since 2.9.0
     37                 *
     38                 * @param array Popular oEmbed providers
     39                 */
    3240                $this->providers = apply_filters( 'oembed_providers', array(
    3341                        '#https?://(www\.)?youtube\.com/watch.*#i'           => array( 'http://www.youtube.com/oembed',                     true  ),
    3442                        'http://youtu.be/*'                                  => array( 'http://www.youtube.com/oembed',                     false ),
    class WP_oEmbed { 
    5058                        '#https?://(.+\.)?polldaddy\.com/.*#i'               => array( 'http://polldaddy.com/oembed/',                      true  ),
    5159                        '#https?://(www\.)?funnyordie\.com/videos/.*#i'      => array( 'http://www.funnyordie.com/oembed',                  true  ),
    5260                        '#https?://(www\.)?twitter\.com/.+?/status(es)?/.*#i'=> array( 'http://api.twitter.com/1/statuses/oembed.{format}', true  ),
    53                         '#https?://(www\.)?soundcloud\.com/.*#i'             => array( 'http://soundcloud.com/oembed',                      true  ),
     61                        '#https?://(www\.)?soundcloud\.com/.*#i'             => array( 'http://soundcloud.com/oembed',                      true  ),
    5462                        '#https?://(www\.)?slideshare\.net/*#'               => array( 'http://www.slideshare.net/api/oembed/2',            true  ),
    5563                        '#http://instagr(\.am|am\.com)/p/.*#i'               => array( 'http://api.instagram.com/oembed',                   true  ),
    5664                        '#https?://(www\.)?rdio\.com/.*#i'                   => array( 'http://www.rdio.com/api/oembed/',                   true  ),
    class WP_oEmbed { 
    100108                if ( !$provider || false === $data = $this->fetch( $provider, $url, $args ) )
    101109                        return false;
    102110
     111                /**
     112                 * Filters the resulting HTML.
     113                 *
     114                 * @since 2.9.0
     115                 *
     116                 * @param string The resulting HTML
     117                 * @param string The URL
     118                 * @param array  Optional arguments. Usually passed from a shortcode
     119                 */
    103120                return apply_filters( 'oembed_result', $this->data2html( $data, $url ), $url, $args );
    104121        }
    105122
    class WP_oEmbed { 
    115132                // Fetch URL content
    116133                if ( $html = wp_remote_retrieve_body( wp_safe_remote_get( $url ) ) ) {
    117134
    118                         // <link> types that contain oEmbed provider URLs
     135                        /**
     136                         * Filters <link> types that contain oEmbed provider URLs.
     137                         *
     138                         * @since 2.9.0
     139                         *
     140                         * @param array <link> types
     141                         */
    119142                        $linktypes = apply_filters( 'oembed_linktypes', array(
    120143                                'application/json+oembed' => 'json',
    121144                                'text/xml+oembed' => 'xml',
    class WP_oEmbed { 
    173196                $provider = add_query_arg( 'maxheight', (int) $args['height'], $provider );
    174197                $provider = add_query_arg( 'url', urlencode($url), $provider );
    175198
     199                /**
     200                 * Filters the oEmbed URL to be fetched.
     201                 *
     202                 * @since 2.9.0
     203                 *
     204                 * @param string $provider The URL to the oEmbed provider.
     205                 * @param string $url      The URL to the content that is desired to be embedded.
     206                 * @param array  $args     Optional arguments. Usually passed from a shortcode.
     207                 */
    176208                $provider = apply_filters( 'oembed_fetch_url', $provider, $url, $args );
    177209
    178210                foreach( array( 'json', 'xml' ) as $format ) {
    class WP_oEmbed { 
    309341                                $return = false;
    310342                }
    311343
    312                 // You can use this filter to add support for custom data types or to filter the result
     344                /**
     345                 * Filters the returning HTML.
     346                 *
     347                 * You can use this filter to add support for custom data types or to filter the result.
     348                 *
     349                 * @since 2.9.0
     350                 *
     351                 * @param string $return The returning HTML
     352                 * @param object $data A data object result from an oEmbed provider.
     353                 * @param string $url The URL to the content that is desired to be embedded.
     354                 */
    313355                return apply_filters( 'oembed_dataparse', $return, $data, $url );
    314356        }
    315357