get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage'; if ( isset( $wp_customize->selective_refresh ) ) { $wp_customize->selective_refresh->add_partial( 'blogname', array( 'selector' => '.site-title a', 'render_callback' => 'atavist_customize_partial_blogname', ) ); $wp_customize->selective_refresh->add_partial( 'blogdescription', array( 'selector' => '.site-description', 'render_callback' => 'atavist_customize_partial_blogdescription', ) ); } /** * Primary color. */ $wp_customize->add_setting( 'primary_color', array( 'default' => 'default', 'transport' => 'postMessage', 'sanitize_callback' => 'atavist_sanitize_color_option', ) ); $wp_customize->add_control( 'primary_color', array( 'type' => 'radio', 'label' => __( 'Primary Color', 'atavist' ), 'choices' => array( 'default' => _x( 'Default', 'primary color', 'atavist' ), 'custom' => _x( 'Custom', 'primary color', 'atavist' ), ), 'section' => 'colors', 'priority' => 5, ) ); // Add primary color hue setting and control. $wp_customize->add_setting( 'primary_color_hue', array( 'default' => 199, 'transport' => 'postMessage', 'sanitize_callback' => 'absint', ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'primary_color_hue', array( 'description' => __( 'Apply a custom color for buttons, links, featured images, etc.', 'atavist' ), 'section' => 'colors', 'mode' => 'hue', ) ) ); // Add image filter setting and control. $wp_customize->add_setting( 'image_filter', array( 'default' => 1, 'sanitize_callback' => 'absint', 'transport' => 'postMessage', ) ); $wp_customize->add_control( 'image_filter', array( 'label' => __( 'Apply a filter to featured images using the primary color', 'atavist' ), 'section' => 'colors', 'type' => 'checkbox', ) ); } add_action( 'customize_register', 'atavist_customize_register' ); /** * Render the site title for the selective refresh partial. * * @return void */ function atavist_customize_partial_blogname() { bloginfo( 'name' ); } /** * Render the site tagline for the selective refresh partial. * * @return void */ function atavist_customize_partial_blogdescription() { bloginfo( 'description' ); } /** * Bind JS handlers to instantly live-preview changes. */ function atavist_customize_preview_js() { wp_enqueue_script( 'atavist-customize-preview', get_theme_file_uri( '/js/customize-preview.js' ), array( 'customize-preview' ), '20151215', true ); } add_action( 'customize_preview_init', 'atavist_customize_preview_js' ); /** * Load dynamic logic for the customizer controls area. */ function atavist_panels_js() { wp_enqueue_script( 'atavist-customize-controls', get_theme_file_uri( '/js/customize-controls.js' ), array(), '1.0', true ); } add_action( 'customize_controls_enqueue_scripts', 'atavist_panels_js' ); /** * Sanitize custom color choice. * * @param string $choice Whether image filter is active. * * @return string */ function atavist_sanitize_color_option( $choice ) { $valid = array( 'default', 'custom', ); if ( in_array( $choice, $valid, true ) ) { return $choice; } return 'default'; } do_action('atavist_slider_functions'); add_action('atavist_slider_functions', 'atavist_header_wp_default_image'); /** * Set up the WordPress core custom header feature. * * @uses atavist_header_style() */ function atavist_custom_header_setup() { /** * Filter Twenty Seventeen custom-header support arguments. * * @since Twenty Seventeen 1.0 * * @param array $args { * An array of custom-header support arguments. * * @type string $default-image Default image of the header. * @type string $default_text_color Default color of the header text. * @type int $width Width in pixels of the custom header image. Default 954. * @type int $height Height in pixels of the custom header image. Default 1300. * @type string $wp-head-callback Callback function used to styles the header image and text * displayed on the blog. * @type string $flex-height Flex support for height of header. * } */ add_theme_support( 'custom-header', apply_filters( 'atavist_custom_header_args', array( 'default-image' => get_parent_theme_file_uri( '/init/assets/img/city-in-yellow.jpg' ), 'width' => 2000, 'height' => 1200, 'flex-height' => true, 'video' => true, 'wp-head-callback' => 'atavist_header_style', ) ) ); register_default_headers( array( 'default-image' => array( 'url' => '%s/init/assets/img/city-in-yellow.jpg', 'thumbnail_url' => '%s/init/assets/img/city-in-yellow.jpg', 'description' => __( 'Default Header Image', 'atavist' ), ), ) ); } add_action( 'after_setup_theme', 'atavist_custom_header_setup' ); if ( ! function_exists( 'atavist_header_style' ) ) : /** * Styles the header image and text displayed on the blog. * * @see atavist_custom_header_setup(). */ function atavist_header_style() { /*$header_text_color = get_header_textcolor(); // If no custom options for text are set, let's bail. // get_header_textcolor() options: add_theme_support( 'custom-header' ) is default, hide text (returns 'blank') or any hex value. if ( get_theme_support( 'custom-header', 'default-text-color' ) === $header_text_color ) { return; }*/ // If we get this far, we have custom styles. Let's do this. ?>