<?php
/**
 * Theme Ostrich Customizer
 *
 * @package Return Blog
 *
 * featured section
 */

$wp_customize->add_section(
	'return_blog_featured',
	array(
		'title' => esc_html__( 'featured', 'return-blog' ),
		'panel' => 'return_blog_home_panel',
	)
);

// featured enable settings
$wp_customize->add_setting(
	'return_blog_featured',
	array(
		'sanitize_callback' => 'return_blog_sanitize_select',
		'default' => 'disable'
	)
);

$wp_customize->add_control(
	'return_blog_featured',
	array(
		'section'		=> 'return_blog_featured',
		'label'			=> esc_html__( 'Content type:', 'return-blog' ),
		'description'			=> esc_html__( 'Choose where you want to render the content from.', 'return-blog' ),
		'type'			=> 'select',
		'choices'		=> array( 
				'disable' => esc_html__( '--Disable--', 'return-blog' ),
				'page' => esc_html__( 'Page', 'return-blog' ),
		 	)
	)
);
$wp_customize->add_setting(
	'return_blog_featured_title',
	array(
		'sanitize_callback' => 'sanitize_text_field',
		'transport'	=> 'postMessage',
	)
);

$wp_customize->add_control(
	'return_blog_featured_title',
	array(
		'section'		=> 'return_blog_featured',
		'label'			=> esc_html__( 'Title:', 'return-blog' ),
		'active_callback'	=> 'return_blog_if_featured_enabled',
	)
);

$wp_customize->add_setting(
	'return_blog_featured_sub_title',
	array(
		'sanitize_callback' => 'sanitize_text_field',
		'transport'	=> 'postMessage',
	)
);

$wp_customize->add_control(
	'return_blog_featured_sub_title',
	array(
		'section'		=> 'return_blog_featured',
		'label'			=> esc_html__( 'Sub Title:', 'return-blog' ),
		'active_callback'	=> 'return_blog_if_featured_enabled',
	)
);


for ($i=1; $i <= 6 ; $i++) { 
	
	// featured post setting
	$wp_customize->add_setting(
		'return_blog_featured_post_'.$i,
		array(
			'sanitize_callback' => 'return_blog_sanitize_dropdown_pages',
		)
	);

	$wp_customize->add_control(
		'return_blog_featured_post_'.$i,
		array(
			'section'		=> 'return_blog_featured',
			'label'			=> esc_html__( 'Post ', 'return-blog' ).$i,
			'active_callback' => 'return_blog_if_featured_post',
			'type'			=> 'select',
			'choices'		=> return_blog_get_post_choices(),
		)
	);

	// featured page setting
	$wp_customize->add_setting(
		'return_blog_featured_page_'.$i,
		array(
			'sanitize_callback' => 'return_blog_sanitize_dropdown_pages',
			'default' => 0,
		)
	);

	$wp_customize->add_control(
		'return_blog_featured_page_'.$i,
		array(
			'section'		=> 'return_blog_featured',
			'label'			=> esc_html__( 'Page ', 'return-blog' ).$i,
			'type'			=> 'dropdown-pages',
			'active_callback' => 'return_blog_if_featured_page'
		)
	);
}

// featured category setting
$wp_customize->add_setting(
	'return_blog_featured_cat',
	array(
		'sanitize_callback' => 'return_blog_sanitize_select',
	)
);

$wp_customize->add_control(
	'return_blog_featured_cat',
	array(
		'section'		=> 'return_blog_featured',
		'label'			=> esc_html__( 'Category:', 'return-blog' ),
		'active_callback' => 'return_blog_if_featured_cat',
		'type'			=> 'select',
		'choices'		=> return_blog_get_post_cat_choices(),
	)
);