<?php

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

			$wp_customize->add_control(
				new wrockmetro_Customizer_Heading_Control(
					$wp_customize,
					'wrockmetro_header_heading',
					array(
						'label'    => esc_html__( 'Choose Ticker Style', 'wrock-metro' ),
						'section'  => 'wrockmetro_ticker_set',
						'priority' => 15,
					)));
			$wp_customize->add_setting(
			'wrockmetro_newsticker_style',
			array(
				'default'           => 'styleone',
				'type'              => 'theme_mod',
				'sanitize_callback' => 'wrockmetro_customize_sanitize_select',
				'capability'        => 'edit_theme_options',
			)
		);

		$wp_customize->add_control(
			new wrockmetro_Image_Radio_Control(
				$wp_customize,
				'wrockmetro_newsticker_style',
				array(
					'label'       => __( 'Ticker Style', 'wrock-metro' ),
					'description' => __( 'Choose News Ticker Style. After Choosing & Publish You need to REFRESH Website', 'wrock-metro' ),
					'section'     => 'wrockmetro_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( 'wrockmetro_authorprofile_style_priority', 20 ),
				)
			));
		
		$wp_customize->add_setting(
				'wrockmetro_ticker_headingset',
				array(
					'sanitize_callback' => 'wp_kses',
				));

			$wp_customize->add_control(
				new wrockmetro_Customizer_Heading_Control(
					$wp_customize,
					'wrockmetro_ticker_headingset',
					array(
						'label'    => esc_html__( 'Ticker Settings', 'wrock-metro' ),
						'section'  => 'wrockmetro_ticker_set',
						'priority' => 25,
					)));
		
		$wp_customize->add_setting('wrockmetro_newticker_on',	
			array(
				'default'			=> 'enable',
				'type'				=> 'theme_mod',
				'capability'		=> 'edit_theme_options',
				'sanitize_callback'	=> 'wrockmetro_customize_sanitize_select'
			));
		$wp_customize->add_control('wrockmetro_newticker_on',
			 array (                             
				'type' => 'radio',
				'label' => __('Enable or Disable News Ticker','wrock-metro'),
				'settings'   => 'wrockmetro_newticker_on',
				'section' => 'wrockmetro_ticker_set',
				'transport'   => 'refresh',
				'choices' => array(
					'enable' => __('Enable','wrock-metro'),
					'disable' => __('Disable','wrock-metro'),
				 ),
				 'priority'    => apply_filters( 'wrockmetro_newticker_on_priority', 30 ),
			 ));
		
		
		// Ticker Posts Count	
		$wp_customize->add_setting('wrockmetro_tickerpost_number',array(
			'default'		=> '5',
			'sanitize_callback'	=> 'absint'
		));
		$wp_customize->add_control('wrockmetro_tickerpost_number',array(
			'section' => 'wrockmetro_ticker_set',
			'label'	=> __('Numbers of Posts to show','wrock-metro'),
			'settings' => 'wrockmetro_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', 'wrock-metro');

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

	$wp_customize->add_control('wrockmetro_ticker_cat', array(
		'settings' => 'wrockmetro_ticker_cat',
		'label'    => __('Choose Category', 'wrock-metro'),
		'type'     => 'select',
		'choices'  => $cats,
		'section'  => 'wrockmetro_ticker_set', // Depending on where you want it to be
		'priority' => 35,
	));
		
		//News Ticker Label Name
		$wp_customize->add_setting('wrockmetro_tickerlabel_text',
		array(
			'default'		=> 'News Ticker',
			'sanitize_callback'	=> 'sanitize_text_field'
			));	
		$wp_customize->add_control('wrockmetro_tickerlabel_text',
		array(
			'label'       => __( 'Change Label Text', 'wrock-metro' ),
			'section' => 'wrockmetro_ticker_set',
			'settings' => 'wrockmetro_tickerlabel_text',
			'priority' => 40,
			'type' => 'text'
		));
				
		//ticker label bg
		$wp_customize->add_setting( 'wrockmetro_tickerbg' , array(
			'default'     => '#f44a56',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'wrockmetro_tickerbg', array(
		'label'        => __( 'News Ticker Label Area', 'wrock-metro' ),
		'description'        => __( 'News Ticker Label Background Color', 'wrock-metro' ),
		'section'    => 'wrockmetro_ticker_set',
		'settings'   => 'wrockmetro_tickerbg',
		'priority' => 45,
		) ) );
		//ticker label text
		$wp_customize->add_setting( 'wrockmetro_tickerlabelfont' , array(
			'default'     => '#ffffff',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'wrockmetro_tickerlabelfont', 
		array(		
		'description'        => __( 'News Ticker Label Font Color', 'wrock-metro' ),
		'section'    => 'wrockmetro_ticker_set',
		'settings'   => 'wrockmetro_tickerlabelfont',
		'priority' => 50,
		) ) );
		//ticker Post BG
		$wp_customize->add_setting( 'wrockmetro_tickerpostbg' , array(
			'default'     => '#ffffff',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'wrockmetro_tickerpostbg', 
		array(		
		'description'        => __( 'Ticker Posts Background', 'wrock-metro' ),
		'section'    => 'wrockmetro_ticker_set',
		'settings'   => 'wrockmetro_tickerpostbg',
		'priority' => 55,
		) ) );
		//ticker Post BG
		$wp_customize->add_setting( 'wrockmetro_tickerpostlink' , array(
			'default'     => '#5533ff',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'wrockmetro_tickerpostlink', 
		array(		
		'description'        => __( 'Ticker Posts Links Color', 'wrock-metro' ),
		'section'    => 'wrockmetro_ticker_set',
		'settings'   => 'wrockmetro_tickerpostlink',
		'priority' => 60,
		) ) );
		
		/***************
		*Style Two
		***************/
		//ticker label bg
		$wp_customize->add_setting( 'wrockmetro_tickerbg_two' , array(
			'default'     => '#F44336',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'wrockmetro_tickerbg_two', array(
		'label'        => __( 'News Ticker Two (Pro Only)', 'wrock-metro' ),
		'description'        => __( 'News Ticker Label Background Color', 'wrock-metro' ),
		'section'    => 'wrockmetro_ticker_set',
		'settings'   => 'wrockmetro_tickerbg_two',
		'priority' => 45,
		) ) );
		//ticker label text
		$wp_customize->add_setting( 'wrockmetro_tickerlabelfont_two' , array(
			'default'     => '#ffffff',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'wrockmetro_tickerlabelfont_two', 
		array(		
		'description'        => __( 'News Ticker Label Font Color (Pro Only)', 'wrock-metro' ),
		'section'    => 'wrockmetro_ticker_set',
		'settings'   => 'wrockmetro_tickerlabelfont_two',
		'priority' => 50,
		) ) );
		//ticker Post BG
		$wp_customize->add_setting( 'wrockmetro_tickerpostbg_two' , array(
			'default'     => '#f8f0db',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'wrockmetro_tickerpostbg_two', 
		array(		
		'description'        => __( 'Ticker Posts Background (Pro Only)', 'wrock-metro' ),
		'section'    => 'wrockmetro_ticker_set',
		'settings'   => 'wrockmetro_tickerpostbg_two',
		'priority' => 55,
		) ) );
		//ticker Post BG
		$wp_customize->add_setting( 'wrockmetro_tickerpostlink_two' , array(
			'default'     => '#1F527B',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'wrockmetro_tickerpostlink_two', 
		array(		
		'description'        => __( 'Ticker Posts Links Color (Pro Only)', 'wrock-metro' ),
		'section'    => 'wrockmetro_ticker_set',
		'settings'   => 'wrockmetro_tickerpostlink_two',
		'priority' => 60,
		) ) );
		/***************
		*Style three
		***************/
		//ticker label bg
		$wp_customize->add_setting( 'wrockmetro_tickerbg_three' , array(
			'default'     => '#F44336',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'wrockmetro_tickerbg_three', array(
		'label'        => __( 'News Ticker Three (Pro Only)', 'wrock-metro' ),
		'description'        => __( 'News Ticker Label Background Color', 'wrock-metro' ),
		'section'    => 'wrockmetro_ticker_set',
		'settings'   => 'wrockmetro_tickerbg_three',
		'priority' => 45,
		) ) );
		//ticker label text
		$wp_customize->add_setting( 'wrockmetro_tickerlabelfont_three' , array(
			'default'     => '#ffffff',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'wrockmetro_tickerlabelfont_three', 
		array(		
		'description'        => __( 'News Ticker Label Font Color (Pro Only)', 'wrock-metro' ),
		'section'    => 'wrockmetro_ticker_set',
		'settings'   => 'wrockmetro_tickerlabelfont_three',
		'priority' => 50,
		) ) );
		//ticker Post BG
		$wp_customize->add_setting( 'wrockmetro_tickerpostbg_three' , array(
			'default'     => '#0d1726',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'wrockmetro_tickerpostbg_three', 
		array(		
		'description'        => __( 'Ticker Posts Background (Pro Only)', 'wrock-metro' ),
		'section'    => 'wrockmetro_ticker_set',
		'settings'   => 'wrockmetro_tickerpostbg_three',
		'priority' => 55,
		) ) );
		//ticker Post BG
		$wp_customize->add_setting( 'wrockmetro_tickerpostlink_three' , array(
			'default'     => '#ffffff',
			'transport'   => 'refresh',
			'sanitize_callback'	=> 'sanitize_hex_color',
		) );
		$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'wrockmetro_tickerpostlink_three', 
		array(		
		'description'        => __( 'Ticker Posts Links Color (Pro Only)', 'wrock-metro' ),
		'section'    => 'wrockmetro_ticker_set',
		'settings'   => 'wrockmetro_tickerpostlink_three',
		'priority' => 60,
		) ) );
		// Tiker speed
		$wp_customize->add_setting('wrockmetro_tickerspeed_three', array(
			'default'           => 10,
			'transport'         => 'refresh',
			'sanitize_callback' => 'absint', // Sanitize as integer
		));

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

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