PluginProbe
Elementor Website Builder – more than just a page builder / 3.0.6
Elementor Website Builder – more than just a page builder v3.0.6
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
← All changes | includes/widgets/image-gallery.php +61 -200 4.2.33.0.6 View file →
@@ -40,9 +40,9 @@
40 40 *
41 41 * @return string Widget title.
42 42 */
43 43 public function get_title() {
44 - return esc_html__( 'Basic Gallery', 'elementor' );
44 + return __( 'Basic Gallery', 'elementor' );
45 45 }
46 46
47 47 /**
48 48 * Get widget icon.
@@ -71,64 +71,21 @@
71 71 public function get_keywords() {
72 72 return [ 'image', 'photo', 'visual', 'gallery' ];
73 73 }
74 74
75 - protected function is_dynamic_content(): bool {
76 - return false;
77 - }
78 -
79 75 /**
80 - * Get style dependencies.
81 - *
82 - * Retrieve the list of style dependencies the widget requires.
83 - *
84 - * @since 3.24.0
85 - * @access public
86 - *
87 - * @return array Widget style dependencies.
88 - */
89 - public function get_style_depends(): array {
90 - return [ 'widget-image-gallery' ];
91 - }
92 -
93 - /**
94 - * Get widget upsale data.
95 - *
96 - * Retrieve the widget promotion data.
97 - *
98 - * @since 3.18.0
99 - * @access protected
100 - *
101 - * @return array Widget promotion data.
102 - */
103 - protected function get_upsale_data() {
104 - return [
105 - 'condition' => ! Utils::has_pro(),
106 - 'image' => esc_url( ELEMENTOR_ASSETS_URL . 'images/go-pro.svg' ),
107 - 'image_alt' => esc_attr__( 'Upgrade', 'elementor' ),
108 - 'description' => esc_html__( 'Use interesting masonry layouts and other overlay features with Elementor\'s Pro Gallery widget.', 'elementor' ),
109 - 'upgrade_url' => esc_url( 'https://go.elementor.com/go-pro-basic-gallery-widget/' ),
110 - 'upgrade_text' => esc_html__( 'Upgrade Now', 'elementor' ),
111 - ];
112 - }
113 -
114 - public function has_widget_inner_wrapper(): bool {
115 - return ! Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
116 - }
117 -
118 - /**
119 76 * Register image gallery widget controls.
120 77 *
121 78 * Adds different input fields to allow the user to change and customize the widget settings.
122 79 *
123 - * @since 3.1.0
80 + * @since 1.0.0
124 81 * @access protected
125 82 */
126 - protected function register_controls() {
83 + protected function _register_controls() {
127 84 $this->start_controls_section(
128 85 'section_gallery',
129 86 [
130 - 'label' => esc_html__( 'Basic Gallery', 'elementor' ),
87 + 'label' => __( 'Image Gallery', 'elementor' ),
131 88 ]
132 89 );
133 90
134 91 $this->add_control(
@@ -133,9 +90,9 @@
133 90
134 91 $this->add_control(
135 92 'wp_gallery',
136 93 [
137 - 'label' => esc_html__( 'Add Images', 'elementor' ),
94 + 'label' => __( 'Add Images', 'elementor' ),
138 95 'type' => Controls_Manager::GALLERY,
139 96 'show_label' => false,
140 97 'dynamic' => [
141 98 'active' => true,
@@ -147,8 +104,9 @@
147 104 Group_Control_Image_Size::get_type(),
148 105 [
149 106 'name' => 'thumbnail', // Usage: `{name}_size` and `{name}_custom_dimension`, in this case `thumbnail_size` and `thumbnail_custom_dimension`.
150 107 'exclude' => [ 'custom' ],
108 + 'separator' => 'none',
151 109 ]
152 110 );
153 111
154 112 $gallery_columns = range( 1, 10 );
@@ -156,9 +114,9 @@
156 114
157 115 $this->add_control(
158 116 'gallery_columns',
159 117 [
160 - 'label' => esc_html__( 'Columns', 'elementor' ),
118 + 'label' => __( 'Columns', 'elementor' ),
161 119 'type' => Controls_Manager::SELECT,
162 120 'default' => 4,
163 121 'options' => $gallery_columns,
164 122 ]
@@ -164,33 +122,17 @@
164 122 ]
165 123 );
166 124
167 125 $this->add_control(
168 - 'gallery_display_caption',
169 - [
170 - 'label' => esc_html__( 'Caption', 'elementor' ),
171 - 'type' => Controls_Manager::SELECT,
172 - 'default' => '',
173 - 'options' => [
174 - 'none' => esc_html__( 'None', 'elementor' ),
175 - '' => esc_html__( 'Attachment Caption', 'elementor' ),
176 - ],
177 - 'selectors' => [
178 - '{{WRAPPER}} .gallery-item .gallery-caption' => 'display: {{VALUE}};',
179 - ],
180 - ]
181 - );
182 -
183 - $this->add_control(
184 126 'gallery_link',
185 127 [
186 - 'label' => esc_html__( 'Link', 'elementor' ),
128 + 'label' => __( 'Link', 'elementor' ),
187 129 'type' => Controls_Manager::SELECT,
188 130 'default' => 'file',
189 131 'options' => [
190 - 'file' => esc_html__( 'Media File', 'elementor' ),
191 - 'attachment' => esc_html__( 'Attachment Page', 'elementor' ),
192 - 'none' => esc_html__( 'None', 'elementor' ),
132 + 'file' => __( 'Media File', 'elementor' ),
133 + 'attachment' => __( 'Attachment Page', 'elementor' ),
134 + 'none' => __( 'None', 'elementor' ),
193 135 ],
194 136 ]
195 137 );
196 138
@@ -196,65 +138,19 @@
196 138
197 139 $this->add_control(
198 140 'open_lightbox',
199 141 [
200 - 'label' => esc_html__( 'Lightbox', 'elementor' ),
142 + 'label' => __( 'Lightbox', 'elementor' ),
201 143 'type' => Controls_Manager::SELECT,
202 - 'description' => sprintf(
203 - /* translators: 1: Link open tag, 2: Link close tag. */
204 - esc_html__( 'Manage your site’s lightbox settings in the %1$sLightbox panel%2$s.', 'elementor' ),
205 - '<a href="javascript: $e.run( \'panel/global/open\' ).then( () => $e.route( \'panel/global/settings-lightbox\' ) )">',
206 - '</a>'
207 - ),
208 144 'default' => 'default',
209 145 'options' => [
210 - 'default' => esc_html__( 'Default', 'elementor' ),
211 - 'yes' => esc_html__( 'Yes', 'elementor' ),
212 - 'no' => esc_html__( 'No', 'elementor' ),
146 + 'default' => __( 'Default', 'elementor' ),
147 + 'yes' => __( 'Yes', 'elementor' ),
148 + 'no' => __( 'No', 'elementor' ),
213 149 ],
214 150 'condition' => [
215 151 'gallery_link' => 'file',
216 152 ],
217 - 'assets' => [
218 - 'styles' => [
219 - [
220 - 'name' => 'e-swiper',
221 - 'conditions' => [
222 - 'terms' => [
223 - [
224 - 'name' => 'gallery_link',
225 - 'operator' => '===',
226 - 'value' => 'file',
227 - ],
228 - [
229 - 'name' => 'open_lightbox',
230 - 'operator' => '!==',
231 - 'value' => 'no',
232 - ],
233 - ],
234 - ],
235 - ],
236 - ],
237 - 'scripts' => [
238 - [
239 - 'name' => 'swiper',
240 - 'conditions' => [
241 - 'terms' => [
242 - [
243 - 'name' => 'gallery_link',
244 - 'operator' => '===',
245 - 'value' => 'file',
246 - ],
247 - [
248 - 'name' => 'open_lightbox',
249 - 'operator' => '!==',
250 - 'value' => 'no',
251 - ],
252 - ],
253 - ],
254 - ],
255 - ],
256 - ],
257 153 ]
258 154 );
259 155
260 156 $this->add_control(
@@ -259,24 +155,33 @@
259 155
260 156 $this->add_control(
261 157 'gallery_rand',
262 158 [
263 - 'label' => esc_html__( 'Order By', 'elementor' ),
159 + 'label' => __( 'Order By', 'elementor' ),
264 160 'type' => Controls_Manager::SELECT,
265 161 'options' => [
266 - '' => esc_html__( 'Default', 'elementor' ),
267 - 'rand' => esc_html__( 'Random', 'elementor' ),
162 + '' => __( 'Default', 'elementor' ),
163 + 'rand' => __( 'Random', 'elementor' ),
268 164 ],
269 165 'default' => '',
270 166 ]
271 167 );
272 168
169 + $this->add_control(
170 + 'view',
171 + [
172 + 'label' => __( 'View', 'elementor' ),
173 + 'type' => Controls_Manager::HIDDEN,
174 + 'default' => 'traditional',
175 + ]
176 + );
177 +
273 178 $this->end_controls_section();
274 179
275 180 $this->start_controls_section(
276 181 'section_gallery_images',
277 182 [
278 - 'label' => esc_html__( 'Images', 'elementor' ),
183 + 'label' => __( 'Images', 'elementor' ),
279 184 'tab' => Controls_Manager::TAB_STYLE,
280 185 ]
281 186 );
282 187
@@ -282,13 +187,13 @@
282 187
283 188 $this->add_control(
284 189 'image_spacing',
285 190 [
286 - 'label' => esc_html__( 'Gap', 'elementor' ),
191 + 'label' => __( 'Spacing', 'elementor' ),
287 192 'type' => Controls_Manager::SELECT,
288 193 'options' => [
289 - '' => esc_html__( 'Default', 'elementor' ),
290 - 'custom' => esc_html__( 'Custom', 'elementor' ),
194 + '' => __( 'Default', 'elementor' ),
195 + 'custom' => __( 'Custom', 'elementor' ),
291 196 ],
292 197 'prefix_class' => 'gallery-spacing-',
293 198 'default' => '',
294 199 ]
@@ -299,21 +204,15 @@
299 204
300 205 $this->add_control(
301 206 'image_spacing_custom',
302 207 [
303 - 'label' => esc_html__( 'Custom Gap', 'elementor' ),
208 + 'label' => __( 'Image Spacing', 'elementor' ),
304 209 'type' => Controls_Manager::SLIDER,
305 - 'size_units' => [ 'px', 'em', 'rem', 'custom' ],
210 + 'show_label' => false,
306 211 'range' => [
307 212 'px' => [
308 213 'max' => 100,
309 214 ],
310 - 'em' => [
311 - 'max' => 10,
312 - ],
313 - 'rem' => [
314 - 'max' => 10,
315 - ],
316 215 ],
317 216 'default' => [
318 217 'size' => 15,
319 218 ],
@@ -335,14 +234,14 @@
335 234 'separator' => 'before',
336 235 ]
337 236 );
338 237
339 - $this->add_responsive_control(
238 + $this->add_control(
340 239 'image_border_radius',
341 240 [
342 - 'label' => esc_html__( 'Border Radius', 'elementor' ),
241 + 'label' => __( 'Border Radius', 'elementor' ),
343 242 'type' => Controls_Manager::DIMENSIONS,
344 - 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
243 + 'size_units' => [ 'px', '%' ],
345 244 'selectors' => [
346 245 '{{WRAPPER}} .gallery-item img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
347 246 ],
348 247 ]
@@ -352,44 +251,52 @@
352 251
353 252 $this->start_controls_section(
354 253 'section_caption',
355 254 [
356 - 'label' => esc_html__( 'Caption', 'elementor' ),
255 + 'label' => __( 'Caption', 'elementor' ),
357 256 'tab' => Controls_Manager::TAB_STYLE,
358 - 'condition' => [
359 - 'gallery_display_caption' => '',
257 + ]
258 + );
259 +
260 + $this->add_control(
261 + 'gallery_display_caption',
262 + [
263 + 'label' => __( 'Display', 'elementor' ),
264 + 'type' => Controls_Manager::SELECT,
265 + 'default' => '',
266 + 'options' => [
267 + '' => __( 'Show', 'elementor' ),
268 + 'none' => __( 'Hide', 'elementor' ),
360 269 ],
270 + 'selectors' => [
271 + '{{WRAPPER}} .gallery-item .gallery-caption' => 'display: {{VALUE}};',
272 + ],
361 273 ]
362 274 );
363 275
364 - $this->add_responsive_control(
276 + $this->add_control(
365 277 'align',
366 278 [
367 - 'label' => esc_html__( 'Alignment', 'elementor' ),
279 + 'label' => __( 'Alignment', 'elementor' ),
368 280 'type' => Controls_Manager::CHOOSE,
369 281 'options' => [
370 - 'start' => [
371 - 'title' => esc_html__( 'Start', 'elementor' ),
282 + 'left' => [
283 + 'title' => __( 'Left', 'elementor' ),
372 284 'icon' => 'eicon-text-align-left',
373 285 ],
374 286 'center' => [
375 - 'title' => esc_html__( 'Center', 'elementor' ),
287 + 'title' => __( 'Center', 'elementor' ),
376 288 'icon' => 'eicon-text-align-center',
377 289 ],
378 - 'end' => [
379 - 'title' => esc_html__( 'End', 'elementor' ),
290 + 'right' => [
291 + 'title' => __( 'Right', 'elementor' ),
380 292 'icon' => 'eicon-text-align-right',
381 293 ],
382 294 'justify' => [
383 - 'title' => esc_html__( 'Justified', 'elementor' ),
295 + 'title' => __( 'Justified', 'elementor' ),
384 296 'icon' => 'eicon-text-align-justify',
385 297 ],
386 298 ],
387 - 'classes' => 'elementor-control-start-end',
388 - 'selectors_dictionary' => [
389 - 'left' => is_rtl() ? 'end' : 'start',
390 - 'right' => is_rtl() ? 'start' : 'end',
391 - ],
392 299 'default' => 'center',
393 300 'selectors' => [
394 301 '{{WRAPPER}} .gallery-item .gallery-caption' => 'text-align: {{VALUE}};',
395 302 ],
@@ -401,9 +308,9 @@
401 308
402 309 $this->add_control(
403 310 'text_color',
404 311 [
405 - 'label' => esc_html__( 'Text Color', 'elementor' ),
312 + 'label' => __( 'Text Color', 'elementor' ),
406 313 'type' => Controls_Manager::COLOR,
407 314 'default' => '',
408 315 'selectors' => [
409 316 '{{WRAPPER}} .gallery-item .gallery-caption' => 'color: {{VALUE}};',
@@ -427,34 +334,8 @@
427 334 ],
428 335 ]
429 336 );
430 337
431 - $this->add_group_control(
432 - Group_Control_Text_Shadow::get_type(),
433 - [
434 - 'name' => 'caption_shadow',
435 - 'selector' => '{{WRAPPER}} .gallery-item .gallery-caption',
436 - 'condition' => [
437 - 'gallery_display_caption' => '',
438 - ],
439 - ]
440 - );
441 -
442 - $this->add_responsive_control(
443 - 'caption_space',
444 - [
445 - 'label' => esc_html__( 'Spacing', 'elementor' ),
446 - 'type' => Controls_Manager::SLIDER,
447 - 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
448 - 'selectors' => [
449 - '{{WRAPPER}} .gallery-item .gallery-caption' => 'margin-block-start: {{SIZE}}{{UNIT}};',
450 - ],
451 - 'condition' => [
452 - 'gallery_display_caption' => '',
453 - ],
454 - ]
455 - );
456 -
457 338 $this->end_controls_section();
458 339 }
459 340
460 341 /**
@@ -498,26 +379,6 @@
498 379 remove_filter( 'wp_get_attachment_link', [ $this, 'add_lightbox_data_to_image_link' ] );
499 380 ?>
500 381 </div>
501 382 <?php
502 - }
503 -
504 - public function render_markdown(): string {
505 - $settings = $this->get_settings_for_display();
506 - if ( empty( $settings['wp_gallery'] ) ) {
507 - return '';
508 - }
509 - $images = [];
510 - foreach ( $settings['wp_gallery'] as $image ) {
511 - $url = $image['url'] ?? '';
512 - if ( empty( $url ) ) {
513 - continue;
514 - }
515 - $alt = '';
516 - if ( ! empty( $image['id'] ) ) {
517 - $alt = get_post_meta( $image['id'], '_wp_attachment_image_alt', true );
518 - }
519 - $images[] = '![' . $alt . '](' . esc_url( $url ) . ')';
520 - }
521 - return implode( "\n\n", $images );
522 383 }
523 384 }