<?php
function electromix_general_setting( $wp_customize ) {
$selective_refresh = isset( $wp_customize->selective_refresh ) ? 'postMessage' : 'refresh';
	$wp_customize->add_panel(
		'electromix_general', array(
			'priority' => 31,
			'title' => esc_html__( 'General', 'electromix' ),
		)
	);
	
	/*=========================================
	Scroller
	=========================================*/
	$wp_customize->add_section(
		'top_scroller', array(
			'title' => esc_html__( 'Top Scroller', 'electromix' ),
			'priority' => 4,
			'panel' => 'electromix_general',
		)
	);
	
	$wp_customize->add_setting( 
		'hs_scroller' , 
			array(
			'default' => '1',
			'sanitize_callback' => 'electromix_sanitize_checkbox',
			'capability' => 'edit_theme_options',
			'priority' => 1,
		) 
	);
	
	$wp_customize->add_control(
	'hs_scroller', 
		array(
			'label'	      => esc_html__( 'Hide / Show Scroller', 'electromix' ),
			'section'     => 'top_scroller',
			'type'        => 'checkbox'
		) 
	);
	
	/*=========================================
	Breadcrumb  Section
	=========================================*/
	$wp_customize->add_section(
		'breadcrumb_setting', array(
			'title' => esc_html__( 'Page Breadcrumb', 'electromix' ),
			'priority' => 12,
			'panel' => 'electromix_general',
		)
	);
	
	// Settings
	$wp_customize->add_setting(
		'breadcrumb_settings'
			,array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'electromix_sanitize_text',
			'priority' => 1,
		)
	);

	$wp_customize->add_control(
	'breadcrumb_settings',
		array(
			'type' => 'hidden',
			'label' => __('Settings','electromix'),
			'section' => 'breadcrumb_setting',
		)
	);
	
	// Breadcrumb Hide/ Show Setting // 
	$wp_customize->add_setting( 
		'hs_breadcrumb' , 
			array(
			'default' => '1',
			'sanitize_callback' => 'electromix_sanitize_checkbox',
			'capability' => 'edit_theme_options',
			'priority' => 2,
		) 
	);
	
	$wp_customize->add_control(
	'hs_breadcrumb', 
		array(
			'label'	      => esc_html__( 'Hide / Show Section', 'electromix' ),
			'section'     => 'breadcrumb_setting',
			'type'        => 'checkbox'
		) 
	);
	
	// enable on Page Title
	$wp_customize->add_setting(
		'breadcrumb_title_enable'
			,array(
			'default' => '1',
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'electromix_sanitize_checkbox',
			'priority' => 3,
		)
	);

	$wp_customize->add_control(
	'breadcrumb_title_enable',
		array(
			'type' => 'checkbox',
			'label' => __('Enable Page Title on Breadcrumb?','electromix'),
			'section' => 'breadcrumb_setting',
		)
	);
	
	// enable on Page Path
	$wp_customize->add_setting(
		'breadcrumb_path_enable'
			,array(
			'default' => '1',
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'electromix_sanitize_checkbox',
			'priority' => 4,
		)
	);

	$wp_customize->add_control(
	'breadcrumb_path_enable',
		array(
			'type' => 'checkbox',
			'label' => __('Enable Page Path on Breadcrumb?','electromix'),
			'section' => 'breadcrumb_setting',
		)
	);	
	
		
	// Background // 
	$wp_customize->add_setting(
		'breadcrumb_bg_head'
			,array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'electromix_sanitize_text',
			'priority' => 9,
		)
	);

	$wp_customize->add_control(
	'breadcrumb_bg_head',
		array(
			'type' => 'hidden',
			'label' => __('Background','electromix'),
			'section' => 'breadcrumb_setting',
		)
	);
	
	// Background Image // 
    $wp_customize->add_setting( 
    	'breadcrumb_bg_img' , 
    	array(
			'default' 			=> esc_url(get_template_directory_uri() .'/assets/images/breadcrumb/img.png'),
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'electromix_sanitize_url',	
			'priority' => 10,
		) 
	);
	
	$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize , 'breadcrumb_bg_img' ,
		array(
			'label'          => esc_html__( 'Side Image', 'electromix'),
			'section'        => 'breadcrumb_setting',
		) 
	));
	
	/*========================
	 **** Pro Upgrade ****
	======================== */
	if ( class_exists( 'Ecommerce_Comp_Customizer' ) ) {
	class  Electromix_breadcrumb__section_upgrade extends WP_Customize_Control {
		public function render_content() { 	
			
		?>
			<a class="customizer_breadcrumb_section_premium up-to-pro" style="padding:9px 0; text-align:center;" href="<?php echo electromix_premium_links(); ?>" target="_blank"><?php esc_html_e('Upgrade To Pro For More','electromix'); ?></a>
			
		<?php }
	}
	
	$wp_customize->add_setting( 'breadcrumb_upgrade_to_pro', array(
		'capability'			=> 'edit_theme_options',
		'electromix_sanitize_callback'	=> 'wp_filter_nohtml_kses',
		'priority' => 5,
	));
	$wp_customize->add_control(
		new  Electromix_breadcrumb__section_upgrade(
		$wp_customize,
		'breadcrumb_upgrade_to_pro',
			array(
				'section'				=> 'breadcrumb_setting',
			)
		)
	);
	}
	
	/*=========================================
	Electromix Container
	=========================================*/
	$wp_customize->add_section(
        'electromix_container',
        array(
        	'priority'      => 2,
            'title' 		=> __('Container','electromix'),
			'panel'  		=> 'electromix_general',
		)
    );
	
	if ( class_exists( 'Ecommerce_Comp_Customizer_Range_Control' ) ) {
		//container width
		$wp_customize->add_setting(
			'electromix_site_cntnr_width',
			array(
				'default'			=> '1320',
				'capability'     	=> 'edit_theme_options',
				'sanitize_callback' => 'electromix_sanitize_range_value',
				'transport'         => 'postMessage',
				'priority'      => 1,
			)
		);
		$wp_customize->add_control( 
		new Ecommerce_Comp_Customizer_Range_Control( $wp_customize, 'electromix_site_cntnr_width', 
			array(
				'label'      => __( 'Container Width', 'electromix' ),
				'section'  => 'electromix_container',
				'media_query'   => true,
                'input_attr'    => array(
                    'mobile'  => array(
                        'min'           => 100,
                        'max'           => 320,
                        'step'          => 1,
                        'default_value' => 320,
                    ),
                    'tablet'  => array(
                        'min'           => 577,
                        'max'           => 768,
                        'step'          => 1,
                        'default_value' => 768,
                    ),
                    'desktop' => array(
                        'min'           => 992,
                        'max'           => 1320,
                        'step'          => 1,
                        'default_value' => 1200,
                    ),
				)
			) ) 
		);
	
	// Pro Upgrade
	class  Electromix_cntr__section_upgrade extends WP_Customize_Control {
		public function render_content() { 			
		?>
			<a class="customizer_cntr_section_premium up-to-pro" style="padding:9px 0; text-align:center;" href="<?php echo electromix_premium_links(); ?>" target="_blank"><?php esc_html_e('Upgrade To Pro For More','electromix'); ?></a>
			
		<?php }
	}
	
	$wp_customize->add_setting( 'cntr_upgrade_to_pro', array(
		'capability'			=> 'edit_theme_options',
		'electromix_sanitize_callback'	=> 'wp_filter_nohtml_kses',
		'priority' => 1,
	));
	$wp_customize->add_control(
		new  Electromix_cntr__section_upgrade(
		$wp_customize,
		'cntr_upgrade_to_pro',
			array(
				'section'				=> 'electromix_container',
			)
		)
	);
	}
	
	/*=========================================
	Electromix Sidebar
	=========================================*/
	$wp_customize->add_section(
        'electromix_sidebar',
        array(
        	'priority'      => 8,
            'title' 		=> __('Sidebar','electromix'),
			'panel'  		=> 'electromix_general',
		)
    );
	
	//  Pages Layout // 
	$wp_customize->add_setting(
		'electromix_pages_sidebar'
			,array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'electromix_sanitize_text',
			'priority' => 1,
		)
	);

	$wp_customize->add_control(
	'electromix_pages_sidebar',
		array(
			'type' => 'hidden',
			'label' => __('Sidebar Layout','electromix'),
			'section' => 'electromix_sidebar',
		)
	);
	
	// Default Page
	$wp_customize->add_setting( 
		'electromix_default_pg_sidebar' , 
			array(
			'default' => 'right_sidebar',
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'electromix_sanitize_select',
			'priority' => 2,
		) 
	);

	$wp_customize->add_control(
	'electromix_default_pg_sidebar' , 
		array(
			'label'          => __( 'Default Page Sidebar Option', 'electromix' ),
			'section'        => 'electromix_sidebar',
			'type'           => 'select',
			'choices'        => 
			array(
				'left_sidebar' 	=> __( 'Left Sidebar', 'electromix' ),
				'right_sidebar' 	=> __( 'Right Sidebar', 'electromix' ),
				'no_sidebar' 	=> __( 'No Sidebar', 'electromix' ),
			) 
		) 
	);
	
	// Archive Page
	$wp_customize->add_setting( 
		'electromix_archive_pg_sidebar' , 
			array(
			'default' => 'right_sidebar',
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'electromix_sanitize_select',
			'priority' => 3,
		) 
	);

	$wp_customize->add_control(
	'electromix_archive_pg_sidebar' , 
		array(
			'label'          => __( 'Archive Page Sidebar Option', 'electromix' ),
			'section'        => 'electromix_sidebar',
			'type'           => 'select',
			'choices'        => 
			array(
				'left_sidebar' 	=> __( 'Left Sidebar', 'electromix' ),
				'right_sidebar' => __( 'Right Sidebar', 'electromix' ),
				'no_sidebar' 	=> __( 'No Sidebar', 'electromix' ),
			) 
		) 
	);
	
	
	// Single Page
	$wp_customize->add_setting( 
		'electromix_single_pg_sidebar' , 
			array(
			'default' => 'right_sidebar',
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'electromix_sanitize_select',
			'priority' => 4,
		) 
	);

	$wp_customize->add_control(
	'electromix_single_pg_sidebar' , 
		array(
			'label'          => __( 'Single Page Sidebar Option', 'electromix' ),
			'section'        => 'electromix_sidebar',
			'type'           => 'select',
			'choices'        => 
			array(
				'left_sidebar' 	=> __( 'Left Sidebar', 'electromix' ),
				'right_sidebar' => __( 'Right Sidebar', 'electromix' ),
				'no_sidebar' 	=> __( 'No Sidebar', 'electromix' ),
			) 
		) 
	);
	
	
	// Blog Page
	$wp_customize->add_setting( 
		'electromix_blog_pg_sidebar' , 
			array(
			'default' => 'right_sidebar',
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'electromix_sanitize_select',
			'priority' => 5,
		) 
	);

	$wp_customize->add_control(
	'electromix_blog_pg_sidebar' , 
		array(
			'label'          => __( 'Blog Page Sidebar Option', 'electromix' ),
			'section'        => 'electromix_sidebar',
			'type'           => 'select',
			'choices'        => 
			array(
				'left_sidebar' 	=> __( 'Left Sidebar', 'electromix' ),
				'right_sidebar' => __( 'Right Sidebar', 'electromix' ),
				'no_sidebar' 	=> __( 'No Sidebar', 'electromix' ),
			) 
		) 
	);
	
	// Search Page
	$wp_customize->add_setting( 
		'electromix_search_pg_sidebar' , 
			array(
			'default' => 'right_sidebar',
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'electromix_sanitize_select',
			'priority' => 5,
		) 
	);

	$wp_customize->add_control(
	'electromix_search_pg_sidebar' , 
		array(
			'label'          => __( 'Search Page Sidebar Option', 'electromix' ),
			'section'        => 'electromix_sidebar',
			'type'           => 'select',
			'choices'        => 
			array(
				'left_sidebar' 	=> __( 'Left Sidebar', 'electromix' ),
				'right_sidebar' => __( 'Right Sidebar', 'electromix' ),
				'no_sidebar' 	=> __( 'No Sidebar', 'electromix' ),
			) 
		) 
	);
	
	
	// WooCommerce Page
	$wp_customize->add_setting( 
		'electromix_shop_pg_sidebar' , 
			array(
			'default' => 'right_sidebar',
			'capability'     => 'edit_theme_options',
			'sanitize_callback' => 'electromix_sanitize_select',
			'priority' => 6,
		) 
	);

	$wp_customize->add_control(
	'electromix_shop_pg_sidebar' , 
		array(
			'label'          => __( 'WooCommerce Page Sidebar Option', 'electromix' ),
			'section'        => 'electromix_sidebar',
			'type'           => 'select',
			'choices'        => 
			array(
				'left_sidebar' 	=> __( 'Left Sidebar', 'electromix' ),
				'right_sidebar' => __( 'Right Sidebar', 'electromix' ),
				'no_sidebar' 	=> __( 'No Sidebar', 'electromix' ),
			) 
		) 
	);
	
	// Pro Upgrade
	if ( class_exists( 'Ecommerce_Comp_Customizer' ) ) {
	class  Electromix_sidebar__section_upgrade extends WP_Customize_Control {
		public function render_content() { 
			$theme = wp_get_theme(); // gets the current theme	
			
		?>
			<a class="customizer_sidebar_upgrade_section up-to-pro" style="padding:9px 0; text-align:center;" href="<?php echo electromix_premium_links(); ?>" target="_blank"><?php esc_html_e('Upgrade To Pro For More','electromix'); ?></a>
			
		<?php }
	}
	
	$wp_customize->add_setting( 'sidebar_upgrade_to_pro', array(
		'capability'			=> 'edit_theme_options',
		'electromix_sanitize_callback'	=> 'wp_filter_nohtml_kses',
		'priority' => 5,
	));
	$wp_customize->add_control(
		new  Electromix_sidebar__section_upgrade(
		$wp_customize,
		'sidebar_upgrade_to_pro',
			array(
				'section'				=> 'electromix_sidebar',
			)
		)
	);
	}
	
	// Widget options
	$wp_customize->add_setting(
		'sidebar_options'
			,array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'electromix_sanitize_text',
			'priority'  => 6
		)
	);

	$wp_customize->add_control(
	'sidebar_options',
		array(
			'type' => 'hidden',
			'label' => __('Options','electromix'),
			'section' => 'electromix_sidebar',
		)
	);
	// Sidebar Width 
	if ( class_exists( 'Ecommerce_Comp_Customizer_Range_Control' ) ) {
		$wp_customize->add_setting(
			'electromix_sidebar_width',
			array(
				'default'	      => esc_html__( '33', 'electromix' ),
				'capability'     	=> 'edit_theme_options',
				'sanitize_callback' => 'ecommerce_comp_sanitize_range_value',
				'transport'         => 'postMessage',
				'priority'  => 7
			)
		);
		$wp_customize->add_control( 
		new Ecommerce_Comp_Customizer_Range_Control( $wp_customize, 'electromix_sidebar_width', 
			array(
				'label'      => __( 'Sidebar Width', 'electromix' ),
				'section'  => 'electromix_sidebar',
				'media_query'   => false,
                'input_attr'    => array(                    
                        'min'           => 25,
                        'max'           => 50,
                        'step'          => 1,
                        'default_value' => 33,
				)
				),
			 ) 
		);
	}
	
	// Widget Typography
	$wp_customize->add_setting(
		'sidebar_typography'
			,array(
			'capability'     	=> 'edit_theme_options',
			'sanitize_callback' => 'electromix_sanitize_text',
		)
	);

	$wp_customize->add_control(
	'sidebar_typography',
		array(
			'type' => 'hidden',
			'label' => __('Typography','electromix'),
			'section' => 'electromix_sidebar',
			'priority'  => 21,
		)
	);
	
	// Widget Title // 
	if ( class_exists( 'Ecommerce_Comp_Customizer_Range_Control' ) ) {
		$wp_customize->add_setting(
			'electromix_widget_ttl_size',
			array(
				'default' => 28,
				'capability'     	=> 'edit_theme_options',
				'sanitize_callback' => 'ecommerce_comp_sanitize_range_value',
				'transport'         => 'postMessage'
			)
		);
		$wp_customize->add_control( 
		new Ecommerce_Comp_Customizer_Range_Control( $wp_customize, 'electromix_widget_ttl_size', 
			array(
				'label'      => __( 'Widget Title Font Size', 'electromix' ),
				'section'  => 'electromix_sidebar',
				'priority'  => 23,
				'media_query'   => false,
                'input_attr'    => array(                    
                        'min'           => 25,
                        'max'           => 100,
                        'step'          => 1,
                        'default_value' => 28,
				)
			) ) 
		);
	}
}

add_action( 'customize_register', 'electromix_general_setting' );
