0 ); }; $can_use = function() use ( $pro_active, $topbar_css_ready ) : bool { return $pro_active() && $topbar_css_ready(); }; // Panel/section location: use existing General panel if present. $panel_id = 'bongoto_general_panel'; $section_args = array( 'title' => __( 'Top Bar', 'bongoto-shop' ), 'priority' => 25, 'description' => __( 'Controls the thin top bar shown above Header variants 2–5. (Pro + requires Topbar CSS from Demo Import)', 'bongoto-shop' ), ); // Only attach panel if it exists (prevents Customizer errors). if ( $wp_customize->get_panel( $panel_id ) ) { $section_args['panel'] = $panel_id; } $wp_customize->add_section( 'bongoto_topbar_section', $section_args ); // Compute once for the description text (fine). $is_pro = $pro_active(); $has_css = $topbar_css_ready(); // Enable $wp_customize->add_setting( 'bongoto_shop_topbar_enable', array( 'default' => true, // IMPORTANT: do not force false when cannot-use (prevents accidental loss on temporary gate fail) 'sanitize_callback' => 'bongoto_shop_sanitize_checkbox', 'transport' => 'refresh', ) ); $wp_customize->add_control( 'bongoto_shop_topbar_enable', array( 'type' => 'checkbox', 'section' => 'bongoto_topbar_section', 'label' => __( 'Enable Top Bar', 'bongoto-shop' ), 'description' => ( ! $is_pro ) ? __( 'Top Bar is a Pro feature. Verify your purchase code to unlock it.', 'bongoto-shop' ) : ( $has_css ? __( 'Show the top bar above the header.', 'bongoto-shop' ) : __( 'Run Demo Import once to download Topbar CSS, then this option will unlock.', 'bongoto-shop' ) ), 'active_callback' => function() { return true; }, ) ); /** * Controls active only when: * - Pro is active (stable) * - Topbar CSS exists (stable) * - Enable toggle is ON */ $controls_active = function() use ( $can_use ) : bool { return $can_use() && (bool) get_theme_mod( 'bongoto_shop_topbar_enable', true ); }; // Phone $wp_customize->add_setting( 'bongoto_shop_topbar_phone', array( 'default' => '', 'sanitize_callback' => 'sanitize_text_field', 'transport' => 'refresh', ) ); $wp_customize->add_control( 'bongoto_shop_topbar_phone', array( 'type' => 'text', 'section' => 'bongoto_topbar_section', 'label' => __( 'Phone', 'bongoto-shop' ), 'input_attrs' => array( 'placeholder' => '+880 1XXXXXXXXX' ), 'active_callback' => $controls_active, ) ); // Email $wp_customize->add_setting( 'bongoto_shop_topbar_email', array( 'default' => '', 'sanitize_callback' => 'sanitize_email', 'transport' => 'refresh', ) ); $wp_customize->add_control( 'bongoto_shop_topbar_email', array( 'type' => 'text', 'section' => 'bongoto_topbar_section', 'label' => __( 'Email', 'bongoto-shop' ), 'input_attrs' => array( 'placeholder' => 'info@example.com' ), 'active_callback' => $controls_active, ) ); // Show login/register $wp_customize->add_setting( 'bongoto_shop_topbar_show_login', array( 'default' => true, // IMPORTANT: do not force false when cannot-use (prevents accidental loss) 'sanitize_callback' => 'bongoto_shop_sanitize_checkbox', 'transport' => 'refresh', ) ); $wp_customize->add_control( 'bongoto_shop_topbar_show_login', array( 'type' => 'checkbox', 'section' => 'bongoto_topbar_section', 'label' => __( 'Show Login / Register', 'bongoto-shop' ), 'active_callback' => $controls_active, ) ); // Social links $social_fields = array( 'facebook' => __( 'Facebook URL', 'bongoto-shop' ), 'instagram' => __( 'Instagram URL', 'bongoto-shop' ), 'linkedin' => __( 'LinkedIn URL', 'bongoto-shop' ), 'twitter' => __( 'Twitter/X URL', 'bongoto-shop' ), 'pinterest' => __( 'Pinterest URL', 'bongoto-shop' ), ); foreach ( $social_fields as $key => $label ) { $setting = 'bongoto_shop_topbar_social_' . $key; $wp_customize->add_setting( $setting, array( 'default' => '', 'sanitize_callback' => 'esc_url_raw', 'transport' => 'refresh', ) ); $wp_customize->add_control( $setting, array( 'type' => 'url', 'section' => 'bongoto_topbar_section', 'label' => $label, 'active_callback' => $controls_active, ) ); } /** * NOTE: * Topbar colors are controlled via presets (CSS variables), * not via Customizer color pickers. */ }, 99 );