<?php
/**
 * Faced Footer Option
 *
 * @since Faced 1.0.0
 *
 */
/*Footer Options*/
$wp_customize->add_section( 'faced_footer_section', array(
   'priority'       => 55,
   'capability'     => 'edit_theme_options',
   'theme_supports' => '',
   'title'          => __( 'Footer Options', 'faced' ),
   'panel' 		 => 'faced_panel',
) );

/*You May also like Setting*/
$wp_customize->add_setting( 'faced_options[faced-footer-post-enable]', array(
    'capability'        => 'edit_theme_options',
    'transport' => 'refresh',
    'default'           => $default['faced-footer-post-enable'],
    'sanitize_callback' => 'faced_sanitize_checkbox'
) );
$wp_customize->add_control( 'faced_options[faced-footer-post-enable]', array(
    'label'     => __( 'Enable You May also like', 'faced' ),
    'description' => __('Checked to Enable You May also like section.', 'faced'),
    'section'   => 'faced_footer_section',
    'settings'  => 'faced_options[faced-footer-post-enable]',
    'type'      => 'checkbox',
    'priority'  => 5,
) );
/*callback functions you may also like section*/
if ( !function_exists('faced_you_may_also_like_active_callback') ) :
    function faced_you_may_also_like_active_callback(){
        global $faced_theme_options;
        $faced_theme_options = faced_get_options_value();
        $enable_you_may_also_like = absint($faced_theme_options['faced-footer-post-enable']);
        if( true == $enable_you_may_also_like ){
            return true;
        }
        else{
            return false;
        }
    }
  endif;
/*You May Also Like Section Title*/
$wp_customize->add_setting( 'faced_options[faced-related-post-section-title]', array(
    'capability'        => 'edit_theme_options',
    'transport' => 'refresh',
    'default'           => $default['faced-related-post-section-title'],
    'sanitize_callback' => 'sanitize_text_field'
) );
$wp_customize->add_control( 'faced_options[faced-related-post-section-title]', array(
'label'     => __( 'Related Post Title', 'faced' ),
'description' => __('Enter your own related posts title.', 'faced'),
'section'   => 'faced_footer_section',
'settings'  => 'faced_options[faced-related-post-section-title]',
'type'      => 'text',
'priority'  => 5,
'active_callback' => 'faced_you_may_also_like_active_callback'
) 
);

/*You May Also Like Category Selection*/
$wp_customize->add_setting(
    'faced_options[faced-related-post-select-category]',
    array(
        'capability' => 'edit_theme_options',
        'transport' => 'refresh',
        'default' => $default['faced-related-post-select-category'],
        'sanitize_callback' => 'absint'
    )
);
$wp_customize->add_control(
    new faced_Customize_Category_Dropdown_Control(
    $wp_customize,
    'faced_options[faced-related-post-select-category]',
    array(
        'label' => __('You May Also Like Section', 'faced'),
        'description' => __('From the dropdown select the category for the you may also like section. Category having post will display in below dropdown.', 'faced'),
        'section' => 'faced_footer_section',
        'settings' => 'faced_options[faced-related-post-select-category]',
        'type' => 'category_dropdown',
        'priority' => 10,
        'active_callback' => 'faced_you_may_also_like_active_callback'

    )
    )
);
/*Copyright Setting*/
$wp_customize->add_setting( 'faced_options[faced-footer-copyright]', array(
    'capability'        => 'edit_theme_options',
    'transport' => 'refresh',
    'default'           => $default['faced-footer-copyright'],
    'sanitize_callback' => 'sanitize_text_field'
) );
$wp_customize->add_control( 'faced_options[faced-footer-copyright]', array(
    'label'     => __( 'Copyright Text', 'faced' ),
    'description' => __('Enter your own copyright text.', 'faced'),
    'section'   => 'faced_footer_section',
    'settings'  => 'faced_options[faced-footer-copyright]',
    'type'      => 'text',
    'priority'  => 15,
) );
/*Go to Top Setting*/
$wp_customize->add_setting( 'faced_options[faced-go-to-top]', array(
    'capability'        => 'edit_theme_options',
    'transport' => 'refresh',
    'default'           => $default['faced-go-to-top'],
    'sanitize_callback' => 'faced_sanitize_checkbox'
) );
$wp_customize->add_control( 'faced_options[faced-go-to-top]', array(
    'label'     => __( 'Enable Go to Top', 'faced' ),
    'description' => __('Checked to Enable Go to Top', 'faced'),
    'section'   => 'faced_footer_section',
    'settings'  => 'faced_options[faced-go-to-top]',
    'type'      => 'checkbox',
    'priority'  => 15,
) );
/*callback functions header section*/
if ( !function_exists('faced_go_to_top_active_callback') ) :
    function faced_go_to_top_active_callback(){
        global $faced_theme_options;
        $faced_theme_options = faced_get_options_value();
        $go_to_top_class = absint($faced_theme_options['faced-go-to-top']);
        if( true == $go_to_top_class ){
            return true;
        }
        else{
            return false;
        }
    }
  endif;

/*Go to top Icon*/
$wp_customize->add_setting( 'faced_options[faced-go-to-top-icon]', array(
    'capability'        => 'edit_theme_options',
    'transport' => 'refresh',
    'default'           => $default['faced-go-to-top-icon'],
    'sanitize_callback' => 'sanitize_text_field'
) );
$wp_customize->add_control( 'faced_options[faced-go-to-top-icon]', array(
    'label'     => __( 'Font awesome class', 'faced' ),
    'description' => sprintf('%1$s <a href="%2$s" target="_blank">%3$s</a> %4$s',
        __( 'Enter fontaweome class like fa-long-arrow-up, fa-angle-up, etc. You can find more icons here in', 'faced' ),
        esc_url('https://fontawesome.com/v4.7/icons/'),
        __('Fontawesome lists and icons name' , 'faced'),
        __('so that you can use any icon from here.' ,'faced')
    ),
    'section'   => 'faced_footer_section',
    'settings'  => 'faced_options[faced-go-to-top-icon]',
    'type'      => 'text',
    'priority'  => 15,
    'active_callback'=> 'faced_go_to_top_active_callback',
) );

/*Social Icons Footer*/
$wp_customize->add_setting( 'faced_options[faced-footer-social-icons]', array(
    'capability'        => 'edit_theme_options',
    'transport' => 'refresh',
    'default'           => $default['faced-footer-social-icons'],
    'sanitize_callback' => 'faced_sanitize_checkbox'
) );
$wp_customize->add_control( 'faced_options[faced-footer-social-icons]', array(
    'label'     => __( 'Enable Social Icons', 'faced' ),
    'description' => __('Checked to Enable Social Icons. Make Social Menus from Appearance > Menus.', 'faced'),
    'section'   => 'faced_footer_section',
    'settings'  => 'faced_options[faced-footer-social-icons]',
    'type'      => 'checkbox',
    'priority'  => 15,
) );

if(function_exists('mc4wp_get_form')) {

    /*Enable Subscribe in Footer*/
    $wp_customize->add_setting('faced_options[faced-footer-mailchimp-subscribe]', array(
        'capability' => 'edit_theme_options',
        'transport' => 'refresh',
        'default' => $default['faced-footer-mailchimp-subscribe'],
        'sanitize_callback' => 'faced_sanitize_checkbox'
    ));
    $wp_customize->add_control('faced_options[faced-footer-mailchimp-subscribe]', array(
        'label' => __('Mailchimp Subscribe Form', 'faced'),
        'description' => sprintf('%1$s <a href="%2$s" target="_blank">%3$s</a> %4$s',
        __( 'Install and Customize', 'faced' ),
        esc_url('https://wordpress.org/plugins/mailchimp-for-wp/'),
        __('Mailchimp Subscribe Plugin' , 'faced'),
        __('and paste the form ID below.' ,'faced')
    ),
        'section' => 'faced_footer_section',
        'settings' => 'faced_options[faced-footer-mailchimp-subscribe]',
        'type' => 'checkbox',
        'priority' => 15,
    ));

    /*callback functions mailchimp enable*/
    if (!function_exists('faced_footer_mailchimp_enable')) :
        function faced_footer_mailchimp_enable()
        {
            global $faced_theme_options;
            $faced_theme_options = faced_get_options_value();
            $enable_mailchimp = absint($faced_theme_options['faced-footer-mailchimp-subscribe']);
            if ($enable_mailchimp == true) {
                return true;
            } else {
                return false;
            }
        }
    endif;

    /*Enable Mailchimp form Id in Footer*/
    $wp_customize->add_setting('faced_options[faced-footer-mailchimp-form-id]', array(
        'capability' => 'edit_theme_options',
        'transport' => 'refresh',
        'default' => $default['faced-footer-mailchimp-form-id'],
        'sanitize_callback' => 'absint'
    ));
    $wp_customize->add_control('faced_options[faced-footer-mailchimp-form-id]', array(
        'label' => __('Mailchimp Form ID', 'faced'),
        'description' => __('From your dashboard go to the mailchimp form plugin and get the ID and put here.', 'faced'),
        'section' => 'faced_footer_section',
        'settings' => 'faced_options[faced-footer-mailchimp-form-id]',
        'type' => 'number',
        'priority' => 15,
        'active_callback'=> 'faced_footer_mailchimp_enable',
    ));

    /*Title for mailchimp*/
    $wp_customize->add_setting('faced_options[faced-footer-mailchimp-form-title]', array(
        'capability' => 'edit_theme_options',
        'transport' => 'refresh',
        'default' => $default['faced-footer-mailchimp-form-title'],
        'sanitize_callback' => 'sanitize_text_field'
    ));
    $wp_customize->add_control('faced_options[faced-footer-mailchimp-form-title]', array(
        'label' => __('Mailchimp Section Title', 'faced'),
        'description' => __('Enter the title of subscribe.', 'faced'),
        'section' => 'faced_footer_section',
        'settings' => 'faced_options[faced-footer-mailchimp-form-title]',
        'type' => 'text',
        'priority' => 15,
        'active_callback'=> 'faced_footer_mailchimp_enable',
    ));


    /*subTitle for mailchimp*/
    $wp_customize->add_setting('faced_options[faced-footer-mailchimp-form-subtitle]', array(
        'capability' => 'edit_theme_options',
        'transport' => 'refresh',
        'default' => $default['faced-footer-mailchimp-form-subtitle'],
        'sanitize_callback' => 'sanitize_text_field'
    ));
    $wp_customize->add_control('faced_options[faced-footer-mailchimp-form-subtitle]', array(
        'label' => __('Mailchimp Section Sub Title', 'faced'),
        'description' => __('Enter the sub title of subscribe.', 'faced'),
        'section' => 'faced_footer_section',
        'settings' => 'faced_options[faced-footer-mailchimp-form-subtitle]',
        'type' => 'text',
        'priority' => 15,
        'active_callback'=> 'faced_footer_mailchimp_enable',
    ));
}
