<?php
/**
 * Prime Cyber Security Theme Customizer.
 *
 * @link https://developer.wordpress.org/themes/basics/theme-functions/
 *
 * @package prime_cyber_security
 */

if( ! function_exists( 'prime_cyber_security_customize_register' ) ):  
/**
 * Add postMessage support for site title and description for the Theme Customizer.F
 *
 * @param WP_Customize_Manager $wp_customize Theme Customizer object.
 */
function prime_cyber_security_customize_register( $wp_customize ) {
    require get_parent_theme_file_path('/inc/controls/changeable-icon.php');
    

    if ( version_compare( get_bloginfo('version'),'4.9', '>=') ) {
        $wp_customize->get_section( 'static_front_page' )->title = __( 'Static Front Page', 'prime-cyber-security' );
    }
	
    /* Option list of all post */	
    $prime_cyber_security_options_posts = array();
    $prime_cyber_security_options_posts_obj = get_posts('posts_per_page=-1');
    $prime_cyber_security_options_posts[''] = esc_html__( 'Choose Post', 'prime-cyber-security' );
    foreach ( $prime_cyber_security_options_posts_obj as $prime_cyber_security_posts ) {
    	$prime_cyber_security_options_posts[$prime_cyber_security_posts->ID] = $prime_cyber_security_posts->post_title;
    }
    
    /* Option list of all categories */
    $prime_cyber_security_args = array(
	   'type'                     => 'post',
	   'orderby'                  => 'name',
	   'order'                    => 'ASC',
	   'hide_empty'               => 1,
	   'hierarchical'             => 1,
	   'taxonomy'                 => 'category'
    ); 
    $prime_cyber_security_option_categories = array();
    $prime_cyber_security_category_lists = get_categories( $prime_cyber_security_args );
    $prime_cyber_security_option_categories[''] = esc_html__( 'Choose Category', 'prime-cyber-security' );
    foreach( $prime_cyber_security_category_lists as $prime_cyber_security_category ){
        $prime_cyber_security_option_categories[$prime_cyber_security_category->term_id] = $prime_cyber_security_category->name;
    }
    
    /** Default Settings */    
    $wp_customize->add_panel( 
        'wp_default_panel',
         array(
            'priority' => 10,
            'capability' => 'edit_theme_options',
            'theme_supports' => '',
            'title' => esc_html__( 'Default Settings', 'prime-cyber-security' ),
            'description' => esc_html__( 'Default section provided by wordpress customizer.', 'prime-cyber-security' ),
        ) 
    );
    
    $wp_customize->get_section( 'title_tagline' )->panel                  = 'wp_default_panel';
    $wp_customize->get_section( 'colors' )->panel                         = 'wp_default_panel';
    $wp_customize->get_section( 'header_image' )->panel                   = 'wp_default_panel';
    $wp_customize->get_section( 'background_image' )->panel               = 'wp_default_panel';
    $wp_customize->get_section( 'static_front_page' )->panel              = 'wp_default_panel';
    
    $wp_customize->get_setting( 'blogname' )->transport         = 'postMessage';
	$wp_customize->get_setting( 'blogdescription' )->transport  = 'postMessage';
	$wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';
    
    /** Default Settings Ends */
    
    /** Site Title control */
    $wp_customize->add_setting( 
        'header_site_title', 
        array(
            'default'           => true,
            'sanitize_callback' => 'prime_cyber_security_sanitize_checkbox',
        ) 
    );

    $wp_customize->add_control(
        'header_site_title',
        array(
            'label'       => __( 'Show / Hide Site Title', 'prime-cyber-security' ),
            'section'     => 'title_tagline',
            'type'        => 'checkbox',
        )
    );

    /** Tagline control */
    $wp_customize->add_setting( 
        'header_tagline', 
        array(
            'default'           => false,
            'sanitize_callback' => 'prime_cyber_security_sanitize_checkbox',
        ) 
    );

    $wp_customize->add_control(
        'header_tagline',
        array(
            'label'       => __( 'Show / Hide Tagline', 'prime-cyber-security' ),
            'section'     => 'title_tagline',
            'type'        => 'checkbox',
        )
    );

    $wp_customize->add_setting('logo_width', array(
        'sanitize_callback' => 'absint', 
    ));

    // Add a control for logo width
    $wp_customize->add_control('logo_width', array(
        'label' => __('Logo Width', 'prime-cyber-security'),
        'section' => 'title_tagline',
        'type' => 'number',
        'input_attrs' => array(
            'min' => '50', 
            'max' => '500', 
            'step' => '5', 
    ),
        'default' => '100', 
    ));

    $wp_customize->add_setting( 'prime_cyber_security_site_title_size', array(
        'default'           => 30, // Default font size in pixels
        'sanitize_callback' => 'absint', // Sanitize the input as a positive integer
    ) );

    // Add control for site title size
    $wp_customize->add_control( 'prime_cyber_security_site_title_size', array(
        'type'        => 'number',
        'section'     => 'title_tagline', // You can change this section to your preferred section
        'label'       => __( 'Site Title Font Size (px)', 'prime-cyber-security' ),
        'input_attrs' => array(
            'min'  => 10,
            'max'  => 100,
            'step' => 1,
        ),
    ) );

    /** Home Page Settings */
    $wp_customize->add_panel( 
        'prime_cyber_security_post_settings',
         array(
            'priority' => 11,
            'capability' => 'edit_theme_options',
            'title' => esc_html__( 'Post & Pages Settings', 'prime-cyber-security' ),
            'description' => esc_html__( 'Customize Post & Pages Settings', 'prime-cyber-security' ),
        ) 
    );

    /** Post Layouts */

    /** Blog Content Alignment */
    $wp_customize->add_setting('prime_cyber_security_blog_layout_option', array(
        'default'           => 'Left',
        'sanitize_callback' => 'prime_cyber_security_sanitize_choices',
    ));

    $wp_customize->add_control('prime_cyber_security_blog_layout_option', array(
        'label'    => __('Post Content Alignment', 'prime-cyber-security'),
        'section'  => 'prime_cyber_security_post_layout_section',
        'settings' => 'prime_cyber_security_blog_layout_option',
        'type'     => 'select',
        'choices'  => array(
		   'Left'     => __('Left', 'prime-cyber-security'),
		   'Center'     => __('Center', 'prime-cyber-security'),
		   'Right'     => __('Right', 'prime-cyber-security'),
        ),
    ));
    
    $wp_customize->add_section(
        'prime_cyber_security_post_layout_section',
        array(
            'title' => esc_html__( 'Post Layout Settings', 'prime-cyber-security' ),
            'priority' => 20,
            'capability' => 'edit_theme_options',
            'panel' => 'prime_cyber_security_post_settings',
        )
    );

    $wp_customize->add_setting('prime_cyber_security_post_layout_setting', array(
        'default'           => 'right-sidebar',
        'sanitize_callback' => 'prime_cyber_security_sanitize_post_layout',
    ));

    $wp_customize->add_control('prime_cyber_security_post_layout_setting', array(
        'label'    => __('Post Column Settings', 'prime-cyber-security'),
        'section'  => 'prime_cyber_security_post_layout_section',
        'settings' => 'prime_cyber_security_post_layout_setting',
        'type'     => 'select',
        'choices'  => array(        
            'right-sidebar'   => __('Right Sidebar', 'prime-cyber-security'),
            'left-sidebar'   => __('Left Sidebar', 'prime-cyber-security'),
            'one-column'   => __('One Column', 'prime-cyber-security'),
            'three-column'   => __('Three Columns', 'prime-cyber-security'),
            'four-column'   => __('Four Columns', 'prime-cyber-security'),
            'grid-layout'   => __('Grid Layout', 'prime-cyber-security')
        ),
    ));

     /** Post Layouts Ends */
     
    /** Post Settings */
    $wp_customize->add_section(
        'prime_cyber_security_post_settings',
        array(
            'title' => esc_html__( 'Post Settings', 'prime-cyber-security' ),
            'priority' => 20,
            'capability' => 'edit_theme_options',
            'panel' => 'prime_cyber_security_post_settings',
        )
    );

    /** Post Heading control */
    $wp_customize->add_setting( 
        'prime_cyber_security_post_heading_setting', 
        array(
            'default'           => true,
            'sanitize_callback' => 'prime_cyber_security_sanitize_checkbox',
        ) 
    );

    $wp_customize->add_control(
        'prime_cyber_security_post_heading_setting',
        array(
            'label'       => __( 'Show / Hide Post Heading', 'prime-cyber-security' ),
            'section'     => 'prime_cyber_security_post_settings',
            'type'        => 'checkbox',
        )
    );

    /** Post Meta control */
    $wp_customize->add_setting( 
        'prime_cyber_security_post_meta_setting', 
        array(
            'default'           => true,
            'sanitize_callback' => 'prime_cyber_security_sanitize_checkbox',
        ) 
    );

    $wp_customize->add_control(
        'prime_cyber_security_post_meta_setting',
        array(
            'label'       => __( 'Show / Hide Post Meta', 'prime-cyber-security' ),
            'section'     => 'prime_cyber_security_post_settings',
            'type'        => 'checkbox',
        )
    );

    /** Post Image control */
    $wp_customize->add_setting( 
        'prime_cyber_security_post_image_setting', 
        array(
            'default'           => true,
            'sanitize_callback' => 'prime_cyber_security_sanitize_checkbox',
        ) 
    );

    $wp_customize->add_control(
        'prime_cyber_security_post_image_setting',
        array(
            'label'       => __( 'Show / Hide Post Image', 'prime-cyber-security' ),
            'section'     => 'prime_cyber_security_post_settings',
            'type'        => 'checkbox',
        )
    );

    /** Post Content control */
    $wp_customize->add_setting( 
        'prime_cyber_security_post_content_setting', 
        array(
            'default'           => true,
            'sanitize_callback' => 'prime_cyber_security_sanitize_checkbox',
        ) 
    );

    $wp_customize->add_control(
        'prime_cyber_security_post_content_setting',
        array(
            'label'       => __( 'Show / Hide Post Content', 'prime-cyber-security' ),
            'section'     => 'prime_cyber_security_post_settings',
            'type'        => 'checkbox',
        )
    );
    /** Post ReadMore control */
     $wp_customize->add_setting( 'prime_cyber_security_read_more_setting', array(
        'default'           => true,
        'sanitize_callback' => 'prime_cyber_security_sanitize_checkbox',
    ) );

    $wp_customize->add_control( 'prime_cyber_security_read_more_setting', array(
        'type'        => 'checkbox',
        'section'     => 'prime_cyber_security_post_settings', 
        'label'       => __( 'Display Read More Button', 'prime-cyber-security' ),
    ) );

    /** Post Settings Ends */

     /** Single Post Settings */
    $wp_customize->add_section(
        'prime_cyber_security_single_post_settings',
        array(
            'title' => esc_html__( 'Single Post Settings', 'prime-cyber-security' ),
            'priority' => 20,
            'capability' => 'edit_theme_options',
            'panel' => 'prime_cyber_security_post_settings',
        )
    );

    /** Single Post Meta control */
    $wp_customize->add_setting( 
        'prime_cyber_security_single_post_meta_setting', 
        array(
            'default'           => true,
            'sanitize_callback' => 'prime_cyber_security_sanitize_checkbox',
        ) 
    );

    $wp_customize->add_control(
        'prime_cyber_security_single_post_meta_setting',
        array(
            'label'       => __( 'Show / Hide Single Post Meta', 'prime-cyber-security' ),
            'section'     => 'prime_cyber_security_single_post_settings',
            'type'        => 'checkbox',
        )
    );

    /** Single Post Content control */
    $wp_customize->add_setting( 
        'prime_cyber_security_single_post_content_setting', 
        array(
            'default'           => true,
            'sanitize_callback' => 'prime_cyber_security_sanitize_checkbox',
        ) 
    );

    $wp_customize->add_control(
        'prime_cyber_security_single_post_content_setting',
        array(
            'label'       => __( 'Show / Hide Single Post Content', 'prime-cyber-security' ),
            'section'     => 'prime_cyber_security_single_post_settings',
            'type'        => 'checkbox',
        )
    );

    /** Single Post Settings Ends */

    //Global Color
    $wp_customize->add_section(
        'prime_cyber_security_global_color',
        array(
            'title' => esc_html__( 'Global Color Settings', 'prime-cyber-security' ),
            'priority' => 20,
            'capability' => 'edit_theme_options',
            'panel' => 'prime_cyber_security_general_settings',
        )
    );

    $wp_customize->add_setting('prime_cyber_security_primary_color', array(
        'default'           => '#D74012',
        'sanitize_callback' => 'sanitize_hex_color',
    ));
    $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'prime_cyber_security_primary_color', array(
        'label'    => __('Theme Primary Color', 'prime-cyber-security'),
        'section'  => 'prime_cyber_security_global_color',
        'settings' => 'prime_cyber_security_primary_color',
    )));    

         // Typography Settings Section
    $wp_customize->add_section('prime_cyber_security_typography_settings', array(
        'title'      => esc_html__('Typography Settings', 'prime-cyber-security'),
        'priority'   => 30,
        'capability' => 'edit_theme_options',
        'panel' => 'prime_cyber_security_general_settings',
    ));

    // Array of fonts to choose from
    $font_choices = array(
        ''               => __('Select', 'prime-cyber-security'),
        'Arial'          => 'Arial, sans-serif',
        'Verdana'        => 'Verdana, sans-serif',
        'Helvetica'      => 'Helvetica, sans-serif',
        'Times New Roman'=> '"Times New Roman", serif',
        'Georgia'        => 'Georgia, serif',
        'Courier New'    => '"Courier New", monospace',
        'Trebuchet MS'   => '"Trebuchet MS", sans-serif',
        'Tahoma'         => 'Tahoma, sans-serif',
        'Palatino'       => '"Palatino Linotype", serif',
        'Garamond'       => 'Garamond, serif',
        'Impact'         => 'Impact, sans-serif',
        'Comic Sans MS'  => '"Comic Sans MS", cursive, sans-serif',
        'Lucida Sans'    => '"Lucida Sans Unicode", sans-serif',
        'Arial Black'    => '"Arial Black", sans-serif',
        'Gill Sans'      => '"Gill Sans", sans-serif',
        'Segoe UI'       => '"Segoe UI", sans-serif',
        'Open Sans'      => '"Open Sans", sans-serif',
        'Roboto'         => 'Roboto, sans-serif',
        'Lato'           => 'Lato, sans-serif',
        'Montserrat'     => 'Montserrat, sans-serif',
        'Libre Baskerville' => 'Libre Baskerville',
    );

    // Heading Font Setting
    $wp_customize->add_setting('prime_cyber_security_heading_font_family', array(
        'default'           => '',
        'sanitize_callback' => 'prime_cyber_security_sanitize_choicess',
    ));
    $wp_customize->add_control('prime_cyber_security_heading_font_family', array(
        'type'    => 'select',
        'choices' => $font_choices,
        'label'   => __('Select Font for Heading', 'prime-cyber-security'),
        'section' => 'prime_cyber_security_typography_settings',
    ));

    // Body Font Setting
    $wp_customize->add_setting('prime_cyber_security_body_font_family', array(
        'default'           => '',
        'sanitize_callback' => 'prime_cyber_security_sanitize_choicess',
    ));
    $wp_customize->add_control('prime_cyber_security_body_font_family', array(
        'type'    => 'select',
        'choices' => $font_choices,
        'label'   => __('Select Font for Body', 'prime-cyber-security'),
        'section' => 'prime_cyber_security_typography_settings',
    ));

    /** Typography Settings Section End */

        /** Home Page Settings */
    $wp_customize->add_panel( 
        'prime_cyber_security_general_settings',
         array(
            'priority' => 9,
            'capability' => 'edit_theme_options',
            'title' => esc_html__( 'General Settings', 'prime-cyber-security' ),
            'description' => esc_html__( 'Customize General Settings', 'prime-cyber-security' ),
        ) 
    );

    /** General Settings */
    $wp_customize->add_section(
        'prime_cyber_security_general_settings',
        array(
            'title' => esc_html__( 'Loader Settings', 'prime-cyber-security' ),
            'priority' => 30,
            'capability' => 'edit_theme_options',
            'panel' => 'prime_cyber_security_general_settings',
        )
    );

    /** Preloader control */
    $wp_customize->add_setting( 
        'prime_cyber_security_header_preloader', 
        array(
            'default' => false,
            'sanitize_callback' => 'prime_cyber_security_sanitize_checkbox',
        ) 
    );

    $wp_customize->add_control(
        'prime_cyber_security_header_preloader',
        array(
            'label'       => __( 'Show Preloader', 'prime-cyber-security' ),
            'section'     => 'prime_cyber_security_general_settings',
            'type'        => 'checkbox',
        )
    );

    $wp_customize->add_setting('prime_cyber_security_loader_layout_setting', array(
        'default' => 'load',
        'sanitize_callback' => 'sanitize_text_field',
    ));

    // Add control for loader layout
    $wp_customize->add_control('prime_cyber_security_loader_layout_control', array(
        'label' => __('Preloader Layout', 'prime-cyber-security'),
        'section' => 'prime_cyber_security_general_settings',
        'settings' => 'prime_cyber_security_loader_layout_setting',
        'type' => 'select',
        'choices' => array(
            'load' => __('Preloader 1', 'prime-cyber-security'),
            'load-one' => __('Preloader 2', 'prime-cyber-security'),
            'ctn-preloader' => __('Preloader 3', 'prime-cyber-security'),
        ),
    ));

    /** Header Section Settings */
    $wp_customize->add_section(
        'prime_cyber_security_header_section_settings',
        array(
            'title' => esc_html__( 'Header Section Settings', 'prime-cyber-security' ),
            'priority' => 30,
            'capability' => 'edit_theme_options',
            'panel' => 'prime_cyber_security_home_page_settings',
        )
    );

        /** Appointment Button */
    $wp_customize->add_setting(
        'prime_cyber_security_header_login_link',
        array( 
            'default' => '',
            'sanitize_callback' => 'esc_url_raw',
            'transport'         => 'refresh'
        )
    );
    
    $wp_customize->add_control(
        'prime_cyber_security_header_login_link',
        array(
            'label' => esc_html__( 'Log In URL', 'prime-cyber-security' ),
            'section' => 'prime_cyber_security_header_section_settings',
            'type' => 'url',
        )
    );

        /** Appointment Button */
    $wp_customize->add_setting(
        'prime_cyber_security_header_signin_link',
        array( 
            'default' => '',
            'sanitize_callback' => 'esc_url_raw',
            'transport'         => 'refresh'
        )
    );
    
    $wp_customize->add_control(
        'prime_cyber_security_header_signin_link',
        array(
            'label' => esc_html__( 'Sign Up URL', 'prime-cyber-security' ),
            'section' => 'prime_cyber_security_header_section_settings',
            'type' => 'url',
        )
    );

    /** Sticky Header control */
    $wp_customize->add_setting( 
        'prime_cyber_security_sticky_header', 
        array(
            'default' => false,
            'sanitize_callback' => 'prime_cyber_security_sanitize_checkbox',
        ) 
    );

    $wp_customize->add_control(
        'prime_cyber_security_sticky_header',
        array(
            'label'       => __( 'Show Sticky Header', 'prime-cyber-security' ),
            'section'     => 'prime_cyber_security_header_section_settings',
            'type'        => 'checkbox',
        )
    );

    // Add Setting for Menu Font Weight
    $wp_customize->add_setting( 'prime_cyber_security_menu_font_weight', array(
        'default'           => 'Bold',
        'sanitize_callback' => 'prime_cyber_security_sanitize_font_weight',
    ) );

    // Add Control for Menu Font Weight
    $wp_customize->add_control( 'prime_cyber_security_menu_font_weight', array(
        'label'    => __( 'Menu Font Weight', 'prime-cyber-security' ),
        'section'  => 'prime_cyber_security_header_section_settings',
        'type'     => 'select',
        'choices'  => array(
            '100' => __( '100 - Thin', 'prime-cyber-security' ),
            '200' => __( '200 - Extra Light', 'prime-cyber-security' ),
            '300' => __( '300 - Light', 'prime-cyber-security' ),
            '400' => __( '400 - Normal', 'prime-cyber-security' ),
            '500' => __( '500 - Medium', 'prime-cyber-security' ),
            '600' => __( '600 - Semi Bold', 'prime-cyber-security' ),
            '700' => __( '700 - Bold', 'prime-cyber-security' ),
            '800' => __( '800 - Extra Bold', 'prime-cyber-security' ),
            '900' => __( '900 - Black', 'prime-cyber-security' ),
        ),
    ) );

    // Add Setting for Menu Text Transform
    $wp_customize->add_setting( 'prime_cyber_security_menu_text_transform', array(
        'default'           => 'Capitalize',
        'sanitize_callback' => 'prime_cyber_security_sanitize_text_transform',
    ) );

    // Add Control for Menu Text Transform
    $wp_customize->add_control( 'prime_cyber_security_menu_text_transform', array(
        'label'    => __( 'Menu Text Transform', 'prime-cyber-security' ),
        'section'  => 'prime_cyber_security_header_section_settings',
        'type'     => 'select',
        'choices'  => array(
            'none'       => __( 'None', 'prime-cyber-security' ),
            'capitalize' => __( 'Capitalize', 'prime-cyber-security' ),
            'uppercase'  => __( 'Uppercase', 'prime-cyber-security' ),
            'lowercase'  => __( 'Lowercase', 'prime-cyber-security' ),
        ),
    ) );

    $wp_customize->add_setting('prime_cyber_security_menus_style',array(
        'default' => '',
        'sanitize_callback' => 'prime_cyber_security_sanitize_choices'
	));
	$wp_customize->add_control('prime_cyber_security_menus_style',array(
        'type' => 'select',
		'label' => __('Menu Hover Style','prime-cyber-security'),
		'section' => 'prime_cyber_security_header_section_settings',
		'choices' => array(
         'None' => __('None','prime-cyber-security'),
         'Zoom In' => __('Zoom In','prime-cyber-security'),
      ),
	));

    /** Home Page Settings */
    $wp_customize->add_panel( 
        'prime_cyber_security_home_page_settings',
         array(
            'priority' => 9,
            'capability' => 'edit_theme_options',
            'title' => esc_html__( 'Home Page Settings', 'prime-cyber-security' ),
            'description' => esc_html__( 'Customize Home Page Settings', 'prime-cyber-security' ),
        ) 
    );

 /** Slider Section Settings */
    $wp_customize->add_section(
        'prime_cyber_security_slider_section_settings',
        array(
            'title' => esc_html__( 'Slider Section Settings', 'prime-cyber-security' ),
            'priority' => 30,
            'capability' => 'edit_theme_options',
            'panel' => 'prime_cyber_security_home_page_settings',
        )
    );

    /** Slider Section control */
    $wp_customize->add_setting( 
        'prime_cyber_security_slider_setting', 
        array(
            'default' => false,
            'sanitize_callback' => 'prime_cyber_security_sanitize_checkbox',
        ) 
    );

    $wp_customize->add_control(
        'prime_cyber_security_slider_setting',
        array(
            'label'       => __( 'Show Slider', 'prime-cyber-security' ),
            'section'     => 'prime_cyber_security_slider_section_settings',
            'type'        => 'checkbox',
        )
    );

    $wp_customize->add_setting('prime_cyber_security_slider_background_image',
        array(
            'sanitize_callback' => 'esc_url_raw',
        )
    );
    $wp_customize->add_control(
        new WP_Customize_Image_Control( $wp_customize,'prime_cyber_security_slider_background_image',
            array(
                'label' => __('Slider Background Image','prime-cyber-security'),
                'section' => 'prime_cyber_security_slider_section_settings',
                'settings' => 'prime_cyber_security_slider_background_image',
            )
        )
    );


    /** Slider Section control */
    $wp_customize->add_setting( 
        'prime_cyber_security_search_box_enable', 
        array(
            'default' => false,
            'sanitize_callback' => 'prime_cyber_security_sanitize_checkbox',
        ) 
    );

    $wp_customize->add_control(
        'prime_cyber_security_search_box_enable',
        array(
            'label'       => __( 'Slider Search Enable Disable', 'prime-cyber-security' ),
            'section'     => 'prime_cyber_security_slider_section_settings',
            'type'        => 'checkbox',
        )
    );

    // Add setting for the counter
    $wp_customize->add_setting( 'prime_cyber_security_slider_counter', array(
        'default'           => 1,
        'sanitize_callback' => 'prime_cyber_security_sanitize_counter',
    ));

    // Add control for the counter
    $wp_customize->add_control( 'prime_cyber_security_slider_counter', array(
        'label'   => __( 'Slider Image Count', 'prime-cyber-security' ),
        'section' => 'prime_cyber_security_slider_section_settings',
        'type'    => 'number',
        'input_attrs' => array(
            'min'  => 1,
            'max'  => 6,
            'step' => 1,
        ),
    ));

    $prime_cyber_security_slider_image = get_theme_mod('prime_cyber_security_slider_counter','');
        for ( $prime_cyber_security_i = 1; $prime_cyber_security_i <= $prime_cyber_security_slider_image; $prime_cyber_security_i++ ) :


    $wp_customize->add_setting('prime_cyber_security_slider_image' .$prime_cyber_security_i,
        array(
            'sanitize_callback' => 'esc_url_raw',
        )
    );
    $wp_customize->add_control(
        new WP_Customize_Image_Control( $wp_customize,'prime_cyber_security_slider_image' .$prime_cyber_security_i,
            array(
                'label' => __('Slider Image ','prime-cyber-security') .$prime_cyber_security_i,
                'section' => 'prime_cyber_security_slider_section_settings',
                'settings' => 'prime_cyber_security_slider_image' .$prime_cyber_security_i,
            )
        )
    );

    // Section Title
    $wp_customize->add_setting(
        'prime_cyber_security_slider_sub_heading' .$prime_cyber_security_i, 
        array(
            'default'           => '',
            'type'              => 'theme_mod',
            'capability'        => 'edit_theme_options',    
            'sanitize_callback' => 'sanitize_text_field'
        )
    );

    $wp_customize->add_control(
        'prime_cyber_security_slider_sub_heading' .$prime_cyber_security_i, 
        array(
            'label'       => __('Sub Heading ', 'prime-cyber-security') .$prime_cyber_security_i,
            'section'     => 'prime_cyber_security_slider_section_settings',
            'settings'    => 'prime_cyber_security_slider_sub_heading' .$prime_cyber_security_i,
            'type'        => 'text'
        )
    );


    // Section Title
    $wp_customize->add_setting(
        'prime_cyber_security_slider_main_heading' .$prime_cyber_security_i, 
        array(
            'default'           => '',
            'type'              => 'theme_mod',
            'capability'        => 'edit_theme_options',    
            'sanitize_callback' => 'sanitize_text_field'
        )
    );

    $wp_customize->add_control(
        'prime_cyber_security_slider_main_heading' .$prime_cyber_security_i, 
        array(
            'label'       => __('Main Heading ', 'prime-cyber-security') .$prime_cyber_security_i,
            'section'     => 'prime_cyber_security_slider_section_settings',
            'settings'    => 'prime_cyber_security_slider_main_heading' .$prime_cyber_security_i,
            'type'        => 'text'
        )
    );

    // Add setting for the counter
    $wp_customize->add_setting( 'prime_cyber_security_slider_populer_search', array(
        'default'           => 1,
        'sanitize_callback' => 'prime_cyber_security_sanitize_counter',
    ));

    // Add control for the counter
    $wp_customize->add_control( 'prime_cyber_security_slider_populer_search', array(
        'label'   => __( 'Popular Search Counter', 'prime-cyber-security' ),
        'section' => 'prime_cyber_security_slider_section_settings',
        'type'    => 'number',
        'input_attrs' => array(
            'min'  => 1,
            'max'  => 6,
            'step' => 1,
        ),
    ));

    // Get the counter with a fallback value (important fix)
    $prime_cyber_security_slider_populer_search_count = absint( get_theme_mod( 'prime_cyber_security_slider_populer_search', 1 ) );

    for ( $prime_cyber_security_m = 1; $prime_cyber_security_m <= $prime_cyber_security_slider_populer_search_count; $prime_cyber_security_m++ ) :

        $setting_id = 'prime_cyber_security_slider_populer_search_text' . $prime_cyber_security_m;

        // Popular Search Setting
        $wp_customize->add_setting( $setting_id, array(
            'default'           => '',
            'type'              => 'theme_mod',
            'capability'        => 'edit_theme_options',
            'sanitize_callback' => 'sanitize_text_field',
        ));

        // Popular Search Control
        $wp_customize->add_control( $setting_id, array(
            'label'    => __( 'Popular Search ', 'prime-cyber-security' ) . $prime_cyber_security_m,
            'section'  => 'prime_cyber_security_slider_section_settings',
            'settings' => $setting_id,
            'type'     => 'text',
        ));

    endfor;

    endfor;


     /** Slider Section Settings */
    $wp_customize->add_section(
        'prime_cyber_security_brand_section_settings',
        array(
            'title' => esc_html__( 'Brand Section Settings', 'prime-cyber-security' ),
            'priority' => 30,
            'capability' => 'edit_theme_options',
            'panel' => 'prime_cyber_security_home_page_settings',
        )
    );

        // Add setting for the counter
    $wp_customize->add_setting( 'prime_cyber_security_brand_count', array(
        'default'           => 1,
        'sanitize_callback' => 'prime_cyber_security_sanitize_counter',
    ));

    // Add control for the counter
    $wp_customize->add_control( 'prime_cyber_security_brand_count', array(
        'label'   => __( 'Brand Image Counter', 'prime-cyber-security' ),
        'section' => 'prime_cyber_security_brand_section_settings',
        'type'    => 'number',
        'input_attrs' => array(
            'min'  => 1,
            'max'  => 3,
            'step' => 1,
        ),
    ));

    $prime_cyber_security_slider_populer_brand_count = get_theme_mod('prime_cyber_security_brand_count','');
        for ( $prime_cyber_security_n = 1; $prime_cyber_security_n <= $prime_cyber_security_slider_populer_brand_count; $prime_cyber_security_n++ ) :

        $wp_customize->add_setting('prime_cyber_security_brand_image' .$prime_cyber_security_n,
            array(
                'sanitize_callback' => 'esc_url_raw',
            )
        );
        $wp_customize->add_control(
            new WP_Customize_Image_Control( $wp_customize,'prime_cyber_security_brand_image' .$prime_cyber_security_n,
                array(
                    'label' => __('Brand Image ','prime-cyber-security') .$prime_cyber_security_n,
                    'section' => 'prime_cyber_security_brand_section_settings',
                    'settings' => 'prime_cyber_security_brand_image' .$prime_cyber_security_n,
                )
            )
        );


        endfor;

    /** Classes Section Settings */
    $wp_customize->add_section(
        'prime_cyber_security_classes_section_settings',
        array(
            'title' => esc_html__( 'Features Section Settings', 'prime-cyber-security' ),
            'priority' => 30,
            'capability' => 'edit_theme_options',
            'panel' => 'prime_cyber_security_home_page_settings',
        )
    );

    /** Classes Section control */
    $wp_customize->add_setting( 
        'prime_cyber_security_classes_setting', 
        array(
            'default' => false,
            'sanitize_callback' => 'prime_cyber_security_sanitize_checkbox',
        ) 
    );

    $wp_customize->add_control(
        'prime_cyber_security_classes_setting',
        array(
            'label'       => __( 'Show Features Section', 'prime-cyber-security' ),
            'section'     => 'prime_cyber_security_classes_section_settings',
            'type'        => 'checkbox',
        )
    );

    // Section Title
    $wp_customize->add_setting(
        'prime_cyber_security_service_title', 
        array(
            'default'           => '',
            'type'              => 'theme_mod',
            'capability'        => 'edit_theme_options',    
            'sanitize_callback' => 'sanitize_text_field'
        )
    );

    $wp_customize->add_control(
        'prime_cyber_security_service_title', 
        array(
            'label'       => __('Section Title', 'prime-cyber-security'),
            'section'     => 'prime_cyber_security_classes_section_settings',
            'settings'    => 'prime_cyber_security_service_title',
            'type'        => 'text'
        )
    );

     // Section Text
    $wp_customize->add_setting(
        'prime_cyber_security_service_text', 
        array(
            'default'           => '',
            'type'              => 'theme_mod',
            'capability'        => 'edit_theme_options',    
            'sanitize_callback' => 'sanitize_text_field'
        )
    );

    $wp_customize->add_control(
        'prime_cyber_security_service_text', 
        array(
            'label'       => __('Section Text', 'prime-cyber-security'),
            'section'     => 'prime_cyber_security_classes_section_settings',
            'settings'    => 'prime_cyber_security_service_text',
            'type'        => 'text'
        )
    );

    // Post Categories
    $categories = get_categories();
    $cat_posts = array();
    $default = '';
    $cat_posts[] = 'Select';
    foreach ($categories as $category) {
        $cat_posts[$category->slug] = $category->name;
    }

    $wp_customize->add_setting(
        'prime_cyber_security_blog_args_',
        array(
            'default'            => 'select',
            'sanitize_callback'  => 'prime_cyber_security_sanitize_choices',
        )
    );
    $wp_customize->add_control(
        'prime_cyber_security_blog_args_',
        array(
            'type'     => 'select',
            'choices'  => $cat_posts,
            'label'    => __('Select Category to Display Services', 'prime-cyber-security'),
            'section'  => 'prime_cyber_security_classes_section_settings',
        )
    );


    for ($i=1; $i <= 10; $i++) {

    $wp_customize->add_setting('prime_cyber_security_category_icon'.$i,array(
        'default'   => '',
        'sanitize_callback' => 'sanitize_text_field'
    ));
    $wp_customize->add_control(new Prime_Cyber_Security_Changeable_Icon(
        $wp_customize,'prime_cyber_security_category_icon'.$i,array(
        'label' => __('Feature Icon ','prime-cyber-security').$i,
        'transport' => 'refresh',
        'section'   => 'prime_cyber_security_classes_section_settings',
        'type'      => 'icon'
    )));
}
    
    
    /** Home Page Settings Ends */
    
    /** Footer Section */
    $wp_customize->add_section(
        'prime_cyber_security_footer_section',
        array(
            'title' => __( 'Footer Settings', 'prime-cyber-security' ),
            'priority' => 70,
            'panel' => 'prime_cyber_security_home_page_settings',
        )
    );

    /** Footer Widget Columns */
    $wp_customize->add_setting('prime_cyber_security_footer_widget_areas', array(
        'default'           => 4,
        'sanitize_callback' => 'prime_cyber_security_sanitize_choices',
    ));

    $wp_customize->add_control('prime_cyber_security_footer_widget_areas', array(
        'label'    => __('Footer Widget Columns', 'prime-cyber-security'),
        'section'  => 'prime_cyber_security_footer_section',
        'settings' => 'prime_cyber_security_footer_widget_areas',
        'type'     => 'select',
        'choices'  => array(
		   '1'     => __('One', 'prime-cyber-security'),
		   '2'     => __('Two', 'prime-cyber-security'),
		   '3'     => __('Three', 'prime-cyber-security'),
		   '4'     => __('Four', 'prime-cyber-security')
        ),
    ));

    /** Footer Copyright control */
    $wp_customize->add_setting( 
        'prime_cyber_security_footer_setting', 
        array(
            'default' => true,
            'sanitize_callback' => 'prime_cyber_security_sanitize_checkbox',
        ) 
    );

    $wp_customize->add_control(
        'prime_cyber_security_footer_setting',
        array(
            'label'       => __( 'Show Footer Copyright', 'prime-cyber-security' ),
            'section'     => 'prime_cyber_security_footer_section',
            'type'        => 'checkbox',
        )
    );
    
    /** Copyright Text */
    $wp_customize->add_setting(
        'prime_cyber_security_footer_copyright_text',
        array(
            'default' => '',
            'sanitize_callback' => 'sanitize_text_field',
        )
    );
    
    $wp_customize->add_control(
        'prime_cyber_security_footer_copyright_text',
        array(
            'label' => __( 'Copyright Info', 'prime-cyber-security' ),
            'section' => 'prime_cyber_security_footer_section',
            'type' => 'text',
        )
    );  
$wp_customize->add_setting('prime_cyber_security_footer_background_image',
        array(
        'default' => '',
        'capability' => 'edit_theme_options',
        'sanitize_callback' => 'absint',
        )
    );


    $wp_customize->add_control(
         new WP_Customize_Cropped_Image_Control($wp_customize, 'prime_cyber_security_footer_background_image',
            array(
                'label' => esc_html__('Footer Background Image', 'prime-cyber-security'),
                /* translators: 1: image width in pixels, 2: image height in pixels */
                'description' => sprintf(esc_html__('Recommended Size %1$s px X %2$s px', 'prime-cyber-security'), 1024, 800),
                'section' => 'prime_cyber_security_footer_section',
                'width' => 1024,
                'height' => 800,
                'flex_width' => true,
                'flex_height' => true,
            )
        )
    );

    /** Footer Background Image Attachment */
    $wp_customize->add_setting('prime_cyber_security_background_attatchment', array(
        'default'           => 'scroll',
        'sanitize_callback' => 'prime_cyber_security_sanitize_choices',
    ));

    $wp_customize->add_control('prime_cyber_security_background_attatchment', array(
        'label'    => __('Footer Background Attachment', 'prime-cyber-security'),
        'section'  => 'prime_cyber_security_footer_section',
        'settings' => 'prime_cyber_security_background_attatchment',
        'type'     => 'select',
        'choices'  => array(
            'fixed' => __('fixed','prime-cyber-security'),
            'scroll' => __('scroll','prime-cyber-security'),
        ),
    ));

    /* Footer Background Color*/
    $wp_customize->add_setting(
        'prime_cyber_security_footer_background_color',
        array(
            'default' => '',
            'sanitize_callback' => 'sanitize_hex_color',
        )
    );
    $wp_customize->add_control(
        new WP_Customize_Color_Control(
            $wp_customize,
            'prime_cyber_security_footer_background_color',
            array(
                'label' => __('Footer Widget Area Background Color', 'prime-cyber-security'),
                'section' => 'prime_cyber_security_footer_section',
                'type' => 'color',
            )
        )
    );

     $wp_customize->add_setting('prime_cyber_security_scroll_icon',array(
        'default'   => 'fas fa-arrow-up',
        'sanitize_callback' => 'sanitize_text_field'
    ));
    $wp_customize->add_control(new Prime_Cyber_Security_Changeable_Icon(
        $wp_customize,'prime_cyber_security_scroll_icon',array(
        'label' => __('Scroll Top Icon','prime-cyber-security'),
        'transport' => 'refresh',
        'section'   => 'prime_cyber_security_footer_section',
        'type'      => 'icon'
    )));

    /** Scroll to top button shape */
    $wp_customize->add_setting('prime_cyber_security_scroll_to_top_radius', array(
        'default'           => 'curved-box',
        'sanitize_callback' => 'prime_cyber_security_sanitize_choices',
    ));

    $wp_customize->add_control('prime_cyber_security_scroll_to_top_radius', array(
        'label'    => __('Scroll Top Button Shape', 'prime-cyber-security'),
        'section'  => 'prime_cyber_security_footer_section',
        'settings' => 'prime_cyber_security_scroll_to_top_radius',
        'type'     => 'select',
        'choices'  => array(
            'box'        => __( 'Box', 'prime-cyber-security' ),
            'curved-box' => __( 'Curved Box', 'prime-cyber-security' ),
            'circle'     => __( 'Circle', 'prime-cyber-security' ),
        ),
    ));


    /** Footer Social Icon */
    $wp_customize->add_section('prime_cyber_security_footer_social_section', array(
        'title' => __( 'Footer Social Settings', 'prime-cyber-security' ),
        'panel' => 'prime_cyber_security_home_page_settings',
    ));

    $wp_customize->add_setting('prime_cyber_security_enable_footer_icon_section', array(
        'default' => true,
        'sanitize_callback' => 'prime_cyber_security_sanitize_checkbox',
    ) );
    $wp_customize->add_control( 'prime_cyber_security_enable_footer_icon_section', array(
        'label'       => __( 'Show Footer Icon', 'prime-cyber-security' ),
        'section'     => 'prime_cyber_security_footer_social_section',
        'type'        => 'checkbox',
    ));

    // Add setting for Facebook Link
    $wp_customize->add_setting(
        'prime_cyber_security_footer_facebook_link',
        array(
            'default'           => 'https://www.facebook.com/',
            'sanitize_callback' => 'esc_url_raw',
        )
    );

    $wp_customize->add_control(
        'prime_cyber_security_footer_facebook_link',
        array(
            'label'           => esc_html__( 'Facebook Link', 'prime-cyber-security'  ),
            'section'         => 'prime_cyber_security_footer_social_section',
            'settings'        => 'prime_cyber_security_footer_facebook_link',
            'type'      => 'url'
        )
    );

    // Add setting for Facebook Icon Changing
    $wp_customize->add_setting(
        'prime_cyber_security_facebook_icon',
        array(
            'default' => 'fa-brands fa-facebook',
            'sanitize_callback' => 'sanitize_text_field',
            'capability' => 'edit_theme_options',
            
        )
    );	

    $wp_customize->add_control(new Prime_Cyber_Security_Changeable_Icon($wp_customize, 
        'prime_cyber_security_facebook_icon',
        array(
            'label'   		=> __('Facebook Icon','prime-cyber-security'),
            'section' 		=> 'prime_cyber_security_footer_social_section',
            'iconset' => 'fb',
        ))  
    );


    // Add setting for Twitter Link
    $wp_customize->add_setting(
        'prime_cyber_security_footer_twitter_link',
        array(
            'default'           => 'https://twitter.com/',
            'sanitize_callback' => 'esc_url_raw',
        )
    );

    $wp_customize->add_control(
        'prime_cyber_security_footer_twitter_link',
        array(
            'label'           => esc_html__( 'Twitter Link', 'prime-cyber-security'  ),
            'section'         => 'prime_cyber_security_footer_social_section',
            'settings'        => 'prime_cyber_security_footer_twitter_link',
            'type'      => 'url'
        )
    );

    // Add setting for Twitter Icon Changing
    $wp_customize->add_setting(
        'prime_cyber_security_twitter_icon',
        array(
            'default' => 'fa-brands fa-twitter',
            'sanitize_callback' => 'sanitize_text_field',
            'capability' => 'edit_theme_options',
            
        )
    );	

    $wp_customize->add_control(new Prime_Cyber_Security_Changeable_Icon($wp_customize, 
        'prime_cyber_security_twitter_icon',
        array(
            'label'   		=> __('Twitter Icon','prime-cyber-security'),
            'section' 		=> 'prime_cyber_security_footer_social_section',
            'iconset' => 'fb',
        ))  
    );

    // Add setting for Instagram Link
    $wp_customize->add_setting(
        'prime_cyber_security_footer_instagram_link',
        array(
            'default'           => 'https://www.instagram.com/',
            'sanitize_callback' => 'esc_url_raw',
        )
    );

    $wp_customize->add_control(
        'prime_cyber_security_footer_instagram_link',
        array(
            'label'           => esc_html__( 'Instagram Link', 'prime-cyber-security'  ),
            'section'         => 'prime_cyber_security_footer_social_section',
            'settings'        => 'prime_cyber_security_footer_instagram_link',
            'type'      => 'url'
        )
    );

    // Add setting for Instagram Icon Changing
    $wp_customize->add_setting(
        'prime_cyber_security_instagram_icon',
        array(
            'default' => 'fa-brands fa-instagram',
            'sanitize_callback' => 'sanitize_text_field',
            'capability' => 'edit_theme_options',
            
        )
    );	

    $wp_customize->add_control(new Prime_Cyber_Security_Changeable_Icon($wp_customize, 
        'prime_cyber_security_instagram_icon',
        array(
            'label'   		=> __('Instagram Icon','prime-cyber-security'),
            'section' 		=> 'prime_cyber_security_footer_social_section',
            'iconset' => 'fb',
        ))  
    );

    // Add setting for Linkedin Link
    $wp_customize->add_setting(
        'prime_cyber_security_footer_linkedin_link',
        array(
            'default'           => 'https://in.linkedin.com/',
            'sanitize_callback' => 'esc_url_raw',
        )
    );

    $wp_customize->add_control(
        'prime_cyber_security_footer_linkedin_link',
        array(
            'label'           => esc_html__( 'Linkedin Link', 'prime-cyber-security'  ),
            'section'         => 'prime_cyber_security_footer_social_section',
            'settings'        => 'prime_cyber_security_footer_linkedin_link',
            'type'      => 'url'
        )
    );

    // Add setting for Linkedin Icon Changing
    $wp_customize->add_setting(
        'prime_cyber_security_linkedin_icon',
        array(
            'default' => 'fa-brands fa-linkedin',
            'sanitize_callback' => 'sanitize_text_field',
            'capability' => 'edit_theme_options',
            
        )
    );	

    $wp_customize->add_control(new Prime_Cyber_Security_Changeable_Icon($wp_customize, 
        'prime_cyber_security_linkedin_icon',
        array(
            'label'   		=> __('Linkedin Icon','prime-cyber-security'),
            'section' 		=> 'prime_cyber_security_footer_social_section',
            'iconset' => 'fb',
        ))  
    );

    // Add setting for Youtube Link
    $wp_customize->add_setting(
        'prime_cyber_security_footer_youtube_link',
        array(
            'default'           => 'https://www.youtube.com/',
            'sanitize_callback' => 'esc_url_raw',
        )
    );

    $wp_customize->add_control(
        'prime_cyber_security_footer_youtube_link',
        array(
            'label'           => esc_html__( 'Youtube Link', 'prime-cyber-security'  ),
            'section'         => 'prime_cyber_security_footer_social_section',
            'settings'        => 'prime_cyber_security_footer_youtube_link',
            'type'      => 'url'
        )
    );

    // Add setting for Youtube Icon Changing
    $wp_customize->add_setting(
        'prime_cyber_security_youtube_icon',
        array(
            'default' => 'fa-brands fa-youtube',
            'sanitize_callback' => 'sanitize_text_field',
            'capability' => 'edit_theme_options',
            
        )
    );	

    $wp_customize->add_control(new Prime_Cyber_Security_Changeable_Icon($wp_customize, 
        'prime_cyber_security_youtube_icon',
        array(
            'label'   		=> __('Youtube Icon','prime-cyber-security'),
            'section' 		=> 'prime_cyber_security_footer_social_section',
            'iconset' => 'fb',
        ))  
    );

    // 404 PAGE SETTINGS
    $wp_customize->add_section(
        'prime_cyber_security_404_section',
        array(
            'title' => __( '404 Page Settings', 'prime-cyber-security' ),
            'priority' => 70,
            'panel' => 'prime_cyber_security_general_settings',
        )
    );
   
    $wp_customize->add_setting('prime_cyber_security_404_page_image', array(
        'default' => '',
        'transport' => 'refresh',
        'sanitize_callback' => 'esc_url_raw', // Sanitize as URL
    ));

    $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'prime_cyber_security_404_page_image', array(
        'label' => __('404 Page Image', 'prime-cyber-security'),
        'section' => 'prime_cyber_security_404_section',
        'settings' => 'prime_cyber_security_404_page_image',
    )));

    $wp_customize->add_setting('404_pagefirst_header', array(
        'default' => __('404', 'prime-cyber-security'),
        'transport' => 'refresh',
        'sanitize_callback' => 'sanitize_text_field', // Sanitize as text field
    ));

    $wp_customize->add_control('404_pagefirst_header', array(
        'type' => 'text',
        'label' => __('Heading', 'prime-cyber-security'),
        'section' => 'prime_cyber_security_404_section',
    ));

    // Setting for 404 page header
    $wp_customize->add_setting('404_page_header', array(
        'default' => __('Sorry, that page can\'t be found!', 'prime-cyber-security'),
        'transport' => 'refresh',
        'sanitize_callback' => 'sanitize_text_field', // Sanitize as text field
    ));

    $wp_customize->add_control('404_page_header', array(
        'type' => 'text',
        'label' => __('Heading', 'prime-cyber-security'),
        'section' => 'prime_cyber_security_404_section',
    ));

}
add_action( 'customize_register', 'prime_cyber_security_customize_register' );
endif;

/**
 * Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
 */
function prime_cyber_security_customize_preview_js() {
    // Use minified libraries if SCRIPT_DEBUG is false
    $prime_cyber_security_build  = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '/build' : '';
    $prime_cyber_security_suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
	wp_enqueue_script( 'prime_cyber_security_customizer', get_template_directory_uri() . '/js' . $prime_cyber_security_build . '/customizer' . $prime_cyber_security_suffix . '.js', array( 'customize-preview' ), '20130508', true );
}
add_action( 'customize_preview_init', 'prime_cyber_security_customize_preview_js' );