PluginProbe
Virtue/Ascend/Pinnacle Toolkit / 2.0
Virtue/Ascend/Pinnacle Toolkit v2.0
4.9.12.2 trunk 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 3.1 3.2 3.3 3.4 3.7 All 48 releases
virtue-toolkit / gallery.php

gallery.php in Virtue/Ascend/Pinnacle Toolkit 2.0, at gallery.php

108 lines 4.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 *
4 * Re-create the [gallery] shortcode and use thumbnails styling from kadencethemes
5 *
6 */
7 function kadence_shortcode_gallery($attr) {
8 $post = get_post();
9 static $instance = 0;
10 $instance++;
11
12 if (!empty($attr['ids'])) {
13 if (empty($attr['orderby'])) {
14 $attr['orderby'] = 'post__in';
15 }
16 $attr['include'] = $attr['ids'];
17 }
18
19 $output = apply_filters('post_gallery', '', $attr);
20
21 if ($output != '') {
22 return $output;
23 }
24
25 if (isset($attr['orderby'])) {
26 $attr['orderby'] = sanitize_sql_orderby($attr['orderby']);
27 if (!$attr['orderby']) {
28 unset($attr['orderby']);
29 }
30 }
31
32 extract(shortcode_atts(array(
33 'order' => 'ASC',
34 'orderby' => 'menu_order ID',
35 'id' => $post->ID,
36 'itemtag' => '',
37 'icontag' => '',
38 'captiontag' => '',
39 'columns' => 3,
40 'size' => 'full',
41 'include' => '',
42 'exclude' => ''
43 ), $attr));
44
45 $id = intval($id);
46
47 if ($order === 'RAND') {
48 $orderby = 'none';
49 }
50
51 $gallery_rn = (rand(10,100));
52
53 if (!empty($include)) {
54 $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
55
56 $attachments = array();
57 foreach ($_attachments as $key => $val) {
58 $attachments[$val->ID] = $_attachments[$key];
59 }
60 } elseif (!empty($exclude)) {
61 $attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
62 } else {
63 $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
64 }
65
66 if (empty($attachments)) {
67 return '';
68 }
69
70 if (is_feed()) {
71 $output = "\n";
72 foreach ($attachments as $att_id => $attachment) {
73 $output .= wp_get_attachment_link($att_id, $size, true) . "\n";
74 }
75 return $output;
76 }
77 // NORMAL
78 $output .= '<div id="kad-wp-gallery'.$gallery_rn.'" class="kad-wp-gallery kad-light-wp-gallery clearfix rowtight">';
79 if ($columns == '2') {$itemsize = 'tcol-lg-6 tcol-md-6 tcol-sm-6 tcol-xs-12 tcol-ss-12'; $imgsize = 600;}
80 else if ($columns == '1') {$itemsize = 'tcol-lg-12 tcol-md-12 tcol-sm-12 tcol-xs-12 tcol-ss-12'; $imgsize = 1200;}
81 else if ($columns == '3'){ $itemsize = 'tcol-lg-4 tcol-md-4 tcol-sm-4 tcol-xs-6 tcol-ss-12'; $imgsize = 400;}
82 else if ($columns == '6'){ $itemsize = 'tcol-lg-2 tcol-md-2 tcol-sm-3 tcol-xs-4 tcol-ss-6'; $imgsize = 300;}
83 else if ($columns == '8' || $columns == '9' || $columns == '7'){ $itemsize = 'tcol-lg-2 tcol-md-2 tcol-sm-3 tcol-xs-4 tcol-ss-4'; $imgsize = 260;}
84 else if ($columns == '12' || $columns == '11'){ $itemsize = 'tcol-lg-1 tcol-md-1 tcol-sm-2 tcol-xs-2 tcol-ss-3'; $imgsize = 240;}
85 else if ($columns == '5'){ $itemsize = 'tcol-lg-25 tcol-md-25 tcol-sm-3 tcol-xs-4 tcol-ss-6'; $imgsize = 300;}
86 else {$itemsize = 'tcol-lg-3 tcol-md-3 tcol-sm-4 tcol-xs-6 tcol-ss-12'; $imgsize = 300;}
87 $i = 0;
88 foreach ($attachments as $id => $attachment) {
89 $attachment_url = wp_get_attachment_url($id);
90 $image = aq_resize($attachment_url, $imgsize, $imgsize, true);
91 if(empty($image)) {$image = $attachment_url;}
92 $link = isset($attr['link']) && 'post' == $attr['link'] ? wp_get_attachment_link($id, $size, true, false) : wp_get_attachment_link($id, $size, false, false);
93
94 $output .= '<div class="'.$itemsize.' g_item"><div class="grid_item kad_gallery_fade_in gallery_item"><a href="'.$attachment_url.'" rel="lightbox[pp_gal]" class="lightboxhover">
95 <img src="'.$image.'" alt="'.esc_attr($attachment->post_excerpt).'" class="light-dropshaddow"/>';
96 $output .= '</a>';
97 $output .= '</div></div>';
98 }
99 $output .= '</div>';
100
101 return $output;
102 }
103 $pinnacle = get_option( 'pinnacle' );
104
105 if(isset($pinnacle['pinnacle_gallery']) && $pinnacle['pinnacle_gallery'] == '1' && (! function_exists( 'kadence_gallery' ) ) ) {
106 remove_shortcode('gallery');
107 add_shortcode('gallery', 'kadence_shortcode_gallery');
108 }