<?php
/**
 * Business Interface Layout 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_Layout' ) ) :
	/**
	 * Business Interface Layout section in Customizer.
	 */
	class Business_Interface_Customizer_Layout {

		/**
		 * 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_layout_section'] = array(
				'title'    => esc_html__( 'Layout', 'business-interface' ),
				'panel'    => 'business_interface_panel_general',
				'priority' => 10,
			);

			// Site layout.
			$options['setting']['business_interface_site_layout'] = array(
				'transport'         => 'postMessage',
				'sanitize_callback' => 'business_interface_sanitize_select',
				'control'           => array(
					'type'        => 'business-interface-select',
					'section'     => 'business_interface_layout_section',
					'label'       => esc_html__( 'Site Layout', 'business-interface' ),
					'description' => esc_html__( 'Choose your site&rsquo;s main layout.', 'business-interface' ),
					'choices'     => array(
						'fw-contained'    => esc_html__( 'Full Width: Contained', 'business-interface' ),
						'fw-stretched'    => esc_html__( 'Full Width: Stretched', 'business-interface' ),
						'boxed-separated' => esc_html__( 'Boxed Content', 'business-interface' ),
						'boxed'           => esc_html__( 'Boxed', 'business-interface' ),
					),
				),
			);

			// Container width.
			$options['setting']['business_interface_container_width'] = array(
				'transport'         => 'postMessage',
				'sanitize_callback' => 'business_interface_sanitize_range',
				'control'           => array(
					'type'        => 'business-interface-range',
					'section'     => 'business_interface_layout_section',
					'label'       => esc_html__( 'Content Width', 'business-interface' ),
					'description' => esc_html__( 'Change your site&rsquo;s main container width.', 'business-interface' ),
					'min'         => 500,
					'max'         => 1920,
					'step'        => 10,
					'unit'        => 'px',
					'required'    => array(
						array(
							'control'  => 'business_interface_site_layout',
							'value'    => 'fw-stretched',
							'operator' => '!=',
						),
					),
				),
			);

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