PluginProbe ʕ •ᴥ•ʔ
Shortcodes and extra features for Phlox theme / 1.3.1
Shortcodes and extra features for Phlox theme v1.3.1
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 10 years ago audio.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 sample-element.php 10 years ago search.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 video.php 9 years ago
gallery.php
600 lines
1 <?php
2 /**
3 * Filterable gallery with lightbox
4 *
5 *
6 * @package auxin-elements
7 * @license LICENSE.txt
8 * @author
9 * @link https://bitbucket.org/averta/
10 * @copyright (c) 2010-2016
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' => __('Column number','auxin-elements'),
73 'description' => '',
74 'param_name' => 'columns',
75 'type' => 'dropdown',
76 'value' => array(
77 '1' => __('1 Column' , 'auxin-elements'),
78 '2' => __('2 Columns', 'auxin-elements'),
79 '3' => __('3 Columns', 'auxin-elements'),
80 '4' => __('4 Columns', 'auxin-elements'),
81 '5' => __('5 Columns', 'auxin-elements'),
82 '6' => __('6 Columns', 'auxin-elements')
83 ),
84 'def_value' => '2',
85 'holder' => 'dropdown',
86 'class' => 'columns',
87 'admin_label' => true,
88 'dependency' => '',
89 'weight' => '',
90 'group' => '' ,
91 'edit_field_class' => ''
92 ),
93 array(
94 'heading' => __('Order images by query','auxin-elements'),
95 'description' => '',
96 'param_name' => 'wp_order',
97 'type' => 'aux_switch',
98 'value' => '0',
99 'class' => '',
100 'admin_label' => true,
101 'dependency' => '',
102 'weight' => '',
103 'group' => '' ,
104 'edit_field_class' => ''
105 ),
106 array(
107 'heading' => __('Order','auxin-elements'),
108 'description' => __('Order images ascending or descending','auxin-elements'),
109 'param_name' => 'order',
110 'type' => 'dropdown',
111 'def_value' => 'ASC',
112 'value' => array(
113 'ASC' => __('ASC' , 'auxin-elements'),
114 'DESC' => __('DESC', 'auxin-elements')
115 ),
116 'holder' => 'dropdown',
117 'class' => 'order',
118 'admin_label' => true,
119 'dependency' => array(
120 'element' => 'wp_order',
121 'value' => '1'
122 ),
123 'weight' => '',
124 'group' => '' ,
125 'edit_field_class' => ''
126 ),
127 array(
128 'heading' => __('Order images by','auxin-elements'),
129 'description' => '',
130 'param_name' => 'orderby',
131 'type' => 'dropdown',
132 'def_value' => 'menu_order ID',
133 'value' => array(
134 'menu_order ID' => __('Menu Order' , 'auxin-elements'),
135 'date' => __('Date' , 'auxin-elements'),
136 'ID' => __('ID' , 'auxin-elements'),
137 'none' => __('None' , 'auxin-elements')
138 ),
139 'dependency' => array(
140 'element' => 'wp_order',
141 'value' => '1'
142 ),
143 'holder' => 'dropdown',
144 'class' => 'orderby',
145 'admin_label' => true,
146 'weight' => '',
147 'group' => '' ,
148 'edit_field_class' => ''
149 ),
150 array(
151 'heading' => __('Gallery layout','auxin-elements'),
152 'description' => '',
153 'param_name' => 'layout',
154 'type' => 'dropdown',
155 'def_value' => 'grid',
156 'value' => array(
157 'grid' => __('Grid', 'auxin-elements'),
158 'masonry' => __('Masonry', 'auxin-elements')//,
159 //'justify-rows' => __('Justify rows', 'auxin-elements')
160 ),
161 'holder' => 'dropdown',
162 'class' => 'layout',
163 'admin_label' => true,
164 'dependency' => '',
165 'weight' => '',
166 'group' => '' ,
167 'edit_field_class' => ''
168 ),
169 array(
170 'heading' => __('Space','auxin-elements'),
171 'description' => __('Space between gallery items in pixel.', 'auxin-elements'),
172 'param_name' => 'space',
173 'type' => 'textfield',
174 'value' => '10',
175 'def_value' => '',
176 'holder' => 'textfield',
177 'class' => 'space',
178 'admin_label' => true,
179 'dependency' => '',
180 'weight' => '',
181 'group' => '' ,
182 'edit_field_class' => ''
183 ),
184 array(
185 'heading' => __('Link images to','auxin-elements'),
186 'description' => '',
187 'param_name' => 'link',
188 'type' => 'dropdown',
189 'def_value' => 'lightbox',
190 'value' => array(
191 'lightbox' => __('Lightbox', 'auxin-elements'),
192 'none' => __('None' , 'auxin-elements'),
193 '' => __('Attachment Page' , 'auxin-elements'),
194 'file' => __('File' , 'auxin-elements')
195 ),
196 'holder' => 'dropdown',
197 'class' => 'link',
198 'admin_label' => true,
199 'dependency' => '',
200 'weight' => '',
201 'group' => '' ,
202 'edit_field_class' => ''
203 ),
204 array(
205 'heading' => __('Image size','auxin-elements'),
206 'description' => '',
207 'param_name' => 'size',
208 'type' => 'dropdown',
209 'def_value' => 'medium',
210 'value' => array(
211 'full' => __('Original' , 'auxin-elements'),
212 'large' => __('Large' , 'auxin-elements'),
213 'medium' => __('Medium' , 'auxin-elements'),
214 'small' => __('Small' , 'auxin-elements'),
215 'thumbnail' => __('Thumbnail' , 'auxin-elements')
216 ),
217 'holder' => 'dropdown',
218 'class' => 'size',
219 'admin_label' => true,
220 'dependency' => '',
221 'weight' => '',
222 'group' => '' ,
223 'edit_field_class' => ''
224 ),
225 array(
226 'heading' => __('Enable pagination','auxin-elements'),
227 'description' => '',
228 'param_name' => 'pagination',
229 'type' => 'aux_switch',
230 'value' => '0',
231 'class' => '',
232 'admin_label' => true,
233 'dependency' => '',
234 'weight' => '',
235 'group' => '' ,
236 'edit_field_class' => ''
237 ),
238 array(
239 'heading' => __('Images per page','auxin-elements'),
240 'description' => '',
241 'param_name' => 'perpage',
242 'type' => 'textfield',
243 'value' => '24',
244 'def_value' => '',
245 'holder' => 'textfield',
246 'class' => 'id',
247 'admin_label' => true,
248 'dependency' => array(
249 'element' => 'pagination',
250 'value' => '1'
251 ),
252 'weight' => '',
253 'group' => '' ,
254 'edit_field_class' => ''
255 ),
256 array(
257 'heading' => __('Extra class name','auxin-elements'),
258 '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'),
259 'param_name' => 'extra_classes',
260 'type' => 'textfield',
261 'value' => '',
262 'def_value' => '',
263 'holder' => 'textfield',
264 'class' => 'extra_classes',
265 'admin_label' => true,
266 'dependency' => '',
267 'weight' => '',
268 'group' => '' ,
269 'edit_field_class' => ''
270 )
271
272 )
273 );
274
275 return $master_array;
276 }
277
278 add_filter( 'auxin_master_array_shortcodes', 'auxin_get_gallery_master_array', 10, 1 );
279
280
281
282
283
284
285 // This is the widget call back in fact the front end out put of this widget comes from this function
286 function auxin_widget_gallery_callback( $attr, $shortcode_content = null ){
287
288 global $axi_img_size;
289 $post = get_post();
290
291 static $instance = 0;
292 $instance++;
293
294 if ( ! empty( $attr['ids'] ) ) {
295 // 'ids' is explicitly ordered, unless you specify otherwise.
296 if ( empty( $attr['orderby'] ) ) {
297 $attr['orderby'] = 'post__in';
298 }
299 $attr['include'] = $attr['ids'];
300 }
301
302 // Allow plugins/themes to override the default gallery template.
303 $output = apply_filters( 'post_gallery', '', $attr, $instance );
304 if ( $output != '' ) {
305 return $output;
306 }
307
308 // We're trusting author input, so let's at least make sure it looks like a valid orderby statement
309 if ( isset( $attr['orderby'] ) ) {
310 $attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] );
311 if ( ! $attr['orderby'] )
312 unset( $attr['orderby'] );
313 }
314
315 $html5 = true;
316 // Defining default attributes
317 $default_atts = array(
318 'wp_order' => '0',
319 'order' => 'ASC',
320 'orderby' => 'menu_order ID',
321 'id' => $post ? $post->ID : 0,
322 'itemtag' => $html5 ? 'figure' : 'dl',
323 'icontag' => $html5 ? 'div' : 'dt',
324 'captiontag' => $html5 ? 'figcaption' : 'dd',
325 'columns' => 4,
326 'space' => 10,
327 'size' => 'medium',
328 'hardcrop' => "yes",
329 'layout' => 'grid', // grid, masonry, justify-rows, packery
330 'include' => '',
331 'exclude' => '',
332 'link' => 'lightbox', // none, file, empty(attachment), lightbox
333 'perpage' => 24,
334 'pagination' => false,
335 'lazyload' => false,
336 'gutter' => '1',
337
338 'title' => '', // header title
339 'extra_classes' => '', // custom css class names for this element
340 'custom_el_id' => '', // custom id attribute for this element
341 'base_class' => 'aux-widget-gallery' // base class name for container
342 );
343
344 $result = auxin_get_widget_scafold( $attr, $default_atts );
345 $atts = $result['parsed_atts'];
346
347 // ------------------------------------------
348
349 $id = intval( $atts['id'] );
350
351
352 if ( !$atts['wp_order'] && empty( $atts['ids'] ) ) {
353 $atts['order'] = 'ASC';
354 $atts['orderby'] = 'post__in';
355 }
356
357 if ( ! empty( $atts['include'] ) ) {
358 $_attachments = get_posts(
359 array(
360 'include' => $atts['include'],
361 'post_status' => 'inherit',
362 'post_type' => 'attachment',
363 'post_mime_type' => 'image',
364 'order' => $atts['order'],
365 'orderby' => $atts['orderby']
366 )
367 );
368
369 $attachments = array();
370 foreach ( $_attachments as $key => $val ) {
371 $attachments[$val->ID] = $_attachments[$key];
372 }
373
374 } elseif ( ! empty( $atts['exclude'] ) ) {
375
376 $attachments = get_children( array(
377 'post_parent' => $id,
378 'exclude' => $atts['exclude'],
379 'post_status' => 'inherit',
380 'post_type' => 'attachment',
381 'post_mime_type' => 'image',
382 'order' => $atts['order'],
383 'orderby' => $atts['orderby']
384 ));
385
386 } else {
387
388 $attachments = get_children( array(
389 'post_parent' => $ids,
390 'post_status' => 'inherit',
391 'post_type' => 'attachment',
392 'post_mime_type' => 'image',
393 'order' => $atts['order'],
394 'orderby' => $atts['orderby']
395 ));
396 }
397
398 if ( empty( $attachments ) ) {
399 return '';
400 }
401
402 if ( is_feed() ) {
403 $output = "\n";
404 foreach ( $attachments as $att_id => $attachment ) {
405 $output .= wp_get_attachment_link( $att_id, $atts['size'], true ) . "\n";
406 }
407 return $output;
408 }
409
410 $itemtag = tag_escape( $atts['itemtag'] );
411 $captiontag = tag_escape( $atts['captiontag'] );
412 $icontag = tag_escape( $atts['icontag'] );
413 $valid_tags = wp_kses_allowed_html( 'post' );
414 if ( ! isset( $valid_tags[ $itemtag ] ) ) {
415 $itemtag = 'dl';
416 }
417 if ( ! isset( $valid_tags[ $captiontag ] ) ) {
418 $captiontag = 'dd';
419 }
420 if ( ! isset( $valid_tags[ $icontag ] ) ) {
421 $icontag = 'dt';
422 }
423
424 $columns = intval( $atts['columns'] );
425 $itemwidth = $columns > 0 ? floor(100/$columns) : 100;
426 $float = is_rtl() ? 'right' : 'left';
427
428 $selector = "gallery-{$instance}";
429
430 $gallery_style = '';
431
432 /**
433 * Filter whether to print default gallery styles.
434 *
435 * @since 3.1.0
436 *
437 * @param bool $print Whether to print default gallery styles.
438 * Defaults to false if the theme supports HTML5 galleries.
439 * Otherwise, defaults to true.
440 */
441 if ( apply_filters( 'use_default_gallery_style', ! $html5 ) ) {
442 $gallery_style = "
443 <style type='text/css'>
444 #{$selector} {
445 margin: auto;
446 }
447 #{$selector} .gallery-item {
448 float: {$float};
449 margin-top: 10px;
450 text-align: center;
451 width: {$itemwidth}%;
452 }
453 #{$selector} img {
454 border: 2px solid #cfcfcf;
455 }
456 #{$selector} .gallery-caption {
457 margin-left: 0;
458 }
459 /* see gallery_shortcode() in wp-includes/media.php */
460 </style>\n\t\t";
461 }
462
463
464 $img_sizes = array (
465 'large' => 1024,
466 'medium' => 768,
467 'small' => 300,
468 'thumbnail' => 150
469 );
470
471 $grid_wrapper_class = '';
472 $grid_col_class = '';
473
474 $layoutAttr = $atts['layout'];
475
476 $grid_wrapper_class = 'aux-col'. $columns;// . ' aux-no-gutter';
477 $grid_col_class = 'aux-col';
478
479 if ( empty( $atts['layout'] ) || 'grid' == $atts['layout'] ){
480 $layoutAttr = 'masonry';
481 } else if ( 'justify-rows' == $atts['layout'] ) {
482 $layoutAttr = 'justifyRows';
483 }
484
485 // space attribute
486 if ( '10' != $atts['space'] ) {
487 $space_attr = 'data-space="'.$atts['space'].'"';
488 } else {
489 $space_attr = '';
490 }
491
492 $size_class = sanitize_html_class( $atts['size'] );
493 $gallery_div = "<div id='$selector' class='gallery aux-gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class} aux-lightbox-frame'>";
494
495 $gallery_div .= "<div class='aux-gallery-container aux-isotope-animated $grid_wrapper_class aux-layout-{$atts['layout']}' data-pagination='{$atts['pagination']}' data-lazyload='{$atts['lazyload']}' data-perpage='{$atts['perpage']}' data-layout='$layoutAttr' $space_attr >";
496
497 /**
498 * Filter the default gallery shortcode CSS styles.
499 *
500 * @param string $gallery_style Default CSS styles and opening HTML div container
501 * for the gallery shortcode output.
502 */
503 $output = apply_filters( 'gallery_style', $gallery_style . $gallery_div );
504
505 $i = 0;
506 $index = 0;
507
508 foreach ( $attachments as $id => $attachment ) {
509 $item = "";
510 $attr = ( trim( $attachment->post_excerpt ) ) ? array( 'aria-describedby' => "$selector-$id" ) : '';
511
512 $url = get_attachment_link( $id );
513 $original_src = auxin_get_attachment_url( $id, 'full' );
514
515 if ( empty( $atts['link'] ) ) {
516 $atts['link'] = 'attachment';
517 }
518
519 if ( 'file' === $atts['link'] || 'lightbox' === $atts['link'] ) {
520 $url = $original_src;
521 }
522
523 if ( empty( $atts['size'] ) || ( $atts['size'] === 'full' && $atts['layout'] != 'grid' ) ) {
524 $image_src = $original_src;
525 } else {
526 $image_src = auxin_get_the_resized_attachment_src( $id, $img_sizes[ $atts['size'] ] , $img_sizes[ $atts['size'] ], $atts['layout'] == 'grid' , 100, true );
527 }
528
529 $image_meta = wp_get_attachment_metadata( $id );
530
531 $orientation = '';
532 if ( isset( $image_meta['height'], $image_meta['width'] ) ) {
533 $orientation = ( $image_meta['height'] > $image_meta['width'] ) ? 'portrait' : 'landscape';
534 }
535 // get image size
536 $image_width = ( 'full' !== $atts['size'] && isset( $image_meta['sizes'][ $atts['size'] ]['width'] ) ) ? $image_meta['sizes'][ $atts['size'] ]['width' ] : $image_meta['width' ];
537 $image_height = ( 'full' !== $atts['size'] && isset( $image_meta['sizes'][ $atts['size'] ]['height'] ) ) ? $image_meta['sizes'][ $atts['size'] ]['height'] : $image_meta['height'];
538 $image_alt = trim(strip_tags( get_post_meta( $id, '_wp_attachment_image_alt', true ) ));
539
540 if ( empty( $image_alt ) )
541 $image_alt = trim( strip_tags( $attachment->post_excerpt ) ); // If not, Use the Caption
542 if ( empty( $image_alt ) )
543 $image_alt = trim( strip_tags( $attachment->post_title ) ); // Finally, use the title
544
545 $loading_class = $atts['lazyload'] ? 'aux-loading' : '';
546
547 $item_inner = "
548 <{$icontag} class='aux-frame-mask aux-frame-darken {$orientation}'>
549 <img src='$image_src'
550 data-original-src-width='{$image_meta['width']}'
551 data-original-src-height='{$image_meta['height']}'
552 data-original-src='$original_src'
553 alt='$image_alt'
554 width='$image_width'
555 height='$image_height'
556 ".$attr."
557 >
558 </{$icontag}>";
559
560 if ( $captiontag && trim($attachment->post_excerpt) ) {
561 $item_inner .= "
562 <{$captiontag} class='wp-caption-text gallery-caption' id='$selector-$id'>
563 " . wptexturize($attachment->post_excerpt) . "
564 </{$captiontag}>";
565 }
566
567 if ( 'lightbox' === $atts['link'] ) {
568 $item_inner = "<a href='$url' class='aux-lightbox-btn'>
569 <div class='aux-hover-scale-circle-plus'>
570 <span class='aux-symbol-plus'></span>
571 <span class='aux-symbol-circle'></span>
572 </div>
573 $item_inner</a>";
574 } elseif ( 'none' != $atts['link'] ) {
575 $item_inner = "<a href='$url'>$item_inner</a>";
576 }
577
578 if ( $atts['pagination'] && ++$index > $atts['perpage'] ) {
579 $item .= "<{$itemtag} class='gallery-item aux-hover-active aux-iso-item aux-iso-hidden $loading_class {$grid_col_class}' data-width='{$image_width}' data-height='{$image_height}'>$item_inner</{$itemtag}>";
580 } else {
581 $item .= "<{$itemtag} class='gallery-item aux-hover-active aux-iso-item {$grid_col_class} $loading_class' data-width='{$image_width}' data-height='{$image_height}'>$item_inner</{$itemtag}>";
582 }
583
584 if ( ! $html5 && $columns > 0 && ++$i % $columns == 0 ) {
585 $item .= '<br style="clear: both" />';
586 }
587
588 $output .= $item;
589 }
590
591 if ( ! $html5 && $columns > 0 && $i % $columns !== 0 ) {
592 $output .= "
593 <br style='clear: both' />";
594 }
595
596 $output .= "</div>\n</div>\n";
597
598 return $result['widget_header'] . $result['widget_title'] . $output . $result['widget_footer'];
599 }
600