<?php
/**
 * Business Interface Pre Footer 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_Pre_Footer' ) ) :
	/**
	 * Business Interface Pre Footer section in Customizer.
	 */
	class Business_Interface_Customizer_Pre_Footer {

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

			// Pre Footer.
			$options['section']['business_interface_section_pre_footer'] = array(
				'title'    => esc_html__( 'Pre Footer', 'business-interface' ),
				'panel'    => 'business_interface_panel_footer',
				'priority' => 10,
			);

			// Pre Footer - Call to Action.
			$options['setting']['business_interface_pre_footer_cta'] = array(
				'transport'         => 'postMessage',
				'sanitize_callback' => 'business_interface_sanitize_toggle',
				'control'           => array(
					'type'    => 'business-interface-heading',
					'label'   => esc_html__( 'Call to Action', 'business-interface' ),
					'section' => 'business_interface_section_pre_footer',
				),
			);

			// Enable Pre Footer CTA.
			$options['setting']['business_interface_enable_pre_footer_cta'] = array(
				'transport'         => 'postMessage',
				'sanitize_callback' => 'business_interface_sanitize_toggle',
				'control'           => array(
					'type'     => 'business-interface-toggle',
					'label'    => esc_html__( 'Enable Call to Action', 'business-interface' ),
					'section'  => 'business_interface_section_pre_footer',
					'required' => array(
						array(
							'control'  => 'business_interface_pre_footer_cta',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
				'partial'           => array(
					'selector'            => '#si-pre-footer',
					'render_callback'     => 'business_interface_pre_footer',
					'container_inclusive' => true,
					'fallback_refresh'    => true,
				),
			);

			// Pre Footer visibility.
			$options['setting']['business_interface_pre_footer_cta_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 Top Bar is displayed.', 'business-interface' ),
					'section'     => 'business_interface_section_pre_footer',
					'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_pre_footer_cta',
							'value'    => true,
							'operator' => '==',
						),
						array(
							'control'  => 'business_interface_enable_pre_footer_cta',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
			);

			// Pre Footer Hide on.
			$options['setting']['business_interface_pre_footer_cta_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 Pre Footer Call to Action. ', 'business-interface' ),
					'section'     => 'business_interface_section_pre_footer',
					'choices'     => business_interface_get_display_choices(),
					'required'    => array(
						array(
							'control'  => 'business_interface_pre_footer_cta',
							'value'    => true,
							'operator' => '==',
						),
						array(
							'control'  => 'business_interface_enable_pre_footer_cta',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
			);

			// Pre Footer CTA Style.
			$options['setting']['business_interface_pre_footer_cta_style'] = array(
				'transport'         => 'postMessage',
				'sanitize_callback' => 'business_interface_sanitize_select',
				'control'           => array(
					'type'        => 'business-interface-select',
					'label'       => esc_html__( 'Style', 'business-interface' ),
					'description' => esc_html__( 'Choose CTA Style.', 'business-interface' ),
					'section'     => 'business_interface_section_pre_footer',
					'choices'     => array(
						'1' => esc_html__( 'Contained', 'business-interface' ),
						'2' => esc_html__( 'Fullwidth', 'business-interface' ),
					),
					'required'    => array(
						array(
							'control'  => 'business_interface_pre_footer_cta',
							'value'    => true,
							'operator' => '==',
						),
						array(
							'control'  => 'business_interface_enable_pre_footer_cta',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
			);

			// Pre Footer CTA Text.
			$options['setting']['business_interface_pre_footer_cta_text'] = array(
				'transport'         => 'postMessage',
				'sanitize_callback' => 'business_interface_sanitize_textarea',
				'control'           => array(
					'type'        => 'business-interface-textarea',
					'label'       => esc_html__( 'Content', 'business-interface' ),
					'description' => esc_html__( 'Shortcodes and basic html elements allowed.', 'business-interface' ),
					'placeholder' => esc_html__( 'Call to Action Content', 'business-interface' ),
					'section'     => 'business_interface_section_pre_footer',
					'rows'        => '5',
					'required'    => array(
						array(
							'control'  => 'business_interface_pre_footer_cta',
							'value'    => true,
							'operator' => '==',
						),
						array(
							'control'  => 'business_interface_enable_pre_footer_cta',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
			);

			// Pre Footer CTA Button Text.
			$options['setting']['business_interface_pre_footer_cta_btn_text'] = array(
				'transport'         => 'postMessage',
				'sanitize_callback' => 'sanitize_text_field',
				'control'           => array(
					'type'        => 'business-interface-text',
					'label'       => esc_html__( 'Button Text', 'business-interface' ),
					'description' => esc_html__( 'Label for the CTA button.', 'business-interface' ),
					'section'     => 'business_interface_section_pre_footer',
					'required'    => array(
						array(
							'control'  => 'business_interface_pre_footer_cta',
							'value'    => true,
							'operator' => '==',
						),
						array(
							'control'  => 'business_interface_enable_pre_footer_cta',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
			);

			// Pre Footer CTA Button URL.
			$options['setting']['business_interface_pre_footer_cta_btn_url'] = array(
				'transport'         => 'postMessage',
				'sanitize_callback' => 'sanitize_text_field',
				'control'           => array(
					'type'        => 'business-interface-text',
					'label'       => esc_html__( 'Button Link', 'business-interface' ),
					'description' => esc_html__( 'Link for the CTA button.', 'business-interface' ),
					'placeholder' => 'http://',
					'section'     => 'business_interface_section_pre_footer',
					'required'    => array(
						array(
							'control'  => 'business_interface_pre_footer_cta',
							'value'    => true,
							'operator' => '==',
						),
						array(
							'control'  => 'business_interface_enable_pre_footer_cta',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
			);

			// Pre Footer CTA open in new tab.
			$options['setting']['business_interface_pre_footer_cta_btn_new_tab'] = array(
				'transport'         => 'postMessage',
				'sanitize_callback' => 'business_interface_sanitize_toggle',
				'control'           => array(
					'type'     => 'business-interface-toggle',
					'label'    => esc_html__( 'Open link in new tab?', 'business-interface' ),
					'section'  => 'business_interface_section_pre_footer',
					'required' => array(
						array(
							'control'  => 'business_interface_pre_footer_cta',
							'value'    => true,
							'operator' => '==',
						),
						array(
							'control'  => 'business_interface_enable_pre_footer_cta',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
			);

			// Pre Footer - Call to Action Design Options.
			$options['setting']['business_interface_pre_footer_cta_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_pre_footer',
					'required' => array(
						array(
							'control'  => 'business_interface_pre_footer_cta',
							'value'    => true,
							'operator' => '==',
						),
						array(
							'control'  => 'business_interface_enable_pre_footer_cta',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
			);

			// Pre Footer - Call to Action Background.
			$options['setting']['business_interface_pre_footer_cta_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_pre_footer',
					'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_pre_footer_cta',
							'value'    => true,
							'operator' => '==',
						),
						array(
							'control'  => 'business_interface_enable_pre_footer_cta',
							'value'    => true,
							'operator' => '==',
						),
						array(
							'control'  => 'business_interface_pre_footer_cta_design_options',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
			);

			// Pre Footer - Call to Action Text Color.
			$options['setting']['business_interface_pre_footer_cta_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_pre_footer',
					'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_pre_footer_cta',
							'value'    => true,
							'operator' => '==',
						),
						array(
							'control'  => 'business_interface_enable_pre_footer_cta',
							'value'    => true,
							'operator' => '==',
						),
						array(
							'control'  => 'business_interface_pre_footer_cta_design_options',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
			);

			// Pre Footer - Call to Action Border.
			$options['setting']['business_interface_pre_footer_cta_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_pre_footer',
					'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' ),
								'right'  => esc_html__( 'Right', 'business-interface' ),
								'bottom' => esc_html__( 'Bottom', 'business-interface' ),
								'left'   => esc_html__( 'Left', 'business-interface' ),
							),
						),
					),
					'required' => array(
						array(
							'control'  => 'business_interface_pre_footer_cta',
							'value'    => true,
							'operator' => '==',
						),
						array(
							'control'  => 'business_interface_enable_pre_footer_cta',
							'value'    => true,
							'operator' => '==',
						),
						array(
							'control'  => 'business_interface_pre_footer_cta_design_options',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
			);

			// CTA typography heading.
			$options['setting']['business_interface_pre_footer_cta_typography'] = 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_pre_footer',
					'required' => array(
						array(
							'control'  => 'business_interface_pre_footer_cta',
							'value'    => true,
							'operator' => '==',
						),
						array(
							'control'  => 'business_interface_enable_pre_footer_cta',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
			);

			// CTA font size.
			$options['setting']['business_interface_pre_footer_cta_font_size'] = array(
				'transport'         => 'postMessage',
				'sanitize_callback' => 'business_interface_sanitize_responsive',
				'control'           => array(
					'type'       => 'business-interface-range',
					'label'      => esc_html__( 'Font Size', 'business-interface' ),
					'section'    => 'business_interface_section_pre_footer',
					'min'        => 8,
					'max'        => 90,
					'step'       => 1,
					'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_pre_footer_cta',
							'value'    => true,
							'operator' => '==',
						),
						array(
							'control'  => 'business_interface_enable_pre_footer_cta',
							'value'    => true,
							'operator' => '==',
						),
						array(
							'control'  => 'business_interface_pre_footer_cta_typography',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
			);

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