<?php 
/**
 * NEWS FEATURED SECTION SETTINGS
 */
Kirki::add_section( 'latest_news_section', array(
	'title'    => esc_html__( 'Latest News Section', 'newscope' ),
	'panel'    => 'newscope_front_page_options',
) );

Kirki::add_field( 'theme_config', [
	'type'        => 'switch',
	'settings'    => 'enable_latest_news_section',
	'label'       => esc_html__( 'Enable Latest News Section', 'newscope' ),
	'section'     => 'latest_news_section',
	'default'     => 'on',
	'priority'        => 1,
	'choices'     => [
		'on'  => esc_html__( 'Enable', 'newscope' ),
		'off' => esc_html__( 'Disable', 'newscope' ),
	],
	'partial_refresh'    => [
		'latest_news_section_titles_quick' => [
			'selector'        => '.latest-news-quick',
			'render_callback' => 'newscope_customizer_quickedit',
		],
	],
] );

new \Kirki\Field\Text(
	[
		'settings' => 'latest_news_section_title',
		'label'    => esc_html__( 'Section Title', 'newscope' ),
		'section'  => 'latest_news_section',
		'default'  => esc_html__( "Latest News", 'newscope' ),
		'priority'        => 1,
        'active_callback' => [
            [
                'setting'  => 'enable_latest_news_section',
                'operator' => '===',
                'value'    => true,
            ],
        ],
	]
);

// title tag pro
new \Kirki\Field\Radio_Image(
	[
		'settings'    => 'latest_news_section_title_tag_pro',
		'label'       => esc_html__( 'Purchase Pro', 'newscope' ),
		'description' => newscope_purchase_link(),
		'section'     => 'latest_news_section',
		'default'     => '',
		'transport'   => 'auto',
		'choices'     => [
			'1'   => get_template_directory_uri() . '/assets/image/pro/html-tag2.jpg',
		],
		'active_callback' => [
            [
                'setting'  => 'enable_latest_news_section',
                'operator' => '===',
                'value'    => true,
            ],
        ], 
	]
);

Kirki::add_field( 'theme_config', [
	'type'        => 'switch',
	'settings'    => 'enable_latest_readmore',
	'label'       => esc_html__( 'Enable Read More Button', 'newscope' ),
	'section'     => 'latest_news_section',
	'default'     => 'on',
	'choices'     => [
		'on'  => esc_html__( 'Enable', 'newscope' ),
		'off' => esc_html__( 'Disable', 'newscope' ),
	],
	'active_callback' => [
		[
			'setting'  => 'enable_latest_news_section',
			'operator' => '===',
			'value'    => true,
		]
	],
] );
new \Kirki\Field\URL(
	[
		'settings' => 'latest_news_btn_url',
		'label'    => esc_html__( 'Read More URL', 'newscope' ),
		'section'  => 'latest_news_section',
		'default'  => '#',
        'active_callback' => [
            [
                'setting'  => 'enable_latest_news_section',
                'operator' => '===',
                'value'    => true,
            ],
            [
                'setting'  => 'enable_latest_readmore',
                'operator' => '===',
                'value'    => true,
            ]
        ],
	]
);
new \Kirki\Field\Text(
	[
		'settings' => 'latest_news_btn_text',
		'label'    => esc_html__( 'Button Text', 'newscope' ),
		'section'  => 'latest_news_section',
		'default'  => esc_html__( 'Read More', 'newscope' ),
		'priority' => 10,
        'active_callback' => [
            [
                'setting'  => 'enable_latest_news_section',
                'operator' => '===',
                'value'    => true,
            ],
            [
                'setting'  => 'enable_latest_readmore',
                'operator' => '===',
                'value'    => true,
            ]
        ],
	]
);
//===========================================
//========== Main Section Slider Settings ============
//===========================================


Kirki::add_field( 'theme_config', [
	'type'        => 'switch',
	'settings'    => 'enable_latest_news_filter',
	'label'       => esc_html__( 'Enable Post Filter', 'newscope' ),
	'section'     => 'latest_news_section',
	'default'     => 'off',
	'choices'     => [
		'on'  => esc_html__( 'Enable', 'newscope' ),
		'off' => esc_html__( 'Disable', 'newscope' ),
	],
	'active_callback' => [
		[
			'setting'  => 'enable_latest_news_section',
			'operator' => '===',
			'value'    => true,
		]
	],
] );

new \Kirki\Field\Select(
	[
		'settings'    => 'latest_news_select_filter',
		'label'       => esc_html__( 'Select Category Or Tags', 'newscope' ),
		'section'     => 'latest_news_section',
		'default'     => 'one',
		'choices'     => [
			'one' => esc_html__( 'Category', 'newscope' ),
			'two' => esc_html__( 'Tags', 'newscope' ),
		],
		'active_callback' => [
			[
				'setting'  => 'enable_latest_news_section',
				'operator' => '===',
				'value'    => true,
			],
			[
				'setting'  => 'enable_latest_news_filter',
				'operator' => '===',
				'value'    => true,
			]
		], 
	]
);

new Kirki\Field\Select(
	[
		'settings'    => 'latest_news_post_cat',
		'label'       => __( 'Select Categroy', 'newscope' ),
		'section'     => 'latest_news_section',
		'default'     => '',
		'multiple'    => -1,
		'placeholder' => __( 'Select an Categorys', 'newscope' ),
		'choices'     => Kirki\Util\Helper::get_terms(array('taxonomy' => 'category')),
		'active_callback' => [
			[
				'setting'  => 'latest_news_select_filter',
				'operator' => '===',
				'value'    => 'one',
			],
			[
				'setting'  => 'enable_latest_news_filter',
				'operator' => '===',
				'value'    => true,
			],
			[
				'setting'  => 'enable_latest_news_section',
				'operator' => '===',
				'value'    => true,
			]
		], 
	]
);

// pro
new \Kirki\Field\Radio_Image(
	[
		'settings'    => 'latest_news_post_tag_pro',
		'label'       => esc_html__( 'Purchase Pro', 'newscope' ),
		'description' => newscope_purchase_link(),
		'section'     => 'latest_news_section',
		'default'     => '',
		'transport'   => 'auto',
		'choices'     => [
			'1'   => get_template_directory_uri() . '/assets/image/pro/tags-pro.jpg',
		],
		'active_callback' => [
			[
				'setting'  => 'latest_news_select_filter',
				'operator' => '===',
				'value'    => 'two',
			],
			[
				'setting'  => 'enable_latest_news_filter',
				'operator' => '===',
				'value'    => true,
			],
			[
				'setting'  => 'enable_latest_news_section',
				'operator' => '===',
				'value'    => true,
			]
		],
	]
);

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

new \Kirki\Field\Select(
	[
		'settings'        => 'news_latest_post_postby',
		'label'           => esc_html__( 'Post Order By', 'newscope' ),
		'section'         => 'latest_news_section',
		'default'         => 'rand',
		'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_latest_news_section',
				'operator' => '===',
				'value'    => true,
			],
		],
	]
);
new \Kirki\Field\Radio_Image(
	[
		'settings'    => 'latest_news_meta_tag_pro',
		'label'       => esc_html__( 'Purchase Pro', 'newscope' ),
		'description' => newscope_purchase_link(),
		'section'     => 'latest_news_section',
		'default'     => '',
		'transport'   => 'auto',
		'choices'     => [
			'1'   => get_template_directory_uri() . '/assets/image/pro/lnews-pro.jpg',
		],
		'active_callback' => [
			[
				'setting'  => 'enable_latest_news_section',
				'operator' => '===',
				'value'    => true,
			]
		],
	]
);