<?php
/**
 * Home Page Options.
 *
 * @package DarkMag
 */

$default = darkmag_get_default_theme_options();

// Latest Blog Section
$wp_customize->add_section( 'section_blog',
	array(
		'title'      => __( 'Latest Posts', 'darkmag' ),
		'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' => 'darkmag_sanitize_checkbox'
	)
);

$wp_customize->add_control('theme_options[enable_blog_section]', 
	array(		
	'label' 	=> __('Enable Latest Posts Section', 'darkmag'),
	'section' 	=> 'section_blog',
	'settings'  => 'theme_options[enable_blog_section]',
	'type' 		=> 'checkbox',	
	)
);

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

$wp_customize->add_control('theme_options[blog_section_title]', 
	array(
	'label'       => __('Section Title', 'darkmag'),
	'section'     => 'section_blog',   
	'settings'    => 'theme_options[blog_section_title]',	
	'active_callback' => 'darkmag_blog_active',		
	'type'        => 'text'
	)
);

// Column
$wp_customize->add_setting('theme_options[blog_posts_column]', 
	array(
	'default' 			=> $default['blog_posts_column'],
	'type'              => 'theme_mod',
	'capability'        => 'edit_theme_options',
	'sanitize_callback' => 'darkmag_sanitize_select'
	)
);

$wp_customize->add_control(new darkmag_Image_Radio_Control($wp_customize, 'theme_options[blog_posts_column]', 
	array(		
	'label' 	=> __('Select Column', 'darkmag'),
	'section' 	=> 'section_blog',
	'settings'  => 'theme_options[blog_posts_column]',
	'type' 		=> 'radio-image',
	'active_callback' => 'darkmag_blog_active',
	'choices' 	=> array(		
		'col-1' 	=> esc_url(get_template_directory_uri()) . '/assets/images/column-1.jpg',						
		'col-2' 	=> esc_url(get_template_directory_uri()) . '/assets/images/column-2.jpg',
		'col-3' 	=> esc_url(get_template_directory_uri()) . '/assets/images/column-3.jpg',
		'col-4' 	=> esc_url(get_template_directory_uri()) . '/assets/images/column-4.jpg',
		'col-5' 	=> esc_url(get_template_directory_uri()) . '/assets/images/column-5.jpg',
		'col-6' 	=> esc_url(get_template_directory_uri()) . '/assets/images/column-6.jpg',
		),	
	))
);

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

$blog_number = darkmag_get_option( 'blog_number' );

// Setting Blog Category.
$wp_customize->add_setting( 'theme_options[blog_category]',
	array(
	'default'           => $default['blog_category'],
	'capability'        => 'edit_theme_options',
	'sanitize_callback' => 'absint',
	)
);
$wp_customize->add_control(
	new darkmag_Dropdown_Taxonomies_Control( $wp_customize, 'theme_options[blog_category]',
		array(
		'label'    => __( 'Select Category', 'darkmag' ),
		'section'  => 'section_blog',
		'settings' => 'theme_options[blog_category]',	
		'active_callback' => 'darkmag_blog_active',		
		)
	)
);
