<?php
/**
 * Button Options.
 *
 * @package CosmosWP
 */

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

global $cosmoswp_customize_control;

/*Adding sections for default layout options panel*/
$wp_customize->add_section(
	$this->button_design,
	array(
		'title'    => esc_html__( 'Button Design', 'cosmoswp' ),
		'panel'    => $this->panel,
		'priority' => 20,
	)
);

/*Margin and Padding Msg*/
$wp_customize->add_setting(
	'site-button-padding-margin-msg',
	array(
		'sanitize_callback' => 'wp_kses_post',
	)
);
$cosmoswp_customize_control->add(
	new CosmosWP_Custom_Control_Heading(
		$wp_customize,
		'site-button-padding-margin-msg',
		array(
			'label'   => esc_html__( 'Margin and Padding', 'cosmoswp' ),
			'section' => $this->button_design,
		)
	)
);

/*Margin*/
$wp_customize->add_setting(
	'site-button-margin',
	array(
		'sanitize_callback' => 'cosmoswp_sanitize_field_default_css_box',
		'default'           => $theme_option_defaults['site-button-margin'],
	)
);
$cosmoswp_customize_control->add(
	new CosmosWP_Custom_Control_Cssbox(
		$wp_customize,
		'site-button-margin',
		array(
			'label'    => esc_html__( 'Margin (px)', 'cosmoswp' ),
			'section'  => $this->button_design,
			'settings' => 'site-button-margin',
		),
		array(),
		array()
	)
);

/*Padding*/
$wp_customize->add_setting(
	'site-button-padding',
	array(
		'sanitize_callback' => 'cosmoswp_sanitize_field_default_css_box',
		'default'           => $theme_option_defaults['site-button-padding'],
	)
);
$cosmoswp_customize_control->add(
	new CosmosWP_Custom_Control_Cssbox(
		$wp_customize,
		'site-button-padding',
		array(
			'label'    => esc_html__( 'Padding (px)', 'cosmoswp' ),
			'section'  => $this->button_design,
			'settings' => 'site-button-padding',
		),
		array(),
		array()
	)
);

/*Button  Styling Msg*/
$wp_customize->add_setting(
	'site-button-styling-styling-msg',
	array(
		'sanitize_callback' => 'wp_kses_post',
	)
);
$cosmoswp_customize_control->add(
	new CosmosWP_Custom_Control_Heading(
		$wp_customize,
		'site-button-styling-styling-msg',
		array(
			'label'   => esc_html__( 'Site Button Styling', 'cosmoswp' ),
			'section' => $this->button_design,
		)
	)
);

/*Button Styling in Tabs*/
$wp_customize->add_setting(
	'site-button-styling',
	array(
		'sanitize_callback' => 'cosmoswp_sanitize_field_tabs',
		'default'           => $theme_option_defaults['site-button-styling'],
	)
);
$border_style_choices = cosmoswp_header_border_style();
$cosmoswp_customize_control->add(
	new CosmosWP_Custom_Control_Tabs(
		$wp_customize,
		'site-button-styling',
		array(
			'label'    => esc_html__( 'Button Styling', 'cosmoswp' ),
			'section'  => $this->button_design,
			'settings' => 'site-button-styling',
		),
		array(
			'tabs'   => array(
				'site-button-normal' => array(
					'label' => esc_html__( 'Normal', 'cosmoswp' ),
				),
				'site-button-hover'  => array(
					'label' => esc_html__( 'Hover', 'cosmoswp' ),
				),
			),
			'fields' => array(
				'normal-text-color'       => array(
					'type'  => 'color',
					'label' => esc_html__( 'Text Color', 'cosmoswp' ),
					'tab'   => 'site-button-normal',
				),
				'normal-bg-color'         => array(
					'type'  => 'color',
					'label' => esc_html__( 'Background Color', 'cosmoswp' ),
					'tab'   => 'site-button-normal',
				),
				'normal-border-style'     => array(
					'type'    => 'select',
					'label'   => esc_html__( 'Border Style', 'cosmoswp' ),
					'options' => $border_style_choices,
					'tab'     => 'site-button-normal',
				),
				'normal-border-color'     => array(
					'type'  => 'color',
					'label' => esc_html__( 'Border Color', 'cosmoswp' ),
					'tab'   => 'site-button-normal',
				),
				'normal-border-width'     => array(
					'type'  => 'cssbox',
					'label' => esc_html__( 'Border Width (px)', 'cosmoswp' ),
					'class' => 'cwp-element-show',
					'tab'   => 'site-button-normal',
					'attr'  => array(
						'min'       => 0,
						'max'       => 1000,
						'step'      => 1,
						'link'      => 1,
						'devices'   => array(
							'desktop' => array(
								'icon' => 'dashicons-laptop',
							),
						),
						'link_text' => esc_html__( 'Link', 'cosmoswp' ),
					),
				),
				'normal-border-radius'    => array(
					'type'  => 'cssbox',
					'label' => esc_html__( 'Border Radius (px)', 'cosmoswp' ),
					'class' => 'cwp-element-show',
					'tab'   => 'site-button-normal',
					'attr'  => array(
						'min'       => 0,
						'max'       => 1000,
						'step'      => 1,
						'link'      => 1,
						'devices'   => array(
							'desktop' => array(
								'icon' => 'dashicons-laptop',
							),
						),
						'link_text' => esc_html__( 'Link', 'cosmoswp' ),
					),
				),
				'normal-box-shadow-color' => array(
					'type'  => 'color',
					'label' => esc_html__( 'Box Shadow Color', 'cosmoswp' ),
					'tab'   => 'site-button-normal',
				),
				'normal-box-shadow-css'   => array(
					'type'       => 'cssbox',
					'label'      => esc_html__( 'Box Shadow', 'cosmoswp' ),
					'tab'        => 'site-button-normal',
					'class'      => 'cwp-element-show',
					'box_fields' => array(
						'x'      => true,
						'Y'      => true,
						'BLUR'   => true,
						'SPREAD' => true,
					),
					'attr'       => array(
						'min'         => 0,
						'max'         => 1000,
						'step'        => 1,
						'link'        => 1,
						'link_toggle' => false,
						'devices'     => array(
							'desktop' => array(
								'icon' => 'dashicons-laptop',
							),
						),
						'link_text'   => esc_html__( 'INSET', 'cosmoswp' ),
					),
				),
				'hover-text-color'        => array(
					'type'  => 'color',
					'label' => esc_html__( ' Text Color', 'cosmoswp' ),
					'tab'   => 'site-button-hover',
				),
				'hover-bg-color'          => array(
					'type'  => 'color',
					'label' => esc_html__( 'Background Color', 'cosmoswp' ),
					'tab'   => 'site-button-hover',
				),
				'hover-border-style'      => array(
					'type'    => 'select',
					'label'   => esc_html__( 'Border Style', 'cosmoswp' ),
					'options' => $border_style_choices,
					'tab'     => 'site-button-hover',
				),
				'hover-border-color'      => array(
					'type'  => 'color',
					'label' => esc_html__( 'Border Color', 'cosmoswp' ),
					'tab'   => 'site-button-hover',
				),
				'hover-border-width'      => array(
					'type'  => 'cssbox',
					'label' => esc_html__( 'Border Width (px)', 'cosmoswp' ),
					'class' => 'cwp-element-show',
					'tab'   => 'site-button-hover',
					'attr'  => array(
						'min'       => 0,
						'max'       => 1000,
						'step'      => 1,
						'link'      => 1,
						'devices'   => array(
							'desktop' => array(
								'icon' => 'dashicons-laptop',
							),
						),
						'link_text' => esc_html__( 'Link', 'cosmoswp' ),
					),
				),
				'hover-border-radius'     => array(
					'type'  => 'cssbox',
					'label' => esc_html__( 'Border Radius (px)', 'cosmoswp' ),
					'class' => 'cwp-element-show',
					'tab'   => 'site-button-hover',
					'attr'  => array(
						'min'       => 0,
						'max'       => 1000,
						'step'      => 1,
						'link'      => 1,
						'devices'   => array(
							'desktop' => array(
								'icon' => 'dashicons-laptop',
							),
						),
						'link_text' => esc_html__( 'Link', 'cosmoswp' ),
					),
				),
				'hover-box-shadow-color'  => array(
					'type'  => 'color',
					'label' => esc_html__( 'Box Shadow Color', 'cosmoswp' ),
					'tab'   => 'site-button-hover',
				),
				'hover-box-shadow-css'    => array(
					'type'       => 'cssbox',
					'label'      => esc_html__( 'Box Shadow', 'cosmoswp' ),
					'tab'        => 'site-button-hover',
					'class'      => 'cwp-element-show',
					'box_fields' => array(
						'x'      => true,
						'Y'      => true,
						'BLUR'   => true,
						'SPREAD' => true,
					),
					'attr'       => array(
						'min'         => -1000,
						'max'         => 1000,
						'step'        => 1,
						'link'        => 1,
						'link_toggle' => false,
						'devices'     => array(
							'desktop' => array(
								'icon' => 'dashicons-laptop',
							),
						),
						'link_text'   => esc_html__( 'INSET', 'cosmoswp' ),
					),
				),
			),
		)
	)
);

/*Typography Options*/
$wp_customize->add_setting(
	'site-button-typography-options',
	array(
		'default'           => $theme_option_defaults['site-button-typography-options'],
		'sanitize_callback' => 'cosmoswp_sanitize_select',
	)
);
$choices = cosmoswp_inherit_options();
$cosmoswp_customize_control->add(
	'site-button-typography-options',
	array(
		'label'    => esc_html__( 'Typography Options', 'cosmoswp' ),
		'type'     => 'select',
		'section'  => $this->button_design,
		'settings' => 'site-button-typography-options',
		'choices'  => $choices,
	)
);

/*Typography data*/
$wp_customize->add_setting(
	'site-button-typography',
	array(
		'sanitize_callback' => 'cosmoswp_sanitize_field_typography',
		'default'           => $theme_option_defaults['site-button-typography'],
	)
);

$cosmoswp_customize_control->add(
	new CosmosWP_Custom_Control_Group(
		$wp_customize,
		'site-button-typography',
		array(
			'label'           => esc_html__( 'Typography', 'cosmoswp' ),
			'section'         => $this->button_design,
			'active_callback' => 'cosmoswp_site_button_typography_if_custom',
			'settings'        => 'site-button-typography',
		),
		cosmoswp_typography_group_fields()
	)
);
