From 5fd3eb12e1d637c82b866a4dce9c9ca7dcda1f48 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Sun, 11 Feb 2018 21:35:08 -0800 Subject: [PATCH] Allow header text and header nav background to be edited in customizer --- inc/custom-header.php | 4 ++-- inc/customizer.php | 30 ++++++++++++++++++++++++++++-- js/customizer.js | 25 ++++++++++++++++++++----- 3 files changed, 50 insertions(+), 9 deletions(-) diff --git a/inc/custom-header.php b/inc/custom-header.php index ea7e993..08207a2 100644 --- a/inc/custom-header.php +++ b/inc/custom-header.php @@ -59,7 +59,7 @@ function ampconf_header_style() { if ( ! display_header_text() ) : ?> .site-title, - .site-description { + .site-header__description { position: absolute; clip: rect(1px, 1px, 1px, 1px); } @@ -68,7 +68,7 @@ function ampconf_header_style() { else : ?> .site-title a, - .site-description { + .site-header__description { color: #; } diff --git a/inc/customizer.php b/inc/customizer.php index 8a64d96..b036831 100644 --- a/inc/customizer.php +++ b/inc/customizer.php @@ -18,20 +18,46 @@ function ampconf_customize_register( $wp_customize ) { if ( isset( $wp_customize->selective_refresh ) ) { $wp_customize->selective_refresh->add_partial( 'blogname', array( - 'selector' => '.site-title a', + 'selector' => '.site-title a', // @todo .site-title is invalid. 'render_callback' => 'ampconf_customize_partial_blogname', ) ); $wp_customize->selective_refresh->add_partial( 'blogdescription', array( - 'selector' => '.site-description', + 'selector' => '.site-header__description', 'render_callback' => 'ampconf_customize_partial_blogdescription', ) ); } + + $wp_customize->add_setting( 'header_nav_background_color', array( + 'transport' => 'postMessage', + 'sanitize_callback' => 'sanitize_hex_color', + 'default' => '#000000', + ) ); + + $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'header_nav_background_color', array( + 'label' => __( 'Header Nav Background Color', 'ampconf' ), + 'section' => 'colors', + ) ) ); } add_action( 'customize_register', 'ampconf_customize_register' ); +/** + * Display custom color CSS. + */ +function ampconf_custom_colors() { + ?> + +