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

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

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

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

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

$wp_customize->add_control( 'newstation_theme_options[sports_news_title]', array(
	'label'           	=> esc_html__( 'Title', 'newstation' ),
	'section'        	=> 'newstation_sports_news_section',
	'active_callback' 	=> 'newstation_is_sports_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[sports_news_title]', array(
		'selector'            => '#sports-news .section-title',
		'settings'            => 'newstation_theme_options[sports_news_title]',
		'container_inclusive' => false,
		'fallback_refresh'    => true,
		'render_callback'     => 'newstation_sports_news_title_partial',
		) );
}

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

$wp_customize->add_control( 'newstation_theme_options[sports_news_see_all]', array(
	'label'           	=> esc_html__( 'Button Label', 'newstation' ),
	'section'        	=> 'newstation_sports_news_section',
	'active_callback' 	=> 'newstation_is_sports_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[sports_news_see_all]', array(
		'selector'            => '#sports-news .btn',
		'settings'            => 'newstation_theme_options[sports_news_see_all]',
		'container_inclusive' => false,
		'fallback_refresh'    => true,
		'render_callback'     => 'newstation_sports_news_see_all_partial',
		) );
}

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

$wp_customize->add_control( 'newstation_theme_options[sports_news_see_all_url]', array(
	'label'           	=> esc_html__( 'Button Link', 'newstation' ),
	'section'        	=> 'newstation_sports_news_section',
	'type'				=> 'url',
	'active_callback' => 'newstation_is_sports_news_section_enable',
	) );

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

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

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