Make WordPress Core

Ticket #38013: 38013.0.diff

File 38013.0.diff, 4.0 KB (added by westonruter, 8 years ago)
  • src/wp-includes/class-wp-customize-manager.php

    diff --git src/wp-includes/class-wp-customize-manager.php src/wp-includes/class-wp-customize-manager.php
    index 668989b..258c97b 100644
    final class WP_Customize_Manager { 
    22552255                }
    22562256
    22572257                /* Static Front Page */
    2258                 // #WP19627
     2258                // See also https://core.trac.wordpress.org/ticket/19627 which introduces the the static-front-page theme_support.
    22592259
    22602260                // 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                         ) );
     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                ) );
    22682267
    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                ) );
    22752273
    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                        'active_callback' => array( $this, 'has_published_pages' ),
     2283                ) );
    22852284
    2286                         $this->add_setting( 'page_on_front', array(
    2287                                 'type'       => 'option',
    2288                                 'capability' => 'manage_options',
    2289                         //      'theme_supports' => 'static-front-page',
    2290                         ) );
     2285                $this->add_setting( 'page_on_front', array(
     2286                        'type' => 'option',
     2287                        'capability' => 'manage_options',
     2288                ) );
    22912289
    2292                         $this->add_control( 'page_on_front', array(
    2293                                 'label'      => __( 'Front page' ),
    2294                                 'section'    => 'static_front_page',
    2295                                 'type'       => 'dropdown-pages',
    2296                         ) );
     2290                $this->add_control( 'page_on_front', array(
     2291                        'label' => __( 'Front page' ),
     2292                        'section' => 'static_front_page',
     2293                        'type' => 'dropdown-pages',
     2294                        'active_callback' => array( $this, 'has_published_pages' ),
     2295                ) );
    22972296
    2298                         $this->add_setting( 'page_for_posts', array(
    2299                                 'type'           => 'option',
    2300                                 'capability'     => 'manage_options',
    2301                         //      'theme_supports' => 'static-front-page',
    2302                         ) );
     2297                $this->add_setting( 'page_for_posts', array(
     2298                        'type' => 'option',
     2299                        'capability' => 'manage_options',
     2300                ) );
    23032301
    2304                         $this->add_control( 'page_for_posts', array(
    2305                                 'label'      => __( 'Posts page' ),
    2306                                 'section'    => 'static_front_page',
    2307                                 'type'       => 'dropdown-pages',
    2308                         ) );
    2309                 }
     2302                $this->add_control( 'page_for_posts', array(
     2303                        'label' => __( 'Posts page' ),
     2304                        'section' => 'static_front_page',
     2305                        'type' => 'dropdown-pages',
     2306                        'active_callback' => array( $this, 'has_published_pages' ),
     2307                ) );
     2308        }
     2309
     2310        /**
     2311         * Return whether there are published pages.
     2312         *
     2313         * Used as active callback for static front page section and controls.
     2314         *
     2315         * @access private
     2316         * @since 4.7.0
     2317         *
     2318         * @returns bool Whether there are published (or to be published) pages.
     2319         */
     2320        public function has_published_pages() {
     2321
     2322                // @todo Also look to see if there are any pages among in $this->get_setting( 'nav_menus_created_posts' )->value().
     2323                return 0 !== count( get_pages( array(
     2324                        'post_type' => 'page',
     2325                        'post_status' => 'publish',
     2326                        'number' => 1,
     2327                ) ) );
    23102328        }
    23112329
    23122330        /**