diff --git a/src/wp-admin/js/customize-controls.js b/src/wp-admin/js/customize-controls.js index 17159a0964..ab834680ec 100644 --- a/src/wp-admin/js/customize-controls.js +++ b/src/wp-admin/js/customize-controls.js @@ -5284,6 +5284,26 @@ } ); } ); + // Toggle visibility of Header Video notice when active state change. + api.control( 'header_video', function( headerVideoControl ) { + headerVideoControl.deferred.embedded.done( function() { + var toggleNotice = function() { + var section = api.section( headerVideoControl.section() ), notice; + if ( ! section ) { + return; + } + notice = section.container.find( '.header-video-not-currently-previewable:first' ); + if ( headerVideoControl.active.get() ) { + notice.stop().slideUp( 'fast' ); + } else { + notice.stop().slideDown( 'fast' ); + } + }; + toggleNotice(); + headerVideoControl.active.bind( toggleNotice ); + } ); + } ); + // Update the setting validities. api.previewer.bind( 'selective-refresh-setting-validities', function handleSelectiveRefreshedSettingValidities( settingValidities ) { api._handleSettingValidities( { diff --git a/src/wp-includes/class-wp-customize-manager.php b/src/wp-includes/class-wp-customize-manager.php index 34aeba767d..54c3f0eac1 100644 --- a/src/wp-includes/class-wp-customize-manager.php +++ b/src/wp-includes/class-wp-customize-manager.php @@ -3407,7 +3407,12 @@ final class WP_Customize_Manager { if ( current_theme_supports( 'custom-header', 'video' ) ) { $title = __( 'Header Media' ); - $description = __( 'If you add a video, the image will be used as a fallback while the video loads.' ); + $description = '

' . __( 'If you add a video, the image will be used as a fallback while the video loads.' ) . '

'; + + // @todo Customizer sections should support having notifications just like controls do. See . + $description .= ''; $width = absint( get_theme_support( 'custom-header', 'width' ) ); $height = absint( get_theme_support( 'custom-header', 'height' ) ); if ( $width && $height ) { @@ -3478,13 +3483,15 @@ final class WP_Customize_Manager { 'description' => $control_description, 'section' => 'header_image', 'mime_type' => 'video', + // @todo These button_labels can be removed once WP_Customize_Media_Control provides mime_type-specific labels automatically. See . 'button_labels' => array( 'select' => __( 'Select Video' ), 'change' => __( 'Change Video' ), 'placeholder' => __( 'No video selected' ), 'frame_title' => __( 'Select Video' ), 'frame_button' => __( 'Choose Video' ), - ) + ), + 'active_callback' => 'is_front_page', ) ) ); $this->add_control( 'external_header_video', array( @@ -3492,6 +3499,7 @@ final class WP_Customize_Manager { 'type' => 'url', 'description' => __( 'Or, enter a YouTube URL:' ), 'section' => 'header_image', + 'active_callback'=> 'is_front_page', ) ); $this->add_control( new WP_Customize_Header_Image_Control( $this ) );