=') ) { $wp_customize->get_section( 'static_front_page' )->title = __( 'Static Front Page', 'beautystore' ); } /* Option list of all post */ $beautystore_options_posts = array(); $beautystore_options_posts_obj = get_posts('posts_per_page=-1'); $beautystore_options_posts[''] = esc_html__( 'Choose Post', 'beautystore' ); foreach ( $beautystore_options_posts_obj as $beautystore_posts ) { $beautystore_options_posts[$beautystore_posts->ID] = $beautystore_posts->post_title; } /* Option list of all Page */ $beautystore_options_pages = array(); $beautystore_options_pages_obj = get_pages('posts_per_page=-1'); $beautystore_options_pages[''] = esc_html__( 'Choose Page', 'beautystore' ); foreach ( $beautystore_options_pages_obj as $beautystore_pages ) { $beautystore_options_pages[$beautystore_pages->ID] = $beautystore_pages->post_title; } /* Option list of all categories */ $beautystore_args = array( 'type' => 'post', 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => 1, 'hierarchical' => 1, 'taxonomy' => 'category' ); $beautystore_option_categories = array(); $beautystore_category_lists = get_categories( $beautystore_args ); $beautystore_option_categories[''] = esc_html__( 'Choose Category', 'beautystore' ); foreach( $beautystore_category_lists as $beautystore_category ){ $beautystore_option_categories[$beautystore_category->term_id] = $beautystore_category->name; } /** Default Settings */ $wp_customize->add_panel( 'wp_default_panel', array( 'priority' => 10, 'capability' => 'edit_theme_options', 'theme_supports' => '', 'title' => esc_html__( 'Default Settings', 'beautystore' ), 'description' => esc_html__( 'Default section provided by wordpress customizer.', 'beautystore' ), ) ); $wp_customize->get_section( 'title_tagline' )->panel = 'wp_default_panel'; $wp_customize->get_section( 'colors' )->panel = 'wp_default_panel'; $wp_customize->get_section( 'header_image' )->panel = 'wp_default_panel'; $wp_customize->get_section( 'background_image' )->panel = 'wp_default_panel'; $wp_customize->get_section( 'static_front_page' )->panel = 'wp_default_panel'; $wp_customize->get_setting( 'blogname' )->transport = 'postMessage'; $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage'; /** Default Settings Ends */ /** Home Page Settings */ $wp_customize->add_panel( 'beautystore_home_page_settings', array( 'priority' => 30, 'capability' => 'edit_theme_options', 'title' => esc_html__( 'Home Page Settings', 'beautystore' ), 'description' => esc_html__( 'Customize Home Page Settings', 'beautystore' ), ) ); /** Banner Section */ $wp_customize->add_section( 'beautystore_banner_settings', array( 'title' => esc_html__( 'Banner Section', 'beautystore' ), 'priority' => 10, 'panel' => 'beautystore_home_page_settings', ) ); /** Enable/Disable Banner Section */ $wp_customize->add_setting( 'beautystore_ed_banner_section', array( 'default' => '', 'sanitize_callback' => 'beautystore_sanitize_checkbox', ) ); $wp_customize->add_control( 'beautystore_ed_banner_section', array( 'label' => esc_html__( 'Enable Banner Section', 'beautystore' ), 'section' => 'beautystore_banner_settings', 'type' => 'checkbox', ) ); /** Banner Post */ $wp_customize->add_setting( 'beautystore_banner_post', array( 'default' => '', 'sanitize_callback' => 'beautystore_sanitize_select', ) ); $wp_customize->add_control( 'beautystore_banner_post', array( 'label' => esc_html__( 'Select Banner Post', 'beautystore' ), 'section' => 'beautystore_banner_settings', 'type' => 'select', 'choices' => $beautystore_options_posts, ) ); /** Read More Text */ $wp_customize->add_setting( 'beautystore_banner_read_more', array( 'default' => esc_html__( 'Read More', 'beautystore' ), 'sanitize_callback' => 'beautystore_sanitize_nohtml', ) ); $wp_customize->add_control( 'beautystore_banner_read_more', array( 'label' => esc_html__( 'Read More Text', 'beautystore' ), 'section' => 'beautystore_banner_settings', 'type' => 'text', ) ); /** Banner Section Ends */ /** Service Section */ $wp_customize->add_section( 'beautystore_featured_settings', array( 'title' => esc_html__( 'Service Section', 'beautystore' ), 'priority' => 30, 'panel' => 'beautystore_home_page_settings', ) ); /** Enable/Disable Service Section */ $wp_customize->add_setting( 'beautystore_ed_featured_section', array( 'default' => '', 'sanitize_callback' => 'beautystore_sanitize_checkbox', ) ); $wp_customize->add_control( 'beautystore_ed_featured_section', array( 'label' => esc_html__( 'Enable Service Pagess Section', 'beautystore' ), 'section' => 'beautystore_featured_settings', 'type' => 'checkbox', ) ); /** Service Section Title */ $wp_customize->add_setting( 'beautystore_featured_post_title', array( 'default' => esc_html__( 'Our Services', 'beautystore' ), 'sanitize_callback' => 'beautystore_sanitize_nohtml', ) ); $wp_customize->add_control( 'beautystore_featured_post_title', array( 'label' => esc_html__( 'Service Section Title', 'beautystore' ), 'section' => 'beautystore_featured_settings', 'type' => 'text', ) ); /** Service Section Content */ $wp_customize->add_setting( 'beautystore_featured_post_content', array( 'default' => '', 'sanitize_callback' => 'beautystore_sanitize_html', ) ); $wp_customize->add_control( 'beautystore_featured_post_content', array( 'label' => esc_html__( 'Service Section Content', 'beautystore' ), 'section' => 'beautystore_featured_settings', 'type' => 'textarea', ) ); /** Service Page One */ $wp_customize->add_setting( 'beautystore_featured_post_one', array( 'default' => '', 'sanitize_callback' => 'beautystore_sanitize_select', ) ); $wp_customize->add_control( 'beautystore_featured_post_one', array( 'label' => esc_html__( 'Select Service Page One', 'beautystore' ), 'section' => 'beautystore_featured_settings', 'type' => 'select', 'choices' => $beautystore_options_pages, ) ); /** Favicon for Page one */ $wp_customize->add_setting( 'beautystore_favicon-one', array( 'default' => '', 'sanitize_callback' => 'beautystore_sanitize_nohtml', ) ); $wp_customize->add_control( 'beautystore_favicon-one', array( 'label' => esc_html__( 'Favicon Name For Page One', 'beautystore' ), 'section' => 'beautystore_featured_settings', 'type' => 'text', ) ); /** Service Page Two */ $wp_customize->add_setting( 'beautystore_featured_post_two', array( 'default' => '', 'sanitize_callback' => 'beautystore_sanitize_select', ) ); $wp_customize->add_control( 'beautystore_featured_post_two', array( 'label' => esc_html__( 'Select Service Page Two', 'beautystore' ), 'section' => 'beautystore_featured_settings', 'type' => 'select', 'choices' => $beautystore_options_pages, ) ); /** Favicon for post Two */ $wp_customize->add_setting( 'beautystore_favicon-two', array( 'default' => '', 'sanitize_callback' => 'beautystore_sanitize_nohtml', ) ); $wp_customize->add_control( 'beautystore_favicon-two', array( 'label' => esc_html__( 'Favicon Name For Page Two', 'beautystore' ), 'section' => 'beautystore_featured_settings', 'type' => 'text', ) ); /** Service Page Three */ $wp_customize->add_setting( 'beautystore_featured_post_three', array( 'default' => '', 'sanitize_callback' => 'beautystore_sanitize_select', ) ); $wp_customize->add_control( 'beautystore_featured_post_three', array( 'label' => esc_html__( 'Select Service Page Three', 'beautystore' ), 'section' => 'beautystore_featured_settings', 'type' => 'select', 'choices' => $beautystore_options_pages, ) ); /** Favicon for post three */ $wp_customize->add_setting( 'beautystore_favicon-three', array( 'default' => '', 'sanitize_callback' => 'beautystore_sanitize_nohtml', ) ); $wp_customize->add_control( 'beautystore_favicon-three', array( 'label' => esc_html__( 'Favicon Name For Page Three', 'beautystore' ), 'section' => 'beautystore_featured_settings', 'type' => 'text', ) ); /** Service Page four */ $wp_customize->add_setting( 'beautystore_featured_post_four', array( 'default' => '', 'sanitize_callback' => 'beautystore_sanitize_select', ) ); $wp_customize->add_control( 'beautystore_featured_post_four', array( 'label' => esc_html__( 'Select Service Page Four', 'beautystore' ), 'section' => 'beautystore_featured_settings', 'type' => 'select', 'choices' => $beautystore_options_pages, ) ); /** Favicon for post three */ $wp_customize->add_setting( 'beautystore_favicon-four', array( 'default' => '', 'sanitize_callback' => 'beautystore_sanitize_nohtml', ) ); $wp_customize->add_control( 'beautystore_favicon-four', array( 'label' => esc_html__( 'Favicon Name For Page Four', 'beautystore' ), 'section' => 'beautystore_featured_settings', 'type' => 'text', ) ); /** Service Page five */ $wp_customize->add_setting( 'beautystore_featured_post_five', array( 'default' => '', 'sanitize_callback' => 'beautystore_sanitize_select', ) ); $wp_customize->add_control( 'beautystore_featured_post_five', array( 'label' => esc_html__( 'Select Service Page Five', 'beautystore' ), 'section' => 'beautystore_featured_settings', 'type' => 'select', 'choices' => $beautystore_options_pages, ) ); /** Favicon for post five */ $wp_customize->add_setting( 'beautystore_favicon-five', array( 'default' => '', 'sanitize_callback' => 'beautystore_sanitize_nohtml', ) ); $wp_customize->add_control( 'beautystore_favicon-five', array( 'label' => esc_html__( 'Favicon Name For Page Five', 'beautystore' ), 'section' => 'beautystore_featured_settings', 'type' => 'text', ) ); /** Service Page six */ $wp_customize->add_setting( 'beautystore_featured_post_six', array( 'default' => '', 'sanitize_callback' => 'beautystore_sanitize_select', ) ); $wp_customize->add_control( 'beautystore_featured_post_six', array( 'label' => esc_html__( 'Select Service Page Six', 'beautystore' ), 'section' => 'beautystore_featured_settings', 'type' => 'select', 'choices' => $beautystore_options_pages, ) ); /** Favicon for page six */ $wp_customize->add_setting( 'beautystore_favicon-six', array( 'default' => '', 'sanitize_callback' => 'beautystore_sanitize_nohtml', ) ); $wp_customize->add_control( 'beautystore_favicon-six', array( 'label' => esc_html__( 'Favicon Name For Page six', 'beautystore' ), 'section' => 'beautystore_featured_settings', 'type' => 'text', ) ); /** Service Section Ends */ /** About Section */ $wp_customize->add_section( 'beautystore_about_settings', array( 'title' => esc_html__( 'About Section', 'beautystore' ), 'priority' => 20, 'panel' => 'beautystore_home_page_settings', ) ); /** Enable/Disable About Note Section */ $wp_customize->add_setting( 'beautystore_ed_about_section', array( 'default' => '', 'sanitize_callback' => 'beautystore_sanitize_checkbox', ) ); $wp_customize->add_control( 'beautystore_ed_about_section', array( 'label' => esc_html__( 'Enable About Section', 'beautystore' ), 'section' => 'beautystore_about_settings', 'type' => 'checkbox', ) ); /** About Section Post */ $wp_customize->add_setting( 'beautystore_about_post', array( 'default' => '', 'sanitize_callback' => 'beautystore_sanitize_select', ) ); $wp_customize->add_control( 'beautystore_about_post', array( 'label' => esc_html__( 'Select About Section Page', 'beautystore' ), 'section' => 'beautystore_about_settings', 'type' => 'select', 'choices' => $beautystore_options_pages, ) ); /** Read More Text */ $wp_customize->add_setting( 'beautystore_about_read_more', array( 'default' => esc_html__( 'Read More', 'beautystore' ), 'sanitize_callback' => 'beautystore_sanitize_nohtml', ) ); $wp_customize->add_control( 'beautystore_about_read_more', array( 'label' => esc_html__( 'Read More Text', 'beautystore' ), 'section' => 'beautystore_about_settings', 'type' => 'text', ) ); /** About Section Ends */ /** Callout Section */ $wp_customize->add_section( 'beautystore_testimonial_settings', array( 'title' => esc_html__( 'Callout Section', 'beautystore' ), 'priority' => 50, 'panel' => 'beautystore_home_page_settings', ) ); /** Enable/Disable Callout Section */ $wp_customize->add_setting( 'beautystore_ed_testimonial_section', array( 'default' => '', 'sanitize_callback' => 'beautystore_sanitize_checkbox', ) ); $wp_customize->add_control( 'beautystore_ed_testimonial_section', array( 'label' => esc_html__( 'Enable Callout Section', 'beautystore' ), 'section' => 'beautystore_testimonial_settings', 'type' => 'checkbox', ) ); /** Callout Section Title */ $wp_customize->add_setting( 'beautystore_testimonial_section_title', array( 'default' => esc_html__( 'Our Special Offer', 'beautystore' ), 'sanitize_callback' => 'beautystore_sanitize_nohtml', ) ); $wp_customize->add_control( 'beautystore_testimonial_section_title', array( 'label' => esc_html__( 'Callout Section Title', 'beautystore' ), 'section' => 'beautystore_testimonial_settings', 'type' => 'text', ) ); /** Callout Section Content */ $wp_customize->add_setting( 'beautystore_testimonial_section_content', array( 'default' => '', 'sanitize_callback' => 'beautystore_sanitize_html', ) ); $wp_customize->add_control( 'beautystore_testimonial_section_content', array( 'label' => esc_html__( 'Callout Section Content', 'beautystore' ), 'section' => 'beautystore_testimonial_settings', 'type' => 'textarea', ) ); /** Callout btn text */ $wp_customize->add_setting( 'beautystore_callout_btntxt', array( 'sanitize_callback' => 'beautystore_sanitize_html', ) ); $wp_customize->add_control( 'beautystore_callout_btntxt', array( 'label' => esc_html__( 'Callout Button Text', 'beautystore' ), 'section' => 'beautystore_testimonial_settings', 'type' => 'text', ) ); /** Callout Button Url */ $wp_customize->add_setting( 'beautystore_callout_btnurl', array( 'sanitize_callback' => 'beautystore_sanitize_html', ) ); $wp_customize->add_control( 'beautystore_callout_btnurl', array( 'label' => esc_html__( 'Callout Button Url', 'beautystore' ), 'section' => 'beautystore_testimonial_settings', 'type' => 'text', ) ); /** Callout Section Ends */ /** Blog Section */ $wp_customize->add_section( 'beautystore_service_settings', array( 'title' => esc_html__( 'Blog Section', 'beautystore' ), 'priority' => 40, 'panel' => 'beautystore_home_page_settings', ) ); /** Enable/Disable Blog Section */ $wp_customize->add_setting( 'beautystore_ed_service_section', array( 'default' => true, 'sanitize_callback' => 'beautystore_sanitize_checkbox', ) ); $wp_customize->add_control( 'beautystore_ed_service_section', array( 'label' => esc_html__( 'Enable Blog Section', 'beautystore' ), 'section' => 'beautystore_service_settings', 'type' => 'checkbox', ) ); /** Blog Section Title */ $wp_customize->add_setting( 'beautystore_service_post_title', array( 'default' => esc_html__( 'Our Blog', 'beautystore' ), 'sanitize_callback' => 'beautystore_sanitize_nohtml', ) ); $wp_customize->add_control( 'beautystore_service_post_title', array( 'label' => esc_html__( 'Blog Section Title', 'beautystore' ), 'section' => 'beautystore_service_settings', 'type' => 'text', ) ); /** Service Section Content */ $wp_customize->add_setting( 'beautystore_service_post_content', array( 'default' => '', 'sanitize_callback' => 'beautystore_sanitize_html', ) ); $wp_customize->add_control( 'beautystore_service_post_content', array( 'label' => esc_html__( 'Blog Section Content', 'beautystore' ), 'section' => 'beautystore_service_settings', 'type' => 'textarea', ) ); /** Blog Section Ends */ /** Home Page Settings Ends */ /** Footer Section */ $wp_customize->add_section( 'beautystore_footer_section', array( 'title' => __( 'Footer Settings', 'beautystore' ), 'priority' => 70, ) ); /** Copyright Text */ $wp_customize->add_setting( 'beautystore_footer_copyright_text', array( 'default' => '', 'sanitize_callback' => 'wp_kses_post', ) ); $wp_customize->add_control( 'beautystore_footer_copyright_text', array( 'label' => __( 'Copyright Info', 'beautystore' ), 'section' => 'beautystore_footer_section', 'type' => 'textarea', ) ); /** * Sanitization Functions * * @link https://github.com/WPTRT/code-examples/blob/master/customizer/sanitization-callbacks.php */ function beautystore_sanitize_checkbox( $checked ){ // Boolean check. return ( ( isset( $checked ) && true == $checked ) ? true : false ); } function beautystore_sanitize_nohtml( $nohtml ){ return wp_filter_nohtml_kses( $nohtml ); } function beautystore_sanitize_html( $html ){ return wp_filter_post_kses( $html ); } function beautystore_sanitize_select( $input, $setting ){ // Ensure input is a slug. $input = sanitize_key( $input ); // Get list of choices from the control associated with the setting. $choices = $setting->manager->get_control( $setting->id )->choices; // If the input is a valid key, return it; otherwise, return the default. return ( array_key_exists( $input, $choices ) ? $input : $setting->default ); } function beautystore_sanitize_url( $url ){ return esc_url_raw( $url ); } } add_action( 'customize_register', 'beautystore_customize_register' ); endif; /** * Binds JS handlers to make Theme Customizer preview reload changes asynchronously. */ function beautystore_customize_preview_js() { // Use minified libraries if SCRIPT_DEBUG is false $build = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '/build' : ''; wp_enqueue_script( 'beautystore_customizer', get_template_directory_uri() . '/assets/js' . $build . '/customizer.js', array( 'customize-preview' ), '20130508', true ); } add_action( 'customize_preview_init', 'beautystore_customize_preview_js' );