Make WordPress Core

Ticket #39087: 39087.2.diff

File 39087.2.diff, 5.1 KB (added by westonruter, 6 years ago)
  • src/wp-admin/js/customize-widgets.js

    diff --git src/wp-admin/js/customize-widgets.js src/wp-admin/js/customize-widgets.js
    index 25c1eb5b7a..3c1d6c2367 100644
     
    15771577                        api.Panel.prototype.ready.call( panel );
    15781578
    15791579                        panel.deferred.embedded.done(function() {
    1580                                 var panelMetaContainer, noRenderedAreasNotice, shouldShowNotice;
     1580                                var panelMetaContainer, noticeContainer, updateNotice, getActiveSectionCount, shouldShowNotice;
    15811581                                panelMetaContainer = panel.container.find( '.panel-meta' );
    1582                                 noRenderedAreasNotice = $( '<div></div>', {
     1582
     1583                                // @todo This should use the Notifications API introduced to panels. See <https://core.trac.wordpress.org/ticket/38794>.
     1584                                noticeContainer = $( '<div></div>', {
    15831585                                        'class': 'no-widget-areas-rendered-notice'
    15841586                                });
    1585                                 noRenderedAreasNotice.append( $( '<em></em>', {
    1586                                         text: l10n.noAreasRendered
    1587                                 } ) );
    1588                                 panelMetaContainer.append( noRenderedAreasNotice );
     1587                                panelMetaContainer.append( noticeContainer );
    15891588
    1590                                 shouldShowNotice = function() {
    1591                                         return ( 0 === _.filter( panel.sections(), function( section ) {
     1589                                /**
     1590                                 * Get the number of active sections in the panel.
     1591                                 *
     1592                                 * @return {number} Number of active sidebar sections.
     1593                                 */
     1594                                getActiveSectionCount = function() {
     1595                                        return _.filter( panel.sections(), function( section ) {
    15921596                                                return section.active();
    1593                                         } ).length );
     1597                                        } ).length;
     1598                                };
     1599
     1600                                /**
     1601                                 * Determine whether or not the notice should be displayed.
     1602                                 *
     1603                                 * @return {boolean}
     1604                                 */
     1605                                shouldShowNotice = function() {
     1606                                        var activeSectionCount = getActiveSectionCount();
     1607                                        if ( 0 === activeSectionCount ) {
     1608                                                return true;
     1609                                        } else {
     1610                                                return activeSectionCount !== api.Widgets.data.registeredSidebars.length;
     1611                                        }
     1612                                };
     1613
     1614                                /**
     1615                                 * Update the notice.
     1616                                 *
     1617                                 * @returns {void}
     1618                                 */
     1619                                updateNotice = function() {
     1620                                        var activeSectionCount = getActiveSectionCount(), nonRenderedAreaCount, message = '';
     1621                                        noticeContainer.empty();
     1622
     1623                                        if ( 0 === activeSectionCount ) {
     1624                                                message = l10n.noAreasRendered;
     1625                                        } else if ( activeSectionCount !== api.Widgets.data.registeredSidebars.length ) {
     1626                                                nonRenderedAreaCount = api.Widgets.data.registeredSidebars.length - activeSectionCount;
     1627                                                if ( 1 === nonRenderedAreaCount ) {
     1628                                                        message = l10n.allAreasNotShown.singular.replace( '%d', nonRenderedAreaCount );
     1629                                                } else {
     1630                                                        message = l10n.allAreasNotShown.plural.replace( '%d', nonRenderedAreaCount );
     1631                                                }
     1632                                        }
     1633
     1634                                        if ( message ) {
     1635                                                noticeContainer.append( $( '<em></em>', {
     1636                                                        text: message
     1637                                                } ) );
     1638                                        }
    15941639                                };
     1640                                updateNotice();
    15951641
    15961642                                /*
    15971643                                 * Set the initial visibility state for rendered notice.
    15981644                                 * Update the visibility of the notice whenever a reflow happens.
    15991645                                 */
    1600                                 noRenderedAreasNotice.toggle( shouldShowNotice() );
     1646                                noticeContainer.toggle( shouldShowNotice() );
    16011647                                api.previewer.deferred.active.done( function () {
    1602                                         noRenderedAreasNotice.toggle( shouldShowNotice() );
     1648                                        noticeContainer.toggle( shouldShowNotice() );
    16031649                                });
    16041650                                api.bind( 'pane-contents-reflowed', function() {
    16051651                                        var duration = ( 'resolved' === api.previewer.deferred.active.state() ) ? 'fast' : 0;
     1652                                        updateNotice();
    16061653                                        if ( shouldShowNotice() ) {
    1607                                                 noRenderedAreasNotice.slideDown( duration );
     1654                                                noticeContainer.slideDown( duration );
    16081655                                        } else {
    1609                                                 noRenderedAreasNotice.slideUp( duration );
     1656                                                noticeContainer.slideUp( duration );
    16101657                                        }
    16111658                                });
    16121659                        });
  • src/wp-includes/class-wp-customize-widgets.php

    diff --git src/wp-includes/class-wp-customize-widgets.php src/wp-includes/class-wp-customize-widgets.php
    index 0cd2359d56..e88b2b65e0 100644
    final class WP_Customize_Widgets { 
    732732                                'error'            => __( 'An error has occurred. Please reload the page and try again.' ),
    733733                                'widgetMovedUp'    => __( 'Widget moved up' ),
    734734                                'widgetMovedDown'  => __( 'Widget moved down' ),
    735                                 'noAreasRendered'  => __( 'There are no widget areas on the page shown, however other pages in this theme do have them.' ),
     735                                'noAreasRendered'  => __( 'You can navigate to other pages on your site while using the customizer to view and edit the widgets displayed on those pages.' ),
     736                                'allAreasNotShown' => wp_array_slice_assoc(
     737                                        /* translators: placeholder is the number of other widget areas registered */
     738                                        _n_noop(
     739                                                'Your theme has %d other widget area, but this particular page doesn\'t display it.',
     740                                                'Your theme has %d other widget areas, but this particular page doesn\'t display them.'
     741                                        ),
     742                                        array( 'singular', 'plural' )
     743                                ),
    736744                                'reorderModeOn'    => __( 'Reorder mode enabled' ),
    737745                                'reorderModeOff'   => __( 'Reorder mode closed' ),
    738746                                'reorderLabelOn'   => esc_attr__( 'Reorder widgets' ),
     747                                /* translators: placeholder is the count for the number of widgets found */
    739748                                'widgetsFound'     => __( 'Number of widgets found: %d' ),
    740749                                'noWidgetsFound'   => __( 'No widgets found.' ),
    741750                        ),