<?php
/**
 * Theme Options.
 *
 * @package Wacko
 */

$default = wacko_default_theme_options();

/**=========== Option Panel ===========**/

$wp_customize->add_panel(
    'wacko_basic_panel', 
    array(
        'title'             => __( 'Theme Options', 'wacko' ),
        'priority'          => 200, 
    )
);

/**=========== Header Setting - start ===========**/

$wp_customize->add_section(
    'wacko_header', 
    array(    
        'title'             => __( 'Header', 'wacko' ),
        'panel'             => 'wacko_basic_panel', 
    )
);

/*----------- Sticky header -----------*/

$wp_customize->add_setting(
    'wacko[sticky_header]',
    array(
        'default'           => $default['sticky_header'],       
        'sanitize_callback' => 'wacko_sanitize_checkbox'
    )
);

$wp_customize->add_control(
    'wacko[sticky_header]', 
    array(
        'label'             => __( 'Enable sticky header', 'wacko' ),
        'section'           => 'wacko_header',   
        'settings'          => 'wacko[sticky_header]',     
        'type'              => 'checkbox',
    )
);

/**=========== Header Setting - end ===========**/


/**=========== Slider Settings - start ===========**/

$wp_customize->add_section(
    'wacko_slider', 
    array(    
        'title'             => __( 'Slider', 'wacko' ),
        'panel'             => 'wacko_basic_panel'    
    )
);    

/*----------- Enable/Disable Slider -----------*/

$wp_customize->add_setting(
    'wacko[slider_enable]', 
    array(
        'default'           => $default['slider_enable'],       
        'sanitize_callback' => 'wacko_sanitize_checkbox'
    )
);

$wp_customize->add_control(
    'wacko[slider_enable]', 
    array(
        'label'             => __( 'Enable slider OR banner image', 'wacko' ),
        'section'           => 'wacko_slider',   
        'settings'          => 'wacko[slider_enable]',     
        'type'              => 'checkbox'
    )
);  

/*----------- Show/Hide slider excerpt -----------*/

$wp_customize->add_setting(
    'wacko[slider_excerpt_enable]', 
    array(
        'default'           => $default['slider_excerpt_enable'],
        'sanitize_callback' => 'wacko_sanitize_checkbox'
    )
);



$wp_customize->add_control(

    'wacko[slider_excerpt_enable]', 

    array(

        'label'             => __( 'Display excerpt', 'wacko' ),

        'section'           => 'wacko_slider',   

        'settings'          => 'wacko[slider_excerpt_enable]',     

        'type'              => 'checkbox',

        'active_callback'   => 'wacko_main_slider',

    )

);

/*----------- Show/Hide slider button -----------*/

$wp_customize->add_setting(

    'wacko[slider_btn_enable]', 

    array(

        'default'           => $default['slider_btn_enable'],       

        'sanitize_callback' => 'wacko_sanitize_checkbox'

    )

);

$wp_customize->add_control(

    'wacko[slider_btn_enable]', 

    array(

        'label'             => __( 'Display read button', 'wacko' ),

        'section'           => 'wacko_slider',   

        'settings'          => 'wacko[slider_btn_enable]',     

        'type'              => 'checkbox',

        'active_callback'   => 'wacko_main_slider',

    )

);

/*----------- Slider type -----------*/

$wp_customize->add_setting(
    'wacko[main_slider_type]', 
    array(
        'default'           => $default['main_slider_type'],
        'sanitize_callback' => 'wacko_sanitize_select'
    )
);

$wp_customize->add_control(
    'wacko[main_slider_type]', 
    array(
        'label'             => __( 'Select slider type', 'wacko' ),
        'section'           => 'wacko_slider',
        'settings'          => 'wacko[main_slider_type]',
        'type'              => 'radio',
        'choices'           => array(
            'slider'        => __( 'Slider', 'wacko' ),
            'banner-image'  => __( 'Banner image', 'wacko' ),
        ),
        'active_callback'   => 'wacko_main_slider',
    )
);  

/*----------- Slider category -----------*/

$wp_customize->add_setting(
    'wacko[slider_cat]', 
    array(
        'default'           => $default['slider_cat'],
        'sanitize_callback' => 'wacko_sanitize_number'
    )
);

$wp_customize->add_control(
    new Wacko_Customize_Category_Control(
        $wp_customize,
        'wacko[slider_cat]',
        array(
            'label'         => __( 'Category for slider', 'wacko'  ),
            'description'   => __( 'Posts of selected category will be used as sliders', 'wacko'  ),
            'settings'      => 'wacko[slider_cat]',
            'section'       => 'wacko_slider',
            'active_callback'   => 'wacko_slider_category',
        )
    )
);

// Slider Transition Delay.

$wp_customize->add_setting( 'wacko[slider_transition_delay]',
    array(
    'default'           => $default['slider_transition_delay'],
    'sanitize_callback' => 'wacko_sanitize_number_range',
    )
);

$wp_customize->add_control( 'wacko[slider_transition_delay]',
    array(
        'label'             => __( 'Transition Delay', 'wacko' ),
        'description'       => __( 'In second(s)', 'wacko' ),
        'settings'          => 'wacko[slider_transition_delay]',
        'section'           => 'wacko_slider',
        'type'              => 'number',
        'input_attrs'       => array( 'min' => 1, 'max' => 10, 'step' => 1, 'style' => 'width: 66px;' ),
        'active_callback'   => 'wacko_slider_category',
    )
);

// Slider Transition Duration.

$wp_customize->add_setting( 'wacko[slider_transition_duration]',
    array(
    'default'           => $default['slider_transition_duration'],
    'sanitize_callback' => 'wacko_sanitize_number_range',
    )
);

$wp_customize->add_control( 'wacko[slider_transition_duration]',
    array(
    'label'             => __( 'Transition Duration', 'wacko' ),
    'description'       => __( 'In second(s)', 'wacko' ),
    'settings'          => 'wacko[slider_transition_duration]',
    'section'           => 'wacko_slider',
    'type'              => 'number',
    'input_attrs'       => array( 'min' => 1, 'max' => 10, 'step' => 1, 'style' => 'width: 66px;' ),
    'active_callback'   => 'wacko_slider_category',
    )
);

/*----------- Banner image -----------*/

$wp_customize->add_setting(
    'wacko[banner_image]',
    array(
        'default'           => $default['banner_image'],
        'sanitize_callback' => 'wacko_sanitize_number',
    )
);

$wp_customize->add_control(
    'wacko[banner_image]',
    array(
        'label'             => __( 'Banner image', 'wacko' ),
        'description'       => __( 'Enter the ID of post to use as a banner image.', 'wacko' ),
        'settings'          => 'wacko[banner_image]',
        'section'           => 'wacko_slider',
        'type'              => 'text',
        'active_callback'   => 'wacko_banner_category',
    )
);

/**=========== Slider Settings - end ===========**/


/**=========== Home Section - start ===========**/

$wp_customize->add_section(
    'wacko_home',
    array(
        'title'       => __( 'Home Sections', 'wacko' ),
        'panel'       => 'wacko_basic_panel'
    )
);

/**=========== Show home page content ===========**/

$wp_customize->add_setting(
    'wacko[home_content]',
    array(
        'default'           => $default['home_content'],
        'sanitize_callback' => 'wacko_sanitize_checkbox'
    )
);

$wp_customize->add_control(
    'wacko[home_content]', 
    array(
        'label'       => __( 'Show home content', 'wacko' ),
        'description' => __( 'Check this box to show page content in home page', 'wacko' ),
        'section'     => 'wacko_home',
        'settings'    => 'wacko[home_content]',
        'type'        => 'checkbox'
    )
);


// Our services

$wp_customize->add_setting(
    'wacko[our_services]', 
    array(
        'default'           => $default['our_services'],
        'sanitize_callback' => 'wacko_sanitize_number'
        )
    );

$wp_customize->add_control(
    new Wacko_Customize_Category_Control(
        $wp_customize,
        'wacko[our_services]',
        array(
            'label'       => __( 'Our services', 'wacko' ),
            'description' => __( 'Leave blank to hide this section', 'wacko' ),
            'settings'    => 'wacko[our_services]',
            'section'     => 'wacko_home',
            )
        )
    );


// About us

$wp_customize->add_setting(
    'wacko[about_us]',
    array(
        'default'           => $default['about_us'],
        'sanitize_callback' => 'wacko_sanitize_number',
    )
);

$wp_customize->add_control(
    'wacko[about_us]', 
    array(
        'label'             => __( 'About us', 'wacko' ),   
        'description'       => __( 'Leave blank to hide this section', 'wacko'  ), 
        'settings'          => 'wacko[about_us]',
        'section'           => 'wacko_home',
        'type'              => 'dropdown-pages',
    )
);

// Testimonial

$wp_customize->add_setting(
    'wacko[wacko_testi]', 
    array(
        'default'           => $default['wacko_testi'],
        'sanitize_callback' => 'wacko_sanitize_number'
        )
    );

$wp_customize->add_control(
    new Wacko_Customize_Category_Control(
        $wp_customize,
        'wacko[wacko_testi]',
        array(
            'label'       => __( 'Testimonial', 'wacko' ),
            'description' => __( 'Leave blank to hide this section', 'wacko' ),
            'settings'    => 'wacko[wacko_testi]',
            'section'     => 'wacko_home',
            )
        )
    );

// Information section

$wp_customize->add_setting(
    'wacko[info_sec]', 
    array(
        'default'           => $default['info_sec'],
        'sanitize_callback' => 'wacko_sanitize_number',
    )
);

$wp_customize->add_control(
    'wacko[info_sec]', 
    array(
        'label'             => __( 'Info section', 'wacko' ),
        'description'       => __( 'Leave blank to hide this section', 'wacko'  ),
        'settings'          => 'wacko[info_sec]',
        'section'           => 'wacko_home',
        'type'              => 'dropdown-pages',
    )
);



// Portfolio

$wp_customize->add_setting(
    'wacko[our_project]', 
    array(
        'default'           => $default['our_project'],      
        'sanitize_callback' => 'wacko_sanitize_number'
        )
    );

$wp_customize->add_control(
    new Wacko_Customize_Category_Control(
        $wp_customize,
        'wacko[our_project]',
        array(
            'label'       => __( 'Portfolio', 'wacko' ),
            'description' => __( 'Leave blank to hide this section', 'wacko' ),
            'settings'    => 'wacko[our_project]',
            'section'     => 'wacko_home',
            )
        )
    );

// Support

$wp_customize->add_setting(
    'wacko[our_support]',
    array(
        'default'           => $default['our_support'],
        'sanitize_callback' => 'wacko_sanitize_number',
    )
);

$wp_customize->add_control(
    'wacko[our_support]',
    array(
        'label'             => __( 'Support', 'wacko' ),
        'description'       => __( 'Leave blank to hide this section', 'wacko'  ),
        'settings'          => 'wacko[our_support]',
        'section'           => 'wacko_home',
        'type'              => 'dropdown-pages',
    )
);

// Call to action

$wp_customize->add_setting(
    'wacko[wacko_cta]',
    array(
        'default'           => $default['wacko_cta'],
        'sanitize_callback' => 'wacko_sanitize_number',
    )
);

$wp_customize->add_control(
    'wacko[wacko_cta]',
    array(
        'label'             => __( 'call to action', 'wacko' ),
        'description'       => __( 'Leave blank to hide this section', 'wacko' ),
        'settings'          => 'wacko[wacko_cta]',
        'section'           => 'wacko_home',
        'type'              => 'dropdown-pages',
    )
);

/**=========== Home Section - end ===========**/

/**=========== Social Media Options - start ===========**/

$wp_customize->add_section(
    'wacko_social',
    array(   
        'title'       => __( 'Social Media', 'wacko' ),
        'panel'       => 'wacko_basic_panel'    
        ));

/*----------- Social link text field -----------*/

$social_options = array('facebook', 'twitter', 'google_plus', 'instagram', 'linkedin', 'pinterest', 'youtube', 'vimeo', 'flickr', 'behance', 'dribbble', 'tumblr', 'github' );

foreach($social_options as $social) {

    $social_name = ucwords(str_replace('_', ' ', $social));
    $label = '';

    switch ($social) {
        case 'facebook':
        $label = __('Facebook', 'wacko' );
        break;

        case 'twitter':
        $label = __( 'Twitter', 'wacko'  );
        break;

        case 'google_plus':
        $label = __( 'Google Plus', 'wacko'  );
        break;

        case 'instagram':
        $label = __( 'Instagram', 'wacko'  );
        break;

        case 'linkedin':
        $label = __( 'LinkedIn', 'wacko'  );
        break;

        case 'pinterest':
        $label = __( 'Pinterest', 'wacko'  );
        break;

        case 'youtube':
        $label = __( 'Youtube', 'wacko'  );
        break;

        case 'vimeo':
        $label = __( 'vimeo', 'wacko'  );
        break;

        case 'flickr':
        $label = __( 'Flickr', 'wacko'  );
        break;

        case 'behance':
        $label = __( 'Behance', 'wacko'  );
        break;

        case 'dribbble':
        $label = __( 'Dribbble', 'wacko'  );
        break;

        case 'tumblr':
        $label = __( 'Tumblr', 'wacko'  );
        break;

        case 'github':
        $label = __( 'Github', 'wacko'  );
        break;

    }

    $wp_customize->add_setting( 'wacko['.$social.']', array(
        'sanitize_callback'     => 'esc_url_raw',
        'sanitize_js_callback'  =>  'esc_url_raw'
        ));

    $wp_customize->add_control( 'wacko['.$social.']', array(
        'label'     => $label,
        'type'      => 'text',
        'section'   => 'wacko_social',
        'settings'  => 'wacko['.$social.']'
        ));
}

/**=========== Social Media Options - end ===========**/


/**=========== General setting - start ===========**/

$wp_customize->add_section(
    'wacko_general', 
    array(    
        'title'       => __('General Setting', 'wacko' ),
        'panel'       => 'wacko_basic_panel'
    )
);

/**=========== Page layout ===========**/

$wp_customize->add_setting(
    'wacko[sidebar]',
    array(
        'default'           => $default['sidebar'],
        'sanitize_callback' => 'wacko_sanitize_select',
    )
);

$wp_customize->add_control( 'wacko[sidebar]',
    array(
        'label'       => esc_html__( 'Page layout', 'wacko'  ),
        'section'     => 'wacko_general',   
        'settings'    => 'wacko[sidebar]',
        'type'        => 'radio',
        'choices'     => array(
            'right'     => esc_html__( 'Right sidebar', 'wacko'  ),
            'left'      => esc_html__( 'Left sidebar', 'wacko'  ),
            'no_side'   => esc_html__( 'No sidebar', 'wacko'  ),
            )
    )
);

/**=========== Enable/Disable - post date ===========**/

$wp_customize->add_setting(
    'wacko[enable_post_date]', 
    array(
        'default'           => $default['enable_post_date'],
        'sanitize_callback' => 'wacko_sanitize_checkbox'
    )
);

$wp_customize->add_control(
    'wacko[enable_post_date]',
    array(
        'label'       => __('Enable post date', 'wacko' ),
        'settings'    => 'wacko[enable_post_date]',
        'section'     => 'wacko_general',
        'type'        => 'checkbox',
    )
);

/**=========== Enable/Disable - post author ===========**/

$wp_customize->add_setting(
    'wacko[enable_post_author]',
    array(
        'default'           => $default['enable_post_author'],
        'sanitize_callback' => 'wacko_sanitize_checkbox'
    )
);

$wp_customize->add_control(
    'wacko[enable_post_author]',
    array(
        'label'       => __('Enable post author', 'wacko' ),
        'settings'    => 'wacko[enable_post_author]',
        'section'     => 'wacko_general',
        'type'        => 'checkbox',
    )
);

/**=========== Enable/Disable - post meta ===========**/

$wp_customize->add_setting(
    'wacko[enable_post_meta]',
    array(
        'default'           => $default['enable_post_meta'],
        'sanitize_callback' => 'wacko_sanitize_checkbox'
    )
);

$wp_customize->add_control(
    'wacko[enable_post_meta]',
    array(
        'label'       => __('Enable post meta', 'wacko' ),
        'settings'    => 'wacko[enable_post_meta]',
        'section'     => 'wacko_general',
        'type'        => 'checkbox',
    )
);

/**=========== General setting - end ===========**/


/**=========== Footer Options - start ===========**/

$wp_customize->add_section(
    'wacko_footer',
    array(
        'title'       => __( 'Footer', 'wacko' ),
        'panel'       => 'wacko_basic_panel'
    )
);

/**=========== Enable/Disable - social media ===========**/ 

$wp_customize->add_setting(
    'wacko[enable_social_media]',
    array(
        'default'           => $default['enable_social_media'],
        'sanitize_callback' => 'wacko_sanitize_checkbox'
    )
);

$wp_customize->add_control(
    'wacko[enable_social_media]',
    array(
        'label'       => __( 'Enable social media', 'wacko' ),
        'settings'    => 'wacko[enable_social_media]',
        'section'     => 'wacko_footer',
        'type'        => 'checkbox',
    )
);

/**=========== Copyright text ===========**/

$wp_customize->add_setting(
    'wacko[copyright_text]',
    array(
      'default'           => $default['copyright_text'],
      'sanitize_callback' => 'sanitize_textarea_field',
    )
);

$wp_customize->add_control(
    'wacko[copyright_text]',
        array(
        'label'       => __( 'Copyright text', 'wacko' ),
        'settings'    => 'wacko[copyright_text]',
        'section'     => 'wacko_footer',
        'type'        => 'textarea'
    )
);

/**=========== Enable/Disable - scroll to top ===========**/

$wp_customize->add_setting(
    'wacko[enable_scroll_top]',
    array(
        'default'           => $default['enable_scroll_top'],
        'sanitize_callback' => 'wacko_sanitize_checkbox'
    )
);


$wp_customize->add_control(
    'wacko[enable_scroll_top]', 
    array(
        'label'       => __( 'Enable scroll to top', 'wacko' ),
        'settings'    => 'wacko[enable_scroll_top]',
        'section'     => 'wacko_footer',
        'type'        => 'checkbox'
    )
);

/**=========== Footer Options - end ===========**/
