<?php
/**
 * Business Interface Sticky Header Settings section in Customizer.
 *
 * @package     Business Interface
 * @author      WPInterface Team
 * @since       1.0.0
 */

/**
 * Do not allow direct script access.
 */
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

if ( ! class_exists( 'Business_Interface_Customizer_Sticky_Header' ) ) :
	/**
	 * Business Interface Sticky Header section in Customizer.
	 */
	class Business_Interface_Customizer_Sticky_Header {

		/**
		 * Primary class constructor.
		 *
		 * @since 1.0.0
		 */
		public function __construct() {

			/**
			 * Registers our custom options in Customizer.
			 */
			add_filter( 'business_interface_customizer_options', array( $this, 'register_options' ) );
		}

		/**
		 * Registers our custom options in Customizer.
		 *
		 * @since 1.0.0
		 * @param array $options Array of customizer options.
		 */
		public function register_options( $options ) {

			// Sticky Header Section.
			$options['section']['business_interface_section_sticky_header'] = array(
				'title'    => esc_html__( 'Sticky Header', 'business-interface' ),
				'panel'    => 'business_interface_panel_header',
				'priority' => 80,
			);

			// Enable Transparent Header.
			$options['setting']['business_interface_sticky_header'] = array(
				'transport'         => 'refresh',
				'sanitize_callback' => 'business_interface_sanitize_toggle',
				'control'           => array(
					'type'    => 'business-interface-toggle',
					'label'   => esc_html__( 'Enable Sticky Header', 'business-interface' ),
					'section' => 'business_interface_section_sticky_header',
				),
			);

			// Responsive heading.
			$options['setting']['business_interface_sticky_header_responsive'] = array(
				'transport'         => 'postMessage',
				'sanitize_callback' => 'business_interface_sanitize_toggle',
				'control'           => array(
					'type'     => 'business-interface-heading',
					'section'  => 'business_interface_section_sticky_header',
					'label'    => esc_html__( 'Responsive', 'business-interface' ),
					'required' => array(
						array(
							'control'  => 'business_interface_sticky_header',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
			);

			// Hide sticky header on.
			$options['setting']['business_interface_sticky_header_hide_on'] = array(
				'transport'         => 'refresh',
				'sanitize_callback' => 'business_interface_sanitize_checkbox_group',
				'control'           => array(
					'type'        => 'business-interface-checkbox-group',
					'label'       => esc_html__( 'Hide on: ', 'business-interface' ),
					'description' => esc_html__( 'Choose on which devices to hide Sticky Header on. ', 'business-interface' ),
					'section'     => 'business_interface_section_sticky_header',
					'choices'     => business_interface_get_device_choices(),
					'required'    => array(
						array(
							'control'  => 'business_interface_sticky_header',
							'value'    => true,
							'operator' => '==',
						),
						array(
							'control'  => 'business_interface_sticky_header_responsive',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
			);

			return $options;
		}
	}
endif;
new Business_Interface_Customizer_Sticky_Header();
