add_section( 'bongoto_section_header', array( 'title' => __( 'Header Settings', 'bongoto-marketplace' ), 'priority' => 20, ) ); /** * ✅ Header Variant */ $is_pro = apply_filters( 'bongoto/is_pro_active', false ); // Define all header layouts (including Basic Header 1) $choices = array( '1' => __( 'Header 1 (Basic)', 'bongoto-marketplace' ), '2' => __( 'Header 2 (Logo • Menu • Actions)', 'bongoto-marketplace' ), '3' => __( 'Header 3 (Center Menu + Search)', 'bongoto-marketplace' ), '4' => __( 'Header 4 (Topbar + Dual Row)', 'bongoto-marketplace' ), '5' => __( 'Header 5 (Centered Menu)', 'bongoto-marketplace' ), ); // Add "(Pro)" label if Pro inactive if ( ! $is_pro ) { foreach ( $choices as $key => $label ) { if ( $key !== '1' ) { $choices[ $key ] = sprintf( '%s %s', $label, '(Pro)' ); } } } // Allow Pro plugin to add more headers if ( has_filter( 'bongoto/pro/header_variant_choices' ) ) { $choices = apply_filters( 'bongoto/pro/header_variant_choices', $choices ); } // Register setting $wp_customize->add_setting( 'bongoto_header_variant', array( 'default' => '1', 'sanitize_callback' => function( $v ) use ( $choices ) { $v = (string) $v; return array_key_exists( $v, $choices ) ? $v : '1'; }, 'transport' => 'refresh', ) ); // Register control $wp_customize->add_control( 'bongoto_header_variant', array( 'label' => __( 'Header Layout', 'bongoto-marketplace' ), 'description' => $is_pro ? __( 'Choose your header layout.', 'bongoto-marketplace' ) : __( 'Upgrade to Bongoto Pro to unlock Header 2–5.', 'bongoto-marketplace' ), 'section' => 'bongoto_section_header', 'type' => 'select', 'choices' => $choices, ) ); /** * ✅ Sticky Header */ $wp_customize->add_setting( 'bongoto_header_sticky', array( 'default' => false, 'sanitize_callback' => 'bongoto_customize_sanitize_checkbox', 'transport' => 'postMessage', ) ); $wp_customize->add_control( 'bongoto_header_sticky', array( 'label' => __( 'Enable Sticky Header', 'bongoto-marketplace' ), 'description' => __( 'Make the header stick to the top while scrolling.', 'bongoto-marketplace' ), 'section' => 'bongoto_section_header', 'type' => 'checkbox', ) ); /** * ✅ Component toggles (Search, Account, Cart, Upload) */ $components = array( 'search' => __( 'Show Search', 'bongoto-marketplace' ), 'account' => __( 'Show Account Icon', 'bongoto-marketplace' ), 'cart' => __( 'Show Cart Icon', 'bongoto-marketplace' ), 'upload' => __( 'Show Upload CTA (Start Selling)', 'bongoto-marketplace' ), ); foreach ( $components as $key => $label ) { $setting_id = "bongoto_header_show_{$key}"; $default = in_array( $key, array( 'search', 'account', 'cart', 'upload' ), true ); $wp_customize->add_setting( $setting_id, array( 'default' => $default, 'sanitize_callback' => 'bongoto_customize_sanitize_checkbox', 'transport' => 'postMessage', ) ); $wp_customize->add_control( $setting_id, array( 'label' => $label, 'section' => 'bongoto_section_header', 'type' => 'checkbox', ) ); } /** * ✅ Upload CTA Label */ $wp_customize->add_setting( 'bongoto_header_upload_label', array( 'default' => __( 'Upload', 'bongoto-marketplace' ), 'sanitize_callback' => 'bongoto_customize_sanitize_text', 'transport' => 'postMessage', ) ); $wp_customize->add_control( 'bongoto_header_upload_label', array( 'label' => __( 'Upload Button Label', 'bongoto-marketplace' ), 'description' => __( 'Text for the Upload/Start Selling button.', 'bongoto-marketplace' ), 'section' => 'bongoto_section_header', 'type' => 'text', ) ); /** * ✅ Selective refresh / live preview */ if ( isset( $wp_customize->selective_refresh ) ) { $wp_customize->selective_refresh->add_partial( 'bongoto_header_partial', array( 'selector' => '#masthead', 'render_callback' => function () { get_template_part( 'template-parts/headers/header', (string) get_theme_mod( 'bongoto_header_variant', '1' ) ); }, 'settings' => array( 'bongoto_header_show_search', 'bongoto_header_show_account', 'bongoto_header_show_cart', 'bongoto_header_show_upload', 'bongoto_header_upload_label', ), ) ); } } add_action( 'customize_register', 'bongoto_customize_register_header', 30 );