$max ) $val = $max; return $val; } } if ( ! function_exists( 'bongoto_sanitize_hex_color' ) ) { function bongoto_sanitize_hex_color( $color ) { $color = trim( $color ); return ( '' === $color ) ? '' : sanitize_hex_color( $color ); } } /* Register */ function bongoto_customize_register( WP_Customize_Manager $wp_customize ) { $is_pro = apply_filters( 'bongoto/is_pro_active', ( defined( 'BONGOTO_PRO_ACTIVE' ) && BONGOTO_PRO_ACTIVE ) ); // Panel $wp_customize->add_panel( 'bongoto_panel', array( 'title' => __( 'Bongoto Theme Options', 'bongoto' ), 'description' => __( 'Global theme options. Site Identity controls remain in the WordPress core section.', 'bongoto' ), 'priority' => 160, ) ); /* General → Colors only */ $wp_customize->add_section( 'bongoto_section_general', array( 'title' => __( 'General', 'bongoto' ), 'priority' => 10, 'panel' => 'bongoto_panel', ) ); $colors = array( array( 'id' => 'bongoto_color_primary', 'label' => __( 'Primary Color', 'bongoto' ), 'default' => '#2563eb' ), array( 'id' => 'bongoto_color_accent', 'label' => __( 'Accent Color', 'bongoto' ), 'default' => '#10b981' ), array( 'id' => 'bongoto_color_text', 'label' => __( 'Text Color', 'bongoto' ), 'default' => '#111827' ), array( 'id' => 'bongoto_color_bg', 'label' => __( 'Background', 'bongoto' ), 'default' => '#ffffff' ), ); foreach ( $colors as $c ) { $wp_customize->add_setting( $c['id'], array( 'default' => $c['default'], 'transport' => 'postMessage', 'sanitize_callback' => 'bongoto_sanitize_hex_color', ) ); $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, $c['id'], array( 'label' => $c['label'], 'section' => 'bongoto_section_general', 'settings' => $c['id'], ) ) ); } /* Site Identity: extra fields */ $wp_customize->add_setting( 'bongoto_logo_max_height', array( 'default' => 40, 'transport' => 'postMessage', 'sanitize_callback' => function( $v ){ return bongoto_sanitize_int_range( $v, 16, 200, 40 ); }, ) ); $wp_customize->add_control( 'bongoto_logo_max_height', array( 'section' => 'title_tagline', 'label' => __( 'Logo Max Height (px)', 'bongoto' ), 'description' => __( 'Sets the maximum rendered height of the logo image.', 'bongoto' ), 'type' => 'number', 'priority' => 43, 'input_attrs' => array( 'min' => 16, 'max' => 200, 'step' => 1 ), ) ); // Our own separate toggles (do NOT depend on core checkbox) $wp_customize->add_setting( 'bongoto_show_title_text', array( 'default' => true, 'transport' => 'postMessage', 'sanitize_callback' => 'bongoto_sanitize_checkbox', ) ); $wp_customize->add_control( 'bongoto_show_title_text', array( 'section' => 'title_tagline', 'label' => __( 'Show Title (text)', 'bongoto' ), 'type' => 'checkbox', 'priority' => 44, ) ); $wp_customize->add_setting( 'bongoto_show_tagline_text', array( 'default' => true, 'transport' => 'postMessage', 'sanitize_callback' => 'bongoto_sanitize_checkbox', ) ); $wp_customize->add_control( 'bongoto_show_tagline_text', array( 'section' => 'title_tagline', 'label' => __( 'Show Tagline (description)', 'bongoto' ), 'type' => 'checkbox', 'priority' => 45, ) ); // Selective refresh if ( isset( $wp_customize->selective_refresh ) ) { $wp_customize->selective_refresh->add_partial( 'blogname', array( 'selector' => '.site-title a', 'render_callback' => function(){ return esc_html( get_bloginfo( 'name' ) ); }, ) ); $wp_customize->selective_refresh->add_partial( 'blogdescription', array( 'selector' => '.site-description', 'render_callback' => function(){ return esc_html( get_bloginfo( 'description', 'display' ) ); }, ) ); } // Shells $wp_customize->add_section( 'bongoto_section_header', array( 'title' => __( 'Header', 'bongoto' ), 'priority' => 20, 'panel' => 'bongoto_panel', ) ); $wp_customize->add_section( 'bongoto_section_footer', array( 'title' => __( 'Footer', 'bongoto' ), 'priority' => 40, 'panel' => 'bongoto_panel', 'description' => $is_pro ? __( 'Footer layout and copyright settings.', 'bongoto' ) : __( 'Footer layout settings. (Copyright text editing is available in Bongoto Pro)', 'bongoto' ), ) ); } add_action( 'customize_register', 'bongoto_customize_register' ); /* Cleanup: remove legacy/duplicate controls and the core Colors + core header text checkbox */ add_action( 'customize_register', function( WP_Customize_Manager $wp_customize ){ // Remove legacy IDs foreach ( array( 'bongoto_show_site_title','bongoto_show_tagline','bongoto_show_site_icon','bongoto_show_site_icon_header' ) as $id ) { if ( $wp_customize->get_control( $id ) ) $wp_customize->remove_control( $id ); if ( $wp_customize->get_setting( $id ) ) $wp_customize->remove_setting( $id ); } // Remove WP core "Display Site Title & Tagline" control completely if ( $wp_customize->get_control( 'display_header_text' ) ) { $wp_customize->remove_control( 'display_header_text' ); } // Keep its setting around silently (we don't rely on it, but no harm if it exists) // Remove WordPress core Colors section to avoid duplication if ( $wp_customize->get_section( 'colors' ) ) { $wp_customize->remove_section( 'colors' ); } // Strip any identity-like controls that slipped into General foreach ( $wp_customize->controls() as $control ) { $label = is_string( $control->label ) ? $control->label : ''; $section = $control->section; if ( 'bongoto_section_general' === $section ) { if ( stripos( $label, 'Site Title' ) !== false || stripos( $label, 'Tagline' ) !== false || stripos( $label, 'Site Icon' ) !== false ) { $wp_customize->remove_control( $control->id ); if ( $wp_customize->get_setting( $control->id ) ) $wp_customize->remove_setting( $control->id ); } } } }, 999 ); /* Include extra option files (if any) */ function bongoto_customize_include_option_files() { $base = trailingslashit( get_template_directory() ) . 'inc/customizer/'; $files = array( 'sanitize.php', 'options-general.php', 'options-header.php', 'options-footer.php', 'options-hero.php', 'controls/class-sortable-control.php', ); foreach ( $files as $rel ) { $path = $base . ltrim( $rel, '/' ); if ( file_exists( $path ) ) { require_once $path; } } } add_action( 'after_setup_theme', 'bongoto_customize_include_option_files', 20 ); /* Live preview (optional) */ function bongoto_customize_live_preview_js() { $rel = 'assets/js/customizer.js'; $file = trailingslashit( get_template_directory() ) . $rel; if ( file_exists( $file ) ) { wp_enqueue_script( 'bongoto-customizer-live', trailingslashit( get_template_directory_uri() ) . $rel, array( 'customize-preview', 'jquery' ), '1.0.0', true ); } } add_action( 'customize_preview_init', 'bongoto_customize_live_preview_js' ); /* Output CSS variables for colors */ function bongoto_customizer_colors_css() { $primary = get_theme_mod( 'bongoto_color_primary', '#2563eb' ); $accent = get_theme_mod( 'bongoto_color_accent', '#10b981' ); $text = get_theme_mod( 'bongoto_color_text', '#111827' ); $bg = get_theme_mod( 'bongoto_color_bg', '#ffffff' ); printf( '', esc_html( $primary ), esc_html( $accent ), esc_html( $text ), esc_html( $bg ) ); } add_action( 'wp_head', 'bongoto_customizer_colors_css', 20 ); /* Pro badge (restored) */ add_action( 'customize_controls_print_footer_scripts', function() { $is_pro = apply_filters( 'bongoto/is_pro_active', false ); $pro_link = esc_url( 'https://bongoto.com/product/bongoto-pro-digital-marketplace-addon/' ); ?>