<?php
/**
 * Subscription Section options
 *
 * @package Theme Palace
 * @subpackage Enlightme
 * @since Enlightme 1.0.0
 */

// Add Subscription section
$wp_customize->add_section( 'enlightme_subscription_section', array(
	'title'             => esc_html__( 'Subscription','enlightme' ),
	'description'       => esc_html__( 'Note: To activate this section you need to install Jetpack Plugin and activate subscription module.', 'enlightme' ),
	'panel'             => 'enlightme_front_page_panel',
) );

// Subscription content enable control and setting
$wp_customize->add_setting( 'enlightme_theme_options[subscription_section_enable]', array(
	'default'			=> 	$options['subscription_section_enable'],
	'sanitize_callback' => 'enlightme_sanitize_switch_control',
) );

$wp_customize->add_control( new Enlightme_Switch_Control( $wp_customize, 'enlightme_theme_options[subscription_section_enable]', array(
	'label'             => esc_html__( 'Subscription Section Enable', 'enlightme' ),
	'section'           => 'enlightme_subscription_section',
	'on_off_label' 		=> enlightme_switch_options(),
) ) );

if ( isset( $wp_customize->selective_refresh ) ) {
    $wp_customize->selective_refresh->add_partial( 'enlightme_theme_options[subscription_section_enable]', array(
		'selector'            => '#subscribe-now .tooltiptext',
		'settings'            => 'enlightme_theme_options[subscription_section_enable]',
    ) );
}

// subscription  background image setting and control.
$wp_customize->add_setting( 'enlightme_theme_options[subscription_image]', array(
	'sanitize_callback' => 'enlightme_sanitize_image'
) );

$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'enlightme_theme_options[subscription_image]',
		array(
		'label'       		=> esc_html__( 'subscription Image', 'enlightme'),
		'description' 		=> sprintf( esc_html__( 'Recommended size: %1$dpx x %2$dpx ', 'enlightme' ), 1920, 600 ),
		'section'     		=> 'enlightme_subscription_section',
		'active_callback'	=> 'enlightme_is_subscription_section_enable',
) ) );


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

$wp_customize->add_control( 'enlightme_theme_options[subscription_title]', array(
	'label'           	=> esc_html__( 'Title', 'enlightme' ),
	'section'        	=> 'enlightme_subscription_section',
	'active_callback' 	=> 'enlightme_is_subscription_section_enable',
	'type'				=> 'text',
) );

// Abort if selective refresh is not available.
if ( isset( $wp_customize->selective_refresh ) ) {
    $wp_customize->selective_refresh->add_partial( 'enlightme_theme_options[subscription_title]', array(
		'selector'            => '#subscribe-now h2.section-title',
		'settings'            => 'enlightme_theme_options[subscription_title]',
		'container_inclusive' => false,
		'fallback_refresh'    => true,
		'render_callback'     => 'enlightme_subscription_title_partial',
    ) );
}

// subscription description setting and control
$wp_customize->add_setting( 'enlightme_theme_options[subscription_description]', array(
	'sanitize_callback' => 'wp_kses_post',	
	'default'			=> $options['subscription_description'],
	'transport'			=> 'postMessage',
) );

$wp_customize->add_control( 'enlightme_theme_options[subscription_description]', array(
	'label'           	=> esc_html__( 'Description', 'enlightme' ),
	'section'        	=> 'enlightme_subscription_section',
	'active_callback' 	=> 'enlightme_is_subscription_section_enable',
	'type'				=> 'textarea',
) );

// Abort if selective refresh is not available.
if ( isset( $wp_customize->selective_refresh ) ) {
    $wp_customize->selective_refresh->add_partial( 'enlightme_theme_options[subscription_description]', array(
		'selector'            => '#subscribe-now div.entry-content',
		'settings'            => 'enlightme_theme_options[subscription_description]',
		'container_inclusive' => false,
		'fallback_refresh'    => true,
		'render_callback'     => 'enlightme_subscription_description_partial',
    ) );
}

// subscription btn title setting and control
$wp_customize->add_setting( 'enlightme_theme_options[subscription_btn_title]', array(
	'sanitize_callback' => 'sanitize_text_field',
	'default'			=> $options['subscription_btn_title'],
) );

$wp_customize->add_control( 'enlightme_theme_options[subscription_btn_title]', array(
	'label'           	=> esc_html__( 'Button Label', 'enlightme' ),
	'section'        	=> 'enlightme_subscription_section',
	'active_callback' 	=> 'enlightme_is_subscription_section_enable',
	'type'				=> 'text',
) );
