Ticket #25527: 25527.2.diff
File 25527.2.diff, 3.7 KB (added by , 11 years ago) |
---|
-
src/wp-includes/class-oembed.php
26 26 * @uses apply_filters() Filters a list of pre-defined oEmbed providers. 27 27 */ 28 28 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 */ 32 41 $this->providers = apply_filters( 'oembed_providers', array( 33 42 '#https?://(www\.)?youtube\.com/watch.*#i' => array( 'http://www.youtube.com/oembed', true ), 34 43 'http://youtu.be/*' => array( 'http://www.youtube.com/oembed', false ), … … 100 109 if ( !$provider || false === $data = $this->fetch( $provider, $url, $args ) ) 101 110 return false; 102 111 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 */ 103 121 return apply_filters( 'oembed_result', $this->data2html( $data, $url ), $url, $args ); 104 122 } 105 123 … … 115 133 // Fetch URL content 116 134 if ( $html = wp_remote_retrieve_body( wp_safe_remote_get( $url ) ) ) { 117 135 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 */ 119 145 $linktypes = apply_filters( 'oembed_linktypes', array( 120 146 'application/json+oembed' => 'json', 121 147 'text/xml+oembed' => 'xml', 122 'application/xml+oembed' => 'xml', // Incorrect, but used by at least Vimeo148 'application/xml+oembed' => 'xml', 123 149 ) ); 124 150 125 151 // Strip <body> … … 173 199 $provider = add_query_arg( 'maxheight', (int) $args['height'], $provider ); 174 200 $provider = add_query_arg( 'url', urlencode($url), $provider ); 175 201 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 */ 176 211 $provider = apply_filters( 'oembed_fetch_url', $provider, $url, $args ); 177 212 178 213 foreach( array( 'json', 'xml' ) as $format ) { … … 309 344 $return = false; 310 345 } 311 346 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 */ 313 358 return apply_filters( 'oembed_dataparse', $return, $data, $url ); 314 359 } 315 360