<?php
/**
 * Suggested Blog section
 *
 * @package United Blog
 */

$default = united_blog_get_default_theme_options();

// Fearured Blog Section.
$wp_customize->add_section('suggested_blog_settings',
    array(
        'title'      => esc_html__('You May Also Like Section', 'united-blog'),
        'capability' => 'edit_theme_options',
        'panel'      => 'front_page_panel',
        'priority'   => 100,
    )
);

// Setting - show_slider_section.
$wp_customize->add_setting('enable_suggested_blog',
    array(
        'default'           => $default['enable_suggested_blog'],
        'capability'        => 'edit_theme_options',
        'sanitize_callback' => 'united_blog_sanitize_checkbox',
    )
);
$wp_customize->add_control('enable_suggested_blog',
    array(
        'label'    => esc_html__('Enable Suggested Blog', 'united-blog'),
        'section'  => 'suggested_blog_settings',
        'type'     => 'checkbox',
    )
);

$wp_customize->add_setting('suggested_blog_title',
    array(
        'default'           => $default['suggested_blog_title'],
        'capability'        => 'edit_theme_options',
        'sanitize_callback' => 'sanitize_text_field',
    )
);
$wp_customize->add_control('suggested_blog_title',
    array(
        'label'    => esc_html__('Section Title', 'united-blog'),
        'section'  => 'suggested_blog_settings',
        'type'     => 'text',
    )
);

// Setting - drop down category for slider.
$wp_customize->add_setting('select_category_for_suggested_blog',
    array(
        'default'           => $default['select_category_for_suggested_blog'],
        'capability'        => 'edit_theme_options',
        'sanitize_callback' => 'absint',
    )
);
$wp_customize->add_control(new united_blog_Dropdown_Taxonomies_Control($wp_customize, 'select_category_for_suggested_blog',
    array(
        'label'           => esc_html__('Choose Category', 'united-blog'),
        'description'     => __( 'Leave Empty if you don\'t want the posts to be category specific', 'united-blog' ),
        'section'         => 'suggested_blog_settings',
        'type'            => 'dropdown-taxonomies',
        'taxonomy'        => 'category',
    )));



// Show Featured Category.
$wp_customize->add_setting('show_suggested_blog_category',
    array(
        'default'           => $default['show_suggested_blog_category'],
        'capability'        => 'edit_theme_options',
        'sanitize_callback' => 'united_blog_sanitize_checkbox',
    )
);
$wp_customize->add_control('show_suggested_blog_category',
    array(
        'label'    => esc_html__('Show Categories', 'united-blog'),
        'section'  => 'suggested_blog_settings',
        'type'     => 'checkbox',
    )
);

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

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

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

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

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

