<?php
/**
 * Theme Customizer Controls
 *
 * @package shopbar
 */

defined( 'ABSPATH' ) || exit;


if ( ! function_exists( 'shopbar_customizer_footer_register' ) ) :
function shopbar_customizer_footer_register( $wp_customize ) {
 	
 	/**
     * Footer Settings Section
     */
    $wp_customize->add_section(
        'shopbar_footer_settings',
        array(
            'priority'   => 25,
            'capability' => 'edit_theme_options',
            'title'      => esc_html__( 'Footer Settings', 'shopbar' ),
        )
    );

    // Title label - Copyright
    $wp_customize->add_setting(
        'shopbar_footer_copyright_label',
        array(
            'sanitize_callback' => 'shopbar_sanitize_title',
        )
    );

    $wp_customize->add_control(
        new Shopbar_Title_Info_Control( $wp_customize, 'shopbar_footer_copyright_label',
        array(
            'label'    => esc_html__( 'Copyright Settings', 'shopbar' ),
            'section'  => 'shopbar_footer_settings',
            'type'     => 'shopbar-title',
            'settings' => 'shopbar_footer_copyright_label',
        )
    ));

    // Copyright text
    $wp_customize->add_setting(
        'shopbar_footer_copyright_text',
        array(
            'type'              => 'theme_mod',
            'sanitize_callback' => 'shopbar_sanitize_textarea_field',
        )
    );

    $wp_customize->add_control(
        'shopbar_footer_copyright_text',
        array(
            'settings'    => 'shopbar_footer_copyright_text',
            'section'     => 'shopbar_footer_settings',
            'type'        => 'textarea',
            'label'       => esc_html__( 'Footer Copyright Text', 'shopbar' ),
            'description' => esc_html__( 'Copyright text to be displayed in the footer. No HTML allowed.', 'shopbar' ),
        )
    );

    // Title label - Footer Bottom Links
    $wp_customize->add_setting(
        'shopbar_footer_bottom_links_label',
        array(
            'sanitize_callback' => 'shopbar_sanitize_title',
        )
    );

    $wp_customize->add_control(
        new Shopbar_Title_Info_Control( $wp_customize, 'shopbar_footer_bottom_links_label',
        array(
            'label'    => esc_html__( 'Footer Bottom Links', 'shopbar' ),
            'section'  => 'shopbar_footer_settings',
            'type'     => 'shopbar-title',
            'settings' => 'shopbar_footer_bottom_links_label',
        )
    ));

    // Privacy Policy URL
    $wp_customize->add_setting(
        'shopbar_footer_privacy_policy_url',
        array(
            'type'              => 'theme_mod',
            'sanitize_callback' => 'shopbar_sanitize_url',
        )
    );

    $wp_customize->add_control(
        'shopbar_footer_privacy_policy_url',
        array(
            'settings'    => 'shopbar_footer_privacy_policy_url',
            'section'     => 'shopbar_footer_settings',
            'type'        => 'url',
            'label'       => esc_html__( 'Privacy Policy URL', 'shopbar' ),
            'description' => esc_html__( 'Enter the URL for the Privacy Policy page.', 'shopbar' ),
        )
    );

    // Cookie Policy URL
    $wp_customize->add_setting(
        'shopbar_footer_cookie_policy_url',
        array(
            'type'              => 'theme_mod',
            'sanitize_callback' => 'shopbar_sanitize_url',
        )
    );

    $wp_customize->add_control(
        'shopbar_footer_cookie_policy_url',
        array(
            'settings'    => 'shopbar_footer_cookie_policy_url',
            'section'     => 'shopbar_footer_settings',
            'type'        => 'url',
            'label'       => esc_html__( 'Cookie Policy URL', 'shopbar' ),
            'description' => esc_html__( 'Enter the URL for the Cookie Policy page.', 'shopbar' ),
        )
    );

    // Terms & Conditions URL
    $wp_customize->add_setting(
        'shopbar_footer_terms_url',
        array(
            'type'              => 'theme_mod',
            'sanitize_callback' => 'shopbar_sanitize_url',
        )
    );

    $wp_customize->add_control(
        'shopbar_footer_terms_url',
        array(
            'settings'    => 'shopbar_footer_terms_url',
            'section'     => 'shopbar_footer_settings',
            'type'        => 'url',
            'label'       => esc_html__( 'Terms & Conditions URL', 'shopbar' ),
            'description' => esc_html__( 'Enter the URL for the Terms & Conditions page.', 'shopbar' ),
        )
    );
}
endif;

add_action( 'customize_register', 'shopbar_customizer_footer_register' );