<?php
/**
 * Header Main Row Options
 *
 * @package Code4rest
 */

namespace Code4rest;

use Code4rest\Theme_Customizer;
use function Code4rest\code4rest;

Theme_Customizer::add_settings(
	array(
		'header_button_tabs' => array(
			'control_type' => 'code4rest_tab_control',
			'section'      => 'header_button',
			'settings'     => false,
			'priority'     => 1,
			'input_attrs'  => array(
				'general' => array(
					'label'  => __( 'General', 'code4rest' ),
					'target' => 'header_button',
				),
				'design' => array(
					'label'  => __( 'Design', 'code4rest' ),
					'target' => 'header_button_design',
				),
				'active' => 'general',
			),
		),
		'header_button_tabs_design' => array(
			'control_type' => 'code4rest_tab_control',
			'section'      => 'header_button_design',
			'settings'     => false,
			'priority'     => 1,
			'input_attrs'  => array(
				'general' => array(
					'label'  => __( 'General', 'code4rest' ),
					'target' => 'header_button',
				),
				'design' => array(
					'label'  => __( 'Design', 'code4rest' ),
					'target' => 'header_button_design',
				),
				'active' => 'design',
			),
		),
		'header_button_label' => array(
			'control_type' => 'code4rest_text_control',
			'section'      => 'header_button',
			'sanitize'     => 'sanitize_text_field',
			'priority'     => 4,
			'label'        => esc_html__( 'Label', 'code4rest' ),
			'default'      => code4rest()->default( 'header_button_label' ),
			'live_method'     => array(
				array(
					'type'     => 'html',
					'selector' => '#main-header .header-button',
					'pattern'  => '$',
					'key'      => '',
				),
			),
		),
		'header_button_link' => array(
			'control_type' => 'code4rest_text_control',
			'section'      => 'header_button',
			'sanitize'     => 'esc_url_raw',
			'label'        => esc_html__( 'URL', 'code4rest' ),
			'priority'     => 4,
			'default'      => code4rest()->default( 'header_button_link' ),
			'partial'      => array(
				'selector'            => '.header-button-wrap',
				'container_inclusive' => true,
				'render_callback'     => 'Code4rest\header_button',
			),
		),
		'header_button_target' => array(
			'control_type' => 'code4rest_switch_control',
			'sanitize'     => 'code4rest_sanitize_toggle',
			'section'      => 'header_button',
			'priority'     => 6,
			'default'      => code4rest()->default( 'header_button_target' ),
			'label'        => esc_html__( 'Open in New Tab?', 'code4rest' ),
		),
		'header_button_nofollow' => array(
			'control_type' => 'code4rest_switch_control',
			'sanitize'     => 'code4rest_sanitize_toggle',
			'section'      => 'header_button',
			'priority'     => 6,
			'default'      => code4rest()->default( 'header_button_nofollow' ),
			'label'        => esc_html__( 'Set link to nofollow?', 'code4rest' ),
		),
		'header_button_sponsored' => array(
			'control_type' => 'code4rest_switch_control',
			'sanitize'     => 'code4rest_sanitize_toggle',
			'section'      => 'header_button',
			'priority'     => 6,
			'default'      => code4rest()->default( 'header_button_sponsored' ),
			'label'        => esc_html__( 'Set link attribute Sponsored?', 'code4rest' ),
		),
		'header_button_download' => array(
			'control_type' => 'code4rest_switch_control',
			'sanitize'     => 'code4rest_sanitize_toggle',
			'section'      => 'header_button',
			'priority'     => 6,
			'default'      => code4rest()->default( 'header_button_download' ),
			'label'        => esc_html__( 'Set link to Download?', 'code4rest' ),
		),
		'header_button_style' => array(
			'control_type' => 'code4rest_radio_icon_control',
			'section'      => 'header_button',
			'priority'     => 6,
			'default'      => code4rest()->default( 'header_button_style' ),
			'label'        => esc_html__( 'Button Style', 'code4rest' ),
			'live_method'     => array(
				array(
					'type'     => 'class',
					'selector' => '#main-header .header-button',
					'pattern'  => 'button-style-$',
					'key'      => '',
				),
			),
			'input_attrs'  => array(
				'layout' => array(
					'filled' => array(
						'name'    => __( 'Filled', 'code4rest' ),
					),
					'outline' => array(
						'name'    => __( 'Outline', 'code4rest' ),
						'icon'    => '',
					),
				),
				'responsive' => false,
			),
		),
		'header_button_visibility' => array(
			'control_type' => 'code4rest_radio_icon_control',
			'section'      => 'header_button',
			'priority'     => 6,
			'default'      => code4rest()->default( 'header_button_visibility' ),
			'label'        => esc_html__( 'Button Visibility', 'code4rest' ),
			'partial'      => array(
				'selector'            => '.header-button-wrap',
				'container_inclusive' => true,
				'render_callback'     => 'Code4rest\header_button',
			),
			'input_attrs'  => array(
				'layout' => array(
					'all' => array(
						'name'    => __( 'Everyone', 'code4rest' ),
					),
					'loggedout' => array(
						'name'    => __( 'Logged Out Only', 'code4rest' ),
					),
					'loggedin' => array(
						'name'    => __( 'Logged In Only', 'code4rest' ),
					),
				),
				'responsive' => false,
			),
		),
		'header_button_size' => array(
			'control_type' => 'code4rest_radio_icon_control',
			'section'      => 'header_button_design',
			'priority'     => 4,
			'default'      => code4rest()->default( 'header_button_size' ),
			'label'        => esc_html__( 'Button Size', 'code4rest' ),
			'live_method'     => array(
				array(
					'type'     => 'class',
					'selector' => '#main-header .header-button',
					'pattern'  => 'button-size-$',
					'key'      => '',
				),
			),
			'input_attrs'  => array(
				'layout' => array(
					'small' => array(
						'name'    => __( 'Sm', 'code4rest' ),
					),
					'medium' => array(
						'name'    => __( 'Md', 'code4rest' ),
						'icon'    => '',
					),
					'large' => array(
						'name'    => __( 'Lg', 'code4rest' ),
						'icon'    => '',
					),
					'custom' => array(
						'name'    => __( 'Custom', 'code4rest' ),
						'icon'    => '',
					),
				),
				'responsive' => false,
			),
		),
		'header_button_padding' => array(
			'control_type' => 'code4rest_measure_control',
			'section'      => 'header_button_design',
			'priority'     => 10,
			'default'      => code4rest()->default( 'header_button_padding' ),
			'label'        => esc_html__( 'Padding', 'code4rest' ),
			'live_method'     => array(
				array(
					'type'     => 'css',
					'selector' => '#main-header .button-size-custom.header-button',
					'property' => 'padding',
					'pattern'  => '$',
					'key'      => 'measure',
				),
			),
			'context'      => array(
				array(
					'setting'    => 'header_button_size',
					'operator'   => '=',
					'value'      => 'custom',
				),
			),
			'input_attrs'  => array(
				'responsive' => false,
			),
		),
		'header_button_color' => array(
			'control_type' => 'code4rest_color_control',
			'section'      => 'header_button_design',
			'label'        => esc_html__( 'Colors', 'code4rest' ),
			'default'      => code4rest()->default( 'header_button_color' ),
			'live_method'     => array(
				array(
					'type'     => 'css',
					'selector' => '#main-header .header-button',
					'property' => 'color',
					'pattern'  => '$',
					'key'      => 'color',
				),
				array(
					'type'     => 'css',
					'selector' => '#main-header .header-button:hover',
					'property' => 'color',
					'pattern'  => '$',
					'key'      => 'hover',
				),
			),
			'input_attrs'  => array(
				'colors' => array(
					'color' => array(
						'tooltip' => __( 'Initial Color', 'code4rest' ),
						'palette' => true,
					),
					'hover' => array(
						'tooltip' => __( 'Hover Color', 'code4rest' ),
						'palette' => true,
					),
				),
			),
		),
		'header_button_background' => array(
			'control_type' => 'code4rest_color_control',
			'section'      => 'header_button_design',
			'label'        => esc_html__( 'Background Colors', 'code4rest' ),
			'default'      => code4rest()->default( 'header_button_background' ),
			'live_method'     => array(
				array(
					'type'     => 'css',
					'selector' => '#main-header .header-button',
					'property' => 'background',
					'pattern'  => '$',
					'key'      => 'color',
				),
				array(
					'type'     => 'css',
					'selector' => '#main-header .header-button:hover',
					'property' => 'background',
					'pattern'  => '$',
					'key'      => 'hover',
				),
			),
			'context'      => array(
				array(
					'setting'    => 'header_button_style',
					'operator'   => '=',
					'value'      => 'filled',
				),
			),
			'input_attrs'  => array(
				'colors' => array(
					'color' => array(
						'tooltip' => __( 'Initial Color', 'code4rest' ),
						'palette' => true,
					),
					'hover' => array(
						'tooltip' => __( 'Hover Color', 'code4rest' ),
						'palette' => true,
					),
				),
			),
		),
		'header_button_border_colors' => array(
			'control_type' => 'code4rest_color_control',
			'section'      => 'header_button_design',
			'label'        => esc_html__( 'Border Colors', 'code4rest' ),
			'default'      => code4rest()->default( 'header_button_border' ),
			'live_method'     => array(
				array(
					'type'     => 'css',
					'selector' => '#main-header .header-button-wrap .header-button',
					'property' => 'border-color',
					'pattern'  => '$',
					'key'      => 'color',
				),
				array(
					'type'     => 'css',
					'selector' => '#main-header .header-button-wrap .header-button:hover',
					'property' => 'border-color',
					'pattern'  => '$',
					'key'      => 'hover',
				),
			),
			'input_attrs'  => array(
				'colors' => array(
					'color' => array(
						'tooltip' => __( 'Initial Color', 'code4rest' ),
						'palette' => true,
					),
					'hover' => array(
						'tooltip' => __( 'Hover Color', 'code4rest' ),
						'palette' => true,
					),
				),
			),
		),
		'header_button_border' => array(
			'control_type' => 'code4rest_border_control',
			'section'      => 'header_button_design',
			'label'        => esc_html__( 'Border', 'code4rest' ),
			'default'      => code4rest()->default( 'header_button_border' ),
			'live_method'     => array(
				array(
					'type'     => 'css_border',
					'selector' => '#main-header .header-button',
					'property' => 'border',
					'pattern'  => '$',
					'key'      => 'border',
				),
			),
			'input_attrs'  => array(
				'responsive' => false,
				'color'      => false,
			),
		),
		'header_button_radius' => array(
			'control_type' => 'code4rest_measure_control',
			'section'      => 'header_button_design',
			'priority'     => 10,
			'default'      => code4rest()->default( 'header_button_radius' ),
			'label'        => esc_html__( 'Border Radius', 'code4rest' ),
			'live_method'     => array(
				array(
					'type'     => 'css',
					'selector' => '#main-header .header-button',
					'property' => 'border-radius',
					'pattern'  => '$',
					'key'      => 'measure',
				),
			),
			'input_attrs'  => array(
				'responsive' => false,
			),
		),
		'header_button_typography' => array(
			'control_type' => 'code4rest_typography_control',
			'section'      => 'header_button_design',
			'label'        => esc_html__( 'Font', 'code4rest' ),
			'default'      => code4rest()->default( 'header_button_typography' ),
			'live_method'     => array(
				array(
					'type'     => 'css_typography',
					'selector' => '#main-header .header-button',
					'pattern'  => array(
						'desktop' => '$',
						'tablet'  => '$',
						'mobile'  => '$',
					),
					'property' => 'font',
					'key'      => 'typography',
				),
			),
			'input_attrs'  => array(
				'id' => 'header_button_typography',
				'options' => 'no-color',
			),
		),
		'header_button_shadow' => array(
			'control_type' => 'code4rest_shadow_control',
			'section'      => 'header_button_design',
			'label'        => esc_html__( 'Button Shadow', 'code4rest' ),
			'live_method'     => array(
				array(
					'type'     => 'css_boxshadow',
					'selector' => '#main-header .header-button',
					'property' => 'box-shadow',
					'pattern'  => '$',
					'key'      => '',
				),
			),
			'default'      => code4rest()->default( 'header_button_shadow' ),
		),
		'header_button_shadow_hover' => array(
			'control_type' => 'code4rest_shadow_control',
			'section'      => 'header_button_design',
			'label'        => esc_html__( 'Button Hover State Shadow', 'code4rest' ),
			'live_method'     => array(
				array(
					'type'     => 'css_boxshadow',
					'selector' => '#main-header .header-button',
					'property' => 'box-shadow',
					'pattern'  => '$',
					'key'      => '',
				),
			),
			'default'      => code4rest()->default( 'header_button_shadow_hover' ),
		),
		'header_button_margin' => array(
			'control_type' => 'code4rest_measure_control',
			'section'      => 'header_button_design',
			'priority'     => 10,
			'default'      => code4rest()->default( 'header_button_margin' ),
			'label'        => esc_html__( 'Margin', 'code4rest' ),
			'live_method'     => array(
				array(
					'type'     => 'css',
					'selector' => '#main-header .header-button',
					'property' => 'margin',
					'pattern'  => '$',
					'key'      => 'measure',
				),
			),
			'input_attrs'  => array(
				'responsive' => false,
			),
		),
	)
);
