diff --git src/wp-admin/js/customize-nav-menus.js src/wp-admin/js/customize-nav-menus.js
index 6dcdadc..6731c34 100644
|
|
|
104 | 104 | deferred.resolve( response ); |
105 | 105 | api.Menus.insertedAutoDrafts.push( response.post_id ); |
106 | 106 | api( 'nav_menus_created_posts' ).set( _.clone( api.Menus.insertedAutoDrafts ) ); |
| 107 | |
| 108 | if ( 'page' === params.post_type ) { |
| 109 | |
| 110 | // Activate static front page controls as this could be the first page created. |
| 111 | if ( api.section.has( 'static_front_page' ) ) { |
| 112 | api.section( 'static_front_page' ).activate(); |
| 113 | } |
| 114 | |
| 115 | // Add new page to dropdown-pages controls. |
| 116 | api.control.each( function( control ) { |
| 117 | var select; |
| 118 | if ( 'dropdown-pages' === control.params.type ) { |
| 119 | select = control.container.find( 'select[name^="_customize-dropdown-pages-"]' ); |
| 120 | select.append( new Option( params.post_title, response.post_id ) ); |
| 121 | } |
| 122 | } ); |
| 123 | } |
107 | 124 | } |
108 | 125 | } ); |
109 | 126 | |
diff --git src/wp-includes/class-wp-customize-control.php src/wp-includes/class-wp-customize-control.php
index 3f4877f..f6c0076 100644
|
|
class WP_Customize_Control { |
533 | 533 | <span class="description customize-control-description"><?php echo $this->description; ?></span> |
534 | 534 | <?php endif; ?> |
535 | 535 | |
536 | | <?php $dropdown = wp_dropdown_pages( |
| 536 | <?php |
| 537 | $dropdown_name = '_customize-dropdown-pages-' . $this->id; |
| 538 | $show_option_none = __( '— Select —' ); |
| 539 | $option_none_value = '0'; |
| 540 | $dropdown = wp_dropdown_pages( |
537 | 541 | array( |
538 | | 'name' => '_customize-dropdown-pages-' . $this->id, |
| 542 | 'name' => $dropdown_name, |
539 | 543 | 'echo' => 0, |
540 | | 'show_option_none' => __( '— Select —' ), |
541 | | 'option_none_value' => '0', |
| 544 | 'show_option_none' => $show_option_none, |
| 545 | 'option_none_value' => $option_none_value, |
542 | 546 | 'selected' => $this->value(), |
543 | 547 | ) |
544 | 548 | ); |
| 549 | if ( empty( $dropdown ) ) { |
| 550 | $dropdown = sprintf( '<select name="%s">', esc_attr( $dropdown_name ) ); |
| 551 | $dropdown .= sprintf( '<option value="%s">%s</option>', esc_attr( $option_none_value ), esc_html( $show_option_none ) ); |
| 552 | $dropdown .= '</select>'; |
| 553 | } |
545 | 554 | |
546 | 555 | // Hackily add in the data link parameter. |
547 | 556 | $dropdown = str_replace( '<select', '<select ' . $this->get_link(), $dropdown ); |
diff --git src/wp-includes/class-wp-customize-manager.php src/wp-includes/class-wp-customize-manager.php
index 668989b..17c452c 100644
|
|
final class WP_Customize_Manager { |
2255 | 2255 | } |
2256 | 2256 | |
2257 | 2257 | /* Static Front Page */ |
2258 | | // #WP19627 |
2259 | | |
2260 | | // Replicate behavior from options-reading.php and hide front page options if there are no pages |
2261 | | if ( get_pages() ) { |
2262 | | $this->add_section( 'static_front_page', array( |
2263 | | 'title' => __( 'Static Front Page' ), |
2264 | | // 'theme_supports' => 'static-front-page', |
2265 | | 'priority' => 120, |
2266 | | 'description' => __( 'Your theme supports a static front page.' ), |
2267 | | ) ); |
| 2258 | // See also https://core.trac.wordpress.org/ticket/19627 which introduces the the static-front-page theme_support. |
| 2259 | |
| 2260 | // Replicate behavior from options-reading.php. |
| 2261 | $this->add_section( 'static_front_page', array( |
| 2262 | 'title' => __( 'Static Front Page' ), |
| 2263 | 'priority' => 120, |
| 2264 | 'description' => __( 'Your theme supports a static front page.' ), |
| 2265 | 'active_callback' => array( $this, 'has_published_pages' ), |
| 2266 | ) ); |
2268 | 2267 | |
2269 | | $this->add_setting( 'show_on_front', array( |
2270 | | 'default' => get_option( 'show_on_front' ), |
2271 | | 'capability' => 'manage_options', |
2272 | | 'type' => 'option', |
2273 | | // 'theme_supports' => 'static-front-page', |
2274 | | ) ); |
| 2268 | $this->add_setting( 'show_on_front', array( |
| 2269 | 'default' => get_option( 'show_on_front' ), |
| 2270 | 'capability' => 'manage_options', |
| 2271 | 'type' => 'option', |
| 2272 | ) ); |
2275 | 2273 | |
2276 | | $this->add_control( 'show_on_front', array( |
2277 | | 'label' => __( 'Front page displays' ), |
2278 | | 'section' => 'static_front_page', |
2279 | | 'type' => 'radio', |
2280 | | 'choices' => array( |
2281 | | 'posts' => __( 'Your latest posts' ), |
2282 | | 'page' => __( 'A static page' ), |
2283 | | ), |
2284 | | ) ); |
| 2274 | $this->add_control( 'show_on_front', array( |
| 2275 | 'label' => __( 'Front page displays' ), |
| 2276 | 'section' => 'static_front_page', |
| 2277 | 'type'=> 'radio', |
| 2278 | 'choices' => array( |
| 2279 | 'posts' => __( 'Your latest posts' ), |
| 2280 | 'page' => __( 'A static page' ), |
| 2281 | ), |
| 2282 | ) ); |
2285 | 2283 | |
2286 | | $this->add_setting( 'page_on_front', array( |
2287 | | 'type' => 'option', |
2288 | | 'capability' => 'manage_options', |
2289 | | // 'theme_supports' => 'static-front-page', |
2290 | | ) ); |
| 2284 | $this->add_setting( 'page_on_front', array( |
| 2285 | 'type' => 'option', |
| 2286 | 'capability' => 'manage_options', |
| 2287 | ) ); |
2291 | 2288 | |
2292 | | $this->add_control( 'page_on_front', array( |
2293 | | 'label' => __( 'Front page' ), |
2294 | | 'section' => 'static_front_page', |
2295 | | 'type' => 'dropdown-pages', |
2296 | | ) ); |
| 2289 | $this->add_control( 'page_on_front', array( |
| 2290 | 'label' => __( 'Front page' ), |
| 2291 | 'section' => 'static_front_page', |
| 2292 | 'type' => 'dropdown-pages', |
| 2293 | ) ); |
2297 | 2294 | |
2298 | | $this->add_setting( 'page_for_posts', array( |
2299 | | 'type' => 'option', |
2300 | | 'capability' => 'manage_options', |
2301 | | // 'theme_supports' => 'static-front-page', |
2302 | | ) ); |
| 2295 | $this->add_setting( 'page_for_posts', array( |
| 2296 | 'type' => 'option', |
| 2297 | 'capability' => 'manage_options', |
| 2298 | ) ); |
2303 | 2299 | |
2304 | | $this->add_control( 'page_for_posts', array( |
2305 | | 'label' => __( 'Posts page' ), |
2306 | | 'section' => 'static_front_page', |
2307 | | 'type' => 'dropdown-pages', |
2308 | | ) ); |
| 2300 | $this->add_control( 'page_for_posts', array( |
| 2301 | 'label' => __( 'Posts page' ), |
| 2302 | 'section' => 'static_front_page', |
| 2303 | 'type' => 'dropdown-pages', |
| 2304 | ) ); |
| 2305 | } |
| 2306 | |
| 2307 | /** |
| 2308 | * Return whether there are published pages. |
| 2309 | * |
| 2310 | * Used as active callback for static front page section and controls. |
| 2311 | * |
| 2312 | * @access private |
| 2313 | * @since 4.7.0 |
| 2314 | * |
| 2315 | * @returns bool Whether there are published (or to be published) pages. |
| 2316 | */ |
| 2317 | public function has_published_pages() { |
| 2318 | |
| 2319 | $setting = $this->get_setting( 'nav_menus_created_posts' ); |
| 2320 | if ( $setting ) { |
| 2321 | foreach ( $setting->value() as $post_id ) { |
| 2322 | if ( 'page' === get_post_type( $post_id ) ) { |
| 2323 | return true; |
| 2324 | } |
| 2325 | } |
2309 | 2326 | } |
| 2327 | |
| 2328 | return 0 !== count( get_pages() ); |
2310 | 2329 | } |
2311 | 2330 | |
2312 | 2331 | /** |