<?php
/**
 * Header Builder Options
 *
 * @package Code4rest
 */

namespace Code4rest;

use Code4rest\Theme_Customizer;
use function Code4rest\code4rest;

ob_start(); ?>
<div class="code4rest-build-tabs nav-tab-wrapper wp-clearfix">
	<a href="#" class="nav-tab preview-desktop code4rest-build-tabs-button" data-device="desktop">
		<span class="dashicons dashicons-desktop"></span>
		<span><?php esc_html_e( 'Desktop', 'code4rest' ); ?></span>
	</a>
	<a href="#" class="nav-tab preview-tablet preview-mobile code4rest-build-tabs-button" data-device="tablet">
		<span class="dashicons dashicons-smartphone"></span>
		<span><?php esc_html_e( 'Tablet / Mobile', 'code4rest' ); ?></span>
	</a>
</div>
<span class="button button-secondary code4rest-builder-hide-button code4rest-builder-tab-toggle"><span class="dashicons dashicons-no"></span><?php esc_html_e( 'Hide', 'code4rest' ); ?></span>
<span class="button button-secondary code4rest-builder-show-button code4rest-builder-tab-toggle"><span class="dashicons dashicons-edit"></span><?php esc_html_e( 'Header Builder', 'code4rest' ); ?></span>
<?php
$builder_tabs = ob_get_clean();
ob_start();
?>
<div class="code4rest-compontent-tabs nav-tab-wrapper wp-clearfix">
	<a href="#" class="nav-tab code4rest-general-tab code4rest-compontent-tabs-button nav-tab-active" data-tab="general">
		<span><?php esc_html_e( 'General', 'code4rest' ); ?></span>
	</a>
	<a href="#" class="nav-tab code4rest-design-tab code4rest-compontent-tabs-button" data-tab="design">
		<span><?php esc_html_e( 'Design', 'code4rest' ); ?></span>
	</a>
</div>
<?php
$compontent_tabs = ob_get_clean();
$settings = array(
	'header_builder' => array(
		'control_type' => 'code4rest_blank_control',
		'section'      => 'header_builder',
		'settings'     => false,
		'description'  => $builder_tabs,
	),
	'header_desktop_items' => array(
		'control_type' => 'code4rest_builder_control',
		'section'      => 'header_builder',
		'default'      => code4rest()->default( 'header_desktop_items' ),
		'context'      => array(
			array(
				'setting' => '__device',
				'value'   => 'desktop',
			),
		),
		'partial'      => array(
			'selector'            => '#masthead',
			'container_inclusive' => true,
			'render_callback'     => 'Code4rest\header_markup',
		),
		'choices'      => array(
			'logo'          => array(
				'name'    => esc_html__( 'Logo', 'code4rest' ),
				'section' => 'title_tagline',
			),
			'navigation'          => array(
				'name'    => esc_html__( 'Primary Navigation', 'code4rest' ),
				'section' => 'code4rest_customizer_primary_navigation',
			),
			'navigation-2'        => array(
				'name'    => esc_html__( 'Secondary Navigation', 'code4rest' ),
				'section' => 'code4rest_customizer_secondary_navigation',
			),
			'search' => array(
				'name'    => esc_html__( 'Search', 'code4rest' ),
				'section' => 'code4rest_customizer_header_search',
			),
			'button'        => array(
				'name'    => esc_html__( 'Button', 'code4rest' ),
				'section' => 'code4rest_customizer_header_button',
			),
			'social'        => array(
				'name'    => esc_html__( 'Social', 'code4rest' ),
				'section' => 'code4rest_customizer_header_social',
			),
			'html'          => array(
				'name'    => esc_html__( 'HTML', 'code4rest' ),
				'section' => 'code4rest_customizer_header_html',
			),
		),
		'input_attrs'  => array(
			'group' => 'header_desktop_items',
			'rows'  => array( 'top', 'main', 'bottom' ),
			'zones' => array(
				'top' => array(
					'top_left'         => is_rtl() ? esc_html__( 'Top - Right', 'code4rest' ) : esc_html__( 'Top - Left', 'code4rest' ),
					'top_left_center'  => is_rtl() ? esc_html__( 'Top - Right Center', 'code4rest' ) : esc_html__( 'Top - Left Center', 'code4rest' ),
					'top_center'       => esc_html__( 'Top - Center', 'code4rest' ),
					'top_right_center' => is_rtl() ? esc_html__( 'Top - Left Center', 'code4rest' ) : esc_html__( 'Top - Right Center', 'code4rest' ),
					'top_right'        => is_rtl() ? esc_html__( 'Top - Left', 'code4rest' ) : esc_html__( 'Top - Right', 'code4rest' ),
				),
				'main' => array(
					'main_left'         => is_rtl() ? esc_html__( 'Main - Right', 'code4rest' ) : esc_html__( 'Main - Left', 'code4rest' ),
					'main_left_center'  => is_rtl() ? esc_html__( 'Main - Right Center', 'code4rest' ) : esc_html__( 'Main - Left Center', 'code4rest' ),
					'main_center'       => esc_html__( 'Main - Center', 'code4rest' ),
					'main_right_center' => is_rtl() ? esc_html__( 'Main - Left Center', 'code4rest' ) : esc_html__( 'Main - Right Center', 'code4rest' ),
					'main_right'        => is_rtl() ? esc_html__( 'Main - Left', 'code4rest' ) : esc_html__( 'Main - Right', 'code4rest' ),
				),
				'bottom' => array(
					'bottom_left'         => is_rtl() ? esc_html__( 'Bottom - Right', 'code4rest' ) : esc_html__( 'Bottom - Left', 'code4rest' ),
					'bottom_left_center'  => is_rtl() ? esc_html__( 'Bottom - Right Center', 'code4rest' ) : esc_html__( 'Bottom - Left Center', 'code4rest' ),
					'bottom_center'       => esc_html__( 'Bottom - Center', 'code4rest' ),
					'bottom_right_center' => is_rtl() ? esc_html__( 'Bottom - Left Center', 'code4rest' ) : esc_html__( 'Bottom - Right Center', 'code4rest' ),
					'bottom_right'        => is_rtl() ? esc_html__( 'Bottom - Left', 'code4rest' ) : esc_html__( 'Bottom - Right', 'code4rest' ),
				),
			),
		),
	),
	'header_tab_settings' => array(
		'control_type' => 'code4rest_blank_control',
		'section'      => 'header_layout',
		'settings'     => false,
		'priority'     => 1,
		'description'  => $compontent_tabs,
	),
	'header_desktop_available_items' => array(
		'control_type' => 'code4rest_available_control',
		'section'      => 'header_layout',
		'settings'     => false,
		'input_attrs'  => array(
			'group'  => 'header_desktop_items',
			'zones'  => array( 'top', 'main', 'bottom' ),
		),
		'context'      => array(
			array(
				'setting' => '__device',
				'value'   => 'desktop',
			),
			array(
				'setting' => '__current_tab',
				'value'   => 'general',
			),
		),
	),
	'header_mobile_items' => array(
		'control_type' => 'code4rest_builder_control',
		'section'      => 'header_builder',
		'transport'    => 'refresh',
		'default'      => code4rest()->default( 'header_mobile_items' ),
		'context'      => array(
			array(
				'setting'  => '__device',
				'operator' => 'in',
				'value'    => array( 'tablet', 'mobile' ),
			),
		),
		'partial'      => array(
			'selector'            => '#mobile-header',
			'container_inclusive' => true,
			'render_callback'     => 'Code4rest\mobile_header',
		),
		'choices'      => array(
			'mobile-logo'          => array(
				'name'    => esc_html__( 'Logo', 'code4rest' ),
				'section' => 'title_tagline',
			),
			'mobile-navigation' => array(
				'name'    => esc_html__( 'Mobile Navigation', 'code4rest' ),
				'section' => 'code4rest_customizer_mobile_navigation',
			),
			// 'mobile-navigation2'          => array(
			// 	'name'    => esc_html__( 'Horizontal Navigation', 'code4rest' ),
			// 	'section' => 'mobile_horizontal_navigation',
			// ),
			'search' => array(
				'name'    => esc_html__( 'Search Toggle', 'code4rest' ),
				'section' => 'code4rest_customizer_header_search',
			),
			'mobile-button'        => array(
				'name'    => esc_html__( 'Button', 'code4rest' ),
				'section' => 'code4rest_customizer_mobile_button',
			),
			'mobile-social'        => array(
				'name'    => esc_html__( 'Social', 'code4rest' ),
				'section' => 'code4rest_customizer_mobile_social',
			),
			'mobile-html'          => array(
				'name'    => esc_html__( 'HTML', 'code4rest' ),
				'section' => 'code4rest_customizer_mobile_html',
			),
			'popup-toggle'          => array(
				'name'    => esc_html__( 'Trigger', 'code4rest' ),
				'section' => 'code4rest_customizer_mobile_trigger',
			),
		),
		'input_attrs'  => array(
			'group' => 'header_mobile_items',
			'rows'  => array( 'popup', 'top', 'main', 'bottom' ),
			'zones' => array(
				'popup' => array(
					'popup_content' => esc_html__( 'Popup Content', 'code4rest' ),
				),
				'top' => array(
					'top_left'   => is_rtl() ? esc_html__( 'Top - Right', 'code4rest' ) : esc_html__( 'Top - Left', 'code4rest' ),
					'top_center' => esc_html__( 'Top - Center', 'code4rest' ),
					'top_right'  => is_rtl() ? esc_html__( 'Top - Left', 'code4rest' ) : esc_html__( 'Top - Right', 'code4rest' ),
				),
				'main' => array(
					'main_left'   => is_rtl() ? esc_html__( 'Main - Right', 'code4rest' ) : esc_html__( 'Main - Left', 'code4rest' ),
					'main_center' => esc_html__( 'Main - Center', 'code4rest' ),
					'main_right'  => is_rtl() ? esc_html__( 'Main - Left', 'code4rest' ) : esc_html__( 'Main - Right', 'code4rest' ),
				),
				'bottom' => array(
					'bottom_left'   => is_rtl() ? esc_html__( 'Bottom - Right', 'code4rest' ) : esc_html__( 'Bottom - Left', 'code4rest' ),
					'bottom_center' => esc_html__( 'Bottom - Center', 'code4rest' ),
					'bottom_right'  => is_rtl() ? esc_html__( 'Bottom - Left', 'code4rest' ) : esc_html__( 'Bottom - Right', 'code4rest' ),
				),
			),
		),
	),
	'header_mobile_available_items' => array(
		'control_type' => 'code4rest_available_control',
		'section'      => 'header_layout',
		'settings'     => false,
		'input_attrs'  => array(
			'group'  => 'header_mobile_items',
			'zones'  => array( 'popup', 'top', 'main', 'bottom' ),
		),
		'context'      => array(
			array(
				'setting'  => '__device',
				'operator' => 'in',
				'value'    => array( 'tablet', 'mobile' ),
			),
			array(
				'setting' => '__current_tab',
				'value'   => 'general',
			),
		),
	),
	'header_transparent_link' => array(
		'control_type' => 'code4rest_focus_button_control',
		'section'      => 'header_layout',
		'settings'     => false,
		'priority'     => 20,
		'label'        => esc_html__( 'Transparent Header', 'code4rest' ),
		'input_attrs'  => array(
			'section' => 'code4rest_customizer_transparent_header',
		),
	),
	'header_sticky_link' => array(
		'control_type' => 'code4rest_focus_button_control',
		'section'      => 'header_layout',
		'settings'     => false,
		'priority'     => 20,
		'label'        => esc_html__( 'Sticky Header', 'code4rest' ),
		'input_attrs'  => array(
			'section' => 'code4rest_customizer_header_sticky',
		),
	),
	'header_wrap_background' => array(
		'control_type' => 'code4rest_background_control',
		'section'      => 'header_layout',
		'label'        => esc_html__( 'Header Background', 'code4rest' ),
		'default'      => code4rest()->default( 'header_wrap_background' ),
		'live_method'     => array(
			array(
				'type'     => 'css_background',
				'selector' => '#masthead',
				'property' => 'background',
				'pattern'  => '$',
				'key'      => 'base',
			),
		),
		'context'      => array(
			array(
				'setting' => '__current_tab',
				'value'   => 'design',
			),
		),
		'input_attrs'  => array(
			'tooltip'  => __( 'Header Background', 'code4rest' ),
		),
	),
	'header_mobile_switch' => array(
		'control_type' => 'code4rest_range_control',
		'section'      => 'header_layout',
		'transport'    => 'refresh',
		'label'        => esc_html__( 'Screen size to switch to mobile header', 'code4rest' ),
		'context'      => array(
			array(
				'setting' => '__current_tab',
				'value'   => 'design',
			),
		),
		'default'      => code4rest()->default( 'header_mobile_switch' ),
		'input_attrs'  => array(
			'min'        => array(
				'px'  => 0,
			),
			'max'        => array(
				'px'  => 4000,
			),
			'step'       => array(
				'px'  => 1,
			),
			'units'      => array( 'px' ),
			'responsive' => false,
		),
	),
);

Theme_Customizer::add_settings( $settings );

