Make WordPress Core

Changeset 31234


Ignore:
Timestamp:
01/18/2015 06:00:18 AM (12 years ago)
Author:
SergeyBiryukov
Message:

Customizer: Replicate behavior from options-reading.php and hide front page options if there are no pages.

props Clorith.
fixes #27630.

File:
1 edited

Legend:

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

    r31211 r31234  
    12001200                // #WP19627
    12011201
    1202                 $this->add_section( 'static_front_page', array(
    1203                         'title'          => __( 'Static Front Page' ),
    1204                 //      'theme_supports' => 'static-front-page',
    1205                         'priority'       => 120,
    1206                         'description'    => __( 'Your theme supports a static front page.' ),
    1207                 ) );
    1208 
    1209                 $this->add_setting( 'show_on_front', array(
    1210                         'default'        => get_option( 'show_on_front' ),
    1211                         'capability'     => 'manage_options',
    1212                         'type'           => 'option',
    1213                 //      'theme_supports' => 'static-front-page',
    1214                 ) );
    1215 
    1216                 $this->add_control( 'show_on_front', array(
    1217                         'label'   => __( 'Front page displays' ),
    1218                         'section' => 'static_front_page',
    1219                         'type'    => 'radio',
    1220                         'choices' => array(
    1221                                 'posts' => __( 'Your latest posts' ),
    1222                                 'page'  => __( 'A static page' ),
    1223                         ),
    1224                 ) );
    1225 
    1226                 $this->add_setting( 'page_on_front', array(
    1227                         'type'       => 'option',
    1228                         'capability' => 'manage_options',
    1229                 //      'theme_supports' => 'static-front-page',
    1230                 ) );
    1231 
    1232                 $this->add_control( 'page_on_front', array(
    1233                         'label'      => __( 'Front page' ),
    1234                         'section'    => 'static_front_page',
    1235                         'type'       => 'dropdown-pages',
    1236                 ) );
    1237 
    1238                 $this->add_setting( 'page_for_posts', array(
    1239                         'type'           => 'option',
    1240                         'capability'     => 'manage_options',
    1241                 //      'theme_supports' => 'static-front-page',
    1242                 ) );
    1243 
    1244                 $this->add_control( 'page_for_posts', array(
    1245                         'label'      => __( 'Posts page' ),
    1246                         'section'    => 'static_front_page',
    1247                         'type'       => 'dropdown-pages',
    1248                 ) );
     1202                // Replicate behavior from options-reading.php and hide front page options if there are no pages
     1203                if ( get_pages() ) {
     1204                        $this->add_section( 'static_front_page', array(
     1205                                'title'          => __( 'Static Front Page' ),
     1206                        //      'theme_supports' => 'static-front-page',
     1207                                'priority'       => 120,
     1208                                'description'    => __( 'Your theme supports a static front page.' ),
     1209                        ) );
     1210
     1211                        $this->add_setting( 'show_on_front', array(
     1212                                'default'        => get_option( 'show_on_front' ),
     1213                                'capability'     => 'manage_options',
     1214                                'type'           => 'option',
     1215                        //      'theme_supports' => 'static-front-page',
     1216                        ) );
     1217
     1218                        $this->add_control( 'show_on_front', array(
     1219                                'label'   => __( 'Front page displays' ),
     1220                                'section' => 'static_front_page',
     1221                                'type'    => 'radio',
     1222                                'choices' => array(
     1223                                        'posts' => __( 'Your latest posts' ),
     1224                                        'page'  => __( 'A static page' ),
     1225                                ),
     1226                        ) );
     1227
     1228                        $this->add_setting( 'page_on_front', array(
     1229                                'type'       => 'option',
     1230                                'capability' => 'manage_options',
     1231                        //      'theme_supports' => 'static-front-page',
     1232                        ) );
     1233
     1234                        $this->add_control( 'page_on_front', array(
     1235                                'label'      => __( 'Front page' ),
     1236                                'section'    => 'static_front_page',
     1237                                'type'       => 'dropdown-pages',
     1238                        ) );
     1239
     1240                        $this->add_setting( 'page_for_posts', array(
     1241                                'type'           => 'option',
     1242                                'capability'     => 'manage_options',
     1243                        //      'theme_supports' => 'static-front-page',
     1244                        ) );
     1245
     1246                        $this->add_control( 'page_for_posts', array(
     1247                                'label'      => __( 'Posts page' ),
     1248                                'section'    => 'static_front_page',
     1249                                'type'       => 'dropdown-pages',
     1250                        ) );
     1251                }
    12491252        }
    12501253
Note: See TracChangeset for help on using the changeset viewer.