get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; $wp_customize->get_setting( 'header_textcolor' )->transport = 'refresh'; $wp_customize->get_setting( 'header_image' )->transport = 'refresh'; $wp_customize->get_setting( 'header_video' )->transport = 'refresh'; /*$wp_customize->remove_control( 'header_textcolor' ); $wp_customize->remove_control( 'external_header_video' );*/ if ( isset( $wp_customize->selective_refresh ) ) { $wp_customize->selective_refresh->add_partial( 'blogname', array( 'selector' => '.site-title a', 'render_callback' => 'big_bob_customize_partial_blogname', ) ); $wp_customize->selective_refresh->add_partial( 'blogdescription', array( 'selector' => '.site-description', 'render_callback' => 'big_bob_customize_partial_blogdescription', ) ); } $wp_customize->add_setting('show_header_color', array( 'default' => 'hide', 'transport' => 'postMessage', 'sanitize_callback' => 'checkHeaderColor', )); $wp_customize->add_control('show_header_color', array( 'label' => 'Show Header Background Color', 'section' => 'colors', 'settings' => 'show_header_color', 'type' => 'radio', 'choices' => array( 'show' => 'Show Color', 'hide' => 'Hide Color', ), )); $wp_customize->selective_refresh->add_partial( 'show_header_color', array( 'render_callback' => 'header_is_transparent', ) ); //settings should always have sanitation callbacks $wp_customize->add_setting('header_background_color', array( 'default' => '#43C6E4', 'transport' => 'postMessage', 'sanitize_callback' => 'sanitize_hex_color_no_hash', )); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'header_background_color', array( 'label' => 'Header Background Color', 'section' => 'colors', 'settings' => 'header_background_color', 'priority' => -1, ))); //There is a WP Customize Image Control Class and a WP Customize Media Control Class $wp_customize->add_setting('show_header_color', array( 'default' => 'hide', 'transport' => 'postMessage', 'sanitize_callback' => 'checkHeaderColor', )); $wp_customize->add_control('show_header_color', array( 'label' => 'Show/Hide Header Background Color', 'section' => 'colors', 'settings' => 'show_header_color', 'type' => 'radio', 'choices' => array( 'show' => 'Show Color', 'hide' => 'Hide Color', ), 'priority' => -2, )); $wp_customize->selective_refresh->add_partial( 'show_header_color', array( 'render_callback' => 'header_is_transparent', ) ); $wp_customize->add_setting('media_fit_screen', array( 'default' => 'On', 'transport' => 'postMessage', 'sanitize_callback' => 'checkMediaFit', )); $wp_customize->add_control('media_fit_screen', array( 'label' => 'Fit Media To Screen', 'section' => 'header_image', 'settings' => 'media_fit_screen', 'type' => 'radio', 'choices' => array( 'On' => 'On', 'Off' => 'Off', ), 'priority' => 0, )); $wp_customize->selective_refresh->add_partial( 'media_fit_screen', array( 'render_callback' => 'media_is_fit', ) ); $wp_customize->add_setting('video_on_phone', array( 'default' => 'On', 'transport' => 'postMessage', 'sanitize_callback' => 'checkMediaFit', )); $wp_customize->add_control('video_on_phone', array( 'label' => 'Show Video On Phone', 'section' => 'header_image', 'settings' => 'video_on_phone', 'type' => 'radio', 'choices' => array( 'On' => 'On', 'Off' => 'Off', ), 'priority' => 0, 'description' => 'Turns off the video for mobile devices with small screen sizes (a width of less than 500 pixels). Please note that WINDOW RESIZING inside or outside the WordPress customizer will not instigate the change. If you would like to test within the WordPress customizer, then please switch to the mobile screen, then switch the radio button on, then wait for the refresh, then switch the radio button back off.', )); $wp_customize->selective_refresh->add_partial( 'video_on_phone', array( 'render_callback' => 'video_for_phone', ) ); } add_action( 'customize_register', 'big_bob_customize_register' ); /** * Render the site title for the selective refresh partial. * * @return void */ function big_bob_customize_partial_blogname() { bloginfo( 'name' ); } /** * Render the site tagline for the selective refresh partial. * * @return void */ function big_bob_customize_partial_blogdescription() { bloginfo( 'description' ); } /** * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. */ function big_bob_customize_preview_js() { wp_enqueue_script( 'big-bob-customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20151215', true ); } add_action( 'customize_preview_init', 'big_bob_customize_preview_js' ); add_action('wp_head', 'cd_customizer_css'); function cd_customizer_css() { ?> 'Show Color', 'hide' => 'Hide Color', ); if (array_key_exists($input, $valid)) { return $input; } else { return ''; } } function checkMediaFit($input) { $valid = array( 'On' => 'On', 'Off' => 'Off', ); if (array_key_exists($input, $valid)) { return $input; } else { return ''; } }