<?php

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

			$wp_customize->add_control(
				new digital_Customizer_Heading_Control(
					$wp_customize,
					'digital_header_heading',
					array(
						'label'    => esc_html__( 'Choose Ticker Style', 'digital' ),
						'section'  => 'digital_ticker_set',
						'priority' => 15,
					)));
			$wp_customize->add_setting(
			'digital_newsticker_style',
			array(
				'default'           => 'styleone',
				'type'              => 'theme_mod',
				'sanitize_callback' => 'digital_customize_sanitize_select',
				'capability'        => 'edit_theme_options',
			)
		);

		$wp_customize->add_control(
			new digital_Image_Radio_Control(
				$wp_customize,
				'digital_newsticker_style',
				array(
					'label'       => __( 'Ticker Style', 'digital' ),
					'description' => __( 'Choose News Ticker Style. After Choosing & Publish You need to REFRESH Website', 'digital' ),
					'section'     => 'digital_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( 'digital_authorprofile_style_priority', 20 ),
				)
			));
		
		$wp_customize->add_setting(
				'digital_ticker_headingset',
				array(
					'sanitize_callback' => 'wp_kses',
				));

			$wp_customize->add_control(
				new digital_Customizer_Heading_Control(
					$wp_customize,
					'digital_ticker_headingset',
					array(
						'label'    => esc_html__( 'Ticker Settings', 'digital' ),
						'section'  => 'digital_ticker_set',
						'priority' => 25,
					)));
		
		$wp_customize->add_setting('digital_newticker_on',	
			array(
				'default'			=> 'enable',
				'type'				=> 'theme_mod',
				'capability'		=> 'edit_theme_options',
				'sanitize_callback'	=> 'digital_customize_sanitize_select'
			));
		$wp_customize->add_control('digital_newticker_on',
			 array (                             
				'type' => 'radio',
				'label' => __('Enable or Disable News Ticker','digital'),
				'settings'   => 'digital_newticker_on',
				'section' => 'digital_ticker_set',
				'transport'   => 'refresh',
				'choices' => array(
					'enable' => __('Enable','digital'),
					'disable' => __('Disable','digital'),
				 ),
				 'priority'    => apply_filters( 'digital_newticker_on_priority', 30 ),
			 ));
		
		
		// Ticker Posts Count	
		$wp_customize->add_setting('digital_tickerpost_number',array(
			'default'		=> '5',
			'sanitize_callback'	=> 'absint'
		));
		$wp_customize->add_control('digital_tickerpost_number',array(
			'section' => 'digital_ticker_set',
			'label'	=> __('Numbers of Posts to show','digital'),
			'settings' => 'digital_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', 'digital');

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

	$wp_customize->add_control('digital_ticker_cat', array(
		'settings' => 'digital_ticker_cat',
		'label'    => __('Choose Category', 'digital'),
		'type'     => 'select',
		'choices'  => $cats,
		'section'  => 'digital_ticker_set', // Depending on where you want it to be
		'priority' => 35,
	));
		
		//News Ticker Label Name
		$wp_customize->add_setting('digital_tickerlabel_text',
		array(
			'default'		=> 'News Ticker',
			'sanitize_callback'	=> 'sanitize_text_field'
			));	
		$wp_customize->add_control('digital_tickerlabel_text',
		array(
			'label'       => __( 'Change Label Text', 'digital' ),
			'section' => 'digital_ticker_set',
			'settings' => 'digital_tickerlabel_text',
			'priority' => 40,
			'type' => 'text'
		));
				
		//ticker label bg
		$wp_customize->add_setting( 'digital_tickerbg' , array(
			'default'     => '#2096cd',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'digital_tickerbg', array(
		'label'        => __( 'News Ticker Label Area', 'digital' ),
		'description'        => __( 'News Ticker Label Background Color', 'digital' ),
		'section'    => 'digital_ticker_set',
		'settings'   => 'digital_tickerbg',
		'priority' => 45,
		) ) );
		//ticker label text
		$wp_customize->add_setting( 'digital_tickerlabelfont' , array(
			'default'     => '#ffffff',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'digital_tickerlabelfont', 
		array(		
		'description'        => __( 'News Ticker Label Font Color', 'digital' ),
		'section'    => 'digital_ticker_set',
		'settings'   => 'digital_tickerlabelfont',
		'priority' => 50,
		) ) );
		//ticker Post BG
		$wp_customize->add_setting( 'digital_tickerpostbg' , array(
			'default'     => '#ffffff',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'digital_tickerpostbg', 
		array(		
		'description'        => __( 'Ticker Posts Background', 'digital' ),
		'section'    => 'digital_ticker_set',
		'settings'   => 'digital_tickerpostbg',
		'priority' => 55,
		) ) );
		//ticker Post BG
		$wp_customize->add_setting( 'digital_tickerpostlink' , array(
			'default'     => '#5533ff',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'digital_tickerpostlink', 
		array(		
		'description'        => __( 'Ticker Posts Links Color', 'digital' ),
		'section'    => 'digital_ticker_set',
		'settings'   => 'digital_tickerpostlink',
		'priority' => 60,
		) ) );
		
		/***************
		*Style Two
		***************/
		//ticker label bg
		$wp_customize->add_setting( 'digital_tickerbg_two' , array(
			'default'     => '#F44336',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'digital_tickerbg_two', array(
		'label'        => __( 'News Ticker Two', 'digital' ),
		'description'        => __( 'News Ticker Label Background Color', 'digital' ),
		'section'    => 'digital_ticker_set',
		'settings'   => 'digital_tickerbg_two',
		'priority' => 45,
		) ) );
		//ticker label text
		$wp_customize->add_setting( 'digital_tickerlabelfont_two' , array(
			'default'     => '#ffffff',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'digital_tickerlabelfont_two', 
		array(		
		'description'        => __( 'News Ticker Label Font Color', 'digital' ),
		'section'    => 'digital_ticker_set',
		'settings'   => 'digital_tickerlabelfont_two',
		'priority' => 50,
		) ) );
		//ticker Post BG
		$wp_customize->add_setting( 'digital_tickerpostbg_two' , array(
			'default'     => '#f8f0db',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'digital_tickerpostbg_two', 
		array(		
		'description'        => __( 'Ticker Posts Background', 'digital' ),
		'section'    => 'digital_ticker_set',
		'settings'   => 'digital_tickerpostbg_two',
		'priority' => 55,
		) ) );
		//ticker Post BG
		$wp_customize->add_setting( 'digital_tickerpostlink_two' , array(
			'default'     => '#1F527B',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'digital_tickerpostlink_two', 
		array(		
		'description'        => __( 'Ticker Posts Links Color', 'digital' ),
		'section'    => 'digital_ticker_set',
		'settings'   => 'digital_tickerpostlink_two',
		'priority' => 60,
		) ) );
		/***************
		*Style three
		***************/
		//ticker label bg
		$wp_customize->add_setting( 'digital_tickerbg_three' , array(
			'default'     => '#F44336',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'digital_tickerbg_three', array(
		'label'        => __( 'News Ticker Two', 'digital' ),
		'description'        => __( 'News Ticker Label Background Color', 'digital' ),
		'section'    => 'digital_ticker_set',
		'settings'   => 'digital_tickerbg_three',
		'priority' => 45,
		) ) );
		//ticker label text
		$wp_customize->add_setting( 'digital_tickerlabelfont_three' , array(
			'default'     => '#ffffff',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'digital_tickerlabelfont_three', 
		array(		
		'description'        => __( 'News Ticker Label Font Color', 'digital' ),
		'section'    => 'digital_ticker_set',
		'settings'   => 'digital_tickerlabelfont_three',
		'priority' => 50,
		) ) );
		//ticker Post BG
		$wp_customize->add_setting( 'digital_tickerpostbg_three' , array(
			'default'     => '#0d1726',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'digital_tickerpostbg_three', 
		array(		
		'description'        => __( 'Ticker Posts Background', 'digital' ),
		'section'    => 'digital_ticker_set',
		'settings'   => 'digital_tickerpostbg_three',
		'priority' => 55,
		) ) );
		//ticker Post BG
		$wp_customize->add_setting( 'digital_tickerpostlink_three' , array(
			'default'     => '#ffffff',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'digital_tickerpostlink_three', 
		array(		
		'description'        => __( 'Ticker Posts Links Color', 'digital' ),
		'section'    => 'digital_ticker_set',
		'settings'   => 'digital_tickerpostlink_three',
		'priority' => 60,
		) ) );
		// Tiker speed
		$wp_customize->add_setting('digital_tickerspeed_three', array(
			'default'           => 10,
			'transport'         => 'refresh',
			'sanitize_callback' => 'absint', // Sanitize as integer
		));

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

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