<?php 
/**
 * News Ticker
 */
Kirki::add_section( 'news_sticker_section', array(
	'title'    => esc_html__( 'News Sticker', 'newshit' ),
	'panel'    => 'newshit_front_page_options',
) );

new \Kirki\Field\Radio_Image(
	[
		'settings'    => 'sticker_pro',
		'label'       => esc_html__( 'Only Enable For Free Version', 'newshit' ),
		'description' => newshit_purchase_link(),
		'section'     => 'news_sticker_section',
		'default'     => '',
		'transport'   => 'auto',
		'priority'        => 1,
		'choices'     => [
			'sticker_pro_img'   => get_template_directory_uri() . '/assets/image/pro/sticker.jpg',
		],
	]
);


// Braking News Text
new \Kirki\Field\Text(
	[
		'settings' => 'braking_news',
		'label'    => esc_html__( 'Braking News Text', 'newshit' ),
		'section'  => 'news_sticker_section',
		'default'  => esc_html__( 'Braking News', 'newshit' ),
		'priority'        => 1,
		'active_callback' => [
			[
				'setting'  => 'enable_news_sticker',
				'operator' => '===',
				'value'    => true,
			],
		], 
		'partial_refresh'    => [
			'braking_news_refresh' => [
				'selector'        => '.acme-news-ticker-label',
				'render_callback' => 'newshit_customizer_quickedit',
			],
		],
	]
);

new \Kirki\Field\Select(
	[
		'settings'    => 'sticker_post_type',
		'label'       => esc_html__( 'Select Post Type', 'newshit' ),
		'section'     => 'news_sticker_section',
		'description' => esc_html__( 'Select Your Post Type Blog Post Or Web Stories', 'newshit' ),
		'default'     => 'post',
		'priority'        => 1,
		'choices'     => [
			'post' => esc_html__( 'Blog Post', 'newshit' ),
			'web-story' => esc_html__( 'Web Stories', 'newshit' ),
		],
		'active_callback' => [
			[
				'setting'  => 'enable_news_sticker',
				'operator' => '===',
				'value'    => true,
			],
		], 
	]
);


// Start Web Stories Filter

if ( is_plugin_active( 'web-stories/web-stories.php' ) ) {
	new \Kirki\Field\Radio_Image(
		[
			'settings'    => 'sticker_story_pro',
			'label'       => esc_html__( 'This Featured For Pro', 'newshit' ),
			'description' => newshit_purchase_link(),
			'section'     => 'news_sticker_section',
			'default'     => '',
			'transport'   => 'auto',
			'priority'        => 1,
			'choices'     => [
				'sticker_pro_img'   => get_template_directory_uri() . '/assets/image/pro/story.jpg',
			],
			'active_callback' => [
				[
					'setting'  => 'enable_news_sticker',
					'operator' => '===',
					'value'    => true,
				],
				[
					'setting'  => 'sticker_post_type',
					'operator' => '===',
					'value'    => 'web-story',
				],
			],
		]
	);
	
	// End Web Stories Filter 
}else{
	new \Kirki\Field\Radio_Image(
		[
			'settings'    => 'news_sticker_no_plugine',
			'label'       => esc_html__( 'You Have No Active Or Install Web Stories Plugin ', 'newshit' ),
			'section'     => 'news_sticker_section',
			'default'     => '',
			'transport'   => 'auto',
			'active_callback' => [
				[
					'setting'  => 'enable_news_sticker',
					'operator' => '===',
					'value'    => true,
				],
				[
					'setting'  => 'sticker_post_type',
					'operator' => '===',
					'value'    => 'web-story',
				],
			],
		]
	);
}


// Post Filter Options 

Kirki::add_field( 'theme_config', [
	'type'        => 'switch',
	'settings'    => 'enable_sticker_filter',
	'label'       => esc_html__( 'Enable Post Filter', 'newshit' ),
	'section'     => 'news_sticker_section',
	'default'     => 'off',
	'choices'     => [
		'on'  => esc_html__( 'Enable', 'newshit' ),
		'off' => esc_html__( 'Disable', 'newshit' ),
	],
	'active_callback' => [
		[
			'setting'  => 'enable_news_sticker',
			'operator' => '===',
			'value'    => true,
		],
		[
			'setting'  => 'sticker_post_type',
			'operator' => '===',
			'value'    => 'post',
		],
	],
] );

new \Kirki\Field\Select(
	[
		'settings'    => 'sticker_filter_select',
		'label'       => esc_html__( 'Select Category Or Tags', 'newshit' ),
		'section'     => 'news_sticker_section',
		'default'     => 'one',
		'choices'     => [
			'one' => esc_html__( 'Category', 'newshit' ),
			'two' => esc_html__( 'Tags', 'newshit' ),
		],
		'active_callback' => [
			[
				'setting'  => 'enable_sticker_filter',
				'operator' => '===',
				'value'    => true,
			],
			[
				'setting'  => 'enable_news_sticker',
				'operator' => '===',
				'value'    => true,
			],
			[
				'setting'  => 'sticker_post_type',
				'operator' => '===',
				'value'    => 'post',
			],
		], 
	]
);

new Kirki\Field\Select(
	[
		'settings'    => 'sticker_filter_cat',
		'label'       => __( 'Select Categroy', 'newshit' ),
		'section'     => 'news_sticker_section',
		'default'     => '',
		'multiple'    => -1,
		'placeholder' => __( 'Select an Categorys', 'newshit' ),
		'choices'     => Kirki\Util\Helper::get_terms(array('taxonomy' => 'category')),
		'active_callback' => [
			[
				'setting'  => 'sticker_filter_select',
				'operator' => '===',
				'value'    => 'one',
			],
			[
				'setting'  => 'enable_sticker_filter',
				'operator' => '===',
				'value'    => true,
			],
			[
				'setting'  => 'enable_news_sticker',
				'operator' => '===',
				'value'    => true,
			],
			[
				'setting'  => 'sticker_post_type',
				'operator' => '===',
				'value'    => 'post',
			],
		], 
	]
);

new \Kirki\Field\Radio_Image(
	[
		'settings'    => 'sticker_tags_pro',
		'label'       => esc_html__( 'Tags For Pro Version', 'newshit' ),
		'description' => newshit_purchase_link(),
		'section'     => 'news_sticker_section',
		'default'     => '',
		'transport'   => 'auto',
		'choices'     => [
			'sticker_tags_pro_img'   => get_template_directory_uri() . '/assets/image/pro/tags-pro.jpg',
		],
		'active_callback' => [
			[
				'setting'  => 'sticker_filter_select',
				'operator' => '===',
				'value'    => 'two',
			],
			[
				'setting'  => 'enable_sticker_filter',
				'operator' => '===',
				'value'    => true,
			],
			[
				'setting'  => 'enable_news_sticker',
				'operator' => '===',
				'value'    => true,
			],
			[
				'setting'  => 'sticker_post_type',
				'operator' => '===',
				'value'    => 'post',
			],
		], 
	]
);


new \Kirki\Field\Select(
	[
		'settings'        => 'news_sticker_order',
		'label'           => esc_html__( 'Post Order', 'newshit' ),
		'section'         => 'news_sticker_section',
		'default'         => 'ASC',
		'placeholder'     => esc_html__( 'Choose an option', 'newshit' ),
		'choices'         => [
			'ASC'  => esc_html__( 'ASC', 'newshit' ),
			'DESE' => esc_html__( 'DESE', 'newshit' ),
		],
		'active_callback' => [
			[
				'setting'  => 'enable_news_sticker',
				'operator' => '===',
				'value'    => true,
			],
		],
	]
);

new \Kirki\Field\Select(
	[
		'settings'        => 'news_sticker_postby',
		'label'           => esc_html__( 'Post Order By', 'newshit' ),
		'section'         => 'news_sticker_section',
		'default'         => 'rand',
		'placeholder'     => esc_html__( 'Choose an option', 'newshit' ),
		'choices'         => [
			'none'          => esc_html__( 'None', 'newshit' ),
			'ID'            => esc_html__( 'ID', 'newshit' ),
			'date'          => esc_html__( 'Date', 'newshit' ),
			'name'          => esc_html__( 'Name', 'newshit' ),
			'title'         => esc_html__( 'Title', 'newshit' ),
			'comment_count' => esc_html__( 'Comment count', 'newshit' ),
			'rand'          => esc_html__( 'Random', 'newshit' ),
		],
		'active_callback' => [
			[
				'setting'  => 'enable_news_sticker',
				'operator' => '===',
				'value'    => true,
			],
		],
	]
);

new \Kirki\Field\Number(
	[
		'settings' => 'news_sticker_title_lanth',
		'label'    => esc_html__( 'Title Length', 'newshit' ),
		'section'  => 'news_sticker_section',
		'default'  => 8,
		'choices'  => [
			'min'  => 1,
			'max'  => 50,
			'step' => 1,
		],
		'active_callback' => [
			[
				'setting'  => 'enable_news_sticker',
				'operator' => '===',
				'value'    => true,
			],
		],
	]
);

new \Kirki\Field\Number(
	[
		'settings' => 'news_sticker_dispaly',
		'label'    => esc_html__( 'Post Number', 'newshit' ),
		'section'  => 'news_sticker_section',
		'default'  => 15,
		'choices'  => [
			'min'  => 1,
			'max'  => 15,
			'step' => 1,
		],
		'active_callback' => [
			[
				'setting'  => 'enable_news_sticker',
				'operator' => '===',
				'value'    => true,
			],
		],
	]
);

new \Kirki\Field\Radio_Image(
	[
		'settings'    => 'news_sticker_dispaly_pro',
		'label'       => esc_html__( 'Purchase Pro For Unlimited Dispaly', 'newshit' ),
		'description' => newshit_purchase_link(),
		'section'     => 'news_sticker_section',
		'default'     => '',
		'transport'   => 'auto',
		'active_callback' => [
			[
				'setting'  => 'enable_news_sticker',
				'operator' => '===',
				'value'    => true,
			],
		],
	]
);