summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'themes/twentysixteen/inc/customizer.php')
-rw-r--r--themes/twentysixteen/inc/customizer.php476
1 files changed, 271 insertions, 205 deletions
diff --git a/themes/twentysixteen/inc/customizer.php b/themes/twentysixteen/inc/customizer.php
index 62eb1b0b..9867d3d9 100644
--- a/themes/twentysixteen/inc/customizer.php
+++ b/themes/twentysixteen/inc/customizer.php
@@ -30,9 +30,15 @@ function twentysixteen_custom_header_and_background() {
* @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,
- ) ) );
+ 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.
@@ -50,35 +56,41 @@ function twentysixteen_custom_header_and_background() {
* 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_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;
- }
+ /**
+ * 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">
+ // If the header text has been hidden.
+ ?>
+ <style type="text/css" id="twentysixteen-header-css">
.site-branding {
margin: 0 auto 0 0;
}
@@ -88,9 +100,9 @@ function twentysixteen_header_style() {
clip: rect(1px, 1px, 1px, 1px);
position: absolute;
}
- </style>
- <?php
-}
+ </style>
+ <?php
+ }
endif; // twentysixteen_header_style
/**
@@ -103,87 +115,135 @@ endif; // twentysixteen_header_style
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';
+ $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',
- ) );
+ $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,
- ) );
+ $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[1],
- 'sanitize_callback' => 'sanitize_hex_color',
- 'transport' => 'postMessage',
- ) );
+ $wp_customize->add_setting(
+ 'page_background_color',
+ array(
+ 'default' => $color_scheme[1],
+ 'sanitize_callback' => 'sanitize_hex_color',
+ 'transport' => 'postMessage',
+ )
+ );
- $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'page_background_color', array(
- 'label' => __( 'Page Background Color', 'twentysixteen' ),
- 'section' => 'colors',
- ) ) );
+ $wp_customize->add_control(
+ new WP_Customize_Color_Control(
+ $wp_customize,
+ 'page_background_color',
+ array(
+ 'label' => __( 'Page Background Color', 'twentysixteen' ),
+ 'section' => 'colors',
+ )
+ )
+ );
// Remove the core header textcolor control, as it shares the main text color.
$wp_customize->remove_control( 'header_textcolor' );
// Add link color setting and control.
- $wp_customize->add_setting( 'link_color', array(
- 'default' => $color_scheme[2],
- 'sanitize_callback' => 'sanitize_hex_color',
- 'transport' => 'postMessage',
- ) );
+ $wp_customize->add_setting(
+ 'link_color',
+ array(
+ 'default' => $color_scheme[2],
+ 'sanitize_callback' => 'sanitize_hex_color',
+ 'transport' => 'postMessage',
+ )
+ );
- $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'link_color', array(
- 'label' => __( 'Link Color', 'twentysixteen' ),
- 'section' => 'colors',
- ) ) );
+ $wp_customize->add_control(
+ new WP_Customize_Color_Control(
+ $wp_customize,
+ 'link_color',
+ array(
+ 'label' => __( 'Link Color', 'twentysixteen' ),
+ 'section' => 'colors',
+ )
+ )
+ );
// Add main text color setting and control.
- $wp_customize->add_setting( 'main_text_color', array(
- 'default' => $color_scheme[3],
- 'sanitize_callback' => 'sanitize_hex_color',
- 'transport' => 'postMessage',
- ) );
+ $wp_customize->add_setting(
+ 'main_text_color',
+ array(
+ 'default' => $color_scheme[3],
+ 'sanitize_callback' => 'sanitize_hex_color',
+ 'transport' => 'postMessage',
+ )
+ );
- $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'main_text_color', array(
- 'label' => __( 'Main Text Color', 'twentysixteen' ),
- 'section' => 'colors',
- ) ) );
+ $wp_customize->add_control(
+ new WP_Customize_Color_Control(
+ $wp_customize,
+ 'main_text_color',
+ array(
+ 'label' => __( 'Main Text Color', 'twentysixteen' ),
+ 'section' => 'colors',
+ )
+ )
+ );
// Add secondary text color setting and control.
- $wp_customize->add_setting( 'secondary_text_color', array(
- 'default' => $color_scheme[4],
- 'sanitize_callback' => 'sanitize_hex_color',
- 'transport' => 'postMessage',
- ) );
-
- $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'secondary_text_color', array(
- 'label' => __( 'Secondary Text Color', 'twentysixteen' ),
- 'section' => 'colors',
- ) ) );
+ $wp_customize->add_setting(
+ 'secondary_text_color',
+ array(
+ 'default' => $color_scheme[4],
+ 'sanitize_callback' => 'sanitize_hex_color',
+ 'transport' => 'postMessage',
+ )
+ );
+
+ $wp_customize->add_control(
+ new WP_Customize_Color_Control(
+ $wp_customize,
+ 'secondary_text_color',
+ array(
+ 'label' => __( 'Secondary Text Color', 'twentysixteen' ),
+ 'section' => 'colors',
+ )
+ )
+ );
}
add_action( 'customize_register', 'twentysixteen_customize_register', 11 );
@@ -248,127 +308,130 @@ function twentysixteen_get_color_schemes() {
* }
* }
*/
- return apply_filters( 'twentysixteen_color_schemes', array(
- 'default' => array(
- 'label' => __( 'Default', 'twentysixteen' ),
- 'colors' => array(
- '#1a1a1a',
- '#ffffff',
- '#007acc',
- '#1a1a1a',
- '#686868',
+ return apply_filters(
+ 'twentysixteen_color_schemes',
+ array(
+ 'default' => array(
+ 'label' => __( 'Default', 'twentysixteen' ),
+ 'colors' => array(
+ '#1a1a1a',
+ '#ffffff',
+ '#007acc',
+ '#1a1a1a',
+ '#686868',
+ ),
),
- ),
- 'dark' => array(
- 'label' => __( 'Dark', 'twentysixteen' ),
- 'colors' => array(
- '#262626',
- '#1a1a1a',
- '#9adffd',
- '#e5e5e5',
- '#c1c1c1',
+ 'dark' => array(
+ 'label' => __( 'Dark', 'twentysixteen' ),
+ 'colors' => array(
+ '#262626',
+ '#1a1a1a',
+ '#9adffd',
+ '#e5e5e5',
+ '#c1c1c1',
+ ),
),
- ),
- 'gray' => array(
- 'label' => __( 'Gray', 'twentysixteen' ),
- 'colors' => array(
- '#616a73',
- '#4d545c',
- '#c7c7c7',
- '#f2f2f2',
- '#f2f2f2',
+ 'gray' => array(
+ 'label' => __( 'Gray', 'twentysixteen' ),
+ 'colors' => array(
+ '#616a73',
+ '#4d545c',
+ '#c7c7c7',
+ '#f2f2f2',
+ '#f2f2f2',
+ ),
),
- ),
- 'red' => array(
- 'label' => __( 'Red', 'twentysixteen' ),
- 'colors' => array(
- '#ffffff',
- '#ff675f',
- '#640c1f',
- '#402b30',
- '#402b30',
+ 'red' => array(
+ 'label' => __( 'Red', 'twentysixteen' ),
+ 'colors' => array(
+ '#ffffff',
+ '#ff675f',
+ '#640c1f',
+ '#402b30',
+ '#402b30',
+ ),
),
- ),
- 'yellow' => array(
- 'label' => __( 'Yellow', 'twentysixteen' ),
- 'colors' => array(
- '#3b3721',
- '#ffef8e',
- '#774e24',
- '#3b3721',
- '#5b4d3e',
+ 'yellow' => array(
+ 'label' => __( 'Yellow', 'twentysixteen' ),
+ 'colors' => array(
+ '#3b3721',
+ '#ffef8e',
+ '#774e24',
+ '#3b3721',
+ '#5b4d3e',
+ ),
),
- ),
- ) );
+ )
+ );
}
if ( ! function_exists( 'twentysixteen_get_color_scheme' ) ) :
-/**
- * Retrieves the current Twenty Sixteen color scheme.
- *
- * Create your own twentysixteen_get_color_scheme() function to override in a child theme.
- *
- * @since Twenty Sixteen 1.0
- *
- * @return array An associative array of either the current or default color scheme HEX values.
- */
-function twentysixteen_get_color_scheme() {
- $color_scheme_option = get_theme_mod( 'color_scheme', 'default' );
- $color_schemes = twentysixteen_get_color_schemes();
+ /**
+ * Retrieves the current Twenty Sixteen color scheme.
+ *
+ * Create your own twentysixteen_get_color_scheme() function to override in a child theme.
+ *
+ * @since Twenty Sixteen 1.0
+ *
+ * @return array An associative array of either the current or default color scheme HEX values.
+ */
+ function twentysixteen_get_color_scheme() {
+ $color_scheme_option = get_theme_mod( 'color_scheme', 'default' );
+ $color_schemes = twentysixteen_get_color_schemes();
- if ( array_key_exists( $color_scheme_option, $color_schemes ) ) {
- return $color_schemes[ $color_scheme_option ]['colors'];
- }
+ if ( array_key_exists( $color_scheme_option, $color_schemes ) ) {
+ return $color_schemes[ $color_scheme_option ]['colors'];
+ }
- return $color_schemes['default']['colors'];
-}
+ return $color_schemes['default']['colors'];
+ }
endif; // twentysixteen_get_color_scheme
if ( ! function_exists( 'twentysixteen_get_color_scheme_choices' ) ) :
-/**
- * Retrieves an array of color scheme choices registered for Twenty Sixteen.
- *
- * Create your own twentysixteen_get_color_scheme_choices() function to override
- * in a child theme.
- *
- * @since Twenty Sixteen 1.0
- *
- * @return array Array of color schemes.
- */
-function twentysixteen_get_color_scheme_choices() {
- $color_schemes = twentysixteen_get_color_schemes();
- $color_scheme_control_options = array();
+ /**
+ * Retrieves an array of color scheme choices registered for Twenty Sixteen.
+ *
+ * Create your own twentysixteen_get_color_scheme_choices() function to override
+ * in a child theme.
+ *
+ * @since Twenty Sixteen 1.0
+ *
+ * @return array Array of color schemes.
+ */
+ function twentysixteen_get_color_scheme_choices() {
+ $color_schemes = twentysixteen_get_color_schemes();
+ $color_scheme_control_options = array();
- foreach ( $color_schemes as $color_scheme => $value ) {
- $color_scheme_control_options[ $color_scheme ] = $value['label'];
- }
+ foreach ( $color_schemes as $color_scheme => $value ) {
+ $color_scheme_control_options[ $color_scheme ] = $value['label'];
+ }
- return $color_scheme_control_options;
-}
+ return $color_scheme_control_options;
+ }
endif; // twentysixteen_get_color_scheme_choices
if ( ! function_exists( 'twentysixteen_sanitize_color_scheme' ) ) :
-/**
- * Handles sanitization for Twenty Sixteen color schemes.
- *
- * Create your own twentysixteen_sanitize_color_scheme() function to override
- * in a child theme.
- *
- * @since Twenty Sixteen 1.0
- *
- * @param string $value Color scheme name value.
- * @return string Color scheme name.
- */
-function twentysixteen_sanitize_color_scheme( $value ) {
- $color_schemes = twentysixteen_get_color_scheme_choices();
+ /**
+ * Handles sanitization for Twenty Sixteen color schemes.
+ *
+ * Create your own twentysixteen_sanitize_color_scheme() function to override
+ * in a child theme.
+ *
+ * @since Twenty Sixteen 1.0
+ *
+ * @param string $value Color scheme name value.
+ * @return string Color scheme name.
+ */
+ function twentysixteen_sanitize_color_scheme( $value ) {
+ $color_schemes = twentysixteen_get_color_scheme_choices();
- if ( ! array_key_exists( $value, $color_schemes ) ) {
- return 'default';
- }
+ if ( ! array_key_exists( $value, $color_schemes ) ) {
+ return 'default';
+ }
- return $value;
-}
+ return $value;
+ }
endif; // twentysixteen_sanitize_color_scheme
/**
@@ -445,14 +508,17 @@ add_action( 'customize_preview_init', 'twentysixteen_customize_preview_js' );
* @return string Color scheme CSS.
*/
function twentysixteen_get_color_scheme_css( $colors ) {
- $colors = wp_parse_args( $colors, array(
- 'background_color' => '',
- 'page_background_color' => '',
- 'link_color' => '',
- 'main_text_color' => '',
- 'secondary_text_color' => '',
- 'border_color' => '',
- ) );
+ $colors = wp_parse_args(
+ $colors,
+ array(
+ 'background_color' => '',
+ 'page_background_color' => '',
+ 'link_color' => '',
+ 'main_text_color' => '',
+ 'secondary_text_color' => '',
+ 'border_color' => '',
+ )
+ );
return <<<CSS
/* Color Scheme */
@@ -869,9 +935,9 @@ add_action( 'wp_enqueue_scripts', 'twentysixteen_page_background_color_css', 11
* @see wp_add_inline_style()
*/
function twentysixteen_link_color_css() {
- $color_scheme = twentysixteen_get_color_scheme();
- $default_color = $color_scheme[2];
- $link_color = get_theme_mod( 'link_color', $default_color );
+ $color_scheme = twentysixteen_get_color_scheme();
+ $default_color = $color_scheme[2];
+ $link_color = get_theme_mod( 'link_color', $default_color );
// Don't do anything if the current color is the default.
if ( $link_color === $default_color ) {
@@ -1126,8 +1192,8 @@ add_action( 'wp_enqueue_scripts', 'twentysixteen_main_text_color_css', 11 );
* @see wp_add_inline_style()
*/
function twentysixteen_secondary_text_color_css() {
- $color_scheme = twentysixteen_get_color_scheme();
- $default_color = $color_scheme[4];
+ $color_scheme = twentysixteen_get_color_scheme();
+ $default_color = $color_scheme[4];
$secondary_text_color = get_theme_mod( 'secondary_text_color', $default_color );
// Don't do anything if the current color is the default.