<?php
/**
 * Breaking News Customizer options.
 *
 * @package Rubik News
 */

// Add Breaking News Section
$wp_customize->add_section(
	'rubik_news_breaking_news_section',
	array(
		'title'       => __( 'Breaking News', 'rubik-news' ),
		'panel'       => 'rubik_news_homepage_sections_panel',
		'priority'    => 10,
	)
);

// Enable Breaking News.
$wp_customize->add_setting(
	'enable_breaking_news',
	array(
		'default'           => true,
		'sanitize_callback' => 'rubik_news_sanitize_checkbox',
	)
);

$wp_customize->add_control(
	'enable_breaking_news',
	array(
		'label'   => __( 'Enable Breaking News', 'rubik-news' ),
		'section' => 'rubik_news_breaking_news_section',
		'type'    => 'checkbox',
	)
);

// Section title.
$wp_customize->add_setting(
	'breaking_news_title',
	array(
		'default'           => __( 'Breaking News', 'rubik-news' ),
		'sanitize_callback' => 'sanitize_text_field',
	)
);

$wp_customize->add_control(
	'breaking_news_title',
	array(
		'label'   => __( 'Section Title', 'rubik-news' ),
		'section' => 'rubik_news_breaking_news_section',
		'type'    => 'text',
	)
);

// Post category.
$wp_customize->add_setting(
	'breaking_news_category',
	array(
		'default'           => 0,
		'sanitize_callback' => 'absint',
	)
);

$wp_customize->add_control(
	'breaking_news_category',
	array(
		'label'       => __( 'News Category', 'rubik-news' ),
		'description' => __(
			'Choose a category for the breaking-news posts.',
			'rubik-news'
		),
		'section'     => 'rubik_news_breaking_news_section',
		'type'        => 'select',
		'choices'     => rubik_news_get_post_category_choices(),
	)
);

// Number of posts.
$wp_customize->add_setting(
	'breaking_news_posts_number',
	array(
		'default'           => 6,
		'sanitize_callback' => 'rubik_news_sanitize_number_range',
	)
);

$wp_customize->add_control(
	'breaking_news_posts_number',
	array(
		'label'       => __( 'Number of Posts', 'rubik-news' ),
		'section'     => 'rubik_news_breaking_news_section',
		'type'        => 'number',
		'input_attrs' => array(
			'min'  => 1,
			'max'  => 20,
			'step' => 1,
		),
	)
);

// Autoplay speed.
$wp_customize->add_setting(
	'breaking_news_autoplay_speed',
	array(
		'default'           => 5000,
		'sanitize_callback' => 'rubik_news_sanitize_number_range',
	)
);

$wp_customize->add_control(
	'breaking_news_autoplay_speed',
	array(
		'label'       => __( 'Autoplay Speed', 'rubik-news' ),
		'description' => __(
			'Time between headlines in milliseconds.',
			'rubik-news'
		),
		'section'     => 'rubik_news_breaking_news_section',
		'type'        => 'number',
		'input_attrs' => array(
			'min'  => 1000,
			'max'  => 20000,
			'step' => 500,
		),
	)
);