PluginProbe ʕ •ᴥ•ʔ
Shortcodes and extra features for Phlox theme / 1.3.14
Shortcodes and extra features for Phlox theme v1.3.14
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
571 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 'holder' => 'textfield',
48 'class' => 'title',
49 'admin_label' => false,
50 'dependency' => '',
51 'weight' => '',
52 'group' => '' ,
53 'edit_field_class' => ''
54 ),
55 array(
56 'heading' => __('Images','auxin-elements'),
57 'description' => '',
58 'param_name' => 'include',
59 'type' => 'attach_images',
60 'value' => '',
61 'def_value' => '',
62 'holder' => '',
63 'class' => 'include',
64 'admin_label' => false,
65 'dependency' => '',
66 'weight' => '',
67 'group' => '' ,
68 'edit_field_class' => ''
69 ),
70 array(
71 'heading' => __('Gallery layout','auxin-elements'),
72 'description' => '',
73 'param_name' => 'layout',
74 'type' => 'aux_visual_select',
75 'def_value' => 'grid',
76 'choices' => array(
77 'grid' => array(
78 'label' => __('Grid', 'auxin-elements'),
79 'image' => AUXIN_URL . 'images/visual-select/gallery-grid.svg'
80 ),
81 'masonry' => array(
82 'label' => __('Masonry', 'auxin-elements'),
83 'image' => AUXIN_URL . 'images/visual-select/gallery-masonry.svg'
84 ),
85 'tiles' => array(
86 'label' => __('Tiles', 'auxin-elements'),
87 'image' => AUXIN_URL . 'images/visual-select/gallery-tile.svg'
88 ),
89 // 'justify-rows' => array(
90 // 'label' => __('Justify rows', 'auxin-elements'),
91 // 'image' => AUXIN_URL . 'images/visual-select/divider-diamond.svg'
92 // )
93 ),
94 'holder' => '',
95 'class' => 'layout',
96 'admin_label' => true,
97 'dependency' => '',
98 'weight' => '',
99 'group' => '' ,
100 'edit_field_class' => ''
101 ),
102 array(
103 'heading' => __('Order images by query','auxin-elements'),
104 'description' => '',
105 'param_name' => 'wp_order',
106 'type' => 'aux_switch',
107 'value' => '0',
108 'class' => '',
109 'admin_label' => false,
110 'dependency' => '',
111 'weight' => '',
112 'group' => '' ,
113 'edit_field_class' => ''
114 ),
115 array(
116 'heading' => __('Order','auxin-elements'),
117 'description' => __('Order images ascending or descending','auxin-elements'),
118 'param_name' => 'order',
119 'type' => 'dropdown',
120 'def_value' => 'ASC',
121 'value' => array(
122 'ASC' => __('ASC' , 'auxin-elements'),
123 'DESC' => __('DESC', 'auxin-elements')
124 ),
125 'holder' => '',
126 'class' => 'order',
127 'admin_label' => false,
128 'dependency' => array(
129 'element' => 'wp_order',
130 'value' => '1'
131 ),
132 'weight' => '',
133 'group' => '' ,
134 'edit_field_class' => ''
135 ),
136 array(
137 'heading' => __('Order images by','auxin-elements'),
138 'description' => '',
139 'param_name' => 'orderby',
140 'type' => 'dropdown',
141 'def_value' => 'menu_order ID',
142 'value' => array(
143 'menu_order ID' => __('Menu Order' , 'auxin-elements'),
144 'date' => __('Date' , 'auxin-elements'),
145 'ID' => __('ID' , 'auxin-elements'),
146 'none' => __('None' , 'auxin-elements')
147 ),
148 'dependency' => array(
149 'element' => 'wp_order',
150 'value' => '1'
151 ),
152 'holder' => '',
153 'class' => 'orderby',
154 'admin_label' => false,
155 'weight' => '',
156 'group' => '' ,
157 'edit_field_class' => ''
158 ),
159 array(
160 'heading' => __('Number of columns', 'auxin-elements'),
161 'description' => '',
162 'param_name' => 'columns',
163 'type' => 'dropdown',
164 'def_value' => '4',
165 'holder' => '',
166 'class' => 'columns',
167 'value' => array(
168 '1' => '1', '2' => '2', '3' => '3',
169 '4' => '4', '5' => '5', '6' => '6'
170 ),
171 'admin_label' => false,
172 'dependency' => array(
173 'element' => 'layout',
174 'value' => array( 'grid', 'masonry' )
175 ),
176 'weight' => '',
177 'group' => 'Layout' ,
178 'edit_field_class' => ''
179 ),
180 array(
181 'heading' => __('Number of columns in tablet size', 'auxin-elements'),
182 'description' => '',
183 'param_name' => 'tablet_cnum',
184 'type' => 'dropdown',
185 'def_value' => 'inherit',
186 'holder' => '',
187 'class' => 'tablet_cnum',
188 'value' => array(
189 'inherit' => 'Inherited from larger',
190 '1' => '1', '2' => '2', '3' => '3',
191 '4' => '4', '5' => '5', '6' => '6'
192 ),
193 'admin_label' => false,
194 'dependency' => array(
195 'element' => 'layout',
196 'value' => array( 'grid', 'masonry' )
197 ),
198 'weight' => '',
199 'group' => 'Layout' ,
200 'edit_field_class' => ''
201 ),
202 array(
203 'heading' => __('Number of columns in phone size', 'auxin-elements'),
204 'description' => '',
205 'param_name' => 'phone_cnum',
206 'type' => 'dropdown',
207 'def_value' => '1',
208 'holder' => '',
209 'class' => 'phone_cnum',
210 'value' => array(
211 '1' => '1' , '2' => '2', '3' => '3'
212 ),
213 'admin_label' => false,
214 'dependency' => array(
215 'element' => 'layout',
216 'value' => array( 'grid', 'masonry' )
217 ),
218 'weight' => '',
219 'group' => 'Layout' ,
220 'edit_field_class' => ''
221 ),
222 array(
223 'heading' => __('Space','auxin-elements'),
224 'description' => __('Space between gallery items in pixel.', 'auxin-elements'),
225 'param_name' => 'space',
226 'type' => 'textfield',
227 'value' => '10',
228 'def_value' => '',
229 'holder' => '',
230 'class' => 'space',
231 'admin_label' => false,
232 'dependency' => array(
233 'element' => 'layout',
234 'value' => array( 'grid', 'masonry' )
235 ),
236 'weight' => '',
237 'group' => '' ,
238 'edit_field_class' => ''
239 ),
240 array(
241 'heading' => __('Image aspect ratio', 'auxin-elements'),
242 'description' => '',
243 'param_name' => 'image_aspect_ratio',
244 'type' => 'dropdown',
245 'def_value' => '0.75',
246 'holder' => '',
247 'class' => 'order',
248 'value' =>array (
249 '0.75' => __('Horizontal 4:3' , 'auxin-elements'),
250 '0.56' => __('Horizontal 16:9', 'auxin-elements'),
251 '1.00' => __('Square 1:1' , 'auxin-elements'),
252 '1.33' => __('Vertical 3:4' , 'auxin-elements')
253 ),
254 'admin_label' => false,
255 'dependency' => array(
256 'element' => 'layout',
257 'value' => array( 'grid' )
258 ),
259 'weight' => '',
260 'group' => '' ,
261 'edit_field_class' => ''
262 ),
263 array(
264 'heading' => __('Link images to','auxin-elements'),
265 'description' => '',
266 'param_name' => 'link',
267 'type' => 'dropdown',
268 'def_value' => 'lightbox',
269 'value' => array(
270 'lightbox' => __('Lightbox', 'auxin-elements'),
271 'none' => __('None' , 'auxin-elements'),
272 '' => __('Attachment Page' , 'auxin-elements'),
273 'file' => __('File' , 'auxin-elements')
274 ),
275 'holder' => '',
276 'class' => 'link',
277 'admin_label' => false,
278 'dependency' => '',
279 'weight' => '',
280 'group' => '' ,
281 'edit_field_class' => ''
282 ),
283 array(
284 'heading' => __('Enable pagination','auxin-elements'),
285 'description' => '',
286 'param_name' => 'pagination',
287 'type' => 'aux_switch',
288 'value' => '0',
289 'class' => '',
290 'admin_label' => false,
291 'dependency' => '',
292 'weight' => '',
293 'group' => '' ,
294 'edit_field_class' => ''
295 ),
296 array(
297 'heading' => __('Enable lazyload','auxin-elements'),
298 'description' => __('Only load images that are in visible page','auxin-elements'),
299 'param_name' => 'lazyload',
300 'type' => 'aux_switch',
301 'value' => '0',
302 'class' => '',
303 'admin_label' => false,
304 'dependency' => array(
305 'element' => 'pagination',
306 'value' => '1'
307 ),
308 'weight' => '',
309 'group' => '' ,
310 'edit_field_class' => ''
311 ),
312 array(
313 'heading' => __('Images per page','auxin-elements'),
314 'description' => '',
315 'param_name' => 'perpage',
316 'type' => 'textfield',
317 'value' => '24',
318 'def_value' => '',
319 'holder' => '',
320 'class' => 'id',
321 'admin_label' => false,
322 'dependency' => array(
323 'element' => 'pagination',
324 'value' => '1'
325 ),
326 'weight' => '',
327 'group' => '' ,
328 'edit_field_class' => ''
329 ),
330 array(
331 'heading' => __('Extra class name','auxin-elements'),
332 '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'),
333 'param_name' => 'extra_classes',
334 'type' => 'textfield',
335 'value' => '',
336 'def_value' => '',
337 'holder' => '',
338 'class' => 'extra_classes',
339 'admin_label' => false,
340 'dependency' => '',
341 'weight' => '',
342 'group' => '' ,
343 'edit_field_class' => ''
344 )
345 )
346 );
347
348 return $master_array;
349 }
350
351 add_filter( 'auxin_master_array_shortcodes', 'auxin_get_gallery_master_array', 10, 1 );
352
353 // This is the widget call back in fact the front end out put of this widget comes from this function
354 function auxin_widget_gallery_callback( $attr, $shortcode_content = null ){
355 if ( ! empty( $attr['ids'] ) ) {
356 $attr['include'] = $attr['ids'];
357 }
358
359 static $instance = 0;
360 $instance++;
361 $selector = "aux-gallery-{$instance}";
362
363 global $post;
364
365 // Defining default attributes
366 $default_atts = array(
367 'order' => 'ASC',
368 'orderby' => 'menu_order ID',
369 'id' => $post ? $post->ID : 0,
370 'columns' => 4,
371 'tablet_cnum' => 'inherit',
372 'phone_cnum' => 1,
373 'space' => 10,
374 'image_aspect_ratio' => 0.75,
375 'layout' => 'grid', // grid, masonry, justify-rows, packery
376 'include' => '',
377 'link' => 'lightbox', // none, file, empty(attachment), lightbox
378 'perpage' => 24,
379 'pagination' => false,
380 'lazyload' => false,
381 'wp_order' => false,
382 'title' => '', // header title
383 'extra_classes' => '', // custom css class names for this element
384 'custom_el_id' => '', // custom id attribute for this element
385 'base_class' => 'aux-widget-gallery' // base class name for container
386 );
387
388 $result = auxin_get_widget_scafold( $attr, $default_atts );
389 extract( $result['parsed_atts'] );
390
391 // ------------------------------------------
392
393 if ( !$wp_order && empty( $ids ) ) {
394 $order = 'ASC';
395 $orderby = 'post__in';
396 }
397
398 $attachments = array();
399
400 if ( ! empty( $include ) ) {
401 $_attachments = get_posts(
402 array(
403 'include' => $include,
404 'post_status' => 'inherit',
405 'post_type' => 'attachment',
406 'post_mime_type' => 'image',
407 'order' => $order,
408 'orderby' => $orderby
409 )
410 );
411
412 foreach ( $_attachments as $key => $val ) {
413 $attachments[$val->ID] = $_attachments[$key];
414 }
415 }
416
417 if ( empty( $attachments ) ) {
418 return '';
419 }
420
421 if ( is_feed() ) {
422 $output = "\n";
423 foreach ( $attachments as $att_id => $attachment ) {
424 $output .= wp_get_attachment_link( $att_id, 'medium', true ) . "\n";
425 }
426 return $output;
427 }
428
429 ob_start();
430
431 // widget header ------------------------------
432 echo $result['widget_header'];
433 echo $result['widget_title'];
434
435 $crop = false;
436
437 if ( 'grid' == $layout ) {
438 $crop = true;
439 }
440
441 if ( empty( $layout ) || 'grid' == $layout ){
442 $isotop_layout = 'masonry';
443 } elseif ( 'justify-rows' == $layout ) {
444 $isotop_layout = 'justifyRows';
445 } elseif ( 'tiles' == $layout ) {
446 $isotop_layout = 'packery';
447 $space = 0;
448 } else {
449 $isotop_layout = 'masonry';
450 }
451
452 $add_lightbox = ( $link == 'lightbox' );
453 $add_caption = false;
454
455 echo "<div id='$selector' class='aux-gallery galleryid-{$id} gallery-columns-{$columns} " . ( $add_lightbox ? 'aux-lightbox-gallery' : '' ) . "'>";
456
457 // isotope attributes
458 $isotope_attrs = ' data-pagination="' . esc_attr( $pagination ) . '"'.
459 ' data-lazyload="' . ( $lazyload ? 'true' : 'false' ) . '"'.
460 ' data-perpage="' . esc_attr( $perpage) . '"'.
461 ' data-layout="' . esc_attr( $isotop_layout ) . '"'.
462 ' data-space="' . esc_attr( $space ) . '"';
463
464 if ( 'tiles' == $layout ) {
465 $column_class = 'aux-tiles-layout';
466 $column_media_width = auxin_get_content_column_width( 4, $space );
467 $isotope_item_classes = 'aux-iso-item';
468 } else {
469 $column_class = 'aux-row aux-de-col' . $columns;
470 if ( 'inherit' == $tablet_cnum ) {
471 $tablet_cnum = $columns;
472 }
473
474 $column_class .= ' aux-tb-col'. $tablet_cnum;
475 $column_class .= ' aux-mb-col'. $phone_cnum;
476 $column_media_width = auxin_get_content_column_width( $columns, $space );
477 $isotope_item_classes = 'aux-iso-item aux-col';
478 }
479
480 $column_media_width = round( $column_media_width );
481
482 printf( '<div class="aux-gallery-container aux-isotope-animated %s aux-no-gutter aux-layout-%s" %s >', esc_attr( $column_class ), esc_attr( $isotop_layout ), $isotope_attrs );
483
484
485 if ( $lazyload ) {
486 $isotope_item_classes .= ' aux-loading';
487 }
488
489 $index = 0;
490
491 foreach ( $attachments as $id => $attachment ) {
492
493 $isotope_item_attrs = '';
494 $attachment_meta = wp_get_attachment_metadata( $id );
495
496 if ( $add_lightbox || 'file' == $link ) {
497 $attachment_url = auxin_get_attachment_url( $id, 'full' );
498 } elseif ( 'attachment' == $link ) {
499 $attachment_url = get_attachment_link( $id );
500 }
501
502 if ( $add_lightbox ) {
503 $lightbox_attrs = 'data-original-width="' . esc_attr( $attachment_meta['width'] ) . '" data-original-height="' . esc_attr( $attachment_meta['height'] ) . '" ' .
504 'data-caption="' . esc_attr( strip_tags( auxin_attachment_caption( $id ) ) ) . '"';
505 }
506
507 if ( 'tiles' == $layout ) {
508 $item_pattern_info = auxin_get_tile_pattern( 'default', $index, $column_media_width );
509 $attachment_media = auxin_get_the_responsive_attachment(
510 $id,
511 array(
512 'upscale' => true,
513 'preloadable' => $lazyload,
514 'crop' => true,
515 'add_hw' => false, // whether add width and height attr or not
516 'size' => $item_pattern_info['size'],
517 'image_sizes' => $item_pattern_info['image_sizes'],
518 'srcset_sizes' => $item_pattern_info['srcset_sizes']
519 )
520
521 );
522
523 } else {
524 if ( 'masonry' == $layout ) {
525 $image_aspect_ratio = 0;
526 }
527
528 $attachment_media = auxin_get_the_responsive_attachment(
529 $id,
530 array(
531 'upscale' => true,
532 'preloadable' => $lazyload,
533 'crop' => $crop,
534 'size' => array( 'width' => $column_media_width, 'height' => $column_media_width * $image_aspect_ratio ),
535 'add_hw' => true, // whether add width and height attr or not
536 'image_sizes' => array(
537 array( 'min' => '', 'max' => '767px', 'width' => round( 100 / $phone_cnum ).'vw' ),
538 array( 'min' => '768px', 'max' => '992px', 'width' => round( 100 / $tablet_cnum ).'vw' ),
539 array( 'min' => '' , 'max' => '', 'width' => $column_media_width.'px' )
540 ),
541 'srcset_sizes' => array(
542 array( 'width' => $column_media_width, 'height' => $column_media_width * $image_aspect_ratio ),
543 array( 'width' => 2 * $column_media_width, 'height' => 2 * $column_media_width * $image_aspect_ratio ),
544 array( 'width' => 4 * $column_media_width, 'height' => 4 * $column_media_width * $image_aspect_ratio )
545 )
546 )
547 );
548 }
549
550 $index ++;
551 if ( $pagination && $index > $perpage ) {
552 $item_classes = 'aux-iso-hidden';
553 } else {
554 $item_classes = '';
555 }
556
557 if ( 'tiles' == $layout ) {
558 $item_classes .= ' aux-image-box '. esc_attr( $item_pattern_info['classname'] );
559 }
560
561 include( locate_template( 'templates/theme-parts/entry/gallery-image.php' ) );
562 }
563
564 echo "</div></div>";
565
566 // widget footer ------------------------------
567 echo $result['widget_footer'];
568
569 return ob_get_clean();
570 }
571