PluginProbe ʕ •ᴥ•ʔ
Shortcodes and extra features for Phlox theme / 1.3.3
Shortcodes and extra features for Phlox theme v1.3.3
2.17.22 2.17.21 2.17.20 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.6 1.0.9 1.1.0 1.3.0 1.3.1 1.3.10 1.3.14 1.3.2 1.3.3 1.3.6 1.4.0 1.4.1 1.4.2 1.5.0 1.5.2 1.6.0 1.6.2 1.6.4 1.7.0 1.7.2 2.10.0 2.10.1 2.10.3 2.10.5 2.10.7 2.10.8 2.10.9 2.11.0 2.11.1 2.11.2 2.12.0 2.14.0 2.15.0 2.15.2 2.15.4 2.15.5 2.15.6 2.15.7 2.15.8 2.15.9 2.16.0 2.16.1 2.16.2 2.16.3 2.16.4 2.17.0 2.17.1 2.17.12 2.17.13 2.17.14 2.17.15 2.17.16 2.17.2 2.17.3 2.17.4 2.17.5 2.17.6 2.17.8 2.17.9 2.4.12 2.4.13 2.4.14 2.4.16 2.4.18 2.4.19 2.4.9 2.5.0 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.14 2.5.15 2.5.16 2.5.17 2.5.19 2.5.2 2.5.20 2.5.3 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.10 2.6.12 2.6.13 2.6.14 2.6.15 2.6.16 2.6.17 2.6.19 2.6.2 2.6.20 2.6.4 2.6.5 2.6.7 2.7.0 2.7.1 2.7.10 2.7.11 2.7.12 2.7.13 2.7.14 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.8.0 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.9 2.9.0 2.9.12 2.9.14 2.9.15 2.9.16 2.9.17 2.9.18 2.9.19 2.9.2 2.9.20 2.9.21 2.9.22 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 2.9.8
auxin-elements / includes / elements / gallery.php
auxin-elements / includes / elements Last commit date
about-widget.php 9 years ago accordion-api.php 9 years ago accordion.php 9 years ago attachment-url.php 9 years ago audio.php 9 years ago before-after.php 9 years ago button.php 9 years ago code.php 9 years ago contact-box.php 9 years ago contact-form.php 9 years ago divider.php 9 years ago dropcap.php 9 years ago facebook.php 9 years ago flickr.php 9 years ago gallery.php 9 years ago gmap.php 9 years ago highlight.php 9 years ago image.php 9 years ago instagram-feed.php 9 years ago latest-items.php 10 years ago latest-posts-slider.php 9 years ago popular-posts-widget.php 9 years ago quote.php 9 years ago recent-posts-grid-carousel.php 9 years ago recent-posts-land-style.php 9 years ago recent-posts-masonry.php 9 years ago recent-posts-tiles.php 9 years ago recent-posts-timeline.php 9 years ago recent-posts-widget.php 9 years ago recent-posts.php 9 years ago related-posts.php 9 years ago sample-element.php 9 years ago search.php 9 years ago slider.php 9 years ago socials-list.php 9 years ago tabs-api.php 9 years ago tabs.php 9 years ago text.php 9 years ago touch-slider.php 9 years ago video.php 9 years ago
gallery.php
569 lines
1 <?php
2 /**
3 * Filterable gallery with lightbox
4 *
5 *
6 * @package Auxin
7 * @license LICENSE.txt
8 * @author
9 * @link http://averta.net/phlox/
10 * @copyright (c) 2010-2017
11 */
12 function auxin_get_gallery_master_array( $master_array ) {
13
14 $master_array['aux_gallery'] = array(
15 'name' => __('[Phlox] Gallery', 'auxin-elements'),
16 'auxin_output_callback' => 'auxin_widget_gallery_callback',
17 'base' => 'aux_gallery',
18 'description' => __('Filterable and grid gallery with lightbox', 'auxin-elements'),
19 'class' => 'aux-widget-gallery',
20 'show_settings_on_create' => true,
21 'weight' => 1,
22 'is_widget' => false,
23 'is_shortcode' => true,
24 'is_so' => true,
25 'is_vc' => true,
26 'category' => THEME_NAME,
27 'group' => '',
28 'admin_enqueue_js' => '',
29 'admin_enqueue_css' => '',
30 'front_enqueue_js' => '',
31 'front_enqueue_css' => '',
32 'icon' => 'auxin-element auxin-gallery',
33 'custom_markup' => '',
34 'js_view' => '',
35 'html_template' => '',
36 'deprecated' => '',
37 'content_element' => '',
38 'as_parent' => '',
39 'as_child' => '',
40 'params' => array(
41 array(
42 'heading' => __('Title','auxin-elements'),
43 'description' => '',
44 'param_name' => 'title',
45 'type' => 'textfield',
46 'value' => '',
47 'def_value' => '',
48 'holder' => 'textfield',
49 'class' => 'title',
50 'admin_label' => true,
51 'dependency' => '',
52 'weight' => '',
53 'group' => '' ,
54 'edit_field_class' => ''
55 ),
56 array(
57 'heading' => __('Images','auxin-elements'),
58 'description' => '',
59 'param_name' => 'include',
60 'type' => 'attach_images',
61 'value' => '',
62 'def_value' => '',
63 'holder' => 'attach_images',
64 'class' => 'include',
65 'admin_label' => true,
66 'dependency' => '',
67 'weight' => '',
68 'group' => '' ,
69 'edit_field_class' => ''
70 ),
71 array(
72 'heading' => __('Gallery layout','auxin-elements'),
73 'description' => '',
74 'param_name' => 'layout',
75 'type' => 'aux_visual_select',
76 'def_value' => 'grid',
77 'choices' => array(
78 'grid' => array(
79 'label' => __('Grid', 'auxin-elements'),
80 'image' => AUX_URL . 'images/visual-select/gallery-grid.svg'
81 ),
82 'masonry' => array(
83 'label' => __('Masonry', 'auxin-elements'),
84 'image' => AUX_URL . 'images/visual-select/gallery-masonry.svg'
85 ),
86 'tiles' => array(
87 'label' => __('Tiles', 'auxin-elements'),
88 'image' => AUX_URL . 'images/visual-select/gallery-tile.svg'
89 ),
90 // 'justify-rows' => array(
91 // 'label' => __('Justify rows', 'auxin-elements'),
92 // 'image' => AUX_URL . 'images/visual-select/divider-diamond.svg'
93 // )
94 ),
95 'holder' => 'dropdown',
96 'class' => 'layout',
97 'admin_label' => true,
98 'dependency' => '',
99 'weight' => '',
100 'group' => '' ,
101 'edit_field_class' => ''
102 ),
103 array(
104 'heading' => __('Order images by query','auxin-elements'),
105 'description' => '',
106 'param_name' => 'wp_order',
107 'type' => 'aux_switch',
108 'value' => '0',
109 'class' => '',
110 'admin_label' => true,
111 'dependency' => '',
112 'weight' => '',
113 'group' => '' ,
114 'edit_field_class' => ''
115 ),
116 array(
117 'heading' => __('Order','auxin-elements'),
118 'description' => __('Order images ascending or descending','auxin-elements'),
119 'param_name' => 'order',
120 'type' => 'dropdown',
121 'def_value' => 'ASC',
122 'value' => array(
123 'ASC' => __('ASC' , 'auxin-elements'),
124 'DESC' => __('DESC', 'auxin-elements')
125 ),
126 'holder' => 'dropdown',
127 'class' => 'order',
128 'admin_label' => true,
129 'dependency' => array(
130 'element' => 'wp_order',
131 'value' => '1'
132 ),
133 'weight' => '',
134 'group' => '' ,
135 'edit_field_class' => ''
136 ),
137 array(
138 'heading' => __('Order images by','auxin-elements'),
139 'description' => '',
140 'param_name' => 'orderby',
141 'type' => 'dropdown',
142 'def_value' => 'menu_order ID',
143 'value' => array(
144 'menu_order ID' => __('Menu Order' , 'auxin-elements'),
145 'date' => __('Date' , 'auxin-elements'),
146 'ID' => __('ID' , 'auxin-elements'),
147 'none' => __('None' , 'auxin-elements')
148 ),
149 'dependency' => array(
150 'element' => 'wp_order',
151 'value' => '1'
152 ),
153 'holder' => 'dropdown',
154 'class' => 'orderby',
155 'admin_label' => true,
156 'weight' => '',
157 'group' => '' ,
158 'edit_field_class' => ''
159 ),
160 array(
161 'heading' => __('Number of columns', 'auxin-elements'),
162 'description' => '',
163 'param_name' => 'columns',
164 'type' => 'dropdown',
165 'def_value' => '4',
166 'holder' => 'dropdown',
167 'class' => 'columns',
168 'value' => array(
169 '1' => '1', '2' => '2', '3' => '3',
170 '4' => '4', '5' => '5', '6' => '6'
171 ),
172 'admin_label' => false,
173 'dependency' => array(
174 'element' => 'layout',
175 'value' => array( 'grid', 'masonry' )
176 ),
177 'weight' => '',
178 'group' => 'Layout' ,
179 'edit_field_class' => ''
180 ),
181 array(
182 'heading' => __('Number of columns in tablet size', 'auxin-elements'),
183 'description' => '',
184 'param_name' => 'tablet_cnum',
185 'type' => 'dropdown',
186 'def_value' => 'inherit',
187 'holder' => 'dropdown',
188 'class' => 'tablet_cnum',
189 'value' => array(
190 'inherit' => 'Inherited from larger',
191 '1' => '1', '2' => '2', '3' => '3',
192 '4' => '4', '5' => '5', '6' => '6'
193 ),
194 'admin_label' => false,
195 'dependency' => array(
196 'element' => 'layout',
197 'value' => array( 'grid', 'masonry' )
198 ),
199 'weight' => '',
200 'group' => 'Layout' ,
201 'edit_field_class' => ''
202 ),
203 array(
204 'heading' => __('Number of columns in phone size', 'auxin-elements'),
205 'description' => '',
206 'param_name' => 'phone_cnum',
207 'type' => 'dropdown',
208 'def_value' => '1',
209 'holder' => 'dropdown',
210 'class' => 'phone_cnum',
211 'value' => array(
212 '1' => '1' , '2' => '2', '3' => '3'
213 ),
214 'admin_label' => false,
215 'dependency' => array(
216 'element' => 'layout',
217 'value' => array( 'grid', 'masonry' )
218 ),
219 'weight' => '',
220 'group' => 'Layout' ,
221 'edit_field_class' => ''
222 ),
223 array(
224 'heading' => __('Space','auxin-elements'),
225 'description' => __('Space between gallery items in pixel.', 'auxin-elements'),
226 'param_name' => 'space',
227 'type' => 'textfield',
228 'value' => '10',
229 'def_value' => '',
230 'holder' => 'textfield',
231 'class' => 'space',
232 'admin_label' => false,
233 'dependency' => array(
234 'element' => 'layout',
235 'value' => array( 'grid', 'masonry' )
236 ),
237 'weight' => '',
238 'group' => '' ,
239 'edit_field_class' => ''
240 ),
241 array(
242 'heading' => __('Image aspect ratio', 'auxin-elements'),
243 'description' => '',
244 'param_name' => 'image_aspect_ratio',
245 'type' => 'dropdown',
246 'def_value' => '0.75',
247 'holder' => 'dropdown',
248 'class' => 'order',
249 'value' =>array (
250 '0.75' => __('Horizontal 4:3' , 'auxin-elements'),
251 '0.56' => __('Horizontal 16:9', 'auxin-elements'),
252 '1.00' => __('Square 1:1' , 'auxin-elements'),
253 '1.33' => __('Vertical 3:4' , 'auxin-elements')
254 ),
255 'admin_label' => false,
256 'dependency' => array(
257 'element' => 'layout',
258 'value' => array( 'grid' )
259 ),
260 'weight' => '',
261 'group' => '' ,
262 'edit_field_class' => ''
263 ),
264 array(
265 'heading' => __('Link images to','auxin-elements'),
266 'description' => '',
267 'param_name' => 'link',
268 'type' => 'dropdown',
269 'def_value' => 'lightbox',
270 'value' => array(
271 'lightbox' => __('Lightbox', 'auxin-elements'),
272 'none' => __('None' , 'auxin-elements'),
273 '' => __('Attachment Page' , 'auxin-elements'),
274 'file' => __('File' , 'auxin-elements')
275 ),
276 'holder' => 'dropdown',
277 'class' => 'link',
278 'admin_label' => true,
279 'dependency' => '',
280 'weight' => '',
281 'group' => '' ,
282 'edit_field_class' => ''
283 ),
284 array(
285 'heading' => __('Enable pagination','auxin-elements'),
286 'description' => '',
287 'param_name' => 'pagination',
288 'type' => 'aux_switch',
289 'value' => '0',
290 'class' => '',
291 'admin_label' => true,
292 'dependency' => '',
293 'weight' => '',
294 'group' => '' ,
295 'edit_field_class' => ''
296 ),
297 array(
298 'heading' => __('Enable lazyload','auxin-elements'),
299 'description' => __('Only load images that are in visible page','auxin-elements'),
300 'param_name' => 'lazyload',
301 'type' => 'aux_switch',
302 'value' => '0',
303 'class' => '',
304 'admin_label' => true,
305 'dependency' => array(
306 'element' => 'pagination',
307 'value' => '1'
308 ),
309 'weight' => '',
310 'group' => '' ,
311 'edit_field_class' => ''
312 ),
313 array(
314 'heading' => __('Images per page','auxin-elements'),
315 'description' => '',
316 'param_name' => 'perpage',
317 'type' => 'textfield',
318 'value' => '24',
319 'def_value' => '',
320 'holder' => 'textfield',
321 'class' => 'id',
322 'admin_label' => false,
323 'dependency' => array(
324 'element' => 'pagination',
325 'value' => '1'
326 ),
327 'weight' => '',
328 'group' => '' ,
329 'edit_field_class' => ''
330 ),
331 array(
332 'heading' => __('Extra class name','auxin-elements'),
333 'description' => __('If you wish to style particular content element differently, then use this field to add a class name and then refer to it in your css file.', 'auxin-elements'),
334 'param_name' => 'extra_classes',
335 'type' => 'textfield',
336 'value' => '',
337 'def_value' => '',
338 'holder' => 'textfield',
339 'class' => 'extra_classes',
340 'admin_label' => false,
341 'dependency' => '',
342 'weight' => '',
343 'group' => '' ,
344 'edit_field_class' => ''
345 )
346 )
347 );
348
349 return $master_array;
350 }
351
352 add_filter( 'auxin_master_array_shortcodes', 'auxin_get_gallery_master_array', 10, 1 );
353
354 // This is the widget call back in fact the front end out put of this widget comes from this function
355 function auxin_widget_gallery_callback( $attr, $shortcode_content = null ){
356 if ( ! empty( $attr['ids'] ) ) {
357 $attr['include'] = $attr['ids'];
358 }
359
360 static $instance = 0;
361 $instance++;
362 $selector = "aux-gallery-{$instance}";
363
364 global $post;
365
366 // Defining default attributes
367 $default_atts = array(
368 'order' => 'ASC',
369 'orderby' => 'menu_order ID',
370 'id' => $post ? $post->ID : 0,
371 'columns' => 4,
372 'tablet_cnum' => 'inherit',
373 'phone_cnum' => 1,
374 'space' => 10,
375 'image_aspect_ratio' => 0.75,
376 'layout' => 'grid', // grid, masonry, justify-rows, packery
377 'include' => '',
378 'link' => 'lightbox', // none, file, empty(attachment), lightbox
379 'perpage' => 24,
380 'pagination' => false,
381 'lazyload' => false,
382 'wp_order' => false,
383 'title' => '', // header title
384 'extra_classes' => '', // custom css class names for this element
385 'custom_el_id' => '', // custom id attribute for this element
386 'base_class' => 'aux-widget-gallery' // base class name for container
387 );
388
389 $result = auxin_get_widget_scafold( $attr, $default_atts );
390 extract( $result['parsed_atts'] );
391
392 // ------------------------------------------
393
394 if ( !$wp_order && empty( $ids ) ) {
395 $order = 'ASC';
396 $orderby = 'post__in';
397 }
398
399 $attachments = array();
400
401 if ( ! empty( $include ) ) {
402 $_attachments = get_posts(
403 array(
404 'include' => $include,
405 'post_status' => 'inherit',
406 'post_type' => 'attachment',
407 'post_mime_type' => 'image',
408 'order' => $order,
409 'orderby' => $orderby
410 )
411 );
412
413 foreach ( $_attachments as $key => $val ) {
414 $attachments[$val->ID] = $_attachments[$key];
415 }
416 }
417
418 if ( empty( $attachments ) ) {
419 return '';
420 }
421
422 if ( is_feed() ) {
423 $output = "\n";
424 foreach ( $attachments as $att_id => $attachment ) {
425 $output .= wp_get_attachment_link( $att_id, 'medium', true ) . "\n";
426 }
427 return $output;
428 }
429
430 ob_start();
431
432 // widget header ------------------------------
433 echo $result['widget_header'];
434 echo $result['widget_title'];
435
436 $crop = false;
437
438 if ( 'grid' == $layout ) {
439 $crop = true;
440 }
441
442 if ( empty( $layout ) || 'grid' == $layout ){
443 $isotop_layout = 'masonry';
444 } elseif ( 'justify-rows' == $layout ) {
445 $isotop_layout = 'justifyRows';
446 } elseif ( 'tiles' == $layout ) {
447 $isotop_layout = 'packery';
448 $space = 0;
449 } else {
450 $isotop_layout = 'masonry';
451 }
452
453 $add_lightbox = ( $link == 'lightbox' );
454 $add_caption = false;
455
456 echo "<div id='$selector' class='aux-gallery galleryid-{$id} gallery-columns-{$columns} " . ( $add_lightbox ? 'aux-lightbox-gallery' : '' ) . "'>";
457
458 // isotope attributes
459 $isotope_attrs = ' data-pagination="' . $pagination . '"'.
460 ' data-lazyload="' . ( $lazyload ? 'true' : 'false' ) . '"'.
461 ' data-perpage="' . $perpage . '"'.
462 ' data-layout="' . $isotop_layout . '"'.
463 ' data-space="' . $space . '"';
464
465 if ( 'tiles' == $layout ) {
466 $column_class = 'aux-tiles-layout';
467 $column_media_width = auxin_get_content_column_width( 4, $space );
468 $isotope_item_classes = 'aux-iso-item';
469 } else {
470 $column_class = 'aux-row aux-de-col' . $columns;
471 if ( 'inherit' == $tablet_cnum ) {
472 $tablet_cnum = $columns;
473 }
474
475 $column_class .= ' aux-tb-col'. $tablet_cnum;
476 $column_class .= ' aux-mb-col'. $phone_cnum;
477 $column_media_width = auxin_get_content_column_width( $columns, $space );
478 $isotope_item_classes = 'aux-iso-item aux-col';
479 }
480
481 echo "<div class='aux-gallery-container aux-isotope-animated $column_class aux-no-gutter aux-layout-$isotop_layout' $isotope_attrs >";
482
483
484 if ( $lazyload ) {
485 $isotope_item_classes .= ' aux-loading';
486 }
487
488 $index = 0;
489
490 foreach ( $attachments as $id => $attachment ) {
491
492 $isotope_item_attrs = '';
493 $attachment_meta = wp_get_attachment_metadata( $id );
494
495 if ( $add_lightbox || 'file' == $link ) {
496 $attachment_url = auxin_get_attachment_url( $id, 'full' );
497 } elseif ( 'attachment' == $link ) {
498 $attachment_url = get_attachment_link( $id );
499 }
500
501 if ( $add_lightbox ) {
502 $lightbox_attrs = 'data-original-width="' . $attachment_meta['width'] . '" data-original-height="' . $attachment_meta['height'] . '" ' .
503 'data-caption="' . auxin_attachment_caption( $id ) . '"';
504 }
505
506 if ( 'tiles' == $layout ) {
507 $item_pattern_info = auxin_get_tile_pattern( 'default', $index, $column_media_width );
508 $attachment_media = auxin_get_the_responsive_attachment(
509 $id,
510 array(
511 'upscale' => true,
512 'preloadable' => $lazyload,
513 'crop' => true,
514 'add_hw' => false, // whether add width and height attr or not
515 'size' => $item_pattern_info['size'],
516 'image_sizes' => $item_pattern_info['image_sizes'],
517 'srcset_sizes' => $item_pattern_info['srcset_sizes']
518 )
519
520 );
521
522 } else {
523 if ( 'masonry' == $layout ) {
524 $image_aspect_ratio = 0;
525 }
526
527 $attachment_media = auxin_get_the_responsive_attachment(
528 $id,
529 array(
530 'upscale' => true,
531 'preloadable' => $lazyload,
532 'crop' => $crop,
533 'size' => array( 'width' => $column_media_width, 'height' => $column_media_width * $image_aspect_ratio ),
534 'add_hw' => true, // whether add width and height attr or not
535 'image_sizes' => array(
536 array( 'min' => '', 'max' => '767px', 'width' => round( 100 / $phone_cnum ).'vw' ),
537 array( 'min' => '768px', 'max' => '992px', 'width' => round( 100 / $tablet_cnum ).'vw' ),
538 array( 'min' => '' , 'max' => '', 'width' => $column_media_width.'px' )
539 ),
540 'srcset_sizes' => array(
541 array( 'width' => $column_media_width, 'height' => $column_media_width * $image_aspect_ratio ),
542 array( 'width' => 2 * $column_media_width, 'height' => 2 * $column_media_width * $image_aspect_ratio ),
543 array( 'width' => 4 * $column_media_width, 'height' => 4 * $column_media_width * $image_aspect_ratio )
544 )
545 )
546 );
547 }
548
549 if ( $pagination && ++$index > $perpage ) {
550 $item_classes = 'aux-iso-hidden';
551 } else {
552 $item_classes = '';
553 }
554
555 if ( 'tiles' == $layout ) {
556 $item_classes .= ' aux-image-box '. $item_pattern_info['classname'];
557 }
558
559 include( locate_template( 'templates/theme-parts/entry/gallery-image.php' ) );
560 }
561
562 echo "</div></div>";
563
564 // widget footer ------------------------------
565 echo $result['widget_footer'];
566
567 return ob_get_clean();
568 }
569