<?php

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
/*********************
News Ticker settings.
*******************/
	$wp_customize->add_section('magazinestyle_ticker_set',
		array(
			'title'       => __( 'News Ticker', 'magazine-style' ),
			'capability'  => 'edit_theme_options',						
			'panel'			=> 'magazinestyle_theme_elements',
		));		
		
		$wp_customize->add_setting(
				'magazinestyle_header_heading',
				array(
					'sanitize_callback' => 'wp_kses',
				));

			$wp_customize->add_control(
				new magazinestyle_Customizer_Heading_Control(
					$wp_customize,
					'magazinestyle_header_heading',
					array(
						'label'    => esc_html__( 'Choose Ticker Style', 'magazine-style' ),
						'section'  => 'magazinestyle_ticker_set',
						'priority' => 15,
					)));
			$wp_customize->add_setting(
			'magazinestyle_newsticker_style',
			array(
				'default'           => 'stylethree',
				'type'              => 'theme_mod',
				'sanitize_callback' => 'magazinestyle_customize_sanitize_select',
				'capability'        => 'edit_theme_options',
			)
		);

		$wp_customize->add_control(
			new magazinestyle_Image_Radio_Control(
				$wp_customize,
				'magazinestyle_newsticker_style',
				array(
					'label'       => __( 'Ticker Style', 'magazine-style' ),
					'description' => __( 'Choose News Ticker Style. After Choosing & Publish You need to REFRESH Website', 'magazine-style' ),
					'section'     => 'magazinestyle_ticker_set',
					'choices'     => array(
						'styleone'  => get_template_directory_uri() . '/images/newsticker/newstickerone.png',
						'styletwo' => get_template_directory_uri() . '/images/newsticker/newstickertwo.png',
						'stylethree' => get_template_directory_uri() . '/images/newsticker/newstickerthree.png',
					),
					'priority'    => apply_filters( 'magazinestyle_authorprofile_style_priority', 20 ),
				)
			));
		
		$wp_customize->add_setting(
				'magazinestyle_ticker_headingset',
				array(
					'sanitize_callback' => 'wp_kses',
				));

			$wp_customize->add_control(
				new magazinestyle_Customizer_Heading_Control(
					$wp_customize,
					'magazinestyle_ticker_headingset',
					array(
						'label'    => esc_html__( 'Ticker Settings', 'magazine-style' ),
						'section'  => 'magazinestyle_ticker_set',
						'priority' => 25,
					)));
		
		$wp_customize->add_setting('magazinestyle_newticker_on',	
			array(
				'default'			=> 'enable',
				'type'				=> 'theme_mod',
				'capability'		=> 'edit_theme_options',
				'sanitize_callback'	=> 'magazinestyle_customize_sanitize_select'
			));
		$wp_customize->add_control('magazinestyle_newticker_on',
			 array (                             
				'type' => 'radio',
				'label' => __('Enable or Disable News Ticker','magazine-style'),
				'settings'   => 'magazinestyle_newticker_on',
				'section' => 'magazinestyle_ticker_set',
				'transport'   => 'refresh',
				'choices' => array(
					'enable' => __('Enable','magazine-style'),
					'disable' => __('Disable','magazine-style'),
				 ),
				 'priority'    => apply_filters( 'magazinestyle_newticker_on_priority', 30 ),
			 ));
		
		
		// Ticker Posts Count	
		$wp_customize->add_setting('magazinestyle_tickerpost_number',array(
			'default'		=> '5',
			'sanitize_callback'	=> 'absint'
		));
		$wp_customize->add_control('magazinestyle_tickerpost_number',array(
			'section' => 'magazinestyle_ticker_set',
			'label'	=> __('Numbers of Posts to show','magazine-style'),
			'settings' => 'magazinestyle_tickerpost_number',
			'priority' => 35,
			'type' => 'number'
		));
		
		// Ticker Categories
		// Get categories
	$categories = get_categories();

	// Prepare categories for dropdown
	$cats = array();
	foreach ($categories as $category) {
		$cats[$category->term_id] = $category->name;
	}

	// Add an "All Categories" option
	$cats['all'] = __('All Categories', 'magazine-style');

	$wp_customize->add_setting('magazinestyle_ticker_cat', array(
		'default'            => 'all', // Set the default value to 'all'
		'sanitize_callback'  => 'sanitize_text_field' // Use appropriate sanitization
	));

	$wp_customize->add_control('magazinestyle_ticker_cat', array(
		'settings' => 'magazinestyle_ticker_cat',
		'label'    => __('Choose Category', 'magazine-style'),
		'type'     => 'select',
		'choices'  => $cats,
		'section'  => 'magazinestyle_ticker_set', // Depending on where you want it to be
		'priority' => 35,
	));
		
		//News Ticker Label Name
		$wp_customize->add_setting('magazinestyle_tickerlabel_text',
		array(
			'default'		=> 'News Ticker',
			'sanitize_callback'	=> 'sanitize_text_field'
			));	
		$wp_customize->add_control('magazinestyle_tickerlabel_text',
		array(
			'label'       => __( 'Change Label Text', 'magazine-style' ),
			'section' => 'magazinestyle_ticker_set',
			'settings' => 'magazinestyle_tickerlabel_text',
			'priority' => 40,
			'type' => 'text'
		));

		$wp_customize->add_setting('magazinestyle_ticker_location', array(
			'default' => 'all_pages',
			'sanitize_callback' => 'sanitize_text_field',
		));
		
		$wp_customize->add_control('magazinestyle_ticker_location', array(
			'label' => __('Visiblity on Page Types', 'magazine-style'),
			'section' => 'magazinestyle_ticker_set',
			'type' => 'select',
			'choices' => array(
				'all_pages' => __('Everywhere', 'magazine-style'),
				'single' => __('Single Posts', 'magazine-style'),
				'page' => __('Pages', 'magazine-style'),
				'archive' => __('Archive Pages', 'magazine-style'),
				'index' => __('Index and Home', 'magazine-style'),
			),
			'priority'    => apply_filters( 'magazinestyle_ticker_location_priority', 40 ),
		));	

		// Tiker speed
		$wp_customize->add_setting('magazinestyle_tickerspeed_three', array(
			'default'           => 10,
			'transport'         => 'refresh',
			'sanitize_callback' => 'absint', // Sanitize as integer
		));

		$wp_customize->add_control('magazinestyle_tickerspeed_three', array(
			'type'        => 'range',
			'section'     => 'magazinestyle_ticker_set',
			'settings'    => 'magazinestyle_tickerspeed_three',
			'description' => __('Ticker Speed', 'magazine-style'),
			'priority' => 40,
			'input_attrs' => array(
				'min'  => 1,
				'max'  => 100,
				'step' => 2,
			),
		));
		$wp_customize->add_setting(
			'magazinestyle_tickercolor_heading',
			array(
				'sanitize_callback' => 'wp_kses',
			));

		$wp_customize->add_control(
			new magazinestyle_Customizer_Heading_Control(
				$wp_customize,
				'magazinestyle_tickercolor_heading',
				array(
					'label'    => esc_html__( 'Color Settings (Pro Only)', 'magazine-style' ),
					'section'  => 'magazinestyle_ticker_set',
					'priority' => 40,
				)));
				
		//ticker label bg
		$wp_customize->add_setting( 'magazinestyle_tickerbg' , array(
			'default'     => '#2096cd',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'magazinestyle_tickerbg', array(
		'label'        => __( 'News Ticker Label Area', 'magazine-style' ),
		'description'        => __( 'News Ticker Label Background Color', 'magazine-style' ),
		'section'    => 'magazinestyle_ticker_set',
		'settings'   => 'magazinestyle_tickerbg',
		'priority' => 45,
		) ) );
		//ticker label text
		$wp_customize->add_setting( 'magazinestyle_tickerlabelfont' , array(
			'default'     => '#ffffff',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'magazinestyle_tickerlabelfont', 
		array(		
		'description'        => __( 'News Ticker Label Font Color', 'magazine-style' ),
		'section'    => 'magazinestyle_ticker_set',
		'settings'   => 'magazinestyle_tickerlabelfont',
		'priority' => 50,
		) ) );
		//ticker Post BG
		$wp_customize->add_setting( 'magazinestyle_tickerpostbg' , array(
			'default'     => '#ffffff',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'magazinestyle_tickerpostbg', 
		array(		
		'description'        => __( 'Ticker Posts Background', 'magazine-style' ),
		'section'    => 'magazinestyle_ticker_set',
		'settings'   => 'magazinestyle_tickerpostbg',
		'priority' => 55,
		) ) );
		//ticker Post BG
		$wp_customize->add_setting( 'magazinestyle_tickerpostlink' , array(
			'default'     => '#5533ff',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'magazinestyle_tickerpostlink', 
		array(		
		'description'        => __( 'Ticker Posts Links Color', 'magazine-style' ),
		'section'    => 'magazinestyle_ticker_set',
		'settings'   => 'magazinestyle_tickerpostlink',
		'priority' => 60,
		) ) );
		
		/***************
		*Style Two
		***************/
		//ticker label bg
		$wp_customize->add_setting( 'magazinestyle_tickerbg_two' , array(
			'default'     => '#F44336',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'magazinestyle_tickerbg_two', array(
		'label'        => __( 'News Ticker Two', 'magazine-style' ),
		'description'        => __( 'News Ticker Label Background Color', 'magazine-style' ),
		'section'    => 'magazinestyle_ticker_set',
		'settings'   => 'magazinestyle_tickerbg_two',
		'priority' => 45,
		) ) );
		//ticker label text
		$wp_customize->add_setting( 'magazinestyle_tickerlabelfont_two' , array(
			'default'     => '#ffffff',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'magazinestyle_tickerlabelfont_two', 
		array(		
		'description'        => __( 'News Ticker Label Font Color', 'magazine-style' ),
		'section'    => 'magazinestyle_ticker_set',
		'settings'   => 'magazinestyle_tickerlabelfont_two',
		'priority' => 50,
		) ) );
		//ticker Post BG
		$wp_customize->add_setting( 'magazinestyle_tickerpostbg_two' , array(
			'default'     => '#f8f0db',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'magazinestyle_tickerpostbg_two', 
		array(		
		'description'        => __( 'Ticker Posts Background', 'magazine-style' ),
		'section'    => 'magazinestyle_ticker_set',
		'settings'   => 'magazinestyle_tickerpostbg_two',
		'priority' => 55,
		) ) );
		//ticker Post BG
		$wp_customize->add_setting( 'magazinestyle_tickerpostlink_two' , array(
			'default'     => '#1F527B',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'magazinestyle_tickerpostlink_two', 
		array(		
		'description'        => __( 'Ticker Posts Links Color', 'magazine-style' ),
		'section'    => 'magazinestyle_ticker_set',
		'settings'   => 'magazinestyle_tickerpostlink_two',
		'priority' => 60,
		) ) );
		/***************
		*Style three
		***************/
		//ticker label bg
		$wp_customize->add_setting( 'magazinestyle_tickerbg_three' , array(
			'default'     => '#F44336',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'magazinestyle_tickerbg_three', array(
		'label'        => __( 'News Ticker Two', 'magazine-style' ),
		'description'        => __( 'News Ticker Label Background Color', 'magazine-style' ),
		'section'    => 'magazinestyle_ticker_set',
		'settings'   => 'magazinestyle_tickerbg_three',
		'priority' => 45,
		) ) );
		//ticker label text
		$wp_customize->add_setting( 'magazinestyle_tickerlabelfont_three' , array(
			'default'     => '#ffffff',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'magazinestyle_tickerlabelfont_three', 
		array(		
		'description'        => __( 'News Ticker Label Font Color', 'magazine-style' ),
		'section'    => 'magazinestyle_ticker_set',
		'settings'   => 'magazinestyle_tickerlabelfont_three',
		'priority' => 50,
		) ) );
		//ticker Post BG
		$wp_customize->add_setting( 'magazinestyle_tickerpostbg_three' , array(
			'default'     => '#0d1726',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'magazinestyle_tickerpostbg_three', 
		array(		
		'description'        => __( 'Ticker Posts Background', 'magazine-style' ),
		'section'    => 'magazinestyle_ticker_set',
		'settings'   => 'magazinestyle_tickerpostbg_three',
		'priority' => 55,
		) ) );
		//ticker Post BG
		$wp_customize->add_setting( 'magazinestyle_tickerpostlink_three' , array(
			'default'     => '#ffffff',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'magazinestyle_tickerpostlink_three', 
		array(		
		'description'        => __( 'Ticker Posts Links Color', 'magazine-style' ),
		'section'    => 'magazinestyle_ticker_set',
		'settings'   => 'magazinestyle_tickerpostlink_three',
		'priority' => 60,
		) ) );
