<?php
/**
 * Post Options Settings
 *
 * @package Travel Tour
 */

add_action( 'customize_register', 'travel_tour_customize_register_post_options' );

function travel_tour_customize_register_post_options( $wp_customize ) {

	$wp_customize->add_section( 'travel_tour_post_options_section', array(
		'title'       => esc_html__( 'Post Options', 'travel-tour' ),
		'description' => esc_html__( 'Customize Single Posts and Pages', 'travel-tour' ),
		'panel'       => 'travel_tour_general_panel',
		'priority'    => 5,
	) );

	$wp_customize->add_setting( 'travel_tour_post_details', array(
		'sanitize_callback' => 'travel_tour_sanitize_array',
		'default'           => array( 'date', 'categories', 'tags', 'author_block' ),
	) );

	$wp_customize->add_control( new Travel_Tour_Multi_Check_Control(
		$wp_customize, 'travel_tour_post_details', array(
			'label'    => esc_attr__( 'Hide / Show Details', 'travel-tour' ),
			'section'  => 'travel_tour_post_options_section',
			'settings' => 'travel_tour_post_details',
			'type'     => 'multi-check',
			'priority' => 1,
			'choices'  => array(
				'author'            => esc_attr__( 'Show post author', 'travel-tour' ),
				'date'              => esc_attr__( 'Show post date', 'travel-tour' ),
				'categories'        => esc_attr__( 'Show Categories', 'travel-tour' ),
				'tags'              => esc_attr__( 'Show Tags', 'travel-tour' ),
				'number_of_comments' => esc_attr__( 'Show number of comments', 'travel-tour' ),
				'author_block'      => esc_attr__( 'Show Author Block', 'travel-tour' ),
			),
		)
	) );

	$wp_customize->add_setting( 'travel_tour_post_options_separator1', array(
		'sanitize_callback' => null,
	) );

	$wp_customize->add_control( new Travel_Tour_Separator_Control(
		$wp_customize, 'travel_tour_post_options_separator1', array(
			'section'  => 'travel_tour_post_options_section',
			'priority' => 2,
		)
	) );

	$wp_customize->add_setting( 'travel_tour_post_options_featured_image_text', array(
		'default'           => '',
		'type'              => 'customtext',
		'capability'        => 'edit_theme_options',
		'transport'         => 'refresh',
		'sanitize_callback' => 'sanitize_text_field',
	) );

	$wp_customize->add_control( new Travel_Tour_Text_Message_Control(
		$wp_customize, 'travel_tour_post_options_featured_image_text', array(
			'label'    => esc_html__( 'Featured Image Options', 'travel-tour' ),
			'section'  => 'travel_tour_post_options_section',
			'settings' => 'travel_tour_post_options_featured_image_text',
			'priority' => 3,
		)
	) );

	$wp_customize->add_setting( 'travel_tour_featured_image_width', array(
		'default'           => 'full',
		'sanitize_callback' => travel_tour_sanitize_choices_with_max_value( 'full', 400, 1200, array( 'full' ) ),
	) );

	$wp_customize->add_control( new Travel_Tour_Slider_Control(
		$wp_customize, 'travel_tour_featured_image_width', array(
			'section'     => 'travel_tour_post_options_section',
			'settings'    => 'travel_tour_featured_image_width',
			'label'       => esc_attr__( 'Image width', 'travel-tour' ),
			'description' => esc_attr__( 'Set the custom width of the featured image on single pages and posts.', 'travel-tour' ),
			'priority'    => 5,
			'choices'     => array(
				'min'       => 400,
				'max'       => 1200,
				'step'      => 50,
				'suffix'    => 'px',
				'max_value' => 'full',
				'max_text'  => esc_attr__( 'Full', 'travel-tour' ),
			),
		)
	) );

	$wp_customize->add_setting( 'travel_tour_featured_image_max_height', array(
		'default'           => 'full',
		'sanitize_callback' => travel_tour_sanitize_choices_with_max_value( 'full', 200, 800, array( 'full' ) ),
	) );

	$wp_customize->add_control( new Travel_Tour_Slider_Control(
		$wp_customize, 'travel_tour_featured_image_max_height', array(
			'section'     => 'travel_tour_post_options_section',
			'settings'    => 'travel_tour_featured_image_max_height',
			'label'       => esc_attr__( 'Featured image max height', 'travel-tour' ),
			'description' => esc_attr__( 'Set the custom maximal height of the featured image on single pages and posts.', 'travel-tour' ),
			'choices'     => array(
				'min'       => 200,
				'max'       => 800,
				'step'      => 25,
				'suffix'    => 'px',
				'max_value' => 'full',
				'max_text'  => esc_attr__( 'Full', 'travel-tour' ),
			),
		)
	) );

	$wp_customize->add_setting( 'travel_tour_featured_image_position', array(
		'default'           => 'center',
		'sanitize_callback' => 'travel_tour_sanitize_choices',
	) );

	$wp_customize->add_control( 'travel_tour_featured_image_position', array(
		'settings'    => 'travel_tour_featured_image_position',
		'label'       => esc_attr__( 'Featured image position', 'travel-tour' ),
		'description' => esc_attr__( 'Choose the position of the featured image on single pages and posts.', 'travel-tour' ),
		'section'     => 'travel_tour_post_options_section',
		'type'        => 'select',
		'choices'     => array(
			'left'   => esc_attr__( 'Left', 'travel-tour' ),
			'center' => esc_attr__( 'Center', 'travel-tour' ),
			'right'  => esc_attr__( 'Right', 'travel-tour' ),
		),
	) );
}
