<?php

/**
 * Related Post Options
 *
 * @package wheel_alignment_service
 */

$wp_customize->add_section(
	'wheel_alignment_service_related_post_options',
	array(
		'title' => esc_html__( 'Related Post Options', 'wheel-alignment-service' ),
		'panel' => 'wheel_alignment_service_theme_options',
	)
);

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

$wp_customize->add_control( new Wheel_Alignment_Service_Separator_Custom_Control( $wp_customize, 'wheel_alignment_service_related_post_separator', array(
	'label' => __( 'Enable / Disable Related Post Section', 'wheel-alignment-service' ),
	'section' => 'wheel_alignment_service_related_post_options',
	'settings' => 'wheel_alignment_service_related_post_separator',
) ) );

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

$wp_customize->add_control(
	new Wheel_Alignment_Service_Toggle_Switch_Custom_Control(
		$wp_customize,
		'wheel_alignment_service_post_hide_related_posts',
		array(
			'label'   => esc_html__( 'Show / Hide Related Posts', 'wheel-alignment-service' ),
			'section' => 'wheel_alignment_service_related_post_options',
		)
	)
);

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

// Add control for number of related posts
$wp_customize->add_control(
    'wheel_alignment_service_related_posts_count',
    array(
        'type'        => 'number',
        'label'       => esc_html__( 'Number of Related Posts to Display', 'wheel-alignment-service' ),
        'section'     => 'wheel_alignment_service_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(
	'wheel_alignment_service_post_related_post_label',
	array(
		'default'           => 'Related Post',
		'sanitize_callback' => 'sanitize_text_field',
	)
);

$wp_customize->add_control(
	'wheel_alignment_service_post_related_post_label',
	array(
		'label'    => esc_html__( 'Related Posts Label', 'wheel-alignment-service' ),
		'section'  => 'wheel_alignment_service_related_post_options',
		'settings' => 'wheel_alignment_service_post_related_post_label',
		'type'     => 'text',
	)
);