<?php
/**
 * Kirki Customizer Settings for Related Posts
 */

// Ensure Kirki is loaded
if ( ! class_exists( 'Kirki' ) ) {
    return;
}

// Add Related Posts Section
Kirki::add_section( 'related_posts_section', array(
    'title'          => esc_html__( 'Related Posts Settings', 'book-review-blog' ),
    'description'    => esc_html__( 'Customize the related posts section display options.', 'book-review-blog' ),
    'panel'          => 'book_review_blog_global_panel', // Optional: Add to a panel if it exists
) );

// Number of Related Posts
Kirki::add_field( 'book_review_blog_config', array(
    'type'        => 'number',
    'settings'    => 'related_posts_count',
    'label'       => esc_html__( 'Number of Related Posts', 'book-review-blog' ),
    'section'     => 'related_posts_section',
    'default'     => 3,
    'choices'     => array(
        'min'  => 1,
        'max'  => 6,
        'step' => 1,
    ),
) );

// Related Posts Order
Kirki::add_field( 'book_review_blog_config', array(
    'type'        => 'select',
    'settings'    => 'related_posts_order',
    'label'       => esc_html__( 'Related Posts Order', 'book-review-blog' ),
    'section'     => 'related_posts_section',
    'default'     => 'rand',
    'choices'     => array(
        'rand'   => esc_html__( 'Random', 'book-review-blog' ),
        'date'   => esc_html__( 'Date', 'book-review-blog' ),
        'title'  => esc_html__( 'Title', 'book-review-blog' ),
    ),
) );

// Section Title
Kirki::add_field( 'book_review_blog_config', array(
    'type'        => 'text',
    'settings'    => 'related_posts_section_title',
    'label'       => esc_html__( 'Related Posts Section Title', 'book-review-blog' ),
    'section'     => 'related_posts_section',
    'default'     => esc_html__( 'Related Posts', 'book-review-blog' ),
) );

// Excerpt Length
Kirki::add_field( 'book_review_blog_config', array(
    'type'        => 'number',
    'settings'    => 'related_post_excerpt_length',
    'label'       => esc_html__( 'Excerpt Length (words)', 'book-review-blog' ),
    'section'     => 'related_posts_section',
    'default'     => 20,
    'choices'     => [
        'min'  => 0,
        'max'  => 400,
        'step' => 1,
    ],
) );

// Read More Text
Kirki::add_field( 'book_review_blog_config', array(
    'type'        => 'text',
    'settings'    => 'related_post_read_more_text',
    'label'       => esc_html__( 'Read More Button Text', 'book-review-blog' ),
    'section'     => 'related_posts_section',
    'default'     => esc_html__( 'Read More', 'book-review-blog' ),
) );

// Show/Hide Elements
Kirki::add_field( 'book_review_blog_config', array(
    'type'        => 'toggle',
    'settings'    => 'show_related_post_category',
    'label'       => esc_html__( 'Show Post Categories', 'book-review-blog' ),
    'section'     => 'related_posts_section',
    'default'     => true,
) );

Kirki::add_field( 'book_review_blog_config', array(
    'type'        => 'toggle',
    'settings'    => 'show_related_post_thumbnail',
    'label'       => esc_html__( 'Show Post Thumbnail', 'book-review-blog' ),
    'section'     => 'related_posts_section',
    'default'     => true,
) );

Kirki::add_field( 'book_review_blog_config', array(
    'type'        => 'toggle',
    'settings'    => 'show_related_post_date',
    'label'       => esc_html__( 'Show Post Date', 'book-review-blog' ),
    'section'     => 'related_posts_section',
    'default'     => true,
) );

Kirki::add_field( 'book_review_blog_config', array(
    'type'        => 'toggle',
    'settings'    => 'show_related_post_author',
    'label'       => esc_html__( 'Show Post Author', 'book-review-blog' ),
    'section'     => 'related_posts_section',
    'default'     => true,
) );

Kirki::add_field( 'book_review_blog_config', array(
    'type'        => 'toggle',
    'settings'    => 'show_related_post_title',
    'label'       => esc_html__( 'Show Post Title', 'book-review-blog' ),
    'section'     => 'related_posts_section',
    'default'     => true,
) );

Kirki::add_field( 'book_review_blog_config', array(
    'type'        => 'toggle',
    'settings'    => 'show_related_post_excerpt',
    'label'       => esc_html__( 'Show Post Excerpt', 'book-review-blog' ),
    'section'     => 'related_posts_section',
    'default'     => true,
) );

Kirki::add_field( 'book_review_blog_config', array(
    'type'        => 'toggle',
    'settings'    => 'show_related_post_read_more',
    'label'       => esc_html__( 'Show Read More Button', 'book-review-blog' ),
    'section'     => 'related_posts_section',
    'default'     => true,
) );
