<?php
/**
 * Must Read Post options.
 *
 * @package New BlogBell
 */

$default = new_blogbell_get_default_theme_options();
$homepage_design_layout     = new_blogbell_get_option( 'homepage_design_layout_options' );

// Must Read Post Section
$wp_customize->add_section( 'section_home_mustread',
	array(
		'title'      => __( 'Must Read News', 'new-blogbell' ),
		'capability' => 'edit_theme_options',
		'panel'      => 'home_page_panel',
		)
);

$wp_customize->add_setting( 'theme_options[disable_mustread_section]',
	array(
		'default'           => $default['disable_mustread_section'],
		'type'              => 'theme_mod',
		'capability'        => 'edit_theme_options',
		'sanitize_callback' => 'new_blogbell_sanitize_switch_control',
	)
);
$wp_customize->add_control( new New_BlogBell_Switch_Control( $wp_customize, 'theme_options[disable_mustread_section]',
    array(
		'label' 			=> __('Enable/Disable Must Read Post Section', 'new-blogbell'),
		'section'    		=> 'section_home_mustread',
		 'settings'  		=> 'theme_options[disable_mustread_section]',
		'on_off_label' 		=> new_blogbell_switch_options(),
    )
) );

// Add arrow enable setting and control.
$wp_customize->add_setting( 'theme_options[mustread_content_align]', array(
	'default'           => $default['mustread_content_align'],
	'sanitize_callback' => 'new_blogbell_sanitize_select',
) );

$wp_customize->add_control( 'theme_options[mustread_content_align]', array(
	'label'             => esc_html__( 'Choose Content Align', 'new-blogbell' ),
	'section'           => 'section_home_mustread',
	'type'              => 'radio',
	'active_callback' => 'new_blogbell_mustread_active',
	'choices'				=> array( 
		'content-right'     => esc_html__( 'Right Side', 'new-blogbell' ), 
		'content-center'     => esc_html__( 'Center Side', 'new-blogbell' ), 
		'content-left'     => esc_html__( 'Left Side', 'new-blogbell' ), 
		'content-justify'     => esc_html__( 'Justify', 'new-blogbell' )
		)
) );

//Must Read Post Section title
$wp_customize->add_setting('theme_options[mustread_title]', 
	array(
	'default'           => $default['mustread_title'],
	'type'              => 'theme_mod',
	'capability'        => 'edit_theme_options',	
	'sanitize_callback' => 'sanitize_text_field'
	)
);

$wp_customize->add_control('theme_options[mustread_title]', 
	array(
	'label'       => __('Section Title', 'new-blogbell'),
	'section'     => 'section_home_mustread',   
	'settings'    => 'theme_options[mustread_title]',
	'active_callback' => 'new_blogbell_mustread_active',		
	'type'        => 'text'
	)
);

if ($homepage_design_layout=='home-main') {
	//Must read Section title
	$wp_customize->add_setting('theme_options[mustread_see_all_txt]', 
		array(
		'default'           => $default['mustread_see_all_txt'],
		'type'              => 'theme_mod',
		'capability'        => 'edit_theme_options',	
		'sanitize_callback' => 'sanitize_text_field'
		)
	);

	$wp_customize->add_control('theme_options[mustread_see_all_txt]', 
		array(
		'label'       => __('See All Text', 'new-blogbell'),
		'section'     => 'section_home_mustread',   
		'settings'    => 'theme_options[mustread_see_all_txt]',
		'active_callback' => 'new_blogbell_mustread_active',		
		'type'        => 'text'
		)
	);

	//Must read Section title
	$wp_customize->add_setting('theme_options[mustread_see_all_url]', 
		array(
		'type'              => 'theme_mod',
		'capability'        => 'edit_theme_options',	
		'sanitize_callback' => 'esc_url_raw'
		)
	);

	$wp_customize->add_control('theme_options[mustread_see_all_url]', 
		array(
		'label'       => __('See All Link', 'new-blogbell'),
		'section'     => 'section_home_mustread',   
		'settings'    => 'theme_options[mustread_see_all_url]',
		'active_callback' => 'new_blogbell_mustread_active',		
		'type'        => 'url'
		)
	);
}

// Add category enable setting and control.
$wp_customize->add_setting( 'theme_options[mustread_category_enable]', array(
	'default'           => $default['mustread_category_enable'],
	'sanitize_callback' => 'new_blogbell_sanitize_checkbox',
) );

$wp_customize->add_control( 'theme_options[mustread_category_enable]', array(
	'label'             => esc_html__( 'Enable Category', 'new-blogbell' ),
	'section'           => 'section_home_mustread',
	'type'              => 'checkbox',
	'active_callback' => 'new_blogbell_mustread_active',
) );	
// Add content enable setting and control.
$wp_customize->add_setting( 'theme_options[mustread_content_enable]', array(
	'default'           => $default['mustread_content_enable'],
	'sanitize_callback' => 'new_blogbell_sanitize_checkbox',
) );

$wp_customize->add_control( 'theme_options[mustread_content_enable]', array(
	'label'             => esc_html__( 'Enable Content', 'new-blogbell' ),
	'section'           => 'section_home_mustread',
	'type'              => 'checkbox',
	'active_callback' => 'new_blogbell_mustread_active',
) );

// Add posted on enable setting and control.
$wp_customize->add_setting( 'theme_options[mustread_posted_on_enable]', array(
	'default'           => $default['mustread_posted_on_enable'],
	'sanitize_callback' => 'new_blogbell_sanitize_checkbox',
) );

$wp_customize->add_control( 'theme_options[mustread_posted_on_enable]', array(
	'label'             => esc_html__( 'Enable Date', 'new-blogbell' ),
	'section'           => 'section_home_mustread',
	'type'              => 'checkbox',
	'active_callback' => 'new_blogbell_mustread_active',
) );

// Add posted on enable setting and control.
$wp_customize->add_setting( 'theme_options[mustread_author_enable]', array(
	'default'           => $default['mustread_author_enable'],
	'sanitize_callback' => 'new_blogbell_sanitize_checkbox',
) );

$wp_customize->add_control( 'theme_options[mustread_author_enable]', array(
	'label'             => esc_html__( 'Enable Author', 'new-blogbell' ),
	'section'           => 'section_home_mustread',
	'type'              => 'checkbox',
	'active_callback' => 'new_blogbell_mustread_active',
) );

// Number of items
$wp_customize->add_setting('theme_options[mustread_excerpt_length]', 
	array(
	'default' 			=> $default['mustread_excerpt_length'],
	'type'              => 'theme_mod',
	'capability'        => 'edit_theme_options',	
	'sanitize_callback' => 'new_blogbell_sanitize_number_range'
	)
);

$wp_customize->add_control('theme_options[mustread_excerpt_length]', 
	array(
	'label'       => __('Excerpt Length', 'new-blogbell'),
	'description' => __('Save & Refresh the customizer to see its effect. Maximum is 1000.', 'new-blogbell'),
	'section'     => 'section_home_mustread',   
	'settings'    => 'theme_options[mustread_excerpt_length]',		
	'type'        => 'number',
	'active_callback' => 'new_blogbell_mustread_active',
	'input_attrs' => array(
			'min'	=> 0,
			'max'	=> 1000,
			'step'	=> 1,
		),
	)
);


// Setting  Team Category.
$wp_customize->add_setting( 'theme_options[mustread_category]',
	array(

	'capability'        => 'edit_theme_options',
	'sanitize_callback' => 'absint',
	)
);
$wp_customize->add_control(
	new New_BlogBell_Dropdown_Taxonomies_Control( $wp_customize, 'theme_options[mustread_category]',
		array(
		'label'    => __( 'Select Category', 'new-blogbell' ),
		'section'  => 'section_home_mustread',
		'settings' => 'theme_options[mustread_category]',	
		'active_callback' => 'new_blogbell_mustread_active',		
		)
	)
);

//==============Advertisment Section===========//

// Advertisment hr setting and control
$wp_customize->add_setting( 'theme_options[mustread_ads_hr]', array(
	'sanitize_callback' => 'sanitize_text_field'
) );

$wp_customize->add_control( new New_BlogBell_Customize_Horizontal_Line( $wp_customize, 'theme_options[mustread_ads_hr]',
	array(
		'section'         => 'section_home_mustread',
		'active_callback' => 'new_blogbell_mustread_active',
		'type'			  => 'hr',
) ) );
$wp_customize->add_setting( 'theme_options[disable_mustread_ads_section]',
	array(
		'default'           => $default['disable_mustread_ads_section'],
		'type'              => 'theme_mod',
		'capability'        => 'edit_theme_options',
		'sanitize_callback' => 'new_blogbell_sanitize_switch_control',
	)
);
$wp_customize->add_control( new New_BlogBell_Switch_Control( $wp_customize, 'theme_options[disable_mustread_ads_section]',
    array(
		'label' 			=> __('Enable/Disable Category News Ads', 'new-blogbell'),
		'section'    		=> 'section_home_mustread',
		'settings'  		=> 'theme_options[disable_mustread_ads_section]',
		'active_callback' => 'new_blogbell_mustread_active',
		'on_off_label' 		=> new_blogbell_switch_options(),
    )
) );

// Add arrow enable setting and control.
$wp_customize->add_setting( 'theme_options[mustread_column_option]', array(
	'default'           => $default['mustread_column_option'],
	'sanitize_callback' => 'new_blogbell_sanitize_select',
) );

$wp_customize->add_control( 'theme_options[mustread_column_option]', array(
	'label'             => esc_html__( 'Choose ADS Column', 'new-blogbell' ),
	'section'           => 'section_home_mustread',
	'type'              => 'radio',
	'active_callback' => 'new_blogbell_mustread_active',
	'choices'				=> array( 
		'col-1'     => esc_html__( 'Column One', 'new-blogbell' ), 
		'col-2'     => esc_html__( 'Column Two', 'new-blogbell' ),
		)
) );

// Number of items
$wp_customize->add_setting('theme_options[number_of_mustread_ads]', 
	array(
	'default' 			=> $default['number_of_mustread_ads'],
	'type'              => 'theme_mod',
	'capability'        => 'edit_theme_options',	
	'sanitize_callback' => 'new_blogbell_sanitize_number_range'
	)
);

$wp_customize->add_control('theme_options[number_of_mustread_ads]', 
	array(
	'label'       => __('Number of Items', 'new-blogbell'),
	'description' => __('Save & Refresh the customizer to see its effect. Maximum is 4.', 'new-blogbell'),
	'section'     => 'section_home_mustread',   
	'settings'    => 'theme_options[number_of_mustread_ads]',		
	'type'        => 'number',
	'active_callback' => 'new_blogbell_mustread_active',
	'input_attrs' => array(
			'min'	=> 1,
			'max'	=> 4,
			'step'	=> 1,
		),
	)
);
$number_of_mustread_ads = new_blogbell_get_option( 'number_of_mustread_ads' );

for( $i=1; $i<=$number_of_mustread_ads; $i++ ){

// mustread title setting and control
	$wp_customize->add_setting( 'theme_options[mustread_ads_img_' . $i . ']', array(
		'type'              => 'theme_mod',
		'sanitize_callback' => 'esc_url_raw',
	) );

	$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'theme_options[mustread_ads_img_' . $i . ']', array(
		'label'       =>sprintf( esc_html__( 'Select ADS Image %d', 'new-blogbell' ), $i ),
		'section'        	=> 'section_home_mustread',
		'settings'    		=> 'theme_options[mustread_ads_img_'.$i.']',	
		'active_callback' 	=> 'new_blogbell_mustread_active',
	) ) );

	// mustread title setting and control
	$wp_customize->add_setting( 'theme_options[mustread_ads_url_' . $i . ']', array(
		'type'              => 'theme_mod',
		'sanitize_callback' => 'esc_url_raw',
	) );

	$wp_customize->add_control( 'theme_options[mustread_ads_url_' . $i . ']', array(
		'label'           	=> sprintf( __( 'ADS Url %d', 'new-blogbell' ), $i ),
		'section'        	=> 'section_home_mustread',
		'settings'    		=> 'theme_options[mustread_ads_url_'.$i.']',	
		'active_callback' 	=> 'new_blogbell_mustread_active',
		'type'				=> 'url',
	) );
}