| @@ -1,176 +1,184 @@ | ||
| 1 | -<?php | |
| 2 | -namespace UiCoreElements; | |
| 3 | - | |
| 4 | -use Elementor\Controls_Manager; | |
| 5 | -use UiCoreElements\UiCoreWidget; | |
| 6 | -use UiCoreElements\Utils\Animation_Trait; | |
| 7 | -use UiCoreElements\Utils\Grid_Trait; | |
| 8 | -use UiCoreElements\Utils\Logo_Trait; | |
| 9 | - | |
| 10 | -defined('ABSPATH') || exit(); | |
| 11 | - | |
| 12 | -class Logo_Grid extends UiCoreWidget { | |
| 13 | - | |
| 14 | - use Animation_Trait; | |
| 15 | - use Grid_Trait; | |
| 16 | - use Logo_Trait; | |
| 17 | - | |
| 18 | - public function get_name() | |
| 19 | - { | |
| 20 | - return 'uicore-logo-grid'; | |
| 21 | - } | |
| 22 | - public function get_title() | |
| 23 | - { | |
| 24 | - return esc_html__( 'Logo Grid', 'uicore-elements' ); | |
| 25 | - } | |
| 26 | - public function get_icon() | |
| 27 | - { | |
| 28 | - return 'eicon-logo ui-e-widget'; | |
| 29 | - } | |
| 30 | - public function get_categories() | |
| 31 | - { | |
| 32 | - return ['uicore']; | |
| 33 | - } | |
| 34 | - public function get_keywords() | |
| 35 | - { | |
| 36 | - return [ 'logo', 'grid', 'client', 'brand', 'showcase' ]; | |
| 37 | - } | |
| 38 | - public function get_styles() | |
| 39 | - { | |
| 40 | - $styles = [ | |
| 41 | - 'logo-grid', | |
| 42 | - 'animation', // hover animations | |
| 43 | - 'entrance', // entrance basic style | |
| 44 | - ]; | |
| 45 | - if(!class_exists('\UiCore\Core') && !class_exists('\UiCoreAnimate\Base')){ | |
| 46 | - $styles['e-animations'] = [ // entrance animations | |
| 47 | - 'external' => true, | |
| 48 | - ]; | |
| 49 | - } | |
| 50 | - return $styles; | |
| 51 | - } | |
| 52 | - public function get_scripts() | |
| 53 | - { | |
| 54 | - return [ | |
| 55 | - 'logo-grid', | |
| 56 | - 'entrance' => [ | |
| 57 | - 'condition' => [ | |
| 58 | - 'animate_items' => 'ui-e-grid-animate' | |
| 59 | - ], | |
| 60 | - ] | |
| 61 | - ]; | |
| 62 | - } | |
| 63 | - protected function register_controls() | |
| 64 | - { | |
| 65 | - | |
| 66 | - $this->TRAIT_register_logo_repeater_controls('Logos'); // Repeater Controls | |
| 67 | - | |
| 68 | - $this->start_controls_section( | |
| 69 | - 'section_grid_settings', | |
| 70 | - [ | |
| 71 | - 'label' => __( 'Grid Settings', 'uicore-elements' ), | |
| 72 | - 'tab' => Controls_Manager::TAB_CONTENT, | |
| 73 | - ] | |
| 74 | - ); | |
| 75 | - | |
| 76 | - $this->add_control( | |
| 77 | - 'layout', | |
| 78 | - [ | |
| 79 | - 'label' => __( 'Grid Layout', 'uicore-elements' ), | |
| 80 | - 'type' => Controls_Manager::SELECT, | |
| 81 | - 'options' => [ | |
| 82 | - 'inner-border' => __( 'Inner Border', 'uicore-elements' ), | |
| 83 | - 'outer-border' => __( 'Outer Border', 'uicore-elements' ), | |
| 84 | - 'divider' => __( 'Inner Divider', 'uicore-elements' ), | |
| 85 | - ], | |
| 86 | - 'default' => 'inner-border', | |
| 87 | - 'frontend_available' => true, | |
| 88 | - 'style_transfer' => true, // enables the param to be copied/pasted even without selector => [] | |
| 89 | - 'render_type' => 'template', | |
| 90 | - ] | |
| 91 | - ); | |
| 92 | - | |
| 93 | - $this->TRAIT_register_grid_layout_controls(); | |
| 94 | - | |
| 95 | - $this->end_controls_section(); | |
| 96 | - | |
| 97 | - $this->start_controls_section( | |
| 98 | - 'section_logo_settings', | |
| 99 | - [ | |
| 100 | - 'label' => __( 'Logo Settings', 'uicore-elements' ), | |
| 101 | - 'tab' => Controls_Manager::TAB_CONTENT, | |
| 102 | - ] | |
| 103 | - ); | |
| 104 | - | |
| 105 | - $this->TRAIT_register_logo_adittional_controls(); | |
| 106 | - | |
| 107 | - $this->end_controls_section(); | |
| 108 | - | |
| 109 | - $this->start_controls_section( | |
| 110 | - 'section_logo_grid', | |
| 111 | - [ | |
| 112 | - 'label' => __( 'Logo Grid', 'uicore-elements' ), | |
| 113 | - 'tab' => Controls_Manager::TAB_STYLE, | |
| 114 | - ] | |
| 115 | - ); | |
| 116 | - | |
| 117 | - $this->TRAIT_register_logos_grid_style_controls(); | |
| 118 | - | |
| 119 | - $this->end_controls_section(); | |
| 120 | - | |
| 121 | - $this->start_controls_section( | |
| 122 | - 'animation_style_grid', | |
| 123 | - [ | |
| 124 | - 'label' => __( 'Animations', 'uicore-elements' ), | |
| 125 | - 'tab' => Controls_Manager::TAB_STYLE, | |
| 126 | - ] | |
| 127 | - ); | |
| 128 | - | |
| 129 | - $this->TRAIT_register_entrance_animations_controls(); | |
| 130 | - $this->TRAIT_register_hover_animation_control( | |
| 131 | - 'Item Hover Animation', | |
| 132 | - [], | |
| 133 | - ['underline'] | |
| 134 | - ); | |
| 135 | - $this->TRAIT_register_hover_animation_control( | |
| 136 | - 'Logo Hover Animation', | |
| 137 | - [], | |
| 138 | - ['underline'] | |
| 139 | - ); | |
| 140 | - | |
| 141 | - $this->end_controls_section(); | |
| 142 | - | |
| 143 | - // Updates and removes grid component controls | |
| 144 | - $this->update_control('columns', [ | |
| 145 | - 'default' => 4, | |
| 146 | - 'desktop_default' => 4, | |
| 147 | - 'tablet_default' => 2, | |
| 148 | - 'mobile_default' => 2, | |
| 149 | - 'render_type' => 'template', | |
| 150 | - 'frontend_available' => true, | |
| 151 | - 'selectors' => [ | |
| 152 | - '{{WRAPPER}} .ui-e-grid' => 'grid-template-columns: repeat({{VALUE}}, minmax(0, 1fr))', | |
| 153 | - ], | |
| 154 | - ]); | |
| 155 | - $this->update_control('gap', [ | |
| 156 | - 'condition' => [ | |
| 157 | - 'layout' => 'inner-border' | |
| 158 | - ], | |
| 159 | - ]); | |
| 160 | - $this->remove_control('masonry'); | |
| 161 | - } | |
| 162 | - protected function render() | |
| 163 | - { | |
| 164 | - | |
| 165 | - if(empty( $this->get_settings_for_display('logo_list'))) { | |
| 166 | - return; | |
| 167 | - } | |
| 168 | - | |
| 169 | - ?> | |
| 170 | - <div class='ui-e-grid'> | |
| 171 | - <?php $this->TRAIT_render_logo_item(); ?> | |
| 172 | - </div> | |
| 173 | - <?php | |
| 174 | - } | |
| 175 | -} | |
| 176 | -\Elementor\Plugin::instance()->widgets_manager->register(new Logo_Grid()); | |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace UiCoreElements; | |
| 4 | + | |
| 5 | +use Elementor\Controls_Manager; | |
| 6 | +use UiCoreElements\UiCoreWidget; | |
| 7 | +use UiCoreElements\Utils\Animation_Trait; | |
| 8 | +use UiCoreElements\Utils\Grid_Trait; | |
| 9 | +use UiCoreElements\Utils\Logo_Trait; | |
| 10 | + | |
| 11 | +defined('ABSPATH') || exit(); | |
| 12 | + | |
| 13 | +class Logo_Grid extends UiCoreWidget | |
| 14 | +{ | |
| 15 | + | |
| 16 | + use Animation_Trait; | |
| 17 | + use Grid_Trait; | |
| 18 | + use Logo_Trait; | |
| 19 | + | |
| 20 | + public function get_name() | |
| 21 | + { | |
| 22 | + return 'uicore-logo-grid'; | |
| 23 | + } | |
| 24 | + public function get_title() | |
| 25 | + { | |
| 26 | + return esc_html__('Logo Grid', 'uicore-elements'); | |
| 27 | + } | |
| 28 | + public function get_icon() | |
| 29 | + { | |
| 30 | + return 'eicon-logo ui-e-widget'; | |
| 31 | + } | |
| 32 | + public function get_categories() | |
| 33 | + { | |
| 34 | + return ['uicore']; | |
| 35 | + } | |
| 36 | + public function get_keywords() | |
| 37 | + { | |
| 38 | + return ['logo', 'grid', 'client', 'brand', 'showcase']; | |
| 39 | + } | |
| 40 | + public function get_styles() | |
| 41 | + { | |
| 42 | + $styles = [ | |
| 43 | + 'logo-grid', | |
| 44 | + 'grid', | |
| 45 | + 'animation', // hover animations | |
| 46 | + 'entrance', // entrance basic style | |
| 47 | + ]; | |
| 48 | + if (!class_exists('\UiCore\Core') && !class_exists('\UiCoreAnimate\Base')) { | |
| 49 | + $styles['e-animations'] = [ // entrance animations | |
| 50 | + 'external' => true, | |
| 51 | + ]; | |
| 52 | + } | |
| 53 | + return $styles; | |
| 54 | + } | |
| 55 | + public function get_scripts() | |
| 56 | + { | |
| 57 | + return [ | |
| 58 | + 'logo-grid', | |
| 59 | + 'entrance' => [ | |
| 60 | + 'condition' => [ | |
| 61 | + 'animate_items' => 'ui-e-grid-animate' | |
| 62 | + ], | |
| 63 | + ] | |
| 64 | + ]; | |
| 65 | + } | |
| 66 | + public function has_widget_inner_wrapper(): bool | |
| 67 | + { | |
| 68 | + // TODO: remove after Optmized Markup experiment is merged to the core | |
| 69 | + return ! \Elementor\Plugin::$instance->experiments->is_feature_active('e_optimized_markup'); | |
| 70 | + } | |
| 71 | + protected function register_controls() | |
| 72 | + { | |
| 73 | + | |
| 74 | + $this->TRAIT_register_logo_repeater_controls('Logos'); // Repeater Controls | |
| 75 | + | |
| 76 | + $this->start_controls_section( | |
| 77 | + 'section_grid_settings', | |
| 78 | + [ | |
| 79 | + 'label' => __('Grid Settings', 'uicore-elements'), | |
| 80 | + 'tab' => Controls_Manager::TAB_CONTENT, | |
| 81 | + ] | |
| 82 | + ); | |
| 83 | + | |
| 84 | + $this->add_control( | |
| 85 | + 'layout', | |
| 86 | + [ | |
| 87 | + 'label' => __('Grid Layout', 'uicore-elements'), | |
| 88 | + 'type' => Controls_Manager::SELECT, | |
| 89 | + 'options' => [ | |
| 90 | + 'inner-border' => __('Inner Border', 'uicore-elements'), | |
| 91 | + 'outer-border' => __('Outer Border', 'uicore-elements'), | |
| 92 | + 'divider' => __('Inner Divider', 'uicore-elements'), | |
| 93 | + ], | |
| 94 | + 'default' => 'inner-border', | |
| 95 | + 'frontend_available' => true, | |
| 96 | + 'style_transfer' => true, // enables the param to be copied/pasted even without selector => [] | |
| 97 | + 'render_type' => 'template', | |
| 98 | + ] | |
| 99 | + ); | |
| 100 | + | |
| 101 | + $this->TRAIT_register_grid_layout_controls(); | |
| 102 | + | |
| 103 | + $this->end_controls_section(); | |
| 104 | + | |
| 105 | + $this->start_controls_section( | |
| 106 | + 'section_logo_settings', | |
| 107 | + [ | |
| 108 | + 'label' => __('Logo Settings', 'uicore-elements'), | |
| 109 | + 'tab' => Controls_Manager::TAB_CONTENT, | |
| 110 | + ] | |
| 111 | + ); | |
| 112 | + | |
| 113 | + $this->TRAIT_register_logo_adittional_controls(); | |
| 114 | + | |
| 115 | + $this->end_controls_section(); | |
| 116 | + | |
| 117 | + $this->start_controls_section( | |
| 118 | + 'section_logo_grid', | |
| 119 | + [ | |
| 120 | + 'label' => __('Logo Grid', 'uicore-elements'), | |
| 121 | + 'tab' => Controls_Manager::TAB_STYLE, | |
| 122 | + ] | |
| 123 | + ); | |
| 124 | + | |
| 125 | + $this->TRAIT_register_logos_grid_style_controls(); | |
| 126 | + | |
| 127 | + $this->end_controls_section(); | |
| 128 | + | |
| 129 | + $this->start_controls_section( | |
| 130 | + 'animation_style_grid', | |
| 131 | + [ | |
| 132 | + 'label' => __('Animations', 'uicore-elements'), | |
| 133 | + 'tab' => Controls_Manager::TAB_STYLE, | |
| 134 | + ] | |
| 135 | + ); | |
| 136 | + | |
| 137 | + $this->TRAIT_register_entrance_animations_controls(); | |
| 138 | + $this->TRAIT_register_hover_animation_control( | |
| 139 | + 'Item Hover Animation', | |
| 140 | + [], | |
| 141 | + ['underline'] | |
| 142 | + ); | |
| 143 | + $this->TRAIT_register_hover_animation_control( | |
| 144 | + 'Logo Hover Animation', | |
| 145 | + [], | |
| 146 | + ['underline'] | |
| 147 | + ); | |
| 148 | + | |
| 149 | + $this->end_controls_section(); | |
| 150 | + | |
| 151 | + // Updates and removes grid component controls | |
| 152 | + $this->update_control('columns', [ | |
| 153 | + 'default' => 4, | |
| 154 | + 'desktop_default' => 4, | |
| 155 | + 'tablet_default' => 2, | |
| 156 | + 'mobile_default' => 2, | |
| 157 | + 'render_type' => 'template', | |
| 158 | + 'frontend_available' => true, | |
| 159 | + 'selectors' => [ | |
| 160 | + '{{WRAPPER}} .ui-e-grid' => 'grid-template-columns: repeat({{VALUE}}, minmax(0, 1fr))', | |
| 161 | + ], | |
| 162 | + ]); | |
| 163 | + $this->update_control('gap', [ | |
| 164 | + 'condition' => [ | |
| 165 | + 'layout' => 'inner-border' | |
| 166 | + ], | |
| 167 | + ]); | |
| 168 | + $this->remove_control('masonry'); | |
| 169 | + } | |
| 170 | + protected function render() | |
| 171 | + { | |
| 172 | + | |
| 173 | + if (empty($this->get_settings_for_display('logo_list'))) { | |
| 174 | + return; | |
| 175 | + } | |
| 176 | + | |
| 177 | +?> | |
| 178 | + <div class='ui-e-grid'> | |
| 179 | + <?php $this->TRAIT_render_logo_item(); ?> | |
| 180 | + </div> | |
| 181 | +<?php | |
| 182 | + } | |
| 183 | +} | |
| 184 | +\Elementor\Plugin::instance()->widgets_manager->register(new Logo_Grid()); | |