Make WordPress Core

Ticket #44610: nocookie2-header.patch

File nocookie2-header.patch, 1.9 KB (added by adakaleh, 2 years ago)

Allow yt-nocookie embeds within headers

  • src/js/_enqueues/wp/custom-header.js

    diff --git a/src/js/_enqueues/wp/custom-header.js b/src/js/_enqueues/wp/custom-header.js
    index ae43f56174..eae8f12227 100644
    a b  
    390390                                height: this.settings.height,
    391391                                width: this.settings.width,
    392392                                videoId: this.settings.videoUrl.match( VIDEO_ID_REGEX )[1],
     393                                host: location.protocol + ( ( this.settings.videoUrl.indexOf( 'youtube-nocookie' ) !== -1 ) ? '//www.youtube-nocookie.com' : '//www.youtube.com' ),
    393394                                events: {
    394395                                        onReady: function( e ) {
    395396                                                e.target.mute();
  • src/wp-includes/class-wp-customize-manager.php

    diff --git a/src/wp-includes/class-wp-customize-manager.php b/src/wp-includes/class-wp-customize-manager.php
    index 3b3259c573..ff2c05c557 100644
    a b final class WP_Customize_Manager { 
    60816081        public function _validate_external_header_video( $validity, $value ) {
    60826082                $video = sanitize_url( $value );
    60836083                if ( $video ) {
    6084                         if ( ! preg_match( '#^https?://(?:www\.)?(?:youtube\.com/watch|youtu\.be/)#', $video ) ) {
     6084                        if ( ! preg_match( '#^https?://(?:www\.)?(?:youtube(?:-nocookie)?\.com/(?:watch|embed)|youtu\.be/)#', $video ) ) {
    60856085                                $validity->add( 'invalid_url', __( 'Please enter a valid YouTube URL.' ) );
    60866086                        }
    60876087                }
  • src/wp-includes/theme.php

    diff --git a/src/wp-includes/theme.php b/src/wp-includes/theme.php
    index 3c7b297b2a..0e6d37300a 100644
    a b function get_header_video_settings() { 
    16471647                ),
    16481648        );
    16491649
    1650         if ( preg_match( '#^https?://(?:www\.)?(?:youtube\.com/watch|youtu\.be/)#', $video_url ) ) {
     1650        if ( preg_match( '#^https?://(?:www\.)?(?:youtube(?:-nocookie)?\.com/(?:watch|embed)|youtu\.be/)#', $video_url ) ) {
    16511651                $settings['mimeType'] = 'video/x-youtube';
    16521652        } elseif ( ! empty( $video_type['type'] ) ) {
    16531653                $settings['mimeType'] = $video_type['type'];