diff --git src/wp-admin/js/customize-widgets.js src/wp-admin/js/customize-widgets.js
index 25c1eb5b7a..3c1d6c2367 100644
|
|
|
1577 | 1577 | api.Panel.prototype.ready.call( panel ); |
1578 | 1578 | |
1579 | 1579 | panel.deferred.embedded.done(function() { |
1580 | | var panelMetaContainer, noRenderedAreasNotice, shouldShowNotice; |
| 1580 | var panelMetaContainer, noticeContainer, updateNotice, getActiveSectionCount, shouldShowNotice; |
1581 | 1581 | 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>', { |
1583 | 1585 | 'class': 'no-widget-areas-rendered-notice' |
1584 | 1586 | }); |
1585 | | noRenderedAreasNotice.append( $( '<em></em>', { |
1586 | | text: l10n.noAreasRendered |
1587 | | } ) ); |
1588 | | panelMetaContainer.append( noRenderedAreasNotice ); |
| 1587 | panelMetaContainer.append( noticeContainer ); |
1589 | 1588 | |
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 ) { |
1592 | 1596 | 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 | } |
1594 | 1639 | }; |
| 1640 | updateNotice(); |
1595 | 1641 | |
1596 | 1642 | /* |
1597 | 1643 | * Set the initial visibility state for rendered notice. |
1598 | 1644 | * Update the visibility of the notice whenever a reflow happens. |
1599 | 1645 | */ |
1600 | | noRenderedAreasNotice.toggle( shouldShowNotice() ); |
| 1646 | noticeContainer.toggle( shouldShowNotice() ); |
1601 | 1647 | api.previewer.deferred.active.done( function () { |
1602 | | noRenderedAreasNotice.toggle( shouldShowNotice() ); |
| 1648 | noticeContainer.toggle( shouldShowNotice() ); |
1603 | 1649 | }); |
1604 | 1650 | api.bind( 'pane-contents-reflowed', function() { |
1605 | 1651 | var duration = ( 'resolved' === api.previewer.deferred.active.state() ) ? 'fast' : 0; |
| 1652 | updateNotice(); |
1606 | 1653 | if ( shouldShowNotice() ) { |
1607 | | noRenderedAreasNotice.slideDown( duration ); |
| 1654 | noticeContainer.slideDown( duration ); |
1608 | 1655 | } else { |
1609 | | noRenderedAreasNotice.slideUp( duration ); |
| 1656 | noticeContainer.slideUp( duration ); |
1610 | 1657 | } |
1611 | 1658 | }); |
1612 | 1659 | }); |
diff --git src/wp-includes/class-wp-customize-widgets.php src/wp-includes/class-wp-customize-widgets.php
index 0cd2359d56..51d66b1dcf 100644
|
|
final class WP_Customize_Widgets { |
733 | 733 | 'widgetMovedUp' => __( 'Widget moved up' ), |
734 | 734 | 'widgetMovedDown' => __( 'Widget moved down' ), |
735 | 735 | 'noAreasRendered' => __( 'There are no widget areas on the page shown, however other pages in this theme do have them.' ), |
| 736 | /* translators: placeholder is the number of other widget areas registered */ |
| 737 | 'allAreasNotShown' => wp_array_slice_assoc( _n_noop( 'There is %d other widget area registered for this theme but it is not shown on the current page.', 'There are %d other widgets area registered for this theme but they are not shown on the current page.' ), array( 'singular', 'plural' ) ), |
736 | 738 | 'reorderModeOn' => __( 'Reorder mode enabled' ), |
737 | 739 | 'reorderModeOff' => __( 'Reorder mode closed' ), |
738 | 740 | 'reorderLabelOn' => esc_attr__( 'Reorder widgets' ), |