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' => 'buzzpress_customize_partial_blogname', ) ); $wp_customize->selective_refresh->add_partial( 'blogdescription', array( 'selector' => '.site-description', 'render_callback' => 'buzzpress_customize_partial_blogdescription', ) ); } // Sanitize text function buzzpress_sanitize_text( $text ) { return sanitize_text_field( $text ); } function buzzpress_sanitize_float( $input ) { return filter_var($input, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); } } add_action( 'customize_register', 'buzzpress_customize_register' ); /** * Render the site title for the selective refresh partial. * * @return void */ function buzzpress_customize_partial_blogname() { bloginfo( 'name' ); } /** * Render the site tagline for the selective refresh partial. * * @return void */ function buzzpress_customize_partial_blogdescription() { bloginfo( 'description' ); } function buzzpress_dark_logo( $wp_customize ) { $wp_customize->add_setting( 'buzzpress_dark_logo', array( 'default' => '', 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'buzzpress_dark_logo' ) ); $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'buzzpress_dark_logo', array( 'label' => 'Dark Logo', 'priority' => 20, 'section' => 'title_tagline', 'settings' => 'buzzpress_dark_logo', 'button_labels' => array(// All These labels are optional 'select' => 'Select Logo', 'remove' => 'Remove Logo', 'change' => 'Change Logo', ) ) )); } add_action( 'customize_register', 'buzzpress_dark_logo' ); /** * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. */ function buzzpress_customize_preview_js() { wp_enqueue_script( 'buzzpress-customizer', get_template_directory_uri() . '/assets/js/customizer.js', array( 'customize-preview' ), '20151215', true ); } add_action( 'customize_preview_init', 'buzzpress_customize_preview_js' );