<?php
/**
 * Popular Post Section options
 *
 * @package Theme Palace
 * @subpackage FavBlog
 * @since FavBlog 1.0.0
 */

// Add Popular Post section
$wp_customize->add_section( 'favblog_popular_post_section', array(
	'title'             => esc_html__( 'Popular Post','favblog' ),
	'description'       => esc_html__( 'Popular Post Section options.', 'favblog' ),
	'panel'             => 'favblog_front_page_panel',
	'priority'			=> 30,
	) );
	
// Popular Post content enable control and setting
$wp_customize->add_setting( 'favblog_theme_options[popular_post_section_enable]', array(
	'default'			=> 	$options['popular_post_section_enable'],
	'sanitize_callback' => 'favblog_sanitize_switch_control',
	) );

$wp_customize->add_control( new FavBlog_Switch_Control( $wp_customize, 'favblog_theme_options[popular_post_section_enable]', array(
	'label'             => esc_html__( 'Popular Post Section Enable', 'favblog' ),
	'section'           => 'favblog_popular_post_section',
	'on_off_label' 		=> favblog_switch_options(),
	) ) );


// Abort if selective refresh is not available.
if ( isset( $wp_customize->selective_refresh ) ) {
    $wp_customize->selective_refresh->add_partial( 'favblog_theme_options[popular_post_section_enable]', array(
		'selector'            => '#must-read .tooltiptext',
		'settings'            => 'favblog_theme_options[popular_post_section_enable]',
    ) );
}

// popular destination sub title setting and control
$wp_customize->add_setting( 'favblog_theme_options[popular_post_sub_title]', array(
	'default'			=> $options['popular_post_sub_title'],
	'sanitize_callback' => 'sanitize_text_field',
	'transport'			=> 'postMessage',
) );

$wp_customize->add_control( 'favblog_theme_options[popular_post_sub_title]', array(
	'label'           	=> esc_html__( 'Sub Title', 'favblog' ),
	'section'        	=> 'favblog_popular_post_section',
	'active_callback' 	=> 'favblog_is_popular_post_section_enable',
	'type'				=> 'text',
) );

// Abort if selective refresh is not available.
if ( isset( $wp_customize->selective_refresh ) ) {
    $wp_customize->selective_refresh->add_partial( 'favblog_theme_options[popular_post_sub_title]', array(
		'selector'            => '#popular-posts .section-header p',
		'settings'            => 'favblog_theme_options[popular_post_sub_title]',
		'container_inclusive' => false,
		'fallback_refresh'    => true,
		'render_callback'     => 'favblog_popular_post_sub_title_partial',
    ) );
}

// popular_post title setting and control
$wp_customize->add_setting( 'favblog_theme_options[popular_post_title]', array(
	'sanitize_callback' => 'sanitize_text_field',
	'default'			=> $options['popular_post_title'],
	'transport'			=> 'postMessage',
	) );

$wp_customize->add_control( 'favblog_theme_options[popular_post_title]', array(
	'label'           	=> esc_html__( 'Section Title', 'favblog' ),
	'section'        	=> 'favblog_popular_post_section',
	'active_callback' 	=> 'favblog_is_popular_post_section_enable',
	'type'				=> 'text',
	) );

// Abort if selective refresh is not available.
if ( isset( $wp_customize->selective_refresh ) ) {
	$wp_customize->selective_refresh->add_partial( 'favblog_theme_options[popular_post_title]', array(
		'selector'            => '#popular-posts .section-header h2',
		'settings'            => 'favblog_theme_options[popular_post_title]',
		'container_inclusive' => false,
		'fallback_refresh'    => true,
		'render_callback'     => 'favblog_popular_post_title_partial',
		) );
}

// hero posts drop down chooser control and setting
$wp_customize->add_setting( 'favblog_theme_options[popular_post_content_category]', array(
	'sanitize_callback' => 'favblog_sanitize_single_category',
) );

$wp_customize->add_control( new FavBlog_Dropdown_Taxonomies_Control( $wp_customize, 'favblog_theme_options[popular_post_content_category]', array(
	'label'             => esc_html__( 'Select Categories', 'favblog' ),
	'description'       => esc_html__( 'Note: Latest selected no of posts will be shown from selected category', 'favblog' ),
	'type'           	=> 'dropdown-taxonomies',
	'section'           => 'favblog_popular_post_section',
	'active_callback'	=> 'favblog_is_popular_post_section_enable',
) ) ); 