<?php
defined( "ABSPATH" ) || die();

if ( file_exists( __DIR__ . "/switch.php" ) ) {

    require_once __DIR__ . "/switch.php";
}
if ( file_exists( __DIR__ . "/dimension.php" ) ) {

    require_once __DIR__ . "/dimension.php";
}
if ( file_exists( __DIR__ . "/icon-picker.php" ) ) {

    require_once __DIR__ . "/icon-picker.php";
}
if ( file_exists( __DIR__ . "/customizer-style.php" ) ) {
    require_once __DIR__ . "/customizer-style.php";
}
/**
 * Customizer settings for Header and Navigation Extension.
 */
trait Customizer {
    use CustomizerStyle;

    public function dnxte_get_customizer_settings( $wp_customize ) {
        // Header and Navigation settings options ==============
        $header_options = get_option( 'dnxte_header_navigation_options', array() );
        $is_cta_enabled = isset( $header_options['cta_menu_button'] ) ? $header_options['cta_menu_button'] : false;
        $is_menu_dropdown_enabled = isset( $header_options['custom_dropdown'] ) ? $header_options['custom_dropdown'] : false;
        $is_header_format_enabled = isset( $header_options['customize_header'] ) ? $header_options['customize_header'] : false;
        $is_primary_menu_enabled = isset( $header_options['hover_animation'] ) ? $header_options['hover_animation'] : false;

        /*
         * Add a new section for the Header and Navigation settings
         */
        $site_domain = get_locale();

        $google_fonts = et_builder_get_fonts(
            array(
                'prepend_standard_fonts' => false,
            )
        );

        $user_fonts = et_builder_get_custom_fonts();

        // combine google fonts with custom user fonts.
        $google_fonts = array_merge( $user_fonts, $google_fonts );

        $et_domain_fonts = array(
            'ru_RU' => 'cyrillic',
            'uk'    => 'cyrillic',
            'bg_BG' => 'cyrillic',
            'vi'    => 'vietnamese',
            'el'    => 'greek',
            'ar'    => 'arabic',
            'he_IL' => 'hebrew',
            'th'    => 'thai',
            'si_lk' => 'sinhala',
            'bn_bd' => 'bengali',
            'ta_lk' => 'tamil',
            'te'    => 'telegu',
            'km'    => 'khmer',
            'kn'    => 'kannada',
            'ml_in' => 'malayalam',
            'ja'    => 'japanese',
            'ko_KR' => 'korean',
            'ml_IN' => 'malayalam',
            'zh_CN' => 'chinese-simplified',
        );

        $font_choices = array();
        $font_choices['none'] = array(
            'label' => 'Default Theme Font',
        );

        $removed_fonts_mapping = et_builder_old_fonts_mapping();

        foreach ( $google_fonts as $google_font_name => $google_font_properties ) {
            $use_parent_font = false;

            if ( isset( $removed_fonts_mapping[$google_font_name] ) ) {
                $parent_font = $removed_fonts_mapping[$google_font_name]['parent_font'];
                $google_font_properties['character_set'] = $google_fonts[$parent_font]['character_set'];
                $use_parent_font = true;
            }

            if ( '' !== $site_domain && isset( $et_domain_fonts[$site_domain] ) && isset( $google_font_properties['character_set'] ) && false === strpos( $google_font_properties['character_set'], $et_domain_fonts[$site_domain] ) ) {
                continue;
            }

            $font_choices[$google_font_name] = array(
                'label' => $google_font_name,
                'data'  => array(
                    'parent_font'    => $use_parent_font ? $google_font_properties['parent_font'] : '',
                    'parent_styles'  => $use_parent_font ? $google_fonts[$parent_font]['styles'] : $google_font_properties['styles'],
                    'current_styles' => $use_parent_font && isset( $google_fonts[$parent_font]['styles'] ) && isset( $google_font_properties['styles'] ) ? $google_font_properties['styles'] : '',
                    'parent_subset'  => $use_parent_font && isset( $google_fonts[$parent_font]['character_set'] ) ? $google_fonts[$parent_font]['character_set'] : '',
                    'standard'       => isset( $google_font_properties['standard'] ) && $google_font_properties['standard'] ? 'on' : 'off',
                ),
            );
        }

        // === SHADOW OFFSET
        $shadow_settings = [
            'shadow_offset_x' => [
                'label'    => 'Shadow Offset X',
                'priority' => 105,
                'min'      => -100,
                'max'      => 100,
                'default'  => 0,
            ],
            'shadow_offset_y' => [
                'label'    => 'Shadow Offset Y',
                'priority' => 106,
                'min'      => -100,
                'max'      => 100,
                'default'  => 0,
            ],
            'shadow_blur'     => [
                'label'    => 'Shadow Blur',
                'priority' => 107,
                'min'      => 0,
                'max'      => 100,
                'default'  => 10,
            ],
            'shadow_spread'   => [
                'label'    => 'Shadow Spread',
                'priority' => 108,
                'min'      => 0,
                'max'      => 100,
                'default'  => 2,
            ],
        ];

        // hover item color =================== [Section - Header Primary]
        if ( $is_primary_menu_enabled ) {
            $wp_customize->add_setting(
                'dnxte_header_primary_section_label',
                array(
                    'default'    => 'none',
                    'type'       => 'option',
                    'capability' => 'edit_theme_options',

                )
            );
            $wp_customize->add_control(
                new WP_Customize_Control(
                    $wp_customize,
                    'dnxte_header_primary_section_label',
                    array(
                        "priority"    => 90,
                        'label'       => esc_html__( 'Header Primary', 'dnxte-divi-essential' ),
                        'description' => '<h3>Customize Header Primary Style</h3>',
                        'section'     => 'et_divi_header_primary',
                        'settings'    => 'dnxte_header_primary_section_label',
                        'type'        => 'hidden',
                    )
                )
            );
            $wp_customize->add_setting(
                'dnxte_menu_hover_color',
                array(
                    'default'           => '#E5E7EB',
                    'type'              => 'option',
                    'capability'        => 'edit_theme_options',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'et_sanitize_alpha_color',
                )
            );

            $wp_customize->add_control(
                new ET_Divi_Customize_Color_Alpha_Control(
                    $wp_customize,
                    'dnxte_menu_hover_color',
                    array(
                        'priority' => 90,
                        'label'    => esc_html__( 'Hover Text Color', 'dnxte-divi-essential' ),
                        'section'  => 'et_divi_header_primary',
                        'settings' => 'dnxte_menu_hover_color',
                    )
                )
            );
            $wp_customize->add_setting(
                'dnxte_menu_hover_bg_color',
                array(
                    'default'           => '',
                    'type'              => 'option',
                    'capability'        => 'edit_theme_options',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'et_sanitize_alpha_color',
                )
            );

            $wp_customize->add_control(
                new ET_Divi_Customize_Color_Alpha_Control(
                    $wp_customize,
                    'dnxte_menu_hover_bg_color',
                    array(
                        'priority' => 90,
                        'label'    => esc_html__( 'Hover Background Color', 'dnxte-divi-essential' ),
                        'section'  => 'et_divi_header_primary',
                        'settings' => 'dnxte_menu_hover_bg_color',
                    )
                )
            );
            $wp_customize->add_setting(
                'dnxte_menu_hover_color_fixed',
                array(
                    'default'           => '#E5E7EB',
                    'type'              => 'option',
                    'capability'        => 'edit_theme_options',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'et_sanitize_alpha_color',
                )
            );

            $wp_customize->add_control(
                new ET_Divi_Customize_Color_Alpha_Control(
                    $wp_customize,
                    'dnxte_menu_hover_color_fixed',
                    array(
                        'priority' => 91,
                        'label'    => esc_html__( 'Fixed Header Hover Text Color', 'dnxte-divi-essential' ),
                        'section'  => 'et_divi_header_primary',
                        'settings' => 'dnxte_menu_hover_color_fixed',
                    )
                )
            );
            $wp_customize->add_setting(
                'dnxte_menu_item_space',
                array(
                    'default'           => '0',
                    'type'              => 'option',
                    'capability'        => 'edit_theme_options',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'absint',
                )
            );

            $wp_customize->add_control(
                new ET_Divi_Range_Option(
                    $wp_customize,
                    'dnxte_menu_item_space',
                    array(
                        'priority'    => 92,
                        'label'       => esc_html__( 'Menu Item Spacing', 'dnxte-divi-essential' ),
                        'section'     => 'et_divi_header_primary',
                        'type'        => 'range',
                        'input_attrs' => array(
                            'min'  => 0,
                            'max'  => 100,
                            'step' => 1,
                        ),
                    )
                )
            );
            $wp_customize->add_setting(
                'dnxte_menu_item_space_fixed',
                array(
                    'default'           => '0',
                    'type'              => 'option',
                    'capability'        => 'edit_theme_options',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'absint',
                )
            );

            $wp_customize->add_control(
                new ET_Divi_Range_Option(
                    $wp_customize,
                    'dnxte_menu_item_space_fixed',
                    array(
                        'priority'    => 93,
                        'label'       => esc_html__( 'Fexed Header Menu Item Spacing', 'dnxte-divi-essential' ),
                        'section'     => 'et_divi_header_primary',
                        'type'        => 'range',
                        'input_attrs' => array(
                            'min'  => 0,
                            'max'  => 100,
                            'step' => 1,
                        ),
                    )
                )
            );

            $wp_customize->add_setting(
                'dnxte_hover_animated_color',
                array(
                    'default'           => '#7b61ff',
                    'type'              => 'option',
                    'capability'        => 'edit_theme_options',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'et_sanitize_alpha_color',
                )
            );

            $wp_customize->add_control(
                new ET_Divi_Customize_Color_Alpha_Control(
                    $wp_customize,
                    'dnxte_hover_animated_color',
                    array(
                        'priority' => 100,
                        'label'    => esc_html__( 'Hover Animated Color', 'dnxte-divi-essential' ),
                        'section'  => 'et_divi_header_primary',
                        'settings' => 'dnxte_hover_animated_color',
                    )
                )
            );

            // Hover Fixed Animated Color
            $wp_customize->add_setting( "dnxte_hover_fixed_animated_color", array(
                'default'           => '#7b61ff',
                'type'              => 'option',
                'capability'        => 'edit_theme_options',
                'transport'         => 'postMessage',
                'sanitize_callback' => 'et_sanitize_alpha_color',
            ) );
            $wp_customize->add_control(
                new ET_Divi_Customize_Color_Alpha_Control(
                    $wp_customize,
                    "dnxte_hover_fixed_animated_color",
                    [
                        "priority" => 101,
                        "label"    => __(
                            "Hover Fixed Animated Color",
                            "dnxte-divi-essential"
                        ),
                        "section"  => "et_divi_header_primary",
                    ]
                )
            );

            // === PADDING ===

            $wp_customize->add_setting( 'dnxte_padding', [
                'default'           => wp_json_encode( array( 'top' => '10', 'right' => '20', 'bottom' => '10', 'left' => '20' ) ),

                'sanitize_callback' => 'sanitize_text_field',
                'transport'         => 'postMessage',
            ] );

            $wp_customize->add_control( new WP_Customize_Dimension_Control( $wp_customize, 'dnxte_padding', [
                "priority" => 102,
                'label'    => __( 'ELEMENT Padding', 'dnxte-divi-essential' ),
                'section'  => 'et_divi_header_primary',
                'settings' => 'dnxte_padding',
            ] ) );

            // === BORDER RADIUS ===

            $wp_customize->add_setting( 'dnxte_radius', [
                'default'           => wp_json_encode( array( 'top' => '5', 'right' => '5', 'bottom' => '5', 'left' => '5' ) ),

                'sanitize_callback' => 'sanitize_text_field',
                'transport'         => 'postMessage',
            ] );

            $wp_customize->add_control( new WP_Customize_Dimension_Control( $wp_customize, 'dnxte_radius', [
                "priority"        => 103,
                'label'           => __( 'ELEMENT Border Radius', 'dnxte-divi-essential' ),
                'section'         => 'et_divi_header_primary',
                'settings'        => 'dnxte_radius',
                'active_callback' => function () {
                    $header_options = get_option( 'dnxte_header_navigation_options', [] );

                    $enabled_effects = [
                        'hover_effect_fill_slide_up',
                        'hover_effect_fill_slide_down',
                        'hover_effect_fill_slide_right',
                        'hover_effect_fill_slide_left',
                        'hover_effect_slide_up',
                        'hover_effect_slide_down',
                        'hover_effect_slide_right',
                        'hover_effect_slide_left',
                    ];

                    return isset( $header_options['group_of_effects'] ) && in_array( $header_options['group_of_effects'], $enabled_effects, true );
                }
            ] ) );
            // === HOVER BACKGROUND SHADOW COLOR ===
            $wp_customize->add_setting( "dnxte_hover_shadow_color", [
                "default"           => "#7b61ff",
                "type"              => "option",
                "sanitize_callback" => "sanitize_hex_color",
            ] );
            $wp_customize->add_control(
                new WP_Customize_Color_Control(
                    $wp_customize,
                    "dnxte_hover_shadow_color",
                    [
                        "priority" => 104,
                        "label"    => __(
                            "Hover Background Shadow Color",
                            "dnxte-divi-essential"
                        ),
                        "section"  => "et_divi_header_primary",
                    ]
                )
            );

            foreach ( $shadow_settings as $key => $config ) {
                $setting_id = "dnxte_{$key}";

                $wp_customize->add_setting( $setting_id, [
                    'default'           => $config['default'],
                    'type'              => 'option',
                    'capability'        => 'edit_theme_options',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'absint',
                ] );

                $wp_customize->add_control( new ET_Divi_Range_Option( $wp_customize, $setting_id, [
                    'priority'    => $config['priority'],
                    'label'       => esc_html__( $config['label'], 'dnxte-divi-essential' ),
                    'section'     => 'et_divi_header_primary',
                    'type'        => 'range',
                    'input_attrs' => [
                        'min'  => $config['min'],
                        'max'  => $config['max'],
                        'step' => 1,
                    ],
                ] ) );
            }

            // === SWITCH TOGGLES ===
            $switches = [
                "hover_active_menu"        => "Hover Style to Active Menu",
                "hover_effect_on_dropdown" => "Hover Effect on Dropdown",

            ];
            foreach ( $switches as $key => $label ) {
                $wp_customize->add_setting( "dnxte_{$key}", [
                    "default"           => 0,
                    "sanitize_callback" => "sanitize_text_field",
                    "transport"         => "refresh",
                ] );

                $wp_customize->add_control( new WP_Customize_Toggle_Switch_Control( $wp_customize, "dnxte_{$key}", [
                    'label'    => __( $label, 'dnxte-divi-essential' ),
                    "priority" => 108,
                    'section'  => 'et_divi_header_primary',
                    'settings' => 'dnxte_' . $key,
                ] ) );
            }

            // Menu Badge style
            $wp_customize->add_setting(
                'dnxte_menu_badge_style',
                array(
                    'default'           => 'default',
                    'type'              => 'option',
                    'capability'        => 'edit_theme_options',
                    'transport'         => 'refresh',
                    'sanitize_callback' => 'sanitize_text_field',
                )
            );
            $wp_customize->add_control(
                'dnxte_menu_badge_style',
                array(
                    'label'    => esc_html__( 'Menu Badge Style', 'dnxte-divi-essential' ),
                    'section'  => 'et_divi_header_primary',
                    "priority" => 109,
                    'settings' => 'dnxte_menu_badge_style',
                    'type'     => 'select',
                    'choices'  => [
                        'default' => esc_html__( 'Default', 'dnxte-divi-essential' ),
                        'rounded' => esc_html__( 'Rounded', 'dnxte-divi-essential' ),
                        'square'  => esc_html__( 'Square', 'dnxte-divi-essential' ),
                        'border'  => esc_html__( 'Border', 'dnxte-divi-essential' ),
                    ],
                )
            );

            $wp_customize->add_setting(
                'dnxte_primary_menu_section_end',
                array(
                    'default'    => 'none',
                    'type'       => 'option',
                    'capability' => 'edit_theme_options',

                )
            );
            $wp_customize->add_control(
                new WP_Customize_Control(
                    $wp_customize,
                    'dnxte_primary_menu_section_end',
                    array(
                        'section'  => 'et_divi_header_primary',
                        "priority" => 109,
                        'label'    => '',
                        'settings' => 'dnxte_primary_menu_section_end',
                        'type'     => 'hidden',
                    )
                )
            );
        } else {
            $wp_customize->add_setting(
                'dnxte_primary_header_blank_section_label',
                array(
                    'default'    => 'none',
                    'type'       => 'option',
                    'capability' => 'edit_theme_options',
                )
            );
            $wp_customize->add_control(
                new WP_Customize_Control(
                    $wp_customize,
                    'dnxte_primary_header_blank_section_label',
                    array(
                        'label'       => esc_html__( 'Primary Header', 'dnxte-divi-essential' ),
                        'description' => '<img src="' . esc_url( DIVI_ESSENTIAL_EXTENSIONS_PATH . 'icon-image/customizer-blank.png' ) . '"><p>To customize Menu CTA Button enable Header & Navigation customization in Divi Essential plugin dashboard.</p><a href="admin.php?page=dnxte-header-navigation" target="_blank" class="button button-primary">Divi Essential Dashboard</a>',
                        'priority'    => 110,
                        'section'     => 'et_divi_header_primary',
                        'settings'    => 'dnxte_primary_header_blank_section_label',
                        'type'        => 'hidden',
                    )
                )
            );
        }
        // End Primary menu section ================= [Section - Header Primary]

        // header format or  primary heading bar [Section - Header Format]

        if ( $is_header_format_enabled ) {
            $wp_customize->add_setting(
                'dnxte_header_format_section_label',
                array(
                    'default'    => 'none',
                    'type'       => 'option',
                    'capability' => 'edit_theme_options',

                )
            );
            $wp_customize->add_control(
                new WP_Customize_Control(
                    $wp_customize,
                    'dnxte_header_format_section_label',
                    array(
                        "priority"    => 11,
                        'label'       => esc_html__( 'Header Format', 'dnxte-divi-essential' ),
                        'description' => '<h3>Customize Header Format Style</h3>',
                        'section'     => 'et_divi_header_layout',
                        'settings'    => 'dnxte_header_format_section_label',
                        'type'        => 'hidden',
                    )
                )
            );
            $wp_customize->add_setting( 'dnxte_header_shadow', [
                'default'           => 0,
                'sanitize_callback' => 'sanitize_text_field',
                "transport"         => "refresh",
            ] );

            $wp_customize->add_control( new WP_Customize_Toggle_Switch_Control( $wp_customize, 'dnxte_header_shadow', [
                "priority" => 11,
                'label'    => __( 'Display Main Header Shadow', 'dnxte-divi-essential' ),
                'section'  => 'et_divi_header_layout',
                'settings' => 'dnxte_header_shadow',
            ] ) );

            $wp_customize->add_setting(
                'dnxte_header_shadow_color',
                array(
                    'default'           => '#666666',
                    'type'              => 'option',
                    'capability'        => 'edit_theme_options',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'et_sanitize_alpha_color',
                )
            );

            $wp_customize->add_control(
                new ET_Divi_Customize_Color_Alpha_Control(
                    $wp_customize,
                    'dnxte_header_shadow_color',
                    array(
                        "priority"        => 12,
                        'label'           => esc_html__( 'Header Shadow Color', 'dnxte-divi-essential' ),
                        'section'         => 'et_divi_header_layout',
                        'settings'        => 'dnxte_header_shadow_color',
                        'active_callback' => function () use ( $wp_customize ) {
                            return $wp_customize->get_setting( 'dnxte_header_shadow' )->value() == 1;
                        },
                    )
                )
            );
            $priority_base = 13;
            $i = 0;
            foreach ( $shadow_settings as $key => $config ) {
                $setting_id = "dnxte_header_{$key}";

                $wp_customize->add_setting( $setting_id, [
                    'default'           => $config['default'],
                    'type'              => 'option',
                    'capability'        => 'edit_theme_options',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'absint',
                ] );

                $wp_customize->add_control( new ET_Divi_Range_Option( $wp_customize, $setting_id, [
                    'priority'        => $priority_base + $i++,
                    'label'           => esc_html__( "Header " . $config['label'], 'dnxte-divi-essential' ),
                    'section'         => 'et_divi_header_layout',
                    'type'            => 'range',
                    'input_attrs'     => [
                        'min'  => $config['min'],
                        'max'  => $config['max'],
                        'step' => 1,
                    ],
                    'active_callback' => function () use ( $wp_customize ) {
                        return $wp_customize->get_setting( 'dnxte_header_shadow' )->value() == 1;
                    },
                ] ) );
            }
            $wp_customize->add_setting( 'dnxte_header_shadow_fixed', [
                'default'           => 0,
                'type'              => 'option',
                'sanitize_callback' => 'absint',
                "transport"         => "refresh",
            ] );

            $wp_customize->add_control( new WP_Customize_Toggle_Switch_Control( $wp_customize, 'dnxte_header_shadow_fixed', [
                "priority" => 17,
                'label'    => __( 'Display Fixed Header Shadow', 'dnxte-divi-essential' ),
                'section'  => 'et_divi_header_layout',
                'settings' => 'dnxte_header_shadow_fixed',
            ] ) );

            $wp_customize->add_setting(
                'dnxte_header_shadow_color_fixed',
                array(
                    'default'           => '',
                    'type'              => 'option',
                    'capability'        => 'edit_theme_options',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'et_sanitize_alpha_color',
                )
            );

            $wp_customize->add_control(
                new ET_Divi_Customize_Color_Alpha_Control(
                    $wp_customize,
                    'dnxte_header_shadow_color_fixed',
                    array(
                        "priority"        => 18,
                        'label'           => esc_html__( 'Fixed Header Shadow Color', 'dnxte-divi-essential' ),
                        'section'         => 'et_divi_header_layout',
                        'settings'        => 'dnxte_header_shadow_color_fixed',
                        'active_callback' => function () use ( $wp_customize ) {
                            return $wp_customize->get_setting( 'dnxte_header_shadow_fixed' )->value() == 1;
                        },
                    )
                )
            );
            foreach ( $shadow_settings as $key => $config ) {
                $setting_id = "dnxte_header_fixed_{$key}";

                $wp_customize->add_setting( $setting_id, [
                    'default'           => $config['default'],
                    'type'              => 'option',
                    'capability'        => 'edit_theme_options',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'absint',
                ] );

                $wp_customize->add_control( new ET_Divi_Range_Option( $wp_customize, $setting_id, [
                    'priority'        => 19 + $i++,
                    'label'           => esc_html__( "Fxied Header " . $config['label'], 'dnxte-divi-essential' ),
                    'section'         => 'et_divi_header_layout',
                    'type'            => 'range',
                    'input_attrs'     => [
                        'min'  => $config['min'],
                        'max'  => $config['max'],
                        'step' => 1,
                    ],
                    'active_callback' => function () use ( $wp_customize ) {
                        return $wp_customize->get_setting( 'dnxte_header_shadow_fixed' )->value() == 1;
                    },
                ] ) );
            }
            $wp_customize->add_setting(
                'dnxte_header_format_section_end',
                array(
                    'default'    => 'none',
                    'type'       => 'option',
                    'capability' => 'edit_theme_options',

                )
            );
            $wp_customize->add_control(
                new WP_Customize_Control(
                    $wp_customize,
                    'dnxte_header_format_section_end',
                    array(
                        'section'  => 'et_divi_header_layout',
                        "priority" => 30,
                        'label'    => '',
                        'settings' => 'dnxte_header_format_section_end',
                        'type'     => 'hidden',
                    )
                )
            );
        } else {
            $wp_customize->add_setting(
                'dnxte_header_format_blank_section_label',
                array(
                    'default'    => 'none',
                    'type'       => 'option',
                    'capability' => 'edit_theme_options',
                )
            );
            $wp_customize->add_control(
                new WP_Customize_Control(
                    $wp_customize,
                    'dnxte_header_format_blank_section_label',
                    array(
                        'label'       => esc_html__( 'Header Format', 'dnxte-divi-essential' ),
                        'description' => '<img src="' . esc_url( DIVI_ESSENTIAL_EXTENSIONS_PATH . 'icon-image/customizer-blank.png' ) . '"><p>To customize Menu CTA Button enable Header & Navigation customization in Divi Essential plugin dashboard.</p><a href="admin.php?page=dnxte-header-navigation" target="_blank" class="button button-primary">Divi Essential Dashboard</a>',
                        'priority'    => 30,
                        'section'     => 'et_divi_header_layout',
                        'settings'    => 'dnxte_header_format_blank_section_label',
                        'type'        => 'hidden',
                    )
                )
            );
        }
        // End Header format section ================= [Section - Header Format]

        // call to action button section ================
        $wp_customize->add_section(
            'dnxte_cta_section',
            array(
                'priority' => 20,
                'title'    => esc_html__( 'Call To Action Button', 'dnxte-divi-essential' ),
                'panel'    => 'et_divi_header_panel',
            )
        );
        if ( $is_cta_enabled ) {
            $wp_customize->add_setting(
                'dnxte_cta_section_label',
                array(
                    'default'    => 'none',
                    'type'       => 'option',
                    'capability' => 'edit_theme_options',

                )
            );
            $wp_customize->add_control(
                new WP_Customize_Control(
                    $wp_customize,
                    'dnxte_cta_section_label',
                    array(
                        'label'       => esc_html__( 'Call To Action Button', 'dnxte-divi-essential' ),
                        'description' => '<h3>Customize Call To Action Button Style</h3>',
                        'section'     => 'dnxte_cta_section',
                        'settings'    => 'dnxte_cta_section_label',
                        'type'        => 'hidden',
                    )
                )
            );

            $wp_customize->add_setting(
                'dnxte_cta_font_select',
                array(
                    'default'           => 'none',
                    'type'              => 'option',
                    'capability'        => 'edit_theme_options',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'et_sanitize_font_choices',
                )
            );

            $wp_customize->add_control(
                new ET_Divi_Select_Option(
                    $wp_customize,
                    'dnxte_cta_font_select',
                    array(
                        'label'    => esc_html__( 'Call To Action Button Font', 'dnxte-divi-essential' ),
                        'section'  => 'dnxte_cta_section',
                        'settings' => 'dnxte_cta_font_select',
                        'type'     => 'select',
                        'choices'  => $font_choices,
                    )
                )
            );

            $wp_customize->add_setting(
                'dnxte_cta_font_size',
                array(
                    'default'           => '14',
                    'type'              => 'option',
                    'capability'        => 'edit_theme_options',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'absint',
                )
            );
            $wp_customize->add_control(
                new ET_Divi_Range_Option(
                    $wp_customize,
                    'dnxte_cta_font_size',
                    array(
                        'label'       => esc_html__( 'Font Size', 'dnxte-divi-essential' ),
                        'section'     => 'dnxte_cta_section',
                        'type'        => 'range',
                        'input_attrs' => array(
                            'min'  => 10,
                            'max'  => 32,
                            'step' => 1,
                        ),
                    )
                )
            );
            $wp_customize->add_setting(
                'dnxte_cta_font_weight',
                array(
                    'default'           => '500',
                    'type'              => 'option',
                    'capability'        => 'edit_theme_options',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'et_sanitize_global_font_weight',
                )
            );

            $wp_customize->add_control(
                new ET_Divi_Custom_Select_Option(
                    $wp_customize,
                    'dnxte_cta_font_weight',
                    array(
                        'label'    => esc_html__( 'Header Font Weight', 'dnxte-divi-essential' ),
                        'section'  => 'dnxte_cta_section',
                        'settings' => 'dnxte_cta_font_weight',
                        'type'     => 'select',
                        'choices'  => et_builder_get_font_weight_list(),
                    )
                )
            );
            $wp_customize->add_setting(
                'dnxte_cta_letter_spaciong',
                array(
                    'default'           => '0',
                    'type'              => 'option',
                    'capability'        => 'edit_theme_options',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'et_sanitize_int_number',
                )
            );

            $wp_customize->add_control(
                new ET_Divi_Range_Option(
                    $wp_customize,
                    'dnxte_cta_letter_spaciong',
                    array(
                        'label'       => esc_html__( 'Letter Spacing', 'dnxte-divi-essential' ),
                        'section'     => 'dnxte_cta_section',
                        'type'        => 'range',
                        'input_attrs' => array(
                            'min'  => -1,
                            'max'  => 10,
                            'step' => 1,
                        ),
                    )
                )
            );

            $wp_customize->add_setting(
                'dnxte_cta_font_style_transform',
                array(
                    'default'           => '',
                    'type'              => 'option',
                    'capability'        => 'edit_theme_options',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'et_sanitize_font_style',
                )
            );

            $wp_customize->add_control(
                new ET_Divi_Font_Style_Option(
                    $wp_customize,
                    'dnxte_cta_font_style_transform',
                    array(
                        'label'   => esc_html__( 'Font Style', 'dnxte-divi-essential' ),
                        'section' => 'dnxte_cta_section',
                        'type'    => 'font_style',
                        'choices' => et_divi_font_style_choices(),
                    )
                )
            );
            $wp_customize->add_setting(
                'dnxte_cta_text_color',
                array(
                    'default'           => '',
                    'type'              => 'option',
                    'capability'        => 'edit_theme_options',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'et_sanitize_alpha_color',
                )
            );

            $wp_customize->add_control(
                new ET_Divi_Customize_Color_Alpha_Control(
                    $wp_customize,
                    'dnxte_cta_text_color',
                    array(
                        'label'    => esc_html__( 'Text Color', 'dnxte-divi-essential' ),
                        'section'  => 'dnxte_cta_section',
                        'settings' => 'dnxte_cta_text_color',
                    )
                )
            );
            $wp_customize->add_setting(
                'dnxte_cta_text_color_hover',
                array(
                    'default'           => '',
                    'type'              => 'option',
                    'capability'        => 'edit_theme_options',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'et_sanitize_alpha_color',
                )
            );

            $wp_customize->add_control(
                new ET_Divi_Customize_Color_Alpha_Control(
                    $wp_customize,
                    'dnxte_cta_text_color_hover',
                    array(
                        'label'    => esc_html__( 'Hover Text Color', 'dnxte-divi-essential' ),
                        'section'  => 'dnxte_cta_section',
                        'settings' => 'dnxte_cta_text_color_hover',
                    )
                )
            );

            $wp_customize->add_setting(
                'dnxte_button_background_color',
                array(
                    'default'           => '',
                    'type'              => 'option',
                    'capability'        => 'edit_theme_options',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'et_sanitize_alpha_color',
                )
            );

            $wp_customize->add_control(
                new ET_Divi_Customize_Color_Alpha_Control(
                    $wp_customize,
                    'dnxte_button_background_color',
                    array(
                        'label'    => esc_html__('Button Background Color', 'dnxte-divi-essential'),
                        'section'  => 'dnxte_cta_section',
                        'settings' => 'dnxte_button_background_color',
                    )
                )
            );
            $wp_customize->add_setting(
                'dnxte_button_background_color_hover',
                array(
                    'default'           => '',
                    'type'              => 'option',
                    'capability'        => 'edit_theme_options',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'et_sanitize_alpha_color',
                )
            );

            $wp_customize->add_control(
                new ET_Divi_Customize_Color_Alpha_Control(
                    $wp_customize,
                    'dnxte_button_background_color_hover',
                    array(
                        'label'    => esc_html__('Button Hover Background Color', 'dnxte-divi-essential'),
                        'section'  => 'dnxte_cta_section',
                        'settings' => 'dnxte_button_background_color_hover',
                    )
                )
            );

            $wp_customize->add_setting( 'dnxte_icon_setting', [
                'default'           => '5',
                'type'              => 'option',
                'capability'        => 'edit_theme_options',
                'transport'         => 'postMessage',
                'sanitize_callback' => 'et_sanitize_font_icon',
            ] );

            // $wp_customize->add_control(new WP_Customize_Icon_Picker_Control($wp_customize, 'dnxte_icon_setting', [
            //     'label' => __('Choose Icon', 'textdomain'),
            //     'section' => 'dnxte_cta_section',
            // ]));
            $wp_customize->add_control(
                new ET_Divi_Icon_Picker_Option(
                    $wp_customize,
                    'dnxte_icon_setting',
                    array(
                        'label'   => esc_html__( 'Select Icon', 'dnxte-divi-essential' ),
                        'section' => 'dnxte_cta_section',
                        'type'    => 'icon_picker',
                    )
                )
            );
            $wp_customize->add_setting(
                'dnxte_cta_icon_color',
                array(
                    'default'           => '',
                    'type'              => 'option',
                    'capability'        => 'edit_theme_options',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'et_sanitize_alpha_color',
                )
            );

            $wp_customize->add_control(
                new ET_Divi_Customize_Color_Alpha_Control(
                    $wp_customize,
                    'dnxte_cta_icon_color',
                    array(
                        'label'    => esc_html__( 'Icon Color', 'dnxte-divi-essential' ),
                        'section'  => 'dnxte_cta_section',
                        'settings' => 'dnxte_cta_icon_color',
                    )
                )
            );
            $wp_customize->add_setting(
                'dnxte_cta_icon_size',
                array(
                    'default'           => '14',
                    'type'              => 'option',
                    'capability'        => 'edit_theme_options',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'absint',
                )
            );

            $wp_customize->add_control(
                new ET_Divi_Range_Option(
                    $wp_customize,
                    'dnxte_cta_icon_size',
                    array(
                        'label'       => esc_html__( 'Icon Size', 'dnxte-divi-essential' ),
                        'section'     => 'dnxte_cta_section',
                        'type'        => 'range',
                        'input_attrs' => array(
                            'min'  => 12,
                            'max'  => 50,
                            'step' => 1,
                        ),
                    )
                )
            );
            $wp_customize->add_setting(
                'dnxte_cta_icon_gap',
                array(
                    'default'           => '5',
                    'type'              => 'option',
                    'capability'        => 'edit_theme_options',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'absint',
                )
            );

            $wp_customize->add_control(
                new ET_Divi_Range_Option(
                    $wp_customize,
                    'dnxte_cta_icon_gap',
                    array(
                        'label'       => esc_html__( 'Icon Gap', 'dnxte-divi-essential' ),
                        'section'     => 'dnxte_cta_section',
                        'type'        => 'range',
                        'input_attrs' => array(
                            'min'  => 0,
                            'max'  => 100,
                            'step' => 1,
                        ),
                    )
                )
            );
            $wp_customize->add_setting( 'dnxte_icon_position', [
                'default'           => 'row',
                'type'              => 'option',
                'transport'         => 'postMessage',
                'sanitize_callback' => function ( $value ) {
                    return in_array( $value, ['row-reverse', 'row'] ) ? $value : 'row';
                },
            ] );

            $wp_customize->add_control( 'dnxte_icon_position', [
                'label'   => __( 'Icon Position', 'dnxte-divi-essential' ),
                'section' => 'dnxte_cta_section',
                'type'    => 'radio',
                'choices' => [
                    'row'         => __( 'Right Side', 'dnxte-divi-essential' ),
                    'row-reverse' => __( 'Left Side', 'dnxte-divi-essential' ),
                ],
            ] );
            $wp_customize->add_setting(
                'dnxte_button_hover_effect_select',
                array(
                    'default'           => 'none',
                    'type'              => 'theme_mod',
                    'capability'        => 'edit_theme_options',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'sanitize_text_field',
                )
            );

            $wp_customize->add_control(
                'dnxte_button_hover_effect_select',
                array(
                    'label'    => esc_html__( 'Hover Effect', 'dnxte-divi-essential' ),
                    'section'  => 'dnxte_cta_section',
                    'settings' => 'dnxte_button_hover_effect_select',
                    'type'     => 'select',
                    'choices'  => [
                        'none'                     => esc_html__( 'None', 'dnxte-divi-essential' ),
                        'dnxt-hover-grow'          => esc_html__( 'Grow', 'dnxte-divi-essential' ),
                        'dnxt-hover-shrink'        => esc_html__( 'Shrink', 'dnxte-divi-essential' ),
                        'dnxt-hover-pulse-shrink'  => esc_html__( 'Pulse Shrink', 'dnxte-divi-essential' ),
                        'dnxt-hover-pulse'         => esc_html__( 'Pulse', 'dnxte-divi-essential' ),
                        'dnxt-hover-pulse-grow'    => esc_html__( 'Pulse Grow', 'dnxte-divi-essential' ),
                        'dnxt-hover-push'          => esc_html__( 'Push', 'dnxte-divi-essential' ),
                        'dnxt-hover-pop'           => esc_html__( 'Pop', 'dnxte-divi-essential' ),
                        'dnxt-hover-bounce-in'     => esc_html__( 'Bounce In', 'dnxte-divi-essential' ),
                        'dnxt-hover-bounce-out'    => esc_html__( 'Bounce Out', 'dnxte-divi-essential' ),
                        'dnxt-hover-rotate'        => esc_html__( 'Rotate', 'dnxte-divi-essential' ),
                        'dnxt-hover-grow-rotate'   => esc_html__( 'Grow Rotate', 'dnxte-divi-essential' ),
                        'dnxt-hover-float'         => esc_html__( 'Float', 'dnxte-divi-essential' ),
                        'dnxt-hover-bob'           => esc_html__( 'Bob', 'dnxte-divi-essential' ),
                        'dnxt-hover-hang'          => esc_html__( 'Hang', 'dnxte-divi-essential' ),
                        'dnxt-hover-skew'          => esc_html__( 'Skew', 'dnxte-divi-essential' ),
                        'dnxt-hover-skew-forward'  => esc_html__( 'Skew Forward', 'dnxte-divi-essential' ),
                        'dnxt-hover-skew-backward' => esc_html__( 'Skew Backward', 'dnxte-divi-essential' ),

                    ],
                )
            );

            $wp_customize->add_setting( 'dnxte_cta_button_padding', [
                'default'           => wp_json_encode( array( 'top' => '12', 'right' => '20', 'bottom' => '10', 'left' => '10' ) ),

                'sanitize_callback' => 'sanitize_text_field',
                'transport'         => 'postMessage',
            ] );

            $wp_customize->add_control( new WP_Customize_Dimension_Control( $wp_customize, 'dnxte_cta_button_padding', [

                'label'    => __( 'Button Padding', 'dnxte-divi-essential' ),
                'section'  => 'dnxte_cta_section',
                'settings' => 'dnxte_cta_button_padding',
            ] ) );

            

            $wp_customize->add_setting(
                'dnxte_cta_button_border_width',
                array(
                    'default'           => '',
                    'type'              => 'option',
                    'capability'        => 'edit_theme_options',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'absint',
                )
            );
            $wp_customize->add_control(
                new ET_Divi_Range_Option(
                    $wp_customize,
                    'dnxte_cta_button_border_width',
                    array(
                        'label'       => esc_html__( 'Border Width', 'dnxte-divi-essential' ),
                        'section'     => 'dnxte_cta_section',
                        'type'        => 'range',
                        'input_attrs' => array(
                            'min'  => 0,
                            'max'  => 32,
                            'step' => 1,
                        ),
                    )
                )
            );
            $wp_customize->add_setting(
                'dnxte_cta_button_border_radius',
                array(
                    'default'           => '',
                    'type'              => 'option',
                    'capability'        => 'edit_theme_options',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'absint',
                )
            );
            $wp_customize->add_control(
                new ET_Divi_Range_Option(
                    $wp_customize,
                    'dnxte_cta_button_border_radius',
                    array(
                        'label'       => esc_html__( 'Border Radius', 'dnxte-divi-essential' ),
                        'section'     => 'dnxte_cta_section',
                        'type'        => 'range',
                        'input_attrs' => array(
                            'min'  => 0,
                            'max'  => 100,
                            'step' => 1,
                        ),
                    )
                )
            );

            $wp_customize->add_setting(
                'dnxte_button_border_color',
                array(
                    'default'           => '',
                    'type'              => 'option',
                    'capability'        => 'edit_theme_options',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'et_sanitize_alpha_color',
                )
            );

            $wp_customize->add_control(
                new ET_Divi_Customize_Color_Alpha_Control(
                    $wp_customize,
                    'dnxte_button_border_color',
                    array(
                        'label'    => esc_html__( 'Button Border Color', 'dnxte-divi-essential' ),
                        'section'  => 'dnxte_cta_section',
                        'settings' => 'dnxte_button_border_color',
                    )
                )
            );
            $wp_customize->add_setting(
                'dnxte_button_border_color_hover',
                array(
                    'default'           => '',
                    'type'              => 'option',
                    'capability'        => 'edit_theme_options',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'et_sanitize_alpha_color',
                )
            );

            $wp_customize->add_control(
                new ET_Divi_Customize_Color_Alpha_Control(
                    $wp_customize,
                    'dnxte_button_border_color_hover',
                    array(
                        'label'    => esc_html__( 'Hover Border Color', 'dnxte-divi-essential' ),
                        'section'  => 'dnxte_cta_section',
                        'settings' => 'dnxte_button_border_color_hover',
                    )
                )
            );

            // cta shadow
            $wp_customize->add_setting( 'dnxte_cta_btn_shadow', [
                'default'           => 0,
                'type'              => 'option',
                'sanitize_callback' => 'sanitize_text_field',
                "transport"         => "refresh",
            ] );

            $wp_customize->add_control( new WP_Customize_Toggle_Switch_Control( $wp_customize, 'dnxte_cta_btn_shadow', [

                'label'    => __( 'Button Shadow', 'dnxte-divi-essential' ),
                'section'  => 'dnxte_cta_section',
                'settings' => 'dnxte_cta_btn_shadow',
            ] ) );

            $wp_customize->add_setting(
                'dnxte_cta_btn_shadow_color',
                array(
                    'default'           => '#666666',
                    'type'              => 'option',
                    'capability'        => 'edit_theme_options',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'et_sanitize_alpha_color',
                )
            );

            $wp_customize->add_control(
                new ET_Divi_Customize_Color_Alpha_Control(
                    $wp_customize,
                    'dnxte_cta_btn_shadow_color',
                    array(
                        'label'           => esc_html__( 'Button Shadow Color', 'dnxte-divi-essential' ),
                        'section'         => 'dnxte_cta_section',
                        'settings'        => 'dnxte_cta_btn_shadow_color',
                        'active_callback' => function () use ( $wp_customize ) {
                            return $wp_customize->get_setting( 'dnxte_cta_btn_shadow' )->value() == 1;
                        },
                    )
                )
            );

            foreach ( $shadow_settings as $key => $config ) {
                $setting_id = "dnxte_cta_btn_{$key}";

                $wp_customize->add_setting( $setting_id, [
                    'default'           => $config['default'],
                    'type'              => 'option',
                    'capability'        => 'edit_theme_options',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'absint',
                ] );

                $wp_customize->add_control( new ET_Divi_Range_Option( $wp_customize, $setting_id, [

                    'label'           => esc_html__( "Button " . $config['label'], 'dnxte-divi-essential' ),
                    'section'         => 'dnxte_cta_section',
                    'type'            => 'range',
                    'input_attrs'     => [
                        'min'  => $config['min'],
                        'max'  => $config['max'],
                        'step' => 1,
                    ],
                    'active_callback' => function () use ( $wp_customize ) {
                        return $wp_customize->get_setting( 'dnxte_cta_btn_shadow' )->value() == 1;
                    },
                ] ) );
            }
        } else {
            $wp_customize->add_setting(
                'dnxte_cta_blank_section_label',
                array(
                    'default'    => 'none',
                    'type'       => 'option',
                    'capability' => 'edit_theme_options',
                )
            );
            $wp_customize->add_control(
                new WP_Customize_Control(
                    $wp_customize,
                    'dnxte_cta_blank_section_label',
                    array(
                        'label'       => esc_html__( 'Call To Action Button', 'dnxte-divi-essential' ),
                        'description' => '<img src="' . esc_url( DIVI_ESSENTIAL_EXTENSIONS_PATH . 'icon-image/customizer-blank.png' ) . '"><p>To customize Menu CTA Button enable Header & Navigation customization in Divi Essential plugin dashboard.</p><a href="admin.php?page=dnxte-header-navigation" target="_blank" class="button button-primary">Divi Essential Dashboard</a>',
                        'section'     => 'dnxte_cta_section',
                        'settings'    => 'dnxte_cta_blank_section_label',
                        'type'        => 'hidden',
                    )
                )
            );
        }

        // dropdown option ===============
        $wp_customize->add_section(
            'dnxte_dropdown_section_settings',
            array(
                'title' => esc_html__( 'Dropdown Settings', 'dnxte-divi-essential' ),
                'panel' => 'et_divi_header_panel',
            )
        );
        if ( $is_menu_dropdown_enabled ) {
            $wp_customize->add_setting(
                'dnxte_dropdown_section_label',
                array(
                    'default'    => 'none',
                    'type'       => 'option',
                    'capability' => 'edit_theme_options',

                )
            );
            $wp_customize->add_control(
                new WP_Customize_Control(
                    $wp_customize,
                    'dnxte_dropdown_section_label',
                    array(
                        'label'       => esc_html__( 'Dropdown Settings', 'dnxte-divi-essential' ),
                        'description' => '<h3>Customize Menu Dropdown Style</h3>',
                        'section'     => 'dnxte_dropdown_section_settings',
                        'settings'    => 'dnxte_dropdown_section_label',
                        'type'        => 'hidden',
                    )
                )
            );

            $wp_customize->add_setting(
                'dnxte_dp_font_select_dp',
                array(
                    'default'           => 'none',
                    'type'              => 'option',
                    'capability'        => 'edit_theme_options',
                    'transport'         => 'refresh',
                    'sanitize_callback' => 'et_sanitize_font_choices',
                )
            );

            $wp_customize->add_control(
                new ET_Divi_Select_Option(
                    $wp_customize,
                    'dnxte_dp_font_select_dp',
                    array(
                        'label'    => esc_html__( 'Dropdown Menu Font', 'dnxte-divi-essential' ),
                        'section'  => 'dnxte_dropdown_section_settings',
                        'settings' => 'dnxte_dp_font_select_dp',
                        'type'     => 'select',
                        'choices'  => $font_choices,
                    )
                )
            );

            $wp_customize->add_setting(
                'dnxte_dp_font_size_dp',
                array(
                    'default'           => '14',
                    'type'              => 'option',
                    'capability'        => 'edit_theme_options',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'absint',
                )
            );
            $wp_customize->add_control(
                new ET_Divi_Range_Option(
                    $wp_customize,
                    'dnxte_dp_font_size_dp',
                    array(
                        'label'       => esc_html__( 'Font Size', 'dnxte-divi-essential' ),
                        'section'     => 'dnxte_dropdown_section_settings',
                        'type'        => 'range',
                        'input_attrs' => array(
                            'min'  => 10,
                            'max'  => 32,
                            'step' => 1,
                        ),
                    )
                )
            );
            $wp_customize->add_setting(
                'dnxte_dp_font_weight_dp',
                array(
                    'default'           => '500',
                    'type'              => 'option',
                    'capability'        => 'edit_theme_options',
                    'transport'         => 'refresh',
                    'sanitize_callback' => 'et_sanitize_global_font_weight',
                )
            );

            $wp_customize->add_control(
                new ET_Divi_Custom_Select_Option(
                    $wp_customize,
                    'dnxte_dp_font_weight_dp',
                    array(
                        'label'    => esc_html__( 'Header Font Weight', 'dnxte-divi-essential' ),
                        'section'  => 'dnxte_dropdown_section_settings',
                        'settings' => 'dnxte_dp_font_weight_dp',
                        'type'     => 'select',
                        'choices'  => et_builder_get_font_weight_list(),
                    )
                )
            );
            $wp_customize->add_setting(
                'dnxte_dp_letter_spacing_dp',
                array(
                    'default'           => '0',
                    'type'              => 'option',
                    'capability'        => 'edit_theme_options',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'et_sanitize_int_number',
                )
            );

            $wp_customize->add_control(
                new ET_Divi_Range_Option(
                    $wp_customize,
                    'dnxte_dp_letter_spacing_dp',
                    array(
                        'label'       => esc_html__( 'Letter Spacing', 'dnxte-divi-essential' ),
                        'section'     => 'dnxte_dropdown_section_settings',
                        'type'        => 'range',
                        'input_attrs' => array(
                            'min'  => -1,
                            'max'  => 8,
                            'step' => 1,
                        ),
                    )
                )
            );

            $wp_customize->add_setting(
                'dnxte_dp_font_style_transform_dp',
                array(
                    'default'           => '',
                    'type'              => 'option',
                    'capability'        => 'edit_theme_options',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'et_sanitize_font_style',
                )
            );

            $wp_customize->add_control(
                new ET_Divi_Font_Style_Option(
                    $wp_customize,
                    'dnxte_dp_font_style_transform_dp',
                    array(
                        'label'   => esc_html__( 'Font Style', 'dnxte-divi-essential' ),
                        'section' => 'dnxte_dropdown_section_settings',
                        'type'    => 'font_style',
                        'choices' => et_divi_font_style_choices(),
                    )
                )
            );

            $wp_customize->add_setting(
                'dnxte_dp_text_color_dp',
                array(
                    'default'           => '',
                    'type'              => 'option',
                    'capability'        => 'edit_theme_options',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'et_sanitize_alpha_color',
                )
            );

            $wp_customize->add_control(
                new ET_Divi_Customize_Color_Alpha_Control(
                    $wp_customize,
                    'dnxte_dp_text_color_dp',
                    array(
                        'label'    => esc_html__( 'Submenu Link Color', 'dnxte-divi-essential' ),
                        'section'  => 'dnxte_dropdown_section_settings',
                        'settings' => 'dnxte_dp_text_color_dp',
                    )
                )
            );
            $wp_customize->add_setting(
                'dnxte_dp_text_color_hover_dp',
                array(
                    'default'           => '',
                    'type'              => 'option',
                    'capability'        => 'edit_theme_options',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'et_sanitize_alpha_color',
                )
            );

            $wp_customize->add_control(
                new ET_Divi_Customize_Color_Alpha_Control(
                    $wp_customize,
                    'dnxte_dp_text_color_hover_dp',
                    array(
                        'label'    => esc_html__( 'Submenu Link Hover Color', 'dnxte-divi-essential' ),
                        'section'  => 'dnxte_dropdown_section_settings',
                        'settings' => 'dnxte_dp_text_color_hover_dp',
                    )
                )
            );

            $wp_customize->add_setting(
                'dnxte_button_hover_effect_select_dp',
                array(
                    'default'           => 'none',
                    'type'              => 'theme_mod',
                    'capability'        => 'edit_theme_options',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'sanitize_text_field',
                )
            );

            $wp_customize->add_control(
                'dnxte_button_hover_effect_select_dp',
                array(
                    'label'    => esc_html__( 'Hover Effect', 'dnxte-divi-essential' ),
                    'section'  => 'dnxte_dropdown_section_settings',
                    'settings' => 'dnxte_button_hover_effect_select_dp',
                    'type'     => 'select',
                    'choices'  => [
                        'none'       => esc_html__( 'None', 'dnxte-divi-essential' ),
                        'pulse'      => esc_html__( 'Pulse', 'dnxte-divi-essential' ),
                        'pulse-grow' => esc_html__( 'Pulse Grow', 'dnxte-divi-essential' ),
                    ],
                )
            );

            $wp_customize->add_setting( 'dnxte_dropdown_arrow_icon', [
                'default'           => '5',
                'type'              => 'option',
                'capability'        => 'edit_theme_options',
                'transport'         => 'postMessage',
                'sanitize_callback' => 'et_sanitize_font_icon',
            ] );

            $wp_customize->add_control(
                new ET_Divi_Icon_Picker_Option(
                    $wp_customize,
                    'dnxte_dropdown_arrow_icon',
                    array(
                        'label'   => esc_html__( 'Select Icon', 'dnxte-divi-essential' ),
                        'section' => 'dnxte_dropdown_section_settings',
                        'type'    => 'icon_picker',
                    )
                )
            );

            $wp_customize->add_setting( 'dnxte_dropdown_shdaow_switch', [
                'default'           => 0,
                'type'              => 'option',
                'sanitize_callback' => 'absint',
                "transport"         => "postMessage",
            ] );

            $wp_customize->add_control( new WP_Customize_Toggle_Switch_Control( $wp_customize, 'dnxte_dropdown_shdaow_switch', [

                'label'    => __( 'DISPLAY DROPDOWN BOX SHADOW', 'dnxte-divi-essential' ),
                'section'  => 'dnxte_dropdown_section_settings',
                'settings' => 'dnxte_dropdown_shdaow_switch',
            ] ) );

            $wp_customize->add_setting( "dnxte_hover_shadow_color_dp", [
                "default"           => "#7b61ff",
                "type"              => "option",
                "sanitize_callback" => "sanitize_hex_color",
            ] );
            $wp_customize->add_control(
                new WP_Customize_Color_Control(
                    $wp_customize,
                    "dnxte_hover_shadow_color_dp",
                    [

                        "label"   => __(
                            "Hover Background Shadow Color",
                            "dnxte-divi-essential"
                        ),
                        "section" => "dnxte_dropdown_section_settings",
                    ]
                )
            );

            foreach ( $shadow_settings as $key => $config ) {
                $setting_id = "dnxte_{$key}";

                $wp_customize->add_setting( $setting_id, [
                    'default'           => $config['default'],
                    'type'              => 'option',
                    'capability'        => 'edit_theme_options',
                    'transport'         => 'postMessage',
                    'sanitize_callback' => 'absint',
                ] );

                $wp_customize->add_control( new ET_Divi_Range_Option( $wp_customize, $setting_id, [

                    'label'       => esc_html__( $config['label'], 'dnxte-divi-essential' ),
                    'section'     => 'dnxte_dropdown_section_settings',
                    'type'        => 'range',
                    'input_attrs' => [
                        'min'  => $config['min'],
                        'max'  => $config['max'],
                        'step' => 1,
                    ],
                ] ) );
            }
        } else {
            $wp_customize->add_setting(
                'dnxte_blank_dropdown_section_label',
                array(
                    'default'    => 'none',
                    'type'       => 'option',
                    'capability' => 'edit_theme_options',
                )
            );
            $wp_customize->add_control(
                new WP_Customize_Control(
                    $wp_customize,
                    'dnxte_blank_dropdown_section_label',
                    array(
                        'label'       => esc_html__( 'Custom Dropdown', 'dnxte-divi-essential' ),
                        'description' => '<img src="' . esc_url( DIVI_ESSENTIAL_EXTENSIONS_PATH . 'icon-image/customizer-blank.png' ) . '"><p>To customize Menu CTA Button enable Header & Navigation customization in Divi Essential plugin dashboard.</p><a href="admin.php?page=dnxte-header-navigation" target="_blank" class="button button-primary">Divi Essential Dashboard</a>',
                        'section'     => 'dnxte_dropdown_section_settings',
                        'settings'    => 'dnxte_blank_dropdown_section_label',
                        'type'        => 'hidden',
                    )
                )
            );
        }

        // === LIVE PREVIEW: Inject CSS ===
        if ( $wp_customize->is_preview() && !is_admin() ) {
            add_action( 'wp_head', [$this, 'render_style'], 10 );
        }
    }

    /**
     * Google fonts URL for header navigation fonts.
     *
     * @return void
     */
    public function get_header_navigation_fonts() {
        $fonts_url = '';

        // need to add all font selection keys here ===================
        $registered_font_keys = [
            [
                'font-family' => 'dnxte_cta_font_select',
                'font-weight' => 'dnxte_cta_font_weight',
            ],
            [
                'font-family' => 'dnxte_dp_font_select_dp',
                'font-weight' => 'dnxte_dp_font_weight_dp',
            ],
        ];

        $font_families = array();

        foreach ( $registered_font_keys as $key ) {
            $customizer_font_key = !empty( get_option( $key['font-family'] ) ) ? get_option( $key['font-family'] ) : '';
            $customizer_font_weight = !empty( get_option( $key['font-weight'] ) ) ? get_option( $key['font-weight'] ) : '400';
            $font_weight = $customizer_font_weight != '400' ? ',' . $customizer_font_weight : '';
            if ( $customizer_font_key !== 'none' ) {
                $font_name = str_replace( ' ', '+', $customizer_font_key );
                $font_families[] = $font_name . ':400' . $font_weight;
            }
        }
        if ( !empty( $font_families ) ) {
            $query_args = array(
                'family' => implode( '|', $font_families ),
                'subset' => urlencode( 'latin,latin-ext' ),
            );
            $fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );
        }
        return esc_url_raw( $fonts_url );
    }

    /**
     * Registed customizer key list for label color change.
     *
     * @return void
     */
    public function dnxte_customizer_key_as_selector_li() {
        global $wp_customize;
        $option_id_selector = '';
        foreach ( $wp_customize->settings() as $id => $setting ) {
            if ( str_starts_with( $id, 'dnxte' ) ) {
                $option_id_selector .= '#customize-control-' . $id . ',';
            }
        }
        return $option_id_selector;
    }

    public function dnxte_customizer_key_as_selector() {
        global $wp_customize;
        $option_id_selector = '';
        foreach ( $wp_customize->settings() as $id => $setting ) {
            if ( str_starts_with( $id, 'dnxte' ) ) {
                $option_id_selector .= '#customize-control-' . $id . ' .customize-control-title, ';
            }
        }
        return $option_id_selector;
    }
}
