get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage'; // Create the Theme Options section $wp_customize->add_section( 'spun_theme_options', array( 'title' => __( 'Theme Options', 'spun' ), ) ); $wp_customize->add_setting( 'spun_grayscale', array( 'default' => false, 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'transport' => 'postMessage', 'sanitize_callback' => 'spun_sanitize_checkbox', ) ); $wp_customize->add_control( 'spun_grayscale', array( 'label' => __( 'Always show color circles', 'spun' ), 'section' => 'spun_theme_options', 'type' => 'checkbox', 'priority' => 1, ) ); $wp_customize->add_setting( 'spun_titles', array( 'default' => false, 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'transport' => 'postMessage', 'sanitize_callback' => 'spun_sanitize_checkbox', ) ); $wp_customize->add_control( 'spun_titles', array( 'label' => __( 'Always show post titles over circles', 'spun' ), 'section' => 'spun_theme_options', 'type' => 'checkbox', 'priority' => 2, ) ); $wp_customize->add_setting( 'spun_opacity', array( 'default' => false, 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'transport' => 'postMessage', 'sanitize_callback' => 'spun_sanitize_checkbox', ) ); $wp_customize->add_control( 'spun_opacity', array( 'label' => __( 'Fully opaque meta', 'spun' ), 'section' => 'spun_theme_options', 'type' => 'checkbox', 'priority' => 3, ) ); } add_action( 'customize_register', 'spun_customize_register' ); /** * Sanitize the checkbox. * * @param boolean $input. * * @return boolean true if is 1 or '1', false if anything else */ function spun_sanitize_checkbox( $input ) { if ( 1 == $input ) { return true; } else { return false; } } /** * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. */ function spun_customize_preview_js() { wp_enqueue_script( 'spun_customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20131113', true ); } add_action( 'customize_preview_init', 'spun_customize_preview_js' );