WordPress.org

Make WordPress Core

Changeset 39237


Ignore:
Timestamp:
11/15/2016 03:46:14 AM (19 months ago)
Author:
westonruter
Message:

Customize: Only show video header controls if previewing front page; show explanatory notice when controls are hidden.

Also include todo for the header_video control's button_labels. See #38796.

Props westonruter, joemcgill, celloexpressions.
Fixes #38778.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/customize-controls.js

    r39199 r39237  
    52855285        } );
    52865286
     5287        // Toggle visibility of Header Video notice when active state change.
     5288        api.control( 'header_video', function( headerVideoControl ) {
     5289            headerVideoControl.deferred.embedded.done( function() {
     5290                var toggleNotice = function() {
     5291                    var section = api.section( headerVideoControl.section() ), notice;
     5292                    if ( ! section ) {
     5293                        return;
     5294                    }
     5295                    notice = section.container.find( '.header-video-not-currently-previewable:first' );
     5296                    if ( headerVideoControl.active.get() ) {
     5297                        notice.stop().slideUp( 'fast' );
     5298                    } else {
     5299                        notice.stop().slideDown( 'fast' );
     5300                    }
     5301                };
     5302                toggleNotice();
     5303                headerVideoControl.active.bind( toggleNotice );
     5304            } );
     5305        } );
     5306
    52875307        // Update the setting validities.
    52885308        api.previewer.bind( 'selective-refresh-setting-validities', function handleSelectiveRefreshedSettingValidities( settingValidities ) {
  • trunk/src/wp-includes/class-wp-customize-manager.php

    r39234 r39237  
    34083408        if ( current_theme_supports( 'custom-header', 'video' ) ) {
    34093409            $title = __( 'Header Media' );
    3410             $description = __( 'If you add a video, the image will be used as a fallback while the video loads.' );
     3410            $description = '<p>' . __( 'If you add a video, the image will be used as a fallback while the video loads.' ) . '</p>';
     3411
     3412            // @todo Customizer sections should support having notifications just like controls do. See <https://core.trac.wordpress.org/ticket/38794>.
     3413            $description .= '<div class="customize-control-notifications-container header-video-not-currently-previewable" style="display: none"><ul>';
     3414            $description .= '<li class="notice notice-info">' . __( 'This theme doesn\'t support video headers on this page. Navigate to the front page or another page that supports video headers.' ) . '</li>';
     3415            $description .= '</ul></div>';
    34113416            $width = absint( get_theme_support( 'custom-header', 'width' ) );
    34123417            $height = absint( get_theme_support( 'custom-header', 'height' ) );
     
    34793484            'section'        => 'header_image',
    34803485            'mime_type'      => 'video',
     3486            // @todo These button_labels can be removed once WP_Customize_Media_Control provides mime_type-specific labels automatically. See <https://core.trac.wordpress.org/ticket/38796>.
    34813487            'button_labels'  => array(
    34823488                'select'       => __( 'Select Video' ),
     
    34853491                'frame_title'  => __( 'Select Video' ),
    34863492                'frame_button' => __( 'Choose Video' ),
    3487             )
     3493            ),
     3494            'active_callback' => 'is_front_page',
    34883495        ) ) );
    34893496
     
    34933500            'description'    => __( 'Or, enter a YouTube URL:' ),
    34943501            'section'        => 'header_image',
     3502            'active_callback'=> 'is_front_page',
    34953503        ) );
    34963504
Note: See TracChangeset for help on using the changeset viewer.