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 { |
| 29 | 29 | // List out some popular sites that support oEmbed. |
| 30 | 30 | // The WP_Embed class disables discovery for non-unfiltered_html users, so only providers in this array will be used for them. |
| 31 | 31 | // 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 | */ |
| 32 | 40 | $this->providers = apply_filters( 'oembed_providers', array( |
| 33 | 41 | '#https?://(www\.)?youtube\.com/watch.*#i' => array( 'http://www.youtube.com/oembed', true ), |
| 34 | 42 | 'http://youtu.be/*' => array( 'http://www.youtube.com/oembed', false ), |
| … |
… |
class WP_oEmbed { |
| 50 | 58 | '#https?://(.+\.)?polldaddy\.com/.*#i' => array( 'http://polldaddy.com/oembed/', true ), |
| 51 | 59 | '#https?://(www\.)?funnyordie\.com/videos/.*#i' => array( 'http://www.funnyordie.com/oembed', true ), |
| 52 | 60 | '#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 ), |
| 54 | 62 | '#https?://(www\.)?slideshare\.net/*#' => array( 'http://www.slideshare.net/api/oembed/2', true ), |
| 55 | 63 | '#http://instagr(\.am|am\.com)/p/.*#i' => array( 'http://api.instagram.com/oembed', true ), |
| 56 | 64 | '#https?://(www\.)?rdio\.com/.*#i' => array( 'http://www.rdio.com/api/oembed/', true ), |
| … |
… |
class WP_oEmbed { |
| 100 | 108 | if ( !$provider || false === $data = $this->fetch( $provider, $url, $args ) ) |
| 101 | 109 | return false; |
| 102 | 110 | |
| | 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 | */ |
| 103 | 120 | return apply_filters( 'oembed_result', $this->data2html( $data, $url ), $url, $args ); |
| 104 | 121 | } |
| 105 | 122 | |
| … |
… |
class WP_oEmbed { |
| 115 | 132 | // Fetch URL content |
| 116 | 133 | if ( $html = wp_remote_retrieve_body( wp_safe_remote_get( $url ) ) ) { |
| 117 | 134 | |
| 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 | */ |
| 119 | 142 | $linktypes = apply_filters( 'oembed_linktypes', array( |
| 120 | 143 | 'application/json+oembed' => 'json', |
| 121 | 144 | 'text/xml+oembed' => 'xml', |
| … |
… |
class WP_oEmbed { |
| 173 | 196 | $provider = add_query_arg( 'maxheight', (int) $args['height'], $provider ); |
| 174 | 197 | $provider = add_query_arg( 'url', urlencode($url), $provider ); |
| 175 | 198 | |
| | 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 | */ |
| 176 | 208 | $provider = apply_filters( 'oembed_fetch_url', $provider, $url, $args ); |
| 177 | 209 | |
| 178 | 210 | foreach( array( 'json', 'xml' ) as $format ) { |
| … |
… |
class WP_oEmbed { |
| 309 | 341 | $return = false; |
| 310 | 342 | } |
| 311 | 343 | |
| 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 | */ |
| 313 | 355 | return apply_filters( 'oembed_dataparse', $return, $data, $url ); |
| 314 | 356 | } |
| 315 | 357 | |