get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage'; } add_action( 'customize_register', 'flatly_customize_register' ); /** * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. */ function flatly_customize_preview_js() { wp_enqueue_script( 'flatly_customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20130508', true ); } add_action( 'customize_preview_init', 'flatly_customize_preview_js' ); /******************************************************************* * These are settings for the Theme Customizer in the admin panel. *******************************************************************/ if (!function_exists( 'flatly_theme_customizer' ) ) : function flatly_theme_customizer( $wp_customize ) { /* color theme */ $wp_customize->add_setting( 'flatly_primary_theme_color', array ( 'default' => '#45b058', 'sanitize_callback' => 'sanitize_hex_color', ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'flatly_primary_theme_color', array( 'label' => __( 'Primary Theme Color Option', 'flatly' ), 'section' => 'colors', 'settings' => 'flatly_primary_theme_color', 'priority' => 21, ) ) ); $wp_customize->add_setting( 'flatly_secondary_theme_color', array ( 'default' => '#58c86d', 'sanitize_callback' => 'sanitize_hex_color', ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'flatly_secondary_theme_color', array( 'label' => __( 'Secondary Theme Color Option', 'flatly' ), 'section' => 'colors', 'settings' => 'flatly_secondary_theme_color', 'priority' => 22, ) ) ); // author bio in posts option $wp_customize->add_section( 'flatly_author_bio_section' , array( 'title' => __( 'Display Author Bio', 'flatly' ), 'priority' => 23, 'description' => __( 'Option to show/hide the author bio in the posts.', 'flatly' ), ) ); $wp_customize->add_setting( 'flatly_author_bio', array ( 'default' => '0', 'sanitize_callback' => 'flatly_sanitize_checkbox', ) ); $wp_customize->add_control('author_bio', array( 'settings' => 'flatly_author_bio', 'label' => __('Show the author bio in posts?', 'flatly'), 'section' => 'flatly_author_bio_section', 'type' => 'checkbox', )); } endif; add_action('customize_register', 'flatly_theme_customizer'); /** * Sanitize integer input */ if (!function_exists( 'flatly_sanitize_integer' ) ) : function flatly_sanitize_integer( $input ) { return absint($input); } endif; /** * Sanitize checkbox */ if (!function_exists( 'flatly_sanitize_checkbox' ) ) : function flatly_sanitize_checkbox( $input ) { if ( $input == 1 ) { return 1; } else { return ''; } } endif; /** * Apply Color Scheme */ if (!function_exists( 'flatly_apply_color' ) ) : function flatly_apply_color() { ?>