Make WordPress Core


Ignore:
Timestamp:
09/20/2016 12:46:54 AM (8 years ago)
Author:
westonruter
Message:

Customize: Let static_front_page section be contextually active based on whether there are any published pages.

If there are no pages when the customizer is opened, the static_front_page section will be hidden. As soon as a page is created in the customizer session, the static_front_page section will be revealed. Previously the section would not be registered if there were no pages. Page stubs created via nav menus will appear in the dropdown-pages controls for page_for_posts and page_on_front, and such page stubs will thus cause the static_front_page section to appear. Plugins that facilitate page creation in the customizer by filtering get_pages will also cause the section to appear.

See #34923.
Fixes #38013.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-customize-control.php

    r38470 r38624  
    534534                <?php endif; ?>
    535535
    536                 <?php $dropdown = wp_dropdown_pages(
     536                <?php
     537                $dropdown_name = '_customize-dropdown-pages-' . $this->id;
     538                $show_option_none = __( '&mdash; Select &mdash;' );
     539                $option_none_value = '0';
     540                $dropdown = wp_dropdown_pages(
    537541                    array(
    538                         'name'              => '_customize-dropdown-pages-' . $this->id,
     542                        'name'              => $dropdown_name,
    539543                        'echo'              => 0,
    540                         'show_option_none'  => __( '&mdash; Select &mdash;' ),
    541                         'option_none_value' => '0',
     544                        'show_option_none'  => $show_option_none,
     545                        'option_none_value' => $option_none_value,
    542546                        'selected'          => $this->value(),
    543547                    )
    544548                );
     549                if ( empty( $dropdown ) ) {
     550                    $dropdown = sprintf( '<select id="%1$s" name="%1$s">', esc_attr( $dropdown_name ) );
     551                    $dropdown .= sprintf( '<option value="%1$s">%2$s</option>', esc_attr( $option_none_value ), esc_html( $show_option_none ) );
     552                    $dropdown .= '</select>';
     553                }
    545554
    546555                // Hackily add in the data link parameter.
Note: See TracChangeset for help on using the changeset viewer.