<?php
// Ticker Posts Options.
$wp_customize->add_section(
    'home_page_ticker_posts_options',
    array(
        'title' => __( 'Latest Blog Ticker Options', 'united-blog' ),
        'panel' => 'theme_option_panel',
        'priority'   => 3,

    )
);

$wp_customize->add_setting(
    'enable_ticker_posts',
    array(
        'default'           => $default['enable_ticker_posts'],
        'sanitize_callback' => 'united_blog_sanitize_checkbox',
    )
);
$wp_customize->add_control(
    'enable_ticker_posts',
    array(
        'label'    => __( 'Enable Ticker', 'united-blog' ),
        'section'     => 'home_page_ticker_posts_options',
        'type'        => 'checkbox',
    )
);

$wp_customize->add_setting(
    'enable_ticker_label',
    array(
        'default'           => $default['enable_ticker_label'],
        'sanitize_callback' => 'united_blog_sanitize_checkbox',
    )
);
$wp_customize->add_control(
    'enable_ticker_label',
    array(
        'label'           => __( 'Enable Ticker Label', 'united-blog' ),
        'section'     => 'home_page_ticker_posts_options',
        'type'        => 'checkbox',
    )
);

// Ticker Label Text.
$wp_customize->add_setting(
    'ticker_label_text',
    array(
        'default'           => $default['ticker_label_text'],
        'sanitize_callback' => 'sanitize_text_field',
    )
);
$wp_customize->add_control(
    'ticker_label_text',
    array(
        'label'           => __( 'Ticker Label Text', 'united-blog' ),
        'description'     => __( 'Leave empty if you want to use the default text "Latest".', 'united-blog' ),
        'section'         => 'home_page_ticker_posts_options',
        'type'            => 'text',
    )
);

// Ticker Posts Category.
$wp_customize->add_setting(
    'ticker_posts_cat',
    array(
        'default'           => $default['ticker_posts_cat'],
        'sanitize_callback' => 'absint',
    )
);
$wp_customize->add_control(
    new united_blog_Dropdown_Taxonomies_Control(
        $wp_customize,
        'ticker_posts_cat',
        array(
            'label'           => __( 'Choose Ticker posts category', 'united-blog' ),
            'section'         => 'home_page_ticker_posts_options',
        )
    )
);

// No of posts.
$wp_customize->add_setting(
    'no_of_ticker_posts',
    array(
        'default'           => $default['no_of_ticker_posts'],
        'sanitize_callback' => 'absint',
    )
);
$wp_customize->add_control(
    'no_of_ticker_posts',
    array(
        'label'           => __( 'Number of Posts', 'united-blog' ),
        'section'         => 'home_page_ticker_posts_options',
        'type'            => 'number',
    )
);

// Posts Orderby.
$wp_customize->add_setting(
    'ticker_posts_orderby',
    array(
        'default'           => $default['ticker_posts_orderby'],
        'sanitize_callback' => 'united_blog_sanitize_select',
    )
);
$wp_customize->add_control(
    'ticker_posts_orderby',
    array(
        'label'           => __( 'Orderby', 'united-blog' ),
        'section'         => 'home_page_ticker_posts_options',
        'type'            => 'select',
        'choices'         => array(
            'date'  => __( 'Date', 'united-blog' ),
            'id'    => __( 'ID', 'united-blog' ),
            'title' => __( 'Title', 'united-blog' ),
            'rand'  => __( 'Random', 'united-blog' ),
        ),
    )
);

// Posts Order.
$wp_customize->add_setting(
    'ticker_posts_order',
    array(
        'default'           => $default['ticker_posts_order'],
        'sanitize_callback' => 'united_blog_sanitize_select',
    )
);
$wp_customize->add_control(
    'ticker_posts_order',
    array(
        'label'           => __( 'Order', 'united-blog' ),
        'section'         => 'home_page_ticker_posts_options',
        'type'            => 'select',
        'choices'         => array(
            'asc'  => __( 'ASC', 'united-blog' ),
            'desc' => __( 'DESC', 'united-blog' ),
        ),
    )
);


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

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

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

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

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

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

