<?php
/**
 * Business Interface Main Navigation 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_Main_Navigation' ) ) :
	/**
	 * Business Interface Main Navigation Settings section in Customizer.
	 */
	class Business_Interface_Customizer_Main_Navigation {

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

			// Main Navigation Section.
			$options['section']['business_interface_section_main_navigation'] = array(
				'title'    => esc_html__( 'Main Navigation', 'business-interface' ),
				'panel'    => 'business_interface_panel_header',
				'priority' => 30,
			);

			// Navigation animation heading.
			$options['setting']['business_interface_main_nav_heading_animation'] = array(
				'transport'         => 'postMessage',
				'sanitize_callback' => 'business_interface_sanitize_toggle',
				'control'           => array(
					'type'    => 'business-interface-heading',
					'label'   => esc_html__( 'Animation', 'business-interface' ),
					'section' => 'business_interface_section_main_navigation',
				),
			);

			// Hover animation.
			$options['setting']['business_interface_main_nav_hover_animation'] = array(
				'transport'         => 'postMessage',
				'sanitize_callback' => 'business_interface_sanitize_select',
				'control'           => array(
					'type'        => 'business-interface-select',
					'label'       => esc_html__( 'Hover Animation', 'business-interface' ),
					'description' => esc_html__( 'Choose menu item hover animation style.', 'business-interface' ),
					'section'     => 'business_interface_section_main_navigation',
					'choices'     => array(
						'none'      => esc_html__( 'None', 'business-interface' ),
						'underline' => esc_html__( 'Underline', 'business-interface' ),
					),
					'required'    => array(
						array(
							'control'  => 'business_interface_main_nav_heading_animation',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
			);

			// Sub Menus heading.
			$options['setting']['business_interface_main_nav_heading_sub_menus'] = array(
				'transport'         => 'postMessage',
				'sanitize_callback' => 'business_interface_sanitize_toggle',
				'control'           => array(
					'type'    => 'business-interface-heading',
					'label'   => esc_html__( 'Sub Menus', 'business-interface' ),
					'section' => 'business_interface_section_main_navigation',
				),
			);

			// Sub-Menu Indicators.
			$options['setting']['business_interface_main_nav_sub_indicators'] = array(
				'transport'         => 'postMessage',
				'sanitize_callback' => 'business_interface_sanitize_toggle',
				'control'           => array(
					'type'        => 'business-interface-toggle',
					'label'       => esc_html__( 'Dropdown Indicators', 'business-interface' ),
					'description' => esc_html__( 'Show indicators (arrow icons) on parent menu items that have sub menus.', 'business-interface' ),
					'section'     => 'business_interface_section_main_navigation',
					'required'    => array(
						array(
							'control'  => 'business_interface_main_nav_heading_sub_menus',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
				'partial'           => array(
					'selector'            => '.main-navigation',
					'render_callback'     => 'business_interface_main_navigation_template',
					'container_inclusive' => true,
					'fallback_refresh'    => true,
				),
			);

			// Mobile Menu heading.
			$options['setting']['business_interface_main_nav_heading_mobile_menu'] = array(
				'transport'         => 'postMessage',
				'sanitize_callback' => 'business_interface_sanitize_toggle',
				'control'           => array(
					'type'    => 'business-interface-heading',
					'label'   => esc_html__( 'Mobile Menu', 'business-interface' ),
					'section' => 'business_interface_section_main_navigation',
				),
			);

			// Mobile Menu Breakpoint.
			$options['setting']['business_interface_main_nav_mobile_breakpoint'] = array(
				'transport'         => 'refresh',
				'sanitize_callback' => 'business_interface_sanitize_range',
				'control'           => array(
					'type'        => 'business-interface-range',
					'label'       => esc_html__( 'Mobile Breakpoint', 'business-interface' ),
					'description' => esc_html__( 'Choose the breakpoint (in px) when to show the mobile navigation.', 'business-interface' ),
					'section'     => 'business_interface_section_main_navigation',
					'min'         => 0,
					'max'         => 1920,
					'step'        => 1,
					'unit'        => 'px',
					'required'    => array(
						array(
							'control'  => 'business_interface_main_nav_heading_mobile_menu',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
			);

			// Mobile Menu Button Label.
			$options['setting']['business_interface_main_nav_mobile_label'] = array(
				'transport'         => 'postMessage',
				'sanitize_callback' => 'sanitize_text_field',
				'control'           => array(
					'type'        => 'business-interface-text',
					'label'       => esc_html__( 'Mobile Menu Button Label', 'business-interface' ),
					'description' => esc_html__( 'This text will be displayed next to the mobile menu button.', 'business-interface' ),
					'section'     => 'business_interface_section_main_navigation',
					'placeholder' => esc_html__( 'Leave empty to hide the label...', 'business-interface' ),
					'required'    => array(
						array(
							'control'  => 'business_interface_main_nav_heading_mobile_menu',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
			);

			// Navigation design options heading.
			$options['setting']['business_interface_nav_design_options'] = array(
				'transport'         => 'postMessage',
				'sanitize_callback' => 'business_interface_sanitize_toggle',
				'control'           => array(
					'type'    => 'business-interface-heading',
					'label'   => esc_html__( 'Design Options', 'business-interface' ),
					'section' => 'business_interface_section_main_navigation',
				),
			);

			// Navigation Background.
			$options['setting']['business_interface_main_nav_background'] = array(
				'transport'         => 'postMessage',
				'sanitize_callback' => 'business_interface_sanitize_design_options',
				'control'           => array(
					'type'     => 'business-interface-design-options',
					'label'    => esc_html__( 'Background', 'business-interface' ),
					'section'  => 'business_interface_section_main_navigation',
					'display'  => array(
						'background' => array(
							'color'    => esc_html__( 'Solid Color', 'business-interface' ),
							'gradient' => esc_html__( 'Gradient', 'business-interface' ),
						),
					),
					'required' => array(
						array(
							'control'  => 'business_interface_nav_design_options',
							'value'    => true,
							'operator' => '==',
						),
						array(
							'control'  => 'business_interface_header_layout',
							'value'    => 'layout-3',
							'operator' => '==',
						),
					),
				),
			);

			// Navigation Font Color.
			$options['setting']['business_interface_main_nav_font_color'] = array(
				'transport'         => 'postMessage',
				'sanitize_callback' => 'business_interface_sanitize_design_options',
				'control'           => array(
					'type'     => 'business-interface-design-options',
					'label'    => esc_html__( 'Font Color', 'business-interface' ),
					'section'  => 'business_interface_section_main_navigation',
					'display'  => array(
						'color' => array(
							'link-color'       => esc_html__( 'Link Color', 'business-interface' ),
							'link-hover-color' => esc_html__( 'Link Hover Color', 'business-interface' ),
						),
					),
					'required' => array(
						array(
							'control'  => 'business_interface_nav_design_options',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
			);

			// Navigation Border.
			$options['setting']['business_interface_main_nav_border'] = array(
				'transport'         => 'postMessage',
				'sanitize_callback' => 'business_interface_sanitize_design_options',
				'control'           => array(
					'type'     => 'business-interface-design-options',
					'label'    => esc_html__( 'Border', 'business-interface' ),
					'section'  => 'business_interface_section_main_navigation',
					'display'  => array(
						'border' => array(
							'style'     => esc_html__( 'Style', 'business-interface' ),
							'color'     => esc_html__( 'Color', 'business-interface' ),
							'width'     => esc_html__( 'Width (px)', 'business-interface' ),
							'positions' => array(
								'top'    => esc_html__( 'Top', 'business-interface' ),
								'bottom' => esc_html__( 'Bottom', 'business-interface' ),
							),
						),
					),
					'required' => array(
						array(
							'control'  => 'business_interface_nav_design_options',
							'value'    => true,
							'operator' => '==',
						),
						array(
							'control'  => 'business_interface_header_layout',
							'value'    => 'layout-3',
							'operator' => '==',
						),
					),
				),
			);

			// Main navigation typography heading.
			$options['setting']['business_interface_typography_main_nav_heading'] = array(
				'transport'         => 'postMessage',
				'sanitize_callback' => 'business_interface_sanitize_toggle',
				'control'           => array(
					'type'    => 'business-interface-heading',
					'label'   => esc_html__( 'Typography', 'business-interface' ),
					'section' => 'business_interface_section_main_navigation',
				),
			);

			// Main navigation font size.
			$options['setting']['business_interface_main_nav_font_size'] = array(
				'transport'         => 'postMessage',
				'sanitize_callback' => 'business_interface_sanitize_responsive',
				'control'           => array(
					'type'        => 'business-interface-range',
					'label'       => esc_html__( 'Font Size', 'business-interface' ),
					'description' => esc_html__( 'Choose your main navigation font size.', 'business-interface' ),
					'section'     => 'business_interface_section_main_navigation',
					'unit'        => array(
						array(
							'id'   => 'px',
							'name' => 'px',
							'min'  => 8,
							'max'  => 25,
							'step' => 1,
						),
						array(
							'id'   => 'em',
							'name' => 'em',
							'min'  => 0.5,
							'max'  => 2,
							'step' => 0.01,
						),
						array(
							'id'   => 'rem',
							'name' => 'rem',
							'min'  => 0.5,
							'max'  => 2,
							'step' => 0.01,
						),
					),
					'required'    => array(
						array(
							'control'  => 'business_interface_typography_main_nav_heading',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
			);

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