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

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

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

$wp_customize->add_control( new Newstation_Switch_Control( $wp_customize, 'newstation_theme_options[top_politician_section_enable]', array(
	'label'             => esc_html__( 'Top Politician Section Enable', 'newstation' ),
	'section'           => 'newstation_top_politician_section',
	'on_off_label' 		=> newstation_switch_options(),
	) ) );

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

$wp_customize->add_control( 'newstation_theme_options[top_politician_title]', array(
	'label'           	=> esc_html__( 'Top Politician Title', 'newstation' ),
	'section'        	=> 'newstation_top_politician_section',
	'active_callback' 	=> 'newstation_is_top_politician_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[top_politician_title]', array(
		'selector'            => '#newstation_top_politician_section .section-title',
		'settings'            => 'newstation_theme_options[top_politician_title]',
		'container_inclusive' => false,
		'fallback_refresh'    => true,
		'render_callback'     => 'newstation_top_politician_title_partial',
		) );
}

// top_politician button setting and control
$wp_customize->add_setting( 'newstation_theme_options[top_politician_btn]', array(
	'sanitize_callback' => 'sanitize_text_field',
	'default'			=> $options['top_politician_btn'],
) );

$wp_customize->add_control( 'newstation_theme_options[top_politician_btn]', array(
	'label'           	=> esc_html__( 'Button', 'newstation' ),
	'section'        	=> 'newstation_top_politician_section',
	'active_callback' 	=> 'newstation_is_top_politician_section_enable',
	'type'				=> 'text',
) );

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

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

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

endfor;

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

$wp_customize->add_control( 'newstation_theme_options[top_politician_view_all_btn]', array(
	'label'           	=> esc_html__( 'View All Button', 'newstation' ),
	'section'        	=> 'newstation_top_politician_section',
	'active_callback' 	=> 'newstation_is_top_politician_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[top_politician_view_all_btn]', array(
		'selector'            => '#newstation_top_politician_section a.see-all',
		'settings'            => 'newstation_theme_options[top_politician_view_all_btn]',
		'container_inclusive' => false,
		'fallback_refresh'    => true,
		'render_callback'     => 'newstation_top_politician_view_all_btn_partial',
    ) );
}

// cta btn link setting and control
$wp_customize->add_setting( 'newstation_theme_options[top_politician_view_all_btn_link]', array(
	'sanitize_callback' => 'esc_url_raw',
) );

$wp_customize->add_control( 'newstation_theme_options[top_politician_view_all_btn_link]', array(
	'label'           	=> esc_html__( 'View All Button Link', 'newstation' ),
	'section'        	=> 'newstation_top_politician_section',
	'active_callback' 	=> 'newstation_is_top_politician_section_enable',
	'type'				=> 'url',
) );