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

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

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

$wp_customize->add_control( new Newstation_Switch_Control( $wp_customize, 'newstation_theme_options[breakingnews_section_enable]', array(
	'label'             => esc_html__( 'Breakingnews Section Enable', 'newstation' ),
	'section'           => 'newstation_breakingnews_section',
	'on_off_label' 		=> newstation_switch_options(),
	) ) );

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

$wp_customize->add_control( 'newstation_theme_options[breakingnews_title]', array(
	'label'           	=> esc_html__( 'Readmore Label', 'newstation' ),
	'section'        	=> 'newstation_breakingnews_section',
	'active_callback' 	=> 'newstation_is_breakingnews_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[breakingnews_title]', array(
		'selector'            => '#newstation_breakingnews_section .news-title',
		'settings'            => 'newstation_theme_options[breakingnews_title]',
		'container_inclusive' => false,
		'fallback_refresh'    => true,
		'render_callback'     => 'newstation_breakingnews_title_partial',
		) );
}

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

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

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

endfor;