get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage'; // add color picker setting $wp_customize->add_setting( 'header_textcolor', array( 'sanitize_callback' => 'sanitize_text_field', 'default' => '#000000' ) ); // add color picker control $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'header_textcolor', array( 'label' => __('Header Text Color', 'business-trust' ), 'section' => 'colors', 'sanitize_callback' => 'sanitize_text_field', 'settings' => 'header_textcolor', ) ) ); /***************** * Theme options.* *****************/ $wp_customize->add_panel( 'theme_options', array( 'title' => __('Theme Options','business-trust' ), 'description' => __('Theme specific customization options', 'business-trust' ), // Include html tags such as

. 'priority' => 2, // Mixed with top-level-section hierarchy. ) ); /********** * Layout * **********/ $wp_customize->add_section( 'layout_section' , array( 'title' => __('Layout', 'business-trust' ), 'description'=> __('Chanege site layout to box layout mode. Default is fluid layout.', 'business-trust' ), 'panel' => 'theme_options', )); $wp_customize->add_setting( 'box_layout_mode' , array( 'default' => false, 'capability' => 'edit_theme_options', 'sanitize_callback' => 'business_trust_sanitize_checkbox', )); $wp_customize->add_control('box_layout_mode' , array( 'label' => __('Enable Box layout','business-trust' ), 'description' => __('(Enable box layout)','business-trust' ), 'section' => 'layout_section', 'type'=> 'checkbox', )); /********* * Hero .* *********/ $wp_customize->add_section( 'hero_section' , array( 'title' => __('Hero Section', 'business-trust' ), 'description'=> __('Add hero contents and add a button with a Navigation link.', 'business-trust' ), 'panel' => 'theme_options', ) ); // title $wp_customize->add_setting('hero_title', array( 'default' => __('Add Hero title', 'business-trust'), 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control('hero_title', array( 'label' => __('Add Hero title', 'business-trust'), 'section' => 'hero_section', 'type' => 'text', 'priority' => 1, ) ); $wp_customize->selective_refresh->add_partial( 'hero_title', array( 'selector' => '#hero-section .section-title', ) ); // description $wp_customize->add_setting('hero_description', array( 'default' => __('Add Hero Description', 'business-trust'), 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control('hero_description', array( 'label' => __('Add Hero Description', 'business-trust'), 'section' => 'hero_section', 'type' => 'text', ) ); // button text $wp_customize->add_setting('hero_button_text', array( 'default' => __('Add Button Text', 'business-trust'), 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control('hero_button_text', array( 'label' => __('Add Button Text', 'business-trust'), 'section' => 'hero_section', 'type' => 'text', ) ); // button link $wp_customize->add_setting('hero_button_link', array( 'default' => '#', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url', ) ); $wp_customize->add_control('hero_button_link', array( 'label' => __('Add Button Link', 'business-trust'), 'section' => 'hero_section', 'type' => 'url', ) ); $wp_customize->add_setting( 'hero_show_all_pages' , array( 'default' => false, 'capability' => 'edit_theme_options', 'sanitize_callback' => 'business_trust_sanitize_checkbox', )); $wp_customize->add_control('hero_show_all_pages' , array( 'label' => __('Show in all pages','business-trust' ), 'description' => __('(Show hero content in all pages)','business-trust' ), 'section' => 'hero_section', 'type'=> 'checkbox', ) ); //footer section $wp_customize->add_section( 'footer_section' , array( 'title' => __('Footer Customizer', 'business-trust' ), 'description'=> __('Customize footer, change Copyright link etc:', 'business-trust' ), 'panel' => 'theme_options', ) ); $wp_customize->add_setting('copyright_text', array( 'default' => __('Copyright Text', 'business-trust'), 'capability' => 'edit_theme_options', 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control('copyright_text', array( 'label' => __('Add Copyright text', 'business-trust'), 'section' => 'footer_section', 'type' => 'text', 'priority' => 1, ) ); }/* end of customizer settings */ add_action( 'customize_register', 'business_trust_customize_register' ); /** * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. */ function business_trust_customize_preview_js() { wp_enqueue_script( 'business_trust_customizer', BUSINESS_TRUST_TEMPLATE_DIR_URI . '/js/customizer.js', array( 'customize-preview' ), '20191014', true ); } add_action( 'customize_preview_init', 'business_trust_customize_preview_js' ); /* sanitization */ function business_trust_sanitize_checkbox( $checked ) { // Boolean check. return ( ( isset( $checked ) && true == $checked ) ? true : false ); }