get_setting( 'blogname' )->transport = 'postMessage';
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
$wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';
$wp_customize->get_section('static_front_page' )->priority = 2;
$wp_customize->get_section('static_front_page' )->description = '';
$wp_customize->remove_control("page_for_posts");
/**
* List All Pages
*/
$slider_pages = array();
$slider_pages_obj = get_pages();
$slider_pages[''] = esc_html__('Select Slider Page','sparklestore');
foreach ($slider_pages_obj as $page) {
$slider_pages[$page->ID] = $page->post_title;
}
// List All Category
$categories = get_categories();
$blog_cat = array();
foreach ($categories as $category) {
$blog_cat[$category->term_id] = $category->name;
}
$sparklestorepro_features = '
- ' . esc_html__( "20+ One Click Pre-defined demos" , "sparklestore" ) . '
- ' . esc_html__( "Multiple Header Layouts and Setting" , "sparklestore" ) . '
- ' . esc_html__( "Unlimited Color Options" , "sparklestore" ) . '
- ' . esc_html__( "Advanced Top Header Setting" , "sparklestore" ) . '
- ' . esc_html__( "Search Options (with category, Ajax)" , "sparklestore" ) . '
- ' . esc_html__( "GDPR Compliance & Cookies Consent" , "sparklestore" ) . '
- ' . esc_html__( "Included Maintenance Mode" , "sparklestore" ) . '
- ' . esc_html__( "Slider Type and Layout Options" , "sparklestore" ) . '
- ' . esc_html__( "27+ Custom Elementor Block" , "sparklestore" ) . '
- ' . esc_html__( "24+ Custom Widgets" , "sparklestore" ) . '
- ' . esc_html__( "Remove Footer Credit Text" , "sparklestore" ) . '
- ' . esc_html__( "Breadcrumb Layout and Option" , "sparklestore" ) . '
- ' . esc_html__( "Website layout (Fullwidth or Boxed)" , "sparklestore" ) . '
- ' . esc_html__( "4+ advanced blog Layout" , "sparklestore" ) . '
- ' . esc_html__( "Offers/Deals Section" , "sparklestore" ) . '
- ' . esc_html__( "WooCommerce Compatible" , "sparklestore" ) . '
- ' . esc_html__( "Fully Multilingual and Translation ready" , "sparklestore" ) . '
- ' . esc_html__( "Fully RTL ready" , "sparklestore" ) . '
';
/**
* Important Link
*/
$wp_customize->add_section('sparklestore_implink_link_section',array(
'title' => esc_html__( 'Pro Theme Features', 'sparklestore' ),
'priority' => 1
));
$wp_customize->add_setting('sparklestore_pro_theme_features', array(
'title' => esc_html__('Pro Theme Features', 'sparklestore'),
'sanitize_callback' => 'sparklestore_text_sanitize',
'priority' => 1
));
$wp_customize->add_control( new Sparklestore_theme_Info_Text( $wp_customize, 'sparklestore_pro_theme_features', array(
'settings' => 'sparklestore_pro_theme_features',
'section' => 'sparklestore_implink_link_section',
'description' => $sparklestorepro_features,
)));
$wp_customize->add_setting('sparklestore_implink_link_options', array(
'title' => esc_html__('Important Links', 'sparklestore'),
'sanitize_callback' => 'sanitize_text_field',
'priority' => 2
));
$wp_customize->add_control( new Sparklestore_theme_Info_Text( $wp_customize, 'sparklestore_implink_link_options', array(
'settings' => 'sparklestore_implink_link_options',
'section' => 'sparklestore_implink_link_section',
'description' => ''.esc_html__('Documentation', 'sparklestore').''.esc_html__('Live Demo', 'sparklestore').''.esc_html__('Support Forum', 'sparklestore').''.esc_html__('Like Us in Facebook', 'sparklestore').'',
)));
$wp_customize->add_setting( 'sparklestore_rate_us', array(
'title' => esc_html__('Rate / Review', 'sparklestore'),
'sanitize_callback' => 'sparklestore_text_sanitize'
));
$wp_customize->add_control( new Sparklestore_theme_Info_Text( $wp_customize, 'sparklestore_rate_us', array(
'settings' => 'sparklestore_rate_us',
'section' => 'sparklestore_implink_link_section',
'description' => sprintf( __( 'Please do rate our theme if you liked it %1$s', 'sparklestore'), ''.esc_html__('Rate/Review','sparklestore').'' ),
)
));
$wp_customize->add_setting( 'sparklestore_setup_instruction', array(
'title' => esc_html__('Instruction Setup Home Page', 'sparklestore'),
'sanitize_callback' => 'sparklestore_text_sanitize'
));
/**
* General Settings Panel
*/
$wp_customize->add_panel('sparklestore_general_settings', array(
'capabitity' => 'edit_theme_options',
'priority' => 5,
'title' => esc_html__('General Settings', 'sparklestore')
));
$wp_customize->get_section('title_tagline')->panel = 'sparklestore_general_settings';
$wp_customize->get_section('title_tagline' )->priority = 1;
$wp_customize->get_section('header_image')->panel = 'sparklestore_general_settings';
$wp_customize->get_section('header_image' )->priority = 3;
$wp_customize->get_section('background_image')->panel = 'sparklestore_general_settings';
$wp_customize->get_section('header_image' )->priority = 4;
/**
* Website Layout Section
*/
$wp_customize->add_section( 'sparklestore_web_page_layout', array(
'title' => esc_html__('Website Layout', 'sparklestore'),
'panel' => 'sparklestore_general_settings'
));
$wp_customize->add_setting('sparklestore_web_page_layout_options', array(
'default' => 'disable',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'sparklestore_radio_enable_disable_sanitize',
//'transport' => 'postMessage'
));
$wp_customize->add_control('sparklestore_web_page_layout_options', array(
'type' => 'radio',
'label' => esc_html__('Enable / Disable Top Header', 'sparklestore'),
'section' => 'sparklestore_web_page_layout',
'settings' => 'sparklestore_web_page_layout_options',
'choices' => array(
'enable' => esc_html__('Boxed Layout', 'sparklestore'),
'disable' => esc_html__('Full Width Layout', 'sparklestore')
)
));
/**
* Main Header Panel
*/
$wp_customize->add_panel( 'sparklestore_header_settings_panel', array(
'priority' => 6,
'title' => esc_html__( 'Main Header Settings', 'sparklestore' ),
));
/**
* Top Header Settings
*/
$wp_customize->add_section(
'sparklestore_top_header_section',
array(
'title' => esc_html__( 'Top Header Settings', 'sparklestore' ),
'panel' => 'sparklestore_header_settings_panel',
'priority' => 1,
)
);
/**
* Enable/Disable Top Header Options
*/
$wp_customize->add_setting(
'sparklestore_top_header_section_options',
array(
'sanitize_callback' => 'sparklestore_sanitize_on_off',
'default' => 'on'
)
);
$wp_customize->add_control( new Sparklestore_Switch_Control(
$wp_customize,
'sparklestore_top_header_section_options',
array(
'settings' => 'sparklestore_top_header_section_options',
'section' => 'sparklestore_top_header_section',
'label' => esc_html__( 'Top Header Section', 'sparklestore' ),
'on_off_label' => array(
'on' => esc_html__( 'Enable', 'sparklestore' ),
'off' => esc_html__( 'Disable', 'sparklestore' )
)
)
)
);
$leftside_options = array(
'topmenu' => esc_html__( 'Top Nav Menu', 'sparklestore' ),
'quickinfo' => esc_html__( 'Quick Contact Information', 'sparklestore' ),
'socialicon' => esc_html__( 'Social Media Link', 'sparklestore' )
);
$wp_customize->add_setting(
'sparklestore_top_header_leftside_options',
array(
'default' => 'quickinfo',
'sanitize_callback' => 'sparklestore_select_type_sanitize',
)
);
$wp_customize->add_control(
'sparklestore_top_header_leftside_options',
array(
'type' => 'select',
'label' => esc_html__( 'Top Header Leftside Options', 'sparklestore' ),
'section' => 'sparklestore_top_header_section',
'choices' => $leftside_options
)
);
$rightside_options = array(
'none' => esc_html__( 'None', 'sparklestore' ),
'topmenu' => esc_html__( 'Top Nav Menu', 'sparklestore' ),
'socialicon' => esc_html__( 'Social Media Link', 'sparklestore' ),
'ecommerceitem' => esc_html__( 'eCommerce Items ( Cart, My Account, Wishlist )', 'sparklestore' )
);
$wp_customize->add_setting(
'sparklestore_top_header_rightside_options',
array(
'default' => 'ecommerceitem',
'sanitize_callback' => 'sparklestore_select_type_sanitize',
)
);
$wp_customize->add_control(
'sparklestore_top_header_rightside_options',
array(
'type' => 'select',
'label' => esc_html__( 'Top Header Rightside Options', 'sparklestore' ),
'section' => 'sparklestore_top_header_section',
'choices' => $rightside_options
)
);
/**
* Main Header Settings Option
*/
$wp_customize->add_section(
'sparklestore_header_option_section',
array(
'title' => esc_html__( 'Main Header Settings', 'sparklestore' ),
'panel' => 'sparklestore_header_settings_panel',
'priority' => 2,
)
);
$wp_customize->add_setting(
'sparklestore_search_options',
array(
'default' => 'advancesearch',
'sanitize_callback' => 'sparklestore_search_options_sanitize',
)
);
$wp_customize->add_control(
'sparklestore_search_options',
array(
'type' => 'radio',
'label' => esc_html__( 'Choose Search Options', 'sparklestore' ),
'section' => 'sparklestore_header_option_section',
'choices' => array(
'normalsearch' => esc_html__( 'Normal Search', 'sparklestore' ),
'advancesearch' => esc_html__( 'Advance Search ( With Category )', 'sparklestore' )
),
)
);
/**
* Text field for search placeholder caption
*/
$wp_customize->add_setting(
'sparklestore_search_placeholder_text',
array(
'default' => esc_html__( 'Product Search...', 'sparklestore' ),
'sanitize_callback' => 'sanitize_text_field'
)
);
$wp_customize->add_control(
'sparklestore_search_placeholder_text',
array(
'type' => 'text',
'label' => esc_html__( 'Enter the Search Box Placeholder Text', 'sparklestore' ),
'section' => 'sparklestore_header_option_section',
)
);
/**
* Main Header Settings Option
*/
$wp_customize->add_section(
'sparklestore_vertical_menu_section',
array(
'title' => esc_html__( 'Vertical Menu Settings', 'sparklestore' ),
'panel' => 'sparklestore_header_settings_panel',
'priority' => 3,
)
);
/**
* Enable/Disable Options
*/
$wp_customize->add_setting(
'sparklestore_vertical_menu_options',
array(
'sanitize_callback' => 'sparklestore_sanitize_on_off',
'default' => 'on'
)
);
$wp_customize->add_control( new Sparklestore_Switch_Control(
$wp_customize,
'sparklestore_vertical_menu_options',
array(
'section' => 'sparklestore_vertical_menu_section',
'label' => esc_html__( 'Vertical Menu', 'sparklestore' ),
'description' => esc_html__( 'Enable/Disable option for vertical menu', 'sparklestore' ),
'on_off_label' => array(
'on' => esc_html__( 'Enable', 'sparklestore' ),
'off' => esc_html__( 'Disable', 'sparklestore' )
)
)
)
);
/**
* Text field for Vertical Menu Show All Menu Text
*/
$wp_customize->add_setting(
'sparklestore_vertical_menu_show_all_menu',
array(
'default' => esc_html__( 'More Categories', 'sparklestore' ),
'sanitize_callback' => 'sanitize_text_field'
)
);
$wp_customize->add_control(
'sparklestore_vertical_menu_show_all_menu',
array(
'type' => 'text',
'label' => esc_html__( 'Vertical Menu Show All Menu Text', 'sparklestore' ),
'section' => 'sparklestore_vertical_menu_section',
)
);
/**
* Text field for Vertical Menu Button Close Text
*/
$wp_customize->add_setting(
'sparklestore_vertical_menu_show_all_menu_close',
array(
'default' => esc_html__( 'Close', 'sparklestore' ),
'sanitize_callback' => 'sanitize_text_field'
)
);
$wp_customize->add_control(
'sparklestore_vertical_menu_show_all_menu_close',
array(
'type' => 'text',
'label' => esc_html__( 'Vertical Menu Button Close Text', 'sparklestore' ),
'section' => 'sparklestore_vertical_menu_section',
)
);
/**
* Text field for Visible Vertical Menu Items
*/
$wp_customize->add_setting(
'sparklestore_vertical_menu_display_itmes',
array(
'default' => 10,
'sanitize_callback' => 'absint'
)
);
$wp_customize->add_control(
'sparklestore_vertical_menu_display_itmes',
array(
'type' => 'number',
'label' => esc_html__( 'Visible Vertical Menu Items', 'sparklestore' ),
'section' => 'sparklestore_vertical_menu_section',
)
);
/**
* Quick Contact Information Settings
*/
$wp_customize->add_section( 'sparklestore_header_quickinfo', array(
'priority' => 5,
'title' => esc_html__( 'Quick Contact Information', 'sparklestore' ),
'panel' => 'sparklestore_header_settings_panel'
));
$wp_customize->add_setting('sparklestore_email_title', array(
'default' => '',
'sanitize_callback' => 'sanitize_email', // done
));
$wp_customize->add_control('sparklestore_email_title',array(
'type' => 'text',
'label' => esc_html__('Email Address', 'sparklestore'),
'section' => 'sparklestore_header_quickinfo',
'setting' => 'sparklestore_email_title',
));
$wp_customize->selective_refresh->add_partial( 'sparklestore_email_title', array(
'selector' => '.footerservices .services_icon',
) );
$wp_customize->add_setting('sparklestore_phone_number', array(
'default' => '',
'sanitize_callback' => 'sparklestore_text_sanitize', // done
));
$wp_customize->add_control('sparklestore_phone_number',array(
'type' => 'text',
'label' => esc_html__('Phone Number', 'sparklestore'),
'section' => 'sparklestore_header_quickinfo',
'setting' => 'sparklestore_phone_number',
));
$wp_customize->add_setting('sparklestore_map_address', array(
'default' => '',
'sanitize_callback' => 'sparklestore_text_sanitize', // done
));
$wp_customize->add_control('sparklestore_map_address',array(
'type' => 'text',
'label' => esc_html__('Address', 'sparklestore'),
'section' => 'sparklestore_header_quickinfo',
'setting' => 'sparklestore_map_address',
));
$wp_customize->add_setting('sparklestore_start_open_time', array(
'default' => '',
'sanitize_callback' => 'sparklestore_text_sanitize', // done
));
$wp_customize->add_control('sparklestore_start_open_time',array(
'type' => 'text',
'label' => esc_html__('Opening Time', 'sparklestore'),
'section' => 'sparklestore_header_quickinfo',
'setting' => 'sparklestore_start_open_time',
));
/**
* WooCommerce Panel
*
* @since 1.0.0
*/
$wp_customize->add_panel(
'woocommerce',
array(
'priority' => 6,
'title' => esc_html__( 'WooCommerce Settings', 'sparklestore' ),
)
);
/**
* Register the radio image control class as a JS control type.
*/
$wp_customize->register_control_type( 'Sparklestore_Customize_Control_Radio_Image' );
if ( class_exists( 'WooCommerce' ) ) {
/**
* WooCommerce Category/Archive Page Layout Settings
*
* @since 1.0.0
*/
$wp_customize->get_section('woocommerce_product_catalog')->title = esc_html__( 'Shop & Category Page Settings', 'sparklestore' );
$wp_customize->get_section('woocommerce_product_catalog' )->priority = 1;
/**
* Image Radio field for woocommerce archive/category sidebar
*
* @since 1.0.0
*/
$wp_customize->add_setting(
'sparklestore_woocommerce_products_page_layout',
array(
'default' => 'rightsidebar',
'sanitize_callback' => 'sanitize_key',
)
);
$wp_customize->add_control( new Sparklestore_Customize_Control_Radio_Image(
$wp_customize,
'sparklestore_woocommerce_products_page_layout',
array(
'label' => esc_html__( 'WooCommerce Archive/Category Page', 'sparklestore' ),
'description' => esc_html__( 'Choose sidebar from available layouts', 'sparklestore' ),
'section' => 'woocommerce_product_catalog',
'priority' => 1,
'choices' => array(
'leftsidebar' => array(
'label' => esc_html__( 'Left Sidebar', 'sparklestore' ),
'url' => '%s/assets/images/left-sidebar.png'
),
'rightsidebar' => array(
'label' => esc_html__( 'Right Sidebar', 'sparklestore' ),
'url' => '%s/assets/images/right-sidebar.png'
),
'nosidebar' => array(
'label' => esc_html__( 'No Sidebar', 'sparklestore' ),
'url' => '%s/assets/images/no-sidebar.png'
)
)
)
)
);
/**
* WooCommerce Single Page Layout Settings
*
* @since 1.0.0
*/
$wp_customize->add_section(
'sparklestore_woo_single_settings_section',
array(
'title' => esc_html__( 'Single Product Page Settings', 'sparklestore' ),
'panel' => 'woocommerce',
'priority' => 2,
)
);
/**
* Image Radio field for woocommerce archive/category sidebar
*
* @since 1.0.0
*/
$wp_customize->add_setting(
'sparklestore_woocommerce_single_products_page_layout',
array(
'default' => 'rightsidebar',
'sanitize_callback' => 'sanitize_key',
)
);
$wp_customize->add_control( new Sparklestore_Customize_Control_Radio_Image(
$wp_customize,
'sparklestore_woocommerce_single_products_page_layout',
array(
'label' => esc_html__( 'WooCommerce Single Product Page', 'sparklestore' ),
'description' => esc_html__( 'Choose sidebar from available layouts', 'sparklestore' ),
'section' => 'sparklestore_woo_single_settings_section',
'choices' => array(
'leftsidebar' => array(
'label' => esc_html__( 'Left Sidebar', 'sparklestore' ),
'url' => '%s/assets/images/left-sidebar.png'
),
'rightsidebar' => array(
'label' => esc_html__( 'Right Sidebar', 'sparklestore' ),
'url' => '%s/assets/images/right-sidebar.png'
),
'nosidebar' => array(
'label' => esc_html__( 'No Sidebar', 'sparklestore' ),
'url' => '%s/assets/images/no-sidebar.png'
)
)
)
)
);
/**
* Text field for related product section title
*
* @since 1.0.0
*/
$wp_customize->add_setting(
'sparklestore_single_related_product_title',
array(
'default' => esc_html__( 'Related Products', 'sparklestore' ),
'sanitize_callback' => 'sanitize_text_field'
)
);
$wp_customize->add_control(
'sparklestore_single_related_product_title',
array(
'type' => 'text',
'label' => esc_html__( 'Enter Related Product Title', 'sparklestore' ),
'section' => 'sparklestore_woo_single_settings_section',
)
);
/**
* Number field for related product section
*
* @since 1.0.0
*/
$wp_customize->add_setting(
'sparklestore_single_num_related_product',
array(
'default' => 6,
'sanitize_callback' => 'absint'
)
);
$wp_customize->add_control(
'sparklestore_single_num_related_product',
array(
'type' => 'number',
'label' => esc_html__( 'Display Number Related Product', 'sparklestore' ),
'section' => 'sparklestore_woo_single_settings_section',
)
);
/**
* Number field for Upsells product section
*
* @since 1.0.0
*/
$wp_customize->add_setting(
'sparklestore_single_num_upsells_product',
array(
'default' => 6,
'sanitize_callback' => 'absint'
)
);
$wp_customize->add_control(
'sparklestore_single_num_upsells_product',
array(
'type' => 'number',
'label' => esc_html__( 'Display Number Upsells Product', 'sparklestore' ),
'section' => 'sparklestore_woo_single_settings_section',
)
);
}
/**
* Theme Primary Color Options
*/
$wp_customize->get_section('colors')->title = esc_html__( 'Themes Colors Settings', 'sparklestore' );
$wp_customize->get_section('colors' )->priority = 8;
$wp_customize->add_setting('sparklestore_primary_theme_color_options', array(
'default' => '#003772',
'sanitize_callback' => 'sanitize_hex_color',
));
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'sparklestore_primary_theme_color_options', array(
'label' => esc_html__( 'Primary Color', 'sparklestore' ),
'section' => 'colors',
)));
$wp_customize->add_setting('sparklestore_secondary_theme_color_options', array(
'default' => '#f33c3c',
'sanitize_callback' => 'sanitize_hex_color',
));
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'sparklestore_secondary_theme_color_options', array(
'label' => esc_html__( 'Secondary Color', 'sparklestore' ),
'section' => 'colors',
)));
/**
* Banner Slider
*/
$wp_customize->add_section( 'sparklestore_banner_slider', array(
'title' => esc_html__('Slider Settings Options', 'sparklestore'),
'priority' => 9,
));
$sliderlayout = array(
'fullslider' => esc_html__( 'Full Slider', 'sparklestore' ),
'sliderpromo' => esc_html__( 'Slider With Promo Images', 'sparklestore' )
);
$wp_customize->add_setting(
'sparklestore_slider_layout_options',
array(
'default' => 'fullslider',
'sanitize_callback' => 'sparklestore_select_type_sanitize',
)
);
$wp_customize->add_control(
'sparklestore_slider_layout_options',
array(
'type' => 'select',
'label' => esc_html__( 'Slider Layout Settings', 'sparklestore' ),
'section' => 'sparklestore_banner_slider',
'choices' => $sliderlayout
)
);
if ( ! function_exists( 'sparklestore_slider_type_options' ) ) {
function sparklestore_slider_type_options(){
if(esc_attr(get_theme_mod('sparklestore_slider_layout_options','fullslider')) =='sliderpromo'){
return true;
}else{
return false;
}
}
}
/**
* Enable/Disable Options
*/
$wp_customize->add_setting(
'sparklestore_slider_options',
array(
'sanitize_callback' => 'sparklestore_sanitize_on_off',
'default' => 'on'
)
);
$wp_customize->add_control( new Sparklestore_Switch_Control(
$wp_customize,
'sparklestore_slider_options',
array(
'section' => 'sparklestore_banner_slider',
'label' => esc_html__( 'Enable/Disable Section', 'sparklestore' ),
'on_off_label' => array(
'on' => esc_html__( 'Enable', 'sparklestore' ),
'off' => esc_html__( 'Disable', 'sparklestore' )
)
)
)
);
$wp_customize->add_setting( 'sparklestore_banner_all_sliders', array(
'sanitize_callback' => 'sparklestore_sanitize_repeater',
'default' => json_encode( array(
array(
'selectpage' => '' ,
'button_text' => '',
'button_url' => ''
)
) )
) );
$wp_customize->add_control( new Sparklestore_Repeater_Controler( $wp_customize, 'sparklestore_banner_all_sliders', array(
'label' => __('Slider Settings Area','sparklestore'),
'section' => 'sparklestore_banner_slider',
'settings' => 'sparklestore_banner_all_sliders',
'sparklestore_box_label' => __('Slider Settings Options','sparklestore'),
'sparklestore_box_add_control' => __('Add New Slider','sparklestore'),
),
array(
'selectpage' => array(
'type' => 'select',
'label' => __( 'Select Slider Page', 'sparklestore' ),
'options' => $slider_pages
),
'button_text' => array(
'type' => 'text',
'label' => __( 'Enter Button Text', 'sparklestore' ),
'default' => ''
),
'button_url' => array(
'type' => 'text',
'label' => __( 'Enter Button Url', 'sparklestore' ),
'default' => ''
)
)
)
);
$wp_customize->add_setting(
'sparklestore_banner_promo_one',
array(
'sanitize_callback' => 'absint'
)
);
$wp_customize->add_control(new WP_Customize_Cropped_Image_Control(
$wp_customize,
'sparklestore_banner_promo_one',
array(
'label' => esc_html__('Slider Promo Image One', 'sparklestore'),
'section' => 'sparklestore_banner_slider',
'width' => 365,
'height' => 280,
'active_callback' => 'sparklestore_slider_type_options',
)
)
);
$wp_customize->add_setting(
'sparklestore_banner_promo_one_url',
array(
'default' => '',
'sanitize_callback' => 'esc_url_raw' //done
)
);
$wp_customize->add_control(
'sparklestore_banner_promo_one_url',
array(
'type' => 'url',
'label' => esc_html__('Custom Promo Link', 'sparklestore'),
'section' => 'sparklestore_banner_slider',
'active_callback' => 'sparklestore_slider_type_options',
)
);
$wp_customize->add_setting(
'sparklestore_banner_promo_two',
array(
'sanitize_callback' => 'absint'
)
);
$wp_customize->add_control(new WP_Customize_Cropped_Image_Control(
$wp_customize,
'sparklestore_banner_promo_two',
array(
'label' => esc_html__('Slider Promo Image Two', 'sparklestore'),
'section' => 'sparklestore_banner_slider',
'width' => 365,
'height' => 280,
'active_callback' => 'sparklestore_slider_type_options',
)
)
);
$wp_customize->add_setting(
'sparklestore_banner_promo_two_url',
array(
'default' => '',
'sanitize_callback' => 'esc_url_raw' //done
)
);
$wp_customize->add_control(
'sparklestore_banner_promo_two_url',
array(
'type' => 'url',
'label' => esc_html__('Custom Promo Link', 'sparklestore'),
'section' => 'sparklestore_banner_slider',
'active_callback' => 'sparklestore_slider_type_options',
)
);
/**
* Home 1 - Full Width Section
*/
$sparklestore_home_section = $wp_customize->get_section( 'sidebar-widgets-sparklemainwidgetarea' );
if ( ! empty( $sparklestore_home_section ) ) {
$sparklestore_home_section->panel = '';
$sparklestore_home_section->title = esc_html__( 'Sparkle: Main Widget Area', 'sparklestore' );
$sparklestore_home_section->priority = 10;
}
/**
* Breadcrumbs Settings
*/
$wp_customize->add_section('sparklestore_breadcrumbs_normal_page_section', array(
'priority' => 11,
'title' => esc_html__('Breadcrumbs Settings', 'sparklestore'),
));
$wp_customize->add_setting('sparklestore_breadcrumbs_normal_page_background_image', array(
'default' => '',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'esc_url_raw'
));
$wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'sparklestore_breadcrumbs_normal_page_background_image', array(
'label' => esc_html__('Breadcrumbs Background Image', 'sparklestore'),
'section' => 'sparklestore_breadcrumbs_normal_page_section',
'setting' => 'sparklestore_breadcrumbs_normal_page_background_image'
)));
/**
* Services Section
*/
$wp_customize->add_section( 'sparklestore_services_area', array(
'title' => esc_html__('Quick Services Settings', 'sparklestore'),
'priority' => 12,
));
/**
* Enable/Disable Options
*/
$wp_customize->add_setting(
'sparklestore_services_area_settings',
array(
'sanitize_callback' => 'sparklestore_sanitize_on_off',
'default' => 'off'
)
);
$wp_customize->add_control( new Sparklestore_Switch_Control(
$wp_customize,
'sparklestore_services_area_settings',
array(
'section' => 'sparklestore_services_area',
'label' => esc_html__( 'Enable/Disable Section', 'sparklestore' ),
'on_off_label' => array(
'on' => esc_html__( 'Enable', 'sparklestore' ),
'off' => esc_html__( 'Disable', 'sparklestore' )
)
)
)
);
$wp_customize->add_setting('sparklestore_services_section', array(
'default' => 'disable',
'sanitize_callback' => 'sparklestore_radio_enable_disable_sanitize' //done
));
$wp_customize->add_control('sparklestore_services_section', array(
'type' => 'radio',
'label' => esc_html__('Manage Services Area Location', 'sparklestore'),
'section' => 'sparklestore_services_area',
'settings' => 'sparklestore_services_section',
'description' => esc_html__('Options to Manage Service Area Below the Header or Abote the Footer Area', 'sparklestore'),
'choices' => array(
'enable' => esc_html__('Below the Header', 'sparklestore'),
'disable' => esc_html__('Abover the Footer', 'sparklestore')
)
));
/**
* Services Settings Options
*
* @since 1.0.0
*/
$wp_customize->add_setting(
'sparklestore_quick_services_settings_options',
array(
'sanitize_callback' => 'sparklestore_sanitize_repeater',
'default' => json_encode( array(
array(
'services_icon' => 'fa fa-truck',
'services_title' => '',
'services_subtitle' => ''
)
) )
)
);
$wp_customize->add_control( new Sparklestore_Repeater_Controler(
$wp_customize,
'sparklestore_quick_services_settings_options',
array(
'label' => esc_html__('More Services Settings','sparklestore'),
'section' => 'sparklestore_services_area',
'sparklestore_box_label' => esc_html__('Services Settings','sparklestore'),
'sparklestore_box_add_control' => esc_html__('Add New Services','sparklestore'),
),
array(
'services_icon' => array(
'type' => 'icon',
'label' => esc_html__( 'Select Services Icon', 'sparklestore' ),
'default' => 'fa fa-truck'
),
'services_title' => array(
'type' => 'text',
'label' => esc_html__( 'Enter Services Title', 'sparklestore' ),
'default' => ''
),
'services_subtitle' => array(
'type' => 'text',
'label' => esc_html__( 'Enter Services Sub Title', 'sparklestore' ),
'default' => ''
)
)
)
);
/**
* Add Design Settings Panel
*
* @since 1.0.0
*/
$wp_customize->add_panel(
'sparklestore_design_settings_panel',
array(
'priority' => 13,
'title' => esc_html__( 'Design Layout Settings', 'sparklestore' ),
)
);
/**
* Home Page Blog Settings
*
* @since 1.0.0
*/
$wp_customize->add_section(
'sparklestore_home_blog_settings_section',
array(
'title' => esc_html__( 'Home & Blog Template Settings', 'sparklestore' ),
'priority' => 12,
//'panel' => 'sparklestore_design_settings_panel',
)
);
/**
* Image Radio field for archive/category layout
*
* @since 1.0.0
*/
$wp_customize->add_setting(
'sparklestore_home_page_blog_layout',
array(
'default' => 'none',
'sanitize_callback' => 'sanitize_key',
)
);
$wp_customize->add_control( new Sparklestore_Customize_Control_Radio_Image(
$wp_customize,
'sparklestore_home_page_blog_layout',
array(
'label' => esc_html__( 'Home Page Blog Layout', 'sparklestore' ),
'description' => esc_html__( 'Choose layout from available layouts', 'sparklestore' ),
'section' => 'sparklestore_home_blog_settings_section',
'choices' => array(
'none' => array(
'label' => esc_html__( 'Normal Layout', 'sparklestore' ),
'url' => '%s/assets/images/blog-list.png'
),
'masonry' => array(
'label' => esc_html__( 'Masonry Layout', 'sparklestore' ),
'url' => '%s/assets/images/masonry-layout.png'
)
)
)
)
);
/**
* Image Radio field for archive/category sidebar
*
* @since 1.0.0
*/
$wp_customize->add_setting(
'sparklestore_home_page_blog_sidebar',
array(
'default' => 'rightsidebar',
'sanitize_callback' => 'sanitize_key',
)
);
$wp_customize->add_control( new Sparklestore_Customize_Control_Radio_Image(
$wp_customize,
'sparklestore_home_page_blog_sidebar',
array(
'label' => esc_html__( 'Home Page Blog Sidebars', 'sparklestore' ),
'description' => esc_html__( 'Choose sidebar from available layouts', 'sparklestore' ),
'section' => 'sparklestore_home_blog_settings_section',
'choices' => array(
'leftsidebar' => array(
'label' => esc_html__( 'Left Sidebar', 'sparklestore' ),
'url' => '%s/assets/images/left-sidebar.png'
),
'rightsidebar' => array(
'label' => esc_html__( 'Right Sidebar', 'sparklestore' ),
'url' => '%s/assets/images/right-sidebar.png'
),
'nosidebar' => array(
'label' => esc_html__( 'No Sidebar', 'sparklestore' ),
'url' => '%s/assets/images/no-sidebar.png'
)
)
)
)
);
// Blog Template Blog Posts by Category.
$wp_customize->add_setting('sparklestore_blogtemplate_postcat', array(
'sanitize_callback' => 'sanitize_text_field', //done
));
$wp_customize->add_control(new sparklestore_Multiple_Check_Control($wp_customize, 'sparklestore_blogtemplate_postcat', array(
'label' => esc_html__('Select Category To Show Posts', 'sparklestore'),
'settings' => 'sparklestore_blogtemplate_postcat',
'section' => 'sparklestore_home_blog_settings_section',
'choices' => $blog_cat,
'description' => esc_html__('Note: Selected Category Only Work When you can select page template (
Blog Template )','sparklestore'),
)));
$post_description = array(
'none' => esc_html__( 'None', 'sparklestore' ),
'excerpt' => esc_html__( 'Post Excerpt', 'sparklestore' ),
'content' => esc_html__( 'Post Content', 'sparklestore' )
);
$wp_customize->add_setting(
'sparklestore_post_description_options',
array(
'default' => 'excerpt',
'sanitize_callback' => 'sparklestore_select_type_sanitize'
)
);
$wp_customize->add_control(
'sparklestore_post_description_options',
array(
'type' => 'select',
'label' => esc_html__( 'Post Description', 'sparklestore' ),
'section' => 'sparklestore_home_blog_settings_section',
'choices' => $post_description
)
);
// Blog Template Read More Button.
$wp_customize->add_setting( 'sparklestore_blogtemplate_btn', array(
'sanitize_callback' => 'sanitize_text_field', //done
'default' => esc_html__( 'Read More', 'sparklestore' ),
));
$wp_customize->add_control('sparklestore_blogtemplate_btn', array(
'label' => esc_html__( 'Enter Blog Button Text', 'sparklestore' ),
'section' => 'sparklestore_home_blog_settings_section',
'type' => 'text',
));
/**
* Number field for Excerpt Length section
*
* @since 1.0.0
*/
$wp_customize->add_setting(
'sparklestore_post_excerpt_length',
array(
'default' => 45,
'sanitize_callback' => 'absint'
)
);
$wp_customize->add_control(
'sparklestore_post_excerpt_length',
array(
'type' => 'number',
'label' => esc_html__( 'Enter Posts Excerpt Length', 'sparklestore' ),
'section' => 'sparklestore_home_blog_settings_section',
)
);
/**
* Enable/Disable Post Date
*/
$wp_customize->add_setting(
'sparklestore_post_date_options',
array(
'sanitize_callback' => 'sparklestore_sanitize_on_off',
'default' => 'on'
)
);
$wp_customize->add_control( new Sparklestore_Switch_Control( $wp_customize,
'sparklestore_post_date_options',
array(
'section' => 'sparklestore_home_blog_settings_section',
'label' => esc_html__( 'Enable/Disable Post Date', 'sparklestore' ),
'on_off_label' => array(
'on' => esc_html__( 'Enable', 'sparklestore' ),
'off' => esc_html__( 'Disable', 'sparklestore' )
)
)
)
);
/**
* Enable/Disable Post Author
*/
$wp_customize->add_setting(
'sparklestore_post_author_options',
array(
'sanitize_callback' => 'sparklestore_sanitize_on_off',
'default' => 'on'
)
);
$wp_customize->add_control( new Sparklestore_Switch_Control( $wp_customize,
'sparklestore_post_author_options',
array(
'section' => 'sparklestore_home_blog_settings_section',
'label' => esc_html__( 'Enable/Disable Post Author', 'sparklestore' ),
'on_off_label' => array(
'on' => esc_html__( 'Enable', 'sparklestore' ),
'off' => esc_html__( 'Disable', 'sparklestore' )
)
)
)
);
/**
* Enable/Disable Post Comments
*/
$wp_customize->add_setting(
'sparklestore_post_comments_options',
array(
'sanitize_callback' => 'sparklestore_sanitize_on_off',
'default' => 'on'
)
);
$wp_customize->add_control( new Sparklestore_Switch_Control( $wp_customize,
'sparklestore_post_comments_options',
array(
'section' => 'sparklestore_home_blog_settings_section',
'label' => esc_html__( 'Enable/Disable Post Comments', 'sparklestore' ),
'on_off_label' => array(
'on' => esc_html__( 'Enable', 'sparklestore' ),
'off' => esc_html__( 'Disable', 'sparklestore' )
)
)
)
);
/**
* Archive/Category Settings
*
* @since 1.0.0
*/
$wp_customize->add_section(
'sparklestore_archive_settings_section',
array(
'title' => esc_html__( 'Archive/Category Settings', 'sparklestore' ),
'panel' => 'sparklestore_design_settings_panel',
)
);
/**
* Image Radio field for archive/category layout
*
* @since 1.0.0
*/
$wp_customize->add_setting(
'sparklestore_archive_layout',
array(
'default' => 'none',
'sanitize_callback' => 'sanitize_key',
)
);
$wp_customize->add_control( new Sparklestore_Customize_Control_Radio_Image(
$wp_customize,
'sparklestore_archive_layout',
array(
'label' => esc_html__( 'Archive/Category Layout', 'sparklestore' ),
'description' => esc_html__( 'Choose layout from available layouts', 'sparklestore' ),
'section' => 'sparklestore_archive_settings_section',
'choices' => array(
'none' => array(
'label' => esc_html__( 'Normal Layout', 'sparklestore' ),
'url' => '%s/assets/images/blog-list.png'
),
'masonry' => array(
'label' => esc_html__( 'Masonry Layout', 'sparklestore' ),
'url' => '%s/assets/images/masonry-layout.png'
)
)
)
)
);
/**
* Image Radio field for archive/category sidebar
*
* @since 1.0.0
*/
$wp_customize->add_setting(
'sparklestore_archive_sidebar',
array(
'default' => 'rightsidebar',
'sanitize_callback' => 'sanitize_key',
)
);
$wp_customize->add_control( new Sparklestore_Customize_Control_Radio_Image(
$wp_customize,
'sparklestore_archive_sidebar',
array(
'label' => esc_html__( 'Archive/Category Sidebars', 'sparklestore' ),
'description' => esc_html__( 'Choose sidebar from available layouts', 'sparklestore' ),
'section' => 'sparklestore_archive_settings_section',
'choices' => array(
'leftsidebar' => array(
'label' => esc_html__( 'Left Sidebar', 'sparklestore' ),
'url' => '%s/assets/images/left-sidebar.png'
),
'rightsidebar' => array(
'label' => esc_html__( 'Right Sidebar', 'sparklestore' ),
'url' => '%s/assets/images/right-sidebar.png'
),
'nosidebar' => array(
'label' => esc_html__( 'No Sidebar', 'sparklestore' ),
'url' => '%s/assets/images/no-sidebar.png'
)
)
)
)
);
/**
* Search Settings
*
* @since 1.0.0
*/
$wp_customize->add_section(
'sparklestore_search_settings_section',
array(
'title' => esc_html__( 'Search Page Settings', 'sparklestore' ),
'panel' => 'sparklestore_design_settings_panel',
)
);
/**
* Image Radio field for archive/category sidebar
*
* @since 1.0.0
*/
$wp_customize->add_setting(
'sparklestore_search_sidebar',
array(
'default' => 'rightsidebar',
'sanitize_callback' => 'sanitize_key',
)
);
$wp_customize->add_control( new Sparklestore_Customize_Control_Radio_Image(
$wp_customize,
'sparklestore_search_sidebar',
array(
'label' => esc_html__( 'Search Page Sidebar', 'sparklestore' ),
'description' => esc_html__( 'Choose sidebar from available layouts', 'sparklestore' ),
'section' => 'sparklestore_search_settings_section',
'choices' => array(
'leftsidebar' => array(
'label' => esc_html__( 'Left Sidebar', 'sparklestore' ),
'url' => '%s/assets/images/left-sidebar.png'
),
'rightsidebar' => array(
'label' => esc_html__( 'Right Sidebar', 'sparklestore' ),
'url' => '%s/assets/images/right-sidebar.png'
),
'nosidebar' => array(
'label' => esc_html__( 'No Sidebar', 'sparklestore' ),
'url' => '%s/assets/images/no-sidebar.png'
)
)
)
)
);
/**
* Footer Settings Area
*/
$wp_customize->add_section('sparklestore_footer_settings', array(
'priority' => 15,
'title' => esc_html__('Footer Settings', 'sparklestore')
));
/**
* Enable/Disable Option for Main Footer Widget Section
*
* @since 1.0.0
*/
$wp_customize->add_setting(
'sparklestore_footer_widget_area_option',
array(
'sanitize_callback' => 'sparklestore_sanitize_on_off',
'default' => 'on'
)
);
$wp_customize->add_control( new Sparklestore_Switch_Control(
$wp_customize,
'sparklestore_footer_widget_area_option',
array(
'settings' => 'sparklestore_footer_widget_area_option',
'section' => 'sparklestore_footer_settings',
'label' => esc_html__( 'Footer Widgert Area Option', 'sparklestore' ),
'description' => esc_html__( 'Enable/Disable option for footer widget section.', 'sparklestore' ),
'on_off_label' => array(
'on' => esc_html__( 'Enable', 'sparklestore' ),
'off' => esc_html__( 'Disable', 'sparklestore' )
)
)
)
);
/**
* Payment Logo
*/
$wp_customize->add_setting( 'paymentlogo_image_one', array(
'default' => '',
'sanitize_callback' => 'esc_url_raw'
));
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'paymentlogo_image_one', array(
'section' => 'sparklestore_footer_settings',
'label' => esc_html__('Upload Payment Logo Image', 'sparklestore'),
'type' => 'image',
)));
$wp_customize->add_setting( 'paymentlogo_image_two', array(
'default' => '',
'sanitize_callback' => 'esc_url_raw' // done
));
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'paymentlogo_image_two', array(
'section' => 'sparklestore_footer_settings',
'label' => esc_html__('Upload Payment Logo Image', 'sparklestore'),
'type' => 'image',
)));
$wp_customize->add_setting( 'paymentlogo_image_three', array(
'default' => '',
'sanitize_callback' => 'esc_url_raw' // done
));
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'paymentlogo_image_three', array(
'section' => 'sparklestore_footer_settings',
'label' => esc_html__('Upload Payment Logo Image', 'sparklestore'),
'type' => 'image',
)));
$wp_customize->add_setting( 'paymentlogo_image_four', array(
'default' => '',
'sanitize_callback' => 'esc_url_raw' // done
));
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'paymentlogo_image_four', array(
'section' => 'sparklestore_footer_settings',
'label' => esc_html__('Upload Payment Logo Image', 'sparklestore'),
'type' => 'image',
)));
$wp_customize->add_setting( 'paymentlogo_image_five', array(
'default' => '',
'sanitize_callback' => 'esc_url_raw' // done
));
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'paymentlogo_image_five', array(
'section' => 'sparklestore_footer_settings',
'label' => esc_html__('Upload Payment Logo Image', 'sparklestore'),
'type' => 'image',
)));
$wp_customize->add_setting( 'paymentlogo_image_six', array(
'default' => '',
'sanitize_callback' => 'esc_url_raw' // done
));
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'paymentlogo_image_six', array(
'section' => 'sparklestore_footer_settings',
'label' => esc_html__('Upload Payment Logo Image', 'sparklestore'),
'type' => 'image',
)));
/**
* Enable/Disable Option for Social Icon and Payment Logo
*
* @since 1.0.0
*/
$wp_customize->add_setting(
'sparklestore_footer_social_icon_payment_logo_option',
array(
'sanitize_callback' => 'sparklestore_sanitize_on_off',
'default' => 'on'
)
);
$wp_customize->add_control( new Sparklestore_Switch_Control(
$wp_customize,
'sparklestore_footer_social_icon_payment_logo_option',
array(
'section' => 'sparklestore_footer_settings',
'label' => esc_html__( 'Social Icon & Payment Logo', 'sparklestore' ),
'description' => esc_html__( 'Enable/Disable option for footer social icon and payment logo.', 'sparklestore' ),
'on_off_label' => array(
'on' => esc_html__( 'Enable', 'sparklestore' ),
'off' => esc_html__( 'Disable', 'sparklestore' )
)
)
)
);
/**
* Footer Content (Copyright Text)
*/
$wp_customize->add_setting('sparklestore_footer_copyright', array(
'default' => '',
'sanitize_callback' => 'sparklestore_text_sanitize' //done
));
$wp_customize->add_control('sparklestore_footer_copyright', array(
'type' => 'textarea',
'label' => esc_html__('Footer Content (Copyright Text)', 'sparklestore'),
'section' => 'sparklestore_footer_settings',
'settings' => 'sparklestore_footer_copyright'
));
$wp_customize->add_setting(
'sparklestore_sub_footer_bg_color',
array(
'default' => '#111111',
'sanitize_callback' => 'sanitize_hex_color',
)
);
/**
* Start of the Social Link Options
*/
$wp_customize->add_section('sparklestore_social_link_activate_settings', array(
'priority' => 16,
'title' => esc_html__('Social Media Settings', 'sparklestore'),
));
$wp_customize->add_setting('sparklestore_social_link_activate', array(
'default' => 1,
'capability' => 'edit_theme_options',
'sanitize_callback' => 'sparklestore_checkbox_sanitize' //done
));
$wp_customize->add_control('sparklestore_social_link_activate', array(
'type' => 'checkbox',
'label' => esc_html__('Check to activate social links area', 'sparklestore'),
'section' => 'sparklestore_social_link_activate_settings',
'settings' => 'sparklestore_social_link_activate'
));
$sparklestore_social_links = array(
'sparklestore_social_facebook' => array(
'id' => 'sparklestore_social_facebook',
'title' => esc_html__('Facebook', 'sparklestore'),
'default' => '',
),
'sparklestore_social_twitter' => array(
'id' => 'sparklestore_social_twitter',
'title' => esc_html__('Twitter', 'sparklestore'),
'default' => '',
),
'sparklestore_social_pinterest' => array(
'id' => 'sparklestore_social_pinterest',
'title' => esc_html__('Pinterest', 'sparklestore'),
'default' => '',
),
'sparklestore_social_linkedin' => array(
'id' => 'sparklestore_social_linkedin',
'title' => esc_html__('Linkedin', 'sparklestore'),
'default' => '',
),
'sparklestore_social_youtube' => array(
'id' => 'sparklestore_social_youtube',
'title' => esc_html__('YouTube', 'sparklestore'),
'default' => '',
)
);
$i = 20;
foreach($sparklestore_social_links as $sparklestore_social_link) {
$wp_customize->add_setting($sparklestore_social_link['id'], array(
'default' => $sparklestore_social_link['default'],
'capability' => 'edit_theme_options',
'sanitize_callback' => 'esc_url_raw'
));
$wp_customize->add_control($sparklestore_social_link['id'], array(
'label' => $sparklestore_social_link['title'],
'section'=> 'sparklestore_social_link_activate_settings',
'settings'=> $sparklestore_social_link['id'],
'priority' => $i
));
$wp_customize->add_setting($sparklestore_social_link['id'].'_checkbox', array(
'default' => 0,
'capability' => 'edit_theme_options',
'sanitize_callback' => 'sparklestore_checkbox_sanitize' // done
));
$wp_customize->add_control($sparklestore_social_link['id'].'_checkbox', array(
'type' => 'checkbox',
'label' => esc_html__('Check to show in new tab', 'sparklestore'),
'section'=> 'sparklestore_social_link_activate_settings',
'settings'=> $sparklestore_social_link['id'].'_checkbox',
'priority' => $i
));
$i++;
}
function sparklestore_checkbox_sanitize($input) {
if ( $input == 1 ) {
return 1;
} else {
return 0;
}
}
function sparklestore_radio_enable_disable_sanitize($input) {
$valid_keys = array(
'enable' => esc_html__('Enable', 'sparklestore'),
'disable' => esc_html__('Disable', 'sparklestore')
);
if ( array_key_exists( $input, $valid_keys ) ) {
return $input;
} else {
return '';
}
}
function sparklestore_text_sanitize( $input ) {
return wp_kses_post( force_balance_tags( $input ) );
}
function sparklestore_page_layout_sanitize($input) {
$imagepath = get_template_directory_uri() . '/images/';
$valid_keys = array(
'leftsidebar' => $imagepath.'left-sidebar.png',
'rightsidebar' => $imagepath.'right-sidebar.png',
'onsidebar' => $imagepath.'no-sidebar.png ',
);
if ( array_key_exists( $input, $valid_keys ) ) {
return $input;
} else {
return '';
}
}
function sparklestore_row_layout_sanitize($input) {
$valid_keys = array(
'2' => '2',
'3' => '3',
'4' => '4',
);
if ( array_key_exists( $input, $valid_keys ) ) {
return $input;
} else {
return '';
}
}
function sparklestore_number_sanitize( $int ) {
return absint( $int );
}
/**
* On/Off Sanitization Function
*
* @since 1.0.0
*/
function sparklestore_sanitize_on_off($input) {
$valid_keys = array(
'on' => esc_html__( 'Enable', 'sparklestore' ),
'off' => esc_html__( 'Disable', 'sparklestore' )
);
if ( array_key_exists( $input, $valid_keys ) ) {
return $input;
} else {
return '';
}
}
/**
* Advance Search Sanitization Function
*
* @since 1.0.0
*/
function sparklestore_search_options_sanitize($input) {
$valid_keys = array(
'normalsearch' => esc_html__( 'Normal Search', 'sparklestore' ),
'advancesearch' => esc_html__( 'Advance Search ( With Category )', 'sparklestore' )
);
if ( array_key_exists( $input, $valid_keys ) ) {
return $input;
} else {
return '';
}
}
/**
* Select Box Sanitization Function
*
* @since 1.0.0
*/
function sparklestore_select_type_sanitize( $input, $setting ) {
// get all select options
$options = $setting->manager->get_control( $setting->id )->choices;
// return default if not valid
return ( array_key_exists( $input, $options ) ? $input : $setting->default );
}
function sparklestore_sanitize_repeater($input){
$input_decoded = json_decode( $input, true );
$allowed_html = array(
'br' => array(),
'em' => array(),
'strong' => array(),
'a' => array(
'href' => array(),
'class' => array(),
'id' => array(),
'target' => array()
),
'button' => array(
'class' => array(),
'id' => array()
)
);
if(!empty($input_decoded)) {
foreach ($input_decoded as $boxes => $box ){
foreach ($box as $key => $value){
$input_decoded[$boxes][$key] = sanitize_text_field( $value );
}
}
return json_encode($input_decoded);
}
return $input;
}
}
add_action( 'customize_register', 'sparklestore_customize_register' );
/**
* Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
*/
function sparklestore_customize_preview_js() {
wp_enqueue_script( 'sparklestore_customizer', get_template_directory_uri() . '/assets/js/customizer.js', array( 'customize-preview' ), '20151215', true );
}
add_action( 'customize_preview_init', 'sparklestore_customize_preview_js' );