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

// Add section.
$wp_customize->add_section(
	'rubik_news_latest_featured_posts_section',
	array(
		'title'    => __( 'Latest News & Featured Posts', 'rubik-news' ),
		'panel'    => 'rubik_news_homepage_sections_panel',
		'priority' => 40,
	)
);

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

$wp_customize->add_control(
	'enable_latest_featured_posts',
	array(
		'label'   => __( 'Enable Latest News & Featured Posts', 'rubik-news' ),
		'section' => 'rubik_news_latest_featured_posts_section',
		'type'    => 'checkbox',
	)
);

/*
 * Latest News options.
 */

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

$wp_customize->add_control(
	'latest_news_title',
	array(
		'label'   => __( 'Latest News Title', 'rubik-news' ),
		'section' => 'rubik_news_latest_featured_posts_section',
		'type'    => 'text',
	)
);

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

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

// Latest News posts number.
$wp_customize->add_setting(
	'latest_news_posts_number',
	array(
		'default'           => 4,
		'sanitize_callback' => 'rubik_news_sanitize_number_range',
	)
);

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

/*
 * Featured Posts options.
 */

// Featured Posts title.
$wp_customize->add_setting(
	'featured_posts_title',
	array(
		'default'           => __( 'Featured Posts', 'rubik-news' ),
		'sanitize_callback' => 'sanitize_text_field',
	)
);

$wp_customize->add_control(
	'featured_posts_title',
	array(
		'label'   => __( 'Featured Posts Title', 'rubik-news' ),
		'section' => 'rubik_news_latest_featured_posts_section',
		'type'    => 'text',
	)
);

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

$wp_customize->add_control(
	'featured_posts_category',
	array(
		'label'       => __( 'Featured Posts Category', 'rubik-news' ),
		'description' => __( 'The first post will use the large featured layout.', 'rubik-news' ),
		'section'     => 'rubik_news_latest_featured_posts_section',
		'type'        => 'select',
		'choices'     => rubik_news_get_post_category_choices(),
	)
);

// Featured Posts number.
$wp_customize->add_setting(
	'featured_posts_number',
	array(
		'default'           => 5,
		'sanitize_callback' => 'rubik_news_sanitize_number_range',
	)
);

$wp_customize->add_control(
	'featured_posts_number',
	array(
		'label'       => __( 'Number of Featured Posts', 'rubik-news' ),
		'description' => __( 'The first post is displayed prominently.', 'rubik-news' ),
		'section'     => 'rubik_news_latest_featured_posts_section',
		'type'        => 'number',
		'input_attrs' => array(
			'min'  => 1,
			'max'  => 10,
			'step' => 1,
		),
	)
);