<?php
/**
 * Business Interface Page Title 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_Page_Header' ) ) :
	/**
	 * Business Interface Page Title Settings section in Customizer.
	 */
	class Business_Interface_Customizer_Page_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 ) {

			// Page Title Section.
			$options['section']['business_interface_section_page_header'] = array(
				'title'    => esc_html__( 'Page Header', 'business-interface' ),
				'panel'    => 'business_interface_panel_header',
				'priority' => 60,
			);

			// Page Header enable.
			$options['setting']['business_interface_page_header_enable'] = array(
				'transport'         => 'refresh',
				'sanitize_callback' => 'business_interface_sanitize_toggle',
				'control'           => array(
					'type'    => 'business-interface-toggle',
					'label'   => esc_html__( 'Enable Page Header', 'business-interface' ),
					'section' => 'business_interface_section_page_header',
				),
			);

			// Alignment.
			$options['setting']['business_interface_page_header_alignment'] = array(
				'transport'         => 'postMessage',
				'sanitize_callback' => 'business_interface_sanitize_select',
				'control'           => array(
					'type'     => 'business-interface-alignment',
					'label'    => esc_html__( 'Title Alignment', 'business-interface' ),
					'section'  => 'business_interface_section_page_header',
					'choices'  => 'horizontal',
					'icons'    => array(
						'left'   => 'dashicons dashicons-editor-alignleft',
						'center' => 'dashicons dashicons-editor-aligncenter',
						'right'  => 'dashicons dashicons-editor-alignright',
					),
					'required' => array(
						array(
							'control'  => 'business_interface_page_header_enable',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
			);

			// Spacing.
			$options['setting']['business_interface_page_header_spacing'] = array(
				'transport'         => 'postMessage',
				'sanitize_callback' => 'business_interface_sanitize_responsive',
				'control'           => array(
					'type'        => 'business-interface-spacing',
					'label'       => esc_html__( 'Page Title Spacing', 'business-interface' ),
					'description' => esc_html__( 'Specify Page Title top and bottom padding.', 'business-interface' ),
					'section'     => 'business_interface_section_page_header',
					'choices'     => array(
						'top'    => esc_html__( 'Top', 'business-interface' ),
						'bottom' => esc_html__( 'Bottom', 'business-interface' ),
					),
					'responsive'  => true,
					'unit'        => array(
						'px',
					),
					'required'    => array(
						array(
							'control'  => 'business_interface_page_header_enable',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
			);

			// Page Header design options heading.
			$options['setting']['business_interface_page_header_heading_design'] = 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_page_header',
					'required' => array(
						array(
							'control'  => 'business_interface_page_header_enable',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
			);

			// Page Header background design.
			$options['setting']['business_interface_page_header_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_page_header',
					'display'  => array(
						'background' => array(
							'color'    => esc_html__( 'Solid Color', 'business-interface' ),
							'gradient' => esc_html__( 'Gradient', 'business-interface' ),
							'image'    => esc_html__( 'Image', 'business-interface' ),
						),
					),
					'required' => array(
						array(
							'control'  => 'business_interface_page_header_enable',
							'value'    => true,
							'operator' => '==',
						),
						array(
							'control'  => 'business_interface_page_header_heading_design',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
			);

			// Page Header Text Color.
			$options['setting']['business_interface_page_header_text_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_page_header',
					'display'  => array(
						'color' => array(
							'text-color'       => esc_html__( 'Text Color', 'business-interface' ),
							'link-color'       => esc_html__( 'Link Color', 'business-interface' ),
							'link-hover-color' => esc_html__( 'Link Hover Color', 'business-interface' ),
						),
					),
					'required' => array(
						array(
							'control'  => 'business_interface_page_header_enable',
							'value'    => true,
							'operator' => '==',
						),
						array(
							'control'  => 'business_interface_page_header_heading_design',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
			);

			// Page Header Border.
			$options['setting']['business_interface_page_header_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_page_header',
					'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_page_header_enable',
							'value'    => true,
							'operator' => '==',
						),
						array(
							'control'  => 'business_interface_page_header_heading_design',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
			);

			// Page Header typography heading.
			$options['setting']['business_interface_typography_page_header'] = 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_page_header',
					'required' => array(
						array(
							'control'  => 'business_interface_page_header_enable',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
			);

			// Page Header font size.
			$options['setting']['business_interface_page_header_font_size'] = array(
				'transport'         => 'postMessage',
				'sanitize_callback' => 'business_interface_sanitize_responsive',
				'control'           => array(
					'type'        => 'business-interface-range',
					'label'       => esc_html__( 'Page Title Font Size', 'business-interface' ),
					'description' => esc_html__( 'Choose your page title font size.', 'business-interface' ),
					'section'     => 'business_interface_section_page_header',
					'responsive'  => true,
					'unit'        => array(
						array(
							'id'   => 'px',
							'name' => 'px',
							'min'  => 8,
							'max'  => 90,
							'step' => 1,
						),
						array(
							'id'   => 'em',
							'name' => 'em',
							'min'  => 0.5,
							'max'  => 5,
							'step' => 0.01,
						),
						array(
							'id'   => 'rem',
							'name' => 'rem',
							'min'  => 0.5,
							'max'  => 5,
							'step' => 0.01,
						),
					),
					'required'    => array(
						array(
							'control'  => 'business_interface_typography_page_header',
							'value'    => true,
							'operator' => '==',
						),
						array(
							'control'  => 'business_interface_page_header_enable',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
			);

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