<?php
/**
 * Theme Ostrich Customizer
 *
 * @package Ostrich Magazine
 *
 * hot_topic section
 */



$wp_customize->add_section(
	'ostrich_magazine_hot_topic',
	array(
		'title' => esc_html__( 'Hot Topics ', 'ostrich-magazine' ),
		'panel' => 'ostrich_magazine_home_panel',
	)
);

$wp_customize->add_setting( 'ostrich_magazine_hot_topic_enable',
	array(
		'default' => 0,
		'transport' => 'refresh',
		'sanitize_callback' => 'ostrich_magazine_switch_sanitization'
	)
);
$wp_customize->add_control( new Ostrich_Magazine_Toggle_Switch_Custom_control( $wp_customize, 'ostrich_magazine_hot_topic_enable',
	array(
		'label' => esc_html__( 'Enable Hot Topic Section', 'ostrich-magazine' ),
		'section' => 'ostrich_magazine_hot_topic'
	)
) );

// hot_topic enable settings
$wp_customize->add_setting(
	'ostrich_magazine_hot_topic',
	array(
		'sanitize_callback' => 'ostrich_magazine_sanitize_select',
		'default' => 'cat'
	)
);

$wp_customize->add_control(
	'ostrich_magazine_hot_topic',
	array(
		'section'		=> 'ostrich_magazine_hot_topic',
		'label'			=> esc_html__( 'Content type:', 'ostrich-magazine' ),
		'description'			=> esc_html__( 'Choose where you want to render the content from.', 'ostrich-magazine' ),
		'type'			=> 'select',
		'active_callback'	=> 'ostrich_magazine_if_hot_topic_enabled',
		'choices'		=> array( 
				'post' => esc_html__( 'Post', 'ostrich-magazine' ),
				'page' => esc_html__( 'Page', 'ostrich-magazine' ),
				'cat' => esc_html__( 'Category', 'ostrich-magazine' ),
		 	)
	)
);

$wp_customize->add_setting(
	'ostrich_magazine_hot_topic_label',
	array(
		'sanitize_callback' => 'sanitize_text_field',
		'default' => esc_html__( 'Hot Topics', 'ostrich-magazine' ),
	)
);

$wp_customize->add_control(
	'ostrich_magazine_hot_topic_label',
	array(
		'section'		=> 'ostrich_magazine_hot_topic',
		'label'			=> esc_html__( 'Hot Topic Section Label', 'ostrich-magazine' ),
		'active_callback'	=> 'ostrich_magazine_if_hot_topic_enabled',
	)
);


for ($i=1; $i <= 4 ; $i++) { 
	// hot_topic post setting
	$wp_customize->add_setting(
		'ostrich_magazine_hot_topic_post_'.$i,
		array(
			'sanitize_callback' => 'ostrich_magazine_sanitize_dropdown_pages',
		)
	);

	$wp_customize->add_control(
		'ostrich_magazine_hot_topic_post_'.$i,
		array(
			'section'		=> 'ostrich_magazine_hot_topic',
			'label'			=> esc_html__( 'Post ', 'ostrich-magazine' ).$i,
			'active_callback' => 'ostrich_magazine_if_hot_topic_post',
			'type'			=> 'select',
			'choices'		=> ostrich_magazine_get_post_choices(),
		)
	);

	// hot_topic page setting
	$wp_customize->add_setting(
		'ostrich_magazine_hot_topic_page_'.$i,
		array(
			'sanitize_callback' => 'ostrich_magazine_sanitize_dropdown_pages',
			'default' => 0,
		)
	);

	$wp_customize->add_control(
		'ostrich_magazine_hot_topic_page_'.$i,
		array(
			'section'		=> 'ostrich_magazine_hot_topic',
			'label'			=> esc_html__( 'Page ', 'ostrich-magazine' ).$i,
			'type'			=> 'dropdown-pages',
			'active_callback' => 'ostrich_magazine_if_hot_topic_page'
		)
	);
}

// hot_topic category setting
$wp_customize->add_setting(
	'ostrich_magazine_hot_topic_cat',
	array(
		'sanitize_callback' => 'ostrich_magazine_sanitize_select',
	)
);

$wp_customize->add_control(
	'ostrich_magazine_hot_topic_cat',
	array(
		'section'		=> 'ostrich_magazine_hot_topic',
		'label'			=> esc_html__( 'Category:', 'ostrich-magazine' ),
		'active_callback' => 'ostrich_magazine_if_hot_topic_cat',
		'type'			=> 'select',
		'choices'		=> ostrich_magazine_get_post_cat_choices(),
	)
);
