get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage'; $wp_customize->get_setting( 'background_color' )->transport = 'postMessage'; $wp_customize->get_setting( 'background_image' )->transport = 'postMessage'; $wp_customize->get_setting( 'background_repeat' )->transport = 'postMessage'; $wp_customize->get_setting( 'background_position_x' )->transport = 'postMessage'; $wp_customize->get_setting( 'background_attachment' )->transport = 'postMessage'; $wp_customize->selective_refresh->add_partial( 'blogname', array( 'selector' => '.site-title a', 'render_callback' => 'afterlight_2_customize_partial_blogname', ) ); $wp_customize->selective_refresh->add_partial( 'blogdescription', array( 'selector' => '.site-description', 'render_callback' => 'afterlight_2_customize_partial_blogdescription', ) ); // Add Theme section. $wp_customize->add_section( 'afterlight_2_theme_options', array( 'title' => __( 'Theme Options', 'afterlight-2' ), 'priority' => 200, ) ); // Add custom background overlay option setting and control. $wp_customize->add_setting( 'afterlight_2_background_overlay', array( 'default' => '1', 'transport' => 'postMessage', 'sanitize_callback' => 'afterlight_2_sanitize_checkbox', ) ); $wp_customize->add_control( 'afterlight_2_background_overlay', array( 'label' => __( 'Add an overlay to background.', 'afterlight-2' ), 'section' => 'afterlight_2_theme_options', 'visibility' => 'background_image', 'theme_supports' => 'custom-background', 'type' => 'checkbox', 'priority' => 1, ) ); // Add custom full page background image option setting and control. $wp_customize->add_setting( 'afterlight_2_full_page_background', array( 'default' => '1', 'transport' => 'postMessage', 'sanitize_callback' => 'afterlight_2_sanitize_checkbox', ) ); $wp_customize->add_control( 'afterlight_2_full_page_background', array( 'label' => __( 'Scale background image to fit.', 'afterlight-2' ), 'section' => 'afterlight_2_theme_options', 'visibility' => 'background_image', 'theme_supports' => 'custom-background', 'type' => 'checkbox', 'priority' => 2, ) ); // Subscribe form $wp_customize->add_setting( 'afterlight_2_subscribe_form', array( 'default' => '1', 'transport' => 'postMessage', 'sanitize_callback' => 'afterlight_2_sanitize_checkbox', ) ); $wp_customize->add_control( 'afterlight_2_subscribe_form', array( 'label' => __( 'Add a subscribe form to the footer.', 'afterlight-2' ), 'section' => 'afterlight_2_theme_options', 'type' => 'checkbox', ) ); } add_action( 'customize_register', 'afterlight_2_customize_register' ); if ( ! function_exists( 'afterlight_2_sanitize_checkbox' ) ) : /** * Sanitize a checkbox setting. * * @since Afterlight 1.0 */ function afterlight_2_sanitize_checkbox( $value ) { return ( 1 == $value ); } endif; /** * Render the site title for the selective refresh partial. * * @return void */ function afterlight_2_customize_partial_blogname() { bloginfo( 'name' ); } /** * Render the site tagline for the selective refresh partial. * * @return void */ function afterlight_2_customize_partial_blogdescription() { bloginfo( 'description' ); } /** * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. */ function afterlight_2_customize_preview_js() { wp_enqueue_script( 'afterlight-2-customizer', get_template_directory_uri() . '/assets/js/customizer.js', array( 'customize-preview' ), '20150421', true ); wp_enqueue_script( 'afterlight-2-dotorg-customizer', get_template_directory_uri() . '/assets/js/dotorg-customizer.js', array( 'customize-preview' ), '20150421', true ); } add_action( 'customize_preview_init', 'afterlight_2_customize_preview_js' );