<?php if( ! defined( 'ABSPATH' ) ) exit;

add_action( 'customize_register', 'live_news_advertise_customize_register' );

function live_news_advertise_customize_register( $wp_customize ) {
	
	function live_news_link_ad_sanitize( $input ) {
		$valid = array(
				'new' => esc_attr__( 'Open URL in the new window.', 'live-news' ),
				'same' => esc_attr__( 'Open URL in the same window.', 'live-news' ),
		);
		
		if ( array_key_exists( $input, $valid ) ) {
			return $input;
		} else {
			return '';
		}
	}	
/***********************************************************************************
 * Back to top button Options
***********************************************************************************/
 
		$wp_customize->add_section( 'advertise' , array(
			'title'       => __( 'Advertise Top', 'live-news' ),
			'priority'   => 98,
		) );
	
		$wp_customize->add_setting( 'advertise_top', array (
			'sanitize_callback' => 'esc_url_raw',
		) );
		
		$wp_customize->add_control( 
			new WP_Customize_Image_Control( $wp_customize, 'advertise_top', array(
				'label'      => __( 'Your IMG Upload 728x90px:', 'live-news' ),
				'section'    => 'advertise',
				'settings'   => 'advertise_top',
		) ) );
			
		$wp_customize->add_setting( 'advertise_top_url', array (
			'sanitize_callback' => 'esc_url_raw',
		) );
		
		$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'advertise_top_url', array(
			'label'    => __( 'IMG URL:', 'live-news' ),
			'section'  => 'advertise',
			'settings' => 'advertise_top_url',
		) ) );	
 		$wp_customize->add_setting( 'advertise_top_link_type', array (
			'sanitize_callback' => 'live_news_link_ad_sanitize',
		) );
		
		$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'advertise_top_link_type', array(
			'label'    => __( 'URL Type:', 'live-news' ),
			'section'  => 'advertise',		
			'settings' => 'advertise_top_link_type',
			'type'     =>  'select',	
            'choices'  => array(
				'new' => esc_html__( 'Open URL in a new window.', 'live-news' ),
				'same' => esc_html__( 'Open URL in the same window.', 'live-news' ),
            ),
			'default'  => 'same'	
		) ) );					
}
