<?php

/**
 * Related Post Options
 *
 * @package fast_food_joint
 */

$wp_customize->add_section(
	'fast_food_joint_related_post_options',
	array(
		'title' => esc_html__( 'Related Post Options', 'fast-food-joint' ),
		'panel' => 'fast_food_joint_theme_options',
	)
);


// Add Separator Custom Control
$wp_customize->add_setting( 'fast_food_joint_related_post_separator', array(
	'sanitize_callback' => 'sanitize_text_field',
) );

$wp_customize->add_control( new Fast_Food_Joint_Separator_Custom_Control( $wp_customize, 'fast_food_joint_related_post_separator', array(
	'label' => __( 'Enable / Disable Related Post Section', 'fast-food-joint' ),
	'section' => 'fast_food_joint_related_post_options',
	'settings' => 'fast_food_joint_related_post_separator',
) ) );

// Post Options - Show / Hide Related Posts.
$wp_customize->add_setting(
	'fast_food_joint_post_hide_related_posts',
	array(
		'default'           => true,
		'sanitize_callback' => 'fast_food_joint_sanitize_switch',
	)
);

$wp_customize->add_control(
	new Fast_Food_Joint_Toggle_Switch_Custom_Control(
		$wp_customize,
		'fast_food_joint_post_hide_related_posts',
		array(
			'label'   => esc_html__( 'Show / Hide Related Posts', 'fast-food-joint' ),
			'section' => 'fast_food_joint_related_post_options',
		)
	)
);

// Register setting for number of related posts
$wp_customize->add_setting(
    'fast_food_joint_related_posts_count',
    array(
        'default'           => '',
        'sanitize_callback' => 'absint', // Ensure it's an integer
    )
);

// Add control for number of related posts
$wp_customize->add_control(
    'fast_food_joint_related_posts_count',
    array(
        'type'        => 'number',
        'label'       => esc_html__( 'Number of Related Posts to Display', 'fast-food-joint' ),
        'section'     => 'fast_food_joint_related_post_options',
        'input_attrs' => array(
            'min'  => 1,
            'max'  => 5, // Adjust maximum based on your preference
            'step' => 1,
        ),
    )
);

// Post Options - Related Post Label.
$wp_customize->add_setting(
	'fast_food_joint_post_related_post_label',
	array(
		'default'           => '',
		'sanitize_callback' => 'sanitize_text_field',
	)
);

$wp_customize->add_control(
	'fast_food_joint_post_related_post_label',
	array(
		'label'    => esc_html__( 'Related Posts Label', 'fast-food-joint' ),
		'section'  => 'fast_food_joint_related_post_options',
		'settings' => 'fast_food_joint_post_related_post_label',
		'type'     => 'text',
	)
);
