<?php
/**
 * Post Options
 *
 * @package Cosmic Blog
 */

$wp_customize->add_section(
	'cosmic_blog_post_options',
	array(
		'title' => esc_html__( 'Post Options', 'cosmic-blog' ),
		'panel' => 'cosmic_blog_theme_options',
	)
);

// Post Options - Hide Date.
$wp_customize->add_setting(
	'cosmic_blog_post_hide_date',
	array(
		'default'           => false,
		'sanitize_callback' => 'cosmic_blog_sanitize_switch',
	)
);

$wp_customize->add_control(
	new Cosmic_Blog_Toggle_Switch_Custom_Control(
		$wp_customize,
		'cosmic_blog_post_hide_date',
		array(
			'label'   => esc_html__( 'Hide Date', 'cosmic-blog' ),
			'section' => 'cosmic_blog_post_options',
		)
	)
);

// Post Options - Hide Author.
$wp_customize->add_setting(
	'cosmic_blog_post_hide_author',
	array(
		'default'           => false,
		'sanitize_callback' => 'cosmic_blog_sanitize_switch',
	)
);

$wp_customize->add_control(
	new Cosmic_Blog_Toggle_Switch_Custom_Control(
		$wp_customize,
		'cosmic_blog_post_hide_author',
		array(
			'label'   => esc_html__( 'Hide Author', 'cosmic-blog' ),
			'section' => 'cosmic_blog_post_options',
		)
	)
);

// Post Options - Hide Category.
$wp_customize->add_setting(
	'cosmic_blog_post_hide_category',
	array(
		'default'           => false,
		'sanitize_callback' => 'cosmic_blog_sanitize_switch',
	)
);

$wp_customize->add_control(
	new Cosmic_Blog_Toggle_Switch_Custom_Control(
		$wp_customize,
		'cosmic_blog_post_hide_category',
		array(
			'label'   => esc_html__( 'Hide Category', 'cosmic-blog' ),
			'section' => 'cosmic_blog_post_options',
		)
	)
);

// Post Options - Hide Tag.
$wp_customize->add_setting(
	'cosmic_blog_post_hide_tags',
	array(
		'default'           => false,
		'sanitize_callback' => 'cosmic_blog_sanitize_switch',
	)
);

$wp_customize->add_control(
	new Cosmic_Blog_Toggle_Switch_Custom_Control(
		$wp_customize,
		'cosmic_blog_post_hide_tags',
		array(
			'label'   => esc_html__( 'Hide Tag', 'cosmic-blog' ),
			'section' => 'cosmic_blog_post_options',
		)
	)
);


// Post Options - Related Post Label.
$wp_customize->add_setting(
	'cosmic_blog_post_related_post_label',
	array(
		'default'           => __( 'Related Posts', 'cosmic-blog' ),
		'sanitize_callback' => 'sanitize_text_field',
	)
);

$wp_customize->add_control(
	'cosmic_blog_post_related_post_label',
	array(
		'label'    => esc_html__( 'Related Posts Label', 'cosmic-blog' ),
		'section'  => 'cosmic_blog_post_options',
		'settings' => 'cosmic_blog_post_related_post_label',
		'type'     => 'text',
	)
);

if ( isset( $wp_customize->selective_refresh ) ) {
	$wp_customize->selective_refresh->add_partial(
		'cosmic_blog_post_related_post_label',
		array(
			'selector' => '.related-posts h2',
			'settings' => 'cosmic_blog_post_related_post_label',
		)
	);
}
