<?php 
/**
 * NEWS most_liked SECTION SETTINGS
 */
Kirki::add_section( 'news_most_liked_section', array(
	'title'    => esc_html__( 'Most Liked Section', 'newshit' ),
	'panel'    => 'newshit_front_page_options',
) );

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

new \Kirki\Field\Text(
	[
		'settings' => 'most_liked_section_title',
		'label'    => esc_html__( 'Section Title', 'newshit' ),
		'section'  => 'news_most_liked_section',
		'default'  => esc_html__( 'Most Likded', 'newshit' ),
		'priority'        => 1,
        'active_callback' => [
            [
                'setting'  => 'enable_news_most_liked',
                'operator' => '===',
                'value'    => true,
            ],
        ],
		'partial_refresh'    => [
			'most_liked_section_title_refresh' => [
				'selector'        => '.most-liked-title',
				'render_callback' => 'newshit_customizer_quickedit',
			],
		],
	]
);


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

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

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




Kirki::add_field( 'theme_config', [
	'type'        => 'switch',
	'settings'    => 'enable_most_liked_filter',
	'label'       => esc_html__( 'Enable Most Liked Post Filter', 'newshit' ),
	'section'     => 'news_most_liked_section',
	'default'     => 'off',
	'priority'        => 1,
	'choices'     => [
		'on'  => esc_html__( 'Enable', 'newshit' ),
		'off' => esc_html__( 'Disable', 'newshit' ),
	],
	'active_callback' => [
		[
			'setting'  => 'enable_news_most_liked',
			'operator' => '===',
			'value'    => true,
		],
		[
			'setting'  => 'mostlike_post_type',
			'operator' => '===',
			'value'    => 'post',
		]
	], 
] );

new \Kirki\Field\Select(
	[
		'settings'    => 'most_liked_select_filter',
		'label'       => esc_html__( 'Select Category Or Tags', 'newshit' ),
		'section'     => 'news_most_liked_section',
		'default'     => 'one',
		'priority'        => 1,
		'choices'     => [
			'one' => esc_html__( 'Category', 'newshit' ),
			'two' => esc_html__( 'Tags', 'newshit' ),
		],
		'active_callback' => [
			[
				'setting'  => 'enable_news_most_liked',
				'operator' => '===',
				'value'    => true,
			],
			[
				'setting'  => 'enable_most_liked_filter',
				'operator' => '===',
				'value'    => true,
			],
			[
				'setting'  => 'mostlike_post_type',
				'operator' => '===',
				'value'    => 'post',
			]
		], 
	]
);

new Kirki\Field\Select(
	[
		'settings'    => 'main_most_liked_post_cat',
		'label'       => __( 'Select Categroy', 'newshit' ),
		'section'     => 'news_most_liked_section',
		'default'     => '',
		'multiple'    => -1,
		'priority'        => 1,
		'placeholder' => __( 'Select an Categorys', 'newshit' ),
		'choices'     => Kirki\Util\Helper::get_terms(array('taxonomy' => 'category')),
		'active_callback' => [
			[
				'setting'  => 'most_liked_select_filter',
				'operator' => '===',
				'value'    => 'one',
			],
			[
				'setting'  => 'enable_most_liked_filter',
				'operator' => '===',
				'value'    => true,
			],
			[
				'setting'  => 'enable_news_most_liked',
				'operator' => '===',
				'value'    => true,
			],
			[
				'setting'  => 'mostlike_post_type',
				'operator' => '===',
				'value'    => 'post',
			]
		], 
	]
);

new \Kirki\Field\Radio_Image(
	[
		'settings'    => 'main_most_liked_tag_pro',
		'label'       => esc_html__( 'Tags Is Pro Featured', 'newshit' ),
		'description' => newshit_purchase_link(),
		'section'     => 'front_three_box_section',
		'default'     => '',
		'transport'   => 'auto',
		'priority'        => 1,
		'choices'     => [
			'1'   => get_template_directory_uri() . '/assets/image/pro/tags-pro.jpg',
		],
		'active_callback' => [
			[
				'setting'  => 'most_liked_select_filter',
				'operator' => '===',
				'value'    => 'two',
			],
			[
				'setting'  => 'enable_most_liked_filter',
				'operator' => '===',
				'value'    => true,
			],
			[
				'setting'  => 'enable_news_most_liked',
				'operator' => '===',
				'value'    => true,
			],
			[
				'setting'  => 'mostlike_post_type',
				'operator' => '===',
				'value'    => 'post',
			]
		],
	]
);

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

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

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

//===========================================
//========== SLIDER ITEM SETTING ============
//===========================================
new \Kirki\Field\Radio_Image(
	[
		'settings'    => 'enable_most_liked_cat_title_pro',
		'label'       => esc_html__( 'Purchase Pro Version', 'newshit' ),
		'description' => newshit_purchase_link(),
		'section'     => 'news_most_liked_section',
		'default'     => '',
		'transport'   => 'auto',
		'choices'     => [
			'1'   => get_template_directory_uri() . '/assets/image/pro/big-cat.jpg',
		],
		'active_callback' => [
			[
				'setting'  => 'enable_news_most_liked',
				'operator' => '===',
				'value'    => true,
			],
		],
	]
);

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

Kirki::add_field( 'theme_config', [
	'type'        => 'switch',
	'settings'    => 'enable_most_liked_meta',
	'label'       => esc_html__( 'Enable Most Liked Meta', 'newshit' ),
	'section'     => 'news_most_liked_section',
	'default'     => 'off',
	'choices'     => [
		'on'  => esc_html__( 'Enable', 'newshit' ),
		'off' => esc_html__( 'Disable', 'newshit' ),
	],
	'active_callback' => [
		[
			'setting'  => 'enable_news_most_liked',
			'operator' => '===',
			'value'    => true,
		],
	], 
] );

new Kirki\Field\Select(
	[
		'settings'    => 'main_most_liked_meta',
		'label'       => __( 'Dispaly Post Meta', 'newshit' ),
		'section'     => 'news_most_liked_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_most_liked',
				'operator' => '===',
				'value'    => true,
			],
            [
				'setting'  => 'enable_most_liked_meta',
				'operator' => '===',
				'value'    => true,
			],
            
		], 
	]
);

new \Kirki\Field\Radio_Image(
	[
		'settings'    => 'enable_most_liked_slide_pro',
		'label'       => esc_html__( 'Purchase Pro Version', 'newshit' ),
		'description' => newshit_purchase_link(),
		'section'     => 'news_most_liked_section',
		'default'     => '',
		'transport'   => 'auto',
		'choices'     => [
			'1'   => get_template_directory_uri() . '/assets/image/pro/most-slide.jpg',
		],
		'active_callback' => [
			[
				'setting'  => 'enable_news_most_liked',
				'operator' => '===',
				'value'    => true,
			],
		],
	]
);