<?php
/**
 * Home Page Options.
 *
 * @package Business Carter
 */

$default = business_carter_get_default_theme_options();

// Latest Blog Section
$wp_customize->add_section( 'section_blog',
	array(
		'title'      => __( 'Latest News Section', 'business-carter' ),
		'priority'   => 100,
		'capability' => 'edit_theme_options',
		'panel'      => 'home_page_panel',
		)
);
// Disable Blog Section
$wp_customize->add_setting('theme_options[enable_blog_section]', 
	array(
	'default' 			=> $default['enable_blog_section'],
	'type'              => 'theme_mod',
	'capability'        => 'edit_theme_options',
	'sanitize_callback' => 'business_carter_sanitize_checkbox'
	)
);

$wp_customize->add_control('theme_options[enable_blog_section]', 
	array(		
	'label' 	=> __('Enable Section', 'business-carter'),
	'description' => __('Go to Customize - Homepage Settings. Select A static page. Set Homepage as Home and Posts page as Blog to show this section.', 'business-carter'),
	'section' 	=> 'section_blog',
	'settings'  => 'theme_options[enable_blog_section]',
	'type' 		=> 'checkbox',	
	)
);

// Section Subtitle
$wp_customize->add_setting('theme_options[business_carter_blog_section_subtitle]', 
	array(
	'default'           => $default['business_carter_blog_section_subtitle'],
	'type'              => 'theme_mod',
	'capability'        => 'edit_theme_options',	
	'sanitize_callback' => 'sanitize_text_field'
	)
);

$wp_customize->add_control('theme_options[business_carter_blog_section_subtitle]', 
	array(
	'label'       => __('Section Subtitle', 'business-carter'),
	'section'     => 'section_blog',   
	'settings'    => 'theme_options[business_carter_blog_section_subtitle]',	
	'active_callback' => 'business_carter_blog_active',		
	'type'        => 'text'
	)
);

// Section Title
$wp_customize->add_setting('theme_options[business_carter_blog_section_title]', 
	array(
	'default'           => $default['business_carter_blog_section_title'],
	'type'              => 'theme_mod',
	'capability'        => 'edit_theme_options',	
	'sanitize_callback' => 'sanitize_text_field'
	)
);

$wp_customize->add_control('theme_options[business_carter_blog_section_title]', 
	array(
	'label'       => __('Section Title', 'business-carter'),
	'section'     => 'section_blog',   
	'settings'    => 'theme_options[business_carter_blog_section_title]',	
	'active_callback' => 'business_carter_blog_active',		
	'type'        => 'text'
	)
);

// Blog Number.
$wp_customize->add_setting( 'theme_options[business_carter_blog_number]',
	array(
		'default'           => $default['business_carter_blog_number'],
		'capability'        => 'edit_theme_options',
		'sanitize_callback' => 'business_carter_sanitize_number_range',
		)
);
$wp_customize->add_control( 'theme_options[business_carter_blog_number]',
	array(
		'label'       		=> __( 'Number of Posts', 'business-carter' ),
		'description' 		=> __('Save & Refresh the customizer to see its effect. Maximum is 50.', 'business-carter'),
		'section'     		=> 'section_blog',
		'active_callback' 	=> 'business_carter_blog_active',		
		'type'        		=> 'number',
		'input_attrs' 		=> array( 
			'min' => 1, 
			'max' => 50, 
			'step' => 1, 
			'style' => 'width: 115px;' 
		),
	)
);

$business_carter_blog_number = business_carter_get_option( 'business_carter_blog_number' );

// Setting Blog Category.
$wp_customize->add_setting( 'theme_options[business_carter_blog_category]',
	array(
	'default'           => $default['business_carter_blog_category'],
	'capability'        => 'edit_theme_options',
	'sanitize_callback' => 'absint',
	)
);
$wp_customize->add_control(
	new business_carter_Dropdown_Taxonomies_Control( $wp_customize, 'theme_options[business_carter_blog_category]',
		array(
		'label'    => __( 'Select Category', 'business-carter' ),
		'section'  => 'section_blog',
		'settings' => 'theme_options[business_carter_blog_category]',	
		'active_callback' => 'business_carter_blog_active',		
		)
	)
);
