<?php
/**
 * Editor Pick Post options.
 *
 * @package New BlogBell
 */

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

// Blog & News Section
$wp_customize->add_section( 'section_home_editorpick',
	array(
		'title'      => __( 'Editor Pick Section', 'new-blogbell' ),
		'capability' => 'edit_theme_options',
		'panel'      => 'home_page_panel',
		)
);

$wp_customize->add_setting( 'theme_options[disable_editorpick_section]',
	array(
		'default'           => $default['disable_editorpick_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_editorpick_section]',
    array(
		'label' 			=> __('Enable/Disable Editor Pick News Section', 'new-blogbell'),
		'section'    		=> 'section_home_editorpick',
		 'settings'  		=> 'theme_options[disable_editorpick_section]',
		'on_off_label' 		=> new_blogbell_switch_options(),
    )
) );

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

$wp_customize->add_control('theme_options[editorpick_title]', 
	array(
	'label'       => __('Section Title', 'new-blogbell'),
	'section'     => 'section_home_editorpick',   
	'settings'    => 'theme_options[editorpick_title]',
	'active_callback' => 'new_blogbell_editorpick_active',		
	'type'        => 'text'
	)
);
if ($homepage_design_layout=='home-main') {
	//Editorpick Section title
	$wp_customize->add_setting('theme_options[editorpick_see_all_txt]', 
		array(
		'default'           => $default['editorpick_see_all_txt'],
		'type'              => 'theme_mod',
		'capability'        => 'edit_theme_options',	
		'sanitize_callback' => 'sanitize_text_field'
		)
	);

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

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

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

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

$wp_customize->add_control( 'theme_options[editorpick_content_align]', array(
	'label'             => esc_html__( 'Choose Content Align', 'new-blogbell' ),
	'section'           => 'section_home_editorpick',
	'type'              => 'radio',
	'active_callback' => 'new_blogbell_editorpick_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' )
		)
) );

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

$wp_customize->add_control( 'theme_options[editorpick_top_category_enable]', array(
	'label'             => esc_html__( 'Enable Category of Top Post', 'new-blogbell' ),
	'section'           => 'section_home_editorpick',
	'type'              => 'checkbox',
	'active_callback' => 'new_blogbell_editorpick_active',
) );	
// Add content enable setting and control.
$wp_customize->add_setting( 'theme_options[editorpick_top_content_enable]', array(
	'default'           => $default['editorpick_top_content_enable'],
	'sanitize_callback' => 'new_blogbell_sanitize_checkbox',
) );

$wp_customize->add_control( 'theme_options[editorpick_top_content_enable]', array(
	'label'             => esc_html__( 'Enable Content of Top Post', 'new-blogbell' ),
	'section'           => 'section_home_editorpick',
	'type'              => 'checkbox',
	'active_callback' => 'new_blogbell_editorpick_active',
) );

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

$wp_customize->add_control( 'theme_options[editorpick_top_posted_on_enable]', array(
	'label'             => esc_html__( 'Enable Date of Top Post', 'new-blogbell' ),
	'section'           => 'section_home_editorpick',
	'type'              => 'checkbox',
	'active_callback' => 'new_blogbell_editorpick_active',
) );

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

$wp_customize->add_control( 'theme_options[editorpick_top_author_enable]', array(
	'label'             => esc_html__( 'Enable Author of Top Post', 'new-blogbell' ),
	'section'           => 'section_home_editorpick',
	'type'              => 'checkbox',
	'active_callback' => 'new_blogbell_editorpick_active',
) );

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

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

// Additional Information First Post
$wp_customize->add_setting('theme_options[editorpick_top_post]', 
	array(
	'type'              => 'theme_mod',
	'capability'        => 'edit_theme_options',	
	'sanitize_callback' => 'new_blogbell_dropdown_posts'
	)
);
$wp_customize->add_control( new New_BlogBell_Dropdown_Chooser( $wp_customize,'theme_options[editorpick_top_post]', 
	array(
	'label'       => __('Select Post', 'new-blogbell'),
	'section'     => 'section_home_editorpick',  
	'settings'    => 'theme_options[editorpick_top_post]',	
	'choices'			=> new_blogbell_post_choices(),	
	'type'        => 'dropdown-posts',
	'active_callback' => 'new_blogbell_editorpick_active',
	)
));

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

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

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

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

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

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

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

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

$wp_customize->add_control('theme_options[editorpick_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_editorpick',   
	'settings'    => 'theme_options[editorpick_excerpt_length]',		
	'type'        => 'number',
	'active_callback' => 'new_blogbell_editorpick_active',
	'input_attrs' => array(
			'min'	=> 0,
			'max'	=> 1000,
			'step'	=> 1,
		),
	)
);

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

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