<?php
/**
 * Single Options Panel.
 *
 * @package United Blog
 */

$default = united_blog_get_default_theme_options();

/*layout management section start */
$wp_customize->add_section('single_settings',
	array(
		'title'      => esc_html__('Single Options', 'united-blog'),
		'priority'   => 100,
		'capability' => 'edit_theme_options',
		'panel'      => 'theme_option_panel',
	)
);

$wp_customize->add_setting(
    'single_page_layout',
    array(
        'default'           => $default['single_page_layout'],
        'sanitize_callback' => 'united_blog_sanitize_select',
    )
);
$wp_customize->add_control(
    'single_page_layout',
    array(
        'label'           => __( 'Select Single Page Layout', 'united-blog' ),
        'description'     => __( 'Make sure to enable Date post meta from above for this to work.', 'united-blog' ),
        'section'         => 'single_settings',
        'type'            => 'select',
        'choices'         => array(
            'fullwidth_banner_layout' => __( 'Full Width Banner Layout', 'united-blog' ),
            'content_banner_layout' => __( 'Default Format', 'united-blog' ),
        ),
    )
);

$wp_customize->add_setting('united_floating_post_navigation',
    array(
        'default' => $default['united_floating_post_navigation'],
        'capability' => 'edit_theme_options',
        'sanitize_callback' => 'united_blog_sanitize_checkbox',
    )
);
$wp_customize->add_control('united_floating_post_navigation',
    array(
        'label' => esc_html__('Enable Floating Next/Previous Article', 'united-blog'),
        'section' => 'single_settings',
        'type' => 'checkbox',
    )
);

// Setting - related_post.
$wp_customize->add_setting('related_post',
    array(
        'default'           => $default['related_post'],
        'capability'        => 'edit_theme_options',
        'sanitize_callback' => 'united_blog_sanitize_checkbox',
    )
);
$wp_customize->add_control('related_post',
    array(
        'label'    => esc_html__('Enable Related Post on Single post', 'united-blog'),
        'section'  => 'single_settings',
        'type'     => 'checkbox',
    )
);
// Setting related_post_title.
$wp_customize->add_setting('related_post_title',
    array(
        'default'           => $default['related_post_title'],
        'capability'        => 'edit_theme_options',
        'sanitize_callback' => 'sanitize_text_field',
    )
);
$wp_customize->add_control('related_post_title',
    array(
        'label'    => esc_html__('Related Post Title', 'united-blog'),
        'section'  => 'single_settings',
        'type'     => 'text',
    )
);

$wp_customize->add_setting('show_single_category',
    array(
        'default'           => $default['show_single_category'],
        'capability'        => 'edit_theme_options',
        'sanitize_callback' => 'united_blog_sanitize_checkbox',
    )
);
$wp_customize->add_control('show_single_category',
    array(
        'label'    => esc_html__('Show Categories', 'united-blog'),
        'section'  => 'single_settings',
        'type'     => 'checkbox',
    )
);

// Single Categories Display Style Display.
$wp_customize->add_setting(
    'single_category_color_display',
    array(
        'default'           => $default['single_category_color_display'],
        'sanitize_callback' => 'united_blog_sanitize_select',
    )
);
$wp_customize->add_control(
    'single_category_color_display',
    array(
        'label'           => __( 'Single Categories Display Style Display', 'united-blog' ),
        'section'         => 'single_settings',
        'type'            => 'select',
        'choices'         => united_blog_get_category_display_styles(),
    )
);

// No of Banner Categories.
$wp_customize->add_setting(
    'single_category_limit',
    array(
        'default'           => $default['single_category_limit'],
        'sanitize_callback' => 'absint',
    )
);
$wp_customize->add_control(
    'single_category_limit',
    array(
        'label'           => __( 'Number of Categories To Display', 'united-blog' ),
        'section'         => 'single_settings',
        'type'            => 'number',
    )
);

/* Single Posts Meta */
$wp_customize->add_setting(
    'single_post_meta',
    array(
        'default'           => $default['single_post_meta'],
        'sanitize_callback' => 'united_blog_sanitize_checkbox_multiple',
    )
);
$wp_customize->add_control(
    new United_Blog_Checkbox_Multiple(
        $wp_customize,
        'single_post_meta',
        array(
            'label'           => __( 'Single Post Meta', 'united-blog' ),
            'section'         => 'single_settings',
            'choices'         => united_blog_get_post_meta(),
        )
    )
);

// Show Post Meta Icon.
$wp_customize->add_setting('show_single_post_meta_icon',
    array(
        'default'           => $default['show_single_post_meta_icon'],
        'capability'        => 'edit_theme_options',
        'sanitize_callback' => 'united_blog_sanitize_checkbox',
    )
);
$wp_customize->add_control('show_single_post_meta_icon',
    array(
        'label'    => esc_html__('Show Post Meta Icon', 'united-blog'),
            'description'     => __( 'Some Icons may show up regardless to provide better info.', 'united-blog' ),
        'section'  => 'single_settings',
        'type'     => 'checkbox',
    )
);

// Banner Date Format
$wp_customize->add_setting(
    'single_posts_date_format',
    array(
        'default'           => $default['single_posts_date_format'],
        'sanitize_callback' => 'united_blog_sanitize_select',
    )
);
$wp_customize->add_control(
    'single_posts_date_format',
    array(
        'label'           => __( 'Date Format', 'united-blog' ),
        'description'     => __( 'Make sure to enable Date post meta from above for this to work.', 'united-blog' ),
        'section'         => 'single_settings',
        'type'            => 'select',
        'choices'         => array(
            'format_1' => __( 'Times Ago', 'united-blog' ),
            'format_2' => __( 'Default Format', 'united-blog' ),
        ),
    )
);

