WordPress.org

Make WordPress Core

Ticket #27406: 27406.disallow-single-section-panels.diff

File 27406.disallow-single-section-panels.diff, 1011 bytes (added by celloexpressions, 4 years ago)

If a panel has only one section, display the section in the top level with the panel context in its title.

  • src/wp-includes/class-wp-customize-manager.php

     
    887887                                continue;
    888888                        }
    889889
     890                        // If there is only one section in the panel, don't display the panel.
     891                        // Display the section in the top level instead, and re-sort.
     892                        if ( 1 === count( $panel->sections ) ) {
     893                                $section = $panel->sections[0];
     894                                // Add the panel title to the section title for context.
     895                                $title = $panel->title . _x( ': ', 'Customizer panel-title: section-title separator when panel is displayed as the single section that it contains.' ) . $section->title;
     896                                $section->title = $title;
     897                                $this->sections[] = $section;
     898                                usort( $this->sections, array( $this, '_cmp_priority' ) );
     899                                continue;
     900                        }
     901
    890902                        usort( $panel->sections, array( $this, '_cmp_priority' ) );
    891903                        $panels[] = $panel;
    892904                }