<?php
/**
* Twenty Sixteen Customizer functionality
*
* @package WordPress
* @subpackage Twenty_Sixteen
* @since Twenty Sixteen 1.0
*/
/**
* Sets up the WordPress core custom header and custom background features.
*
* @since Twenty Sixteen 1.0
*
* @see twentysixteen_header_style()
*/
function twentysixteen_custom_header_and_background() {
$color_scheme = twentysixteen_get_color_scheme();
$default_background_color = trim( $color_scheme[0], '#' );
$default_text_color = trim( $color_scheme[3], '#' );
/**
* Filter the arguments used when adding 'custom-background' support in Twenty Sixteen.
*
* @since Twenty Sixteen 1.0
*
* @param array $args {
* An array of custom-background support arguments.
*
* @type string $default-color Default color of the background.
* }
*/
add_theme_support(
'custom-background',
apply_filters(
'twentysixteen_custom_background_args',
array(
'default-color' => $default_background_color,
)
)
);
/**
* Filter the arguments used when adding 'custom-header' support in Twenty Sixteen.
*
* @since Twenty Sixteen 1.0
*
* @param array $args {
* An array of custom-header support arguments.
*
* @type string $default-text-color Default color of the header text.
* @type int $width Width in pixels of the custom header image. Default 1200.
* @type int $height Height in pixels of the custom header image. Default 280.
* @type bool $flex-height Whether to allow flexible-height header images. Default true.
* @type callable $wp-head-callback Callback function used to style the header image and text
* displayed on the blog.
* }
*/
add_theme_support(
'custom-header',
apply_filters(
'twentysixteen_custom_header_args',
array(
'default-text-color' => $default_text_color,
'width' => 1200,
'height' => 280,
'flex-height' => true,
'wp-head-callback' => 'twentysixteen_header_style',
)
)
);
}
add_action( 'after_setup_theme', 'twentysixteen_custom_header_and_background' );
if ( ! function_exists( 'twentysixteen_header_style' ) ) :
/**
* Styles the header text displayed on the site.
*
* Create your own twentysixteen_header_style() function to override in a child theme.
*
* @since Twenty Sixteen 1.0
*
* @see twentysixteen_custom_header_and_background().
*/
function twentysixteen_header_style() {
// If the header text option is untouched, let's bail.
if ( display_header_text() ) {
return;
}
// If the header text has been hidden.
?>
<style type="text/css" id="twentysixteen-header-css">
.site-branding {
margin: 0 auto 0 0;
}
.site-branding .site-title,
.site-description {
clip: rect(1px, 1px, 1px, 1px);
position: absolute;
}
</style>
<?php
}
endif; // twentysixteen_header_style
/**
* Adds postMessage support for site title and description for the Customizer.
*
* @since Twenty Sixteen 1.0
*
* @param WP_Customize_Manager $wp_customize The Customizer object.
*/
function twentysixteen_customize_register( $wp_customize ) {
$color_scheme = twentysixteen_get_color_scheme();
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
if ( isset( $wp_customize->selective_refresh ) ) {
$wp_customize->selective_refresh->add_partial(
'blogname',
array(
'selector' => '.site-title a',
'container_inclusive' => false,
'render_callback' => 'twentysixteen_customize_partial_blogname',
)
);
$wp_customize->selective_refresh->add_partial(
'blogdescription',
array(
'selector' => '.site-description',
'container_inclusive' => false,
'render_callback' => 'twentysixteen_customize_partial_blogdescription',
)
);
}
// Add color scheme setting and control.
$wp_customize->add_setting(
'color_scheme',
array(
'default' => 'default',
'sanitize_callback' => 'twentysixteen_sanitize_color_scheme',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
'color_scheme',
array(
'label' => __( 'Base Color Scheme', 'twentysixteen' ),
'section' => 'colors',
'type' => 'select',
'choices' => twentysixteen_get_color_scheme_choices(),
'priority' => 1,
)
);
// Add page background color setting and control.
$wp_customize->add_setting(
'page_background_color',
array(
'default' => $color_scheme[
|