get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage'; $wp_customize->add_setting( 'header_title_color', array( 'default' => '#fff', 'type' => 'theme_mod', 'sanitize_callback' => 'sanitize_hex_color', 'transport' => 'postMessage' ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'header_title_color', array( 'label' => __( 'Header Title Color', 'corporately' ), 'section' => 'header_image', 'priority' => 1, 'settings' => 'header_title_color', ) ) ); $wp_customize->add_setting( 'header_tagline_color', array( 'default' => '#fff', 'type' => 'theme_mod', 'sanitize_callback' => 'sanitize_hex_color', 'transport' => 'postMessage' ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'header_tagline_color', array( 'label' => __( 'Header Tagline Color', 'corporately' ), 'section' => 'header_image', 'priority' => 1, 'settings' => 'header_tagline_color', ) ) ); $wp_customize->add_setting( 'header_bg_color', array( 'default' => '#333', 'type' => 'theme_mod', 'sanitize_callback' => 'sanitize_hex_color', 'transport' => 'postMessage' ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'header_bg_color', array( 'label' => __( 'Header Background Color', 'corporately' ), 'section' => 'header_image', 'priority' => 1, 'settings' => 'header_bg_color', ) ) ); $wp_customize->add_control( 'header_textcolor', array( 'label' => __( 'Header Text Color', 'corporately' ), 'section' => 'head_colors', ) ); $wp_customize->add_setting( 'nav_bg', array( 'default' => '#eee', 'type' => 'theme_mod', 'sanitize_callback' => 'sanitize_hex_color', 'transport' => 'postMessage' ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'nav_bg', array( 'label' => __( 'Navigation Background Color', 'corporately' ), 'section' => 'header_image', 'priority' => 1, 'settings' => 'nav_bg', ) ) ); $wp_customize->add_setting( 'header_background_color', array( 'default' => '#00adcf', // steelblue 'type' => 'theme_mod', 'sanitize_callback' => 'sanitize_hex_color', 'transport' => 'postMessage' ) ); $wp_customize->add_control( 'display_header_text', array( 'label' => __( 'Header Text Color', 'corporately' ), 'section' => 'head_colors', ) ); $wp_customize->add_setting( 'show_sitename_in_menubar', array( 'default' => 0, 'sanitize_callback' => 'corporately_sanitize_checkbox', ) ); // Show Sitename in Menubar Control $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'show_sitename_in_menubar', array( 'label' => __( 'Hide sitename in menu bar?', 'corporately' ), 'type' => 'checkbox', 'section' => 'title_tagline', ) ) ); // Sidebar Layout Control $wp_customize->add_control( 'layout_control', array( 'settings' => 'layout_setting', 'type' => 'radio', 'label' => __( 'Sidebar position', 'corporately' ), 'choices' => array( 'no-sidebar' => __( 'No sidebar', 'corporately' ), 'sidebar-right' => __( 'Sidebar right', 'corporately' ), 'sidebar-left' => __( 'Sidebar left', 'corporately' ), ), 'section' => 'sidebar_settings' ) ); /** * Front Page sections * * @since corporately 2.1.2 * * @param $page_names array */ $page_names = array( 'services', 'clients', 'about', 'contact' ); // Create a setting and control for each of the sections available in the theme. for ( $i = 0; $i < count( $page_names ); $i++ ) { $wp_customize->add_setting( 'panel_' . $page_names[$i], array( 'default' => false, 'sanitize_callback' => 'absint', // 'transport' => 'postMessage', ) ); $wp_customize->add_control( 'panel_' . $page_names[$i], array( /* translators: %s is the front page section name */ 'label' => sprintf( __( '%s Page Content', 'corporately' ), ucwords( $page_names[$i] ) ), 'description' => ( 0 !== $i ? '' : __( 'Select pages to feature in each area from the dropdowns. Add an image to a section by setting a featured image in the page editor. Empty sections will not be displayed.', 'corporately' ) ), 'section' => 'static_front_page', 'type' => 'dropdown-pages', 'allow_addition' => true, 'active_callback' => 'corporately_is_static_front_page', ) ); // $wp_customize->selective_refresh->add_partial( 'panel_' . $page_names[$i], array( // 'selector' => '#' . $page_names[$i], // 'render_callback' => 'corporately_front_page_section', // 'container_inclusive' => true, // ) ); } } add_action( 'customize_register', 'corporately_customize_register' ); /** * Return whether we're previewing the front page and it's a static page. */ function corporately_is_static_front_page() { return ( is_front_page() && ! is_home() ); } /** * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. */ function corporately_customize_preview_js() { wp_enqueue_script( 'corporately_customizer', get_template_directory_uri() . '/assets/js/customizer.js', array( 'customize-preview' ), '20160507', true ); } add_action( 'customize_preview_init', 'corporately_customize_preview_js' ); /* * Sanitize layout options */ function corporately_sanitize_layout ( $value ) { if ( !in_array( $value, array( 'no-sidebar', 'sidebar-right', 'sidebar-left' ) ) ) { $value = 'no-sidebar'; } return $value; } /** * Checkbox sanitization callback * @link https://github.com/WPTRT/code-examples/blob/master/customizer/sanitization-callbacks.php * * Sanitization callback for 'checkbox' type controls. This callback sanitizes `$checked` * as a boolean value, either TRUE or FALSE. * * @param bool $checked Whether the checkbox is checked. * @return bool Whether the checkbox is checked. */ function corporately_sanitize_checkbox( $checked ) { // Boolean check return ( ( isset( $checked ) && true == $checked ) ? true : false ); } if(! function_exists('corporately_get_user_input' ) ): function corporately_get_user_input(){ ?>