70 '#https?://(www\.)?twitter\.com/\w{1,15}/lists/.*#i' => array( 'https://publish.twitter.com/oembed', true ), |
70 '#https?://(www\.)?twitter\.com/\w{1,15}/lists/.*#i' => array( 'https://publish.twitter.com/oembed', true ), |
71 '#https?://(www\.)?twitter\.com/\w{1,15}/timelines/.*#i' => array( 'https://publish.twitter.com/oembed', true ), |
71 '#https?://(www\.)?twitter\.com/\w{1,15}/timelines/.*#i' => array( 'https://publish.twitter.com/oembed', true ), |
72 '#https?://(www\.)?twitter\.com/i/moments/.*#i' => array( 'https://publish.twitter.com/oembed', true ), |
72 '#https?://(www\.)?twitter\.com/i/moments/.*#i' => array( 'https://publish.twitter.com/oembed', true ), |
73 '#https?://(www\.)?soundcloud\.com/.*#i' => array( 'https://soundcloud.com/oembed', true ), |
73 '#https?://(www\.)?soundcloud\.com/.*#i' => array( 'https://soundcloud.com/oembed', true ), |
74 '#https?://(.+?\.)?slideshare\.net/.*#i' => array( 'https://www.slideshare.net/api/oembed/2', true ), |
74 '#https?://(.+?\.)?slideshare\.net/.*#i' => array( 'https://www.slideshare.net/api/oembed/2', true ), |
75 '#https?://(www\.)?instagr(\.am|am\.com)/(p|tv)/.*#i' => array( 'https://api.instagram.com/oembed', true ), |
|
76 '#https?://(open|play)\.spotify\.com/.*#i' => array( 'https://embed.spotify.com/oembed/', true ), |
75 '#https?://(open|play)\.spotify\.com/.*#i' => array( 'https://embed.spotify.com/oembed/', true ), |
77 '#https?://(.+\.)?imgur\.com/.*#i' => array( 'https://api.imgur.com/oembed', true ), |
76 '#https?://(.+\.)?imgur\.com/.*#i' => array( 'https://api.imgur.com/oembed', true ), |
78 '#https?://(www\.)?meetu(\.ps|p\.com)/.*#i' => array( 'https://api.meetup.com/oembed', true ), |
77 '#https?://(www\.)?meetu(\.ps|p\.com)/.*#i' => array( 'https://api.meetup.com/oembed', true ), |
79 '#https?://(www\.)?issuu\.com/.+/docs/.+#i' => array( 'https://issuu.com/oembed_wp', true ), |
78 '#https?://(www\.)?issuu\.com/.+/docs/.+#i' => array( 'https://issuu.com/oembed_wp', true ), |
80 '#https?://(www\.)?mixcloud\.com/.*#i' => array( 'https://www.mixcloud.com/oembed', true ), |
79 '#https?://(www\.)?mixcloud\.com/.*#i' => array( 'https://www.mixcloud.com/oembed', true ), |
86 '#https?://cloudup\.com/.*#i' => array( 'https://cloudup.com/oembed', true ), |
85 '#https?://cloudup\.com/.*#i' => array( 'https://cloudup.com/oembed', true ), |
87 '#https?://(www\.)?reverbnation\.com/.*#i' => array( 'https://www.reverbnation.com/oembed', true ), |
86 '#https?://(www\.)?reverbnation\.com/.*#i' => array( 'https://www.reverbnation.com/oembed', true ), |
88 '#https?://videopress\.com/v/.*#' => array( 'https://public-api.wordpress.com/oembed/?for=' . $host, true ), |
87 '#https?://videopress\.com/v/.*#' => array( 'https://public-api.wordpress.com/oembed/?for=' . $host, true ), |
89 '#https?://(www\.)?reddit\.com/r/[^/]+/comments/.*#i' => array( 'https://www.reddit.com/oembed', true ), |
88 '#https?://(www\.)?reddit\.com/r/[^/]+/comments/.*#i' => array( 'https://www.reddit.com/oembed', true ), |
90 '#https?://(www\.)?speakerdeck\.com/.*#i' => array( 'https://speakerdeck.com/oembed.{format}', true ), |
89 '#https?://(www\.)?speakerdeck\.com/.*#i' => array( 'https://speakerdeck.com/oembed.{format}', true ), |
91 '#https?://www\.facebook\.com/.*/posts/.*#i' => array( 'https://www.facebook.com/plugins/post/oembed.json/', true ), |
|
92 '#https?://www\.facebook\.com/.*/activity/.*#i' => array( 'https://www.facebook.com/plugins/post/oembed.json/', true ), |
|
93 '#https?://www\.facebook\.com/.*/photos/.*#i' => array( 'https://www.facebook.com/plugins/post/oembed.json/', true ), |
|
94 '#https?://www\.facebook\.com/photo(s/|\.php).*#i' => array( 'https://www.facebook.com/plugins/post/oembed.json/', true ), |
|
95 '#https?://www\.facebook\.com/permalink\.php.*#i' => array( 'https://www.facebook.com/plugins/post/oembed.json/', true ), |
|
96 '#https?://www\.facebook\.com/media/.*#i' => array( 'https://www.facebook.com/plugins/post/oembed.json/', true ), |
|
97 '#https?://www\.facebook\.com/questions/.*#i' => array( 'https://www.facebook.com/plugins/post/oembed.json/', true ), |
|
98 '#https?://www\.facebook\.com/notes/.*#i' => array( 'https://www.facebook.com/plugins/post/oembed.json/', true ), |
|
99 '#https?://www\.facebook\.com/.*/videos/.*#i' => array( 'https://www.facebook.com/plugins/video/oembed.json/', true ), |
|
100 '#https?://www\.facebook\.com/video\.php.*#i' => array( 'https://www.facebook.com/plugins/video/oembed.json/', true ), |
|
101 '#https?://(www\.)?screencast\.com/.*#i' => array( 'https://api.screencast.com/external/oembed', true ), |
90 '#https?://(www\.)?screencast\.com/.*#i' => array( 'https://api.screencast.com/external/oembed', true ), |
102 '#https?://([a-z0-9-]+\.)?amazon\.(com|com\.mx|com\.br|ca)/.*#i' => array( 'https://read.amazon.com/kp/api/oembed', true ), |
91 '#https?://([a-z0-9-]+\.)?amazon\.(com|com\.mx|com\.br|ca)/.*#i' => array( 'https://read.amazon.com/kp/api/oembed', true ), |
103 '#https?://([a-z0-9-]+\.)?amazon\.(co\.uk|de|fr|it|es|in|nl|ru)/.*#i' => array( 'https://read.amazon.co.uk/kp/api/oembed', true ), |
92 '#https?://([a-z0-9-]+\.)?amazon\.(co\.uk|de|fr|it|es|in|nl|ru)/.*#i' => array( 'https://read.amazon.co.uk/kp/api/oembed', true ), |
104 '#https?://([a-z0-9-]+\.)?amazon\.(co\.jp|com\.au)/.*#i' => array( 'https://read.amazon.com.au/kp/api/oembed', true ), |
93 '#https?://([a-z0-9-]+\.)?amazon\.(co\.jp|com\.au)/.*#i' => array( 'https://read.amazon.com.au/kp/api/oembed', true ), |
105 '#https?://([a-z0-9-]+\.)?amazon\.cn/.*#i' => array( 'https://read.amazon.cn/kp/api/oembed', true ), |
94 '#https?://([a-z0-9-]+\.)?amazon\.cn/.*#i' => array( 'https://read.amazon.cn/kp/api/oembed', true ), |
148 * | YouTube | youtube.com/watch | 2.9.0 | |
137 * | YouTube | youtube.com/watch | 2.9.0 | |
149 * | Crowdsignal | polldaddy.com | 3.0.0 | |
138 * | Crowdsignal | polldaddy.com | 3.0.0 | |
150 * | SmugMug | smugmug.com | 3.0.0 | |
139 * | SmugMug | smugmug.com | 3.0.0 | |
151 * | YouTube | youtu.be | 3.0.0 | |
140 * | YouTube | youtu.be | 3.0.0 | |
152 * | Twitter | twitter.com | 3.4.0 | |
141 * | Twitter | twitter.com | 3.4.0 | |
153 * | Instagram | instagram.com | 3.5.0 | |
|
154 * | Instagram | instagr.am | 3.5.0 | |
|
155 * | Slideshare | slideshare.net | 3.5.0 | |
142 * | Slideshare | slideshare.net | 3.5.0 | |
156 * | SoundCloud | soundcloud.com | 3.5.0 | |
143 * | SoundCloud | soundcloud.com | 3.5.0 | |
157 * | Dailymotion | dai.ly | 3.6.0 | |
144 * | Dailymotion | dai.ly | 3.6.0 | |
158 * | Flickr | flic.kr | 3.6.0 | |
145 * | Flickr | flic.kr | 3.6.0 | |
159 * | Spotify | spotify.com | 3.6.0 | |
146 * | Spotify | spotify.com | 3.6.0 | |
175 * | VideoPress | videopress.com | 4.4.0 | |
162 * | VideoPress | videopress.com | 4.4.0 | |
176 * | Reddit | reddit.com | 4.4.0 | |
163 * | Reddit | reddit.com | 4.4.0 | |
177 * | Speaker Deck | speakerdeck.com | 4.4.0 | |
164 * | Speaker Deck | speakerdeck.com | 4.4.0 | |
178 * | Twitter | twitter.com/timelines | 4.5.0 | |
165 * | Twitter | twitter.com/timelines | 4.5.0 | |
179 * | Twitter | twitter.com/moments | 4.5.0 | |
166 * | Twitter | twitter.com/moments | 4.5.0 | |
180 * | Facebook | facebook.com | 4.7.0 | |
|
181 * | Twitter | twitter.com/user | 4.7.0 | |
167 * | Twitter | twitter.com/user | 4.7.0 | |
182 * | Twitter | twitter.com/likes | 4.7.0 | |
168 * | Twitter | twitter.com/likes | 4.7.0 | |
183 * | Twitter | twitter.com/lists | 4.7.0 | |
169 * | Twitter | twitter.com/lists | 4.7.0 | |
184 * | Screencast | screencast.com | 4.8.0 | |
170 * | Screencast | screencast.com | 4.8.0 | |
185 * | Amazon | amazon.com (com.mx, com.br, ca) | 4.9.0 | |
171 * | Amazon | amazon.com (com.mx, com.br, ca) | 4.9.0 | |
190 * | Amazon | amzn.to (eu, in, asia) | 4.9.0 | |
176 * | Amazon | amzn.to (eu, in, asia) | 4.9.0 | |
191 * | Amazon | z.cn | 4.9.0 | |
177 * | Amazon | z.cn | 4.9.0 | |
192 * | Someecards | someecards.com | 4.9.0 | |
178 * | Someecards | someecards.com | 4.9.0 | |
193 * | Someecards | some.ly | 4.9.0 | |
179 * | Someecards | some.ly | 4.9.0 | |
194 * | Crowdsignal | survey.fm | 5.1.0 | |
180 * | Crowdsignal | survey.fm | 5.1.0 | |
195 * | Instagram TV | instagram.com | 5.1.0 | |
|
196 * | Instagram TV | instagr.am | 5.1.0 | |
|
197 * | TikTok | tiktok.com | 5.4.0 | |
181 * | TikTok | tiktok.com | 5.4.0 | |
198 * |
182 * |
199 * No longer supported providers: |
183 * No longer supported providers: |
200 * |
184 * |
201 * | Provider | Flavor | Since | Removed | |
185 * | Provider | Flavor | Since | Removed | |
209 * | Vine | vine.co | 4.1.0 | 4.9.0 | |
193 * | Vine | vine.co | 4.1.0 | 4.9.0 | |
210 * | Photobucket | photobucket.com | 2.9.0 | 5.1.0 | |
194 * | Photobucket | photobucket.com | 2.9.0 | 5.1.0 | |
211 * | Funny or Die | funnyordie.com | 3.0.0 | 5.1.0 | |
195 * | Funny or Die | funnyordie.com | 3.0.0 | 5.1.0 | |
212 * | CollegeHumor | collegehumor.com | 4.0.0 | 5.3.1 | |
196 * | CollegeHumor | collegehumor.com | 4.0.0 | 5.3.1 | |
213 * | Hulu | hulu.com | 2.9.0 | 5.5.0 | |
197 * | Hulu | hulu.com | 2.9.0 | 5.5.0 | |
|
198 * | Instagram | instagram.com | 3.5.0 | 5.5.2 | |
|
199 * | Instagram | instagr.am | 3.5.0 | 5.5.2 | |
|
200 * | Instagram TV | instagram.com | 5.1.0 | 5.5.2 | |
|
201 * | Instagram TV | instagr.am | 5.1.0 | 5.5.2 | |
|
202 * | Facebook | facebook.com | 4.7.0 | 5.5.2 | |
214 * |
203 * |
215 * @see wp_oembed_add_provider() |
204 * @see wp_oembed_add_provider() |
216 * |
205 * |
217 * @since 2.9.0 |
206 * @since 2.9.0 |
218 * |
207 * |
229 * |
218 * |
230 * @since 4.0.0 |
219 * @since 4.0.0 |
231 * |
220 * |
232 * @param string $name Method to call. |
221 * @param string $name Method to call. |
233 * @param array $arguments Arguments to pass when calling. |
222 * @param array $arguments Arguments to pass when calling. |
234 * @return mixed|bool Return value of the callback, false otherwise. |
223 * @return mixed|false Return value of the callback, false otherwise. |
235 */ |
224 */ |
236 public function __call( $name, $arguments ) { |
225 public function __call( $name, $arguments ) { |
237 if ( in_array( $name, $this->compat_methods, true ) ) { |
226 if ( in_array( $name, $this->compat_methods, true ) ) { |
238 return $this->$name( ...$arguments ); |
227 return $this->$name( ...$arguments ); |
239 } |
228 } |
246 * @since 4.0.0 |
235 * @since 4.0.0 |
247 * |
236 * |
248 * @see WP_oEmbed::discover() |
237 * @see WP_oEmbed::discover() |
249 * |
238 * |
250 * @param string $url The URL to the content. |
239 * @param string $url The URL to the content. |
251 * @param string|array $args Optional provider arguments. |
240 * @param string|array $args { |
|
241 * Optional. Additional provider arguments. Default empty. |
|
242 * |
|
243 * @type bool $discover Optional. Determines whether to attempt to discover link tags |
|
244 * at the given URL for an oEmbed provider when the provider URL |
|
245 * is not found in the built-in providers list. Default true. |
|
246 * } |
252 * @return string|false The oEmbed provider URL on success, false on failure. |
247 * @return string|false The oEmbed provider URL on success, false on failure. |
253 */ |
248 */ |
254 public function get_provider( $url, $args = '' ) { |
249 public function get_provider( $url, $args = '' ) { |
255 $args = wp_parse_args( $args ); |
250 $args = wp_parse_args( $args ); |
256 |
251 |
337 * @see WP_oEmbed::fetch() |
332 * @see WP_oEmbed::fetch() |
338 * |
333 * |
339 * @since 4.8.0 |
334 * @since 4.8.0 |
340 * |
335 * |
341 * @param string $url The URL to the content that should be attempted to be embedded. |
336 * @param string $url The URL to the content that should be attempted to be embedded. |
342 * @param array|string $args Optional. Arguments, usually passed from a shortcode. Default empty. |
337 * @param string|array $args Optional. Additional arguments for retrieving embed HTML. |
|
338 * See wp_oembed_get() for accepted arguments. Default empty. |
343 * @return object|false The result in the form of an object on success, false on failure. |
339 * @return object|false The result in the form of an object on success, false on failure. |
344 */ |
340 */ |
345 public function get_data( $url, $args = '' ) { |
341 public function get_data( $url, $args = '' ) { |
346 $args = wp_parse_args( $args ); |
342 $args = wp_parse_args( $args ); |
347 |
343 |
367 * @see WP_oEmbed::data2html() |
363 * @see WP_oEmbed::data2html() |
368 * |
364 * |
369 * @since 2.9.0 |
365 * @since 2.9.0 |
370 * |
366 * |
371 * @param string $url The URL to the content that should be attempted to be embedded. |
367 * @param string $url The URL to the content that should be attempted to be embedded. |
372 * @param array|string $args Optional. Arguments, usually passed from a shortcode. Default empty. |
368 * @param string|array $args Optional. Additional arguments for retrieving embed HTML. |
373 * @return string|false The UNSANITIZED (and potentially unsafe) HTML that should be used to embed on success, |
369 * See wp_oembed_get() for accepted arguments. Default empty. |
374 * false on failure. |
370 * @return string|false The UNSANITIZED (and potentially unsafe) HTML that should be used to embed |
|
371 * on success, false on failure. |
375 */ |
372 */ |
376 public function get_html( $url, $args = '' ) { |
373 public function get_html( $url, $args = '' ) { |
377 /** |
374 /** |
378 * Filters the oEmbed result before any HTTP requests are made. |
375 * Filters the oEmbed result before any HTTP requests are made. |
379 * |
376 * |
383 * Returning a non-null value from the filter will effectively short-circuit retrieval |
380 * Returning a non-null value from the filter will effectively short-circuit retrieval |
384 * and return the passed value instead. |
381 * and return the passed value instead. |
385 * |
382 * |
386 * @since 4.5.3 |
383 * @since 4.5.3 |
387 * |
384 * |
388 * @param null|string $result The UNSANITIZED (and potentially unsafe) HTML that should be used to embed. |
385 * @param null|string $result The UNSANITIZED (and potentially unsafe) HTML that should be used to embed. |
389 * Default null to continue retrieving the result. |
386 * Default null to continue retrieving the result. |
390 * @param string $url The URL to the content that should be attempted to be embedded. |
387 * @param string $url The URL to the content that should be attempted to be embedded. |
391 * @param array $args Optional. Arguments, usually passed from a shortcode. Default empty. |
388 * @param string|array $args Optional. Additional arguments for retrieving embed HTML. |
|
389 * See wp_oembed_get() for accepted arguments. Default empty. |
392 */ |
390 */ |
393 $pre = apply_filters( 'pre_oembed_result', null, $url, $args ); |
391 $pre = apply_filters( 'pre_oembed_result', null, $url, $args ); |
394 |
392 |
395 if ( null !== $pre ) { |
393 if ( null !== $pre ) { |
396 return $pre; |
394 return $pre; |
407 * |
405 * |
408 * @since 2.9.0 |
406 * @since 2.9.0 |
409 * |
407 * |
410 * @param string|false $data The returned oEmbed HTML (false if unsafe). |
408 * @param string|false $data The returned oEmbed HTML (false if unsafe). |
411 * @param string $url URL of the content to be embedded. |
409 * @param string $url URL of the content to be embedded. |
412 * @param array $args Optional arguments, usually passed from a shortcode. |
410 * @param string|array $args Optional. Additional arguments for retrieving embed HTML. |
|
411 * See wp_oembed_get() for accepted arguments. Default empty. |
413 */ |
412 */ |
414 return apply_filters( 'oembed_result', $this->data2html( $data, $url ), $url, $args ); |
413 return apply_filters( 'oembed_result', $this->data2html( $data, $url ), $url, $args ); |
415 } |
414 } |
416 |
415 |
417 /** |
416 /** |
509 * |
508 * |
510 * @since 2.9.0 |
509 * @since 2.9.0 |
511 * |
510 * |
512 * @param string $provider The URL to the oEmbed provider. |
511 * @param string $provider The URL to the oEmbed provider. |
513 * @param string $url The URL to the content that is desired to be embedded. |
512 * @param string $url The URL to the content that is desired to be embedded. |
514 * @param array|string $args Optional. Arguments, usually passed from a shortcode. Default empty. |
513 * @param string|array $args Optional. Additional arguments for retrieving embed HTML. |
|
514 * See wp_oembed_get() for accepted arguments. Default empty. |
515 * @return object|false The result in the form of an object on success, false on failure. |
515 * @return object|false The result in the form of an object on success, false on failure. |
516 */ |
516 */ |
517 public function fetch( $provider, $url, $args = '' ) { |
517 public function fetch( $provider, $url, $args = '' ) { |
518 $args = wp_parse_args( $args, wp_embed_defaults( $url ) ); |
518 $args = wp_parse_args( $args, wp_embed_defaults( $url ) ); |
519 |
519 |
528 * @since 2.9.0 |
528 * @since 2.9.0 |
529 * @since 4.9.0 The `dnt` (Do Not Track) query parameter was added to all oEmbed provider URLs. |
529 * @since 4.9.0 The `dnt` (Do Not Track) query parameter was added to all oEmbed provider URLs. |
530 * |
530 * |
531 * @param string $provider URL of the oEmbed provider. |
531 * @param string $provider URL of the oEmbed provider. |
532 * @param string $url URL of the content to be embedded. |
532 * @param string $url URL of the content to be embedded. |
533 * @param array $args Optional arguments, usually passed from a shortcode. |
533 * @param array $args Optional. Additional arguments for retrieving embed HTML. |
|
534 * See wp_oembed_get() for accepted arguments. Default empty. |
534 */ |
535 */ |
535 $provider = apply_filters( 'oembed_fetch_url', $provider, $url, $args ); |
536 $provider = apply_filters( 'oembed_fetch_url', $provider, $url, $args ); |
536 |
537 |
537 foreach ( array( 'json', 'xml' ) as $format ) { |
538 foreach ( array( 'json', 'xml' ) as $format ) { |
538 $result = $this->_fetch_with_format( $provider, $format ); |
539 $result = $this->_fetch_with_format( $provider, $format ); |
595 private function _parse_xml( $response_body ) { |
596 private function _parse_xml( $response_body ) { |
596 if ( ! function_exists( 'libxml_disable_entity_loader' ) ) { |
597 if ( ! function_exists( 'libxml_disable_entity_loader' ) ) { |
597 return false; |
598 return false; |
598 } |
599 } |
599 |
600 |
600 $loader = libxml_disable_entity_loader( true ); |
601 if ( PHP_VERSION_ID < 80000 ) { |
|
602 // This function has been deprecated in PHP 8.0 because in libxml 2.9.0, external entity loading |
|
603 // is disabled by default, so this function is no longer needed to protect against XXE attacks. |
|
604 // phpcs:ignore PHPCompatibility.FunctionUse.RemovedFunctions.libxml_disable_entity_loaderDeprecated |
|
605 $loader = libxml_disable_entity_loader( true ); |
|
606 } |
|
607 |
601 $errors = libxml_use_internal_errors( true ); |
608 $errors = libxml_use_internal_errors( true ); |
602 |
609 |
603 $return = $this->_parse_xml_body( $response_body ); |
610 $return = $this->_parse_xml_body( $response_body ); |
604 |
611 |
605 libxml_use_internal_errors( $errors ); |
612 libxml_use_internal_errors( $errors ); |
606 libxml_disable_entity_loader( $loader ); |
613 |
|
614 if ( PHP_VERSION_ID < 80000 && isset( $loader ) ) { |
|
615 // phpcs:ignore PHPCompatibility.FunctionUse.RemovedFunctions.libxml_disable_entity_loaderDeprecated |
|
616 libxml_disable_entity_loader( $loader ); |
|
617 } |
607 |
618 |
608 return $return; |
619 return $return; |
609 } |
620 } |
610 |
621 |
611 /** |
622 /** |