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

// Add Trending News section.
$wp_customize->add_section(
	'rubik_news_trending_news_section',
	array(
		'title'    => __( 'Trending News', 'rubik-news' ),
		'panel'    => 'rubik_news_homepage_sections_panel',
		'priority' => 30,
	)
);

// Enable section.
$wp_customize->add_setting(
	'enable_trending_news',
	array(
		'default'           => true,
		'sanitize_callback' => 'rubik_news_sanitize_checkbox',
	)
);

$wp_customize->add_control(
	'enable_trending_news',
	array(
		'label'   => __( 'Enable Trending News', 'rubik-news' ),
		'section' => 'rubik_news_trending_news_section',
		'type'    => 'checkbox',
	)
);

// Section title.
$wp_customize->add_setting(
	'trending_news_title',
	array(
		'default'           => __( 'Trending Now', 'rubik-news' ),
		'sanitize_callback' => 'sanitize_text_field',
	)
);

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

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

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

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

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

// Show ranking number.
$wp_customize->add_setting(
	'trending_news_show_number',
	array(
		'default'           => true,
		'sanitize_callback' => 'rubik_news_sanitize_checkbox',
	)
);

$wp_customize->add_control(
	'trending_news_show_number',
	array(
		'label'   => __( 'Show Ranking Number', 'rubik-news' ),
		'section' => 'rubik_news_trending_news_section',
		'type'    => 'checkbox',
	)
);