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



$wp_customize->add_section(
	'ostrich_magazine_technology',
	array(
		'title' => esc_html__( 'Technology', 'ostrich-magazine' ),
		'panel' => 'ostrich_magazine_home_panel',
	)
);

$wp_customize->add_setting( 'ostrich_magazine_technology_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_technology_enable',
	array(
		'label' => esc_html__( 'Enable Technology Section', 'ostrich-magazine' ),
		'section' => 'ostrich_magazine_technology'
	)
) );

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

$wp_customize->add_control(
	'ostrich_magazine_technology',
	array(
		'section'		=> 'ostrich_magazine_technology',
		'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_technology_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_technology_label',
	array(
		'sanitize_callback' => 'sanitize_text_field',
		'default' => esc_html__( 'Hot Topics', 'ostrich-magazine' ),
	)
);

$wp_customize->add_control(
	'ostrich_magazine_technology_label',
	array(
		'section'		=> 'ostrich_magazine_technology',
		'label'			=> esc_html__( 'Hot Topic Section Label', 'ostrich-magazine' ),
		'active_callback'	=> 'ostrich_magazine_if_technology_enabled',
	)
);


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

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

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

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

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

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