add_section( 'bongoto_shop_section_header', array( 'title' => __( 'Header Settings', 'bongoto-shop' ), 'priority' => 20, 'panel' => 'bongoto_general_panel', ) ); /** * Header Variant */ $is_pro = function_exists( 'bongoto_shop_is_pro_active' ) ? bongoto_shop_is_pro_active() : (bool) apply_filters( 'bongoto_shop/is_pro_active', false ); // Define all header layouts (including Basic Header 1). $choices = array( '1' => __( 'Header 1 (Basic)', 'bongoto-shop' ), '2' => __( 'Header 2 (Logo • Menu • Actions)', 'bongoto-shop' ), '3' => __( 'Header 3 (Center Menu + Search)', 'bongoto-shop' ), '4' => __( 'Header 4 (Topbar + Dual Row)', 'bongoto-shop' ), '5' => __( 'Header 5 (Centered Menu)', 'bongoto-shop' ), ); // Add "(Pro)" label if Pro inactive. if ( ! $is_pro ) { foreach ( $choices as $key => $label ) { if ( '1' !== $key ) { $choices[ $key ] = sprintf( '%s %s', $label, __( '(Pro)', 'bongoto-shop' ) ); } } } // Allow Pro plugin or child theme to alter/extend choices. if ( has_filter( 'bongoto_shop/header/variant_choices' ) ) { $choices = apply_filters( 'bongoto_shop/header/variant_choices', $choices ); } // Setting: variant. $wp_customize->add_setting( 'bongoto_shop_header_variant', array( 'default' => '1', 'sanitize_callback' => function ( $v ) use ( $choices, $is_pro ) { $v = (string) $v; if ( ! $is_pro && '1' !== $v ) { return '1'; } return array_key_exists( $v, $choices ) ? $v : '1'; }, 'transport' => 'refresh', ) ); // Control: variant. $wp_customize->add_control( 'bongoto_shop_header_variant', array( 'label' => __( 'Header Layout', 'bongoto-shop' ), 'description' => $is_pro ? __( 'Choose your header layout.', 'bongoto-shop' ) : __( 'Upgrade to Bongoto Shop Pro to unlock Header 2–5.', 'bongoto-shop' ), 'section' => 'bongoto_shop_section_header', 'type' => 'select', 'choices' => $choices, ) ); /** * Sticky Header */ $wp_customize->add_setting( 'bongoto_shop_header_sticky', array( 'default' => false, 'sanitize_callback' => 'bongoto_shop_customize_sanitize_checkbox', 'transport' => 'postMessage', ) ); $wp_customize->add_control( 'bongoto_shop_header_sticky', array( 'label' => __( 'Enable Sticky Header', 'bongoto-shop' ), 'description' => __( 'Make the header stick to the top while scrolling.', 'bongoto-shop' ), 'section' => 'bongoto_shop_section_header', 'type' => 'checkbox', ) ); /** * Component toggles (Search, Account, Cart) */ $components = array( 'search' => __( 'Show Search', 'bongoto-shop' ), 'account' => __( 'Show Account Icon', 'bongoto-shop' ), 'cart' => __( 'Show Cart Icon', 'bongoto-shop' ), ); foreach ( $components as $key => $label ) { $setting_id = "bongoto_shop_header_show_{$key}"; $wp_customize->add_setting( $setting_id, array( 'default' => true, 'sanitize_callback' => 'bongoto_shop_customize_sanitize_checkbox', 'transport' => 'postMessage', ) ); $wp_customize->add_control( $setting_id, array( 'label' => $label, 'section' => 'bongoto_shop_section_header', 'type' => 'checkbox', ) ); } /** * Selective refresh / live preview */ if ( isset( $wp_customize->selective_refresh ) ) { $wp_customize->selective_refresh->add_partial( 'bongoto_shop_header_partial', array( 'selector' => '#masthead', 'render_callback' => function () { get_template_part( 'template-parts/headers/header', (string) get_theme_mod( 'bongoto_shop_header_variant', '1' ) ); }, 'settings' => array( 'bongoto_shop_header_show_search', 'bongoto_shop_header_show_account', 'bongoto_shop_header_show_cart', 'bongoto_shop_header_sticky', 'bongoto_shop_header_variant', ), ) ); } } add_action( 'customize_register', 'bongoto_shop_customize_register_header', 30 );