<?php
/**
 * Header Settings Customizer Controls
 *
 * @package shopbar
 */

defined( 'ABSPATH' ) || exit;

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

	/**
	 * Header Settings Section
	 */
	$wp_customize->add_section(
		'shopbar_header_settings',
		array(
			'priority'   => 15,
			'capability' => 'edit_theme_options',
			'title'      => esc_html__( 'Header Settings', 'shopbar' ),
		)
	);

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

	$wp_customize->add_control(
		new Shopbar_Title_Info_Control( $wp_customize, 'shopbar_header_title_label',
		array(
			'label'    => esc_html__( 'Header Settings', 'shopbar' ),
			'section'  => 'shopbar_header_settings',
			'type'     => 'shopbar-title',
			'settings' => 'shopbar_header_title_label',
		)
	));

	// Browse Categories label text.
	$wp_customize->add_setting(
		'shopbar_header_browse_categories_text',
		array(
			'default'           => __( 'Browse Categories', 'shopbar' ),
			'type'              => 'theme_mod',
			'sanitize_callback' => 'shopbar_sanitize_text_field',
			'transport'         => 'refresh',
		)
	);

	$wp_customize->add_control(
		'shopbar_header_browse_categories_text',
		array(
			'label'       => esc_html__( 'Browse Categories Text', 'shopbar' ),
			'description' => esc_html__( 'Change the text shown on the Browse Categories button in the header.', 'shopbar' ),
			'section'     => 'shopbar_header_settings',
			'type'        => 'text',
		)
	);

	// Info note about the Category Header menu location.
	$wp_customize->add_setting(
		'shopbar_header_browse_categories_info',
		array(
			'sanitize_callback' => 'shopbar_sanitize_title',
		)
	);

	$wp_customize->add_control(
		new Shopbar_Info_Control( $wp_customize, 'shopbar_header_browse_categories_info',
		array(
			'label'    => esc_html__( 'Note: To show categories in this dropdown, create a new menu in Appearance -> Menus and set its Menu Location to "Category Header".', 'shopbar' ),
			'section'  => 'shopbar_header_settings',
			'type'     => 'shopbar-info',
			'settings' => 'shopbar_header_browse_categories_info',
		)
	));
}
endif;

add_action( 'customize_register', 'shopbar_customizer_header_settings_register' );
