<?php
/**
 * Register General section, settings and controls for Theme Customizer
 *
 */
if ( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly.
}
// Add General Settings
add_action( 'customize_register', 'pmthemes_customize_register_general_settings' );
function pmthemes_customize_register_general_settings( $wp_customize ) {
    // Get Default Fonts from settings
    $theme_def = pmthemes_default_options();
	// Add Layout Section
	$wp_customize->add_section( 'pmthemes_section_layout', array(
        'title'    => __( 'Theme Layout', 'pmthemes' ),
        'priority' => 1,
		'panel' => 'pmthemes_options_panel' 
		)
	);
    // Theme Style
    $wp_customize->add_setting( 'pmthemes_theme_options[theme_styles]', array(
            'default'           => $theme_def['theme_styles'],
            'type'           	=> 'option',
            'transport'         => 'postMessage',
            'sanitize_callback' => 'pmthemes_sanitize_theme_styles'
        )
    );
    $wp_customize->add_control( 'pmthemes_color_scheme', array(
            'label'    => __( 'Theme Style', 'pmthemes' ),
            'section'    => 'pmthemes_section_layout',
            'settings' => 'pmthemes_theme_options[theme_styles]',
            'type'     => 'select',
            'priority' => 1,
            'choices'  => pmthemes_theme_style_keys(),
        )
    );
    // Layout Style
    $wp_customize->add_setting( 'pmthemes_theme_options[theme_style]', array(
            'default'           => $theme_def['theme_style'],
            'type'           	=> 'option',
            'transport'         => 'postMessage',
            'sanitize_callback' => 'pmthemes_sanitize_theme_style'
        )
    );
    $wp_customize->add_control( 'pmthemes_control_theme_style', array(
            'label'    => __( 'Layout Style', 'pmthemes' ),
            'section'  => 'pmthemes_section_layout',
            'settings' => 'pmthemes_theme_options[theme_style]',
            'type'     => 'select',
            'priority' => 2,
            'choices'  => array(
                'boxed-one' => __( 'Boxed (Default)', 'pmthemes' ),
                'wide-head' => __( 'Wide Header', 'pmthemes')
            )
        )
    );
    // Theme Width
    $wp_customize->add_setting( 'pmthemes_theme_options[theme_width]', array(
            'default'           => $theme_def['theme_width'],
            'type'           	=> 'option',
            'transport'         => 'postMessage',
            'sanitize_callback' => 'pmthemes_sanitize_theme_width'
        )
    );
    $wp_customize->add_control( 'pmthemes_theme_width', array(
            'label'    => __( 'Theme Width', 'pmthemes' ),
            'section'  => 'pmthemes_section_layout',
            'settings' => 'pmthemes_theme_options[theme_width]',
            'type'     => 'select',
            'priority' => 3,
            'choices'  => array(
                'wd1' 	  => __( 'Default', 'pmthemes' ),
                'wd2' => __( '960px', 'pmthemes'),
                'wd3' => __( '980px', 'pmthemes' ),
                'wd4' => __( '1000px', 'pmthemes' ),
                'wd5' => __( '1050px', 'pmthemes'),
                'wd6' => __( '1080px', 'pmthemes' ),
                'wd7' => __( '1120px', 'pmthemes'),
                'wd8' => __( '1180px', 'pmthemes' ),
                'wd9' => __( '1220px', 'pmthemes'),
                'wd10' => __( '1280px', 'pmthemes' ),
            )
        )
    );
    // Extra Functions Title
    $wp_customize->add_setting( 'pmthemes_theme_options[extra_functions]', array(
            'default'           => '',
            'type'           	=> 'option',
            'transport'         => 'refresh',
            'sanitize_callback' => 'esc_attr'
        )
    );
    $wp_customize->add_control( new Pmthemes_Customize_Header_Control(
            $wp_customize, 'pmthemes_control_extra_functions', array(
                'label' => __( 'Extras', 'pmthemes' ),
                'section' => 'pmthemes_section_layout',
                'settings' => 'pmthemes_theme_options[extra_functions]',
                'priority' => 4,
            )
        )
    );
    // Remove Wide Header Body Margin
    $wp_customize->add_setting( 'pmthemes_theme_options[no_body_margin]', array(
            'default'           => $theme_def['no_body_margin'],
            'type'           	=> 'option',
            'transport'         => 'refresh',
            'sanitize_callback' => 'pmthemes_sanitize_checkbox'
        )
    );
    $wp_customize->add_control( 'pmthemes_control_no_body_margin', array(
            'label'    => __( 'Remove Wide Header Body Margin', 'pmthemes' ),
            'description'    => __( 'Applicable for Wide Header layout only', 'pmthemes' ),
            'section'  => 'pmthemes_section_layout',
            'settings' => 'pmthemes_theme_options[no_body_margin]',
            //'active_callback' =>'pmthemes_wide_header_active',
            'type'     => 'checkbox',
            'priority' => 5,
        )
    );
    // Remove Body Border and Shadow
    $wp_customize->add_setting( 'pmthemes_theme_options[no_body_border]', array(
            'default'           => $theme_def['no_body_border'],
            'type'           	=> 'option',
            'transport'         => 'refresh',
            'sanitize_callback' => 'pmthemes_sanitize_checkbox'
        )
    );
    $wp_customize->add_control( 'pmthemes_control_no_body_border', array(
            'label'    => __( 'Remove Body Border & Shadow', 'pmthemes' ),
            'section'  => 'pmthemes_section_layout',
            'settings' => 'pmthemes_theme_options[no_body_border]',
            //'active_callback' =>'pmthemes_wide_header_active',
            'type'     => 'checkbox',
            'priority' => 6,
        )
    );
	// Link to Top
	$wp_customize->add_setting( 'pmthemes_theme_options[link_to_top]', array(
        'default'           => $theme_def['link_to_top'],
		'type'           	=> 'option',
        'transport'         => 'refresh',
        'sanitize_callback' => 'pmthemes_sanitize_checkbox'
		)
	);
    $wp_customize->add_control( 'pmthemes_control_link_to_top', array(
        'label'    => __( 'Display Scroll to Top button.', 'pmthemes' ),
        'section'  => 'pmthemes_section_layout',
        'settings' => 'pmthemes_theme_options[link_to_top]',
        'type'     => 'checkbox',
		'priority' => 7,
		)
	);

    // WooCommerce Shop Page Layout
    $wp_customize->add_setting( 'pmthemes_theme_options[pmth_wc_shop_lyt]', array(
            'default'           => $theme_def['pmth_wc_shop_lyt'],
            'type'           	=> 'option',
            'transport'         => 'refresh',
            'sanitize_callback' => 'pmthemes_sanitize_wc_layout'
        )
    );
    $wp_customize->add_control( 'pmthemes_control_pmth_wc_shop_lyt', array(
            'label'    => __( 'Shop Page Layout', 'pmthemes' ),
            'section'  => 'woocommerce_product_catalog',
            'settings' => 'pmthemes_theme_options[pmth_wc_shop_lyt]',
            'active_callback' => 'pmthemes_woocommerce_class_active',
            'type'     => 'select',
            'choices'  => array(
                'wc_full_page' => __( 'Full Page', 'pmthemes'),
                'wc_show_sbar' => __( 'Show Sidebar', 'pmthemes' ),
            ),
            'priority' => 8,
        )
    );
}


