<?php
defined( 'ABSPATH' ) || exit;

/**
 * Split Heading Shortcode.
 */
if ( ! class_exists( 'Vcex_Split_Heading_Shortcode' ) ) {

	class Vcex_Split_Heading_Shortcode extends \TotalThemeCore\Vcex\Shortcode_Abstract {

		/**
		 * Shortcode tag.
		 */
		public const TAG = 'vcex_split_heading';

		/**
		 * Main constructor.
		 */
		public function __construct() {

			// Call parent class constructor.
			parent::__construct();
		}

		/**
		 * Shortcode title.
		 */
		public static function get_title(): string {
			return esc_html__( 'Split Heading', 'total-theme-core' );
		}

		/**
		 * Shortcode description.
		 */
		public static function get_description(): string {
			return esc_html__( 'Create a heading composed of multiple styled text segments.', 'total-theme-core' );
		}

		/**
		 * Returns custom vc map settings.
		 */
		public static function get_params_list(): array {
			return [
				[
					'type' => 'vcex_select_buttons',
					'heading' => esc_html__( 'Orientation', 'total-theme-core' ),
					'param_name' => 'direction',
					'std' => 'horizontal',
					'choices' => [
						'horizontal' => esc_html__( 'Horizontal', 'total-theme-core' ),
						'vertical'   => esc_html__( 'Vertical', 'total-theme-core' ),
					],
					'editors' => [ 'wpbakery', 'elementor' ],
				],
				[
					'heading' => esc_html__( 'HTML Tag', 'total-theme-core' ),
					'admin_label' => true,
					'param_name' => 'tag',
					'description' => esc_html__( 'Used for SEO reasons only (not styling). You can select your heading font style under the "Typography" tab. The default tag for this element is a <div> but you can modify the default tag via the Customizer.', 'total-theme-core' ),
					'type' => 'vcex_select_buttons',
					'choices' => 'html_tag',
					'editors' => [ 'wpbakery', 'elementor' ],
				],
				[
					'type' => 'param_group',
					'heading' => esc_html__( 'Strings', 'total-theme-core' ),
					'param_name' => 'strings',
					'value' => '',
					'editors' => [ 'wpbakery', 'elementor' ],
					'params' => [
						[
							'type' => 'vcex_text',
							'heading' => esc_html__( 'Text', 'total-theme-core' ),
							'param_name' => 'text',
							'admin_label' => true,
							// Elementor requires a default
							'elementor' => [
								'default' => 'Lorem',
							],
							'editors' => [ 'wpbakery', 'elementor' ],
						],
						[
							'type' => 'vcex_font_family_select',
							'heading' => esc_html__( 'Font Family', 'total-theme-core' ),
							'param_name' => 'font_family',
							'css' => true,
							'group' => esc_html__( 'Typography', 'total-theme-core' ),
							'editors' => [ 'wpbakery', 'elementor' ],
						],
						[
							'type' => 'vcex_colorpicker',
							'heading' => esc_html__( 'Color', 'total-theme-core' ),
							'param_name' => 'color',
							'editors' => [ 'wpbakery', 'elementor' ],
						],
						[
							'type' => 'vcex_colorpicker',
							'allow_gradient' => true,
							'heading' => esc_html__( 'Background', 'total-theme-core' ),
							'param_name' => 'background',
							'editors' => [ 'wpbakery', 'elementor' ],
						],
						[
							'type' => 'vcex_select',
							'heading' => esc_html__( 'Font Weight', 'total-theme-core' ),
							'param_name' => 'font_weight',
							'choices' => 'font_weight',
							'editors' => [ 'wpbakery', 'elementor' ],
						],
						[
							'type' => 'vcex_select',
							'heading' => esc_html__( 'Font Style', 'total-theme-core' ),
							'param_name' => 'font_style',
							'choices' => 'font_style',
							'editors' => [ 'wpbakery', 'elementor' ],
						],
						[
							'type' => 'vcex_preset_textfield',
							'choices' => 'letter_spacing',
							'heading' => esc_html__( 'Letter Spacing', 'total-theme-core' ),
							'param_name' => 'letter_spacing',
							'editors' => [ 'wpbakery', 'elementor' ],
						],
						[
							'type' => 'vcex_text',
							'heading' => esc_html__( 'Opacity', 'total-theme-core' ),
							'param_name' => 'opacity',
							'description' => self::param_description( 'opacity' ),
							'editors' => [ 'wpbakery', 'elementor' ],
						],
						[
							'type' => 'vcex_text',
							'heading' => esc_html__( 'Rotation', 'total-theme-core' ),
							'param_name' => 'rotate',
							'description' => self::param_description( 'rotate' ),
							'editors' => [ 'wpbakery', 'elementor' ],
						],
						[
							'type' => 'vcex_text',
							'heading' => esc_html__( 'Padding', 'total-theme-core' ),
							'param_name' => 'padding',
							'description' => self::param_description( 'padding' ),
							'editors' => [ 'wpbakery', 'elementor' ],
						],
						[
							'type' => 'vcex_text',
							'heading' => esc_html__( 'Spacing After', 'total-theme-core' ),
							'param_name' => 'margin_end',
							'description' => self::param_description( 'margin' ),
							'editors' => [ 'wpbakery', 'elementor' ],
						],
						[
							'type' => 'vcex_select',
							'choices' => 'border_radius',
							'heading' => esc_html__( 'Border Radius', 'total-theme-core' ),
							'param_name' => 'border_radius',
							'editors' => [ 'wpbakery', 'elementor' ],
						],
						[
							'type' => 'vcex_text',
							'heading' => esc_html__( 'Extra class name', 'total-theme-core' ),
							'param_name' => 'el_class',
							'editors' => [ 'wpbakery', 'elementor' ],
						],
					],
					'elementor' => [
						'title_field' => '{{{ text }}}',
					],
				],
				[
					'type' => 'vcex_select',
					'heading' => esc_html__( 'Visibility', 'total-theme-core' ),
					'param_name' => 'visibility',
					'editors' => [ 'wpbakery', 'elementor' ],
				],
				[
					'type' => 'textfield',
					'heading' => esc_html__( 'Extra class name', 'total-theme-core' ),
					'param_name' => 'el_class',
					'description' => self::param_description( 'el_class' ),
					'editors' => [ 'wpbakery', 'elementor' ],
				],
				vcex_vc_map_add_css_animation(),
				[
					'type' => 'textfield',
					'heading' => esc_html__( 'Animation Duration', 'total-theme-core'),
					'param_name' => 'animation_duration',
					'css' => true,
					'description' => esc_html__( 'Enter your custom time in seconds (decimals allowed).', 'total-theme-core'),
				],
				[
					'type' => 'textfield',
					'heading' => esc_html__( 'Animation Delay', 'total-theme-core'),
					'param_name' => 'animation_delay',
					'css' => true,
					'description' => esc_html__( 'Enter your custom time in seconds (decimals allowed).', 'total-theme-core'),
				],
				// Style
				[
					'type' => 'vcex_select',
					'heading' => esc_html__( 'Bottom Margin', 'total-theme-core' ),
					'param_name' => 'bottom_margin',
					'admin_label' => true,
					'group' => esc_html__( 'Style', 'total-theme-core' ),
					'editors' => [ 'wpbakery', 'elementor' ],
				],
				[
					'type' => 'textfield',
					'heading' => esc_html__( 'Max Width', 'total-theme-core' ),
					'param_name' => 'max_width',
					'css' => true,
					'description' => self::param_description( 'width' ),
					'group' => esc_html__( 'Style', 'total-theme-core' ),
					'editors' => [ 'wpbakery', 'elementor' ],
				],
				[
					'type' => 'vcex_text_align',
					'heading' => esc_html__( 'Align', 'total-theme-core' ),
					'param_name' => 'align',
					'std' => 'center',
					'dependency' => array( 'element' => 'max_width', 'not_empty' => true ),
					'group' => esc_html__( 'Style', 'total-theme-core' ),
					'editors' => [ 'wpbakery', 'elementor' ],
				],
				// Typography
				[
					'type' => 'vcex_text_align',
					'heading' => esc_html__( 'Text Align', 'total-theme-core' ),
					'param_name' => 'text_align',
					'group' => esc_html__( 'Typography', 'total-theme-core' ),
					'editors' => [ 'wpbakery', 'elementor' ],
				],
				[
					'type' => 'vcex_colorpicker',
					'heading' => esc_html__( 'Color', 'total-theme-core' ),
					'param_name' => 'color',
					'css' => true,
					'group' => esc_html__( 'Typography', 'total-theme-core' ),
					'editors' => [ 'wpbakery', 'elementor' ],
				],
				[
					'type' => 'vcex_text_shadow',
					'heading' => esc_html__( 'Text Shadow', 'total-theme-core' ),
					'param_name' => 'text_shadow',
					'css' => true,
					'group' => esc_html__( 'Typography', 'total-theme-core' ),
				],
				[
					'type' => 'vcex_font_size',
					'heading' => esc_html__( 'Font Size', 'total-theme-core' ),
					'param_name' => 'font_size',
					'css' => true,
					'group' => esc_html__( 'Typography', 'total-theme-core' ),
				],
				[
					'type' => 'vcex_font_family_select',
					'heading' => esc_html__( 'Font Family', 'total-theme-core' ),
					'param_name' => 'font_family',
					'css' => true,
					'group' => esc_html__( 'Typography', 'total-theme-core' ),
					'editors' => [ 'wpbakery', 'elementor' ],
				],
				[
					'type' => 'vcex_select',
					'heading' => esc_html__( 'Font Weight', 'total-theme-core' ),
					'param_name' => 'font_weight',
					'css' => true,
					'group' => esc_html__( 'Typography', 'total-theme-core' ),
					'editors' => [ 'wpbakery', 'elementor' ],
				],
				[
					'type' => 'vcex_select',
					'heading' => esc_html__( 'Font Style', 'total-theme-core' ),
					'param_name' => 'font_style',
					'css' => true,
					'group' => esc_html__( 'Typography', 'total-theme-core' ),
					'editors' => [ 'wpbakery', 'elementor' ],
				],
				[
					'type' => 'vcex_preset_textfield',
					'heading' => esc_html__( 'Line Height', 'total-theme-core' ),
					'param_name' => 'line_height',
					'css' => true,
					'group' => esc_html__( 'Typography', 'total-theme-core' ),
					'editors' => [ 'wpbakery', 'elementor' ],
				],
				[
					'type' => 'vcex_preset_textfield',
					'heading' => esc_html__( 'Letter Spacing', 'total-theme-core' ),
					'param_name' => 'letter_spacing',
					'css' => true,
					'group' => esc_html__( 'Typography', 'total-theme-core' ),
					'editors' => [ 'wpbakery', 'elementor' ],
				],
			];
		}

	}

}

new Vcex_Split_Heading_Shortcode;

if ( class_exists( 'WPBakeryShortCode' ) && ! class_exists( 'WPBakeryShortCode_Split_Heading' ) ) {
	class WPBakeryShortCode_Split_Heading extends WPBakeryShortCode {}
}
