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' => 'avon_customize_partial_blogname', ) ); $wp_customize->selective_refresh->add_partial( 'blogdescription', array( 'selector' => '.site-description', 'render_callback' => 'avon_customize_partial_blogdescription', ) ); } } add_action( 'customize_register', 'avon_customize_register' ); if ( ! function_exists( 'avon_theme_customize_register' ) ) { function avon_theme_customize_register( $wp_customize ) { $wp_customize->add_section( AVON_PREFIX . 'theme_options', array( 'title' => __( 'Theme Settings', 'avon' ), 'capability' => 'edit_theme_options', 'description' => __( 'General Theme Settings', 'avon' ), 'priority' => apply_filters( 'avon_theme_options_priority', 160 ), ) ); function avon_sanitize_radio( $input, $setting ){ $input = sanitize_key($input); $choices = $setting->manager->get_control( $setting->id )->choices; return ( array_key_exists( $input, $choices ) ? $input : $setting->default ); } // $wp_customize->add_setting( // AVON_PREFIX . 'scripts_from_cdn', // array( // 'default' => 'yes', // 'type' => 'theme_mod', // 'sanitize_callback' => 'avon_sanitize_radio', // 'capability' => 'edit_theme_options', // ) // ); // // $wp_customize->add_control( // new WP_Customize_Control( // $wp_customize, // AVON_PREFIX . 'scripts_from_cdn', // array( // 'label' => __( 'Load Scripts from CDN', 'avon' ), // 'description' => __( 'Do you want to load scripts from CDN? It will improve performance.', 'avon' ), // 'section' => AVON_PREFIX . 'theme_options', // 'settings' => AVON_PREFIX . 'scripts_from_cdn', // 'type' => 'radio', // 'choices' => array( // 'yes' => esc_html__('Yes, CDN','avon'), // 'no' => esc_html__('No, CDN','avon'), // ), // 'priority' => apply_filters( 'avon_scripts_from_cdn_priority', 10 ), // ) // ) // ); } } // endif function_exists( 'avon_theme_customize_register' ). add_action( 'customize_register', 'avon_theme_customize_register' ); /** * Render the site title for the selective refresh partial. * * @return void */ function avon_customize_partial_blogname() { bloginfo( 'name' ); } /** * Render the site tagline for the selective refresh partial. * * @return void */ function avon_customize_partial_blogdescription() { bloginfo( 'description' ); } /** * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. */ function avon_customize_preview_js() { wp_enqueue_script( 'avon-customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20151215', true ); } add_action( 'customize_preview_init', 'avon_customize_preview_js' );