Make WordPress Core

Ticket #44610: 44610.2.diff

File 44610.2.diff, 5.2 KB (added by jepperask, 6 years ago)
  • package-lock.json

     
    36433643                                        "version": "1.0.5",
    36443644                                        "bundled": true,
    36453645                                        "dev": true,
     3646                                        "optional": true,
    36463647                                        "requires": {
    36473648                                                "delayed-stream": "~1.0.0"
    36483649                                        }
     
    37053706                                "delayed-stream": {
    37063707                                        "version": "1.0.0",
    37073708                                        "bundled": true,
    3708                                         "dev": true
     3709                                        "dev": true,
     3710                                        "optional": true
    37093711                                },
    37103712                                "delegates": {
    37113713                                        "version": "1.0.0",
     
    39933995                                "mime-db": {
    39943996                                        "version": "1.27.0",
    39953997                                        "bundled": true,
    3996                                         "dev": true
     3998                                        "dev": true,
     3999                                        "optional": true
    39974000                                },
    39984001                                "mime-types": {
    39994002                                        "version": "2.1.15",
    40004003                                        "bundled": true,
    40014004                                        "dev": true,
     4005                                        "optional": true,
    40024006                                        "requires": {
    40034007                                                "mime-db": "~1.27.0"
    40044008                                        }
     
    40744078                                "number-is-nan": {
    40754079                                        "version": "1.0.1",
    40764080                                        "bundled": true,
    4077                                         "dev": true
     4081                                        "dev": true,
     4082                                        "optional": true
    40784083                                },
    40794084                                "oauth-sign": {
    40804085                                        "version": "0.8.2",
  • src/js/_enqueues/wp/custom-header.js

     
    389389                                height: this.settings.height,
    390390                                width: this.settings.width,
    391391                                videoId: this.settings.videoUrl.match( VIDEO_ID_REGEX )[1],
    392                                 events: {
     392                                host: location.protocol + ((this.settings.videoUrl.indexOf("youtube-nocookie") !== -1) ? "//www.youtube-nocookie.com" : "//www.youtube.com"),
     393                                events: {       
    393394                                        onReady: function( e ) {
    394395                                                e.target.mute();
    395396                                                handler.showControls();
  • src/wp-includes/class-oembed.php

     
    5050        public function __construct() {
    5151                $host      = urlencode( home_url() );
    5252                $providers = array(
    53                         '#https?://((m|www)\.)?youtube\.com/watch.*#i' => array( 'https://www.youtube.com/oembed', true ),
     53                        '#https?://((m|www)\.)?youtube(-nocookie)?\.com/watch.*#i' => array( 'https://www.youtube.com/oembed', true ),
    5454                        '#https?://((m|www)\.)?youtube\.com/playlist.*#i' => array( 'https://www.youtube.com/oembed', true ),
    5555                        '#https?://youtu\.be/.*#i'                     => array( 'https://www.youtube.com/oembed', true ),
    5656                        '#https?://(.+\.)?vimeo\.com/.*#i'             => array( 'https://vimeo.com/api/oembed.{format}', true ),
  • src/wp-includes/class-wp-customize-manager.php

     
    58535853         * @return mixed
    58545854         */
    58555855        public function _validate_external_header_video( $validity, $value ) {
    5856                 $video = esc_url_raw( $value );
    5857                 if ( $video ) {
    5858                         if ( ! preg_match( '#^https?://(?:www\.)?(?:youtube\.com/watch|youtu\.be/)#', $video ) ) {
     5856        $video = esc_url_raw( $value );
     5857        if ( $video ) {
     5858                        if ( ! preg_match( '#^https?://(?:www\.)?(youtube|youtube-nocookie)\.com/(watch|embed|youtu\.be/)#', $video ) ) {
    58595859                                $validity->add( 'invalid_url', __( 'Please enter a valid YouTube URL.' ) );
    58605860                        }
    5861                 }
    5862                 return $validity;
     5861        }
     5862        return $validity;
    58635863        }
    58645864
    58655865        /**
  • src/wp-includes/embed.php

     
    189189                return;
    190190        }
    191191
    192         wp_embed_register_handler( 'youtube_embed_url', '#https?://(www.)?youtube\.com/(?:v|embed)/([^/]+)#i', 'wp_embed_handler_youtube' );
     192        wp_embed_register_handler( 'youtube_embed_url', '#https?://(www.)?youtube(-nocookie)?\.com/(?:v|embed)/([^/]+)#i', 'wp_embed_handler_youtube' );
    193193
    194194        /**
    195195         * Filters the audio embed handler callback.
     
    228228 */
    229229function wp_embed_handler_youtube( $matches, $attr, $url, $rawattr ) {
    230230        global $wp_embed;
    231         $embed = $wp_embed->autoembed( sprintf( 'https://youtube.com/watch?v=%s', urlencode( $matches[2] ) ) );
     231        $youtube_no_cookie_url = strpos($matches[0], 'youtube-nocookie') !== false;
     232        $protocol = stripos($_SERVER['SERVER_PROTOCOL'],'https') === true ? 'https://' : 'http://';
     233        $host = $protocol . ($youtube_no_cookie_url ? 'youtube-nocookie.com' : 'youtube.com');
     234        $embed = $wp_embed->autoembed( sprintf( '%s/watch?v=%s', $host, urlencode( $matches[3] ) ) );
     235        if ($youtube_no_cookie_url) {
     236                $embed = str_replace("youtube.com", "youtube-nocookie.com", $embed);
     237        }
    232238
    233239        /**
    234240         * Filters the YoutTube embed output.
  • src/wp-includes/theme.php

     
    14611461                ),
    14621462        );
    14631463
    1464         if ( preg_match( '#^https?://(?:www\.)?(?:youtube\.com/watch|youtu\.be/)#', $video_url ) ) {
     1464        if ( preg_match( '#^https?://(?:www\.)?(youtube|youtube-nocookie)\.com/(watch|embed|youtu\.be/)#', $video_url ) ) {
    14651465                $settings['mimeType'] = 'video/x-youtube';
    14661466        } elseif ( ! empty( $video_type['type'] ) ) {
    14671467                $settings['mimeType'] = $video_type['type'];