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

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

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

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

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

$wp_customize->add_control( 'newstation_theme_options[business_news_title]', array(
	'label'           	=> esc_html__( 'Title', 'newstation' ),
	'section'        	=> 'newstation_business_news_section',
	'active_callback' 	=> 'newstation_is_business_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[business_news_title]', array(
		'selector'            => '#business-news .section-title',
		'settings'            => 'newstation_theme_options[business_news_title]',
		'container_inclusive' => false,
		'fallback_refresh'    => true,
		'render_callback'     => 'newstation_business_news_title_partial',
		) );
}

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

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

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

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

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

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

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

// business_news hr setting and control
	$wp_customize->add_setting( 'newstation_theme_options[business_news_post_hr]', array(
		'sanitize_callback' => 'sanitize_text_field'
	) );

	$wp_customize->add_control( new Newstation_Customize_Horizontal_Line( $wp_customize, 'newstation_theme_options[business_news_post_hr]',
		array(
			'section'         => 'newstation_business_news_section',
			'active_callback' => 'newstation_is_business_news_section_enable',
			'type'			  => 'hr'
	) ) );

$wp_customize->add_setting( 'newstation_theme_options[business_ads_image]', array(
	'sanitize_callback' => 'newstation_sanitize_image'
	) );

$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'newstation_theme_options[business_ads_image]',
	array(
		'label'       		=> esc_html__( 'Ads Image', 'newstation' ),
		'section'     		=> 'newstation_business_news_section',
		'active_callback' => 'newstation_is_business_news_section_enable',
		) ) );

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

$wp_customize->add_control( 'newstation_theme_options[business_ads_url]', array(
	'label'           	=> esc_html__( 'Ads Url', 'newstation' ),
	'section'        	=> 'newstation_business_news_section',
	'type'				=> 'url',
	'active_callback' => 'newstation_is_business_news_section_enable',
	) );