<?php
/**
 * Business Interface Misc 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_Misc' ) ) :
	/**
	 * Business Interface Misc section in Customizer.
	 */
	class Business_Interface_Customizer_Misc {

		/**
		 * 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 ) {

			// Section.
			$options['section']['business_interface_section_misc'] = array(
				'title'    => esc_html__( 'Misc Settings', 'business-interface' ),
				'panel'    => 'business_interface_panel_general',
				'priority' => 60,
			);

			// Schema toggle.
			$options['setting']['business_interface_enable_schema'] = array(
				'transport'         => 'postMessage',
				'sanitize_callback' => 'business_interface_sanitize_toggle',
				'control'           => array(
					'type'        => 'business-interface-toggle',
					'label'       => esc_html__( 'Schema Markup', 'business-interface' ),
					'description' => esc_html__( 'Add structured data to your content.', 'business-interface' ),
					'section'     => 'business_interface_section_misc',
				),
			);

			// Custom form styles.
			$options['setting']['business_interface_custom_input_style'] = array(
				'transport'         => 'postMessage',
				'sanitize_callback' => 'business_interface_sanitize_toggle',
				'control'           => array(
					'type'        => 'business-interface-toggle',
					'label'       => esc_html__( 'Custom Form Styles', 'business-interface' ),
					'description' => esc_html__( 'Custom design for checkboxes and radio buttons.', 'business-interface' ),
					'section'     => 'business_interface_section_misc',
				),
			);

			// Page Preloader heading.
			$options['setting']['business_interface_preloader_heading'] = array(
				'transport'         => 'postMessage',
				'sanitize_callback' => 'business_interface_sanitize_toggle',
				'control'           => array(
					'type'    => 'business-interface-heading',
					'label'   => esc_html__( 'Page Preloader', 'business-interface' ),
					'section' => 'business_interface_section_misc',
				),
			);

			// Enable/Disable Page Preloader.
			$options['setting']['business_interface_preloader'] = array(
				'transport'         => 'refresh',
				'sanitize_callback' => 'business_interface_sanitize_toggle',
				'control'           => array(
					'type'        => 'business-interface-toggle',
					'label'       => esc_html__( 'Enable Page Preloader', 'business-interface' ),
					'description' => esc_html__( 'Show animation until page is fully loaded.', 'business-interface' ),
					'section'     => 'business_interface_section_misc',
					'required'    => array(
						array(
							'control'  => 'business_interface_preloader_heading',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
			);

			// Preloader visibility.
			$options['setting']['business_interface_preloader_visibility'] = array(
				'transport'         => 'postMessage',
				'sanitize_callback' => 'business_interface_sanitize_select',
				'control'           => array(
					'type'        => 'business-interface-select',
					'label'       => esc_html__( 'Device Visibility', 'business-interface' ),
					'description' => esc_html__( 'Devices where Page Preloader is displayed.', 'business-interface' ),
					'section'     => 'business_interface_section_misc',
					'choices'     => array(
						'all'                => esc_html__( 'Show on All Devices', 'business-interface' ),
						'hide-mobile'        => esc_html__( 'Hide on Mobile', 'business-interface' ),
						'hide-tablet'        => esc_html__( 'Hide on Tablet', 'business-interface' ),
						'hide-mobile-tablet' => esc_html__( 'Hide on Mobile and Tablet', 'business-interface' ),
					),
					'required'    => array(
						array(
							'control'  => 'business_interface_preloader_heading',
							'value'    => true,
							'operator' => '==',
						),
						array(
							'control'  => 'business_interface_preloader',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
			);

			// Scroll Top heading.
			$options['setting']['business_interface_scroll_top_heading'] = array(
				'transport'         => 'postMessage',
				'sanitize_callback' => 'business_interface_sanitize_toggle',
				'control'           => array(
					'type'    => 'business-interface-heading',
					'label'   => esc_html__( 'Scroll Top Button', 'business-interface' ),
					'section' => 'business_interface_section_misc',
				),
			);

			// Enable/Disable Scroll Top.
			$options['setting']['business_interface_enable_scroll_top'] = array(
				'transport'         => 'refresh',
				'sanitize_callback' => 'business_interface_sanitize_toggle',
				'control'           => array(
					'type'        => 'business-interface-toggle',
					'label'       => esc_html__( 'Enable Scroll Top Button', 'business-interface' ),
					'description' => esc_html__( 'A sticky button that allows users to easily return to the top of a page.', 'business-interface' ),
					'section'     => 'business_interface_section_misc',
					'required'    => array(
						array(
							'control'  => 'business_interface_scroll_top_heading',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
			);

			// Scroll Top device visibility.
			$options['setting']['business_interface_scroll_top_visibility'] = array(
				'transport'         => 'postMessage',
				'sanitize_callback' => 'business_interface_sanitize_select',
				'control'           => array(
					'type'        => 'business-interface-select',
					'label'       => esc_html__( 'Device Visibility', 'business-interface' ),
					'description' => esc_html__( 'Devices where the button is displayed.', 'business-interface' ),
					'section'     => 'business_interface_section_misc',
					'choices'     => array(
						'all'                => esc_html__( 'Show on All Devices', 'business-interface' ),
						'hide-mobile'        => esc_html__( 'Hide on Mobile', 'business-interface' ),
						'hide-tablet'        => esc_html__( 'Hide on Tablet', 'business-interface' ),
						'hide-mobile-tablet' => esc_html__( 'Hide on Mobile and Tablet', 'business-interface' ),
					),
					'required'    => array(
						array(
							'control'  => 'business_interface_enable_scroll_top',
							'value'    => true,
							'operator' => '==',
						),
						array(
							'control'  => 'business_interface_scroll_top_heading',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
			);

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