<?php 
/**
 * NEWS FEATURED SECTION SETTINGS
 */
Kirki::add_section( 'news_featured_section', array(
	'title'    => esc_html__( 'News Featured Section', 'newshit' ),
	'panel'    => 'newshit_front_page_options',
) );

Kirki::add_field( 'theme_config', [
	'type'        => 'switch',
	'settings'    => 'enable_news_featured',
	'label'       => esc_html__( 'Enable News Featured Section', 'newshit' ),
	'section'     => 'news_featured_section',
	'default'     => 'off',
	'priority'        => 1,
	'choices'     => [
		'on'  => esc_html__( 'Enable', 'newshit' ),
		'off' => esc_html__( 'Disable', 'newshit' ),
	],
] );

new \Kirki\Field\Text(
	[
		'settings' => 'feature_section_title',
		'label'    => esc_html__( 'Section Title', 'newshit' ),
		'section'  => 'news_featured_section',
		'default'  => esc_html__( 'Featured Post', 'newshit' ),
		'priority'        => 1,
        'active_callback' => [
            [
                'setting'  => 'enable_news_featured',
                'operator' => '===',
                'value'    => true,
            ],
        ],
		'partial_refresh'    => [
			'feature_section_title_refresh' => [
				'selector'        => '.feature-title',
				'render_callback' => 'newshit_customizer_quickedit',
			],
		], 
	]
);

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

new \Kirki\Field\Select(
	[
		'settings'    => 'featured_post_type',
		'label'       => esc_html__( 'Select Post Type', 'newshit' ),
		'section'     => 'news_featured_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_featured',
				'operator' => '===',
				'value'    => true,
			],
		], 
	]
);
// Start Web Stories Filter

if ( is_plugin_active( 'web-stories/web-stories.php' ) ) {

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


Kirki::add_field( 'theme_config', [
	'type'        => 'switch',
	'settings'    => 'enable_featured_filter',
	'label'       => esc_html__( 'Enable Featured Post Filter', 'newshit' ),
	'section'     => 'news_featured_section',
	'default'     => 'off',
	'choices'     => [
		'on'  => esc_html__( 'Enable', 'newshit' ),
		'off' => esc_html__( 'Disable', 'newshit' ),
	],
	'active_callback' => [
		[
			'setting'  => 'enable_news_featured',
			'operator' => '===',
			'value'    => true,
		],
		[
			'setting'  => 'featured_post_type',
			'operator' => '===',
			'value'    => 'post',
		],
	], 
] );

new \Kirki\Field\Select(
	[
		'settings'    => 'featured_select_filter',
		'label'       => esc_html__( 'Select Category Or Tags', 'newshit' ),
		'section'     => 'news_featured_section',
		'default'     => 'one',
		'choices'     => [
			'one' => esc_html__( 'Category', 'newshit' ),
			'two' => esc_html__( 'Tags', 'newshit' ),
		],
		'active_callback' => [
			[
				'setting'  => 'enable_news_featured',
				'operator' => '===',
				'value'    => true,
			],
			[
				'setting'  => 'enable_featured_filter',
				'operator' => '===',
				'value'    => true,
			],
			[
				'setting'  => 'featured_post_type',
				'operator' => '===',
				'value'    => 'post',
			],
		], 
	]
);

new Kirki\Field\Select(
	[
		'settings'    => 'main_feature_post_cat',
		'label'       => __( 'Select Categroy', 'newshit' ),
		'section'     => 'news_featured_section',
		'default'     => '',
		'multiple'    => -1,
		'placeholder' => __( 'Select an Categorys', 'newshit' ),
		'choices'     => Kirki\Util\Helper::get_terms(array('taxonomy' => 'category')),
		'active_callback' => [
			[
				'setting'  => 'featured_select_filter',
				'operator' => '===',
				'value'    => 'one',
			],
			[
				'setting'  => 'enable_featured_filter',
				'operator' => '===',
				'value'    => true,
			],
			[
				'setting'  => 'enable_news_featured',
				'operator' => '===',
				'value'    => true,
			],
			[
				'setting'  => 'featured_post_type',
				'operator' => '===',
				'value'    => 'post',
			],
		], 
	]
);

new \Kirki\Field\Radio_Image(
	[
		'settings'    => 'main_featured_post_pro',
		'label'       => esc_html__( 'Tags Is Pro Featured', 'newshit' ),
		'description' => newshit_purchase_link(),
		'section'     => 'news_featured_section',
		'default'     => '',
		'transport'   => 'auto',
		'choices'     => [
			'1'   => get_template_directory_uri() . '/assets/image/pro/tags-pro.jpg',
		],
		'active_callback' => [
			[
				'setting'  => 'featured_select_filter',
				'operator' => '===',
				'value'    => 'two',
			],
			[
				'setting'  => 'enable_featured_filter',
				'operator' => '===',
				'value'    => true,
			],
			[
				'setting'  => 'enable_news_featured',
				'operator' => '===',
				'value'    => true,
			],
			[
				'setting'  => 'featured_post_type',
				'operator' => '===',
				'value'    => 'post',
			],
		],
	]
);

new \Kirki\Field\Select(
	[
		'settings'        => 'news_featured_order',
		'label'           => esc_html__( 'Post Order', 'newshit' ),
		'section'         => 'news_featured_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_featured',
				'operator' => '===',
				'value'    => true,
			],
		], 
	]
);

new \Kirki\Field\Select(
	[
		'settings'        => 'news_featured_postby',
		'label'           => esc_html__( 'Post Order By', 'newshit' ),
		'section'         => 'news_featured_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_featured',
				'operator' => '===',
				'value'    => true,
			],
		],
	]
);

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

//===========================================
//========== SLIDER ITEM SETTING ============
//===========================================

new \Kirki\Field\Radio_Image(
	[
		'settings'    => 'enable_featured_cpro',
		'label'       => esc_html__( 'Pro Featured', 'newshit' ),
		'description' => newshit_purchase_link(),
		'section'     => 'news_featured_section',
		'default'     => '',
		'transport'   => 'auto',
		'choices'     => [
			'1'   => get_template_directory_uri() . '/assets/image/pro/feature-cat-title.jpg',
		],
		'active_callback' => [
			[
				'setting'  => 'enable_news_featured',
				'operator' => '===',
				'value'    => true,
			],
		],
	]
);


Kirki::add_field( 'theme_config', [
	'type'        => 'switch',
	'settings'    => 'enable_featured_meta',
	'label'       => esc_html__( 'Enable Featured meta', 'newshit' ),
	'section'     => 'news_featured_section',
	'default'     => 'off',
	'choices'     => [
		'on'  => esc_html__( 'Enable', 'newshit' ),
		'off' => esc_html__( 'Disable', 'newshit' ),
	],
	'active_callback' => [
		[
			'setting'  => 'enable_news_featured',
			'operator' => '===',
			'value'    => true,
		],
	], 
] );

new Kirki\Field\Select(
	[
		'settings'    => 'main_feature_meta',
		'label'       => __( 'Dispaly Post Meta', 'newshit' ),
		'section'     => 'news_featured_section',
		'default'     => '',
		'multiple'    => 3,
		'choices'         => [
			'author'  => esc_html__( 'Author', 'newshit' ),
			'comment' => esc_html__( 'Comment', 'newshit' ),
			'date' => esc_html__( 'Date', 'newshit' ),
		],
		'active_callback' => [
			[
				'setting'  => 'enable_news_featured',
				'operator' => '===',
				'value'    => true,
			],
            [
				'setting'  => 'enable_featured_meta',
				'operator' => '===',
				'value'    => true,
			],
            
		], 
	]
);


Kirki::add_field( 'theme_config', [
	'type'        => 'switch',
	'settings'    => 'enable_featured_slider',
	'label'       => esc_html__( 'Enable Slider', 'newshit' ),
	'section'     => 'news_featured_section',
	'default'     => 'on',
	'choices'     => [
		'on'  => esc_html__( 'Enable', 'newshit' ),
		'off' => esc_html__( 'Disable', 'newshit' ),
	],
	'active_callback' => [
		[
			'setting'  => 'enable_news_featured',
			'operator' => '===',
			'value'    => true,
		],
	], 
] );

new \Kirki\Field\Number(
	[
		'settings' => 'featured_dispaly_number',
		'label'    => esc_html__( 'Dispaly Item', 'newshit' ),
		'section'  => 'news_featured_section',
		'default'  => 4,
		'choices'  => [
			'min'  => 1,
			'max'  => 8,
			'step' => 1,
		],
		'active_callback' => [
			[
				'setting'  => 'enable_news_featured',
				'operator' => '===',
				'value'    => true,
			],
            [
				'setting'  => 'enable_featured_slider',
				'operator' => '!==',
				'value'    => true,
			],
		],
	]
);
new \Kirki\Field\Radio_Image(
	[
		'settings'    => 'featured_dispaly_pro',
		'label'       => esc_html__( 'Purchase Pro for Add Unlimited Items', 'newshit' ),
		'description' => newshit_purchase_link(),
		'section'     => 'news_featured_section',
		'default'     => '',
		'transport'   => 'auto',
		'active_callback' => [
			[
				'setting'  => 'enable_news_featured',
				'operator' => '===',
				'value'    => true,
			],
            [
				'setting'  => 'enable_featured_slider',
				'operator' => '!==',
				'value'    => true,
			],
		],
	]
);

//====================================================
//======== News Featured Section Ads Settings ============
//====================================================

Kirki::add_field( 'theme_config', [
	'type'        => 'switch',
	'settings'    => 'news_featured_ads_enable',
	'label'       => esc_html__( 'Enable Ads Banner', 'newshit' ),
	'description' => esc_html__( 'Enable Ads Banner For Featured Section', 'newshit' ),
	'section'     => 'news_featured_section',
	'default'     => 'on',
	'choices'     => [
		'on'  => esc_html__( 'Enable', 'newshit' ),
		'off' => esc_html__( 'Disable', 'newshit' ),
	],
	'partial_refresh'    => [
		'news_featured_ads_enable_refresh' => [
			'selector'        => '.newshit-featured-section-ads-wrapper',
			'render_callback' => 'newshit_customizer_quickedit',
		],
	],
] );



new \Kirki\Field\Select(
	[
		'settings'    => 'featured_section_ads_type',
		'label'       => esc_html__( 'Select Ads Type', 'newshit' ),
		'section'     => 'news_featured_section',
		'default'     => 'link',
		'active_callback' => [
			[
				'setting'  => 'news_featured_ads_enable',
				'operator' => '===',
				'value'    => true,
			]
		],
		'choices'     => [
			'link' => esc_html__( 'Link', 'newshit' ),
			'code' => esc_html__( 'Code', 'newshit' ),
		],
	]
);

new \Kirki\Field\Image(
	[
		'settings'    => 'featured_section_ads_image',
		'label'       => esc_html__( 'Upload Ads image', 'newshit' ),
		'section'     => 'news_featured_section',
        'active_callback' => [
			[
				'setting'  => 'featured_section_ads_type',
				'operator' => '===',
				'value'    => 'link',
			],
			[
				'setting'  => 'news_featured_ads_enable',
				'operator' => '===',
				'value'    => true,
			]
		],
        'choices'     => [
			'save_as' => 'array',
		],
	]
);

new \Kirki\Field\URL(
	[
		'settings' => 'featured_section_ads_url',
		'label'    => esc_html__( 'Ads URL', 'newshit' ),
		'section'  => 'news_featured_section',
		'default'  => '#',
        'active_callback' => [
			[
				'setting'  => 'featured_section_ads_type',
				'operator' => '===',
				'value'    => 'link',
			],
			[
				'setting'  => 'news_featured_ads_enable',
				'operator' => '===',
				'value'    => true,
			]
		], 
	]
);

new \Kirki\Field\Radio_Image(
	[
		'settings'    => 'featured_section_ads_pro',
		'label'       => esc_html__( 'Code Is Pro Featured', 'newshit' ),
		'description' => newshit_purchase_link(),
		'section'     => 'news_featured_section',
		'default'     => '',
		'transport'   => 'auto',
		'choices'     => [
			'1'   => get_template_directory_uri() . '/assets/image/pro/ads-code.jpg',
		],
		'active_callback' => [
			[
				'setting'  => 'featured_section_ads_type',
				'operator' => '===',
				'value'    => 'code',
			],
			[
				'setting'  => 'news_featured_ads_enable',
				'operator' => '===',
				'value'    => true,
			]
		],
	]
);
