<?php

class AIOC_TestimonialCarouselItem extends ET_Builder_Module {

	public $slug       = 'aioc_testimonial_carousel_item';
	public $type       = 'child';
	public $vb_support = 'on';

	protected $module_credits = array(
		'module_uri' => 'https://diviextended.com/product/all-in-one-carousel-for-divi',
		'author'     => 'Elicus',
		'author_uri' => 'http://elicus.com',
	);
	
	public function init() {
		$this->name 						= esc_html__( 'Testimonial Item', 'all-in-one-carousel-for-divi' );
		$this->advanced_setting_title_text  = esc_html__( 'Testimonial Item', 'all-in-one-carousel-for-divi' );
        $this->child_title_var              = 'name';
		$this->main_css_element 			= '.aioc_testimonial_carousel %%order_class%%';
		if ( is_archive() ) {
            $this->main_css_element = '%%order_class%%';
        }
		add_filter( 'et_builder_processed_range_value', array( $this, 'aioc_builder_processed_range_value' ), 10, 3 );
	}


	public function get_settings_modal_toggles() {
		return array(
			'general'  => array(
				'toggles' => array(
					'main_content' => array(
						'title' => esc_html__( 'Content', 'all-in-one-carousel-for-divi' ),
					),
					'image' => array(
						'title' => esc_html__( 'Image', 'all-in-one-carousel-for-divi' ),
					),
				),
			),
			'advanced' => array(
				'toggles' => array(
					'text' => array(
						'title' => esc_html__( 'Text', 'all-in-one-carousel-for-divi' ),
					),
					'text_settings' => array(
						'title' => esc_html__( 'Content', 'all-in-one-carousel-for-divi' ),
						'sub_toggles'   => array(
                            'name' => array(
                                'name' => 'Name',
                            ),
                            'designation' => array(
                                'name' => 'Designation',
                            ),
                            'company' => array(
                                'name' => 'Company',
                            ),
                            'content' => array(
                                'name' => 'Content',
                            ),
                        ),
                        'tabbed_subtoggles' => true,
					),
					'image' => array(
						'title' => esc_html__( 'Image', 'all-in-one-carousel-for-divi' ),
					),
					'content_bg_settings' => array(
						'title' => esc_html__( 'Content Background', 'all-in-one-carousel-for-divi' ),
					),
					'meta_settings' => array(
						'title' => esc_html__( 'Meta', 'all-in-one-carousel-for-divi' ),
					),
					'rating'      => array(
						'title'    => esc_html__( 'Star Rating', 'all-in-one-carousel-for-divi' ),
					),
					'quote_icon'  => array(
						'title'             => esc_html__( 'Quote Icon', 'all-in-one-carousel-for-divi' ),
						'tabbed_subtoggles' => true,
						'sub_toggles'       => array(
							'quote_icon_opening' => array(
								'name' => 'Opening Quote Icon',
							),
							'quote_icon_closing' => array(
								'name' => 'Closing Quote Icon',
							),
						),
					),
				),
			),
		);
	}

	public function get_advanced_fields_config() {
		return array(
			'fonts' => array(
				'name' => array(
					'label'          => esc_html__( 'Name', 'all-in-one-carousel-for-divi' ),
					'font_size'      => array(
						'default' => '16px',
						'range_settings'   => array(
							'min'  => '1',
							'max'  => '100',
							'step' => '1',
						),
						'validate_unit'    => true,
					),
					'line_height'    => array(
						'default_on_front' => '1.2em',
						'range_settings'   => array(
							'min'  => '0.1',
							'max'  => '10',
							'step' => '0.1',
						),
					),
					'letter_spacing' => array(
						'default_on_front' => '',
						'range_settings'   => array(
							'min'  => '0',
							'max'  => '10',
							'step' => '1',
						),
						'validate_unit'    => true,
					),
					'css'            => array(
						'main' => "{$this->main_css_element} .aioc_slide_name",
						'important' => 'all',
					),
					'hide_text_align' => true,
					'tab_slug' => 'advanced',
					'toggle_slug' => 'text_settings',
					'sub_toggle' => 'name',
				),
				'designation' => array(
					'label'          => esc_html__( 'Designation', 'all-in-one-carousel-for-divi' ),
					'font_size'      => array(
						'default' => '16px',
						'range_settings'   => array(
							'min'  => '1',
							'max'  => '100',
							'step' => '1',
						),
						'validate_unit'    => true,
					),
					'line_height'    => array(
						'default_on_front' => '1.2em',
						'range_settings'   => array(
							'min'  => '0.1',
							'max'  => '10',
							'step' => '0.1',
						),
					),
					'letter_spacing' => array(
						'default_on_front' => '',
						'range_settings'   => array(
							'min'  => '0',
							'max'  => '10',
							'step' => '1',
						),
						'validate_unit'    => true,
					),
					'css'            => array(
						'main' => "{$this->main_css_element} .aioc_slide_designation",
						'important' => 'all',
					),
					'tab_slug' => 'advanced',
					'toggle_slug' => 'text_settings',
					'sub_toggle' => 'designation',
				),
				'company' => array(
					'label'           => esc_html__( 'Company', 'all-in-one-carousel-for-divi' ),
					'font_size'       => array(
						'default'        => '14px',
						'range_settings' => array(
							'min'  => '8',
							'max'  => '100',
							'step' => '1',
						),
					),
					'line_height'     => array(
						'default'        => '1.7',
						'range_settings' => array(
							'min'  => '0.1',
							'max'  => '10',
							'step' => '0.1',
						),
					),
					'letter_spacing'  => array(
						'default'        => '0',
						'range_settings' => array(
							'min'  => '0.1',
							'max'  => '10',
							'step' => '0.1',
						),
					),
					'hide_text_align' => true,
					'css'             => array(
						'main'        => '.aioc_testimonial_carousel %%order_class%% .aioc_slide_company, .aioc_testimonial_carousel %%order_class%% .aioc_slide_company a',
						'important'   => 'all',
					),
					'tab_slug' => 'advanced',
					'toggle_slug' => 'text_settings',
					'sub_toggle' => 'company',
				),
				'content' => array(
					'label'          => esc_html__( 'Content', 'all-in-one-carousel-for-divi' ),
					'font_size'      => array(
						'default' => '14px',
						'range_settings'   => array(
							'min'  => '1',
							'max'  => '100',
							'step' => '1',
						),
						'validate_unit'    => true,
					),
					'line_height'    => array(
						'default' => '1.5em',
						'range_settings'   => array(
							'min'  => '0.1',
							'max'  => '10',
							'step' => '0.1',
						),
					),
					'letter_spacing' => array(
						'default' => '',
						'range_settings'   => array(
							'min'  => '0',
							'max'  => '10',
							'step' => '1',
						),
						'validate_unit'    => true,
					),
					'css'            => array(
						'main' => "{$this->main_css_element} .aioc_slide_content",
						'important' => 'all',
					),
					'hide_text_align' => true,
					'tab_slug' => 'advanced',
					'toggle_slug' => 'text_settings',
					'sub_toggle' => 'content',
				),
			),
			'margin_padding' => array(
				'css' => array(
					'main'      => '%%order_class%% .aioc_slide_wrapper',
					'important' => 'all',
				),
			),
			'max_width'            => array(
				'default' => array(
					'css' => array(
						'main'             => '%%order_class%%',
						'module_alignment' => '%%order_class%%',
					),
				),
			),
			'borders' => array(
				'image'  => array(
					'css'          => array(
						'main' => array(
							'border_radii'  => '.aioc_testimonial_carousel %%order_class%% .aioc_slide_image',
							'border_styles' => '.aioc_testimonial_carousel %%order_class%% .aioc_slide_image',
							'important'     => 'all',
						),
					),
					'label_prefix' => esc_html__( 'Image', 'all-in-one-carousel-for-divi' ),
					'tab_slug'     => 'advanced',
					'toggle_slug'  => 'image',
				),
				'default' => array(
					'css' => array(
						'main' => array(
							'border_styles' => '%%order_class%% .aioc_slide_wrapper',
							'border_radii'  => '%%order_class%% .aioc_slide_wrapper',
						),
						'important' => 'all',
					),
				),
			),
			'box_shadow' => array(
				'default' => array(
					'css' => array(
						'main' => '%%order_class%% .aioc_slide_wrapper',
					),
				),
			),
			'background' => array(
				'css' => array(
					'main' => '%%order_class%% .aioc_slide_wrapper',
				),
			),
			'text'    => false,
			'filters' => false,
			'text_shadow' => false,
		);
	}

	public function get_fields() {
		return array(
			'name' => array(
				'label'           		=> esc_html__( 'Name', 'all-in-one-carousel-for-divi' ),
				'type'           		=> 'text',
				'option_category' 		=> 'basic_option',
				'tab_slug'        		=> 'general',
				'toggle_slug'     		=> 'main_content',
				'description'     		=> esc_html__( 'Here you can input the text to be used for the title.', 'all-in-one-carousel-for-divi' ),
			),
			'designation' => array(
				'label'           		=> esc_html__( 'Designation', 'all-in-one-carousel-for-divi' ),
				'type'           		=> 'text',
				'option_category' 		=> 'basic_option',
				'tab_slug'        		=> 'general',
				'toggle_slug'     		=> 'main_content',
				'description'     		=> esc_html__( 'Here you can input the text to be used for the designation.', 'all-in-one-carousel-for-divi' ),
			),
			'company' => array(
				'label'           		=> esc_html__( 'Company', 'all-in-one-carousel-for-divi' ),
				'type'           		=> 'text',
				'option_category' 		=> 'basic_option',
				'tab_slug'        		=> 'general',
				'toggle_slug'     		=> 'main_content',
				'description'     		=> esc_html__( 'Here you can input the text to be used for the company.', 'all-in-one-carousel-for-divi' ),
			),
			'company_url' => array(
				'label'           	=> esc_html__( 'Company URL', 'all-in-one-carousel-for-divi' ),
				'type'            	=> 'text',
				'option_category' 	=> 'basic_option',
				'dynamic_content' 	=> 'url',
				'tab_slug'        		=> 'general',
				'toggle_slug'     		=> 'main_content',
				'description'     	=> esc_html__( 'Here you can input youtube URL.', 'all-in-one-carousel-for-divi' ),
			),
			'content' => array(
				'label'                 => esc_html__( 'Content', 'all-in-one-carousel-for-divi' ),
				'type'                  => 'tiny_mce',
				'option_category'       => 'basic_option',
				'toggle_slug'           => 'main_content',
				'description'           => esc_html__( 'Here you can input the text to be used for the content.', 'all-in-one-carousel-for-divi' ),
			),
			'content_length'       => array(
				'label'            => esc_html__( 'Content Length', 'all-in-one-carousel-for-divi' ),
				'type'             => 'text',
				'option_category'  => 'configuration',
				'default'		  => '250',
				'tab_slug'         => 'general',
				'toggle_slug'      => 'main_content',
				'description'      => esc_html__( 'Here you can define content length in characters, if 0 no content will be shown.', 'all-in-one-carousel-for-divi' ),
			),
			'rating' => array(
				'label'           	=> esc_html__( 'Rating', 'all-in-one-carousel-for-divi' ),
				'type'            	=> 'range',
				'option_category'	=> 'basic_option',
				'range_settings'  => array(
					'min'  => '0.5',
					'max'  => '5',
					'step' => '0.5',
				),
				'unitless'		  	=> true,
				'default'         	=> '5',
				'default_on_front'  => '5',
				'max_limit' => 5,
				'sticky'          => true,
				'tab_slug'        	=> 'general',
				'toggle_slug'     	=> 'main_content',
				'description'     	=> esc_html__( 'Here you can choose the rating for the testimonial.', 'all-in-one-carousel-for-divi' ),
			),
			'image' => array(
				'label'                 => esc_html__( 'Image', 'all-in-one-carousel-for-divi' ),
				'type'                  => 'upload',
				'option_category'       => 'basic_option',
				'upload_button_text'    => esc_attr__( 'Upload an image', 'all-in-one-carousel-for-divi' ),
				'choose_text'           => esc_attr__( 'Choose an Image', 'all-in-one-carousel-for-divi' ),
				'update_text'           => esc_attr__( 'Set As Image', 'all-in-one-carousel-for-divi' ),
				'dynamic_content'  		=> 'image',
				'tab_slug'              => 'general',
				'toggle_slug'           => 'image',
				'description'           => esc_html__( 'Upload an image to display.', 'all-in-one-carousel-for-divi' ),
			),
			'image_alt' => array(
				'label'                 => esc_html__( 'Image Alt Text', 'all-in-one-carousel-for-divi' ),
				'type'                  => 'text',
				'option_category'       => 'basic_option',
				'tab_slug'              => 'general',
				'toggle_slug'           => 'image',
				'description'           => esc_html__( 'Here you can input the text to be used for the image as HTML ALT text.', 'all-in-one-carousel-for-divi' ),
			),
			'show_opening_font_icon' => array(
				'label'           => esc_html__( 'Show Opening Quote Icon', 'all-in-one-carousel-for-divi' ),
				'type'            => 'yes_no_button',
				'option_category' => 'configuration',
				'options'         => array(
					'on'  => esc_html__( 'Yes', 'all-in-one-carousel-for-divi' ),
					'off' => esc_html__( 'No', 'all-in-one-carousel-for-divi' ),
				),
				'default'         => 'on',
				'tab_slug'        => 'advanced',
				'toggle_slug'     => 'quote_icon',
				'sub_toggle'      => 'quote_icon_opening',
				'description'     => esc_html__( 'Choose whether or not the opening quote icon should be visible.', 'all-in-one-carousel-for-divi' ),
			),
			'opening_font_icon' => array(
				'label'                 => esc_html__( 'Icon', 'all-in-one-carousel-for-divi' ),
				'type'                  => 'select_icon',
				'option_category'       => 'basic_option',
				'class'                 => array(
					'et-pb-font-icon'
				),
				'tab_slug'        => 'advanced',
				'toggle_slug'     => 'quote_icon',
				'sub_toggle'      => 'quote_icon_opening',
				'description'     => esc_html__( 'Choose an opening quote icon to display.', 'all-in-one-carousel-for-divi' ),
			),				
			'opening_font_icon_size' => array(
				'label'           => esc_html__( 'Quote Icon Size', 'all-in-one-carousel-for-divi' ),
				'type'            => 'range',
				'option_category' => 'font_option',
				'range_settings'  => array(
					'min'  => '1',
					'max'  => '350',
					'step' => '1',
				),
				'mobile_options'  => true,
				'show_if'         => array(
					'show_opening_font_icon' => 'on',
				),
				'default'         => '46px',
				'tab_slug'        => 'advanced',
				'toggle_slug'     => 'quote_icon',
				'sub_toggle'      => 'quote_icon_opening',
				'description'     => esc_html__( 'Here you can choose size of the quote icon.', 'all-in-one-carousel-for-divi' ),
			),
			'opening_font_icon_color' => array(
				'label'        => esc_html__( 'Quote Icon Color', 'all-in-one-carousel-for-divi' ),
				'type'         => 'color-alpha',
				'custom_color' => true,
				'show_if'      => array(
					'show_opening_font_icon' => 'on',
				),
				'tab_slug'     => 'advanced',
				'toggle_slug'  => 'quote_icon',
				'sub_toggle'   => 'quote_icon_opening',
				'description'  => esc_html__( 'Here you can define color for the quote icon', 'all-in-one-carousel-for-divi' ),
			),
			'custom_position_opening_font_icon' => array(
				'label'           => esc_html__( 'Enable Custom Position For Quote Icon', 'all-in-one-carousel-for-divi' ),
				'type'            => 'yes_no_button',
				'option_category' => 'configuration',
				'options'         => array(
					'on'  => esc_html__( 'Yes', 'all-in-one-carousel-for-divi' ),
					'off' => esc_html__( 'No', 'all-in-one-carousel-for-divi' ),
				),
				'show_if'         => array(
					'show_opening_font_icon' => 'on',
				),
				'default'         => 'off',
				'tab_slug'        => 'advanced',
				'toggle_slug'     => 'quote_icon',
				'sub_toggle'      => 'quote_icon_opening',
				'description'     => esc_html__( 'Choose whether to use the custom position of quote icon.', 'all-in-one-carousel-for-divi' ),
			),
			'opening_font_icon_position_top' => array(
				'label'           => esc_html__( 'Quote Icon Position From Top', 'all-in-one-carousel-for-divi' ),
				'type'            => 'range',
				'option_category' => 'font_option',
				'range_settings'  => array(
					'min'  => '0',
					'max'  => '100',
					'step' => '1',
				),
				'allowed_units'   => array( '%', 'px', ),
				'mobile_options'  => true,
				'show_if'         => array(
					'show_opening_font_icon'            => 'on',
					'custom_position_opening_font_icon' => 'on',
				),
				'default'         => '0%',
				'default_unit'    => '%',
				'tab_slug'        => 'advanced',
				'toggle_slug'     => 'quote_icon',
				'sub_toggle'      => 'quote_icon_opening',
				'description'     => esc_html__( 'Here you can choose the quote icon position from top.', 'all-in-one-carousel-for-divi' ),
			),
			'opening_font_icon_position' => array(
				'label'           => esc_html__( 'Quote Icon Position', 'all-in-one-carousel-for-divi' ),
				'type'            => 'select',
				'option_category' => 'layout',
				'options'         => array(
					'left'   => esc_html__( 'Left', 'all-in-one-carousel-for-divi' ),
					'center' => esc_html__( 'Center', 'all-in-one-carousel-for-divi' ),
					'right'  => esc_html__( 'Right', 'all-in-one-carousel-for-divi' ),
				),
				'show_if'         => array(
					'show_opening_font_icon'            => 'on',
					'custom_position_opening_font_icon' => 'on',
				),
				'default'         => 'left',
				'tab_slug'        => 'advanced',
				'toggle_slug'     => 'quote_icon',
				'description'     => esc_html__( 'opening quote icon position', 'all-in-one-carousel-for-divi' ),
				'sub_toggle'      => 'quote_icon_opening',
			),
			'show_closing_font_icon' => array(
				'label'           => esc_html__( 'Show Closing Quote Icon', 'all-in-one-carousel-for-divi' ),
				'type'            => 'yes_no_button',
				'option_category' => 'configuration',
				'options'         => array(
					'on'  => esc_html__( 'Yes', 'all-in-one-carousel-for-divi' ),
					'off' => esc_html__( 'No', 'all-in-one-carousel-for-divi' ),
				),
				'default'         => 'off',
				'tab_slug'        => 'advanced',
				'toggle_slug'     => 'quote_icon',
				'sub_toggle'      => 'quote_icon_closing',
				'description'     => esc_html__( 'Choose whether or not the quote icon should be visible.', 'all-in-one-carousel-for-divi' ),
			),		
			'closing_font_icon' => array(
				'label'                 => esc_html__( 'Icon', 'all-in-one-carousel-for-divi' ),
				'type'                  => 'select_icon',
				'option_category'       => 'basic_option',
				'class'                 => array(
					'et-pb-font-icon'
				),
				'show_if'         => array(
					'show_closing_font_icon' => 'on',
				),
				'tab_slug'        => 'advanced',
				'toggle_slug'     => 'quote_icon',
				'sub_toggle'      => 'quote_icon_closing',
				'description'           => esc_html__( 'Choose an closing quote icon to display.', 'all-in-one-carousel-for-divi' ),
			),
			'closing_font_icon_size' => array(
				'label'           => esc_html__( 'Quote Icon Size', 'all-in-one-carousel-for-divi' ),
				'type'            => 'range',
				'option_category' => 'font_option',
				'range_settings'  => array(
					'min'  => '1',
					'max'  => '350',
					'step' => '1',
				),
				'mobile_options'  => true,
				'show_if'         => array(
					'show_closing_font_icon' => 'on',
				),
				'default'         => '46px',
				'tab_slug'        => 'advanced',
				'toggle_slug'     => 'quote_icon',
				'sub_toggle'      => 'quote_icon_closing',
				'description'     => esc_html__( 'Here you can choose size of the quote icon.', 'all-in-one-carousel-for-divi' ),
			),
			'closing_font_icon_color' => array(
				'label'        => esc_html__( 'Quote Icon Color', 'all-in-one-carousel-for-divi' ),
				'type'         => 'color-alpha',
				'custom_color' => true,
				'show_if'      => array(
					'show_closing_font_icon' => 'on',
				),
				'default'      => '',
				'tab_slug'     => 'advanced',
				'toggle_slug'  => 'quote_icon',
				'sub_toggle'   => 'quote_icon_closing',
				'description'  => esc_html__( 'Here you can define color for the quote icon', 'all-in-one-carousel-for-divi' ),
			),
			'custom_position_closing_font_icon' => array(
				'label'           => esc_html__( 'Enable Custom Position For Quote Icon', 'all-in-one-carousel-for-divi' ),
				'type'            => 'yes_no_button',
				'option_category' => 'configuration',
				'options'         => array(
					'on'  => esc_html__( 'Yes', 'all-in-one-carousel-for-divi' ),
					'off' => esc_html__( 'No', 'all-in-one-carousel-for-divi' ),
				),
				'show_if'         => array(
					'show_closing_font_icon' => 'on',
				),
				'default'         => 'off',
				'tab_slug'        => 'advanced',
				'toggle_slug'     => 'quote_icon',
				'sub_toggle'      => 'quote_icon_closing',
				'description'     => esc_html__( 'Choose whether or not the quote icon should be visible.', 'all-in-one-carousel-for-divi' ),
			),
			'closing_font_icon_position_bottom' => array(
				'label'           => esc_html__( 'Quote Icon Position From Bottom', 'all-in-one-carousel-for-divi' ),
				'type'            => 'range',
				'option_category' => 'font_option',
				'range_settings'  => array(
					'min'  => '0',
					'max'  => '100',
					'step' => '1',
				),
				'allowed_units'   => array( '%', 'px', ),
				'mobile_options'  => true,
				'show_if'         => array(
					'show_closing_font_icon'            => 'on',
					'custom_position_closing_font_icon' => 'on',
				),
				'default'         => '0%',
				'default_unit'    => '%',
				'tab_slug'        => 'advanced',
				'toggle_slug'     => 'quote_icon',
				'sub_toggle'      => 'quote_icon_closing',
				'description'     => esc_html__( 'Here you can choose the quote icon size from top.', 'all-in-one-carousel-for-divi' ),
			),
			'closing_font_icon_position' => array(
				'label'           => esc_html__( 'Quote Icon Position', 'all-in-one-carousel-for-divi' ),
				'type'            => 'select',
				'option_category' => 'layout',
				'options'         => array(
					'left'   => esc_html__( 'Left', 'all-in-one-carousel-for-divi' ),
					'center' => esc_html__( 'Center', 'all-in-one-carousel-for-divi' ),
					'right'  => esc_html__( 'Right', 'all-in-one-carousel-for-divi' ),
				),
				'show_if'         => array(
					'show_closing_font_icon'            => 'on',
					'custom_position_closing_font_icon' => 'on',
				),
				'default'         => 'right',
				'tab_slug'        => 'advanced',
				'toggle_slug'     => 'quote_icon',
				'sub_toggle'      => 'quote_icon_closing',
				'description'     => esc_html__( 'cloing quote icon position', 'all-in-one-carousel-for-divi' ),
			),
		);
	}

	public function render( $attrs, $content, $render_slug ) {
		global $slide_effect;

		$multi_view            					= et_pb_multi_view_options( $this );
		$name						    		= $this->props['name'];
		$designation							= $this->props['designation'];
		$company   								= $this->props['company'];
		$company_url    						= $this->props['company_url'];
		$rating   								= $this->props['rating'];
		$image_alt 								= sprintf( esc_html__( '%s', 'all-in-one-carousel-for-divi' ), $this->props['image_alt'] );
		$show_opening_font_icon 				= $this->props['show_opening_font_icon'];
		$show_closing_font_icon 				= $this->props['show_closing_font_icon'];
		$opening_font_icon 						= $this->props['opening_font_icon'];
		$closing_font_icon 						= $this->props['closing_font_icon'];
		$custom_position_opening_font_icon 		= $this->props['custom_position_opening_font_icon'];
		$opening_font_icon_position 			= $this->props['opening_font_icon_position'];
		$custom_position_closing_font_icon 		= $this->props['custom_position_closing_font_icon'];
		$closing_font_icon_position 			= $this->props['closing_font_icon_position'];
		$content_length							= '' !== intval( $this->props['content_length'] ) ? intval( $this->props['content_length'] ) : 250;
		$slide_border_radius  					= '' !== $this->props['border_radii'] ? explode( '|', $this->props['border_radii'] ) : '';
		$company_html = '';

		$opening_icon_classes	= implode(
			' ',
			array(
				'aioc_testimonial_quote_icon',
				'aioc_testimonial_opening_quote_icon',
				'et-pb-icon',
			)
		);

		$closing_icon_classes	= implode(
			' ',
			array(
				'aioc_testimonial_quote_icon',
				'aioc_testimonial_closing_quote_icon',
				'et-pb-icon',
			)
		);

		$image = $multi_view->render_element(
			array(
				'tag'      => 'img',
				'attrs'    => array(
					'src'   => '{{image}}',
					'data-mfp-src'  => '{{image}}',
					'class' => 'aioc_slide_image',
					'alt'   => $image_alt,
				),
				'required' => 'image',
			)
		);

		$name = $multi_view->render_element(
			array(
				'tag'      => 'div',
				'content'  => '{{name}}',
				'attrs'    => array(
					'class' => 'aioc_slide_name',
				),
				'required' => 'name',
			)
		);

		$designation = $multi_view->render_element(
			array(
				'tag'      => 'div',
				'content'  => '{{designation}}',
				'attrs'    => array(
					'class' => 'aioc_slide_designation',
				),
				'required' => 'designation',
			)
		);

		if ( '' !== $company_url && '' !== $company ) {
			$company_html = sprintf(
				'<div class="aioc_slide_company">
					<a href="%1$s" target="_blank" rel="nofollow">%2$s</a>
				</div>',
				esc_url( $company_url ),
				esc_html( $company )
			);
		} elseif ( '' !== $company ) {
			$company_html = sprintf(
				'<div class="aioc_slide_company">
					%1$s
				</div>',
				esc_html( $company )
			);
		}

		if ( '' !== $image ) {
			$image = sprintf(
				'<div class="aioc_slide_image_wrapper">%1$s</div>',
				et_core_intentionally_unescaped( $image, 'html' )
			);
		}

		/* Get Star Rating */
		if ( $rating > 0 ) {
			$stars = '';
			$rating = min(5, $rating);
			
			for ( $i = 1; $i <= absint( $rating ); $i++ ) {
				$stars .= '<span class="aioc_testimonial_star aioc_testimonial_filled_star"></span>';
			}
			if ( $rating != absint( $rating ) ) {
				$stars .= '<span class="aioc_testimonial_star aioc_testimonial_half_filled_star"></span>';
				$unfilled_stars  = 5 - absint( $rating ) - 1;
			} else {
				$unfilled_stars  = 5 - absint( $rating );
			}
			for ( $i = 1; $i <= $unfilled_stars; $i++ ) {
				$stars .= '<span class="aioc_testimonial_star aioc_testimonial_empty_star"></span>';
			}

			$testimonial_rating = sprintf(
				'<div class="aioc_testimonial_rating">
					<span itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating">
						<span class="aioc_testimonial_rating_value" itemprop="ratingValue">%1$s</span>
						%2$s
					</span>
				</div>',
				$rating,
				$stars
			);
		}

		// Font Icon Style.
		$this->generate_styles(
			array(
				'utility_arg'    => 'icon_font_family',
				'render_slug'    => $render_slug,
				'base_attr_name' => 'opening_font_icon',
				'important'      => true,
				'selector'       => '%%order_class%% .aioc_testimonial_opening_quote_icon',
				'processor'      => array(
					'ET_Builder_Module_Helper_Style_Processor',
					'process_extended_icon',
				),
			)
		);

		$opening_icon = $multi_view->render_element(
			array(
				'content'  => '{{opening_font_icon}}',
				'attrs'    => array(
					'class' => $opening_icon_classes,
				),
				'required' => 'opening_font_icon',
			)
		);
		
		// Font Icon Style.
		$this->generate_styles(
			array(
				'utility_arg'    => 'icon_font_family',
				'render_slug'    => $render_slug,
				'base_attr_name' => 'closing_font_icon',
				'important'      => true,
				'selector'       => '%%order_class%% .aioc_testimonial_closing_quote_icon',
				'processor'      => array(
					'ET_Builder_Module_Helper_Style_Processor',
					'process_extended_icon',
				),
			)
		);

		$closing_icon = $multi_view->render_element(
			array(
				'content'  => '{{closing_font_icon}}',
				'attrs'    => array(
					'class' => $closing_icon_classes,
				),
				'required' => 'closing_font_icon',
			)
		);

		$contentLength = substr($content, 0, $content_length);
		
		if ('' !== $content || '' !== $opening_icon || '' !== $closing_icon) {
			remove_filter('the_content', 'wpautop');
			$content_wrapper = sprintf(
				'<div class="aioc_slide_content">
				%1$s
				<p>%2$s</p>
				%3$s
				</div>',
				'on' === $show_opening_font_icon ? et_core_intentionally_unescaped($opening_icon, 'html') : '',
				et_core_intentionally_unescaped($content, 'html'),
				'on' === $show_closing_font_icon ? et_core_intentionally_unescaped($closing_icon, 'html') : ''
			);
			add_filter('the_content', 'wpautop');
		}


		if ( '' !== $name || '' !== $designation || '' !== $company_html || isset( $image ) ) {
			$meta_wrapper = sprintf(
				'<div class="aioc_slide_meta_wrapper">%1$s<div class="aioc_slide_author_details">%2$s%3$s%4$s</div></div>',
				isset( $image ) ? et_core_intentionally_unescaped( $image, 'html' ): '',
				et_core_intentionally_unescaped( $name, 'html' ),
				et_core_intentionally_unescaped( $designation, 'html' ),
				et_core_intentionally_unescaped( $company_html, 'html' )
			);
		}

		if ( '' !== $content || ( isset( $testimonial_rating ) && '' !== $testimonial_rating ) || isset( $meta_wrapper ) ) {
			$slide_wrapper = sprintf(
				'<div class="aioc_slide_wrapper">
					%1$s%2$s%3$s
				</div>',
				et_core_intentionally_unescaped( $content_wrapper, 'html' ),
				et_core_intentionally_unescaped( $testimonial_rating, 'html' ),
				isset( $meta_wrapper ) ? et_core_intentionally_unescaped( $meta_wrapper, 'html' ) : ''
			);
		} else {
			$slide_wrapper = '';
		}

		// Opening Quote Icon
		if ( 'on' === $show_opening_font_icon ) {
			if ( '' !== $opening_icon ) {
				$opening_font_icon_size 	= et_pb_responsive_options()->get_property_values( $this->props, 'opening_font_icon_size' ); 
				$opening_font_icon_color    = et_pb_responsive_options()->get_property_values( $this->props, 'opening_font_icon_color' );
				et_pb_responsive_options()->generate_responsive_css( $opening_font_icon_size, '%%order_class%% .aioc_testimonial_opening_quote_icon', 'font-size', $render_slug, '!important;', 'range' );
				et_pb_responsive_options()->generate_responsive_css( $opening_font_icon_color, '%%order_class%% .aioc_testimonial_opening_quote_icon', 'color', $render_slug, '!important;', 'color' );
				$opening_font_icon_color_hover    = $this->get_hover_value( 'opening_font_icon_color' );
				if ( $opening_font_icon_color_hover ) {
					self::set_style( $render_slug, array(
						'selector'    => '%%order_class%% .aioc_testimonial_opening_quote_icon:hover',
						'declaration' => sprintf(
							'color: %1$s !important;',
							esc_attr( $opening_font_icon_color_hover )
						),
					) );
				}
			}

			if ( 'on' === $custom_position_opening_font_icon ) {
				self::set_style(
					$render_slug,
					array(
						'selector'    => '%%order_class%% .aioc_testimonial_opening_quote_icon',
						'declaration' => 'position: absolute;',
					)
				);

				$opening_font_icon_position_top = et_pb_responsive_options()->get_property_values( $this->props, 'opening_font_icon_position_top' );

				if ( ! empty ( $opening_font_icon_position_top ) ) {
					et_pb_responsive_options()->generate_responsive_css( $opening_font_icon_position_top, '%%order_class%% .aioc_testimonial_opening_quote_icon', 'top', $render_slug, '!important;', 'range' );
				}
				
				if ( 'left' === $opening_font_icon_position ) {
					self::set_style(
						$render_slug,
						array(
							'selector'    => '%%order_class%% .aioc_testimonial_opening_quote_icon',
							'declaration' => 'left: 0 !important;',
						)
					);
				}

				if ( 'right' === $opening_font_icon_position ) {
					self::set_style(
						$render_slug,
						array(
							'selector'    => '%%order_class%% .aioc_testimonial_opening_quote_icon',
							'declaration' => 'right: 0 !important;',
						)
					);
				}

				if ( 'center' === $opening_font_icon_position ) {
					self::set_style(
						$render_slug,
						array(
							'selector'    => '%%order_class%% .aioc_testimonial_opening_quote_icon',
							'declaration' => 'left: 50% !important; -webkit-transform: translateX(-50%); transform: translateX(-50%);',
						)
					);
				}
			}			
		}

		// Closing Quote Icon
		if ( 'on' === $show_closing_font_icon ) {
			if ( '' !== $closing_icon ) {
				$closing_font_icon_size 	= et_pb_responsive_options()->get_property_values( $this->props, 'closing_font_icon_size' ); 
				$closing_font_icon_color    = et_pb_responsive_options()->get_property_values( $this->props, 'closing_font_icon_color' );
				et_pb_responsive_options()->generate_responsive_css( $closing_font_icon_size, '%%order_class%% .aioc_testimonial_closing_quote_icon', 'font-size', $render_slug, '!important;', 'range' );
				et_pb_responsive_options()->generate_responsive_css( $closing_font_icon_color, '%%order_class%% .aioc_testimonial_closing_quote_icon', 'color', $render_slug, '!important;', 'color' );
				$closing_font_icon_color_hover    = $this->get_hover_value( 'closing_font_icon_color' );
				if ( $closing_font_icon_color_hover ) {
					self::set_style( $render_slug, array(
						'selector'    => '%%order_class%% .aioc_testimonial_closing_quote_icon:hover',
						'declaration' => sprintf(
							'color: %1$s !important;',
							esc_attr( $closing_font_icon_color_hover )
						),
					) );
				}
			}

			if ( 'on' === $custom_position_closing_font_icon ) {
				self::set_style(
					$render_slug,
					array(
						'selector'    => '%%order_class%% .aioc_testimonial_closing_quote_icon',
						'declaration' => 'position: absolute;',
					)
				);

				$closing_font_icon_position_bottom = et_pb_responsive_options()->get_property_values( $this->props, 'closing_font_icon_position_bottom' );

				if ( ! empty ( $closing_font_icon_position_bottom ) ) {
					et_pb_responsive_options()->generate_responsive_css( $closing_font_icon_position_bottom, '%%order_class%% .aioc_testimonial_closing_quote_icon', 'bottom', $render_slug, '!important;', 'range' );
				}
				
				if ( 'left' === $closing_font_icon_position ) {
					self::set_style(
						$render_slug,
						array(
							'selector'    => '%%order_class%% .aioc_testimonial_closing_quote_icon',
							'declaration' => 'left: 0 !important;',
						)
					);
				}

				if ( 'right' === $closing_font_icon_position ) {
					self::set_style(
						$render_slug,
						array(
							'selector'    => '%%order_class%% .aioc_testimonial_closing_quote_icon',
							'declaration' => 'right: 0 !important;',
						)
					);
				}

				if ( 'center' === $closing_font_icon_position ) {
					self::set_style(
						$render_slug,
						array(
							'selector'    => '%%order_class%% .aioc_testimonial_closing_quote_icon',
							'declaration' => 'left: 50% !important; -webkit-transform: translateX(-50%); transform: translateX(-50%);',
						)
					);
				}
			}			
		}

		if ( 'coverflow' === $slide_effect && '' !== $slide_border_radius ){	
			self::set_style(
				$render_slug,
				array(
					'selector'    => '%%order_class%% .aioc_slide_wrapper',
					'declaration' => sprintf( 'border-radius: %1$s %2$s %3$s %4$s;', 
						$slide_border_radius[1],
						$slide_border_radius[2],
						$slide_border_radius[3],
						$slide_border_radius[4]
					),
				)
			);
		}

		$args = array(
			'render_slug'	=> $render_slug,
			'props'			=> $this->props,
			'fields'		=> $this->fields_unprocessed,
			'module'		=> $this,
			'backgrounds' 	=> array(
				'content_bg' => array(
					'normal' => "{$this->main_css_element} .aioc_slide_wrapper",
					'hover' => "{$this->main_css_element} .aioc_slide_wrapper:hover",
	 			),
			),
		);

		AIOC_Helper::process_background( $args );

		$background_layout_class_names = et_pb_background_layout_options()->get_background_layout_class( $this->props );
        $this->add_classname(
            array(
                $this->get_text_orientation_classname(),
                $background_layout_class_names[0],
                'aioc_slide_carousel_slide',
                'swiper-slide'
            )
        );

        $file = et_is_builder_plugin_active() ? 'style-dbp' : 'style';
		wp_enqueue_style( 'aioc-testimonial-carousel-item-style', ALL_IN_ONE_CAROUSEL_FOR_DIVI_PATH . 'includes/modules/TestimonialCarouselItem/' . $file . '.min.css', array(), '1.0.0' );

		return $slide_wrapper;
	}

    /**
	 * Filter multi view value.
	 *
	 * @since 3.27.1
	 *
	 * @see ET_Builder_Module_Helper_MultiViewOptions::filter_value
	 *
	 * @param mixed                                     $raw_value Props raw value.
	 * @param array                                     $args {
	 *                                         Context data.
	 *
	 *     @type string $context      Context param: content, attrs, visibility, classes.
	 *     @type string $name         Module options props name.
	 *     @type string $mode         Current data mode: desktop, hover, tablet, phone.
	 *     @type string $attr_key     Attribute key for attrs context data. Example: src, class, etc.
	 *     @type string $attr_sub_key Attribute sub key that availabe when passing attrs value as array such as styes. Example: padding-top, margin-botton, etc.
	 * }
	 * @param ET_Builder_Module_Helper_MultiViewOptions $multi_view Multiview object instance.
	 *
	 * @return mixed
	 */

	public function multi_view_filter_value( $raw_value, $args, $multi_view ) {
		$name = isset( $args['name'] ) ? $args['name'] : '';
	
		if ( $raw_value && ('opening_font_icon' === $name || 'closing_font_icon' === $name) ) {
			// Process font icon based on $name
			$processed_value = html_entity_decode( et_pb_process_font_icon( $raw_value ) );
			
			// Additional processing for specific cases
			if ( '%%1%%' === $raw_value ) {
				$processed_value = '"';
			}
	
			return $processed_value;
		}
	
		// If $name doesn't match any condition, return the raw value
		return $raw_value;
	}

	public function aioc_builder_processed_range_value( $result, $range, $range_string ) {
		if ( false !== strpos( $result, '0calc' ) ) {
			return $range;
		}
		return $result;
	}	

}

new AIOC_TestimonialCarouselItem;
