<?php

/**
 * NEWS FEATURED SECTION SETTINGS
 */
Kirki::add_section('category_section_option', array(
    'title'    => esc_html__('Category Section', 'newscope'),
    'panel'    => 'newscope_front_page_options',
));

Kirki::add_field('theme_config', [
    'type'        => 'switch',
    'settings'    => 'enable_category_section',
    'label'       => esc_html__('Enable News Featured Section', 'newscope'),
    'section'     => 'category_section_option',
    'default'     => 'on',
    'priority'        => 1,
    'choices'     => [
        'on'  => esc_html__('Enable', 'newscope'),
        'off' => esc_html__('Disable', 'newscope'),
    ],
    'partial_refresh'    => [
        'features_section_title_quick' => [
            'selector'        => '.category-title',
            'render_callback' => 'newscope_customizer_quickedit',
        ],
    ],
]);

new \Kirki\Field\Text(
    [
        'settings' => 'category_section_title',
        'label'    => esc_html__('Section Title', 'newscope'),
        'section'  => 'category_section_option',
        'default'  => esc_html__('Category', 'newscope'),
        'priority'        => 1,
        'active_callback' => [
            [
                'setting'  => 'enable_category_section',
                'operator' => '===',
                'value'    => true,
            ],
        ],
    ]
);

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

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

new \Kirki\Field\Select(
    [
        'settings'        => 'category_section_postby',
        'label'           => esc_html__('Post Order By', 'newscope'),
        'section'         => 'category_section_option',
        '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_category_section',
                'operator' => '===',
                'value'    => true,
            ],
        ],
    ]
);
new \Kirki\Field\Number(
    [
        'settings' => 'category_post_display',
        'label'    => esc_html__( 'Display Item', 'newscope' ),
        'section'  => 'category_section_option',
        'default'  => 20,
        'choices'  => [
            'min'  => 1,
            'max'  => 100,
            'step' => 1,
        ],
        'active_callback' => [
            [
                'setting'  => 'enable_category_section',
                'operator' => '===',
                'value'    => true,
            ]
        ], 
    ]
);