| @@ -1,137 +1,148 @@ | ||
| 1 | -<?php | |
| 2 | -namespace UiCoreElements; | |
| 3 | -use Elementor\Controls_Manager; | |
| 4 | -use UiCoreElements\UiCoreWidget; | |
| 5 | -use UiCoreElements\Utils\Testimonial_Trait; | |
| 6 | -use UiCoreElements\Utils\Animation_Trait; | |
| 7 | -use UiCoreElements\Utils\Grid_Trait; | |
| 8 | -use UicoreElements\Utils\Item_Style_Component; | |
| 9 | - | |
| 10 | -use function PHPSTORM_META\map; | |
| 11 | - | |
| 12 | -defined('ABSPATH') || exit(); | |
| 13 | - | |
| 14 | -/** | |
| 15 | - * Testimonial Grid | |
| 16 | - * | |
| 17 | - * @author Lucas Marini Falbo <[email protected]> | |
| 18 | - * @since 1.0.1 | |
| 19 | - */ | |
| 20 | - | |
| 21 | -class TestimonialGrid extends UiCoreWidget | |
| 22 | -{ | |
| 23 | - use Testimonial_Trait; | |
| 24 | - use Animation_Trait; | |
| 25 | - use Grid_Trait; | |
| 26 | - use Item_Style_Component; | |
| 27 | - | |
| 28 | - public function get_name() | |
| 29 | - { | |
| 30 | - return 'uicore-testimonial-grid'; | |
| 31 | - } | |
| 32 | - public function get_title() | |
| 33 | - { | |
| 34 | - return esc_html__('Testimonial Grid', 'uicore-elements'); | |
| 35 | - } | |
| 36 | - public function get_icon() | |
| 37 | - { | |
| 38 | - return 'eicon-testimonial ui-e-widget'; | |
| 39 | - } | |
| 40 | - public function get_categories() | |
| 41 | - { | |
| 42 | - return ['uicore']; | |
| 43 | - } | |
| 44 | - public function get_keywords() | |
| 45 | - { | |
| 46 | - return ['testimonial', 'review', 'services', 'cards', 'box', 'features', 'client', 'grid']; | |
| 47 | - } | |
| 48 | - public function get_styles() | |
| 49 | - { | |
| 50 | - $styles = [ | |
| 51 | - 'testimonial-grid', | |
| 52 | - 'animation', // hover animations | |
| 53 | - 'entrance', // entrance basic style | |
| 54 | - ]; | |
| 55 | - if(!class_exists('\UiCore\Core') && !class_exists('\UiCoreAnimate\Base')){ | |
| 56 | - $styles['e-animations'] = [ // entrance animations | |
| 57 | - 'external' => true, | |
| 58 | - ]; | |
| 59 | - } | |
| 60 | - return $styles; | |
| 61 | - } | |
| 62 | - public function get_scripts() | |
| 63 | - { | |
| 64 | - return [ | |
| 65 | - 'utils/global-testimonial' => [ | |
| 66 | - 'condition' => [ | |
| 67 | - 'layout' => 'layout_5' | |
| 68 | - ], | |
| 69 | - ], | |
| 70 | - 'entrance' => [ | |
| 71 | - 'condition' => [ | |
| 72 | - 'animate_items' => 'ui-e-grid-animate' | |
| 73 | - ], | |
| 74 | - ] | |
| 75 | - ]; | |
| 76 | - } | |
| 77 | - protected function register_controls() | |
| 78 | - { | |
| 79 | - | |
| 80 | - $this->TRAIT_register_testimonial_repeater_controls('Testimonial Grid Items'); // Repeater Controls | |
| 81 | - | |
| 82 | - $this->start_controls_section( // Specific Additional Grid Controls | |
| 83 | - 'section_review_additional_settings', | |
| 84 | - [ | |
| 85 | - 'label' => __('Additional Settings', 'uicore-elements'), | |
| 86 | - 'tab' => Controls_Manager::TAB_CONTENT, | |
| 87 | - ] | |
| 88 | - ); | |
| 89 | - | |
| 90 | - $this->TRAIT_register_specific_testimonial_controls('layout'); | |
| 91 | - $this->TRAIT_register_grid_layout_controls(); | |
| 92 | - $this->TRAIT_register_testimonial_additional_controls(); // Content Additional Controls | |
| 93 | - | |
| 94 | - $this->end_controls_section(); | |
| 95 | - | |
| 96 | - $this->start_controls_section( | |
| 97 | - 'section_style_review_items', | |
| 98 | - [ | |
| 99 | - 'label' => esc_html__( 'Items', 'uicore-elements' ), | |
| 100 | - 'tab' => Controls_Manager::TAB_STYLE, | |
| 101 | - ] | |
| 102 | - ); | |
| 103 | - | |
| 104 | - $this->TRAIT_register_all_item_style_controls(false); | |
| 105 | - | |
| 106 | - $this->end_controls_section(); | |
| 107 | - | |
| 108 | - $this->TRAIT_register_style_controls(); // Other Components Style Controls | |
| 109 | - | |
| 110 | - $this->start_controls_section( | |
| 111 | - 'section_style_animations', | |
| 112 | - [ | |
| 113 | - 'label' => __('Animations', 'uicore-elements'), | |
| 114 | - 'tab' => Controls_Manager::TAB_STYLE, | |
| 115 | - ] | |
| 116 | - ); | |
| 117 | - | |
| 118 | - $this->TRAIT_register_testimonial_animation_controls(); | |
| 119 | - | |
| 120 | - $this->end_controls_section(); | |
| 121 | - } | |
| 122 | - public function render() | |
| 123 | - { | |
| 124 | - $settings = $this->get_settings_for_display(); | |
| 125 | - $layout = $settings['layout']; | |
| 126 | - | |
| 127 | - $this->add_render_attribute('review-card', 'class', 'ui-e-grid'); | |
| 128 | - ?> | |
| 129 | - <div <?php $this->print_render_attribute_string('review-card'); ?>> | |
| 130 | - <?php foreach ( $settings['review_items'] as $index => $item ) : ?> | |
| 131 | - <?php $this->TRAIT_render_review_item($item, $layout); ?> | |
| 132 | - <?php endforeach; ?> | |
| 133 | - </div> | |
| 134 | - <?php | |
| 135 | - } | |
| 136 | -} | |
| 137 | -\Elementor\Plugin::instance()->widgets_manager->register(new TestimonialGrid()); | |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace UiCoreElements; | |
| 4 | + | |
| 5 | +use Elementor\Controls_Manager; | |
| 6 | +use UiCoreElements\UiCoreWidget; | |
| 7 | +use UiCoreElements\Utils\Testimonial_Trait; | |
| 8 | +use UiCoreElements\Utils\Animation_Trait; | |
| 9 | +use UiCoreElements\Utils\Grid_Trait; | |
| 10 | +use UicoreElements\Utils\Item_Style_Component; | |
| 11 | + | |
| 12 | +use function PHPSTORM_META\map; | |
| 13 | + | |
| 14 | +defined('ABSPATH') || exit(); | |
| 15 | + | |
| 16 | +/** | |
| 17 | + * Testimonial Grid | |
| 18 | + * | |
| 19 | + * @author Lucas Marini Falbo <[email protected]> | |
| 20 | + * @since 1.0.1 | |
| 21 | + */ | |
| 22 | + | |
| 23 | +class TestimonialGrid extends UiCoreWidget | |
| 24 | +{ | |
| 25 | + use Testimonial_Trait; | |
| 26 | + use Animation_Trait; | |
| 27 | + use Grid_Trait; | |
| 28 | + use Item_Style_Component; | |
| 29 | + | |
| 30 | + public function get_name() | |
| 31 | + { | |
| 32 | + return 'uicore-testimonial-grid'; | |
| 33 | + } | |
| 34 | + public function get_title() | |
| 35 | + { | |
| 36 | + return esc_html__('Testimonial Grid', 'uicore-elements'); | |
| 37 | + } | |
| 38 | + public function get_icon() | |
| 39 | + { | |
| 40 | + return 'eicon-testimonial ui-e-widget'; | |
| 41 | + } | |
| 42 | + public function get_categories() | |
| 43 | + { | |
| 44 | + return ['uicore']; | |
| 45 | + } | |
| 46 | + public function get_keywords() | |
| 47 | + { | |
| 48 | + return ['testimonial', 'review', 'services', 'cards', 'box', 'features', 'client', 'grid']; | |
| 49 | + } | |
| 50 | + public function get_styles() | |
| 51 | + { | |
| 52 | + $styles = [ | |
| 53 | + 'testimonial-grid', | |
| 54 | + 'grid', | |
| 55 | + 'animation', // hover animations | |
| 56 | + 'entrance', // entrance basic style | |
| 57 | + ]; | |
| 58 | + if (!class_exists('\UiCore\Core') && !class_exists('\UiCoreAnimate\Base')) { | |
| 59 | + $styles['e-animations'] = [ // entrance animations | |
| 60 | + 'external' => true, | |
| 61 | + ]; | |
| 62 | + } | |
| 63 | + return $styles; | |
| 64 | + } | |
| 65 | + public function get_scripts() | |
| 66 | + { | |
| 67 | + return [ | |
| 68 | + 'testimonial' => [ | |
| 69 | + 'condition' => [ | |
| 70 | + 'layout' => 'layout_5' | |
| 71 | + ], | |
| 72 | + ], | |
| 73 | + 'entrance' => [ | |
| 74 | + 'condition' => [ | |
| 75 | + 'animate_items' => 'ui-e-grid-animate' | |
| 76 | + ], | |
| 77 | + ] | |
| 78 | + ]; | |
| 79 | + } | |
| 80 | + public function has_widget_inner_wrapper(): bool | |
| 81 | + { | |
| 82 | + // TODO: remove after Optmized Markup experiment is merged to the core | |
| 83 | + return ! \Elementor\Plugin::$instance->experiments->is_feature_active('e_optimized_markup'); | |
| 84 | + } | |
| 85 | + protected function register_controls() | |
| 86 | + { | |
| 87 | + | |
| 88 | + $this->TRAIT_register_testimonial_repeater_controls('Testimonial Grid Items'); // Repeater Controls | |
| 89 | + | |
| 90 | + $this->start_controls_section( // Specific Additional Grid Controls | |
| 91 | + 'section_review_additional_settings', | |
| 92 | + [ | |
| 93 | + 'label' => __('Additional Settings', 'uicore-elements'), | |
| 94 | + 'tab' => Controls_Manager::TAB_CONTENT, | |
| 95 | + ] | |
| 96 | + ); | |
| 97 | + | |
| 98 | + $this->TRAIT_register_specific_testimonial_controls('layout'); | |
| 99 | + $this->TRAIT_register_grid_layout_controls(); | |
| 100 | + $this->TRAIT_register_testimonial_additional_controls(); // Content Additional Controls | |
| 101 | + | |
| 102 | + $this->end_controls_section(); | |
| 103 | + | |
| 104 | + $this->start_controls_section( | |
| 105 | + 'section_style_review_items', | |
| 106 | + [ | |
| 107 | + 'label' => esc_html__('Items', 'uicore-elements'), | |
| 108 | + 'tab' => Controls_Manager::TAB_STYLE, | |
| 109 | + ] | |
| 110 | + ); | |
| 111 | + | |
| 112 | + $this->TRAIT_register_all_item_style_controls(false); | |
| 113 | + | |
| 114 | + $this->end_controls_section(); | |
| 115 | + | |
| 116 | + $this->TRAIT_register_style_controls(); // Other Components Style Controls | |
| 117 | + | |
| 118 | + $this->start_controls_section( | |
| 119 | + 'section_style_animations', | |
| 120 | + [ | |
| 121 | + 'label' => __('Animations', 'uicore-elements'), | |
| 122 | + 'tab' => Controls_Manager::TAB_STYLE, | |
| 123 | + ] | |
| 124 | + ); | |
| 125 | + | |
| 126 | + $this->TRAIT_register_testimonial_animation_controls(); | |
| 127 | + | |
| 128 | + $this->end_controls_section(); | |
| 129 | + } | |
| 130 | + public function render() | |
| 131 | + { | |
| 132 | + $settings = $this->get_settings_for_display(); | |
| 133 | + $layout = $settings['layout']; | |
| 134 | + $masonry = $this->is_option('masonry', 'yes') | |
| 135 | + ? 'ui-e-maso' | |
| 136 | + : ''; | |
| 137 | + | |
| 138 | + $this->add_render_attribute('review-card', 'class', ['ui-e-grid', $masonry]); | |
| 139 | +?> | |
| 140 | + <div <?php $this->print_render_attribute_string('review-card'); ?>> | |
| 141 | + <?php foreach ($settings['review_items'] as $index => $item) : ?> | |
| 142 | + <?php $this->TRAIT_render_review_item($item, $layout); ?> | |
| 143 | + <?php endforeach; ?> | |
| 144 | + </div> | |
| 145 | +<?php | |
| 146 | + } | |
| 147 | +} | |
| 148 | +\Elementor\Plugin::instance()->widgets_manager->register(new TestimonialGrid()); | |