<?php
/**
 * Register Footer Content section, settings and controls for Theme Customizer
 *
 */
if ( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly.
}
// Add Footie Settings
add_action( 'customize_register', 'pmthemes_customize_register_footie_settings' );
function pmthemes_customize_register_footie_settings( $wp_customize ) {
    // Get Default Fonts from settings
    $theme_def = pmthemes_default_options();
    // Add Footer Layout Section
    $wp_customize->add_section('pmthemes_section_footer', array(
            'title' => __('Footer Settings', 'pmthemes'),
            'priority' => 11,
            'panel' => 'pmthemes_options_panel'
        )
    );
    // Footer Widgets Layout
    $wp_customize->add_setting('pmthemes_theme_options[fwidgets]', array(
            'default' => $theme_def['fwidgets'],
            'type' => 'option',
            'transport' => 'refresh',
            'sanitize_callback' => 'pmthemes_sanitize_fwidgets'
        )
    );
    
    $wp_customize->add_control('pmthemes_control_fwidgets', array(
            'label' => __('Footer Widgets Layout', 'pmthemes'),
            'section' => 'pmthemes_section_footer',
            'settings' => 'pmthemes_theme_options[fwidgets]',
            'type' => 'select',
            'priority' => 2,
            'choices' => array(
                '0' => __('No Widget', 'pmthemes'),
                '1' => __('1 Column', 'pmthemes'),
                '2' => __('2 Columns', 'pmthemes'),
                '3' => __('3 Columns', 'pmthemes'),
                '4' => __('4 Columns', 'pmthemes'),
            )
        )
    );
    // Footer Text
    $wp_customize->add_setting('pmthemes_theme_options[footer_text]', array(
            'default' => $theme_def['footer_text'],
            'type' => 'option',
            'transport' => 'refresh',
            'sanitize_callback' => 'pmthemes_sanitize_footer_text'
        )
    );
    $wp_customize->add_control('pmthemes_control_footer_text', array(
            'label' => __('Footer Text', 'pmthemes'),
            'section' => 'pmthemes_section_footer',
            'settings' => 'pmthemes_theme_options[footer_text]',
            'type' => 'textarea',
            'priority' => 4,
        )
    );
    // Credit Link
    $wp_customize->add_setting('pmthemes_theme_options[credit_link]', array(
            'default' => $theme_def['credit_link'],
            'type' => 'option',
            'transport' => 'refresh',
            'sanitize_callback' => 'pmthemes_sanitize_checkbox'
        )
    );
    $wp_customize->add_control('pmthemes_control_credit_link', array(
            'label' => __('Display credit link to pmthemes on footer.', 'pmthemes'),
            'section' => 'pmthemes_section_footer',
            'settings' => 'pmthemes_theme_options[credit_link]',
            'type' => 'checkbox',
            'priority' => 6,
        )
    );
    // Footie Code
    $wp_customize->add_setting('pmthemes_theme_options[track_code]', array(
            'default' => $theme_def['track_code'],
            'type' => 'option',
            'transport' => 'postMessage',
            'sanitize_callback' => 'pmthemes_sanitize_track_code'
        )
    );
    $wp_customize->add_control('pmthemes_control_track_code', array(
            'label' => __('Footer Code', 'pmthemes'),
            'section' => 'pmthemes_section_footer',
            'settings' => 'pmthemes_theme_options[track_code]',
            'type' => 'textarea',
            'description' => 'For Google Analytics, tracking code, etc.',
            'priority' => 8,
        )
    );
}
