Ticket #37516: theme-feature-37516.diff
File theme-feature-37516.diff, 4.6 KB (added by , 7 years ago) |
---|
-
src/wp-includes/class-wp-customize-manager.php
4454 4454 'section' => 'title_tagline', 4455 4455 ) ); 4456 4456 4457 // Theme feature for enabling and disabling the site title 4458 if ( current_theme_supports( 'custom-title-tagline', 'display-title' ) ) { 4459 $this->add_setting( 'header_display_title', array( 4460 'default' => get_option( 'header_display_title' ) || get_option( 'blogname' ), 4461 'type' => 'option', 4462 'capability' => 'manage_options', 4463 'transport' => 'postMessage', 4464 'sanitize_callback' => 'absint', 4465 4466 4467 ) ); 4468 4469 $this->add_control( 'header_display_title', array( 4470 'label' => __( 'Display Site Title' ), 4471 'section' => 'title_tagline', 4472 'settings' => 'header_display_title', 4473 'type' => 'checkbox', 4474 ) ); 4475 } 4476 4477 // Theme feature for enabling and disabling the site tagline 4478 if ( current_theme_supports( 'custom-title-tagline', 'display-tagline' ) ) { 4479 $this->add_setting( 'header_display_tagline', array( 4480 'default' => get_option( 'header_display_tagline' ) || get_option( 'blogdescrption' ), 4481 'type' => 'option', 4482 'capability' => 'manage_options', 4483 'transport' => 'postMessage', 4484 'sanitize_callback' => 'absint', 4485 ) ); 4486 4487 $this->add_control( 'header_display_tagline', array( 4488 'label' => __( 'Display Site Tagline' ), 4489 'section' => 'title_tagline', 4490 'settings' => 'header_display_tagline', 4491 'type' => 'checkbox', 4492 ) ); 4493 } 4494 4457 4495 // Add a setting to hide header text if the theme doesn't support custom headers. 4458 if ( ! current_theme_supports( 'custom-header', 'header-text' ) ) {4496 if ( ! current_theme_supports( 'custom-header', 'header-text' ) && ! current_theme_supports( 'custom-title-tagline' ) ) { 4459 4497 $this->add_setting( 'header_text', array( 4460 4498 'theme_supports' => array( 'custom-logo', 'header-text' ), 4461 4499 'default' => 1, -
src/wp-includes/general-template.php
4253 4253 4254 4254 return $settings; 4255 4255 } 4256 4257 if ( 0 ) { 4258 /** 4259 * TEMPORARY - this needs a better solution 4260 * Used to demonstrate https://core.trac.wordpress.org/ticket/37516 only 4261 * apply_filters( 'bloginfo', $output, $show ); 4262 */ 4263 function filter_bloginfo_header_text( $output, $show ) { 4264 if ( 'name' === $show ) 4265 return ( get_option( 'header_text_title') ? $output : '' ); 4266 elseif ( 'description' === $show ) 4267 return ( get_option( 'header_text_tagline' ) ? $output : '' ); 4268 4269 4270 return $output; 4271 } 4272 4273 function add_filter_bloginfo_header_text( $header_name ) { 4274 add_filter( 'bloginfo', 'filter_bloginfo_header_text', 10, 2 ); 4275 } 4276 4277 add_action( 'get_header', 'add_filter_bloginfo_header_text' ); 4278 4279 function filter_register_blogname_partials( WP_Customize_Manager $wp_customize ) { 4280 4281 if ( ! isset( $wp_customize->selective_refresh ) ) { 4282 return; 4283 } 4284 4285 $wp_customize->selective_refresh->add_partial( 'header_text_title', array( 4286 'selector' => '.site-title a', 4287 'settings' => array( 'blogname', 'header_text_title' ), 4288 'render_callback' => function() { 4289 return filter_bloginfo_header_text( get_bloginfo( 'name' ), 'name' ); 4290 }, 4291 ) ); 4292 4293 $wp_customize->selective_refresh->add_partial( 'header_text_tagline', array( 4294 'selector' => '.site-description', 4295 'settings' => array( 'blogdescription', 'header_text_tagline' ), 4296 'render_callback' => function() { 4297 return filter_bloginfo_header_text( get_bloginfo( 'description' ), 'description' ); 4298 } 4299 ) ); 4300 } 4301 add_action( 'customize_register', 'filter_register_blogname_partials' ); 4302 4303 } 4304 No newline at end of file -
src/wp-includes/theme.php
2419 2419 2420 2420 return false; 2421 2421 } 2422 2423 break; 2424 2425 case 'custom-title-tagline' : 2426 if ( ! is_array( $args ) ) 2427 $args = array( 0 => array() ); 2428 2429 $defaults = array( 2430 'display-title' => true, 2431 'display-tagline' => true, 2432 ); 2433 2434 $args[0] = wp_parse_args( array_intersect_key( $args[0], $defaults ), $defaults ); 2435 2436 break; 2437 2422 2438 } 2423 2439 2424 2440 $_wp_theme_features[ $feature ] = $args; … … 3151 3167 clean_post_cache( $post_id ); 3152 3168 } 3153 3169 } 3170