PluginProbe
WP Directory Kit / 1.5.3
WP Directory Kit v1.5.3
1.5.9 1.5.7 1.5.6 1.5.5 1.5.4 1.5.3 trunk 1.1.0 1.1.6 1.1.8 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.8 All 37 releases
wpdirectorykit / elementor-elements / views / wdk-listing-slider.php

wdk-listing-slider.php in WP Directory Kit 1.5.3, at elementor-elements/views/wdk-listing-slider.php

331 lines 19.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * The template for Element Listing Images Slider.
5 * This is the template that elementor element slider, carousel
6 *
7 */
8
9 if (! defined('ABSPATH')) {
10 exit; // Exit if accessed directly.
11 }
12 ?>
13 <div class="wdk-element" id="wdk_el_<?php echo esc_html($id_element); ?>">
14 <div class="wdk-listing-slider">
15 <?php
16 // Organize images into tabs: gallery, plans, custom fields
17 $tabs = [];
18
19 // Gallery Tab
20 $tabs['gallery'] = [];
21 foreach ($images as $key => $image) {
22 $type = 'gallery';
23 if (strpos($key, '__') !== FALSE) {
24 $type = substr($key, 0, strpos($key, '__'));
25 }
26 if ($type === 'gallery') {
27 $tabs['gallery'][$key] = $image;
28 }
29 }
30
31 // Plans tab if exists
32 if (!empty($plans_exists)) {
33 $tabs['plans'] = [];
34 foreach ($images as $key => $image) {
35 $type = 'gallery';
36 if (strpos($key, '__') !== FALSE) {
37 $type = substr($key, 0, strpos($key, '__'));
38 }
39 if ($type === 'plans') {
40 $tabs['plans'][$key] = $image;
41 }
42 }
43 }
44
45 // Custom fields (images_fields) tabs if exists
46 if (!empty($images_fields)) {
47 foreach ($images_fields as $field_id => $field_images) {
48 $tabs[$field_id] = [];
49 foreach ($images as $key => $image) {
50 $field_images_id = 'gallery';
51 if (strpos($key, '__') !== FALSE) {
52 $field_images_id = substr($key, 0, strpos($key, '__'));
53 }
54 if ($field_images_id == $field_id) {
55 $tabs[$field_id][$key] = $image;
56 }
57 }
58 }
59 }
60 // Only make tabs if we have images for them
61 $tab_keys = array_filter(array_keys($tabs), function($tab_key) use ($tabs) {
62 return !empty($tabs[$tab_key]);
63 });
64 ?>
65
66 <?php if (count($images) > 0): ?>
67 <?php if (count($tab_keys) > 1): ?>
68 <div class="elementor-section elementor-section-boxed">
69 <div class="elementor-container">
70 <div class="wdk-listing-slider--tabs">
71 <?php foreach ($tab_keys as $tab_key): ?>
72 <a data-tab="<?php echo esc_attr($tab_key); ?>" href="#" class="wdk-listing-slider--tabs--btn <?php echo $tab_key === 'gallery' ? 'active' : ''; ?>">
73 <?php
74 if ($tab_key === 'gallery') {
75 echo esc_html__('Gallery', 'wpdirectorykit');
76 } elseif ($tab_key === 'plans') {
77 echo esc_html__('Plans', 'wpdirectorykit');
78 } else {
79 echo esc_html(wdk_field_label($tab_key));
80 }
81 ?>
82 </a>
83 <?php endforeach; ?>
84 </div>
85 </div>
86 </div>
87 <?php endif; ?>
88
89 <div class="wdk-listing-slider--content-tabs">
90 <?php foreach ($tab_keys as $tab_key): ?>
91 <div class="wdk-listing-slider--tab-pane<?php if ($tab_key === 'gallery') echo ' active'; ?>" id="wdk_list_slider_tab_<?php echo esc_attr($tab_key); ?>">
92 <div class="<?php if ($settings['popup_enable'] == 'yes'): ?> wdk_js_gallery <?php endif; ?> wdk_listing_slider_box <?php echo esc_attr($settings['layout_carousel_animation_style']) . '_animation'; ?> <?php echo esc_attr(join(' ', [$settings['styles_carousel_dots_position_style'], $settings['styles_carousel_arrows_position_style'], $settings['styles_carousel_arrows_position'], $settings['styles_carousel_arrows_position_style']])); ?>">
93 <div class="wdk_listing_slider_ini" id="wdk_slider_<?php echo esc_attr($tab_key); ?>">
94 <?php foreach ($tabs[$tab_key] as $key => $image): ?>
95 <?php
96 $type = $tab_key;
97 ?>
98 <?php if (
99 is_string($image) && (
100 filter_var($image, FILTER_VALIDATE_URL) ||
101 preg_match('/^www\./i', $image)
102 )
103 ): ?>
104 <div class="wdk-col" data-type="<?php echo esc_html($type); ?>">
105 <div class="wdk-listing-image-card">
106 <?php if (strpos($image, 'vimeo.com') !== FALSE): ?>
107 <div class="wdk-listing-image wdk-listing-video-embed<?php if ($settings['enable_fixed_height'] != 'yes'): ?> auto_height<?php endif; ?>">
108 <?php echo wp_oembed_get($image, array("width" => "800", "height" => "450")); ?>
109 </div>
110 <?php elseif (strpos($image, 'watch?v=') !== FALSE): ?>
111 <?php $embed_code = substr($image, strpos($image, 'watch?v=') + 8); ?>
112 <div class="wdk-listing-image wdk-listing-video-embed<?php if ($settings['enable_fixed_height'] != 'yes'): ?> auto_height<?php endif; ?>">
113 <?php echo wp_oembed_get('https://www.youtube.com/watch?v=' . $embed_code, array("width" => "800", "height" => "455")); ?>
114 </div>
115 <?php elseif (strpos($image, 'youtube.com/shorts/') !== FALSE): ?>
116 <?php $embed_code = substr($image, strpos($image, 'shorts') + 7); ?>
117 <div class="wdk-listing-image wdk-listing-video-embed<?php if ($settings['enable_fixed_height'] != 'yes'): ?> auto_height<?php endif; ?>">
118 <?php echo wp_oembed_get('https://www.youtube.com/watch?v=' . $embed_code, array("width" => "800", "height" => "455")); ?>
119 </div>
120 <?php elseif (strpos($image, 'youtu.be/') !== FALSE): ?>
121 <?php $embed_code = substr($image, strpos($image, 'youtu.be/') + 9); ?>
122 <div class="wdk-listing-image wdk-listing-video-embed<?php if ($settings['enable_fixed_height'] != 'yes'): ?> auto_height<?php endif; ?>">
123 <?php echo wp_oembed_get('https://www.youtube.com/watch?v=' . $embed_code, array("width" => "800", "height" => "455")); ?>
124 </div>
125 <?php elseif (filter_var($image, FILTER_VALIDATE_URL) !== FALSE && preg_match('/\.(mp4|flv|wmw|ogv|webm|ogg)$/i', $image)): ?>
126 <video
127 src="<?php echo esc_url($image); ?>"
128 controls
129 class="wdk-listing-image <?php if ($settings['enable_fixed_height'] != 'yes'): ?> auto_height<?php endif; ?>"
130 <?php if (wmvc_show_data('auto_start_video', $settings, false) == 'yes'): ?> autoplay loop<?php endif; ?>
131 >
132 </video>
133 <?php else: ?>
134 <iframe
135 src="<?php echo esc_url($image); ?>" width="100%" frameborder="0" allowfullscreen
136 class="wdk-listing-image <?php if ($settings['enable_fixed_height'] != 'yes'): ?> auto_height <?php endif; ?>"></iframe>
137 <?php endif; ?>
138 </div>
139 </div>
140 <?php elseif (!wmvc_show_data('wdk_listing_video_disabled', $settings, false) && wdk_file_extension_type(wmvc_show_data('src', $image)) == 'video'): ?>
141 <div class="wdk-col" data-type="<?php echo esc_html($type); ?>">
142 <div class="wdk-listing-image-card">
143 <video controls loop <?php if (wmvc_show_data('auto_start_video', $settings, false) == 'yes'): ?> autoplay <?php endif; ?> src="<?php echo esc_url(wmvc_show_data('src', $image)); ?>" alt="<?php echo esc_attr(wmvc_show_data('alt', $image)); ?>" class="wdk-listing-image <?php if ($settings['enable_fixed_height'] != 'yes'): ?> auto_height <?php endif; ?>"></video>
144
145 </div>
146 </div>
147 <?php elseif (wdk_file_extension_type(wmvc_show_data('src', $image)) == 'image'): ?>
148 <div class="wdk-col" data-type="<?php echo esc_html($type); ?>">
149 <div class="wdk-listing-image-card">
150 <img
151 src="<?php echo esc_url(wmvc_show_data('src', $image)); ?>"
152 class="wdk-listing-image<?php if ($settings['enable_fixed_height'] != 'yes'): ?> auto_height<?php endif; ?>"
153 alt="<?php echo esc_attr(wmvc_show_data('alt', $image)); ?>">
154 </div>
155 </div>
156 <?php endif; ?>
157 <?php endforeach; ?>
158
159 <?php if (!empty($tabs[$tab_key]) && wmvc_show_data('layout_carousel_columns', $settings, 1) < wmvc_count($tabs[$tab_key])): ?>
160 </div>
161 <div class="wdk-listing-slider_arrows">
162 <a title="<?php echo esc_attr__('prev slider', 'wpdirectorykit'); ?>" href="#" class="wdk-slider-prev wdk-listing-slider_arrow">
163 <?php \Elementor\Icons_Manager::render_icon($settings['styles_carousel_arrows_icon_left'], ['aria-hidden' => 'true']); ?>
164 </a>
165 <a title="<?php echo esc_attr__('next slider', 'wpdirectorykit'); ?>" href="#" class="wdk-slider-next wdk-listing-slider_arrow">
166 <?php \Elementor\Icons_Manager::render_icon($settings['styles_carousel_arrows_icon_right'], ['aria-hidden' => 'true']); ?>
167 </a>
168 </div>
169 <?php else: ?>
170 </div>
171 <?php endif; ?>
172 </div>
173 <?php
174 // Thumbs
175 if (count($tabs[$tab_key]) > 1): ?>
176 <div class="banner-thumbs-con elementor-section elementor-section-boxed">
177 <div class="elementor-container">
178 <div class="banner-thumbs" id="banner_thumbs_<?php echo esc_attr($tab_key); ?>">
179 <?php foreach ($tabs[$tab_key] as $key => $image): ?>
180 <?php
181 $type = $tab_key;
182 ?>
183 <?php if (
184 is_string($image) && (
185 filter_var($image, FILTER_VALIDATE_URL) ||
186 preg_match('/^www\./i', $image)
187 )
188 ): ?>
189
190 <?php elseif (!wmvc_show_data('wdk_listing_video_disabled', $settings, false) && wdk_file_extension_type(wmvc_show_data('src', $image)) == 'video'): ?>
191 <div class="banner-thumb" data-type="<?php echo esc_html($type); ?>">
192 <video src="<?php echo esc_url(wmvc_show_data('src', $image)); ?>" alt="<?php echo esc_attr(wmvc_show_data('alt', $image)); ?>" class="wdk-listing-image <?php if ($settings['enable_fixed_height'] != 'yes'): ?> auto_height <?php endif; ?>"></video>
193 </div>
194 <?php elseif (wdk_file_extension_type(wmvc_show_data('src', $image)) == 'image'): ?>
195 <div class="banner-thumb" data-type="<?php echo esc_html($type); ?>">
196 <img src="<?php echo esc_url(wmvc_show_data('src', $image)); ?>" class="wdk-listing-image <?php if ($settings['enable_fixed_height'] != 'yes'): ?> auto_height <?php endif; ?>" alt="<?php echo esc_attr(wmvc_show_data('alt', $image)); ?>">
197 </div>
198 <?php endif; ?>
199 <?php endforeach; ?>
200 </div><!--banner-thumbs end-->
201 </div>
202 </div>
203 <?php endif; ?>
204 </div>
205 <?php endforeach; ?>
206 </div> <!-- .wdk-listing-slider--content-tabs -->
207 <?php endif; ?>
208 </div>
209 </div>
210 <script>
211 jQuery(document).ready(function($){
212 function initTabSlider(tab_key) {
213 var sliderSelector = '#wdk_slider_' + tab_key;
214 var thumbsSelector = '#banner_thumbs_' + tab_key;
215
216 // destroy before re-init
217 if ($(sliderSelector).hasClass('slick-initialized')) {
218 $(sliderSelector).slick('unslick');
219 }
220 if ($(thumbsSelector).length && $(thumbsSelector).hasClass('slick-initialized')) {
221 $(thumbsSelector).slick('unslick');
222 }
223
224 $(sliderSelector).slick({
225 <?php if (!empty($images) && wmvc_show_data('layout_carousel_columns', $settings, 1) < wmvc_count($images)): ?>
226 dots: true,
227 arrows: true,
228 <?php else: ?>
229 dots: false,
230 arrows: false,
231 <?php endif; ?>
232 slidesToShow: <?php echo wmvc_show_data('layout_carousel_columns', $settings, 1); ?>,
233 slidesToScroll: <?php echo wmvc_show_data('layout_carousel_columns', $settings, 1); ?>,
234 <?php if (!empty(wmvc_show_data('layout_carousel_is_infinite', $settings))): ?>
235 infinite: <?php echo wmvc_show_data('layout_carousel_is_infinite', $settings, 'true'); ?>,
236 <?php endif; ?>
237 <?php if (!empty(wmvc_show_data('layout_carousel_is_autoplay', $settings))): ?>
238 autoplay: <?php echo wmvc_show_data('layout_carousel_is_autoplay', $settings, 'false'); ?>,
239 <?php endif; ?>
240 nextArrow: $('#wdk_el_<?php echo esc_html($id_element); ?> #wdk_list_slider_tab_'+tab_key+' .wdk-listing-slider_arrows .wdk-slider-next'),
241 prevArrow: $('#wdk_el_<?php echo esc_html($id_element); ?> #wdk_list_slider_tab_'+tab_key+' .wdk-listing-slider_arrows .wdk-slider-prev'),
242 customPaging: function(slider, i) {
243 return '<span class="wdk_lr_dot"><?php \Elementor\Icons_Manager::render_icon($settings['styles_carousel_dots_icon'], ['aria-hidden' => 'true']); ?></span>';
244 },
245 responsive: [{
246 breakpoint: 600,
247 settings: {
248 slidesToShow: 1,
249 slidesToScroll: 1
250 }
251 }],
252 asNavFor: thumbsSelector.length ? thumbsSelector : null
253 });
254
255 if ($(thumbsSelector).length) {
256 $(thumbsSelector).slick({
257 slidesToShow: <?php echo (!empty(trim(wmvc_show_data('styles_thmbn_nav_columns', $settings, '4')))) ? wmvc_show_data('styles_thmbn_nav_columns', $settings, '4') : 4; ?>,
258 slidesToScroll: 1,
259 asNavFor: sliderSelector,
260 dots: false,
261 centerMode: false,
262 arrows: false,
263 focusOnSelect: true,
264 responsive: [{
265 breakpoint: 991,
266 settings: {
267 slidesToShow: <?php echo (!empty(trim(wmvc_show_data('styles_thmbn_nav_columns_tablet', $settings, '3')))) ? wmvc_show_data('styles_thmbn_nav_columns_tablet', $settings, '3') : 3; ?>,
268 }
269 },
270 {
271 breakpoint: 768,
272 settings: {
273 slidesToShow: <?php echo (!empty(trim(wmvc_show_data('styles_thmbn_nav_columns_mobile', $settings, '2')))) ? wmvc_show_data('styles_thmbn_nav_columns_mobile', $settings, '2') : 2; ?>,
274 }
275 },
276 ]
277 });
278 }
279
280 // Sync thumb highlight after change
281 $(sliderSelector).on('afterChange', function(event, slick, currentSlide) {
282 if ($(thumbsSelector).length) {
283 $(thumbsSelector).find('.slick-slide').removeClass('is-active');
284 $(thumbsSelector).find('.slick-slide[data-slick-index="' + currentSlide + '"]').addClass('is-active');
285 }
286 });
287
288 $(sliderSelector).on('reInit afterChange', function(event, slick, currentSlide) {
289 var visibleSlides = $(sliderSelector).find('.slick-slide:not(.slick-cloned):visible').length;
290 if (visibleSlides <= 1) {
291 $('#wdk_el_<?php echo esc_html($id_element); ?> #wdk_list_slider_tab_'+tab_key+' .slick-arrow').hide();
292 } else {
293 $('#wdk_el_<?php echo esc_html($id_element); ?> #wdk_list_slider_tab_'+tab_key+' .slick-arrow').show();
294 }
295 });
296 }
297
298 // On load: initialize all tabs, show only active
299 $('.wdk-listing-slider--tab-pane').hide();
300 $('.wdk-listing-slider--tab-pane.active').show();
301
302 // Initialize the visible slider only, or all if you like
303 var firstTab = $('.wdk-listing-slider--tab-pane.active').attr('id');
304 if (firstTab) {
305 var firstTabKey = firstTab.replace('wdk_list_slider_tab_', '');
306 initTabSlider(firstTabKey);
307 }
308
309 // Change tabs event
310 $(document).on('click', '.wdk-listing-slider--tabs--btn', function(e){
311 e.preventDefault();
312 var $this = $(this);
313 var tabKey = $this.data('tab');
314 $('.wdk-listing-slider--tabs--btn').removeClass('active');
315 $this.addClass('active');
316 $('.wdk-listing-slider--tab-pane').removeClass('active').hide();
317 $('#wdk_list_slider_tab_'+tabKey).addClass('active').show();
318
319 // destroy all others
320 $('.wdk_listing_slider_ini.slick-initialized').not('#wdk_slider_'+tabKey).each(function(){
321 $(this).slick('unslick');
322 });
323 $('.banner-thumbs.slick-initialized').not('#banner_thumbs_'+tabKey).each(function(){
324 $(this).slick('unslick');
325 });
326
327 // init for this tab if not already initialized
328 initTabSlider(tabKey);
329 });
330 });
331 </script>