<?php
/**
 * Business Interface Copyright Bar 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_Copyright_Settings' ) ) :
	/**
	 * Business Interface Copyright Bar section in Customizer.
	 */
	class Business_Interface_Customizer_Copyright_Settings {

		/**
		 * 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_copyright_bar'] = array(
				'title'    => esc_html__( 'Copyright Bar', 'business-interface' ),
				'priority' => 30,
				'panel'    => 'business_interface_panel_footer',
			);

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

			// Copyright Layout.
			$options['setting']['business_interface_copyright_layout'] = array(
				'transport'         => 'postMessage',
				'sanitize_callback' => 'business_interface_sanitize_select',
				'control'           => array(
					'type'        => 'business-interface-radio-image',
					'section'     => 'business_interface_section_copyright_bar',
					'label'       => esc_html__( 'Copyright Layout', 'business-interface' ),
					'description' => esc_html__( 'Choose your site&rsquo;s copyright widgets layout.', 'business-interface' ),
					'choices'     => array(
						'layout-1' => array(
							'image' => BUSINESS_INTERFACE_URI . '/inc/customizer/assets/images/copyright-layout-1.svg',
							'title' => esc_html__( 'Centered', 'business-interface' ),
						),
						'layout-2' => array(
							'image' => BUSINESS_INTERFACE_URI . '/inc/customizer/assets/images/copyright-layout-2.svg',
							'title' => esc_html__( 'Inline', 'business-interface' ),
						),
					),
					'required'    => array(
						array(
							'control'  => 'business_interface_enable_copyright',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
			);

			// Enable Copyright Bar.
			$options['setting']['business_interface_copyright_separator'] = array(
				'transport'         => 'postMessage',
				'sanitize_callback' => 'business_interface_sanitize_select',
				'control'           => array(
					'type'        => 'business-interface-select',
					'section'     => 'business_interface_section_copyright_bar',
					'label'       => esc_html__( 'Copyright Separator', 'business-interface' ),
					'description' => esc_html__( 'Select type of Copyright Separator.', 'business-interface' ),
					'choices'     => array(
						'none'                => esc_html__( 'None', 'business-interface' ),
						'contained-separator' => esc_html__( 'Contained Separator', 'business-interface' ),
						'fw-separator'        => esc_html__( 'Fullwidth Separator', 'business-interface' ),
					),
					'required'    => array(
						array(
							'control'  => 'business_interface_enable_copyright',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
			);

			// Copyright visibility.
			$options['setting']['business_interface_copyright_visibility'] = array(
				'transport'         => 'postMessage',
				'sanitize_callback' => 'business_interface_sanitize_select',
				'control'           => array(
					'type'        => 'business-interface-select',
					'section'     => 'business_interface_section_copyright_bar',
					'label'       => esc_html__( 'Device Visibility', 'business-interface' ),
					'description' => esc_html__( 'Devices where Copyright Bar is displayed.', 'business-interface' ),
					'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_copyright',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
			);

			// Copyright widgets heading.
			$options['setting']['business_interface_copyright_heading_widgets'] = array(
				'transport'         => 'postMessage',
				'sanitize_callback' => 'business_interface_sanitize_toggle',
				'control'           => array(
					'type'        => 'business-interface-heading',
					'section'     => 'business_interface_section_copyright_bar',
					'label'       => esc_html__( 'Copyright Bar Widgets', 'business-interface' ),
					'description' => esc_html__( 'Click the Add Widget button to add available widgets to your Copyright Bar.', 'business-interface' ),
					'required'    => array(
						array(
							'control'  => 'business_interface_enable_copyright',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
			);

			// Copyright widgets.
			$options['setting']['business_interface_copyright_widgets'] = array(
				'transport'         => 'postMessage',
				'sanitize_callback' => 'business_interface_sanitize_widget',
				'control'           => array(
					'type'       => 'business-interface-widget',
					'section'    => 'business_interface_section_copyright_bar',
					'label'      => esc_html__( 'Copyright Bar Widgets', 'business-interface' ),
					'widgets'    => array(
						'text'    => array(
							'max_uses' => 3,
						),
						'nav'     => array(
							'menu_location' => apply_filters( 'business_interface_footer_menu_location', 'business-interface-footer' ),
							'max_uses'      => 1,
						),
						'socials' => array(
							'max_uses' => 1,
							'styles'   => array(
								'minimal' => esc_html__( 'Minimal', 'business-interface' ),
								'rounded' => esc_html__( 'Rounded', 'business-interface' ),
							),
						),
					),
					'locations'  => array(
						'start' => esc_html__( 'Start', 'business-interface' ),
						'end'   => esc_html__( 'End', 'business-interface' ),
					),
					'visibility' => 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_copyright_heading_widgets',
							'value'    => true,
							'operator' => '==',
						),
						array(
							'control'  => 'business_interface_enable_copyright',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
				'partial'           => array(
					'selector'            => '#business-interface-copyright',
					'render_callback'     => 'business_interface_copyright_bar_output',
					'container_inclusive' => true,
					'fallback_refresh'    => true,
				),
			);

			// Copyright design options heading.
			$options['setting']['business_interface_copyright_heading_design_options'] = array(
				'transport'         => 'postMessage',
				'sanitize_callback' => 'business_interface_sanitize_toggle',
				'control'           => array(
					'type'     => 'business-interface-heading',
					'section'  => 'business_interface_section_copyright_bar',
					'label'    => esc_html__( 'Design Options', 'business-interface' ),
					'required' => array(
						array(
							'control'  => 'business_interface_enable_copyright',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
			);

			// Copyright Background.
			$options['setting']['business_interface_copyright_background'] = array(
				'transport'         => 'postMessage',
				'sanitize_callback' => 'business_interface_sanitize_design_options',
				'control'           => array(
					'type'     => 'business-interface-design-options',
					'section'  => 'business_interface_section_copyright_bar',
					'label'    => esc_html__( 'Background', 'business-interface' ),
					'space'    => true,
					'display'  => array(
						'background' => array(
							'color'    => esc_html__( 'Solid Color', 'business-interface' ),
							'gradient' => esc_html__( 'Gradient', 'business-interface' ),
						),
					),
					'required' => array(
						array(
							'control'  => 'business_interface_copyright_heading_design_options',
							'value'    => true,
							'operator' => '==',
						),
						array(
							'control'  => 'business_interface_enable_copyright',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
			);

			// Copyright Text Color.
			$options['setting']['business_interface_copyright_text_color'] = array(
				'transport'         => 'postMessage',
				'sanitize_callback' => 'business_interface_sanitize_design_options',
				'control'           => array(
					'type'        => 'business-interface-design-options',
					'section'     => 'business_interface_section_copyright_bar',
					'label'       => esc_html__( 'Font Color', 'business-interface' ),
					'description' => '',
					'space'       => true,
					'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_copyright_heading_design_options',
							'value'    => true,
							'operator' => '==',
						),
						array(
							'control'  => 'business_interface_enable_copyright',
							'value'    => true,
							'operator' => '==',
						),
					),
				),
			);

			return $options;
		}

	}
endif;
new Business_Interface_Customizer_Copyright_Settings();
