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

$default = united_blog_get_default_theme_options();

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

$wp_customize->add_setting(
    'archive_posts_layout',
    array(
        'default'           => $default['archive_posts_layout'],
        'sanitize_callback' => 'united_blog_sanitize_select',
    )
);
$wp_customize->add_control(
    'archive_posts_layout',
    array(
        'label'           => __( 'Archive Layout', 'united-blog' ),
        'section'         => 'archive_settings',
        'type'            => 'select',
        'choices'         => array(
            'archive-layout-1' => __( 'Archive Layout 1', 'united-blog' ),
            'archive-layout-2' => __( 'Archive Layout 2', 'united-blog' ),
        ),
    )
);


// Setting - read_more_button_text.
$wp_customize->add_setting('read_more_button_text',
    array(
        'default'           => $default['read_more_button_text'],
        'capability'        => 'edit_theme_options',
        'sanitize_callback' => 'sanitize_text_field',
    )
);
$wp_customize->add_control('read_more_button_text',
    array(
        'label'    => esc_html__('Button Text for Read More', 'united-blog'),
        'section'  => 'archive_settings',
        'type'     => 'text',
    )
);

/*content excerpt in global*/
$wp_customize->add_setting('excerpt_length_global',
    array(
        'default'           => $default['excerpt_length_global'],
        'capability'        => 'edit_theme_options',
        'sanitize_callback' => 'united_blog_sanitize_positive_integer',
    )
);
$wp_customize->add_control('excerpt_length_global',
    array(
        'label'       => esc_html__('Archive Excerpt Length', 'united-blog'),
        'section'     => 'archive_settings',
        'type'        => 'number',
        'input_attrs' => array('min' => 1, 'max' => 200, 'style' => 'width: 150px;'),

    )
);


// Setting pagination_type.
$wp_customize->add_setting('pagination_type',
    array(
        'default'           => $default['pagination_type'],
        'capability'        => 'edit_theme_options',
        'sanitize_callback' => 'united_blog_sanitize_select',
    )
);
$wp_customize->add_control('pagination_type',
    array(
        'label'    => esc_html__('Pagination Type', 'united-blog'),
        'section'  => 'archive_settings',
        'type'     => 'select',
        'choices'  => array(
            'numeric' => esc_html__('Numeric', 'united-blog'),
            'default' => esc_html__('Default (Older / Newer Post)', 'united-blog'),
        ),
        'priority' => 100,
    )
);

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

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

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

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

// Show Post Meta Icon.
$wp_customize->add_setting('show_archive_post_meta_icon',
    array(
        'default'           => $default['show_archive_post_meta_icon'],
        'capability'        => 'edit_theme_options',
        'sanitize_callback' => 'united_blog_sanitize_checkbox',
    )
);
$wp_customize->add_control('show_archive_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'  => 'archive_settings',
        'type'     => 'checkbox',
    )
);

// Banner Date Format
$wp_customize->add_setting(
    'archive_posts_date_format',
    array(
        'default'           => $default['archive_posts_date_format'],
        'sanitize_callback' => 'united_blog_sanitize_select',
    )
);
$wp_customize->add_control(
    'archive_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'         => 'archive_settings',
        'type'            => 'select',
        'choices'         => array(
            'format_1' => __( 'Times Ago', 'united-blog' ),
            'format_2' => __( 'Default Format', 'united-blog' ),
        ),
    )
);

