<?php 
/**
 * MAIN NEWS SECTION SETTINGS
 */
Kirki::add_section( 'news_main_section', array(
	'title'    => esc_html__( 'Slider Section', 'newscope' ),
	'panel'    => 'newscope_front_page_options',
) );

Kirki::add_field( 'theme_config', [
	'type'        => 'switch',
	'settings'    => 'enable_news_main_section',
	'label'       => esc_html__( 'Enable News Main Section', 'newscope' ),
	'section'     => 'news_main_section',
	'default'     => 'on',
	'priority'        => 1,
	'choices'     => [
		'on'  => esc_html__( 'Enable', 'newscope' ),
		'off' => esc_html__( 'Disable', 'newscope' ),
	],
	'partial_refresh'    => [
		'document_title' => [
			'selector'        => '.newscope-post-items',
			'render_callback' => 'newscope_customizer_quickedit',
		],
	],
] );


//===========================================
//========== Main Section Slider Settings ============
//===========================================

Kirki::add_field( 'theme_config', [
	'type'        => 'switch',
	'settings'    => 'enable_slider_filter',
	'label'       => esc_html__( 'Enable Slider Post Filter', 'newscope' ),
	'section'     => 'news_main_section',
	'default'     => 'off',
	'priority'        => 1,
	'choices'     => [
		'on'  => esc_html__( 'Enable', 'newscope' ),
		'off' => esc_html__( 'Disable', 'newscope' ),
	],
	'active_callback' => [
		[
			'setting'  => 'enable_news_main_section',
			'operator' => '===',
			'value'    => true,
		]
	], 
	'partial_refresh'    => [
			'slider_section_quick' => [
				'selector'        => '.hero-slider-wrapper',
				'render_callback' => 'newscope_customizer_quickedit',
			],
		],
] );

new \Kirki\Field\Select(
	[
		'settings'    => 'main_slider_filter_select',
		'label'       => esc_html__( 'Select Category Or Tags', 'newscope' ),
		'section'     => 'news_main_section',
		'default'     => 'one',
		'priority'        => 1,
		'choices'     => [
			'one' => esc_html__( 'Category', 'newscope' ),
			'two' => esc_html__( 'Tags', 'newscope' ),
		],
		'active_callback' => [
			[
				'setting'  => 'enable_slider_filter',
				'operator' => '===',
				'value'    => true,
			],
			[
				'setting'  => 'enable_news_main_section',
				'operator' => '===',
				'value'    => true,
			]
		], 
	]
);

new Kirki\Field\Select(
	[
		'settings'    => 'main_slider_post_cat',
		'label'       => __( 'Select Categroy', 'newscope' ),
		'section'     => 'news_main_section',
		'default'     => '',
		'multiple'    => -1,
		'priority'        => 1,
		'placeholder' => __( 'Select an Categorys', 'newscope' ),
		'choices'     => Kirki\Util\Helper::get_terms(array('taxonomy' => 'category')),
		'active_callback' => [
			[
				'setting'  => 'main_slider_filter_select',
				'operator' => '===',
				'value'    => 'one',
			],
			[
				'setting'  => 'enable_slider_filter',
				'operator' => '===',
				'value'    => true,
			],
			[
				'setting'  => 'enable_news_main_section',
				'operator' => '===',
				'value'    => true,
			]
		], 
	]
);

// pro
new \Kirki\Field\Radio_Image(
	[
		'settings'    => 'main_slider_post_tag_pro',
		'label'       => esc_html__( 'Purchase Pro', 'newscope' ),
		'description' => newscope_purchase_link(),
		'section'     => 'news_main_section',
		'default'     => '',
		'transport'   => 'auto',
		'priority'        => 1,
		'choices'     => [
			'1'   => get_template_directory_uri() . '/assets/image/pro/tags-pro.jpg',
		],
		'active_callback' => [
			[
				'setting'  => 'main_slider_filter_select',
				'operator' => '===',
				'value'    => 'two',
			],
			[
				'setting'  => 'enable_slider_filter',
				'operator' => '===',
				'value'    => true,
			],
			[
				'setting'  => 'enable_news_main_section',
				'operator' => '===',
				'value'    => true,
			]
		], 
	]
);

new \Kirki\Field\Select(
	[
		'settings'        => 'news_main_slider_order',
		'label'           => esc_html__( 'Post Order', 'newscope' ),
		'section'         => 'news_main_section',
		'default'         => 'ASC',
		'priority'        => 2,
		'placeholder'     => esc_html__( 'Choose an option', 'newscope' ),
		'choices'         => [
			'ASC'  => esc_html__( 'ASC', 'newscope' ),
			'DESE' => esc_html__( 'DESE', 'newscope' ),
		],
		'active_callback' => [
			[
				'setting'  => 'enable_news_main_section',
				'operator' => '===',
				'value'    => true,
			],
		], 
	]
);

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

new \Kirki\Field\Number(
	[
		'settings' => 'main_slider_post_number',
		'label'    => esc_html__( 'Slide Item', 'newscope' ),
		'section'  => 'news_main_section',
		'default'  => 10,
		'choices'  => [
			'min'  => 1,
			'max'  => 100,
			'step' => 1,
		],
		'priority'        => 2,
		'active_callback' => [
			[
				'setting'  => 'enable_news_main_section',
				'operator' => '===',
				'value'    => true,
			],
		],
	]
);
// pro
		new \Kirki\Field\Number(
			[
				'settings' => 'main_slider_title_lanth',
				'label'    => esc_html__( 'Title Length', 'newscope' ),
				'section'  => 'news_main_section',
				'default'  => 20,
				'priority'        => 2,
				'choices'  => [
					'min'  => 1,
					'max'  => 50,
					'step' => 1,
				],
				'active_callback' => [
					[
						'setting'  => 'enable_news_main_section',
						'operator' => '===',
						'value'    => true,
					],
				],
			]
		);

// pro
new \Kirki\Field\Radio_Image(
	[
		'settings'    => 'main_slider_cat-meta_pro',
		'label'       => esc_html__( 'Purchase Pro', 'newscope' ),
		'description' => newscope_purchase_link(),
		'section'     => 'news_main_section',
		'default'     => '',
		'transport'   => 'auto',
		'priority'        => 2,
		'choices'     => [
			'1'   => get_template_directory_uri() . '/assets/image/pro/slider-cat-meta.jpg',
		],
		'active_callback' => [
			[
				'setting'  => 'enable_news_main_section',
				'operator' => '===',
				'value'    => true,
			],
		],
	]
);