<?php
/**
 * Theme Customizer Controls
 *
 * @package crater-free
 */

if ( ! function_exists( 'crater_free_customizer_sticky_header_register' ) ) :
function crater_free_customizer_sticky_header_register( $wp_customize ) {

    // Menu settings
    CraterFree_Kirki::add_section( 'crater_free_sticky_header_settings', array(
        'title'          => esc_html__( 'Sticky Header Settings', 'crater-free' ),
        'priority'       => 20,
    ) );


    CraterFree_Kirki::add_field( 'crater-free', array(
        'type'        => 'custom',
        'settings'    => 'label_sticky_header',
        'label'       => '',
        'section'     => 'crater_free_sticky_header_settings',
        'default'     => '<div style="font-weight:400;background: #fff;color: #555;padding: 5px 0;text-align: center;margin: 20px 0 15px 0;letter-spacing: 3px;">' . esc_html__( 'Sticky Header', 'crater-free' ) . '</div>',
        'priority'    => 10,
    ) );

    // Toggle for sticky header 
    CraterFree_Kirki::add_field( 'crater-free', [
        'type'     => 'toggle',
        'settings' => 'cr_sticky_menu',
        'label'    => esc_html__( 'Enable Sticky Header Feature:', 'crater-free' ),
        'description'   => esc_html__( 'Choose whether to enable a sticky header feature for the site', 'crater-free' ),
        'section'  => 'crater_free_sticky_header_settings',
        'default'  => 0,
    ] );

    // Logo for sticky header
    CraterFree_Kirki::add_field( 'crater-free', [
        'type'     => 'image',
        'settings' => 'cr_sticky_logo',
        'label'    => esc_html__( 'Logo for Sticky Header', 'crater-free' ),
        'description'   => esc_html__( 'Upload logo for Sticky Header. Recommended height is 50px.', 'crater-free' ),
        'section'  => 'crater_free_sticky_header_settings',
        'default'  => '',
        'active_callback'  => [
            [
                'setting'  => 'cr_sticky_menu',
                'operator' => '===',
                'value'    => true,
            ],
        ],
    ] );

    // Logo height sticky header
    CraterFree_Kirki::add_field( 'crater-free', [
        'type'     => 'slider',
        'settings' => 'cr_sticky_logo_height',
        'label'    => esc_html__( 'Sticky Logo Height', 'crater-free' ),
        'description'   => esc_html__( 'Increase or decrease logo height. Default height is 50px. Applies only if you upload a logo for sticky header', 'crater-free' ),
        'section'  => 'crater_free_sticky_header_settings',
        'default'  => 50,
        'choices'  => [
            'min'  => 0,
            'max'  => 150,
            'step' => 1,
        ],
        'active_callback'  => [
            [
                'setting'  => 'cr_sticky_menu',
                'operator' => '===',
                'value'    => true,
            ],
        ],
    ] );

    // Logo width sticky header
    CraterFree_Kirki::add_field( 'crater-free', [
        'type'     => 'slider',
        'settings' => 'cr_sticky_logo_width',
        'label'    => __( 'Sticky Logo Width', 'crater-free' ),
        'description'   => __( 'Increase or decrease logo width. Default width is 75%. Applies only if you upload a logo for sticky header', 'crater-free' ),
        'section'  => 'crater_free_sticky_header_settings',
        'default'  => 75,
        'choices'  => [
            'min'  => 1,
            'max'  => 100,
            'step' => 1,
        ],
        'active_callback'  => [
            [
                'setting'  => 'cr_sticky_menu',
                'operator' => '===',
                'value'    => true,
            ],
        ],
    ] );

    // Set menu padding for sticky header
    CraterFree_Kirki::add_field( 'crater-free', [
        'type'     => 'slider',
        'settings' => 'cr_sticky_menu_pad',
        'label'    => esc_html__( 'Menu Padding Value', 'crater-free' ),
        'description'   => esc_html__( 'Choose padding value to adjust your stikcy header menu. This value either increase or decrease the menu height. Default value is 20', 'crater-free' ),
        'section'  => 'crater_free_sticky_header_settings',
        'default'  => 20,
        'choices'  => [
            'min'  => 0,
            'max'  => 100,
            'step' => 1,
        ],
        'active_callback'  => [
            [
                'setting'  => 'cr_sticky_menu',
                'operator' => '===',
                'value'    => true,
            ],
        ],
    ] );

}
endif;

add_action( 'init', 'crater_free_customizer_sticky_header_register' );