<?php
/**
 * Latest Recipe Options.
 *
 * @package Memory Blog
 */

$default = memory_blog_get_default_theme_options();

// Latest Recipe Section
$wp_customize->add_section( 'section_latest_recipe',
	array(
		'title'      => __( 'Latest Recipe Section', 'memory-blog' ),
		'priority'   => 100,
		'capability' => 'edit_theme_options',
		'panel'      => 'home_page_panel',
	)
);

// Enable Section
$wp_customize->add_setting('theme_options[enable_latest_recipe_section]', 
	array(
	'default' 			=> $default['enable_latest_recipe_section'],
	'type'              => 'theme_mod',
	'capability'        => 'edit_theme_options',
	'sanitize_callback' => 'memory_blog_sanitize_checkbox'
	)
);

$wp_customize->add_control('theme_options[enable_latest_recipe_section]', 
	array(		
	'label' 	=> __('Enable Section', 'memory-blog'),
	'section' 	=> 'section_latest_recipe',
	'settings'  => 'theme_options[enable_latest_recipe_section]',
	'type' 		=> 'checkbox',	
	)
);

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

$wp_customize->add_control('theme_options[latest_recipe_section_title]', 
	array(
	'label'       => __('Section Title', 'memory-blog'),
	'section'     => 'section_latest_recipe',   
	'settings'    => 'theme_options[latest_recipe_section_title]',	
	'active_callback' => 'memory_blog_latest_recipe_active',		
	'type'        => 'text'
	)
);

// Latest Recipe Number.
$wp_customize->add_setting( 'theme_options[latest_recipe_number]',
	array(
		'default'           => $default['latest_recipe_number'],
		'capability'        => 'edit_theme_options',
		'sanitize_callback' => 'memory_blog_sanitize_number_range',
		)
);
$wp_customize->add_control( 'theme_options[latest_recipe_number]',
	array(
		'label'       		=> __('Items (Max: 12)', 'memory-blog'),
		'section'     		=> 'section_latest_recipe',
		'active_callback' 	=> 'memory_blog_latest_recipe_active',		
		'type'        		=> 'number',
		'input_attrs' 		=> array( 
			'min' => 1, 
			'max' => 12, 
			'step' => 1, 
			'style' => 'width: 115px;' 
		),
	)
);

$latest_recipe_number = memory_blog_get_option( 'latest_recipe_number' );

// Setting Category.
$wp_customize->add_setting( 'theme_options[latest_recipe_category]',
	array(
	'default'           => $default['latest_recipe_category'],
	'capability'        => 'edit_theme_options',
	'sanitize_callback' => 'absint',
	)
);
$wp_customize->add_control(
	new memory_blog_Dropdown_Taxonomies_Control( $wp_customize, 'theme_options[latest_recipe_category]',
		array(
		'label'    => __( 'Select Category', 'memory-blog' ),
		'section'  => 'section_latest_recipe',
		'settings' => 'theme_options[latest_recipe_category]',	
		'active_callback' => 'memory_blog_latest_recipe_active',		
		)
	)
);