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' => 'Bakery_Treats_Customize_partial_blogname', ) ); $wp_customize->selective_refresh->add_partial( 'blogdescription', array( 'selector' => '.site-description', 'render_callback' => 'Bakery_Treats_Customize_partial_blogdescription', ) ); } /* * Theme Options Panel */ $wp_customize->add_panel('bakery_treats_panel', array( 'priority' => 25, 'capability' => 'edit_theme_options', 'title' => __('Bakery Treats Theme Options', 'bakery-treats'), )); /* * Customizer main header section */ $wp_customize->add_setting( 'bakery_treats_site_title_text', array( 'capability' => 'edit_theme_options', 'transport' => 'refresh', 'default' => 1, 'sanitize_callback' => 'bakery_treats_sanitize_checkbox', ) ); $wp_customize->add_control( 'bakery_treats_site_title_text', array( 'label' => __('Enable Title', 'bakery-treats'), 'description' => __('Enable or Disable Title from the site', 'bakery-treats'), 'section' => 'title_tagline', 'type' => 'checkbox', ) ); $wp_customize->add_setting( 'bakery_treats_site_tagline_text', array( 'capability' => 'edit_theme_options', 'transport' => 'refresh', 'default' => 0, 'sanitize_callback' => 'bakery_treats_sanitize_checkbox', ) ); $wp_customize->add_control( 'bakery_treats_site_tagline_text', array( 'label' => __('Enable Tagline', 'bakery-treats'), 'description' => __('Enable or Disable Tagline from the site', 'bakery-treats'), 'section' => 'title_tagline', 'type' => 'checkbox', ) ); $wp_customize->add_setting( 'bakery_treats_logo_width', array( 'capability' => 'edit_theme_options', 'transport' => 'refresh', 'default' => '150', 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control( 'bakery_treats_logo_width', array( 'label' => __('Logo Width in PX', 'bakery-treats'), 'section' => 'title_tagline', 'type' => 'number', 'input_attrs' => array( 'min' => 100, 'max' => 300, 'step' => 1, ), ) ); /*Additional Options*/ $wp_customize->add_section('bakery_treats_additional_section', array( 'priority' => 5, 'capability' => 'edit_theme_options', 'theme_supports' => '', 'title' => __('Additional Options', 'bakery-treats'), 'panel' => 'bakery_treats_panel', )); /*Main Slider Enable Option*/ $wp_customize->add_setting( 'bakery_treats_enable_preloader', array( 'capability' => 'edit_theme_options', 'transport' => 'refresh', 'default' => 0, 'sanitize_callback' => 'bakery_treats_sanitize_checkbox', ) ); $wp_customize->add_control( 'bakery_treats_enable_preloader', array( 'label' => __('Enable Preloader', 'bakery-treats'), 'description' => __('Checked to show preloader', 'bakery-treats'), 'section' => 'bakery_treats_additional_section', 'type' => 'checkbox', ) ); /*** Customizer main header section ***/ /*Main Header Options*/ $wp_customize->add_section('bakery_treats_header_section', array( 'priority' => 5, 'capability' => 'edit_theme_options', 'theme_supports' => '', 'title' => __('Main Header Options', 'bakery-treats'), 'panel' => 'bakery_treats_panel', )); $wp_customize->add_setting( 'bakery_treats_header_info_phone_text', array( 'capability' => 'edit_theme_options', 'transport' => 'refresh', 'default' => '', 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control( 'bakery_treats_header_info_phone_text', array( 'label' => __('Edit Phone Text ', 'bakery-treats'), 'section' => 'bakery_treats_header_section', 'type' => 'text', ) ); /*Main Header Phone Text*/ $wp_customize->add_setting( 'bakery_treats_header_info_phone', array( 'capability' => 'edit_theme_options', 'transport' => 'refresh', 'default' => '', 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control( 'bakery_treats_header_info_phone', array( 'label' => __('Edit Phone Number ', 'bakery-treats'), 'section' => 'bakery_treats_header_section', 'type' => 'text', ) ); $wp_customize->add_setting( 'bakery_treats_header_info_email_text', array( 'capability' => 'edit_theme_options', 'transport' => 'refresh', 'default' => '', 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control( 'bakery_treats_header_info_email_text', array( 'label' => __('Edit Email Text ', 'bakery-treats'), 'section' => 'bakery_treats_header_section', 'type' => 'text', ) ); /*Main Header Phone Text*/ $wp_customize->add_setting( 'bakery_treats_header_info_email', array( 'capability' => 'edit_theme_options', 'transport' => 'refresh', 'default' => '', 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control( 'bakery_treats_header_info_email', array( 'label' => __('Edit Email Address ', 'bakery-treats'), 'section' => 'bakery_treats_header_section', 'type' => 'text', ) ); $wp_customize->add_setting( 'bakery_treats_header_search', array( 'capability' => 'edit_theme_options', 'transport' => 'refresh', 'default' => 1, 'sanitize_callback' => 'bakery_treats_sanitize_checkbox', ) ); $wp_customize->add_control( 'bakery_treats_header_search', array( 'label' => __('Enable Disable Search', 'bakery-treats'), 'description' => __('Enable or Disable header Search', 'bakery-treats'), 'section' => 'bakery_treats_header_section', 'type' => 'checkbox', ) ); /* * Customizer main slider section */ /*Main Slider Options*/ $wp_customize->add_section('bakery_treats_slider_section', array( 'priority' => 5, 'capability' => 'edit_theme_options', 'theme_supports' => '', 'title' => __('Main Slider Options', 'bakery-treats'), 'panel' => 'bakery_treats_panel', )); /*Main Slider Enable Option*/ $wp_customize->add_setting( 'bakery_treats_enable_slider', array( 'capability' => 'edit_theme_options', 'transport' => 'refresh', 'default' => 1, 'sanitize_callback' => 'bakery_treats_sanitize_checkbox', ) ); $wp_customize->add_control( 'bakery_treats_enable_slider', array( 'label' => __('Enable Main Slider', 'bakery-treats'), 'description' => __('Checked to show the main slider', 'bakery-treats'), 'section' => 'bakery_treats_slider_section', 'type' => 'checkbox', ) ); for ($i=1; $i <= 3; $i++) { /*Main Slider Image*/ $wp_customize->add_setting( 'bakery_treats_slider_image'.$i, array( 'capability' => 'edit_theme_options', 'default' => '', 'transport' => 'postMessage', 'sanitize_callback' => 'esc_url_raw', ) ); $wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'bakery_treats_slider_image'.$i, array( 'label' => __('Edit Slider Image ', 'bakery-treats') .$i, 'description' => __('Edit the slider image.', 'bakery-treats'), 'section' => 'bakery_treats_slider_section', ) ) ); /*Main Slider Heading*/ $wp_customize->add_setting( 'bakery_treats_slider_top_text'.$i, array( 'capability' => 'edit_theme_options', 'transport' => 'refresh', 'default' => '', 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control( 'bakery_treats_slider_top_text'.$i, array( 'label' => __('Edit Slider Top Text ', 'bakery-treats') .$i, 'description' => __('Edit the slider Top text.', 'bakery-treats'), 'section' => 'bakery_treats_slider_section', 'type' => 'text', ) ); /*Main Slider Heading*/ $wp_customize->add_setting( 'bakery_treats_slider_heading'.$i, array( 'capability' => 'edit_theme_options', 'transport' => 'refresh', 'default' => '', 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control( 'bakery_treats_slider_heading'.$i, array( 'label' => __('Edit Heading Text ', 'bakery-treats') .$i, 'description' => __('Edit the slider heading text.', 'bakery-treats'), 'section' => 'bakery_treats_slider_section', 'type' => 'text', ) ); } /*Main Slider Content*/ $wp_customize->add_setting( 'bakery_treats_add_phone_number', array( 'capability' => 'edit_theme_options', 'transport' => 'refresh', 'default' => '', 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control( 'bakery_treats_add_phone_number', array( 'label' => __('Add Phone Number to Book a Table ', 'bakery-treats'), 'description' => __('Edit the slider content text.', 'bakery-treats'), 'section' => 'bakery_treats_slider_section', 'type' => 'text', ) ); /*Main Slider Content*/ $wp_customize->add_setting( 'bakery_treats_bakery_opening_time', array( 'capability' => 'edit_theme_options', 'transport' => 'refresh', 'default' => '', 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control( 'bakery_treats_bakery_opening_time', array( 'label' => __('Add Opening Hour', 'bakery-treats'), 'description' => __('Edit the slider content text.', 'bakery-treats'), 'section' => 'bakery_treats_slider_section', 'type' => 'text', ) ); /* * Customizer Our Special Products section */ /*New Arrivals Options*/ $wp_customize->add_section('bakery_treats_arrivals_section', array( 'priority' => 5, 'capability' => 'edit_theme_options', 'theme_supports' => '', 'title' => __('Our Special Products Option', 'bakery-treats'), 'panel' => 'bakery_treats_panel', )); /*New Arrivals Enable Option*/ $wp_customize->add_setting( 'bakery_treats_enable_new_arrivals', array( 'capability' => 'edit_theme_options', 'transport' => 'refresh', 'default' => 1, 'sanitize_callback' => 'bakery_treats_sanitize_checkbox', ) ); $wp_customize->add_control( 'bakery_treats_enable_new_arrivals', array( 'label' => __('Enable Our Special Products Section', 'bakery-treats'), 'description' => __('Checked to show the category', 'bakery-treats'), 'section' => 'bakery_treats_arrivals_section', 'type' => 'checkbox', ) ); /*Our Special Products Heading 2*/ $wp_customize->add_setting( 'bakery_treats_new_arrivals_top_heading', array( 'capability' => 'edit_theme_options', 'transport' => 'refresh', 'default' => '', 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control( 'bakery_treats_new_arrivals_top_heading', array( 'label' => __('Edit Section Top Heading', 'bakery-treats'), 'description' => __('Edit section top heading', 'bakery-treats'), 'section' => 'bakery_treats_arrivals_section', 'type' => 'text', ) ); /*Our Special Products Heading*/ $wp_customize->add_setting( 'bakery_treats_new_arrivals_heading', array( 'capability' => 'edit_theme_options', 'transport' => 'refresh', 'default' => '', 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control( 'bakery_treats_new_arrivals_heading', array( 'label' => __('Edit Section Heading', 'bakery-treats'), 'description' => __('Edit section main heading', 'bakery-treats'), 'section' => 'bakery_treats_arrivals_section', 'type' => 'text', ) ); /*Our Special Products Products*/ $args = array( 'type' => 'product', 'taxonomy' => 'product_cat' ); $categories = get_categories($args); $cat_posts = array(); $i = 0; $cat_posts[]='Select'; foreach($categories as $category){ if($i==0){ $default = $category->slug; $i++; } $cat_posts[$category->slug] = $category->name; } $wp_customize->add_setting('bakery_treats_product_category',array( 'default' => 'select', 'sanitize_callback' => 'bakery_treats_sanitize_choices', )); $wp_customize->add_control('bakery_treats_product_category',array( 'type' => 'select', 'choices' => $cat_posts, 'label' => __('Select Product Category','bakery-treats'), 'section' => 'bakery_treats_arrivals_section', )); /* * Customizer Footer Section */ /*Footer Options*/ $wp_customize->add_section('bakery_treats_footer_section', array( 'priority' => 5, 'capability' => 'edit_theme_options', 'theme_supports' => '', 'title' => __('Footer Options', 'bakery-treats'), 'panel' => 'bakery_treats_panel', )); /*Footer Social Menu Option*/ $wp_customize->add_setting( 'bakery_treats_footer_social_menu', array( 'capability' => 'edit_theme_options', 'transport' => 'refresh', 'default' => 1, 'sanitize_callback' => 'bakery_treats_sanitize_checkbox', ) ); $wp_customize->add_control( 'bakery_treats_footer_social_menu', array( 'label' => __('Enable Footer Social Menu', 'bakery-treats'), 'description' => __('Checked to show the footer social menu. Go to Dashboard >> Appearance >> Menus >> Create New Menu >> Add Custom Link >> Add Social Menu >> Checked Social Menu >> Save Menu.', 'bakery-treats'), 'section' => 'bakery_treats_footer_section', 'type' => 'checkbox', ) ); /*Go To Top Option*/ $wp_customize->add_setting( 'bakery_treats_enable_go_to_top_option', array( 'capability' => 'edit_theme_options', 'transport' => 'refresh', 'default' => 1, 'sanitize_callback' => 'bakery_treats_sanitize_checkbox', ) ); $wp_customize->add_control( 'bakery_treats_enable_go_to_top_option', array( 'label' => __('Enable Go To Top', 'bakery-treats'), 'description' => __('Checked to enable Go To Top option.', 'bakery-treats'), 'section' => 'bakery_treats_footer_section', 'type' => 'checkbox', ) ); /*Footer Copyright Text Enable*/ $wp_customize->add_setting( 'bakery_treats_copyright_option', array( 'capability' => 'edit_theme_options', 'transport' => 'refresh', 'default' => '', 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control( 'bakery_treats_copyright_option', array( 'label' => __('Edit Copyright Text', 'bakery-treats'), 'description' => __('Edit the Footer Copyright Section.', 'bakery-treats'), 'section' => 'bakery_treats_footer_section', 'type' => 'text', ) ); } add_action( 'customize_register', 'Bakery_Treats_Customize_register' ); /** * Render the site title for the selective refresh partial. * * @return void */ function Bakery_Treats_Customize_partial_blogname() { bloginfo( 'name' ); } /** * Render the site tagline for the selective refresh partial. * * @return void */ function Bakery_Treats_Customize_partial_blogdescription() { bloginfo( 'description' ); } /** * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. */ function Bakery_Treats_Customize_preview_js() { wp_enqueue_script( 'bakery-treats-customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), BAKERY_TREATS_VERSION, true ); } add_action( 'customize_preview_init', 'Bakery_Treats_Customize_preview_js' ); /** * Singleton class for handling the theme's customizer integration. * * @since 1.0.0 * @access public */ final class Bakery_Treats_Customize { /** * Returns the instance. * * @since 1.0.0 * @access public * @return object */ public static function get_instance() { static $instance = null; if ( is_null( $instance ) ) { $instance = new self; $instance->setup_actions(); } return $instance; } /** * Constructor method. * * @since 1.0.0 * @access private * @return void */ private function __construct() {} /** * Sets up initial actions. * * @since 1.0.0 * @access private * @return void */ private function setup_actions() { // Register panels, sections, settings, controls, and partials. add_action( 'customize_register', array( $this, 'sections' ) ); // Register scripts and styles for the controls. add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_control_scripts' ), 0 ); } /** * Sets up the customizer sections. * * @since 1.0.0 * @access public * @param object $manager * @return void */ public function sections( $manager ) { // Load custom sections. load_template( trailingslashit( get_template_directory() ) . '/revolution/inc/section-pro.php' ); // Register custom section types. $manager->register_section_type( 'bakery_treats_Customize_Section_Pro' ); // Register sections. $manager->add_section( new Bakery_Treats_Customize_Section_Pro( $manager,'bakery_treats_go_pro', array( 'priority' => 1, 'title' => esc_html__( 'Bakery Treats Pro', 'bakery-treats' ), 'pro_text' => esc_html__( 'Buy Pro', 'bakery-treats' ), 'pro_url' => esc_url( BAKERY_TREATS_BUY_NOW ), ) ) ); // Register sections. $manager->add_section( new Bakery_Treats_Customize_Section_Pro( $manager,'bakery_treats_lite_documentation', array( 'priority' => 1, 'title' => esc_html__( 'Lite Documentation', 'bakery-treats' ), 'pro_text' => esc_html__( 'Instruction', 'bakery-treats' ), 'pro_url' => esc_url( BAKERY_TREATS_LITE_DOC ), ) ) ); $manager->add_section( new Bakery_Treats_Customize_Section_Pro( $manager, 'bakery_treats_live_demo', array( 'priority' => 1, 'title' => esc_html__( 'Pro Theme Demo', 'bakery-treats' ), 'pro_text' => esc_html__( 'Live Preview', 'bakery-treats' ), 'pro_url' => esc_url( BAKERY_TREATS_LIVE_DEMO ), ) ) ); } /** * Loads theme customizer CSS. * * @since 1.0.0 * @access public * @return void */ public function enqueue_control_scripts() { wp_enqueue_script( 'bakery-treats-customize-controls', trailingslashit( get_template_directory_uri() ) . '/revolution/assets/js/customize-controls.js', array( 'customize-controls' ) ); wp_enqueue_style( 'bakery-treats-customize-controls', trailingslashit( get_template_directory_uri() ) . '/revolution/assets/css/customize-controls.css' ); } } // Doing this customizer thang! Bakery_Treats_Customize::get_instance();