<?php

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

			$wp_customize->add_control(
				new poster_Customizer_Heading_Control(
					$wp_customize,
					'poster_header_heading',
					array(
						'label'    => esc_html__( 'Choose Ticker Style', 'poster' ),
						'section'  => 'poster_ticker_set',
						'priority' => 15,
					)));
			$wp_customize->add_setting(
			'poster_newsticker_style',
			array(
				'default'           => 'styleone',
				'type'              => 'theme_mod',
				'sanitize_callback' => 'poster_customize_sanitize_select',
				'capability'        => 'edit_theme_options',
			)
		);

		$wp_customize->add_control(
			new poster_Image_Radio_Control(
				$wp_customize,
				'poster_newsticker_style',
				array(
					'label'       => __( 'Ticker Style', 'poster' ),
					'description' => __( 'Choose News Ticker Style. After Choosing & Publish You need to REFRESH Website', 'poster' ),
					'section'     => 'poster_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( 'poster_authorprofile_style_priority', 20 ),
				)
			));
		
		$wp_customize->add_setting(
				'poster_ticker_headingset',
				array(
					'sanitize_callback' => 'wp_kses',
				));

			$wp_customize->add_control(
				new poster_Customizer_Heading_Control(
					$wp_customize,
					'poster_ticker_headingset',
					array(
						'label'    => esc_html__( 'Ticker Settings', 'poster' ),
						'section'  => 'poster_ticker_set',
						'priority' => 25,
					)));
		
		$wp_customize->add_setting('poster_newticker_on',	
			array(
				'default'			=> 'enable',
				'type'				=> 'theme_mod',
				'capability'		=> 'edit_theme_options',
				'sanitize_callback'	=> 'poster_customize_sanitize_select'
			));
		$wp_customize->add_control('poster_newticker_on',
			 array (                             
				'type' => 'radio',
				'label' => __('Enable or Disable News Ticker','poster'),
				'settings'   => 'poster_newticker_on',
				'section' => 'poster_ticker_set',
				'transport'   => 'refresh',
				'choices' => array(
					'enable' => __('Enable','poster'),
					'disable' => __('Disable','poster'),
				 ),
				 'priority'    => apply_filters( 'poster_newticker_on_priority', 30 ),
			 ));
		
		
		// Ticker Posts Count	
		$wp_customize->add_setting('poster_tickerpost_number',array(
			'default'		=> '5',
			'sanitize_callback'	=> 'absint'
		));
		$wp_customize->add_control('poster_tickerpost_number',array(
			'section' => 'poster_ticker_set',
			'label'	=> __('Numbers of Posts to show','poster'),
			'settings' => 'poster_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', 'poster');

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

	$wp_customize->add_control('poster_ticker_cat', array(
		'settings' => 'poster_ticker_cat',
		'label'    => __('Choose Category', 'poster'),
		'type'     => 'select',
		'choices'  => $cats,
		'section'  => 'poster_ticker_set', // Depending on where you want it to be
		'priority' => 35,
	));
		
		//News Ticker Label Name
		$wp_customize->add_setting('poster_tickerlabel_text',
		array(
			'default'		=> 'News Ticker',
			'sanitize_callback'	=> 'sanitize_text_field'
			));	
		$wp_customize->add_control('poster_tickerlabel_text',
		array(
			'label'       => __( 'Change Label Text', 'poster' ),
			'section' => 'poster_ticker_set',
			'settings' => 'poster_tickerlabel_text',
			'priority' => 40,
			'type' => 'text'
		));
				
		//ticker label bg
		$wp_customize->add_setting( 'poster_tickerbg' , array(
			'default'     => '#f44a56',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'poster_tickerbg', array(
		'label'        => __( 'News Ticker Label Area', 'poster' ),
		'description'        => __( 'News Ticker Label Background Color', 'poster' ),
		'section'    => 'poster_ticker_set',
		'settings'   => 'poster_tickerbg',
		'priority' => 45,
		) ) );
		//ticker label text
		$wp_customize->add_setting( 'poster_tickerlabelfont' , array(
			'default'     => '#ffffff',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'poster_tickerlabelfont', 
		array(		
		'description'        => __( 'News Ticker Label Font Color', 'poster' ),
		'section'    => 'poster_ticker_set',
		'settings'   => 'poster_tickerlabelfont',
		'priority' => 50,
		) ) );
		//ticker Post BG
		$wp_customize->add_setting( 'poster_tickerpostbg' , array(
			'default'     => '#ffffff',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'poster_tickerpostbg', 
		array(		
		'description'        => __( 'Ticker Posts Background', 'poster' ),
		'section'    => 'poster_ticker_set',
		'settings'   => 'poster_tickerpostbg',
		'priority' => 55,
		) ) );
		//ticker Post BG
		$wp_customize->add_setting( 'poster_tickerpostlink' , array(
			'default'     => '#5533ff',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'poster_tickerpostlink', 
		array(		
		'description'        => __( 'Ticker Posts Links Color', 'poster' ),
		'section'    => 'poster_ticker_set',
		'settings'   => 'poster_tickerpostlink',
		'priority' => 60,
		) ) );
		
		/***************
		*Style Two
		***************/
		//ticker label bg
		$wp_customize->add_setting( 'poster_tickerbg_two' , array(
			'default'     => '#F44336',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'poster_tickerbg_two', array(
		'label'        => __( 'News Ticker Two (Pro Only)', 'poster' ),
		'description'        => __( 'News Ticker Label Background Color', 'poster' ),
		'section'    => 'poster_ticker_set',
		'settings'   => 'poster_tickerbg_two',
		'priority' => 45,
		) ) );
		//ticker label text
		$wp_customize->add_setting( 'poster_tickerlabelfont_two' , array(
			'default'     => '#ffffff',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'poster_tickerlabelfont_two', 
		array(		
		'description'        => __( 'News Ticker Label Font Color (Pro Only)', 'poster' ),
		'section'    => 'poster_ticker_set',
		'settings'   => 'poster_tickerlabelfont_two',
		'priority' => 50,
		) ) );
		//ticker Post BG
		$wp_customize->add_setting( 'poster_tickerpostbg_two' , array(
			'default'     => '#f8f0db',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'poster_tickerpostbg_two', 
		array(		
		'description'        => __( 'Ticker Posts Background (Pro Only)', 'poster' ),
		'section'    => 'poster_ticker_set',
		'settings'   => 'poster_tickerpostbg_two',
		'priority' => 55,
		) ) );
		//ticker Post BG
		$wp_customize->add_setting( 'poster_tickerpostlink_two' , array(
			'default'     => '#1F527B',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'poster_tickerpostlink_two', 
		array(		
		'description'        => __( 'Ticker Posts Links Color (Pro Only)', 'poster' ),
		'section'    => 'poster_ticker_set',
		'settings'   => 'poster_tickerpostlink_two',
		'priority' => 60,
		) ) );
		/***************
		*Style three
		***************/
		//ticker label bg
		$wp_customize->add_setting( 'poster_tickerbg_three' , array(
			'default'     => '#F44336',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'poster_tickerbg_three', array(
		'label'        => __( 'News Ticker Three (Pro Only)', 'poster' ),
		'description'        => __( 'News Ticker Label Background Color', 'poster' ),
		'section'    => 'poster_ticker_set',
		'settings'   => 'poster_tickerbg_three',
		'priority' => 45,
		) ) );
		//ticker label text
		$wp_customize->add_setting( 'poster_tickerlabelfont_three' , array(
			'default'     => '#ffffff',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'poster_tickerlabelfont_three', 
		array(		
		'description'        => __( 'News Ticker Label Font Color (Pro Only)', 'poster' ),
		'section'    => 'poster_ticker_set',
		'settings'   => 'poster_tickerlabelfont_three',
		'priority' => 50,
		) ) );
		//ticker Post BG
		$wp_customize->add_setting( 'poster_tickerpostbg_three' , array(
			'default'     => '#0d1726',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'poster_tickerpostbg_three', 
		array(		
		'description'        => __( 'Ticker Posts Background (Pro Only)', 'poster' ),
		'section'    => 'poster_ticker_set',
		'settings'   => 'poster_tickerpostbg_three',
		'priority' => 55,
		) ) );
		//ticker Post BG
		$wp_customize->add_setting( 'poster_tickerpostlink_three' , array(
			'default'     => '#ffffff',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'poster_tickerpostlink_three', 
		array(		
		'description'        => __( 'Ticker Posts Links Color (Pro Only)', 'poster' ),
		'section'    => 'poster_ticker_set',
		'settings'   => 'poster_tickerpostlink_three',
		'priority' => 60,
		) ) );
		// Tiker speed
		$wp_customize->add_setting('poster_tickerspeed_three', array(
			'default'           => 10,
			'transport'         => 'refresh',
			'sanitize_callback' => 'absint', // Sanitize as integer
		));

		$wp_customize->add_control('poster_tickerspeed_three', array(
			'type'        => 'range',
			'section'     => 'poster_ticker_set',
			'settings'    => 'poster_tickerspeed_three',
			'description' => __('Ticker Speed', 'poster'),
			'priority' => 65,
			'input_attrs' => array(
				'min'  => 1,
				'max'  => 100,
				'step' => 2,
			),
		));

		$wp_customize->add_setting('poster_ticker_location', array(
			'default' => 'all_pages',
			'sanitize_callback' => 'sanitize_text_field',
		));
		
		$wp_customize->add_control('poster_ticker_location', array(
			'label' => __('Visiblity on Page Types', 'poster'),
			'section' => 'poster_ticker_set',
			'type' => 'select',
			'choices' => array(
				'all_pages' => __('Everywhere', 'poster'),
				'single' => __('Single Posts', 'poster'),
				'page' => __('Pages', 'poster'),
				'archive' => __('Archive Pages', 'poster'),
				'index' => __('Index and Home', 'poster'),
			),
			'priority'    => apply_filters( 'poster_ticker_location_priority', 100 ),
		));	