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



$wp_customize->add_section(
	'ostrich_magazine_latest',
	array(
		'title' => esc_html__( 'Latest Section', 'ostrich-magazine' ),
		'panel' => 'ostrich_magazine_home_panel',
	)
);

$wp_customize->add_setting( 'ostrich_magazine_latest_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_latest_enable',
	array(
		'label' => esc_html__( 'Enable Latest Section', 'ostrich-magazine' ),
		'section' => 'ostrich_magazine_latest'
	)
) );

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

$wp_customize->add_control(
	'ostrich_magazine_latest_label',
	array(
		'section'		=> 'ostrich_magazine_latest',
		'label'			=> esc_html__( 'Hot Topic Section Label', 'ostrich-magazine' ),
		'active_callback'	=> 'ostrich_magazine_if_latest_enabled',
	)
);


for ($i=1; $i <= 2 ; $i++) { 
// latest category setting
$wp_customize->add_setting(
	'ostrich_magazine_latest_cat_'.$i,
	array(
		'sanitize_callback' => 'ostrich_magazine_sanitize_select',
	)
);

$wp_customize->add_control(
	'ostrich_magazine_latest_cat_'.$i,
	array(
		'section'		=> 'ostrich_magazine_latest',
		'label'			=> esc_html__( 'Category ', 'ostrich-magazine' ).$i,
		'active_callback' => 'ostrich_magazine_if_latest_enabled',
		'type'			=> 'select',
		'choices'		=> ostrich_magazine_get_post_cat_choices(),
	)
);

}
