diff --git a/src/wp-includes/class-wp-oembed.php b/src/wp-includes/class-wp-oembed.php
index ce75a4f196..acf2f5852f 100644
|
a
|
b
|
class WP_oEmbed { |
| 50 | 50 | public function __construct() { |
| 51 | 51 | $host = urlencode( home_url() ); |
| 52 | 52 | $providers = array( |
| 53 | | '#https?://((m|www)\.)?youtube\.com/watch.*#i' => array( 'https://www.youtube.com/oembed', true ), |
| 54 | | '#https?://((m|www)\.)?youtube\.com/playlist.*#i' => array( 'https://www.youtube.com/oembed', true ), |
| 55 | | '#https?://((m|www)\.)?youtube\.com/shorts/*#i' => array( 'https://www.youtube.com/oembed', true ), |
| | 53 | '#https?://((m|www)\.)?youtube(?:-nocookie)?\.com/watch.*#i' => array( 'https://www.youtube.com/oembed', true ), |
| | 54 | '#https?://((m|www)\.)?youtube(?:-nocookie)?\.com/playlist.*#i' => array( 'https://www.youtube.com/oembed', true ), |
| | 55 | '#https?://((m|www)\.)?youtube(?:-nocookie)?\.com/shorts/*#i' => array( 'https://www.youtube.com/oembed', true ), |
| 56 | 56 | '#https?://youtu\.be/.*#i' => array( 'https://www.youtube.com/oembed', true ), |
| 57 | 57 | '#https?://(.+\.)?vimeo\.com/.*#i' => array( 'https://vimeo.com/api/oembed.{format}', true ), |
| 58 | 58 | '#https?://(www\.)?dailymotion\.com/.*#i' => array( 'https://www.dailymotion.com/services/oembed', true ), |
| … |
… |
class WP_oEmbed { |
| 359 | 359 | return false; |
| 360 | 360 | } |
| 361 | 361 | |
| | 362 | // If the input was a youtube-nocookie.com URL, modify the embed |
| | 363 | // to use youtube-nocookie.com. |
| | 364 | if ( $provider === 'https://www.youtube.com/oembed' && str_contains( $url, 'youtube-nocookie.com/' ) ) { |
| | 365 | $data->html = str_replace( 'https://www.youtube.com/embed/', 'https://www.youtube-nocookie.com/embed/', $data->html ); |
| | 366 | // Remove "feature=oembed" parameter, since the iframe's code |
| | 367 | // is no longer identical to YouTube's oembed output. |
| | 368 | $data->html = str_replace( '?feature=oembed', '', $data->html ); |
| | 369 | $data->html = str_replace( '&feature=oembed', '', $data->html ); |
| | 370 | } |
| | 371 | |
| 362 | 372 | return $data; |
| 363 | 373 | } |
| 364 | 374 | |
diff --git a/src/wp-includes/embed.php b/src/wp-includes/embed.php
index 443d399217..20543eb995 100644
|
a
|
b
|
function wp_maybe_load_embeds() { |
| 202 | 202 | return; |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | | wp_embed_register_handler( 'youtube_embed_url', '#https?://(www.)?youtube\.com/(?:v|embed)/([^/]+)#i', 'wp_embed_handler_youtube' ); |
| | 205 | wp_embed_register_handler( 'youtube_embed_url', '#https?://(www.)?youtube(?:-nocookie)?\.com/(?:v|embed)/([^/]+)#i', 'wp_embed_handler_youtube' ); |
| 206 | 206 | |
| 207 | 207 | /** |
| 208 | 208 | * Filters the audio embed handler callback. |
| … |
… |
function wp_maybe_load_embeds() { |
| 241 | 241 | */ |
| 242 | 242 | function wp_embed_handler_youtube( $matches, $attr, $url, $rawattr ) { |
| 243 | 243 | global $wp_embed; |
| 244 | | $embed = $wp_embed->autoembed( sprintf( 'https://youtube.com/watch?v=%s', urlencode( $matches[2] ) ) ); |
| | 244 | if ( str_contains( $url, 'youtube-nocookie.com/' ) ) { |
| | 245 | $embed = $wp_embed->autoembed( sprintf( 'https://youtube-nocookie.com/watch?v=%s', urlencode( $matches[2] ) ) ); |
| | 246 | } else { |
| | 247 | $embed = $wp_embed->autoembed( sprintf( 'https://youtube.com/watch?v=%s', urlencode( $matches[2] ) ) ); |
| | 248 | } |
| 245 | 249 | |
| 246 | 250 | /** |
| 247 | 251 | * Filters the YoutTube embed output. |