<?php
/**
 * Business Interface Breadcrumbs Settings section in Customizer.
 *
 * @package     Business Interface
 * @author      WPInterface Team
 * @since       1.1.0
 */

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

if ( ! class_exists( 'Business_Interface_Customizer_Breadcrumbs' ) ) :
	/**
	 * Business Interface Breadcrumbs Settings section in Customizer.
	 */
	class Business_Interface_Customizer_Breadcrumbs {

		/**
		 * Primary class constructor.
		 *
		 * @since 1.1.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.1.0
		 * @param array $options Array of customizer options.
		 */
		public function register_options( $options ) {

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

			// Breadcrumbs.
			$options['setting']['business_interface_breadcrumbs_enable'] = array(
				'transport'         => 'refresh',
				'sanitize_callback' => 'business_interface_sanitize_toggle',
				'control'           => array(
					'type'     => 'business-interface-toggle',
					'label'    => esc_html__( 'Enable Breadcrumbs', 'business-interface' ),
					'section'  => 'business_interface_section_breadcrumbs',
				),
			);

			// Hide breadcrumbs on.
			$options['setting']['business_interface_breadcrumbs_hide_on'] = array(
				'transport'         => 'refresh',
				'sanitize_callback' => 'business_interface_sanitize_checkbox_group',
				'control'           => array(
					'type'        => 'business-interface-checkbox-group',
					'label'       => esc_html__( 'Disable On: ', 'business-interface' ),
					'description' => esc_html__( 'Choose on which pages you want to disable breadcrumbs. ', 'business-interface' ),
					'section'     => 'business_interface_section_breadcrumbs',
					'choices'     => business_interface_get_display_choices(),
					'required'    => array(
						array(
							'control'  => 'business_interface_breadcrumbs_enable',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
			);

			// Position.
			$options['setting']['business_interface_breadcrumbs_position'] = array(
				'transport'         => 'refresh',
				'sanitize_callback' => 'business_interface_sanitize_select',
				'control'           => array(
					'type'     => 'business-interface-select',
					'label'    => esc_html__( 'Position', 'business-interface' ),
					'section'  => 'business_interface_section_breadcrumbs',
					'choices'  => array(
						'in-page-header' => esc_html__( 'In Page Header', 'business-interface' ),
						'below-header'   => esc_html__( 'Below Header (Separate Container)', 'business-interface' ),
					),
					'required' => array(
						array(
							'control'  => 'business_interface_breadcrumbs_enable',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
			);

			// Alignment.
			$options['setting']['business_interface_breadcrumbs_alignment'] = array(
				'transport'         => 'postMessage',
				'sanitize_callback' => 'business_interface_sanitize_select',
				'control'           => array(
					'type'     => 'business-interface-alignment',
					'label'    => esc_html__( 'Alignment', 'business-interface' ),
					'section'  => 'business_interface_section_breadcrumbs',
					'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_breadcrumbs_enable',
							'value'    => true,
							'operator' => '==',
						),
						array(
							'control'  => 'business_interface_breadcrumbs_position',
							'value'    => 'below-header',
							'operator' => '==',
						),
					),
				),
			);

			// Spacing.
			$options['setting']['business_interface_breadcrumbs_spacing'] = array(
				'transport'         => 'postMessage',
				'sanitize_callback' => 'business_interface_sanitize_responsive',
				'control'           => array(
					'type'        => 'business-interface-spacing',
					'label'       => esc_html__( 'Spacing', 'business-interface' ),
					'description' => esc_html__( 'Specify top and bottom padding.', 'business-interface' ),
					'section'     => 'business_interface_section_breadcrumbs',
					'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_breadcrumbs_enable',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
			);

			// Design options heading.
			$options['setting']['business_interface_breadcrumbs_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_breadcrumbs',
					'required' => array(
						array(
							'control'  => 'business_interface_breadcrumbs_enable',
							'value'    => true,
							'operator' => '==',
						),
						array(
							'control'  => 'business_interface_breadcrumbs_position',
							'value'    => 'below-header',
							'operator' => '==',
						),
					),
				),
			);

			// Background design.
			$options['setting']['business_interface_breadcrumbs_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_breadcrumbs',
					'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_breadcrumbs_enable',
							'value'    => true,
							'operator' => '==',
						),
						array(
							'control'  => 'business_interface_breadcrumbs_heading_design',
							'value'    => true,
							'operator' => '==',
						),
						array(
							'control'  => 'business_interface_breadcrumbs_position',
							'value'    => 'below-header',
							'operator' => '==',
						),
					),
				),
			);

			// Text Color.
			$options['setting']['business_interface_breadcrumbs_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_breadcrumbs',
					'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_breadcrumbs_enable',
							'value'    => true,
							'operator' => '==',
						),
						array(
							'control'  => 'business_interface_breadcrumbs_heading_design',
							'value'    => true,
							'operator' => '==',
						),
						array(
							'control'  => 'business_interface_breadcrumbs_position',
							'value'    => 'below-header',
							'operator' => '==',
						),
					),
				),
			);

			// Border.
			$options['setting']['business_interface_breadcrumbs_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_breadcrumbs',
					'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_breadcrumbs_enable',
							'value'    => true,
							'operator' => '==',
						),
						array(
							'control'  => 'business_interface_breadcrumbs_heading_design',
							'value'    => true,
							'operator' => '==',
						),
						array(
							'control'  => 'business_interface_breadcrumbs_position',
							'value'    => 'below-header',
							'operator' => '==',
						),
					),
				),
			);

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