<?php
/**
 * Most Recent Posts options
 *
 * @package Theme Palace
 * @subpackage Pushpa
 * @since Pushpa 1.0.0
 */

// Add Most Recent Posts
$wp_customize->add_section( 'pushpa_most_recent_posts_section', array(
	'title'             => esc_html__( 'Most Recent Posts','pushpa' ),
	'description'       => esc_html__( 'Most Recent Posts options.', 'pushpa' ),
	'panel'             => 'pushpa_front_page_panel',
	) );

// Hero content enable control and setting
$wp_customize->add_setting( 'pushpa_theme_options[most_recent_posts_section_enable]', array(
	'default'			=> 	$options['most_recent_posts_section_enable'],
	'sanitize_callback' => 'pushpa_sanitize_switch_control',
	) );

$wp_customize->add_control( new Pushpa_Switch_Control( $wp_customize, 'pushpa_theme_options[most_recent_posts_section_enable]', array(
	'label'             => esc_html__( 'Most Recent Posts Enable', 'pushpa' ),
	'section'           => 'pushpa_most_recent_posts_section',
	'on_off_label' 		=> pushpa_switch_options(),
	) ) );

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


for ( $i = 1; $i <= 4; $i++ ) :

// Most recent posts drop down chooser control and setting
$wp_customize->add_setting( 'pushpa_theme_options[most_recent_posts_content_post_' . $i . ']', array(
	'sanitize_callback' => 'pushpa_sanitize_page',
	) );

$wp_customize->add_control( new Pushpa_Dropdown_Chooser( $wp_customize, 'pushpa_theme_options[most_recent_posts_content_post_' . $i . ']', array(
	'label'             => sprintf( esc_html__( 'Select Post %d', 'pushpa' ), $i ),
	'section'           => 'pushpa_most_recent_posts_section',
	'choices'			=> pushpa_post_choices(),
	'active_callback'	=> 'pushpa_is_most_recent_posts_section_enable',
	) ) );
endfor;

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

$wp_customize->add_control( 'pushpa_theme_options[most_recent_posts_btn]', array(
	'label'           	=> esc_html__( 'Button Label', 'pushpa' ),
	'section'        	=> 'pushpa_most_recent_posts_section',
	'active_callback' 	=> 'pushpa_is_most_recent_posts_section_enable',
	'type'				=> 'text',
	) );

// Abort if selective refresh is not available.
if ( isset( $wp_customize->selective_refresh ) ) {
	$wp_customize->selective_refresh->add_partial( 'pushpa_theme_options[most_recent_posts_btn]', array(
		'selector'            => '#pushpa_most_recent_posts .read-more .btn',
		'settings'            => 'pushpa_theme_options[most_recent_posts_btn]',
		'container_inclusive' => false,
		'fallback_refresh'    => true,
		'render_callback'     => 'pushpa_most_recent_post_btn_partial',
		) );
}