includes();
$this->actions();
}
public function includes() {
require_once( apply_filters( 'etheme_file_url', ETHEME_CODE . 'customizer/search/class-customize-search.php' ) );
require_once( apply_filters( 'etheme_file_url', ETHEME_CODE . 'customizer/user-preferences/class-customize-user-preferences.php' ) );
}
public function actions() {
// customizer Kirki loader style
add_action( 'wp_head', array( $this, 'head_config_customizer' ), 99 );
add_action( 'init', function () {
if ( get_query_var( 'et_is_customize_preview', false ) ) {
// dequeue WooZone style
add_action( "admin_print_styles", function () {
wp_dequeue_style( 'WooZone-main-style' );
} );
}
}, 10 );
add_action( 'customize_controls_print_footer_scripts', array( $this, 'etheme_load_admin_styles_customizer' ) );
add_action( 'customize_controls_print_styles', array( $this, 'etheme_customizer_css' ), 99 );
add_action( 'customize_controls_print_scripts', array( $this, 'customizer_js' ), 99 );
add_action( 'customize_preview_init', array( $this, 'previewer_scripts' ) );
add_action( 'customize_register', array( $this, 'partial_refresh' ) );
add_action( 'customize_register', array( $this, 'woocommerce_options' ) );
}
public function head_config_customizer() {
if ( ! class_exists( 'Kirki' ) ) {
return;
}
?>
add_setting(
'woocommerce_shop_page_categories_appearance',
array(
'default' => '',
'type' => 'option',
'capability' => 'manage_woocommerce',
'sanitize_callback' => function ( $value ) {
$options = array( '', 'separated' );
return in_array( $value, $options, true ) ? $value : '';
},
)
);
$wp_customize->add_control(
'woocommerce_shop_page_categories_appearance',
array(
'label' => __( 'Categories Appearance', 'xstore' ),
'description' => __( 'Choose how to display product categories on the product archives.', 'xstore' ),
'section' => 'woocommerce_product_catalog',
'settings' => 'woocommerce_shop_page_categories_appearance',
'type' => 'select',
'choices' => array(
'' => __( 'Merged with Products', 'xstore' ),
'separated' => __( 'Apart from Products', 'xstore' ),
),
)
);
// checkout fields
$wp_customize->add_setting(
'woocommerce_checkout_full_name_fields',
array(
'default' => '',
'type' => 'option',
'capability' => 'manage_woocommerce',
'sanitize_callback' => function ( $value ) {
$options = array( '', 'merged' );
return in_array( $value, $options, true ) ? $value : '';
},
)
);
$wp_customize->add_control(
'woocommerce_checkout_full_name_fields',
array(
'label' => __( 'First/Last name fields', 'xstore' ),
'description' => __( 'Choose how to display first/last name fields on checkout page.', 'xstore' ) . '
' .
__( 'Works for live mode, not for the customizer preview.', 'xstore' ),
'section' => 'woocommerce_checkout',
'settings' => 'woocommerce_checkout_full_name_fields',
'type' => 'select',
'choices' => array(
'' => __( 'Separated', 'xstore' ),
'merged' => __( 'Merged', 'xstore' ),
),
)
);
}
public function partial_refresh( WP_Customize_Manager $wp_customize ) {
// Abort if selective refresh is not available.
if ( ! isset( $wp_customize->selective_refresh ) ) {
return;
}
$et_partials = array();
if ( !get_option( 'etheme_disable_customizer_header_builder', false ) ) {
$et_partials['header_partials'] = array(
// header parts
array(
'selector' => '.header-top',
'partial' => 'top_header_style_separator',
),
array(
'selector' => 'body:not(.cart-checkout-light-header) .header-main',
'partial' => 'main_header_style_separator',
),
// cart checkout advanced layout use-case
array(
'selector' => 'body.cart-checkout-advanced-layout .header-main',
'partial' => 'cart_checkout_layout_header_separator',
),
array(
'selector' => '.header-bottom',
'partial' => 'bottom_header_style_separator',
),
// vertical header
array(
'selector' => '#header-vertical',
'partial' => 'header_vertical_et-desktop',
),
array(
'selector' => '#header-vertical .et_b_header-logo.et_element-top-level',
'partial' => 'header_vertical_logo_img_et-desktop',
),
array(
'selector' => '#header-vertical .header-vertical-menu-icon-wrapper, .header-vertical-menu',
'partial' => 'header_vertical_menu_type_et-desktop',
),
// header elements
array(
'selector' => '.header-button-wrapper.et_element-top-level',
'partial' => 'button_content_separator',
),
array(
'selector' => 'body:not(.cart-checkout-light-header) .site-header .et_b_header-logo.et_element-top-level',
'partial' => 'logo_content_separator',
),
array(
'selector' => 'body.cart-checkout-advanced-layout .site-header .et_b_header-logo.et_element-top-level',
'partial' => 'cart_checkout_logo_img_et-desktop',
),
// all departments menu
array(
'selector' => '.et_b_header-menu.et_element-top-level .secondary-menu-wrapper',
'partial' => 'secondary_menu_content_separator',
),
array(
'selector' => '.et_b_header-mobile-menu',
'partial' => 'mobile_menu_content_separator',
),
array(
'selector' => '.et_b_header-wishlist.et_element-top-level',
'partial' => 'wishlist_content_separator',
),
array(
'selector' => '.et_b_header-socials.et_element-top-level',
'partial' => 'header_socials_content_separator',
),
array(
'selector' => '.et_b_header-languages.et_element-top-level',
'partial' => 'languages_content_separator',
),
array(
'selector' => '.header-html_block1',
'partial' => 'html_block1',
),
array(
'selector' => '.header-html_block2',
'partial' => 'html_block2',
),
array(
'selector' => '.header-html_block3',
'partial' => 'html_block3',
),
array(
'selector' => '.et_b_header-widget',
'partial' => 'header_widget1_content_separator',
),
array(
'selector' => '.et_b_header-account.et_element-top-level',
'partial' => 'account_content_separator',
),
array(
'selector' => '.et_b_header-search.et_element-top-level',
'partial' => 'search_content_separator',
),
array(
'selector' => '.header-promo-text',
'partial' => 'promo_text_content_separator',
),
array(
'selector' => '.et_b_header-newsletter.et_element-top-level',
'partial' => 'newsletter_content_separator',
),
array(
'selector' => '.et_b_header-cart.et_element-top-level',
'partial' => 'cart_content_separator',
),
array(
'selector' => '.header-main-menu.et_element-top-level',
'partial' => 'menu_content_separator',
),
array(
'selector' => '.header-main-menu2.et_element-top-level',
'partial' => 'menu_2_content_separator',
),
array(
'selector' => '.site-header .et_b_header-menu.et_element-top-level:not(.header-secondary-menu) .nav-sublist-dropdown, .site-header .header-secondary-menu.et_element-top-level .menu .nav-sublist-dropdown',
'partial' => 'menu_dropdown_content_separator',
),
array(
'selector' => '.et_b_header-contacts.et_element-top-level',
'partial' => 'contacts_content_separator',
),
);
}
if ( get_option( 'etheme_single_product_builder', false ) ) {
// single product elements
$et_partials['single_product_partials'] = array(
array(
'partial' => 'product_gallery_content_separator',
'selector' => '.woocommerce-product-gallery'
),
array(
'partial' => 'product_title_style_separator',
'selector' => 'h1.product_title',
),
array(
'partial' => 'product_price_style_separator',
'selector' => '.et_product-block > .price, .element > .price',
),
array(
'partial' => 'product_rating_content_separator',
'selector' => '.woocommerce-product-rating .star-rating',
),
array(
'partial' => 'product_meta_content_separator',
'selector' => '.product_meta',
),
array(
'partial' => 'product_cart_style_separator',
'selector' => 'form.cart',
),
array(
'partial' => 'single_countdown_type',
'selector' => '.et_product-block .product-sale-counter'
),
array(
'partial' => 'product_tabs_content_separator',
'selector' => '.woocommerce-tabs',
),
array(
'partial' => 'product_short_description_style_separator',
'selector' => '.woocommerce-product-details__short-description',
),
array(
'partial' => 'product_sharing_content_separator',
'selector' => '.single-product-socials',
),
array(
'partial' => 'product_size_guide_content_separator',
'selector' => '.single-product-size-guide',
),
array(
'partial' => 'product_wishlist_content_separator',
'selector' => '.single-wishlist',
),
array(
'partial' => 'product_compare_style_separator',
'selector' => '.single-compare',
),
array(
'partial' => 'product_breadcrumbs_content_separator',
'selector' => 'body.single-product .page-heading',
),
array(
'partial' => 'products_upsell_content_separator',
'selector' => 'body.single-product .upsell-products',
),
array(
'partial' => 'products_cross_sell_content_separator',
'selector' => 'body.single-product .cross-sell-products',
),
array(
'partial' => 'products_related_content_separator',
'selector' => '.related-products',
),
array(
'partial' => 'single_product_html_block1_content_separator',
'selector' => '.single_product-html_block',
),
// bought together
array(
'partial' => 'single_product_bought_together_content_separator',
'selector' => '.bought-together-products',
),
// sidebar settings
array(
'partial' => 'single_product_layout_content_separator',
'selector' => '.single-product .widget-area'
)
);
} else {
$et_partials['single_product_partials'] = array(
// product brands
array(
'selector' => '.product_brand, .products-page-brands',
'partial' => 'enable_brands'
),
array(
'selector' => 'body.single-product .page-heading',
'partial' => 'breadcrumb_type'
),
// countdown
array(
'partial' => 'single_countdown_type',
'selector' => '.product-information .product-sale-counter'
),
// sale, outofstock
array(
'selector' => '.sale-wrapper',
'partial' => 'sale_icon'
),
// single related products
array(
'partial' => 'show_related',
'selector' => '.related-products',
),
// tabs
array(
'selector' => '.single .single-product .woocommerce-tabs',
'partial' => 'tabs_type'
),
);
}
$et_partials['global_partials'] = array(
// breadcrumbs
array(
'selector' => 'body:not(.single-product) .page-heading, .cart-checkout-nav',
'partial' => 'breadcrumb_type',
),
// footer
array(
'selector' => '.footer',
'partial' => 'footer_columns',
),
array(
'selector' => '.footer-bottom',
'partial' => 'copyrights_color',
),
// woocommerce
array(
'selector' => '.product-category',
'partial' => 'cat_style'
),
array(
'selector' => '.content-product',
'partial' => 'product_view'
),
array(
'selector' => '.woocommerce-cart .cross-sell-products',
'partial' => 'cart_products_cross_sell_type_et-desktop'
),
// toolbar
array(
'selector' => '.filter-wrap',
'partial' => 'view_mode'
),
// swatches
array(
'selector' => '.st-swatch-in-loop, .st-swatch-preview-single-product',
'partial' => 'enable_swatch'
),
// cart empty
array(
'selector' => '.cart-empty',
'partial' => 'empty_cart_content'
),
// sale, outofstock
array(
'selector' => '.content-product .stock, .content-product .available-on-backorder',
'partial' => 'sale_icon'
),
// default woocommerce checkout
array(
'selector' => '.woocommerce-checkout',
'partial' => 'wp_page_for_privacy_policy'
),
// social sharing
array(
'selector' => '.product-share, .share-post',
'partial' => 'socials',
),
// page 404 content
array(
'selector' => '.page-404',
'partial' => '404_text',
),
// mobile panel
array(
'selector' => '.et-mobile-panel-wrapper',
'partial' => 'mobile_panel_content_separator',
),
);
if ( isset($et_partials['header_partials']) ) {
foreach ($et_partials['header_partials'] as $key) {
$wp_customize->selective_refresh->add_partial($key['partial'],
array(
'selector' => $key['selector'],
)
);
}
}
foreach ( $et_partials['single_product_partials'] as $key ) {
$wp_customize->selective_refresh->add_partial( $key['partial'],
array(
'selector' => $key['selector'],
)
);
}
foreach ( $et_partials['global_partials'] as $key ) {
$wp_customize->selective_refresh->add_partial( $key['partial'],
array(
'selector' => $key['selector'],
)
);
}
unset( $et_partials );
}
}
new Etheme_Customize_Init();