<?php
    /**
     * Theme options via the Customizer.
     *
     * @package dazzlo
     * @since dazzlo 1.0
     */

    // ------------- Theme Customizer  ------------- //

    add_action( 'customize_register', 'dazzlo_customizer_register' );

    function dazzlo_customizer_register( $wp_customize ) {



// Pro Version
        class Dazzlo_Customize_Pro_Version extends WP_Customize_Control {
            public $type = 'pro_options';

            public function render_content() {
                echo '<span>Upgrade to <strong></strong></span>';
                echo '<a href="'. esc_url($this->description) .'" target="_blank">';
                echo '<strong> '. esc_html__( 'Dazzlo Premium', 'dazzlo' ) .'<strong></a>';
                echo '</a>';
            }
        }

        // Pro Version Links
        class Dazzlo_Customize_Pro_Version_Links extends WP_Customize_Control {
            public $type = 'pro_links';

            public function render_content() {
                ?>
                <ul>
                    <li class="customize-control">
                        <h3><?php esc_html_e( 'Upgrade', 'dazzlo' ); ?> <span>*</span></h3>
                        <p><?php esc_html_e( 'There are lots of reasons to upgrade to Pro version. Unlimited custom Colors, rich Typography options, multiple variation of Blog Feed layout and way much more. Also Premium Support included.', 'dazzlo' ); ?></p>
                        <a href="<?php echo esc_url('https://www.vinethemes.com/downloads/dazzlo-blog-news-wordpress-theme/'); ?>" target="_blank" class="button button-primary widefat"><?php esc_html_e( 'Get Dazzlo Premium', 'dazzlo' ); ?></a>
                    </li>
                    <li class="customize-control">
                        <h3><?php esc_html_e( 'Documentation', 'dazzlo' ); ?></h3>
                        <p><?php esc_html_e( 'Read how to customize the theme, set up widgets, and learn all the possible options available to you.', 'dazzlo' ); ?></p>
                        <a href="<?php echo esc_url('https://www.vinethemes.com/documentation/dazzlo-theme-documentation/'); ?>" target="_blank" class="button button-primary widefat"><?php esc_html_e( 'Documentation', 'dazzlo' ); ?></a>
                    </li>
                    <li class="customize-control">
                        <h3><?php esc_html_e( 'Support', 'dazzlo' ); ?></h3>
                        <p><?php esc_html_e( 'For Dazzlo theme related questions feel free to post on our support forums.', 'dazzlo' ); ?></p>
                        <a href="<?php echo esc_url('https://www.vinethemes.com/forums'); ?>" target="_blank" class="button button-primary widefat"><?php esc_html_e( 'Support', 'dazzlo' ); ?></a>
                    </li>

                </ul>
                <?php
            }
        }


        /*
        ** Pro Version =====
        */

        // add Colors section
        $wp_customize->add_section( 'dazzlo_pro' , array(
            'title'		 => esc_html__( 'About Dazzlo', 'dazzlo' ),
            'priority'	 => 1,
            'capability' => 'edit_theme_options'
        ) );

        // Pro Version
        $wp_customize->add_setting( 'pro_version_', array(
            'sanitize_callback' => 'dazzlo_sanitize_custom_control'
        ) );
        $wp_customize->add_control( new Dazzlo_Customize_Pro_Version_Links ( $wp_customize,
                'pro_version_', array(
                    'section'	=> 'dazzlo_pro',
                    'type'		=> 'pro_links',
                    'label' 	=> '',
                    'priority'	=> 1
                )
            )
        );

        // Light and Dark Logo
        $wp_customize->remove_control('custom_logo');
        $wp_customize->add_setting( 'dazzlo_light_logo', array(
            // Image setting don't have anything in it, otherwise it will not get saved.
            'sanitize_callback' => 'dazzlo_sanitize_image'
        ) );

        $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'dazzlo_light_logo1', array(
                    'label'    => esc_html__( 'Light Logo', 'dazzlo' ),
                    'section'  => 'title_tagline',
                    'settings' => 'dazzlo_light_logo'
                )
            )
        );

        $wp_customize->add_setting( 'dazzlo_dark_logo', array(
            // Image setting don't have anything in it, otherwise it will not get saved.
            'sanitize_callback' => 'dazzlo_sanitize_image'
        ) );
        $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'dazzlo_dark_logo1', array(
                    'label'    => esc_html__( 'Dark Logo', 'dazzlo' ),
                    'section'  => 'title_tagline',
                    'settings' => 'dazzlo_dark_logo'
                )
            )
        );



        //Top Information Bar
        $wp_customize->add_section( 'dazzlo_information_bar', array(
            'title'       => esc_html__( 'Top Information Bar', 'dazzlo' ),
            'description' => esc_html__( 'Configure your Top Information bar here.', 'dazzlo' ),
            'priority'    => 2
        ) );


        $wp_customize->add_setting( 'dazzlo_information_bar_disable', array(
            'default'    => 'disable',
            'section'  => 'dazzlo_information_bar',
            'capability' => 'edit_theme_options',
            'sanitize_callback'	=> 'dazzlo_sanitize_radio',
        ) );

        $wp_customize->add_control( 'dazzlo_information_bar_select_box', array(
            'settings' => 'dazzlo_information_bar_disable',
            'label'    => esc_html__( 'Top Information Bar', 'dazzlo' ),
            'section'  => 'dazzlo_information_bar',
            'type'     => 'select',
            'choices'  => array(
                'enable'  => esc_html__( 'Enable', 'dazzlo' ),
                'disable' => esc_html__( 'Disable', 'dazzlo' ),
            ),
            'priority' => 1
        ) );

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

        $wp_customize->add_control('dazzlo_information_text', array(
                'label'      => esc_html__('Information Bar Text','dazzlo'),
                'section'    => 'dazzlo_information_bar',
                'settings'   => 'dazzlo_information_text',
                'type'		 => 'text',
                'priority'	 => 2
            )
        );


        $wp_customize->add_setting(
            'dazzlo_information_link',
            array(
                'sanitize_callback' => 'esc_url_raw'
            )
        );

        $wp_customize->add_control('dazzlo_information_link', array(
                'label'      => esc_html__('Information Bar Link URL','dazzlo'),
                'section'    => 'dazzlo_information_bar',
                'settings'   => 'dazzlo_information_link',
                'type'		 => 'url',
                'priority'	 => 3
            )
        );

        // Pro Version
        $wp_customize->add_setting( 'pro_version_colors8', array(
            'sanitize_callback' => 'dazzlo_sanitize_custom_control'
        ) );
        $wp_customize->add_control( new Dazzlo_Customize_Pro_Version ( $wp_customize,
                'pro_version_colors8', array(
                    'section'	  => 'dazzlo_information_bar',
                    'type'		  => 'pro_options',
                    'label' 	  => esc_html__( 'Upgrade', 'dazzlo' ),
                    'description' => esc_url_raw( 'https://www.vinethemes.com/downloads/dazzlo-blog-news-wordpress-theme/' ),
                    'priority'	  => 100
                )
            )
        );



        //Top Information Bar


        // Header Design
        $wp_customize->add_section( 'dazzlo_header_designs', array(
            'title'       => esc_html__( 'Header Designs', 'dazzlo' ),
            'description' => esc_html__( 'Select Header Designs from here.', 'dazzlo' ),
            'priority'    => 3
        ) );

        $wp_customize->add_setting( 'dazzlo_header_design_layout', array(
            'default' => 'header1',
            'section'  => 'dazzlo_header_designs',
            'sanitize_callback'	=> 'dazzlo_sanitize_radio',
        ) );
        $wp_customize->add_control( 'dazzlo_header_design_layout', array(
            'type' => 'radio',
            'label'    => esc_html__( 'Header Design Layout', 'dazzlo' ),
            'section'  => 'dazzlo_header_designs',
            'choices'  => array(
                'header1'  => esc_html__( 'Header 1', 'dazzlo' ),
                'header2' => esc_html__( 'Header 2', 'dazzlo' ),
            ),
            'priority' => 10
        ) );

        // Pro Version
        $wp_customize->add_setting( 'pro_version_colors7', array(
            'sanitize_callback' => 'dazzlo_sanitize_custom_control'
        ) );
        $wp_customize->add_control( new Dazzlo_Customize_Pro_Version ( $wp_customize,
                'pro_version_colors7', array(
                    'section'	  => 'dazzlo_header_designs',
                    'type'		  => 'pro_options',
                    'label' 	  => esc_html__( 'Upgrade', 'dazzlo' ),
                    'description' => esc_url_raw( 'https://www.vinethemes.com/downloads/dazzlo-blog-news-wordpress-theme/' ),
                    'priority'	  => 100
                )
            )
        );

        //Header Design



        //Slick Slider
        $wp_customize->add_section( 'dazzlo_customizer_mainslider', array(
            'title'       => esc_html__( 'Main Slider Options', 'dazzlo' ),
            'description' => esc_html__( 'Configure your Main Slider here.', 'dazzlo' ),
            'priority'    => 4
        ) );
        $wp_customize->add_setting( 'dazzlo_customizer_mainslider_disable', array(
            'default'    => 'enable',
            'section'  => 'dazzlo_customizer_mainslider',
            'capability' => 'edit_theme_options',
            'sanitize_callback'	=> 'dazzlo_sanitize_radio',
        ) );

        $wp_customize->add_control( 'dazzlo_mainslider_select_box', array(
            'settings' => 'dazzlo_customizer_mainslider_disable',
            'label'    => esc_html__( 'Homepage Main Slider', 'dazzlo' ),
            'section'  => 'dazzlo_customizer_mainslider',
            'type'     => 'select',
            'choices'  => array(
                'enable'  => esc_html__( 'Enable', 'dazzlo' ),
                'disable' => esc_html__( 'Disable', 'dazzlo' ),
            ),
            'priority' => 5
        ) );
        $wp_customize->add_setting( 'dazzlo_mainslider_category', array(
            'default' => '0',
            'sanitize_callback'	=> 'absint',
            'section'  => 'dazzlo_customizer_mainslider',

        ) );
        $wp_customize->add_control(new dazzlo_Customize_Category_Control( $wp_customize, 'dazzlo_mainslider_category', array(
                    'label'    => esc_html__( 'Category for Main Slider(Not available in Free Version)', 'dazzlo' ),
                    'section'  => 'dazzlo_customizer_mainslider',
                    'settings' => 'dazzlo_mainslider_category',
                    'priority'	 => 6
                )
            )
        );


        $wp_customize->add_setting( 'dazzlo_mainslider_slides', array(
            'default' => '3',
            'sanitize_callback'	=> 'absint',
            'section'  => 'dazzlo_customizer_mainslider',
        ) );

        $wp_customize->add_control( 'dazzlo_mainslider_slides', array(
                'label'      => esc_html__('Number of Posts for Main Slider(Upgrade to Premium)','dazzlo'),
                'section'    => 'dazzlo_customizer_mainslider',
                'settings'   => 'dazzlo_mainslider_slides',
                'type'		 => 'number',
                'priority'	 => 8
            )
        );


        $wp_customize->add_setting( 'dazzlo_beforeslider_category', array(
            'default' => '0',
            'sanitize_callback'	=> 'absint',
            'section'  => 'dazzlo_customizer_mainslider',

        ) );
        $wp_customize->add_control(new dazzlo_Customize_Category_Control( $wp_customize, 'dazzlo_beforeslider_category', array(
                    'label'    => esc_html__( 'Category for Before Slider Posts', 'dazzlo' ),
                    'section'  => 'dazzlo_customizer_mainslider',
                    'settings' => 'dazzlo_beforeslider_category',
                    'priority'	 => 9
                )
            )
        );


        $wp_customize->add_setting( 'dazzlo_afterslider_category', array(
            'default' => '0',
            'sanitize_callback'	=> 'absint',
            'section'  => 'dazzlo_customizer_mainslider',

        ) );
        $wp_customize->add_control(new dazzlo_Customize_Category_Control( $wp_customize, 'dazzlo_afterslider_category', array(
                    'label'    => esc_html__( 'Category for After Slider Posts', 'dazzlo' ),
                    'section'  => 'dazzlo_customizer_mainslider',
                    'settings' => 'dazzlo_afterslider_category',
                    'priority'	 => 10
                )
            )
        );



        // Pro Version
        $wp_customize->add_setting( 'pro_version_colors6', array(
            'sanitize_callback' => 'dazzlo_sanitize_custom_control'
        ) );
        $wp_customize->add_control( new Dazzlo_Customize_Pro_Version ( $wp_customize,
                'pro_version_colors6', array(
                    'section'	  => 'dazzlo_customizer_mainslider',
                    'type'		  => 'pro_options',
                    'label' 	  => esc_html__( 'Upgrade', 'dazzlo' ),
                    'description' => esc_url_raw( 'https://www.vinethemes.com/downloads/dazzlo-blog-news-wordpress-theme/' ),
                    'priority'	  => 100
                )
            )
        );


        //Small Slider
        $wp_customize->add_section( 'dazzlo_customizer_slider', array(
            'title'       => esc_html__( 'Small Slider Options', 'dazzlo' ),
            'description' => esc_html__( 'Configure your Small Slider here.', 'dazzlo' ),
            'priority'    => 5
        ) );
        $wp_customize->add_setting( 'dazzlo_customizer_slider_disable', array(
            'default'    => 'enable',
            'section'  => 'dazzlo_customizer_slider',
            'capability' => 'edit_theme_options',
            'sanitize_callback'	=> 'dazzlo_sanitize_radio',
        ) );

        $wp_customize->add_control( 'dazzlo_slider_select_box', array(
            'settings' => 'dazzlo_customizer_slider_disable',
            'label'    => esc_html__( 'Homepage Small Slider', 'dazzlo' ),
            'section'  => 'dazzlo_customizer_slider',
            'type'     => 'select',
            'choices'  => array(
                'enable'  => esc_html__( 'Enable', 'dazzlo' ),
                'disable' => esc_html__( 'Disable', 'dazzlo' ),
            ),
            'priority' => 5
        ) );
        $wp_customize->add_setting( 'dazzlo_slider_category', array(
            'default' => '0',
            'sanitize_callback'	=> 'absint',
            'section'  => 'dazzlo_customizer_slider',

        ) );
        $wp_customize->add_control(new dazzlo_Customize_Category_Control( $wp_customize, 'dazzlo_slider_category', array(
                    'label'    => esc_html__( 'Category for Small Slider', 'dazzlo' ),
                    'section'  => 'dazzlo_customizer_slider',
                    'settings' => 'dazzlo_slider_category',
                    'priority'	 => 6
                )
            )
        );


        $wp_customize->add_setting( 'dazzlo_slider_category', array(
            'default' => '0',
            'sanitize_callback'	=> 'absint',
            'section'  => 'dazzlo_customizer_slider',

        ) );
        $wp_customize->add_control(new dazzlo_Customize_Category_Control( $wp_customize, 'dazzlo_slider_category', array(
                    'label'    => esc_html__( 'Category for Slider', 'dazzlo' ),
                    'section'  => 'dazzlo_customizer_slider',
                    'settings' => 'dazzlo_slider_category',
                    'priority'	 => 7
                )
            )
        );

        $wp_customize->add_setting( 'dazzlo_slider_slides', array(
            'default' => '4',
            'sanitize_callback'	=> 'absint',
            'section'  => 'dazzlo_customizer_slider',
        ) );

        $wp_customize->add_control( 'dazzlo_slider_slides', array(
                'label'      => esc_html__('Number of Posts for Small Slider','dazzlo'),
                'section'    => 'dazzlo_customizer_slider',
                'settings'   => 'dazzlo_slider_slides',
                'type'		 => 'number',
                'priority'	 => 8
            )
        );

        // Pro Version
        $wp_customize->add_setting( 'pro_version_colors66', array(
            'sanitize_callback' => 'dazzlo_sanitize_custom_control'
        ) );
        $wp_customize->add_control( new Dazzlo_Customize_Pro_Version ( $wp_customize,
                'pro_version_colors66', array(
                    'section'	  => 'dazzlo_customizer_slider',
                    'type'		  => 'pro_options',
                    'label' 	  => esc_html__( 'Upgrade', 'dazzlo' ),
                    'description' => esc_url_raw( 'https://www.vinethemes.com/downloads/dazzlo-blog-news-wordpress-theme/' ),
                    'priority'	  => 100
                )
            )
        );

        // Post Layout Boxes
        // Layoutbox1

        $wp_customize->add_section( 'dazzlo_customizer_layoutbox1', array(
            'title'       => esc_html__( 'Layout Box1 Options', 'dazzlo' ),
            'description' => esc_html__( 'Configure your Layout Box1 here.', 'dazzlo' ),
            'priority'    => 6
        ) );
        $wp_customize->add_setting( 'dazzlo_customizer_layoutbox1_disable', array(
            'default'    => 'enable',
            'section'  => 'dazzlo_customizer_layoutbox1',
            'capability' => 'edit_theme_options',
            'sanitize_callback'	=> 'dazzlo_sanitize_radio',
        ) );
        $wp_customize->add_control( 'dazzlo_layoutbox1_select_box', array(
            'settings' => 'dazzlo_customizer_layoutbox1_disable',
            'label'    => esc_html__( 'Homepage Layout Box1', 'dazzlo' ),
            'section'  => 'dazzlo_customizer_layoutbox1',
            'type'     => 'select',
            'choices'  => array(
                'enable'  => esc_html__( 'Enable', 'dazzlo' ),
                'disable' => esc_html__( 'Disable', 'dazzlo' ),
            ),
            'priority' => 6
        ) );
        $wp_customize->add_setting('dazzlo_layoutbox1_title', array(
            'default'     => 'Layout Box 1',
            'section'  => 'dazzlo_customizer_layoutbox1',
            'capability' => 'edit_theme_options',
            'sanitize_callback'	=> 'sanitize_text_field',
        ) );
        $wp_customize->add_control(new WP_Customize_Control($wp_customize, 'layoutbox1_title', array(
                    'label'      => esc_html__('Layout Box1 Title','dazzlo'),
                    'section'    => 'dazzlo_customizer_layoutbox1',
                    'settings'   => 'dazzlo_layoutbox1_title',
                    'type'		 => 'text',
                    'priority'	 => 7
                )
            )
        );
        $wp_customize->add_setting( 'dazzlo_layoutbox1_category', array(
            'default' => 0,
            'sanitize_callback'	=> 'absint',
            'section'  => 'dazzlo_customizer_layoutbox1',

        ) );
        $wp_customize->add_control(new dazzlo_Customize_Category_Control( $wp_customize, 'dazzlo_layoutbox1_category', array(
                    'label'    => esc_html__( 'Category for Layout Box1', 'dazzlo' ),
                    'section'  => 'dazzlo_customizer_layoutbox1',
                    'settings' => 'dazzlo_layoutbox1_category',
                    'priority'	 => 8
                )
            )
        );
        $wp_customize->add_setting( 'dazzlo_layoutbox1_no', array(
            'default' => '5',
            'sanitize_callback'	=> 'absint',
            'section'  => 'dazzlo_customizer_layoutbox1',
        ) );



        $wp_customize->add_control('dazzlo_layoutbox1_no', array(
                    'label'      => esc_html__('Number of Posts for Layout Box1','dazzlo'),
                    'section'    => 'dazzlo_customizer_layoutbox1',
                    'settings'   => 'dazzlo_layoutbox1_no',
                    'type'		 => 'number',
                    'priority'	 => 9
                )
        );
        // Pro Version
        $wp_customize->add_setting( 'pro_version_colors9', array(
            'sanitize_callback' => 'dazzlo_sanitize_custom_control'
        ) );
        $wp_customize->add_control( new Dazzlo_Customize_Pro_Version ( $wp_customize,
                'pro_version_colors9', array(
                    'section'	  => 'dazzlo_customizer_layoutbox1',
                    'type'		  => 'pro_options',
                    'label' 	  => esc_html__( 'Upgrade', 'dazzlo' ),
                    'description' => esc_url_raw( 'https://www.vinethemes.com/downloads/dazzlo-blog-news-wordpress-theme/' ),
                    'priority'	  => 100
                )
            )
        );


// Layoutbox2

$wp_customize->add_section( 'dazzlo_customizer_layoutbox2', array(
    'title'       => esc_html__( 'Layout Box2 Options', 'dazzlo' ),
    'description' => esc_html__( 'Configure your Layout Box2 here.', 'dazzlo' ),
    'priority'    => 7
) );
$wp_customize->add_setting( 'dazzlo_customizer_layoutbox2_disable', array(
    'default'    => 'enable',
    'section'  => 'dazzlo_customizer_layoutbox2',
    'capability' => 'edit_theme_options',
    'sanitize_callback'	=> 'dazzlo_sanitize_radio',
) );
$wp_customize->add_control( 'dazzlo_layoutbox2_select_box', array(
    'settings' => 'dazzlo_customizer_layoutbox2_disable',
    'label'    => esc_html__( 'Homepage Layout Box2', 'dazzlo' ),
    'section'  => 'dazzlo_customizer_layoutbox2',
    'type'     => 'select',
    'choices'  => array(
        'enable'  => esc_html__( 'Enable', 'dazzlo' ),
        'disable' => esc_html__( 'Disable', 'dazzlo' ),
    ),
    'priority' => 6
) );
$wp_customize->add_setting('dazzlo_layoutbox2_title', array(
    'default'     => 'Layout Box 2',
    'section'  => 'dazzlo_customizer_layoutbox2',
    'capability' => 'edit_theme_options',
    'sanitize_callback'	=> 'sanitize_text_field',
) );
$wp_customize->add_control(new WP_Customize_Control($wp_customize, 'layoutbox2_title', array(
            'label'      => esc_html__('Layout Box2 Title','dazzlo'),
            'section'    => 'dazzlo_customizer_layoutbox2',
            'settings'   => 'dazzlo_layoutbox2_title',
            'type'		 => 'text',
            'priority'	 => 7
        )
    )
);
$wp_customize->add_setting( 'dazzlo_layoutbox2_category', array(
    'default' => 0,
    'sanitize_callback'	=> 'absint',
    'section'  => 'dazzlo_customizer_layoutbox2',

) );
$wp_customize->add_control(new dazzlo_Customize_Category_Control( $wp_customize, 'dazzlo_layoutbox2_category', array(
            'label'    => esc_html__( 'Category for Layout Box2', 'dazzlo' ),
            'section'  => 'dazzlo_customizer_layoutbox2',
            'settings' => 'dazzlo_layoutbox2_category',
            'priority'	 => 8
        )
    )
);
$wp_customize->add_setting( 'dazzlo_layoutbox2_no', array(
    'default' => '3',
    'sanitize_callback'	=> 'absint',
    'section'  => 'dazzlo_customizer_layoutbox2',
) );

$wp_customize->add_control('dazzlo_layoutbox2_no', array(
            'label'      => esc_html__('Number of Posts for Layout Box2','dazzlo'),
            'section'    => 'dazzlo_customizer_layoutbox2',
            'settings'   => 'dazzlo_layoutbox2_no',
            'type'		 => 'number',
            'priority'	 => 9
        )
);
// Pro Version
        $wp_customize->add_setting( 'pro_version_colors10', array(
            'sanitize_callback' => 'dazzlo_sanitize_custom_control'
        ) );
        $wp_customize->add_control( new Dazzlo_Customize_Pro_Version ( $wp_customize,
                'pro_version_colors10', array(
                    'section'	  => 'dazzlo_customizer_layoutbox2',
                    'type'		  => 'pro_options',
                    'label' 	  => esc_html__( 'Upgrade', 'dazzlo' ),
                    'description' => esc_url_raw( 'https://www.vinethemes.com/downloads/dazzlo-blog-news-wordpress-theme/' ),
                    'priority'	  => 100
                )
            )
        );

// Layoutbox3

$wp_customize->add_section( 'dazzlo_customizer_layoutbox3', array(
    'title'       => esc_html__( 'Layout Box3 Options', 'dazzlo' ),
    'description' => esc_html__( 'Configure your Layout Box3 here.', 'dazzlo' ),
    'priority'    => 8
) );
$wp_customize->add_setting( 'dazzlo_customizer_layoutbox3_disable', array(
    'default'    => 'enable',
    'section'  => 'dazzlo_customizer_layoutbox3',
    'capability' => 'edit_theme_options',
    'sanitize_callback'	=> 'dazzlo_sanitize_radio',
) );
$wp_customize->add_control( 'dazzlo_layoutbox3_select_box', array(
    'settings' => 'dazzlo_customizer_layoutbox3_disable',
    'label'    => esc_html__( 'Homepage Layout Box3', 'dazzlo' ),
    'section'  => 'dazzlo_customizer_layoutbox3',
    'type'     => 'select',
    'choices'  => array(
        'enable'  => esc_html__( 'Enable', 'dazzlo' ),
        'disable' => esc_html__( 'Disable', 'dazzlo' ),
    ),
    'priority' => 6
) );
$wp_customize->add_setting('dazzlo_layoutbox3_title', array(
    'default'     => 'Layout Box 3',
    'section'  => 'dazzlo_customizer_layoutbox3',
    'capability' => 'edit_theme_options',
    'sanitize_callback'	=> 'sanitize_text_field',
) );
$wp_customize->add_control(new WP_Customize_Control($wp_customize, 'layoutbox3_title', array(
            'label'      => esc_html__('Layout Box3 Title','dazzlo'),
            'section'    => 'dazzlo_customizer_layoutbox3',
            'settings'   => 'dazzlo_layoutbox3_title',
            'type'		 => 'text',
            'priority'	 => 7
        )
    )
);
$wp_customize->add_setting( 'dazzlo_layoutbox3_category', array(
    'default' => 0,
    'sanitize_callback'	=> 'absint',
    'section'  => 'dazzlo_customizer_layoutbox3',

) );
$wp_customize->add_control(new dazzlo_Customize_Category_Control( $wp_customize, 'dazzlo_layoutbox3_category', array(
            'label'    => esc_html__( 'Category for Layout Box3', 'dazzlo' ),
            'section'  => 'dazzlo_customizer_layoutbox3',
            'settings' => 'dazzlo_layoutbox3_category',
            'priority'	 => 8
        )
    )
);
$wp_customize->add_setting( 'dazzlo_layoutbox3_no', array(
    'default' => '5',
    'sanitize_callback'	=> 'absint',
    'section'  => 'dazzlo_customizer_layoutbox3',
) );

$wp_customize->add_control('dazzlo_layoutbox3_no', array(
            'label'      => esc_html__('Number of Posts for Layout Box3','dazzlo'),
            'section'    => 'dazzlo_customizer_layoutbox3',
            'settings'   => 'dazzlo_layoutbox3_no',
            'type'		 => 'number',
            'priority'	 => 9
        )
);
// Pro Version
        $wp_customize->add_setting( 'pro_version_colors11', array(
            'sanitize_callback' => 'dazzlo_sanitize_custom_control'
        ) );
        $wp_customize->add_control( new Dazzlo_Customize_Pro_Version ( $wp_customize,
                'pro_version_colors11', array(
                    'section'	  => 'dazzlo_customizer_layoutbox3',
                    'type'		  => 'pro_options',
                    'label' 	  => esc_html__( 'Upgrade', 'dazzlo' ),
                    'description' => esc_url_raw( 'https://www.vinethemes.com/downloads/dazzlo-blog-news-wordpress-theme/' ),
                    'priority'	  => 100
                )
            )
        );

// Layoutbox4

$wp_customize->add_section( 'dazzlo_customizer_layoutbox4', array(
    'title'       => esc_html__( 'Layout Box4 Options', 'dazzlo' ),
    'description' => esc_html__( 'Configure your Layout Box4 here.', 'dazzlo' ),
    'priority'    => 9
) );
$wp_customize->add_setting( 'dazzlo_customizer_layoutbox4_disable', array(
    'default'    => 'enable',
    'section'  => 'dazzlo_customizer_layoutbox4',
    'capability' => 'edit_theme_options',
    'sanitize_callback'	=> 'dazzlo_sanitize_radio',
) );
$wp_customize->add_control( 'dazzlo_layoutbox4_select_box', array(
    'settings' => 'dazzlo_customizer_layoutbox4_disable',
    'label'    => esc_html__( 'Homepage Layout Box4', 'dazzlo' ),
    'section'  => 'dazzlo_customizer_layoutbox4',
    'type'     => 'select',
    'choices'  => array(
        'enable'  => esc_html__( 'Enable', 'dazzlo' ),
        'disable' => esc_html__( 'Disable', 'dazzlo' ),
    ),
    'priority' => 6
) );
$wp_customize->add_setting('dazzlo_layoutbox4_title', array(
    'default'     => 'Layout Box 4',
    'section'  => 'dazzlo_customizer_layoutbox4',
    'capability' => 'edit_theme_options',
    'sanitize_callback'	=> 'sanitize_text_field',
) );
$wp_customize->add_control(new WP_Customize_Control($wp_customize, 'layoutbox4_title', array(
            'label'      => esc_html__('Layout Box4 Title','dazzlo'),
            'section'    => 'dazzlo_customizer_layoutbox4',
            'settings'   => 'dazzlo_layoutbox4_title',
            'type'		 => 'text',
            'priority'	 => 7
        )
    )
);
$wp_customize->add_setting( 'dazzlo_layoutbox4_category', array(
    'default' => 0,
    'sanitize_callback'	=> 'absint',
    'section'  => 'dazzlo_customizer_layoutbox4',

) );
$wp_customize->add_control(new dazzlo_Customize_Category_Control( $wp_customize, 'dazzlo_layoutbox4_category', array(
            'label'    => esc_html__( 'Category for Layout Box4', 'dazzlo' ),
            'section'  => 'dazzlo_customizer_layoutbox4',
            'settings' => 'dazzlo_layoutbox4_category',
            'priority'	 => 8
        )
    )
);
$wp_customize->add_setting( 'dazzlo_layoutbox4_no', array(
    'default' => '6',
    'sanitize_callback'	=> 'absint',
    'section'  => 'dazzlo_customizer_layoutbox4',
) );

$wp_customize->add_control('dazzlo_layoutbox4_no', array(
            'label'      => esc_html__('Number of Posts for Layout Box4','dazzlo'),
            'section'    => 'dazzlo_customizer_layoutbox4',
            'settings'   => 'dazzlo_layoutbox4_no',
            'type'		 => 'number',
            'priority'	 => 9
        )
);
// Pro Version
        $wp_customize->add_setting( 'pro_version_colors12', array(
            'sanitize_callback' => 'dazzlo_sanitize_custom_control'
        ) );
        $wp_customize->add_control( new Dazzlo_Customize_Pro_Version ( $wp_customize,
                'pro_version_colors12', array(
                    'section'	  => 'dazzlo_customizer_layoutbox4',
                    'type'		  => 'pro_options',
                    'label' 	  => esc_html__( 'Upgrade', 'dazzlo' ),
                    'description' => esc_url_raw( 'https://www.vinethemes.com/downloads/dazzlo-blog-news-wordpress-theme/' ),
                    'priority'	  => 100
                )
            )
        );


        //General Options

        $wp_customize->add_section( 'dazzlo_general_options', array(
            'title'       => esc_html__( 'General Options', 'dazzlo' ),
            'description' => esc_html__( '(Load More Posts features is not available in Free version. Upgrade to Premium version.)', 'dazzlo' ),
            'priority'    => 11
        ) );


        $wp_customize->add_setting('dazzlo_latest_posts', array(
            'default'     => 'Latest Posts',
            'section'  => 'dazzlo_general_options',
            'capability' => 'edit_theme_options',
            'sanitize_callback'	=> 'sanitize_text_field',
        ) );
        $wp_customize->add_control(new WP_Customize_Control($wp_customize, 'latestposts_title', array(
                    'label'      => esc_html__('Latest Posts Title','dazzlo'),
                    'section'    => 'dazzlo_general_options',
                    'settings'   => 'dazzlo_latest_posts',
                    'type'		 => 'text',
                    'priority'	 => 5
                )
            )
        );



        $wp_customize->add_setting( 'dazzlo_general_search_icon', array(
            'section'  => 'dazzlo_general_options',
            'capability' => 'edit_theme_options',
            'sanitize_callback'	=> 'dazzlo_sanitize_checkbox',
        ) );

        $wp_customize->add_control( 'dazzlo_general_search_icon', array(
            'settings' => 'dazzlo_general_search_icon',
            'label'    => esc_html__( 'Hide Top Search Icon', 'dazzlo' ),
            'section'  => 'dazzlo_general_options',
            'type'     => 'checkbox',
            'priority' => 6
        ) );
        $wp_customize->add_setting( 'dazzlo_general_responsive', array(
            'section'  => 'dazzlo_general_options',
            'capability' => 'edit_theme_options',
            'sanitize_callback'	=> 'dazzlo_sanitize_checkbox',
        ) );

        $wp_customize->add_control( 'dazzlo_general_responsive', array(
            'settings' => 'dazzlo_general_responsive',
            'label'    => esc_html__( 'Disable Responsive', 'dazzlo' ),
            'section'  => 'dazzlo_general_options',
            'type'     => 'checkbox',
            'priority' => 6
        ) );
        $wp_customize->add_setting( 'dazzlo_general_sidebar_home', array(
            'section'  => 'dazzlo_general_options',
            'capability' => 'edit_theme_options',
            'sanitize_callback'	=> 'dazzlo_sanitize_checkbox',
        ) );

        $wp_customize->add_control( 'dazzlo_general_sidebar_home', array(
            'settings' => 'dazzlo_general_sidebar_home',
            'label'    => esc_html__( 'Disable Sidebar on Homepage and Archive Pages', 'dazzlo' ),
            'section'  => 'dazzlo_general_options',
            'type'     => 'checkbox',
            'priority' => 6
        ) );
        $wp_customize->add_setting( 'dazzlo_general_sidebar_post', array(
            'section'  => 'dazzlo_general_options',
            'capability' => 'edit_theme_options',
            'sanitize_callback'	=> 'dazzlo_sanitize_checkbox',
        ) );

        $wp_customize->add_control( 'dazzlo_general_sidebar_post', array(
            'settings' => 'dazzlo_general_sidebar_post',
            'label'    => esc_html__( 'Disable Sidebar on Posts', 'dazzlo' ),
            'section'  => 'dazzlo_general_options',
            'type'     => 'checkbox',
            'priority' => 6
        ) );
        $wp_customize->add_setting( 'dazzlo_general_sidebar_page', array(
            'section'  => 'dazzlo_general_options',
            'capability' => 'edit_theme_options',
            'sanitize_callback'	=> 'dazzlo_sanitize_checkbox',
        ) );

        $wp_customize->add_control( 'dazzlo_general_sidebar_page', array(
            'settings' => 'dazzlo_general_sidebar_page',
            'label'    => esc_html__( 'Disable Sidebar on Pages', 'dazzlo' ),
            'section'  => 'dazzlo_general_options',
            'type'     => 'checkbox',
            'priority' => 6
        ) );

        $wp_customize->add_setting( 'dazzlo_general_author_post', array(
            'section'  => 'dazzlo_general_options',
            'capability' => 'edit_theme_options',
            'sanitize_callback'	=> 'dazzlo_sanitize_checkbox',
        ) );

        $wp_customize->add_control( 'dazzlo_general_author_post', array(
            'settings' => 'dazzlo_general_author_post',
            'label'    => esc_html__( 'Disable Author Box on Posts', 'dazzlo' ),
            'section'  => 'dazzlo_general_options',
            'type'     => 'checkbox',
            'priority' => 6
        ) );


        // Pro Version
        $wp_customize->add_setting( 'pro_version_colors2', array(
            'sanitize_callback' => 'dazzlo_sanitize_custom_control'
        ) );
        $wp_customize->add_control( new Dazzlo_Customize_Pro_Version ( $wp_customize,
                'pro_version_colors2', array(
                    'section'	  => 'dazzlo_general_options',
                    'type'		  => 'pro_options',
                    'label' 	  => esc_html__( 'Upgrade', 'dazzlo' ),
                    'description' => esc_url_raw( 'https://www.vinethemes.com/downloads/dazzlo-blog-news-wordpress-theme/' ),
                    'priority'	  => 100
                )
            )
        );


        // Footer Settings
        $wp_customize->add_section( 'dazzlo_footer_settings', array(
            'title'       => esc_html__( 'Footer Settings', 'dazzlo' ),
            'description' => esc_html__( 'Configure Your Footer Here. You can\'t change our footer links in the free version of this theme.', 'dazzlo' ),
             'priority'    => 12
        ) );

        $wp_customize->add_setting(
            'footer_copyright',
            array(
                'default'     => 'Copyright 2024.',
                'sanitize_callback' => 'sanitize_text_field'
            )
        );

        $wp_customize->add_control('footer_copyright', array(
                    'label'      => esc_html__('Footer Copyright Text','dazzlo'),
                    'section'    => 'dazzlo_footer_settings',
                    'settings'   => 'footer_copyright',
                    'type'		 => 'text',
                    'priority'	 => 1
                )
        );


        // Pro Version
        $wp_customize->add_setting( 'pro_version_colors3', array(
            'sanitize_callback' => 'dazzlo_sanitize_custom_control'
        ) );
        $wp_customize->add_control( new Dazzlo_Customize_Pro_Version ( $wp_customize,
                'pro_version_colors3', array(
                    'section'	  => 'dazzlo_footer_settings',
                    'type'		  => 'pro_options',
                    'label' 	  => esc_html__( 'Upgrade', 'dazzlo' ),
                    'description' => esc_url_raw( 'https://www.vinethemes.com/downloads/dazzlo-blog-news-wordpress-theme/' ),
                    'priority'	  => 100
                )
            )
        );


    }


// Adding controls to default customizer panel
    add_action('customize_register','dazzlo_customizer_options');
    /*
     * Add in our custom Main Color setting and control to be used in the Customizer in the Colors section
     *
     */
    function dazzlo_customizer_options( $wp_customize ) {
        $wp_customize->add_setting(
            'dazzlo_main_color', //give it an ID
            array(
                'default' => '#3d55ef', // Give it a default
                'sanitize_callback' => 'sanitize_hex_color',
                'transport'      => 'refresh'
            )
        );
        $wp_customize->add_control(
            new WP_Customize_Color_Control(
                $wp_customize,
                'dazzlo_custom_main_color', //give it an ID
                array(
                    'label'      => esc_html__( 'Main Color', 'dazzlo' ), //set the label to appear in the Customizer
                    'section'    => 'colors', //select the section for it to appear under
                    'settings'   => 'dazzlo_main_color' //pick the setting it applies to
                )
            )
        );
        $wp_customize->add_setting(
            'dazzlo_main_text', //give it an ID
            array(
                'default' => '#3d55ef', // Give it a default
                'sanitize_callback' => 'sanitize_hex_color',
                'transport'      => 'refresh'
            )
        );
        $wp_customize->add_control(
            new Dazzlo_Customize_Pro_Version(
                $wp_customize,
                'dazzlo_custom_text', //give it an ID
                array(
                    'label'      => esc_html__( 'Upgrade', 'dazzlo' ), //set the label to appear in the Customizer
                    'section'    => 'colors', //select the section for it to appear under
                    'settings'   => 'dazzlo_main_text', //pick the setting it applies to
                    'description' => esc_url_raw( 'https://www.vinethemes.com/downloads/dazzlo-blog-news-wordpress-theme/' ),
                )
            )
        );



    }


function dazzlo_sanitize_image( $file, $setting ) {

    $mimes = array(
        'jpg|jpeg|jpe' => 'image/jpeg',
        'gif'          => 'image/gif',
        'png'          => 'image/png',
        'bmp'          => 'image/bmp',
        'tif|tiff'     => 'image/tiff',
        'ico'          => 'image/x-icon'
    );

    //check file type from file name
    $file_ext = wp_check_filetype( $file, $mimes );

    //if file has a valid mime type return it, otherwise return default
    return ( $file_ext['ext'] ? $file : $setting->default );
}



    function dazzlo_sanitize_text( $input ) {
        return wp_kses_post( force_balance_tags( $input ) );
    }


    //checkbox sanitization function
    function dazzlo_sanitize_checkbox( $input ){

        //returns true if checkbox is checked
        return (( isset( $input ) && true === $input ) ? true : false );
    }

    //radio box sanitization function
    function dazzlo_sanitize_radio( $input, $setting ){
    $valid = array(
        'excerpt' => 'excerpt',
        'full' => 'full',
        'standard' => 'standard',
        'grid' => 'grid',
        'enable' => 'enable',
        'disable' => 'disable',
        'header1' => 'header1',
        'header2' => 'header2',
    );
    if ( array_key_exists( $input, $valid ) ) {
        return $input;
    } else {
        return $setting->default;
    }
    }

    function dazzlo_panels_js() {
        wp_enqueue_style( 'dazzlo-customizer-ui-css', get_theme_file_uri( '/customizer-ui.css' ) );
    }
    add_action( 'customize_controls_enqueue_scripts', 'dazzlo_panels_js' );
