<?php

Kirki::add_config( 'my_theme_config', array(
    'capability' => 'edit_theme_options',
    'option_type' => 'theme_mod',
) );


new \Kirki\Panel(
	'grshop_grocery_panel_id',
	[
		'priority'    => 1,
		'title'       => esc_html__( 'GrShop: Theme Options', 'grshop-grocery' ),
		'description' => esc_html__( 'Theme Settings.', 'grshop-grocery' ),
	]
);


/* Topbar Settings */
new \Kirki\Section(
	'grshop_grocery_header',
	[
		'title'       => esc_html__( 'Header Settings', 'grshop-grocery' ),
		'description' => esc_html__( 'Customize Header Options.', 'grshop-grocery' ),
		'panel'       => 'grshop_grocery_panel_id',
		'priority'    => 160,
	]
);

new \Kirki\Field\Text(
	[
		'settings'    => 'topbar_welcome_message',
		'label'       => esc_html__( 'Topbar Welcome Message', 'grshop-grocery' ),
		'default'     => 'Welcome to GRShop. Build your Grocery & Food Store',
		'section'     => 'grshop_grocery_header',
		'priority' => 1,
	]
);



new \Kirki\Field\Repeater(
	[
		'settings' => 'topbar_pages',
		'label'    => esc_html__( 'Topbar Pages', 'grshop-grocery' ),
		'section'  => 'grshop_grocery_header',
		'priority' => 2,
		'default'  => [
			[
				'link_text'   => esc_html__( 'About Us', 'grshop-grocery' ),
				'link_url'    => '#',
				'link_target' => '_self',
				'checkbox'    => false,
			],
			[
				'link_text'   => esc_html__( 'Contact Us', 'grshop-grocery' ),
				'link_url'    => '#',
				'link_target' => '_self',
				'checkbox'    => false,
			],
		],
		'fields'   => [
			'link_text'   => [
				'type'        => 'text',
				'label'       => esc_html__( 'Link Text', 'grshop-grocery' ),
				'description' => esc_html__( 'Description', 'grshop-grocery' ),
				'default'     => '',
			],
			'link_url'    => [
				'type'        => 'text',
				'label'       => esc_html__( 'Link URL', 'grshop-grocery' ),
				'description' => esc_html__( 'Description', 'grshop-grocery' ),
				'default'     => '',
			],
			'link_target' => [
				'type'        => 'select',
				'label'       => esc_html__( 'Link Target', 'grshop-grocery' ),
				'description' => esc_html__( 'Description', 'grshop-grocery' ),
				'default'     => '_self',
				'choices'     => [
					'_blank' => esc_html__( 'New Window', 'grshop-grocery' ),
					'_self'  => esc_html__( 'Same Frame', 'grshop-grocery' ),
				],
			],
		],
	]
);




/* Header Search Form */
new \Kirki\Field\Checkbox_Switch(
	[
		'settings'    => 'header_search_form',
		'label'       => esc_html__( 'Show Search Form?', 'grshop-grocery' ),
		'section'     => 'grshop_grocery_header',
		'default'     => 'on',
		'choices'     => [
			'on'  => esc_html__( 'Enable', 'grshop-grocery' ),
			'off' => esc_html__( 'Disable', 'grshop-grocery' ),
		],
		'priority' => 3,
	]
);

new \Kirki\Field\Checkbox_Switch(
	[
		'settings'    => 'header_my_accounts',
		'label'       => esc_html__( 'Show Accounts Info?', 'grshop-grocery' ),
		'section'     => 'grshop_grocery_header',
		'default'     => 'on',
		'choices'     => [
			'on'  => esc_html__( 'Enable', 'grshop-grocery' ),
			'off' => esc_html__( 'Disable', 'grshop-grocery' ),
		],
		'priority' => 4,
	]
);


new \Kirki\Field\URL(
	[
		'settings' => 'header_my_accounts_login',
		'label'    => esc_html__( 'Login Page Link', 'grshop-grocery' ),
		'section'  => 'grshop_grocery_header',
		'default'  => esc_html__( '#', 'grshop-grocery' ),
		'priority' => 5,
	]
);


new \Kirki\Field\URL(
	[
		'settings' => 'header_my_accounts_register',
		'label'    => esc_html__( 'Signup Page Link', 'grshop-grocery' ),
		'section'  => 'grshop_grocery_header',
		'default'  => esc_html__( '#', 'grshop-grocery' ),
		'priority' => 6,
	]
);

new \Kirki\Field\URL(
	[
		'settings' => 'header_my_accounts_dashboard',
		'label'    => esc_html__( 'Customer Dashboard Page Link', 'grshop-grocery' ),
		'section'  => 'grshop_grocery_header',
		'default'  => esc_html__( '#', 'grshop-grocery' ),
		'priority' => 7,
	]
);

new \Kirki\Field\Text(
	[
		'settings' => 'header_contact_number',
		'label'    => esc_html__( 'Contact Number', 'grshop-grocery' ),
		'section'  => 'grshop_grocery_header',
		'default'  => esc_html__( '+8801304-43-545', 'grshop-grocery' ),
		'priority' => 8,
	]
);




/* Slider Settings */
new \Kirki\Section(
	'grshop_grocery_section_slider',
	[
		'title'       => esc_html__( 'Slider Settings', 'grshop-grocery' ),
		'description' => esc_html__( 'Add your slider.', 'grshop-grocery' ),
		'panel'       => 'grshop_grocery_panel_id',
		'priority'    => 160,
	]
);


new \Kirki\Field\Repeater(
	[
		'settings' => 'slider_settings',
		'label'    => esc_html__( 'Slider Controls', 'grshop-grocery' ),
		'section'  => 'grshop_grocery_section_slider',
		'priority' => 10,
		'default'  => [
			[
				'slider_image' => '',
				'slider_title'   => esc_html__( 'We Deliver Fresh Groceries & Food to Your', 'grshop-grocery' ),
				'slider_title_curve'   => esc_html__( 'Doorstep', 'grshop-grocery' ),
				'slider_text'   => esc_html__( 'Ut tincidunt volutpat velit a condimentum. Vestibulum nec augue lacinia, placerat nibh in, luctus felis', 'grshop-grocery' ),
				'link_text'   => esc_html__( 'Order Now', 'grshop-grocery' ),
				'link_url'    => '#',
				'link_target' => '_self',
			],
		],
		'fields'   => [
			'slider_image'   => [
				'type'        => 'image',
				'label'       => esc_html__( 'Slider Background Image', 'grshop-grocery' ),
			],
			'slider_title'   => [
				'type'        => 'text',
				'label'       => esc_html__( 'Slider Title', 'grshop-grocery' ),
				'default'     => '',
			],
			'slider_title_curve'   => [
				'type'        => 'text',
				'label'       => esc_html__( 'Slider Curve Title', 'grshop-grocery' ),
				'default'     => '',
			],
			'slider_text'   => [
				'type'        => 'textarea',
				'label'       => esc_html__( 'Slider Description', 'grshop-grocery' ),
				'default'     => '',
			],
			'link_text'   => [
				'type'        => 'text',
				'label'       => esc_html__( 'Slider Button Text', 'grshop-grocery' ),
				'default'     => '',
			],
			'link_url'    => [
				'type'        => 'text',
				'label'       => esc_html__( 'Slider Button Link', 'grshop-grocery' ),
				'default'     => '',
			],
			'link_target' => [
				'type'        => 'select',
				'label'       => esc_html__( 'Button Link Target', 'grshop-grocery' ),
				'default'     => '_self',
				'choices'     => [
					'_blank' => esc_html__( 'New Window', 'grshop-grocery' ),
					'_self'  => esc_html__( 'Same Frame', 'grshop-grocery' ),
				],
			],
		],
	]
);


/* Latest Product Settings */
new \Kirki\Section(
	'grshop_grocery_latest_products',
	[
		'title'       => esc_html__( 'Latest Product Settings', 'grshop-grocery' ),
		'description' => esc_html__( 'Customize Products.', 'grshop-grocery' ),
		'panel'       => 'grshop_grocery_panel_id',
		'priority'    => 160,
	]
);

new \Kirki\Field\Text(
	[
		'settings' => 'lproduct_section_label',
		'label'    => esc_html__( 'Section Label', 'grshop-grocery' ),
		'section'  => 'grshop_grocery_latest_products',
		'default'  => esc_html__( 'Top Picks', 'grshop-grocery' ),
		'priority' => 10,
	]
);

new \Kirki\Field\Text(
	[
		'settings' => 'lproduct_section_title',
		'label'    => esc_html__( 'Section Title', 'grshop-grocery' ),
		'section'  => 'grshop_grocery_latest_products',
		'default'  => esc_html__( 'Latest', 'grshop-grocery' ),
		'priority' => 10,
	]
);

new \Kirki\Field\Text(
	[
		'settings' => 'lproduct_section_focus',
		'label'    => esc_html__( 'Section Focus Title', 'grshop-grocery' ),
		'section'  => 'grshop_grocery_latest_products',
		'default'  => esc_html__( 'Products', 'grshop-grocery' ),
		'priority' => 10,
	]
);

new \Kirki\Field\Slider(
	[
		'settings' => 'show_product',
		'label'    => esc_html__( 'Show Products', 'grshop-grocery' ),
		'section'  => 'grshop_grocery_latest_products',
		'default'  => 4,
		'choices'  => [
			'min'  => 4,
		],
	]
);


/* Product Category Settings */
new \Kirki\Section(
	'grshop_grocery_product_cats',
	[
		'title'       => esc_html__( 'Product Category', 'grshop-grocery' ),
		'description' => esc_html__( 'Product Category.', 'grshop-grocery' ),
		'panel'       => 'grshop_grocery_panel_id',
		'priority'    => 160,
	]
);

new \Kirki\Field\Text(
	[
		'settings' => 'cproduct_section_label',
		'label'    => esc_html__( 'Section Label', 'grshop-grocery' ),
		'section'  => 'grshop_grocery_product_cats',
		'default'  => esc_html__( 'Top Picks', 'grshop-grocery' ),
		'priority' => 10,
	]
);

new \Kirki\Field\Text(
	[
		'settings' => 'cproduct_section_title',
		'label'    => esc_html__( 'Section Title', 'grshop-grocery' ),
		'section'  => 'grshop_grocery_product_cats',
		'default'  => esc_html__( 'Latest', 'grshop-grocery' ),
		'priority' => 10,
	]
);

new \Kirki\Field\Text(
	[
		'settings' => 'cproduct_section_focus',
		'label'    => esc_html__( 'Section Focus Title', 'grshop-grocery' ),
		'section'  => 'grshop_grocery_product_cats',
		'default'  => esc_html__( 'Products', 'grshop-grocery' ),
		'priority' => 10,
	]
);

new \Kirki\Field\Slider(
	[
		'settings' => 'show_category',
		'label'    => esc_html__( 'Show Category', 'grshop-grocery' ),
		'section'  => 'grshop_grocery_product_cats',
		'default'  => 8,
		'choices'  => [
			'min'  => 8,
		],
	]
);




/* Video CTA Settings */
new \Kirki\Section(
	'grshop_grocery_cta',
	[
		'title'       => esc_html__( 'Call to Action', 'grshop-grocery' ),
		'description' => esc_html__( 'Settings for CTA.', 'grshop-grocery' ),
		'panel'       => 'grshop_grocery_panel_id',
		'priority'    => 160,
	]
);

new \Kirki\Field\Image(
	[
		'settings'    => 'cta_section_thumbnail',
		'label'       => esc_html__( 'Video Thumbnail Image', 'grshop-grocery' ),
		'description' => esc_html__( 'Save Video Thumbnail Image.', 'grshop-grocery' ),
		'section'     => 'grshop_grocery_cta',
		'default'     => '',
	]
);

new \Kirki\Field\Text(
	[
		'settings' => 'cta_section_video',
		'label'    => esc_html__( 'Youtube Video Link', 'grshop-grocery' ),
		'description'    => esc_html__( 'Just Type Video ID', 'grshop-grocery' ),
		'section'  => 'grshop_grocery_cta',
		'default'  => 'ozNPF3xNC4',
		'priority' => 10,
	]
);

new \Kirki\Field\Text(
	[
		'settings' => 'cta_section_label',
		'label'    => esc_html__( 'Section Label', 'grshop-grocery' ),
		'section'  => 'grshop_grocery_cta',
		'default'  => esc_html__( ' Your online resource of healthy recipes.', 'grshop-grocery' ),
		'priority' => 10,
	]
);

new \Kirki\Field\Text(
	[
		'settings' => 'cta_section_title',
		'label'    => esc_html__( 'Section Title', 'grshop-grocery' ),
		'section'  => 'grshop_grocery_cta',
		'default'  => esc_html__( 'Organic Vegetables Everyday', 'grshop-grocery' ),
		'priority' => 10,
	]
);

new \Kirki\Field\Textarea(
	[
		'settings' => 'cta_section_desc',
		'label'    => esc_html__( 'Section Description', 'grshop-grocery' ),
		'section'  => 'grshop_grocery_cta',
		'default'  => esc_html__( 'Type Description here', 'grshop-grocery' ),
		'priority' => 10,
	]
);


new \Kirki\Field\Text(
	[
		'settings' => 'cta_button',
		'label'    => esc_html__( 'CTA Button', 'grshop-grocery' ),
		'section'  => 'grshop_grocery_cta',
		'default'  => esc_html__( 'Order Now', 'grshop-grocery' ),
		'priority' => 10,
	]
);

new \Kirki\Field\URL(
	[
		'settings' => 'cta_button_link',
		'label'    => esc_html__( 'CTA Button Link', 'grshop-grocery' ),
		'section'  => 'grshop_grocery_cta',
		'default'  => esc_html__( '#', 'grshop-grocery' ),
		'priority' => 10,
	]
);



/* Blog Settings */
new \Kirki\Section(
	'grshop_grocery_blog',
	[
		'title'       => esc_html__( 'Blog Post', 'grshop-grocery' ),
		'description' => esc_html__( 'Blog post settings.', 'grshop-grocery' ),
		'panel'       => 'grshop_grocery_panel_id',
		'priority'    => 160,
	]
);

new \Kirki\Field\Text(
	[
		'settings' => 'b_section_label',
		'label'    => esc_html__( 'Section Label', 'grshop-grocery' ),
		'section'  => 'grshop_grocery_blog',
		'default'  => esc_html__( 'Top Picks', 'grshop-grocery' ),
		'priority' => 10,
	]
);

new \Kirki\Field\Text(
	[
		'settings' => 'b_section_title',
		'label'    => esc_html__( 'Section Title', 'grshop-grocery' ),
		'section'  => 'grshop_grocery_blog',
		'default'  => esc_html__( 'Latest', 'grshop-grocery' ),
		'priority' => 10,
	]
);

new \Kirki\Field\Text(
	[
		'settings' => 'b_section_focus',
		'label'    => esc_html__( 'Section Focus Title', 'grshop-grocery' ),
		'section'  => 'grshop_grocery_blog',
		'default'  => esc_html__( 'Products', 'grshop-grocery' ),
		'priority' => 10,
	]
);

new \Kirki\Field\Slider(
	[
		'settings' => 'show_post',
		'label'    => esc_html__( 'Show Post', 'grshop-grocery' ),
		'section'  => 'grshop_grocery_blog',
		'default'  => 3,
		'choices'  => [
			'min'  => 3,
		],
	]
);

$categories = get_categories(); // Retrieve all blog categories
$choices = [];

// Loop through categories and build choices array
foreach ( $categories as $category ) {
    $choices[ $category->term_id ] = $category->name;
}

// Create Kirki select field
new \Kirki\Field\Select( [
    'settings'    => 'select_blog_category',
    'label'       => esc_html__( 'Select Category', 'grshop-grocery' ),
    'section'     => 'grshop_grocery_blog',
    'default'     => 'option-3',
    'placeholder' => esc_html__( 'Choose an option', 'grshop-grocery' ),
    'choices'     => $choices,
] );




/* Product Category Settings */
new \Kirki\Section(
	'grshop_grocery_page_breadcrumb',
	[
		'title'       => esc_html__( 'Breadcrumbs', 'grshop-grocery' ),
		'description' => esc_html__( 'Breadcrumbs Settings.', 'grshop-grocery' ),
		'panel'       => 'grshop_grocery_panel_id',
		'priority'    => 160,
	]
);

new \Kirki\Field\Checkbox(
	[
		'settings'    => 'grshop_grocery_page_bc',
		'label'       => esc_html__( 'Show page breadcrumb', 'grshop-grocery' ),
		'section'     => 'grshop_grocery_page_breadcrumb',
		'default'     => true,
	]
);

new \Kirki\Field\Checkbox(
	[
		'settings'    => 'grshop_grocery_archive_bc',
		'label'       => esc_html__( 'Show Archive breadcrumb', 'grshop-grocery' ),
		'section'     => 'grshop_grocery_page_breadcrumb',
		'default'     => true,
	]
);

new \Kirki\Field\Text(
	[
		'settings' => 'grshop_grocery_bc_archive_title',
		'label'    => esc_html__( 'Archive Breadcrumb Title', 'grshop-grocery' ),
		'section'  => 'grshop_grocery_page_breadcrumb',
		'default'  => esc_html__( 'All Blogs', 'grshop-grocery' ),
		'priority' => 10,
	]
);


new \Kirki\Field\Checkbox(
	[
		'settings'    => 'grshop_grocery_search_bc',
		'label'       => esc_html__( 'Show Search breadcrumb', 'grshop-grocery' ),
		'section'     => 'grshop_grocery_page_breadcrumb',
		'default'     => true,
	]
);