-
Notifications
You must be signed in to change notification settings - Fork 0
/
shortcodes.php
143 lines (88 loc) · 4.14 KB
/
shortcodes.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<?php
function kai_gallery($atts, $content = null) {
extract(shortcode_atts(array(
"gallery_id" => '0',
"gallery_limit" => '4',
"total_items" => '12',
"slider_mode" => "false",
"autoplay" => "false",
"speed" => "5000"
),
$atts));
//Retrieve testimonials from post type
$gallery_args = array(
'post_type' => 'post_gallery',
'p' => $gallery_id,
'post_status' => 'publish',
'posts_per_page' => 1,
);
$pm_gallery_show_rollover_btn = get_option('pm_gallery_show_rollover_btn');
$pm_gallery_show_expand_btn = get_option('pm_gallery_show_expand_btn');
$pm_gallery_zoom_effect = get_option('pm_gallery_zoom_effect');
$pm_gallery_rollover_text = get_option('pm_gallery_rollover_text');
$gallery_query = new WP_Query($gallery_args);
if($slider_mode == "true") {
//Build Slider
$html = '<div id="slide-wrapper">';
$html .= '<div id="slide-window" data-autoplay="'. $autoplay .'" data-autoplayspeed="'. $speed .'">';
$html .= '<ul id="slides">';
if ($gallery_query->have_posts()) : while ($gallery_query->have_posts()) : $gallery_query->the_post();
$pm_post_slides = get_post_meta( get_the_ID(), 'pm_post_slides', true ); //ARRAY VALUE
$slides_length = count($pm_post_slides);
for($i = 0; $i < $slides_length; $i++) {
$html .= '<li class="slide color-'. $i .' alive"><img src="'. esc_url($pm_post_slides[$i]['image']) .'" alt="'. esc_attr($pm_post_slides[$i]['caption']) .'" /></li>';
}
endwhile; else:
endif;
$html .= '</ul>';
$html .= '</div>';
$html .= '<div class="slides-navigation">';
$html .= '<span class="slides-nav-btn" id="slide-left-btn"><i class="fas fa-chevron-left"></i></span>';
$html .= '<span class="slides-nav-btn" id="slide-right-btn"><i class="fas fa-chevron-right"></i></span>';
$html .= '</div>';
$html .= '</div>';
} else {
//Build Gallery layout
if ($gallery_query->have_posts()) : while ($gallery_query->have_posts()) : $gallery_query->the_post();
$pm_post_slides = get_post_meta( get_the_ID(), 'pm_post_slides', true ); //ARRAY VALUE
if( is_array($pm_post_slides) && count($pm_post_slides) > 0 ) {
$page_offset = 0;
$limit = $gallery_limit; //param
$gallery_items = count($pm_post_slides);
$start_index = $page_offset * $limit;
$next_load = $start_index + $limit;
$display_total = $total_items; //param
if($next_load > $gallery_items) {
$next_load = $gallery_items;
}
$html = '<ul class="as-gallery-list'. ($pm_gallery_zoom_effect === "yes" ? ' zoom-on' : '') .'" id="ajax_posts_container">';
for($i = $start_index; $i >= $start_index && $i < $next_load; $i++) {
$html .= '<li>';
$html .= '<a href="'. esc_url($pm_post_slides[$i]['image']) .'" class="lightbox" data-rel="prettyPhoto[gallery]">';
if($pm_gallery_show_rollover_btn === "yes") :
$html .= '<span></span>';
$html .= '<div class="as-gallery-expand-icon"><span class="fas fa-expand"></span> '. esc_attr($pm_gallery_rollover_text) .'</div>';
endif;
$html .= '<img src="'. esc_url($pm_post_slides[$i]['image']) .'" alt="'. esc_attr($pm_post_slides[$i]['caption']) .'" />';
$html .= '</a>';
if($pm_gallery_show_expand_btn === "yes") :
$html .= '<a href="'. esc_url($pm_post_slides[$i]['image']) .'" class="lightbox as-gallery-expand-btn" data-rel="prettyPhoto[gallery]"><i class="fas fa-expand"></i></a>';
endif;
$html .= '</li>';
}
$html .= '</ul>';
if($next_load < $gallery_items) {
$html .= '<div class="as-gallery-load-container" id="load_more_btn_container"><a href="#" id="load_more_btn" data-limit="'.$gallery_limit.'" data-total_items="12" data-gallery_id="'.$gallery_id.'" class="gl-btn offset-color">Load More</a></div>';
$html .= '<div class="lds-dual-ring" id="fw_spinner"></div>';
}
} else {
$html .= '<p>'. esc_attr('No gallery images found.', 'progallery') .'</p>';
}
endwhile; else:
endif;
}//end $slider_mode
wp_reset_postdata();
//return the shortcode
return $html;
}
?>