Changeset 38624 for trunk/src/wp-includes/class-wp-customize-manager.php
- Timestamp:
- 09/20/2016 12:46:54 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-customize-manager.php
r38513 r38624 2255 2255 } 2256 2256 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 ) ); 2268 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 ) ); 2275 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 ) ); 2285 2286 $this->add_setting( 'page_on_front', array( 2287 'type' => 'option', 2288 'capability' => 'manage_options', 2289 // 'theme_supports' => 'static-front-page', 2290 ) ); 2291 2292 $this->add_control( 'page_on_front', array( 2293 'label' => __( 'Front page' ), 2294 'section' => 'static_front_page', 2295 'type' => 'dropdown-pages', 2296 ) ); 2297 2298 $this->add_setting( 'page_for_posts', array( 2299 'type' => 'option', 2300 'capability' => 'manage_options', 2301 // 'theme_supports' => 'static-front-page', 2302 ) ); 2303 2304 $this->add_control( 'page_for_posts', array( 2305 'label' => __( 'Posts page' ), 2306 'section' => 'static_front_page', 2307 'type' => 'dropdown-pages', 2308 ) ); 2309 } 2257 /* 2258 * Static Front Page 2259 * See also https://core.trac.wordpress.org/ticket/19627 which introduces the the static-front-page theme_support. 2260 * The following replicates behavior from options-reading.php. 2261 */ 2262 2263 $this->add_section( 'static_front_page', array( 2264 'title' => __( 'Static Front Page' ), 2265 'priority' => 120, 2266 'description' => __( 'Your theme supports a static front page.' ), 2267 'active_callback' => array( $this, 'has_published_pages' ), 2268 ) ); 2269 2270 $this->add_setting( 'show_on_front', array( 2271 'default' => get_option( 'show_on_front' ), 2272 'capability' => 'manage_options', 2273 'type' => 'option', 2274 ) ); 2275 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 ) ); 2285 2286 $this->add_setting( 'page_on_front', array( 2287 'type' => 'option', 2288 'capability' => 'manage_options', 2289 ) ); 2290 2291 $this->add_control( 'page_on_front', array( 2292 'label' => __( 'Front page' ), 2293 'section' => 'static_front_page', 2294 'type' => 'dropdown-pages', 2295 ) ); 2296 2297 $this->add_setting( 'page_for_posts', array( 2298 'type' => 'option', 2299 'capability' => 'manage_options', 2300 ) ); 2301 2302 $this->add_control( 'page_for_posts', array( 2303 'label' => __( 'Posts page' ), 2304 'section' => 'static_front_page', 2305 'type' => 'dropdown-pages', 2306 ) ); 2307 } 2308 2309 /** 2310 * Return whether there are published pages. 2311 * 2312 * Used as active callback for static front page section and controls. 2313 * 2314 * @access private 2315 * @since 4.7.0 2316 * 2317 * @returns bool Whether there are published (or to be published) pages. 2318 */ 2319 public function has_published_pages() { 2320 2321 $setting = $this->get_setting( 'nav_menus_created_posts' ); 2322 if ( $setting ) { 2323 foreach ( $setting->value() as $post_id ) { 2324 if ( 'page' === get_post_type( $post_id ) ) { 2325 return true; 2326 } 2327 } 2328 } 2329 2330 return 0 !== count( get_pages() ); 2310 2331 } 2311 2332
Note: See TracChangeset
for help on using the changeset viewer.