PluginProbe
Virtue/Ascend/Pinnacle Toolkit / 3.1
Virtue/Ascend/Pinnacle Toolkit v3.1
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 3.8 All 47 releases
virtue-toolkit / gallery.php

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

115 lines 4.5 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 'lightboxsize' => 'full',
43 'exclude' => ''
44 ), $attr));
45
46 $id = intval($id);
47
48 if ($order === 'RAND') {
49 $orderby = 'none';
50 }
51
52 $gallery_rn = (rand(10,100));
53
54 if (!empty($include)) {
55 $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
56
57 $attachments = array();
58 foreach ($_attachments as $key => $val) {
59 $attachments[$val->ID] = $_attachments[$key];
60 }
61 } elseif (!empty($exclude)) {
62 $attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
63 } else {
64 $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
65 }
66
67 if (empty($attachments)) {
68 return '';
69 }
70
71 if (is_feed()) {
72 $output = "\n";
73 foreach ($attachments as $att_id => $attachment) {
74 $output .= wp_get_attachment_link($att_id, $size, true) . "\n";
75 }
76 return $output;
77 }
78 // NORMAL
79 $output .= '<div id="kad-wp-gallery'.esc_attr($gallery_rn).'" class="kad-wp-gallery kad-light-wp-gallery clearfix rowtight">';
80 if ($columns == '2') {$itemsize = 'tcol-lg-6 tcol-md-6 tcol-sm-6 tcol-xs-12 tcol-ss-12'; $imgsize = 600;}
81 else if ($columns == '1') {$itemsize = 'tcol-lg-12 tcol-md-12 tcol-sm-12 tcol-xs-12 tcol-ss-12'; $imgsize = 1200;}
82 else if ($columns == '3'){ $itemsize = 'tcol-lg-4 tcol-md-4 tcol-sm-4 tcol-xs-6 tcol-ss-12'; $imgsize = 400;}
83 else if ($columns == '6'){ $itemsize = 'tcol-lg-2 tcol-md-2 tcol-sm-3 tcol-xs-4 tcol-ss-6'; $imgsize = 300;}
84 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;}
85 else if ($columns == '12' || $columns == '11'){ $itemsize = 'tcol-lg-1 tcol-md-1 tcol-sm-2 tcol-xs-2 tcol-ss-3'; $imgsize = 240;}
86 else if ($columns == '5'){ $itemsize = 'tcol-lg-25 tcol-md-25 tcol-sm-3 tcol-xs-4 tcol-ss-6'; $imgsize = 300;}
87 else {$itemsize = 'tcol-lg-3 tcol-md-3 tcol-sm-4 tcol-xs-6 tcol-ss-12'; $imgsize = 300;}
88 $i = 0;
89 foreach ($attachments as $id => $attachment) {
90 $attachment_url = wp_get_attachment_url($id);
91 $image = aq_resize($attachment_url, $imgsize, $imgsize, true);
92 if(empty($image)) {$image = $attachment_url;}
93 if($lightboxsize != 'full') {
94 $attachment_url = wp_get_attachment_image_src( $id, $lightboxsize);
95 $attachment_url = $attachment_url[0];
96 }
97 $link = isset($attr['link']) && 'post' == $attr['link'] ? wp_get_attachment_link($id, $size, true, false) : wp_get_attachment_link($id, $size, false, false);
98
99 $output .= '<div class="'.esc_attr($itemsize).' g_item"><div class="grid_item kad_gallery_fade_in gallery_item"><a href="'.esc_url($attachment_url).'" rel="lightbox[pp_gal]" class="lightboxhover">
100 <img src="'.esc_url($image).'" alt="'.esc_attr($attachment->post_excerpt).'" class="light-dropshaddow"/>';
101 $output .= '</a>';
102 $output .= '</div></div>';
103 }
104 $output .= '</div>';
105
106 return $output;
107 }
108 $pinnacle = get_option( 'pinnacle' );
109 $virtue = get_option( 'virtue' );
110 if(! function_exists( 'kadence_gallery' ) ) {
111 if( (isset($pinnacle['pinnacle_gallery']) && $pinnacle['pinnacle_gallery'] == '1') || (isset($virtue['virtue_gallery']) && $virtue['virtue_gallery'] == '1') ) {
112 remove_shortcode('gallery');
113 add_shortcode('gallery', 'kadence_shortcode_gallery');
114 }
115 }