<?php
/**
* World News Section options
*
* @package Theme Palace
* @subpackage Newstation
* @since Newstation 1.0.0
*/

// Add World News section
$wp_customize->add_section( 'newstation_world_news_section', array(
	'title'             => esc_html__( 'World News','newstation' ),
	'description'       => esc_html__( 'World News Section options.', 'newstation' ),
	'panel'             => 'newstation_front_page_panel',
) );

// World News content enable control and setting
$wp_customize->add_setting( 'newstation_theme_options[world_news_section_enable]', array(
	'default'			=> 	$options['world_news_section_enable'],
	'sanitize_callback' => 'newstation_sanitize_switch_control',
	) );

$wp_customize->add_control( new Newstation_Switch_Control( $wp_customize, 'newstation_theme_options[world_news_section_enable]', array(
	'label'             => esc_html__( 'World News Section Enable', 'newstation' ),
	'section'           => 'newstation_world_news_section',
	'on_off_label' 		=> newstation_switch_options(),
	) ) );

// world_news title setting and control
$wp_customize->add_setting( 'newstation_theme_options[world_news_title]', array(
	'sanitize_callback' => 'sanitize_text_field',
	'default'			=> $options['world_news_title'],
	'transport'			=> 'postMessage',
	) );

$wp_customize->add_control( 'newstation_theme_options[world_news_title]', array(
	'label'           	=> esc_html__( 'Title', 'newstation' ),
	'section'        	=> 'newstation_world_news_section',
	'active_callback' 	=> 'newstation_is_world_news_section_enable',
	'type'				=> 'text',
	) );

// Abort if selective refresh is not available.
if ( isset( $wp_customize->selective_refresh ) ) {
	$wp_customize->selective_refresh->add_partial( 'newstation_theme_options[world_news_title]', array(
		'selector'            => '#main-post-wrapper #world-news .section-title',
		'settings'            => 'newstation_theme_options[world_news_title]',
		'container_inclusive' => false,
		'fallback_refresh'    => true,
		'render_callback'     => 'newstation_world_news_title_partial',
		) );
}

for ( $i = 1; $i <= 4; $i++ ) :

// World News posts drop down chooser control and setting
$wp_customize->add_setting( 'newstation_theme_options[world_news_content_post_' . $i . ']', array(
	'sanitize_callback' => 'newstation_sanitize_page',
	) );

$wp_customize->add_control( new Newstation_Dropdown_Chooser( $wp_customize, 'newstation_theme_options[world_news_content_post_' . $i . ']', array(
	'label'             => sprintf( esc_html__( 'Select Post %d', 'newstation' ), $i ),
	'section'           => 'newstation_world_news_section',
	'choices'			=> newstation_post_choices(),
	'active_callback'	=> 'newstation_is_world_news_section_enable',
	) ) );

endfor;