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

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

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

$wp_customize->add_control(
	'enable_featured_news',
	array(
		'label'   => __( 'Enable Featured News', 'rubik-news' ),
		'section' => 'rubik_news_featured_news_section',
		'type'    => 'checkbox',
	)
);

// Featured News category.
$wp_customize->add_setting(
	'featured_news_category',
	array(
		'default'           => 0,
		'sanitize_callback' => 'absint',
	)
);

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

// Show category.
$wp_customize->add_setting(
	'featured_news_show_category',
	array(
		'default'           => true,
		'sanitize_callback' => 'rubik_news_sanitize_checkbox',
	)
);

$wp_customize->add_control(
	'featured_news_show_category',
	array(
		'label'   => __( 'Show Post Category', 'rubik-news' ),
		'section' => 'rubik_news_featured_news_section',
		'type'    => 'checkbox',
	)
);

// Show excerpt on the large post.
$wp_customize->add_setting(
	'featured_news_show_excerpt',
	array(
		'default'           => true,
		'sanitize_callback' => 'rubik_news_sanitize_checkbox',
	)
);

$wp_customize->add_control(
	'featured_news_show_excerpt',
	array(
		'label'   => __( 'Show Featured Post Excerpt', 'rubik-news' ),
		'section' => 'rubik_news_featured_news_section',
		'type'    => 'checkbox',
	)
);

// Excerpt length.
$wp_customize->add_setting(
	'featured_news_excerpt_length',
	array(
		'default'           => 18,
		'sanitize_callback' => 'rubik_news_sanitize_number_range',
	)
);

$wp_customize->add_control(
	'featured_news_excerpt_length',
	array(
		'label'       => __( 'Excerpt Length', 'rubik-news' ),
		'description' => __( 'Number of words in the excerpt.', 'rubik-news' ),
		'section'     => 'rubik_news_featured_news_section',
		'type'        => 'number',
		'input_attrs' => array(
			'min'  => 5,
			'max'  => 50,
			'step' => 1,
		),
	)
);

// Show author.
$wp_customize->add_setting(
	'featured_news_show_author',
	array(
		'default'           => true,
		'sanitize_callback' => 'rubik_news_sanitize_checkbox',
	)
);

$wp_customize->add_control(
	'featured_news_show_author',
	array(
		'label'   => __( 'Show Post Author', 'rubik-news' ),
		'section' => 'rubik_news_featured_news_section',
		'type'    => 'checkbox',
	)
);

// Show date.
$wp_customize->add_setting(
	'featured_news_show_date',
	array(
		'default'           => true,
		'sanitize_callback' => 'rubik_news_sanitize_checkbox',
	)
);

$wp_customize->add_control(
	'featured_news_show_date',
	array(
		'label'   => __( 'Show Post Date', 'rubik-news' ),
		'section' => 'rubik_news_featured_news_section',
		'type'    => 'checkbox',
	)
);

// Show comments.
$wp_customize->add_setting(
	'featured_news_show_comments',
	array(
		'default'           => true,
		'sanitize_callback' => 'rubik_news_sanitize_checkbox',
	)
);

$wp_customize->add_control(
	'featured_news_show_comments',
	array(
		'label'   => __( 'Show Comment Count', 'rubik-news' ),
		'section' => 'rubik_news_featured_news_section',
		'type'    => 'checkbox',
	)
);