PluginProbe
UiCore Elements – Free widgets and templates for Elementor / 1.3.17
UiCore Elements – Free widgets and templates for Elementor v1.3.17
1.3.17 1.3.16 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 All 41 releases
uicore-elements / includes / widgets / gallery-grid.php

gallery-grid.php in UiCore Elements – Free widgets and templates for Elementor 1.3.17, at includes/widgets/gallery-grid.php

256 lines 7.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace UiCoreElements;
4
5 use Elementor\Controls_Manager;
6 use Elementor\Group_Control_Background;
7
8 use UiCoreElements\UiCoreWidget;
9 use UicoreElements\Utils\Gallery_Trait;
10 use UiCoreElements\Utils\Animation_Trait;
11 use UiCoreElements\Utils\Grid_Trait;
12 use UicoreElements\Utils\Item_Style_Component;
13
14 defined('ABSPATH') || exit();
15
16 /**
17 * Gallery Grid
18 *
19 * @author Lucas Marini Falbo <lucas95@uicore.co>
20 * @since 1.0.14
21 */
22
23 class GalleryGrid extends UiCoreWidget
24 {
25 use Animation_Trait;
26 use Grid_Trait;
27 use Gallery_Trait;
28 use Item_Style_Component;
29
30 public function get_name()
31 {
32 return 'uicore-gallery-grid';
33 }
34 public function get_title()
35 {
36 return esc_html__('Gallery Grid', 'uicore-elements');
37 }
38 public function get_icon()
39 {
40 return 'eicon-gallery-grid ui-e-widget';
41 }
42 public function get_categories()
43 {
44 return ['uicore'];
45 }
46 public function get_keywords()
47 {
48 return ['gallery', 'grid', 'content', 'box',];
49 }
50 public function get_styles()
51 {
52 $styles = [
53 'gallery-grid',
54 'grid',
55 'filters' => [
56 'condition' => [
57 'filters' => 'yes',
58 ]
59 ],
60 'animation', // hover animations
61 'entrance', // entrance basic style
62 ];
63 if (!class_exists('\UiCore\Core') && !class_exists('\UiCoreAnimate\Base')) {
64 $styles['e-animations'] = [ // entrance animations
65 'external' => true,
66 ];
67 }
68 return $styles;
69 }
70 public function get_scripts()
71 {
72 return [
73 'gallery-grid' => [
74 'condition' => [
75 'filters' => 'yes'
76 ],
77 ],
78 'entrance' => [
79 'condition' => [
80 'animate_items' => 'ui-e-grid-animate'
81 ],
82 ]
83 ];
84 }
85 public function has_widget_inner_wrapper(): bool
86 {
87 // TODO: remove after Optmized Markup experiment is merged to the core
88 return ! \Elementor\Plugin::$instance->experiments->is_feature_active('e_optimized_markup');
89 }
90 protected function register_controls()
91 {
92 $this->TRAIT_register_gallery_repeater_controls('Content');
93 $this->TRAIT_register_additional_controls();
94
95 $this->start_controls_section(
96 'grid_section',
97 [
98 'label' => esc_html__('Grid Settings', 'uicore-elements'),
99 'tab' => Controls_Manager::TAB_CONTENT,
100 ]
101 );
102
103 $this->TRAIT_register_grid_layout_controls();
104
105 $this->end_controls_section();
106
107 $this->start_controls_section(
108 'items_style_section',
109 [
110 'label' => esc_html__('Item', 'uicore-elements'),
111 'tab' => Controls_Manager::TAB_STYLE,
112 ]
113 );
114
115 $this->TRAIT_register_all_item_style_controls(false);
116
117 $this->end_controls_section();
118
119 $this->TRAIT_register_filters_style_controls();
120 $this->TRAIT_register_image_style_controls();
121 $this->TRAIT_register_title_style_controls();
122 $this->TRAIT_register_description_style_controls();
123 $this->TRAIT_register_tags_style_controls();
124 $this->TRAIT_register_badge_style_controls();
125 $this->TRAIT_register_gallery_animations();
126
127 // Update some component controls
128 $this->update_control(
129 'item_border',
130 [
131 'default' => 'none',
132 ]
133 );
134 $this->update_control(
135 'item_border_border',
136 [
137 'default' => 'none'
138 ]
139 );
140 $this->update_control(
141 'item_padding',
142 [
143 'default' => [
144 'top' => 10,
145 'right' => 10,
146 'bottom' => 10,
147 'left' => 10,
148 ],
149 'selectors' => [
150 '{{WRAPPER}} .ui-e-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
151 ],
152 ]
153 );
154 $this->update_control(
155 'item_border_radius',
156 [
157 'default' => [
158 'top' => 0,
159 'right' => 0,
160 'bottom' => 0,
161 'left' => 0,
162 'unit' => 'px',
163 ]
164 ]
165 );
166 $this->update_control(
167 'gap',
168 [
169 'default' => [
170 'size' => 35,
171 ]
172 ]
173 );
174
175 // Remove some useless component controls or group controls that can't be properly updated
176 $this->remove_control('item_background_background');
177 $this->remove_control('item_hover_background_background');
178 $this->remove_control('item_background_color');
179 $this->remove_control('item_background_image');
180 $this->remove_control('item_background_gradient');
181
182 // Inject new controls
183 $this->start_injection([
184 'of' => 'item_border_border',
185 'at' => 'before',
186 ]);
187
188 // normal background controls
189 $this->add_group_control(
190 Group_Control_Background::get_type(),
191 [
192 'name' => 'item_gallery_background',
193 'selector' => '{{WRAPPER}} .ui-e-item',
194 'condition' => [
195 'layout' => '',
196 ]
197 ]
198 );
199 $this->add_group_control(
200 Group_Control_Background::get_type(),
201 [
202 'name' => 'item_content_background',
203 'selector' => '{{WRAPPER}} .ui-e-content',
204 'condition' => [
205 'layout' => 'ui-e-overlay',
206 ]
207 ]
208 );
209
210 $this->end_injection();
211
212 $this->start_injection([
213 'of' => 'item_hover_border_color',
214 'at' => 'before',
215 ]);
216
217 // hover background controls
218 $this->add_group_control(
219 Group_Control_Background::get_type(),
220 [
221 'name' => 'item_gallery_hover_background',
222 'selector' => '{{WRAPPER}} .ui-e-item:hover',
223 'condition' => [
224 'layout' => '',
225 ]
226 ]
227 );
228 $this->add_group_control(
229 Group_Control_Background::get_type(),
230 [
231 'name' => 'item_content_hover_background',
232 'selector' => '{{WRAPPER}} .ui-e-item:hover .ui-e-content',
233 'condition' => [
234 'layout' => 'ui-e-overlay',
235 ]
236 ]
237 );
238
239 $this->end_injection();
240 }
241 public function render()
242 {
243 $settings = $this->get_settings_for_display();
244 $masonry = $this->is_option('masonry', 'yes') ? 'ui-e-maso' : '';
245
246 $this->TRAIT_render_gallery_filters($settings);
247
248 ?>
249 <div class='ui-e-grid ui-e-items-wrp <?php echo esc_attr($masonry); ?>'>
250 <?php $this->TRAIT_render_gallery($settings); ?>
251 </div>
252 <?php
253 }
254 }
255 \Elementor\Plugin::instance()->widgets_manager->register(new GalleryGrid());
256