PageRenderTime 108ms CodeModel.GetById 41ms RepoModel.GetById 3ms app.codeStats 0ms

/wp-includes/class-oembed.php

https://gitlab.com/math4youbyusgroupillinois/WordPress
PHP | 581 lines | 233 code | 66 blank | 282 comment | 52 complexity | ac3bd7dc006330128607505656da3e4c MD5 | raw file
  1. <?php
  2. /**
  3. * API for fetching the HTML to embed remote content based on a provided URL.
  4. * Used internally by the {@link WP_Embed} class, but is designed to be generic.
  5. *
  6. * @link http://codex.wordpress.org/oEmbed oEmbed Codex Article
  7. * @link http://oembed.com/ oEmbed Homepage
  8. *
  9. * @package WordPress
  10. * @subpackage oEmbed
  11. */
  12. /**
  13. * oEmbed class.
  14. *
  15. * @package WordPress
  16. * @subpackage oEmbed
  17. * @since 2.9.0
  18. */
  19. class WP_oEmbed {
  20. public $providers = array();
  21. public static $early_providers = array();
  22. /**
  23. * Constructor
  24. *
  25. * @since 2.9.0
  26. */
  27. public function __construct() {
  28. $providers = array(
  29. '#http://(www\.)?youtube\.com/watch.*#i' => array( 'http://www.youtube.com/oembed', true ),
  30. '#https://(www\.)?youtube\.com/watch.*#i' => array( 'http://www.youtube.com/oembed?scheme=https', true ),
  31. '#http://(www\.)?youtube\.com/playlist.*#i' => array( 'http://www.youtube.com/oembed', true ),
  32. '#https://(www\.)?youtube\.com/playlist.*#i' => array( 'http://www.youtube.com/oembed?scheme=https', true ),
  33. '#http://youtu\.be/.*#i' => array( 'http://www.youtube.com/oembed', true ),
  34. '#https://youtu\.be/.*#i' => array( 'http://www.youtube.com/oembed?scheme=https', true ),
  35. 'http://blip.tv/*' => array( 'http://blip.tv/oembed/', false ),
  36. '#https?://(.+\.)?vimeo\.com/.*#i' => array( 'http://vimeo.com/api/oembed.{format}', true ),
  37. '#https?://(www\.)?dailymotion\.com/.*#i' => array( 'http://www.dailymotion.com/services/oembed', true ),
  38. 'http://dai.ly/*' => array( 'http://www.dailymotion.com/services/oembed', false ),
  39. '#https?://(www\.)?flickr\.com/.*#i' => array( 'https://www.flickr.com/services/oembed/', true ),
  40. '#https?://flic\.kr/.*#i' => array( 'https://www.flickr.com/services/oembed/', true ),
  41. '#https?://(.+\.)?smugmug\.com/.*#i' => array( 'http://api.smugmug.com/services/oembed/', true ),
  42. '#https?://(www\.)?hulu\.com/watch/.*#i' => array( 'http://www.hulu.com/api/oembed.{format}', true ),
  43. 'http://revision3.com/*' => array( 'http://revision3.com/api/oembed/', false ),
  44. 'http://i*.photobucket.com/albums/*' => array( 'http://photobucket.com/oembed', false ),
  45. 'http://gi*.photobucket.com/groups/*' => array( 'http://photobucket.com/oembed', false ),
  46. '#https?://(www\.)?scribd\.com/doc/.*#i' => array( 'http://www.scribd.com/services/oembed', true ),
  47. '#https?://wordpress.tv/.*#i' => array( 'http://wordpress.tv/oembed/', true ),
  48. '#https?://(.+\.)?polldaddy\.com/.*#i' => array( 'https://polldaddy.com/oembed/', true ),
  49. '#https?://poll\.fm/.*#i' => array( 'https://polldaddy.com/oembed/', true ),
  50. '#https?://(www\.)?funnyordie\.com/videos/.*#i' => array( 'http://www.funnyordie.com/oembed', true ),
  51. '#https?://(www\.)?twitter\.com/.+?/status(es)?/.*#i' => array( 'https://api.twitter.com/1/statuses/oembed.{format}', true ),
  52. '#https?://vine.co/v/.*#i' => array( 'https://vine.co/oembed.{format}', true ),
  53. '#https?://(www\.)?soundcloud\.com/.*#i' => array( 'http://soundcloud.com/oembed', true ),
  54. '#https?://(.+?\.)?slideshare\.net/.*#i' => array( 'https://www.slideshare.net/api/oembed/2', true ),
  55. '#http://instagr(\.am|am\.com)/p/.*#i' => array( 'http://api.instagram.com/oembed', true ),
  56. '#https?://(www\.)?rdio\.com/.*#i' => array( 'http://www.rdio.com/api/oembed/', true ),
  57. '#https?://rd\.io/x/.*#i' => array( 'http://www.rdio.com/api/oembed/', true ),
  58. '#https?://(open|play)\.spotify\.com/.*#i' => array( 'https://embed.spotify.com/oembed/', true ),
  59. '#https?://(.+\.)?imgur\.com/.*#i' => array( 'http://api.imgur.com/oembed', true ),
  60. '#https?://(www\.)?meetu(\.ps|p\.com)/.*#i' => array( 'http://api.meetup.com/oembed', true ),
  61. '#https?://(www\.)?issuu\.com/.+/docs/.+#i' => array( 'http://issuu.com/oembed_wp', true ),
  62. '#https?://(www\.)?collegehumor\.com/video/.*#i' => array( 'http://www.collegehumor.com/oembed.{format}', true ),
  63. '#https?://(www\.)?mixcloud\.com/.*#i' => array( 'http://www.mixcloud.com/oembed', true ),
  64. '#https?://(www\.|embed\.)?ted\.com/talks/.*#i' => array( 'http://www.ted.com/talks/oembed.{format}', true ),
  65. '#https?://(www\.)?(animoto|video214)\.com/play/.*#i' => array( 'http://animoto.com/oembeds/create', true ),
  66. );
  67. if ( ! empty( self::$early_providers['add'] ) ) {
  68. foreach ( self::$early_providers['add'] as $format => $data ) {
  69. $providers[ $format ] = $data;
  70. }
  71. }
  72. if ( ! empty( self::$early_providers['remove'] ) ) {
  73. foreach ( self::$early_providers['remove'] as $format ) {
  74. unset( $providers[ $format ] );
  75. }
  76. }
  77. self::$early_providers = array();
  78. /**
  79. * Filter the list of oEmbed providers.
  80. *
  81. * Discovery is disabled for users lacking the unfiltered_html capability.
  82. * Only providers in this array will be used for those users.
  83. *
  84. * Supported providers:
  85. *
  86. * | ------------ | -------------------- | ----- | --------- |
  87. * | Provider | Flavor | SSL | Since |
  88. * | ------------ | -------------------- | ----- | --------- |
  89. * | Blip | blip.tv | | 2.9.0 |
  90. * | Dailymotion | dailymotion.com | Yes | 2.9.0 |
  91. * | Flickr | flickr.com | Yes | 2.9.0 |
  92. * | Hulu | hulu.com | Yes | 2.9.0 |
  93. * | Photobucket | photobucket.com | | 2.9.0 |
  94. * | Revision3 | revision3.com | | 2.9.0 |
  95. * | Scribd | scribd.com | Yes | 2.9.0 |
  96. * | Vimeo | vimeo.com | Yes | 2.9.0 |
  97. * | WordPress.tv | wordpress.tv | Yes | 2.9.0 |
  98. * | YouTube | youtube.com/watch | Yes | 2.9.0 |
  99. * | ------------ | -------------------- | ----- | --------- |
  100. * | Funny or Die | funnyordie.com | Yes | 3.0.0 |
  101. * | Polldaddy | polldaddy.com | Yes | 3.0.0 |
  102. * | SmugMug | smugmug.com | Yes | 3.0.0 |
  103. * | YouTube | youtu.be | Yes | 3.0.0 |
  104. * | ------------ | -------------------- | ----- | --------- |
  105. * | Twitter | twitter.com | Yes | 3.4.0 |
  106. * | ------------ | -------------------- | ----- | --------- |
  107. * | Instagram | instagram.com | | 3.5.0 |
  108. * | Instagram | instagr.am | | 3.5.0 |
  109. * | Slideshare | slideshare.net | Yes | 3.5.0 |
  110. * | SoundCloud | soundcloud.com | Yes | 3.5.0 |
  111. * | ------------ | -------------------- | ----- | --------- |
  112. * | Dailymotion | dai.ly | | 3.6.0 |
  113. * | Flickr | flic.kr | Yes | 3.6.0 |
  114. * | Rdio | rdio.com | Yes | 3.6.0 |
  115. * | Rdio | rd.io | Yes | 3.6.0 |
  116. * | Spotify | spotify.com | Yes | 3.6.0 |
  117. * | ------------ | -------------------- | ----- | --------- |
  118. * | Imgur | imgur.com | Yes | 3.9.0 |
  119. * | Meetup.com | meetup.com | Yes | 3.9.0 |
  120. * | Meetup.com | meetu.ps | Yes | 3.9.0 |
  121. * | ------------ | -------------------- | ----- | --------- |
  122. * | Animoto | animoto.com | Yes | 4.0.0 |
  123. * | Animoto | video214.com | Yes | 4.0.0 |
  124. * | CollegeHumor | collegehumor.com | Yes | 4.0.0 |
  125. * | Issuu | issuu.com | Yes | 4.0.0 |
  126. * | Mixcloud | mixcloud.com | Yes | 4.0.0 |
  127. * | Polldaddy | poll.fm | Yes | 4.0.0 |
  128. * | TED | ted.com | Yes | 4.0.0 |
  129. * | YouTube | youtube.com/playlist | Yes | 4.0.0 |
  130. * | ------------ | -------------------- | ----- | --------- |
  131. * | Vine | vine.co | Yes | 4.1.0 |
  132. * | ------------ | -------------------- | ----- | --------- |
  133. *
  134. * No longer supported providers:
  135. *
  136. * | ------------ | -------------------- | ----- | --------- | --------- |
  137. * | Provider | Flavor | SSL | Since | Removed |
  138. * | ------------ | -------------------- | ----- | --------- | --------- |
  139. * | Qik | qik.com | Yes | 2.9.0 | 3.9.0 |
  140. * | ------------ | -------------------- | ----- | --------- | --------- |
  141. * | Viddler | viddler.com | Yes | 2.9.0 | 4.0.0 |
  142. * | ------------ | -------------------- | ----- | --------- | --------- |
  143. *
  144. * @see wp_oembed_add_provider()
  145. *
  146. * @since 2.9.0
  147. *
  148. * @param array $providers An array of popular oEmbed providers.
  149. */
  150. $this->providers = apply_filters( 'oembed_providers', $providers );
  151. // Fix any embeds that contain new lines in the middle of the HTML which breaks wpautop().
  152. add_filter( 'oembed_dataparse', array($this, '_strip_newlines'), 10, 3 );
  153. }
  154. /**
  155. * Make private/protected methods readable for backwards compatibility.
  156. *
  157. * @since 4.0.0
  158. * @access public
  159. *
  160. * @param callable $name Method to call.
  161. * @param array $arguments Arguments to pass when calling.
  162. * @return mixed|bool Return value of the callback, false otherwise.
  163. */
  164. public function __call( $name, $arguments ) {
  165. return call_user_func_array( array( $this, $name ), $arguments );
  166. }
  167. /**
  168. * Takes a URL and returns the corresponding oEmbed provider's URL, if there is one.
  169. *
  170. * @since 4.0.0
  171. * @access public
  172. *
  173. * @see WP_oEmbed::discover()
  174. *
  175. * @param string $url The URL to the content.
  176. * @param string|array $args Optional provider arguments.
  177. * @return bool|string False on failure, otherwise the oEmbed provider URL.
  178. */
  179. public function get_provider( $url, $args = '' ) {
  180. $provider = false;
  181. if ( !isset($args['discover']) )
  182. $args['discover'] = true;
  183. foreach ( $this->providers as $matchmask => $data ) {
  184. list( $providerurl, $regex ) = $data;
  185. // Turn the asterisk-type provider URLs into regex
  186. if ( !$regex ) {
  187. $matchmask = '#' . str_replace( '___wildcard___', '(.+)', preg_quote( str_replace( '*', '___wildcard___', $matchmask ), '#' ) ) . '#i';
  188. $matchmask = preg_replace( '|^#http\\\://|', '#https?\://', $matchmask );
  189. }
  190. if ( preg_match( $matchmask, $url ) ) {
  191. $provider = str_replace( '{format}', 'json', $providerurl ); // JSON is easier to deal with than XML
  192. break;
  193. }
  194. }
  195. if ( !$provider && $args['discover'] )
  196. $provider = $this->discover( $url );
  197. return $provider;
  198. }
  199. /**
  200. * Add an oEmbed provider just-in-time when wp_oembed_add_provider() is called
  201. * before the 'plugins_loaded' hook.
  202. *
  203. * The just-in-time addition is for the benefit of the 'oembed_providers' filter.
  204. *
  205. * @since 4.0.0
  206. * @access public
  207. * @static
  208. *
  209. * @see wp_oembed_add_provider()
  210. *
  211. * @param string $format Format of URL that this provider can handle. You can use
  212. * asterisks as wildcards.
  213. * @param string $provider The URL to the oEmbed provider..
  214. * @param bool $regex Optional. Whether the $format parameter is in a regex format.
  215. * Default false.
  216. */
  217. public static function _add_provider_early( $format, $provider, $regex = false ) {
  218. if ( empty( self::$early_providers['add'] ) ) {
  219. self::$early_providers['add'] = array();
  220. }
  221. self::$early_providers['add'][ $format ] = array( $provider, $regex );
  222. }
  223. /**
  224. * Remove an oEmbed provider just-in-time when wp_oembed_remove_provider() is called
  225. * before the 'plugins_loaded' hook.
  226. *
  227. * The just-in-time removal is for the benefit of the 'oembed_providers' filter.
  228. *
  229. * @since 4.0.0
  230. * @access public
  231. * @static
  232. *
  233. * @see wp_oembed_remove_provider()
  234. *
  235. * @param string $format The format of URL that this provider can handle. You can use
  236. * asterisks as wildcards.
  237. */
  238. public static function _remove_provider_early( $format ) {
  239. if ( empty( self::$early_providers['remove'] ) ) {
  240. self::$early_providers['remove'] = array();
  241. }
  242. self::$early_providers['remove'][] = $format;
  243. }
  244. /**
  245. * The do-it-all function that takes a URL and attempts to return the HTML.
  246. *
  247. * @see WP_oEmbed::fetch()
  248. * @see WP_oEmbed::data2html()
  249. *
  250. * @param string $url The URL to the content that should be attempted to be embedded.
  251. * @param array $args Optional arguments. Usually passed from a shortcode.
  252. * @return false|string False on failure, otherwise the UNSANITIZED (and potentially unsafe) HTML that should be used to embed.
  253. */
  254. public function get_html( $url, $args = '' ) {
  255. $provider = $this->get_provider( $url, $args );
  256. if ( !$provider || false === $data = $this->fetch( $provider, $url, $args ) )
  257. return false;
  258. /**
  259. * Filter the HTML returned by the oEmbed provider.
  260. *
  261. * @since 2.9.0
  262. *
  263. * @param string $data The returned oEmbed HTML.
  264. * @param string $url URL of the content to be embedded.
  265. * @param array $args Optional arguments, usually passed from a shortcode.
  266. */
  267. return apply_filters( 'oembed_result', $this->data2html( $data, $url ), $url, $args );
  268. }
  269. /**
  270. * Attempts to discover link tags at the given URL for an oEmbed provider.
  271. *
  272. * @param string $url The URL that should be inspected for discovery `<link>` tags.
  273. * @return bool|string False on failure, otherwise the oEmbed provider URL.
  274. */
  275. public function discover( $url ) {
  276. $providers = array();
  277. /**
  278. * Filter oEmbed remote get arguments.
  279. *
  280. * @since 4.0.0
  281. *
  282. * @see WP_Http::request()
  283. *
  284. * @param array $args oEmbed remote get arguments.
  285. * @param string $url URL to be inspected.
  286. */
  287. $args = apply_filters( 'oembed_remote_get_args', array(), $url );
  288. // Fetch URL content
  289. $request = wp_safe_remote_get( $url, $args );
  290. if ( $html = wp_remote_retrieve_body( $request ) ) {
  291. /**
  292. * Filter the link types that contain oEmbed provider URLs.
  293. *
  294. * @since 2.9.0
  295. *
  296. * @param array $format Array of oEmbed link types. Accepts 'application/json+oembed',
  297. * 'text/xml+oembed', and 'application/xml+oembed' (incorrect,
  298. * used by at least Vimeo).
  299. */
  300. $linktypes = apply_filters( 'oembed_linktypes', array(
  301. 'application/json+oembed' => 'json',
  302. 'text/xml+oembed' => 'xml',
  303. 'application/xml+oembed' => 'xml',
  304. ) );
  305. // Strip <body>
  306. $html = substr( $html, 0, stripos( $html, '</head>' ) );
  307. // Do a quick check
  308. $tagfound = false;
  309. foreach ( $linktypes as $linktype => $format ) {
  310. if ( stripos($html, $linktype) ) {
  311. $tagfound = true;
  312. break;
  313. }
  314. }
  315. if ( $tagfound && preg_match_all( '/<link([^<>]+)>/i', $html, $links ) ) {
  316. foreach ( $links[1] as $link ) {
  317. $atts = shortcode_parse_atts( $link );
  318. if ( !empty($atts['type']) && !empty($linktypes[$atts['type']]) && !empty($atts['href']) ) {
  319. $providers[$linktypes[$atts['type']]] = $atts['href'];
  320. // Stop here if it's JSON (that's all we need)
  321. if ( 'json' == $linktypes[$atts['type']] )
  322. break;
  323. }
  324. }
  325. }
  326. }
  327. // JSON is preferred to XML
  328. if ( !empty($providers['json']) )
  329. return $providers['json'];
  330. elseif ( !empty($providers['xml']) )
  331. return $providers['xml'];
  332. else
  333. return false;
  334. }
  335. /**
  336. * Connects to a oEmbed provider and returns the result.
  337. *
  338. * @param string $provider The URL to the oEmbed provider.
  339. * @param string $url The URL to the content that is desired to be embedded.
  340. * @param array $args Optional arguments. Usually passed from a shortcode.
  341. * @return bool|object False on failure, otherwise the result in the form of an object.
  342. */
  343. public function fetch( $provider, $url, $args = '' ) {
  344. $args = wp_parse_args( $args, wp_embed_defaults( $url ) );
  345. $provider = add_query_arg( 'maxwidth', (int) $args['width'], $provider );
  346. $provider = add_query_arg( 'maxheight', (int) $args['height'], $provider );
  347. $provider = add_query_arg( 'url', urlencode($url), $provider );
  348. /**
  349. * Filter the oEmbed URL to be fetched.
  350. *
  351. * @since 2.9.0
  352. *
  353. * @param string $provider URL of the oEmbed provider.
  354. * @param string $url URL of the content to be embedded.
  355. * @param array $args Optional arguments, usually passed from a shortcode.
  356. */
  357. $provider = apply_filters( 'oembed_fetch_url', $provider, $url, $args );
  358. foreach( array( 'json', 'xml' ) as $format ) {
  359. $result = $this->_fetch_with_format( $provider, $format );
  360. if ( is_wp_error( $result ) && 'not-implemented' == $result->get_error_code() )
  361. continue;
  362. return ( $result && ! is_wp_error( $result ) ) ? $result : false;
  363. }
  364. return false;
  365. }
  366. /**
  367. * Fetches result from an oEmbed provider for a specific format and complete provider URL
  368. *
  369. * @since 3.0.0
  370. * @access private
  371. * @param string $provider_url_with_args URL to the provider with full arguments list (url, maxheight, etc.)
  372. * @param string $format Format to use
  373. * @return bool|object False on failure, otherwise the result in the form of an object.
  374. */
  375. private function _fetch_with_format( $provider_url_with_args, $format ) {
  376. $provider_url_with_args = add_query_arg( 'format', $format, $provider_url_with_args );
  377. /** This filter is documented in wp-includes/class-oembed.php */
  378. $args = apply_filters( 'oembed_remote_get_args', array(), $provider_url_with_args );
  379. $response = wp_safe_remote_get( $provider_url_with_args, $args );
  380. if ( 501 == wp_remote_retrieve_response_code( $response ) )
  381. return new WP_Error( 'not-implemented' );
  382. if ( ! $body = wp_remote_retrieve_body( $response ) )
  383. return false;
  384. $parse_method = "_parse_$format";
  385. return $this->$parse_method( $body );
  386. }
  387. /**
  388. * Parses a json response body.
  389. *
  390. * @since 3.0.0
  391. * @access private
  392. */
  393. private function _parse_json( $response_body ) {
  394. return ( ( $data = json_decode( trim( $response_body ) ) ) && is_object( $data ) ) ? $data : false;
  395. }
  396. /**
  397. * Parses an XML response body.
  398. *
  399. * @since 3.0.0
  400. * @access private
  401. */
  402. private function _parse_xml( $response_body ) {
  403. if ( ! function_exists( 'libxml_disable_entity_loader' ) )
  404. return false;
  405. $loader = libxml_disable_entity_loader( true );
  406. $errors = libxml_use_internal_errors( true );
  407. $return = $this->_parse_xml_body( $response_body );
  408. libxml_use_internal_errors( $errors );
  409. libxml_disable_entity_loader( $loader );
  410. return $return;
  411. }
  412. /**
  413. * Helper function for parsing an XML response body.
  414. *
  415. * @since 3.6.0
  416. * @access private
  417. */
  418. private function _parse_xml_body( $response_body ) {
  419. if ( ! function_exists( 'simplexml_import_dom' ) || ! class_exists( 'DOMDocument' ) )
  420. return false;
  421. $dom = new DOMDocument;
  422. $success = $dom->loadXML( $response_body );
  423. if ( ! $success )
  424. return false;
  425. if ( isset( $dom->doctype ) )
  426. return false;
  427. foreach ( $dom->childNodes as $child ) {
  428. if ( XML_DOCUMENT_TYPE_NODE === $child->nodeType )
  429. return false;
  430. }
  431. $xml = simplexml_import_dom( $dom );
  432. if ( ! $xml )
  433. return false;
  434. $return = new stdClass;
  435. foreach ( $xml as $key => $value ) {
  436. $return->$key = (string) $value;
  437. }
  438. return $return;
  439. }
  440. /**
  441. * Converts a data object from {@link WP_oEmbed::fetch()} and returns the HTML.
  442. *
  443. * @param object $data A data object result from an oEmbed provider.
  444. * @param string $url The URL to the content that is desired to be embedded.
  445. * @return false|string False on error, otherwise the HTML needed to embed.
  446. */
  447. public function data2html( $data, $url ) {
  448. if ( ! is_object( $data ) || empty( $data->type ) )
  449. return false;
  450. $return = false;
  451. switch ( $data->type ) {
  452. case 'photo':
  453. if ( empty( $data->url ) || empty( $data->width ) || empty( $data->height ) )
  454. break;
  455. if ( ! is_string( $data->url ) || ! is_numeric( $data->width ) || ! is_numeric( $data->height ) )
  456. break;
  457. $title = ! empty( $data->title ) && is_string( $data->title ) ? $data->title : '';
  458. $return = '<a href="' . esc_url( $url ) . '"><img src="' . esc_url( $data->url ) . '" alt="' . esc_attr($title) . '" width="' . esc_attr($data->width) . '" height="' . esc_attr($data->height) . '" /></a>';
  459. break;
  460. case 'video':
  461. case 'rich':
  462. if ( ! empty( $data->html ) && is_string( $data->html ) )
  463. $return = $data->html;
  464. break;
  465. case 'link':
  466. if ( ! empty( $data->title ) && is_string( $data->title ) )
  467. $return = '<a href="' . esc_url( $url ) . '">' . esc_html( $data->title ) . '</a>';
  468. break;
  469. default:
  470. $return = false;
  471. }
  472. /**
  473. * Filter the returned oEmbed HTML.
  474. *
  475. * Use this filter to add support for custom data types, or to filter the result.
  476. *
  477. * @since 2.9.0
  478. *
  479. * @param string $return The returned oEmbed HTML.
  480. * @param object $data A data object result from an oEmbed provider.
  481. * @param string $url The URL of the content to be embedded.
  482. */
  483. return apply_filters( 'oembed_dataparse', $return, $data, $url );
  484. }
  485. /**
  486. * Strip any new lines from the HTML.
  487. *
  488. * @access public
  489. * @param string $html Existing HTML.
  490. * @param object $data Data object from WP_oEmbed::data2html()
  491. * @param string $url The original URL passed to oEmbed.
  492. * @return string Possibly modified $html
  493. */
  494. public function _strip_newlines( $html, $data, $url ) {
  495. if ( false !== strpos( $html, "\n" ) )
  496. $html = str_replace( array( "\r\n", "\n" ), '', $html );
  497. return $html;
  498. }
  499. }
  500. /**
  501. * Returns the initialized {@link WP_oEmbed} object
  502. *
  503. * @since 2.9.0
  504. * @access private
  505. *
  506. * @see WP_oEmbed
  507. *
  508. * @return WP_oEmbed object.
  509. */
  510. function _wp_oembed_get_object() {
  511. static $wp_oembed;
  512. if ( is_null($wp_oembed) )
  513. $wp_oembed = new WP_oEmbed();
  514. return $wp_oembed;
  515. }