diff --git src/wp-admin/css/customize-controls.css src/wp-admin/css/customize-controls.css
index 039477a37c..fbcfe64101 100644
|
|
body { |
303 | 303 | transition: 0.18s transform cubic-bezier(0.645, 0.045, 0.355, 1), 0.18s -webkit-transform cubic-bezier(0.645, 0.045, 0.355, 1); /* easeInOutCubic */ |
304 | 304 | } |
305 | 305 | |
| 306 | #customize-theme-controls .customize-pane-child.skip-transition { |
| 307 | -webkit-transition: none; |
| 308 | transition: none; |
| 309 | } |
| 310 | |
306 | 311 | #customize-info, |
307 | 312 | #customize-theme-controls .customize-pane-parent { |
308 | 313 | position: relative; |
diff --git src/wp-admin/js/customize-controls.js src/wp-admin/js/customize-controls.js
index e8f19dd7c7..c5d5be4969 100644
|
|
|
711 | 711 | var construct = this, |
712 | 712 | content = construct.contentContainer, |
713 | 713 | overlay = content.closest( '.wp-full-overlay' ), |
714 | | elements, transitionEndCallback; |
| 714 | elements, transitionEndCallback, transitionParentPane; |
715 | 715 | |
716 | 716 | // Determine set of elements that are affected by the animation. |
717 | 717 | elements = overlay.add( content ); |
718 | | if ( _.isUndefined( construct.panel ) || '' === construct.panel() ) { |
| 718 | |
| 719 | if ( ! construct.panel || '' === construct.panel() ) { |
| 720 | transitionParentPane = true; |
| 721 | } else if ( api.panel( construct.panel() ).contentContainer.hasClass( 'skip-transition' ) ) { |
| 722 | transitionParentPane = true; |
| 723 | } else { |
| 724 | transitionParentPane = false; |
| 725 | } |
| 726 | if ( transitionParentPane ) { |
719 | 727 | elements = elements.add( '#customize-info, .customize-pane-parent' ); |
720 | 728 | } |
721 | 729 | |
… |
… |
|
996 | 1004 | overlay = section.headContainer.closest( '.wp-full-overlay' ), |
997 | 1005 | backBtn = content.find( '.customize-section-back' ), |
998 | 1006 | sectionTitle = section.headContainer.find( '.accordion-section-title' ).first(), |
999 | | expand; |
| 1007 | expand, panel; |
1000 | 1008 | |
1001 | 1009 | if ( expanded && ! content.hasClass( 'open' ) ) { |
1002 | 1010 | |
… |
… |
|
1044 | 1052 | } |
1045 | 1053 | |
1046 | 1054 | } else if ( ! expanded && content.hasClass( 'open' ) ) { |
| 1055 | if ( section.panel() ) { |
| 1056 | panel = api.panel( section.panel() ); |
| 1057 | if ( panel.contentContainer.hasClass( 'skip-transition' ) ) { |
| 1058 | panel.collapse(); |
| 1059 | } |
| 1060 | } |
1047 | 1061 | section._animateChangeExpanded( function() { |
1048 | 1062 | backBtn.attr( 'tabindex', '-1' ); |
1049 | 1063 | sectionTitle.attr( 'tabindex', '0' ); |
… |
… |
|
1722 | 1736 | overlay = accordionSection.closest( '.wp-full-overlay' ), |
1723 | 1737 | container = accordionSection.closest( '.wp-full-overlay-sidebar-content' ), |
1724 | 1738 | topPanel = panel.headContainer.find( '.accordion-section-title' ), |
1725 | | backBtn = accordionSection.find( '.customize-panel-back' ); |
| 1739 | backBtn = accordionSection.find( '.customize-panel-back' ), |
| 1740 | childSections = panel.sections(), |
| 1741 | skipTransition; |
1726 | 1742 | |
1727 | 1743 | if ( expanded && ! accordionSection.hasClass( 'current-panel' ) ) { |
1728 | 1744 | // Collapse any sibling sections/panels |
… |
… |
|
1737 | 1753 | } |
1738 | 1754 | }); |
1739 | 1755 | |
1740 | | panel._animateChangeExpanded( function() { |
1741 | | topPanel.attr( 'tabindex', '-1' ); |
1742 | | backBtn.attr( 'tabindex', '0' ); |
| 1756 | if ( panel.params.autoExpandSoleSection && 1 === childSections.length && childSections[0].active.get() ) { |
| 1757 | accordionSection.addClass( 'current-panel skip-transition' ); |
| 1758 | overlay.addClass( 'in-sub-panel' ); |
1743 | 1759 | |
1744 | | backBtn.focus(); |
1745 | | accordionSection.css( 'top', '' ); |
1746 | | container.scrollTop( 0 ); |
| 1760 | childSections[0].expand( { |
| 1761 | completeCallback: args.completeCallback |
| 1762 | } ); |
| 1763 | } else { |
| 1764 | panel._animateChangeExpanded( function() { |
| 1765 | topPanel.attr( 'tabindex', '-1' ); |
| 1766 | backBtn.attr( 'tabindex', '0' ); |
1747 | 1767 | |
1748 | | if ( args.completeCallback ) { |
1749 | | args.completeCallback(); |
1750 | | } |
1751 | | } ); |
| 1768 | backBtn.focus(); |
| 1769 | accordionSection.css( 'top', '' ); |
| 1770 | container.scrollTop( 0 ); |
| 1771 | |
| 1772 | if ( args.completeCallback ) { |
| 1773 | args.completeCallback(); |
| 1774 | } |
| 1775 | } ); |
| 1776 | |
| 1777 | accordionSection.addClass( 'current-panel' ); |
| 1778 | overlay.addClass( 'in-sub-panel' ); |
| 1779 | } |
1752 | 1780 | |
1753 | | overlay.addClass( 'in-sub-panel' ); |
1754 | | accordionSection.addClass( 'current-panel' ); |
1755 | 1781 | api.state( 'expandedPanel' ).set( panel ); |
1756 | 1782 | |
1757 | 1783 | } else if ( ! expanded && accordionSection.hasClass( 'current-panel' ) ) { |
1758 | | panel._animateChangeExpanded( function() { |
1759 | | topPanel.attr( 'tabindex', '0' ); |
1760 | | backBtn.attr( 'tabindex', '-1' ); |
| 1784 | skipTransition = accordionSection.hasClass( 'skip-transition' ); |
| 1785 | if ( ! skipTransition ) { |
| 1786 | panel._animateChangeExpanded( function() { |
| 1787 | topPanel.attr( 'tabindex', '0' ); |
| 1788 | backBtn.attr( 'tabindex', '-1' ); |
1761 | 1789 | |
1762 | | topPanel.focus(); |
1763 | | accordionSection.css( 'top', '' ); |
| 1790 | topPanel.focus(); |
| 1791 | accordionSection.css( 'top', '' ); |
1764 | 1792 | |
1765 | | if ( args.completeCallback ) { |
1766 | | args.completeCallback(); |
1767 | | } |
1768 | | } ); |
| 1793 | if ( args.completeCallback ) { |
| 1794 | args.completeCallback(); |
| 1795 | } |
| 1796 | } ); |
| 1797 | } else { |
| 1798 | accordionSection.removeClass( 'skip-transition' ); |
| 1799 | } |
1769 | 1800 | |
1770 | 1801 | overlay.removeClass( 'in-sub-panel' ); |
1771 | 1802 | accordionSection.removeClass( 'current-panel' ); |
diff --git src/wp-includes/class-wp-customize-panel.php src/wp-includes/class-wp-customize-panel.php
index 46e604a9a6..87ae392e97 100644
|
|
class WP_Customize_Panel { |
104 | 104 | public $description = ''; |
105 | 105 | |
106 | 106 | /** |
| 107 | * Auto-expand a section in a panel when the panel is expanded when the panel only has the one section. |
| 108 | * |
| 109 | * @since 4.7.4 |
| 110 | * @access public |
| 111 | * @var bool |
| 112 | */ |
| 113 | public $auto_expand_sole_section = false; |
| 114 | |
| 115 | /** |
107 | 116 | * Customizer sections for this panel. |
108 | 117 | * |
109 | 118 | * @since 4.0.0 |
… |
… |
class WP_Customize_Panel { |
219 | 228 | $array['content'] = $this->get_content(); |
220 | 229 | $array['active'] = $this->active(); |
221 | 230 | $array['instanceNumber'] = $this->instance_number; |
| 231 | $array['autoExpandSoleSection'] = $this->auto_expand_sole_section; |
222 | 232 | return $array; |
223 | 233 | } |
224 | 234 | |
diff --git src/wp-includes/class-wp-customize-widgets.php src/wp-includes/class-wp-customize-widgets.php
index 2522ac8b0b..6d83181883 100644
|
|
final class WP_Customize_Widgets { |
416 | 416 | $this->manager->add_setting( $setting_id, $setting_args ); |
417 | 417 | } |
418 | 418 | |
| 419 | $panel_help_text = __( 'Widgets are independent sections of content that can be placed into widgetized areas provided by your theme (commonly called sidebars).' ); |
419 | 420 | $this->manager->add_panel( 'widgets', array( |
420 | 421 | 'type' => 'widgets', |
421 | 422 | 'title' => __( 'Widgets' ), |
422 | | 'description' => __( 'Widgets are independent sections of content that can be placed into widgetized areas provided by your theme (commonly called sidebars).' ), |
| 423 | 'description' => $panel_help_text, |
423 | 424 | 'priority' => 110, |
424 | 425 | 'active_callback' => array( $this, 'is_panel_active' ), |
| 426 | 'auto_expand_sole_section' => true, |
425 | 427 | ) ); |
426 | 428 | |
427 | 429 | foreach ( $sidebars_widgets as $sidebar_id => $sidebar_widget_ids ) { |
… |
… |
final class WP_Customize_Widgets { |
451 | 453 | |
452 | 454 | $section_args = array( |
453 | 455 | 'title' => $wp_registered_sidebars[ $sidebar_id ]['name'], |
454 | | 'description' => $wp_registered_sidebars[ $sidebar_id ]['description'], |
| 456 | 'description' => sprintf( '<p>%s</p><p>%s</p>', $panel_help_text, $wp_registered_sidebars[ $sidebar_id ]['description'] ), |
| 457 | 'description_hidden' => true, |
455 | 458 | 'priority' => array_search( $sidebar_id, array_keys( $wp_registered_sidebars ) ), |
456 | 459 | 'panel' => 'widgets', |
457 | 460 | 'sidebar_id' => $sidebar_id, |