get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; // add color picker $wp_customize->add_setting( 'primary_color', array( 'default' => '#4064d7', 'sanitize_callback' => 'sanitize_hex_color', 'transport' => 'refresh', ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'primary_color', array( 'label' => __( 'Primary Color', 'business-trust' ), 'section' => 'colors', ) ) ); // add color picker $wp_customize->add_setting( 'header_text_color', array( 'default' => '#ffffff', 'sanitize_callback' => 'sanitize_hex_color', 'transport' => 'refresh', ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'header_text_color', array( 'label' => __( 'Header Text Color', 'business-trust' ), 'section' => 'colors', ) ) ); /***************** * 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. ) ); /********** * Contact * **********/ $wp_customize->add_section( 'contact_section' , array( 'title' => __('Header Contact', 'business-trust' ), 'description'=> __('Contact details appeared in footer.', 'business-trust' ), 'panel' => 'theme_options', )); //header tel $wp_customize->add_setting('header_telephone' , array( 'default' => '01-900-123-456', 'sanitize_callback' => 'sanitize_text_field', )); $wp_customize->add_control('header_telephone' , array( 'label' => __('Telephone:', 'business-trust' ), 'section' => 'contact_section', 'type'=> 'text', ) ); $wp_customize->selective_refresh->add_partial( 'header_telephone', array( 'selector' => '.contact-info', ) ); //header email $wp_customize->add_setting('header_email' , array( 'default' => 'mail@domain.com', 'sanitize_callback' => 'sanitize_email', )); $wp_customize->add_control('header_email' , array( 'label' => __('Email:', 'business-trust' ), 'section' => 'contact_section', 'type'=> 'text', ) ); //header address $wp_customize->add_setting('header_address' , array( 'default' => __('Street, City, State', 'business-trust'), 'sanitize_callback' => 'sanitize_text_field', )); $wp_customize->add_control('header_address' , array( 'label' => __('Address:', 'business-trust' ), 'section' => 'contact_section', 'type'=> 'text', ) ); /********** * 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 site box layout mode','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' => '.callout-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, ) ); // Footer bg colour $wp_customize->add_setting( 'footer_bg_color', array( 'default' => '#040c22', 'sanitize_callback' => 'sanitize_hex_color', 'transport' => 'refresh', ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'footer_bg_color', array( 'label' => __( 'Footer Background Color', 'business-trust' ), 'section' => 'footer_section', ) ) ); // footer bg image $wp_customize->add_setting( 'footer_bg_image' , array( 'default' => '', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_url_raw', ) ); $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize , 'footer_bg_image' , array( 'label' => __( 'Footer Background Image', 'business-trust' ), 'description' => __('Upload your background image', 'business-trust'), 'settings' => 'footer_bg_image', 'section' => 'footer_section', )) ); }/* 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 ); }