<?php
/**
 * asana Theme Customizer
 *
 * @package asana
 * @since asana 1.6.0
 */

/**
 * @since asana 1.6.0
 */
function asana_customize_register( $wp_customize ) {
    $wp_customize->remove_control('site_icon');

    $option_tree = get_option( 'option_tree' );

    $wp_customize->add_panel( 'homepage_settings_panel', array(
        'title' => esc_html__( 'Home page settings', 'asana' ),
        'description' => '',
        'priority' => 160,
        'active_callback' => 'is_front_page'
    ) );

    $wp_customize->add_section( 'homepage_settings_section', array(
        'title' => __( 'Home page blocks', 'asana' ),
        'panel' => 'homepage_settings_panel',
        'active_callback' => 'is_front_page'
    ) );

    // rev slider
    $wp_customize->add_setting( 'option_tree[uni_home_rev_slider_enable]', array(
        'type' => 'option',
        'capability' => 'edit_theme_options',
        'default' => $option_tree['uni_home_rev_slider_enable']
    ) );
    $wp_customize->add_control( 'option_tree[uni_home_rev_slider_enable]', array(
        'type' => 'select',
        'priority' => 10,
        'section' => 'homepage_settings_section',
        'label' => __( 'Enable/Disable RevolutionSlider', 'asana' ),
        'description' => '',
        'choices' => array(
            'on' => 'Enable',
            'off' => 'Disable'
        )
    ) );

    // simple slider
    $wp_customize->add_setting( 'option_tree[uni_home_slider_enable]', array(
        'type' => 'option',
        'capability' => 'edit_theme_options',
        'default' => $option_tree['uni_home_slider_enable']
    ) );
    $wp_customize->add_control( 'option_tree[uni_home_slider_enable]', array(
        'type' => 'select',
        'priority' => 10,
        'section' => 'homepage_settings_section',
        'label' => __( 'Enable/Disable simple slider', 'asana' ),
        'description' => '',
        'choices' => array(
            'on' => 'Enable',
            'off' => 'Disable'
        )
    ) );

    // about us block
    $wp_customize->add_setting( 'option_tree[uni_home_about_enable]', array(
        'type' => 'option',
        'capability' => 'edit_theme_options',
        'default' => $option_tree['uni_home_about_enable']
    ) );
    $wp_customize->add_control( 'option_tree[uni_home_about_enable]', array(
        'type' => 'select',
        'priority' => 10,
        'section' => 'homepage_settings_section',
        'label' => __( 'Enable/Disable "About Us" block', 'asana' ),
        'description' => '',
        'choices' => array(
            'on' => 'Enable',
            'off' => 'Disable'
        )
    ) );

    // custom grid
    $wp_customize->add_setting( 'option_tree[uni_home_grid_custom_enable]', array(
        'type' => 'option',
        'capability' => 'edit_theme_options',
        'default' => $option_tree['uni_home_grid_custom_enable']
    ) );
    $wp_customize->add_control( 'option_tree[uni_home_grid_custom_enable]', array(
        'type' => 'select',
        'priority' => 10,
        'section' => 'homepage_settings_section',
        'label' => __( 'Show/hide the grid with custom content on home page', 'asana' ),
        'description' => '',
        'choices' => array(
            'on' => 'Enable',
            'off' => 'Disable'
        )
    ) );

    // posts grid
    $wp_customize->add_setting( 'option_tree[uni_home_grid_enable]', array(
        'type' => 'option',
        'capability' => 'edit_theme_options',
        'default' => $option_tree['uni_home_grid_enable']
    ) );
    $wp_customize->add_control( 'option_tree[uni_home_grid_enable]', array(
        'type' => 'select',
        'priority' => 10,
        'section' => 'homepage_settings_section',
        'label' => __( 'Show/hide the grid with posts on home page', 'asana' ),
        'description' => '',
        'choices' => array(
            'on' => 'Enable',
            'off' => 'Disable'
        )
    ) );

    // membership cards block
    $wp_customize->add_setting( 'option_tree[uni_home_membership_cards_enable]', array(
        'type' => 'option',
        'capability' => 'edit_theme_options',
        'default' => $option_tree['uni_home_membership_cards_enable']
    ) );
    $wp_customize->add_control( 'option_tree[uni_home_membership_cards_enable]', array(
        'type' => 'select',
        'priority' => 10,
        'section' => 'homepage_settings_section',
        'label' => __( 'Show/hide membership cards section on home page', 'asana' ),
        'description' => '',
        'choices' => array(
            'on' => 'Enable',
            'off' => 'Disable'
        )
    ) );

    // shop block
    $wp_customize->add_setting( 'option_tree[uni_home_shop_enable]', array(
        'type' => 'option',
        'capability' => 'edit_theme_options',
        'default' => $option_tree['uni_home_shop_enable']
    ) );
    $wp_customize->add_control( 'option_tree[uni_home_shop_enable]', array(
        'type' => 'select',
        'priority' => 10,
        'section' => 'homepage_settings_section',
        'label' => __( 'Show/hide WooCommerce shop section on home page', 'asana' ),
        'description' => '',
        'choices' => array(
            'on' => 'Enable',
            'off' => 'Disable'
        )
    ) );

    // blog block
    $wp_customize->add_setting( 'option_tree[uni_home_blog_enable]', array(
        'type' => 'option',
        'capability' => 'edit_theme_options',
        'default' => $option_tree['uni_home_blog_enable']
    ) );
    $wp_customize->add_control( 'option_tree[uni_home_blog_enable]', array(
        'type' => 'select',
        'priority' => 10,
        'section' => 'homepage_settings_section',
        'label' => __( 'Show/hide a blog section on home page', 'asana' ),
        'description' => '',
        'choices' => array(
            'on' => 'Enable',
            'off' => 'Disable'
        )
    ) );

    // classes block
    $wp_customize->add_setting( 'option_tree[uni_home_classes_enable]', array(
        'type' => 'option',
        'capability' => 'edit_theme_options',
        'default' => $option_tree['uni_home_classes_enable']
    ) );
    $wp_customize->add_control( 'option_tree[uni_home_classes_enable]', array(
        'type' => 'select',
        'priority' => 10,
        'section' => 'homepage_settings_section',
        'label' => __( 'Show/hide Classes block on home page?', 'asana' ),
        'description' => '',
        'choices' => array(
            'on' => 'Enable',
            'off' => 'Disable'
        )
    ) );

}
add_action( 'customize_register', 'asana_customize_register' );

/**
 * @since asana 1.6.0
 */
function asana_customize_preview_js() {
	wp_enqueue_script( 'asana-customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '1.6.0', true );
}
add_action( 'customize_preview_init', 'asana_customize_preview_js' );

?>