PluginProbe
Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder / 3.1.4
Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder v3.1.4
3.1.4 3.0.8 3.0.9 3.1.0 3.1.2 3.1.3 3.0.7 3.0.5 3.0.4 3.0.3 3.0.2 trunk 1.5.0 1.5.1 1.5.2 1.6.1 1.6.2 1.6.3 1.6.4 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 All 93 releases
← All changes | traits/global-widget-template.php +681 -557 1.5.0 → 3.1.4 View file →
@@ -1,557 +1,681 @@
1 -<?php
2 -
3 -namespace UltimateStoreKit\Traits;
4 -
5 -use Elementor\Plugin;
6 -
7 -// use WP_Query;
8 -
9 -
10 -defined('ABSPATH') || die();
11 -
12 -trait Global_Widget_Template {
13 -
14 - protected function register_global_template_wc_rating($rating, $count = 0) {
15 - $html = '';
16 - if (
17 - 0 <= $rating
18 - ) {
19 - /* translators: %s: rating */
20 - // $label = sprintf(__('Rated %s out of 5', 'woocommerce'), $rating);
21 - $html = '<div class="star-rating" role="img">' . wc_get_star_rating_html($rating, $count) . '</div>';
22 - }
23 -
24 - return apply_filters('woocommerce_product_get_rating_html', $html, $rating, $count);
25 - }
26 - public function register_global_template_add_to_wishlist($tooltip_position) {
27 - $settings = $this->get_settings_for_display();
28 - global $product;
29 - $user_id = get_current_user_id();
30 - $product_id = $product->get_ID();
31 - $wishlist = ultimate_store_kit_get_wishlist($user_id);
32 - $is_wishlisted = in_array($product_id, $wishlist);
33 - if (!empty($is_wishlisted)) {
34 - $selected = ' usk-active';
35 - $tooltip = esc_html__('Wishlist item Added!', 'ultimate-store-kit');
36 - } else {
37 - $selected = '';
38 - $tooltip = esc_html__('Add to Wishlist', 'ultimate-store-kit');
39 - } ?>
40 - <?php if ($settings['show_wishlist'] == 'yes') : ?>
41 - <a href="javascript:void(0);" class="usk-action-btn ajax_add_to_wishlist usk-shoping-icon-wishlist usk-btn usk-wishlist<?php echo esc_attr($selected); ?>" data-product_id="<?php echo absint($product_id); ?>" aria-label="<?php echo esc_html__($tooltip); ?>" data-microtip-position="<?php echo esc_attr($tooltip_position); ?>" role="tooltip">
42 - <i class="icon eicon-heart"></i>
43 - </a>
44 - <?php endif; ?>
45 - <?php
46 - }
47 -
48 - function register_global_template_add_to_compare($tooltip_position) {
49 - global $product;
50 - $settings = $this->get_settings_for_display();
51 - $user_id = get_current_user_id();
52 - $product_id = $product->get_ID();
53 - $compare_products = usk_get_compare_products($user_id);
54 - $is_compared = in_array($product_id, $compare_products);
55 -
56 - if (!empty($is_compared)) {
57 - $tooltip = esc_html__('Added', 'ultimate-store-kit');
58 - $selected = 'usk-active';
59 - } else {
60 - $tooltip = esc_html__('Compare', 'ultimate-store-kit');
61 - $selected = '';
62 - } ?>
63 - <?php if ($settings['show_compare'] == 'yes') : ?>
64 - <a href="javascript:void(0)" class="usk-action-btn ajax_add_to_compare usk-compare <?php echo esc_attr($selected); ?>" data-product_id="<?php echo $product_id; ?>" aria-label="<?php echo esc_html__($tooltip); ?>" data-microtip-position="<?php echo esc_attr($tooltip_position); ?>" role="tooltip">
65 - <i class="icon eicon-flow"></i>
66 - </a>
67 - <?php
68 - ?>
69 - <?php endif; ?>
70 - <?php
71 -
72 - }
73 -
74 -
75 - protected function register_global_template_quick_view($product_id, $tooltip_position) {
76 - $settings = $this->get_settings_for_display();
77 - if ('yes' == $settings['show_quick_view']) : ?>
78 - <?php wp_nonce_field('ajax-usk-quick-view-nonce', 'usk-quick-view-modal-sc');
79 - ?>
80 - <a class="usk-action-btn usk-shoping-icon-quickview quick_view usk-view usk-btn" href="javascript:void(0)" data-id="<?php echo absint($product_id); ?>" aria-label="<?php echo esc_html__('Quick View'); ?>" data-microtip-position="<?php echo esc_attr($tooltip_position); ?>" role="tooltip">
81 - <i class="icon eicon-preview-medium"></i>
82 - </a>
83 - <?php endif;
84 - }
85 - protected function register_global_template_add_to_cart($tooltip_position) {
86 - global $product;
87 - $settings = $this->get_settings_for_display();
88 - if ('yes' == $settings['show_cart']) : ?>
89 - <?php if ($product) {
90 - $defaults = [
91 - 'quantity' => 1,
92 - 'class' => implode(
93 - ' ',
94 - array_filter(
95 - [
96 - 'usk-cart',
97 - 'usk-action-btn',
98 - 'product_type_' . $product->get_type(),
99 - $product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '',
100 - $product->supports('ajax_add_to_cart') && $product->is_purchasable() && $product->is_in_stock() ? 'ajax_add_to_cart' : '',
101 - ]
102 - )
103 - ),
104 - 'attributes' => [
105 - 'data-product_id' => $product->get_id(),
106 - 'data-product_sku' => $product->get_sku(),
107 - 'data-microtip-position' => $tooltip_position,
108 - 'aria-label' => $product->add_to_cart_text(),
109 - 'rel' => 'nofollow',
110 - 'role' => 'tooltip',
111 - ],
112 - ];
113 - $args = apply_filters('woocommerce_loop_add_to_cart_args', wp_parse_args($defaults), $product);
114 - if (isset($args['attributes']['aria-label'])) {
115 - $args['attributes']['aria-label'] = wp_strip_all_tags($args['attributes']['aria-label']);
116 - }
117 - echo apply_filters(
118 - 'woocommerce_loop_add_to_cart_link', // WPCS: XSS ok.
119 - sprintf(
120 - '<a href="%s" data-quantity="%s" class="%s" %s><i class="icon eicon-cart-light"></i></a>',
121 - esc_url($product->add_to_cart_url()),
122 - esc_attr(isset($args['quantity']) ? $args['quantity'] : 1),
123 - esc_attr(isset($args['class']) ? $args['class'] : 'button'),
124 - isset($args['attributes']) ? wc_implode_html_attributes($args['attributes']) : ''
125 - ),
126 - $product,
127 - $args
128 - );
129 - }; ?>
130 - <?php endif;
131 - }
132 - protected function register_global_template_badge_label() {
133 - $settings = $this->get_settings_for_display();
134 - global $product;
135 - if ($product->is_on_sale() && $settings['show_sale_badge']) :
136 - printf('<div class="usk-badge-wrap usk-sale-badge"><span class="usk-badge">%1$s</span></div>', esc_html__('Sale', 'ultimate-store-kit'));
137 - endif;
138 - if ($settings['show_discount_badge']) :
139 - $this->usk_get_badge_label_percentage();
140 - endif;
141 - if (($settings['show_stock_status'] === 'yes')) :
142 - if ($product->get_stock_status() === 'instock') {
143 - $stock_status = esc_html__('In Stock', 'ultimate-store-kit');
144 - } else {
145 - $stock_status = esc_html__('Out of Stock', 'ultimate-store-kit');
146 - }
147 -
148 - printf('<div class="usk-badge-wrap usk-stock-status-badge"><span class="usk-badge">%1$s</span></div>', $stock_status);
149 - endif;
150 - if ($product->is_featured() && $settings['show_trending_badge']) :
151 - printf('<div class="usk-badge-wrap usk-trending-badge"><span class="usk-badge">%1$s</span></div>', esc_html__('Trending', 'ultimate-store-kit'));
152 - endif;
153 - if ($settings['show_new_badge']) :
154 - $newness_days = $settings['newness_days'];
155 - $created_date = strtotime($product->get_date_created());
156 - $valid_date = time() - (60 * 60 * 24 * $newness_days);
157 - if ($valid_date < $created_date) {
158 - printf('<div class="usk-badge-wrap usk-new-badge"><span class="usk-badge">%s</span></div>', esc_html__('New', 'ultimate-store-kit'));
159 - }
160 - endif;
161 - }
162 - protected function register_global_template_navigation() {
163 - $settings = $this->get_settings_for_display();
164 - $hide_arrow_on_mobile = $settings['hide_arrow_on_mobile'] ? ' usk-visible@m' : '';
165 -
166 - if ('arrows' == $settings['navigation']) : ?>
167 - <div style="direction: ltr;" class="usk-position-z-index usk-position-<?php echo esc_html($settings['arrows_position'] . $hide_arrow_on_mobile); ?>">
168 - <div class="usk-arrows-container usk-slidenav-container">
169 - <a href="" class="usk-navigation-prev usk-slidenav-previous usk-icon usk-slidenav">
170 - <i class="usk-icon-arrow-left-<?php echo esc_html($settings['nav_arrows_icon']); ?>" aria-hidden="true"></i>
171 - </a>
172 - <a href="" class="usk-navigation-next usk-slidenav-next usk-icon usk-slidenav">
173 - <i class="usk-icon-arrow-right-<?php echo esc_html($settings['nav_arrows_icon']); ?>" aria-hidden="true"></i>
174 - </a>
175 - </div>
176 - </div>
177 - <?php endif;
178 - }
179 - protected function register_global_template_pagination() {
180 - $settings = $this->get_settings_for_display();
181 -
182 - if ('dots' == $settings['navigation'] or 'arrows-fraction' == $settings['navigation']) : ?>
183 - <div class="usk-position-z-index usk-position-<?php echo esc_html($settings['dots_position']); ?>">
184 - <div class="usk-dots-container">
185 - <div class="swiper-pagination"></div>
186 - </div>
187 - </div>
188 -
189 - <?php elseif ('progressbar' == $settings['navigation']) : ?>
190 - <div class="swiper-pagination usk-position-z-index usk-position-<?php echo esc_html($settings['progress_position']); ?>"></div>
191 - <?php endif;
192 - }
193 - protected function register_global_template_both_navigation() {
194 - $settings = $this->get_settings_for_display();
195 - $hide_arrow_on_mobile = $settings['hide_arrow_on_mobile'] ? 'usk-visible@m usk-flex' : 'usk-flex';
196 -
197 - ?>
198 - <div class="usk-position-z-index usk-position-<?php echo esc_html($settings['both_position']); ?>">
199 - <div class="usk-arrows-dots-container usk-slidenav-container ">
200 -
201 - <div class="usk-flex usk-flex-middle">
202 - <div class="<?php echo esc_html($hide_arrow_on_mobile); ?>">
203 - <a href="" class="usk-navigation-prev usk-slidenav-previous usk-icon usk-slidenav">
204 - <i class="usk-icon-arrow-left-<?php echo esc_html($settings['nav_arrows_icon']); ?>" aria-hidden="true"></i>
205 - </a>
206 - </div>
207 -
208 - <?php if ('center' !== $settings['both_position']) : ?>
209 - <div class="swiper-pagination"></div>
210 - <?php endif; ?>
211 -
212 - <div class="<?php echo esc_html($hide_arrow_on_mobile); ?>">
213 - <a href="" class="usk-navigation-next usk-slidenav-next usk-icon usk-slidenav">
214 - <i class="usk-icon-arrow-right-<?php echo esc_html($settings['nav_arrows_icon']); ?>" aria-hidden="true"></i>
215 - </a>
216 - </div>
217 -
218 - </div>
219 - </div>
220 - </div>
221 - <?php
222 - }
223 - protected function register_global_template_arrows_fraction() {
224 - $settings = $this->get_settings_for_display();
225 - $hide_arrow_on_mobile = $settings['hide_arrow_on_mobile'] ? 'usk-visible@m' : ''; ?>
226 - <div class="usk-position-z-index usk-position-<?php echo esc_html($settings['arrows_fraction_position']); ?>">
227 - <div class="usk-arrows-fraction-container usk-slidenav-container ">
228 -
229 - <div class="usk-flex usk-flex-middle">
230 - <div class="<?php echo esc_html($hide_arrow_on_mobile); ?>">
231 - <a href="" class="usk-navigation-prev usk-slidenav-previous usk-icon usk-slidenav">
232 - <i class="usk-icon-arrow-left-<?php echo esc_html($settings['nav_arrows_icon']); ?>" aria-hidden="true"></i>
233 - </a>
234 - </div>
235 -
236 - <?php if ('center' !== $settings['arrows_fraction_position']) : ?>
237 - <div class="swiper-pagination"></div>
238 - <?php endif; ?>
239 -
240 - <div class="<?php echo esc_html($hide_arrow_on_mobile); ?>">
241 - <a href="" class="usk-navigation-next usk-slidenav-next usk-icon usk-slidenav">
242 - <i class="usk-icon-arrow-right-<?php echo esc_html($settings['nav_arrows_icon']); ?>" aria-hidden="true"></i>
243 - </a>
244 - </div>
245 -
246 - </div>
247 - </div>
248 - </div>
249 - <?php
250 - }
251 - protected function usk_register_global_template_carousel_footer() {
252 - $settings = $this->get_settings_for_display(); ?>
253 - </div>
254 - <?php if ('yes' === $settings['show_scrollbar']) : ?>
255 - <div class="swiper-scrollbar"></div>
256 - <?php endif; ?>
257 - </div>
258 - <?php if ('both' == $settings['navigation']) : ?>
259 - <?php $this->register_global_template_both_navigation(); ?>
260 - <?php if ('center' === $settings['both_position']) : ?>
261 - <div class="usk-position-z-index usk-position-bottom">
262 - <div class="usk-dots-container">
263 - <div class="swiper-pagination"></div>
264 - </div>
265 - </div>
266 - <?php endif; ?>
267 - <?php elseif ('arrows-fraction' == $settings['navigation']) : ?>
268 - <?php $this->register_global_template_arrows_fraction(); ?>
269 - <?php if ('center' === $settings['arrows_fraction_position']) : ?>
270 - <div class="usk-dots-container">
271 - <div class="swiper-pagination"></div>
272 - </div>
273 - <?php endif; ?>
274 - <?php else : ?>
275 - <?php $this->register_global_template_pagination() ?>
276 - <?php $this->register_global_template_navigation() ?>
277 - <?php endif; ?>
278 - </div>
279 - </div>
280 - </div>
281 -
282 - <?php
283 - }
284 - protected function register_global_template_carousel_header() {
285 - $settings = $this->get_settings_for_display();
286 - $this->add_render_attribute('usk-carousel-wrapper', 'class', ['' . $this->get_name() . '', 'usk-content-position-' . $settings['alignment'] . '']);
287 - $id = 'ultimate-store-kit-' . $this->get_id();
288 - $elementor_vp_lg = get_option('elementor_viewport_lg');
289 - $elementor_vp_md = get_option('elementor_viewport_md');
290 - $viewport_lg = !empty($elementor_vp_lg) ? $elementor_vp_lg - 1 : 1023;
291 - $viewport_md = !empty($elementor_vp_md) ? $elementor_vp_md - 1 : 767;
292 - $this->add_render_attribute('carousel', 'id', $id);
293 - $this->add_render_attribute('carousel', 'class', ['usk-carousel', 'usk-carousel-layout', 'elementor-swiper']);
294 - if ('arrows' == $settings['navigation']) {
295 - $this->add_render_attribute('carousel', 'class', 'usk-arrows-align-' . $settings['arrows_position']);
296 - } elseif ('dots' == $settings['navigation']) {
297 - $this->add_render_attribute('carousel', 'class', 'usk-dots-align-' . $settings['dots_position']);
298 - } elseif ('both' == $settings['navigation']) {
299 - $this->add_render_attribute('carousel', 'class', 'usk-arrows-dots-align-' . $settings['both_position']);
300 - } elseif ('arrows-fraction' == $settings['navigation']) {
301 - $this->add_render_attribute('carousel', 'class', 'usk-arrows-dots-align-' . $settings['arrows_fraction_position']);
302 - }
303 -
304 - if ('arrows-fraction' == $settings['navigation']) {
305 - $pagination_type = 'fraction';
306 - } elseif ('both' == $settings['navigation'] or 'dots' == $settings['navigation']) {
307 - $pagination_type = 'bullets';
308 - } elseif ('progressbar' == $settings['navigation']) {
309 - $pagination_type = 'progressbar';
310 - } else {
311 - $pagination_type = '';
312 - }
313 -
314 - $this->add_render_attribute(
315 - [
316 - 'carousel' => [
317 - 'data-settings' => [
318 - wp_json_encode(array_filter([
319 - "autoplay" => ("yes" == $settings["autoplay"]) ? ["delay" => $settings["autoplay_speed"]] : false,
320 - "loop" => ($settings["loop"] == "yes") ? true : false,
321 - "speed" => $settings["speed"]["size"],
322 - "pauseOnHover" => ("yes" == $settings["pauseonhover"]) ? true : false,
323 - "slidesPerView" => isset($settings["columns_mobile"]) ? (int)$settings["columns_mobile"] : 1,
324 - "slidesPerGroup" => isset($settings["slides_to_scroll_mobile"]) ? (int)$settings["slides_to_scroll_mobile"] : 1,
325 - "spaceBetween" => $settings["items_gap"]["size"],
326 - "centeredSlides" => ($settings["centered_slides"] === "yes") ? true : false,
327 - "grabCursor" => ($settings["grab_cursor"] === "yes") ? true : false,
328 - "effect" => $settings["skin"],
329 - "observer" => ($settings["observer"]) ? true : false,
330 - "observeParents" => ($settings["observer"]) ? true : false,
331 - // "direction" => $settings['direction'],
332 - "watchSlidesVisibility" => true,
333 - "watchSlidesProgress" => true,
334 - "breakpoints" => [
335 - (int) $viewport_md => [
336 - "slidesPerView" => isset($settings["columns_tablet"]) ? (int)$settings["columns_tablet"] : 2,
337 - "spaceBetween" => $settings["items_gap"]["size"],
338 - "slidesPerGroup" => isset($settings["slides_to_scroll_tablet"]) ? (int)$settings["slides_to_scroll_tablet"] : 1,
339 - ],
340 - (int) $viewport_lg => [
341 - "slidesPerView" => isset($settings["columns"]) ? (int)$settings["columns"] : 3,
342 - "spaceBetween" => $settings["items_gap"]["size"],
343 - "slidesPerGroup" => isset($settings["slides_to_scroll"]) ? (int)$settings["slides_to_scroll"] : 1,
344 - ]
345 - ],
346 - "navigation" => [
347 - "nextEl" => "#" . $id . " .usk-navigation-next",
348 - "prevEl" => "#" . $id . " .usk-navigation-prev",
349 - ],
350 - "pagination" => [
351 - "el" => "#" . $id . " .swiper-pagination",
352 - "type" => $pagination_type,
353 - "clickable" => "true",
354 - 'dynamicBullets' => ("yes" == $settings["dynamic_bullets"]) ? true : false,
355 - ],
356 - "scrollbar" => [
357 - "el" => "#" . $id . " .swiper-scrollbar",
358 - "hide" => "true",
359 - ],
360 - 'coverflowEffect' => [
361 - 'rotate' => ("yes" == $settings["coverflow_toggle"]) ? $settings["coverflow_rotate"]["size"] : 50,
362 - 'stretch' => ("yes" == $settings["coverflow_toggle"]) ? $settings["coverflow_stretch"]["size"] : 0,
363 - 'depth' => ("yes" == $settings["coverflow_toggle"]) ? $settings["coverflow_depth"]["size"] : 100,
364 - 'modifier' => ("yes" == $settings["coverflow_toggle"]) ? $settings["coverflow_modifier"]["size"] : 1,
365 - 'slideShadows' => true,
366 - ],
367 -
368 - ]))
369 - ]
370 - ]
371 - ]
372 - );
373 -
374 - $swiper_class = Plugin::$instance->experiments->is_feature_active( 'e_swiper_latest' ) ? 'swiper' : 'swiper-container';
375 - $this->add_render_attribute('swiper', 'class', 'swiper-carousel ' . $swiper_class);
376 -
377 - ?>
378 -
379 - <div class="ultimate-store-kit">
380 - <div <?php $this->print_render_attribute_string('usk-carousel-wrapper'); ?>>
381 - <div <?php $this->print_render_attribute_string('carousel'); ?>>
382 - <div <?php echo $this->get_render_attribute_string('swiper'); ?>>
383 - <div class="swiper-wrapper">
384 - <?php
385 - }
386 - protected function usk_get_badge_label_percentage() {
387 - global $product;
388 - if ($product->is_on_sale()) {
389 - $percentage = '';
390 - if ($product->get_type() == 'variable') {
391 - $available_variations = $product->get_variation_prices();
392 - $max_percentage = 0;
393 - foreach ($available_variations['regular_price'] as $key => $regular_price) {
394 - $sale_price = $available_variations['sale_price'][$key];
395 - if ($sale_price < $regular_price) {
396 - $percentage = round((($regular_price - $sale_price) / $regular_price) * 100);
397 - if ($percentage > $max_percentage) {
398 - $max_percentage = $percentage;
399 - }
400 - }
401 - }
402 - $percentage = $max_percentage;
403 - } elseif (($product->get_type() == 'simple' || $product->get_type() == 'external')) {
404 - $percentage = round((($product->get_regular_price() - $product->get_sale_price()) / $product->get_regular_price()) * 100);
405 - }
406 - if ($percentage) {
407 - printf('<div class="usk-badge-wrap usk-percantage-badge"><span class="usk-badge">%1$s%2$s</span></div>', $percentage, __('% off', 'ultimate-store-kit'));
408 - }
409 - }
410 - }
411 - protected function render_navigation() {
412 - $settings = $this->get_settings_for_display();
413 - $hide_arrow_on_mobile = $settings['hide_arrow_on_mobile'] ? ' bdt-visible@m' : '';
414 -
415 - if ('arrows' == $settings['navigation']) : ?>
416 - <div class="bdt-position-z-index bdt-position-<?php echo esc_attr($settings['arrows_position'] . $hide_arrow_on_mobile); ?>">
417 - <div class="bdt-arrows-container bdt-slidenav-container">
418 - <a href="" class="bdt-navigation-prev bdt-slidenav-previous bdt-icon bdt-slidenav">
419 - <i class="ep-icon-arrow-left-<?php echo esc_attr($settings['nav_arrows_icon']); ?>" aria-hidden="true"></i>
420 - </a>
421 - <a href="" class="bdt-navigation-next bdt-slidenav-next bdt-icon bdt-slidenav">
422 - <i class="ep-icon-arrow-right-<?php echo esc_attr($settings['nav_arrows_icon']); ?>" aria-hidden="true"></i>
423 - </a>
424 - </div>
425 - </div>
426 - <?php
427 - endif;
428 - }
429 -
430 - protected function render_pagination() {
431 - $settings = $this->get_settings_for_display();
432 -
433 - if ('dots' == $settings['navigation'] or 'arrows-fraction' == $settings['navigation']) : ?>
434 - <div class="bdt-position-z-index bdt-position-<?php echo esc_attr($settings['dots_position']); ?>">
435 - <div class="bdt-dots-container">
436 - <div class="swiper-pagination"></div>
437 - </div>
438 - </div>
439 -
440 - <?php
441 - elseif ('progressbar' == $settings['navigation']) : ?>
442 - <div class="swiper-pagination bdt-position-z-index bdt-position-<?php echo esc_attr($settings['progress_position']); ?>"></div>
443 - <?php
444 - endif;
445 - }
446 -
447 - protected function render_both_navigation() {
448 - $settings = $this->get_settings_for_display();
449 - $hide_arrow_on_mobile = $settings['hide_arrow_on_mobile'] ? 'bdt-visible@m' : '';
450 -
451 - ?>
452 - <div class="bdt-position-z-index bdt-position-<?php echo esc_attr($settings['both_position']); ?>">
453 - <div class="bdt-arrows-dots-container bdt-slidenav-container ">
454 -
455 - <div class="bdt-flex bdt-flex-middle">
456 - <div class="<?php
457 - echo esc_attr($hide_arrow_on_mobile); ?>">
458 - <a href="" class="bdt-navigation-prev bdt-slidenav-previous bdt-icon bdt-slidenav">
459 - <i class="ep-icon-arrow-left-<?php echo esc_attr($settings['nav_arrows_icon']); ?>" aria-hidden="true"></i>
460 - </a>
461 - </div>
462 -
463 - <?php
464 - if ('center' !== $settings['both_position']) : ?>
465 - <div class="swiper-pagination"></div>
466 - <?php
467 - endif; ?>
468 -
469 - <div class="<?php
470 - echo esc_attr($hide_arrow_on_mobile); ?>">
471 - <a href="" class="bdt-navigation-next bdt-slidenav-next bdt-icon bdt-slidenav">
472 - <i class="ep-icon-arrow-right-<?php echo esc_attr($settings['nav_arrows_icon']); ?>" aria-hidden="true"></i>
473 - </a>
474 - </div>
475 -
476 - </div>
477 - </div>
478 - </div>
479 - <?php
480 - }
481 - protected function render_arrows_fraction() {
482 - $settings = $this->get_settings_for_display();
483 - $hide_arrow_on_mobile = $settings['hide_arrow_on_mobile'] ? 'bdt-visible@m' : ''; ?>
484 - <div class="bdt-position-z-index bdt-position-<?php echo esc_attr($settings['arrows_fraction_position']); ?>">
485 - <div class="bdt-arrows-fraction-container bdt-slidenav-container ">
486 -
487 - <div class="bdt-flex bdt-flex-middle">
488 - <div class="<?php
489 - echo esc_attr($hide_arrow_on_mobile); ?>">
490 - <a href="" class="bdt-navigation-prev bdt-slidenav-previous bdt-icon bdt-slidenav">
491 - <i class="ep-icon-arrow-left-<?php echo esc_attr($settings['nav_arrows_icon']); ?>" aria-hidden="true"></i>
492 - </a>
493 - </div>
494 -
495 - <?php
496 - if ('center' !== $settings['arrows_fraction_position']) : ?>
497 - <div class="swiper-pagination"></div>
498 - <?php
499 - endif; ?>
500 -
501 - <div class="<?php
502 - echo esc_attr($hide_arrow_on_mobile); ?>">
503 - <a href="" class="bdt-navigation-next bdt-slidenav-next bdt-icon bdt-slidenav">
504 - <i class="ep-icon-arrow-right-<?php echo esc_attr($settings['nav_arrows_icon']); ?>" aria-hidden="true"></i>
505 - </a>
506 - </div>
507 -
508 - </div>
509 - </div>
510 - </div>
511 - <?php
512 - }
513 - protected function render_footer() {
514 - $settings = $this->get_settings_for_display(); ?>
515 - </div>
516 - <?php
517 - if ('yes' === $settings['show_scrollbar']) : ?>
518 - <div class="swiper-scrollbar"></div>
519 - <?php
520 - endif; ?>
521 - </div>
522 -
523 - <?php
524 - if ('both' == $settings['navigation']) : ?>
525 - <?php $this->render_both_navigation(); ?>
526 - <?php
527 - if ('center' === $settings['both_position']) : ?>
528 - <div class="bdt-position-z-index bdt-position-bottom">
529 - <div class="bdt-dots-container">
530 - <div class="swiper-pagination"></div>
531 - </div>
532 - </div>
533 - <?php
534 - endif; ?>
535 - <?php
536 - elseif ('arrows-fraction' == $settings['navigation']) : ?>
537 - <?php $this->render_arrows_fraction(); ?>
538 - <?php
539 - if ('center' === $settings['arrows_fraction_position']) : ?>
540 - <div class="bdt-dots-container">
541 - <div class="swiper-pagination"></div>
542 - </div>
543 - <?php
544 - endif; ?>
545 - <?php
546 - else : ?>
547 - <?php $this->render_pagination(); ?>
548 - <?php $this->render_navigation(); ?>
549 - <?php
550 - endif; ?>
551 -
552 - </div>
553 - </div>
554 -
555 - <?php
556 - }
557 - }
1 +<?php
2 +
3 +namespace UltimateStoreKit\Traits;
4 +
5 +use Elementor\Plugin;
6 +
7 +// use WP_Query;
8 +
9 +
10 +defined('ABSPATH') || die();
11 +
12 +trait Global_Widget_Template
13 +{
14 +
15 + protected function register_templates_grid_columns_markup($settings)
16 + { ?>
17 + <ul class="usk-grid-header-tabs">
18 + <?php if (in_array("list-2", $settings['filter_column_lists'])): ?>
19 + <li class="usk-grid-tabs-list">
20 + <a class="tab-option" href="javascript:void(0)" data-grid-column="usk-grid-1 usk-list-layout">
21 + <span class="usk-icon-grid-list"></span>
22 + </a>
23 + </li>
24 + <?php
25 + endif;
26 + if (in_array('grid-2', $settings['filter_column_lists'])):
27 + ?>
28 + <li class="usk-grid-tabs-list">
29 + <a class="tab-option" href="javascript:void(0)" data-grid-column="usk-grid-2">
30 + <span class="usk-icon-grid-2"></span>
31 + </a>
32 + </li>
33 + <?php
34 + endif;
35 + if (in_array('grid-3', $settings['filter_column_lists'])):
36 + ?>
37 + <li class="usk-grid-tabs-list">
38 + <a class="tab-option" href="javascript:void(0)" data-grid-column="usk-grid-3">
39 + <span class="usk-icon-grid-3"></span>
40 + </a>
41 + </li>
42 + <?php
43 + endif;
44 + if (in_array('grid-4', $settings['filter_column_lists'])):
45 + ?>
46 + <li class="usk-grid-tabs-list">
47 + <a class="tab-option" href="javascript:void(0)" data-grid-column="usk-grid-4">
48 + <span class="usk-icon-grid-4"></span>
49 + </a>
50 + </li>
51 + <?php
52 + endif;
53 + if (in_array('grid-5', $settings['filter_column_lists'])):
54 + ?>
55 + <li class="usk-grid-tabs-list">
56 + <a class="tab-option" href="javascript:void(0)" data-grid-column="usk-grid-5">
57 + <span class="usk-icon-grid-5"></span>
58 + </a>
59 + </li>
60 + <?php
61 + endif;
62 + if (in_array('grid-6', $settings['filter_column_lists'])):
63 + ?>
64 + <li class="usk-grid-tabs-list">
65 + <a class="tab-option" href="javascript:void(0)" data-grid-column="usk-grid-6">
66 + <span class="usk-icon-grid-6"></span>
67 + </a>
68 + </li>
69 + <?php
70 + endif;
71 + ?>
72 + </ul>
73 + <?php
74 + }
75 +
76 + protected function register_global_template_wc_rating($rating, $count = 0)
77 + {
78 + $html = '';
79 + if (
80 + 0 <= $rating
81 + ) {
82 + /* translators: %s: rating */
83 + // $label = sprintf(__('Rated %s out of 5', 'woocommerce'), $rating);
84 + $html = '<div class="star-rating" role="img">' . wc_get_star_rating_html($rating, $count) . '</div>';
85 + }
86 +
87 + return apply_filters('woocommerce_product_get_rating_html', $html, $rating, $count);
88 + }
89 + public function register_global_template_add_to_wishlist($tooltip_position, $settings)
90 + {
91 + global $product;
92 + $user_id = get_current_user_id();
93 + $product_id = $product->get_ID();
94 + $wishlist = ultimate_store_kit_get_wishlist($user_id);
95 + $is_wishlisted = in_array($product_id, $wishlist);
96 + if (!empty($is_wishlisted)) {
97 + $selected = ' usk-active';
98 + $tooltip = __('View Wishlist', 'ultimate-store-kit');
99 + $redirect_url = wc_get_account_endpoint_url('wishlist');
100 + } else {
101 + $selected = '';
102 + $tooltip = __('Add to Wishlist', 'ultimate-store-kit');
103 + $redirect_url = "javascript:void(0);";
104 + } ?>
105 + <?php if (isset($settings['show_wishlist']) ? $settings['show_wishlist'] : true): ?>
106 + <a href="<?php echo esc_url($redirect_url); ?>"
107 + class="usk-action-btn ajax_add_to_wishlist usk-shoping-icon-wishlist usk-btn usk-wishlist<?php echo esc_attr($selected); ?>"
108 + data-product_id="<?php echo absint($product_id); ?>" aria-label="<?php echo esc_attr($tooltip); ?>"
109 + data-aria_label="<?php echo esc_attr__('View Wishlist', 'ultimate-store-kit'); ?>"
110 + data-redirect_url="<?php echo esc_url(wc_get_account_endpoint_url('wishlist')); ?>"
111 + data-microtip-position="<?php echo esc_attr($tooltip_position); ?>" role="tooltip">
112 + <i class="icon usk-icon-heart-full"></i>
113 + </a>
114 + <?php endif; ?>
115 + <?php
116 + }
117 +
118 + function register_global_template_add_to_compare($tooltip_position, $settings)
119 + {
120 + global $product;
121 + $user_id = get_current_user_id();
122 + $product_id = $product->get_ID();
123 + $compare_products = ultimate_store_kit_get_compare_products($user_id);
124 + $is_compared = in_array($product_id, $compare_products);
125 +
126 + $compare_page_id = '';
127 + if (function_exists('ultimate_store_kit_compare_product_page') && $comparePage = ultimate_store_kit_compare_product_page()) {
128 + $compare_page_id = $comparePage;
129 + }
130 +
131 + $compare_redirect_link = home_url();
132 + if ($compare_page_id) {
133 + $compare_redirect_link = get_page_link($compare_page_id);
134 + }
135 +
136 + if (!empty($is_compared)) {
137 + $tooltip = __('View Compare', 'ultimate-store-kit');
138 + $selected = 'usk-active';
139 + $compare_page_link = home_url();
140 + if ($compare_page_id) {
141 + $compare_page_link = get_page_link($compare_page_id);
142 + }
143 + } else {
144 + $tooltip = __('Add to Compare', 'ultimate-store-kit');
145 + $selected = '';
146 + $compare_page_link = "javascript:void(0);";
147 + } ?>
148 + <?php if (isset($settings['show_compare']) && $settings['show_compare'] == 'yes'): ?>
149 + <a href="<?php echo esc_url($compare_page_link); ?>"
150 + class="usk-action-btn ajax_add_to_compare usk-compare <?php echo esc_attr($selected); ?>"
151 + data-product_id="<?php echo esc_attr($product_id); ?>"
152 + data-redirect_url="<?php echo esc_url($compare_redirect_link); ?>" aria-label="<?php echo esc_attr($tooltip); ?>"
153 + data-aria_label="<?php echo esc_attr__('View Compare', 'ultimate-store-kit'); ?>"
154 + data-microtip-position="<?php echo esc_attr($tooltip_position); ?>" role="tooltip">
155 + <i class="icon usk-icon-compare"></i>
156 + </a>
157 + <?php
158 + ?>
159 + <?php endif; ?>
160 + <?php
161 +
162 + }
163 +
164 + protected function register_global_template_quick_view($product_id, $tooltip_position, $settings)
165 + {
166 + // $settings = $this->get_settings_for_display();
167 + if (isset($settings['show_quick_view']) ? $settings['show_quick_view'] : true): ?>
168 + <?php wp_nonce_field('ajax-usk-quick-view-nonce', 'usk-quick-view-modal-sc');
169 + ?>
170 + <a class="usk-action-btn usk-shoping-icon-quickview quick_view usk-view usk-btn" href="javascript:void(0)"
171 + data-id="<?php echo absint($product_id); ?>"
172 + aria-label="<?php echo esc_attr__('Quick View', 'ultimate-store-kit'); ?>"
173 + data-microtip-position="<?php echo esc_attr($tooltip_position); ?>" role="tooltip">
174 + <i class="icon usk-icon-preview"></i>
175 + </a>
176 + <?php endif;
177 + }
178 + protected function register_global_template_add_to_cart($tooltip_position, $settings)
179 + {
180 + global $product;
181 + if (isset($settings['show_cart']) ? $settings['show_cart'] : true): ?>
182 + <?php if ($product) {
183 + $defaults = [
184 + 'quantity' => 1,
185 + 'class' => implode(
186 + ' ',
187 + array_filter(
188 + [
189 + 'usk-cart',
190 + 'usk-action-btn',
191 + 'product_type_' . $product->get_type(),
192 + $product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '',
193 + $product->supports('ajax_add_to_cart') && $product->is_purchasable() && $product->is_in_stock() ? 'ajax_add_to_cart' : '',
194 + ]
195 + )
196 + ),
197 + 'attributes' => [
198 + 'data-product_id' => $product->get_id(),
199 + 'data-product_sku' => $product->get_sku(),
200 + 'data-microtip-position' => $tooltip_position,
201 + 'aria-label' => $product->add_to_cart_text(),
202 + 'rel' => 'nofollow',
203 + 'role' => 'tooltip',
204 + ],
205 + ];
206 + $args = apply_filters('woocommerce_loop_add_to_cart_args', wp_parse_args($defaults), $product);
207 + if (isset($args['attributes']['aria-label'])) {
208 + $args['attributes']['aria-label'] = wp_strip_all_tags($args['attributes']['aria-label']);
209 + }
210 + echo wp_kses_post(apply_filters(
211 + 'woocommerce_loop_add_to_cart_link', // WPCS: XSS ok.
212 + sprintf(
213 + '<a href="%s" data-quantity="%s" class="%s" %s><i class="icon usk-icon-cart"></i></a>',
214 + esc_url($product->add_to_cart_url()),
215 + esc_attr(isset($args['quantity']) ? $args['quantity'] : 1),
216 + esc_attr(isset($args['class']) ? $args['class'] : 'button'),
217 + isset($args['attributes']) ? wc_implode_html_attributes($args['attributes']) : ''
218 + ),
219 + $product,
220 + $args
221 + ));
222 + }
223 + ; ?>
224 + <?php endif;
225 + }
226 + protected function register_global_template_badge_label($settings)
227 + {
228 + // print_r($settings);
229 + global $product;
230 + if ($product->is_on_sale() && (isset($settings['show_sale_badge']) ? $settings['show_sale_badge'] : true)):
231 + printf('<div class="usk-badge-wrap usk-sale-badge"><span class="usk-badge">%1$s</span></div>', esc_html__('Sale', 'ultimate-store-kit'));
232 + endif;
233 + if (isset($settings['show_discount_badge']) ? $settings['show_discount_badge'] : true):
234 + $this->usk_get_badge_label_percentage();
235 + endif;
236 + if (isset($settings['show_stock_status']) && $settings['show_stock_status'] === 'yes'):
237 + if ($product->get_stock_status() === 'instock') {
238 + $stock_status = esc_html__('In Stock', 'ultimate-store-kit');
239 + } else {
240 + $stock_status = esc_html__('Out of Stock', 'ultimate-store-kit');
241 + }
242 +
243 + printf('<div class="usk-badge-wrap usk-stock-status-badge"><span class="usk-badge">%1$s</span></div>', esc_html($stock_status));
244 + endif;
245 + if ($product->is_featured() && (isset($settings['show_trending_badge']) ? $settings['show_trending_badge'] : true)):
246 + printf('<div class="usk-badge-wrap usk-trending-badge"><span class="usk-badge">%1$s</span></div>', esc_html__('Trending', 'ultimate-store-kit'));
247 + endif;
248 + if (isset($settings['show_new_badge']) ? $settings['show_new_badge'] : true):
249 + $newness_days = isset($settings['newness_days']) ? $settings['newness_days'] : 60;
250 + $created_date = strtotime($product->get_date_created());
251 + $valid_date = time() - (60 * 60 * 24 * $newness_days);
252 + if ($valid_date < $created_date) {
253 + printf('<div class="usk-badge-wrap usk-new-badge"><span class="usk-badge">%s</span></div>', esc_html__('New', 'ultimate-store-kit'));
254 + }
255 + endif;
256 + }
257 + protected function register_global_template_navigation()
258 + {
259 + $settings = $this->get_settings_for_display();
260 + $hide_arrow_on_mobile = $settings['hide_arrow_on_mobile'] ? ' usk-visible@m' : '';
261 +
262 + if ('arrows' == $settings['navigation']): ?>
263 + <div style="direction: ltr;"
264 + class="usk-position-z-index usk-position-<?php echo esc_attr($settings['arrows_position'] . $hide_arrow_on_mobile); ?>">
265 + <div class="usk-arrows-container usk-slidenav-container">
266 + <a href="" class="usk-navigation-prev usk-slidenav-previous usk-icon usk-slidenav">
267 + <i class="usk-icon-arrow-left-<?php echo esc_attr($settings['nav_arrows_icon']); ?>" aria-hidden="true"></i>
268 + </a>
269 + <a href="" class="usk-navigation-next usk-slidenav-next usk-icon usk-slidenav">
270 + <i class="usk-icon-arrow-right-<?php echo esc_attr($settings['nav_arrows_icon']); ?>"
271 + aria-hidden="true"></i>
272 + </a>
273 + </div>
274 + </div>
275 + <?php endif;
276 + }
277 + protected function register_global_template_pagination()
278 + {
279 + $settings = $this->get_settings_for_display();
280 +
281 + if ('dots' == $settings['navigation'] or 'arrows-fraction' == $settings['navigation']): ?>
282 + <div class="usk-position-z-index usk-position-<?php echo esc_attr($settings['dots_position']); ?>">
283 + <div class="usk-dots-container">
284 + <div class="swiper-pagination"></div>
285 + </div>
286 + </div>
287 +
288 + <?php elseif ('progressbar' == $settings['navigation']): ?>
289 + <div
290 + class="swiper-pagination usk-position-z-index usk-position-<?php echo esc_attr($settings['progress_position']); ?>">
291 + </div>
292 + <?php endif;
293 + }
294 + protected function register_global_template_both_navigation()
295 + {
296 + $settings = $this->get_settings_for_display();
297 + $hide_arrow_on_mobile = $settings['hide_arrow_on_mobile'] ? 'usk-visible@m usk-flex' : 'usk-flex';
298 +
299 + ?>
300 + <div class="usk-position-z-index usk-position-<?php echo esc_attr($settings['both_position']); ?>">
301 + <div class="usk-arrows-dots-container usk-slidenav-container ">
302 +
303 + <div class="usk-flex usk-flex-middle">
304 + <div class="<?php echo esc_attr($hide_arrow_on_mobile); ?>">
305 + <a href="" class="usk-navigation-prev usk-slidenav-previous usk-icon usk-slidenav">
306 + <i class="usk-icon-arrow-left-<?php echo esc_attr($settings['nav_arrows_icon']); ?>"
307 + aria-hidden="true"></i>
308 + </a>
309 + </div>
310 +
311 + <?php if ('center' !== $settings['both_position']): ?>
312 + <div class="swiper-pagination"></div>
313 + <?php endif; ?>
314 +
315 + <div class="<?php echo esc_attr($hide_arrow_on_mobile); ?>">
316 + <a href="" class="usk-navigation-next usk-slidenav-next usk-icon usk-slidenav">
317 + <i class="usk-icon-arrow-right-<?php echo esc_attr($settings['nav_arrows_icon']); ?>"
318 + aria-hidden="true"></i>
319 + </a>
320 + </div>
321 +
322 + </div>
323 + </div>
324 + </div>
325 + <?php
326 + }
327 + protected function register_global_template_arrows_fraction()
328 + {
329 + $settings = $this->get_settings_for_display();
330 + $hide_arrow_on_mobile = $settings['hide_arrow_on_mobile'] ? 'usk-visible@m' : ''; ?>
331 + <div class="usk-position-z-index usk-position-<?php echo esc_attr($settings['arrows_fraction_position']); ?>">
332 + <div class="usk-arrows-fraction-container usk-slidenav-container ">
333 +
334 + <div class="usk-flex usk-flex-middle">
335 + <div class="<?php echo esc_attr($hide_arrow_on_mobile); ?>">
336 + <a href="" class="usk-navigation-prev usk-slidenav-previous usk-icon usk-slidenav">
337 + <i class="usk-icon-arrow-left-<?php echo esc_attr($settings['nav_arrows_icon']); ?>"
338 + aria-hidden="true"></i>
339 + </a>
340 + </div>
341 +
342 + <?php if ('center' !== $settings['arrows_fraction_position']): ?>
343 + <div class="swiper-pagination"></div>
344 + <?php endif; ?>
345 +
346 + <div class="<?php echo esc_attr($hide_arrow_on_mobile); ?>">
347 + <a href="" class="usk-navigation-next usk-slidenav-next usk-icon usk-slidenav">
348 + <i class="usk-icon-arrow-right-<?php echo esc_attr($settings['nav_arrows_icon']); ?>"
349 + aria-hidden="true"></i>
350 + </a>
351 + </div>
352 +
353 + </div>
354 + </div>
355 + </div>
356 + <?php
357 + }
358 + protected function usk_register_global_template_carousel_footer()
359 + {
360 + $settings = $this->get_settings_for_display(); ?>
361 + </div>
362 + <?php if ('yes' === $settings['show_scrollbar']): ?>
363 + <div class="swiper-scrollbar"></div>
364 + <?php endif; ?>
365 + </div>
366 + <?php if ('both' == $settings['navigation']): ?>
367 + <?php $this->register_global_template_both_navigation(); ?>
368 + <?php if ('center' === $settings['both_position']): ?>
369 + <div class="usk-position-z-index usk-position-bottom">
370 + <div class="usk-dots-container">
371 + <div class="swiper-pagination"></div>
372 + </div>
373 + </div>
374 + <?php endif; ?>
375 + <?php elseif ('arrows-fraction' == $settings['navigation']): ?>
376 + <?php $this->register_global_template_arrows_fraction(); ?>
377 + <?php if ('center' === $settings['arrows_fraction_position']): ?>
378 + <div class="usk-dots-container">
379 + <div class="swiper-pagination"></div>
380 + </div>
381 + <?php endif; ?>
382 + <?php else: ?>
383 + <?php $this->register_global_template_pagination() ?>
384 + <?php $this->register_global_template_navigation() ?>
385 + <?php endif; ?>
386 + </div>
387 + </div>
388 + </div>
389 +
390 + <?php
391 + }
392 + protected function register_global_template_carousel_header()
393 + {
394 + $settings = $this->get_settings_for_display();
395 + $this->add_render_attribute('usk-carousel-wrapper', 'class', ['' . $this->get_name() . '', 'usk-grid-carousel']);
396 + $id = 'ultimate-store-kit-' . $this->get_id();
397 + $elementor_vp_lg = get_option('elementor_viewport_lg');
398 + $elementor_vp_md = get_option('elementor_viewport_md');
399 + $viewport_lg = !empty($elementor_vp_lg) ? $elementor_vp_lg - 1 : 1023;
400 + $viewport_md = !empty($elementor_vp_md) ? $elementor_vp_md - 1 : 767;
401 + $this->add_render_attribute('carousel', 'id', $id);
402 + $this->add_render_attribute('carousel', 'class', ['usk-carousel', 'usk-carousel-layout', 'elementor-swiper']);
403 + if ('arrows' == $settings['navigation']) {
404 + $this->add_render_attribute('carousel', 'class', 'usk-arrows-align-' . $settings['arrows_position']);
405 + } elseif ('dots' == $settings['navigation']) {
406 + $this->add_render_attribute('carousel', 'class', 'usk-dots-align-' . $settings['dots_position']);
407 + } elseif ('both' == $settings['navigation']) {
408 + $this->add_render_attribute('carousel', 'class', 'usk-arrows-dots-align-' . $settings['both_position']);
409 + } elseif ('arrows-fraction' == $settings['navigation']) {
410 + $this->add_render_attribute('carousel', 'class', 'usk-arrows-dots-align-' . $settings['arrows_fraction_position']);
411 + }
412 +
413 + if ('arrows-fraction' == $settings['navigation']) {
414 + $pagination_type = 'fraction';
415 + } elseif ('both' == $settings['navigation'] or 'dots' == $settings['navigation']) {
416 + $pagination_type = 'bullets';
417 + } elseif ('progressbar' == $settings['navigation']) {
418 + $pagination_type = 'progressbar';
419 + } else {
420 + $pagination_type = '';
421 + }
422 +
423 + $this->add_render_attribute(
424 + [
425 + 'carousel' => [
426 + 'data-settings' => [
427 + wp_json_encode(array_filter([
428 + "autoplay" => ("yes" == $settings["autoplay"]) ? ["delay" => $settings["autoplay_speed"]] : false,
429 + "loop" => ($settings["loop"] == "yes") ? true : false,
430 + "speed" => $settings["speed"]["size"],
431 + "pauseOnHover" => ("yes" == $settings["pauseonhover"]) ? true : false,
432 + "slidesPerView" => isset($settings["columns_mobile"]) ? (int) $settings["columns_mobile"] : 1,
433 + "slidesPerGroup" => isset($settings["slides_to_scroll_mobile"]) ? (int) $settings["slides_to_scroll_mobile"] : 1,
434 + "spaceBetween" => !empty($settings["items_gap_mobile"]["size"]) ? (int)$settings["items_gap_mobile"]["size"] : 0,
435 + "centeredSlides" => ($settings["centered_slides"] === "yes") ? true : false,
436 + "grabCursor" => ($settings["grab_cursor"] === "yes") ? true : false,
437 + "effect" => $settings["skin"],
438 + "observer" => ($settings["observer"]) ? true : false,
439 + "observeParents" => ($settings["observer"]) ? true : false,
440 + // "direction" => $settings['direction'],
441 + "watchSlidesVisibility" => true,
442 + "watchSlidesProgress" => true,
443 + "breakpoints" => [
444 + (int) $viewport_md => [
445 + "slidesPerView" => isset($settings["columns_tablet"]) ? (int) $settings["columns_tablet"] : 2,
446 + "spaceBetween" => !empty($settings["items_gap_tablet"]["size"]) ? (int)$settings["items_gap_tablet"]["size"] : 0,
447 + "slidesPerGroup" => isset($settings["slides_to_scroll_tablet"]) ? (int) $settings["slides_to_scroll_tablet"] : 1,
448 + ],
449 + (int) $viewport_lg => [
450 + "slidesPerView" => isset($settings["columns"]) ? (int) $settings["columns"] : 3,
451 + "spaceBetween" => !empty($settings["items_gap"]["size"]) ? (int)$settings["items_gap"]["size"] : 0,
452 + "slidesPerGroup" => isset($settings["slides_to_scroll"]) ? (int) $settings["slides_to_scroll"] : 1,
453 + ]
454 + ],
455 + "navigation" => [
456 + "nextEl" => "#" . $id . " .usk-navigation-next",
457 + "prevEl" => "#" . $id . " .usk-navigation-prev",
458 + ],
459 + "pagination" => [
460 + "el" => "#" . $id . " .swiper-pagination",
461 + "type" => $pagination_type,
462 + "clickable" => "true",
463 + 'dynamicBullets' => ("yes" == $settings["dynamic_bullets"]) ? true : false,
464 + ],
465 + "scrollbar" => [
466 + "el" => "#" . $id . " .swiper-scrollbar",
467 + "hide" => "true",
468 + ],
469 + 'coverflowEffect' => [
470 + 'rotate' => ("yes" == $settings["coverflow_toggle"]) ? $settings["coverflow_rotate"]["size"] : 50,
471 + 'stretch' => ("yes" == $settings["coverflow_toggle"]) ? $settings["coverflow_stretch"]["size"] : 0,
472 + 'depth' => ("yes" == $settings["coverflow_toggle"]) ? $settings["coverflow_depth"]["size"] : 100,
473 + 'modifier' => ("yes" == $settings["coverflow_toggle"]) ? $settings["coverflow_modifier"]["size"] : 1,
474 + 'slideShadows' => true,
475 + ],
476 +
477 + ]))
478 + ]
479 + ]
480 + ]
481 + );
482 +
483 + $this->add_render_attribute('swiper', 'class', 'swiper-carousel swiper');
484 +
485 + ?>
486 +
487 + <div class="ultimate-store-kit">
488 + <div <?php $this->print_render_attribute_string('usk-carousel-wrapper'); ?>>
489 + <div <?php $this->print_render_attribute_string('carousel'); ?>>
490 + <div <?php $this->print_render_attribute_string('swiper'); ?>>
491 + <div class="swiper-wrapper">
492 + <?php
493 + }
494 + protected function usk_get_badge_label_percentage()
495 + {
496 + global $product;
497 + if ($product->is_on_sale()) {
498 + $percentage = '';
499 + if ($product->get_type() == 'variable') {
500 + $available_variations = $product->get_variation_prices();
501 + $max_percentage = 0;
502 + foreach ($available_variations['regular_price'] as $key => $regular_price) {
503 + $sale_price = $available_variations['sale_price'][$key];
504 + if ($sale_price < $regular_price) {
505 + $percentage = round((($regular_price - $sale_price) / $regular_price) * 100);
506 + if ($percentage > $max_percentage) {
507 + $max_percentage = $percentage;
508 + }
509 + }
510 + }
511 + $percentage = $max_percentage;
512 + } elseif (($product->get_type() == 'simple' || $product->get_type() == 'external')) {
513 + $percentage = round((($product->get_regular_price() - $product->get_sale_price()) / $product->get_regular_price()) * 100);
514 + }
515 + if ($percentage) {
516 + printf('<div class="usk-badge-wrap usk-percantage-badge"><span class="usk-badge">%1$s%2$s</span></div>', esc_html($percentage), esc_html__('% off', 'ultimate-store-kit'));
517 + }
518 + }
519 + }
520 + protected function render_navigation()
521 + {
522 + $settings = $this->get_settings_for_display();
523 + $hide_arrow_on_mobile = $settings['hide_arrow_on_mobile'] ? ' bdt-visible@m' : '';
524 +
525 + if ('arrows' == $settings['navigation']): ?>
526 + <div
527 + class="bdt-position-z-index bdt-position-<?php echo esc_attr($settings['arrows_position'] . $hide_arrow_on_mobile); ?>">
528 + <div class="bdt-arrows-container bdt-slidenav-container">
529 + <a href="" class="bdt-navigation-prev bdt-slidenav-previous bdt-icon bdt-slidenav">
530 + <i class="usk-icon-arrow-left-<?php echo esc_attr($settings['nav_arrows_icon']); ?>"
531 + aria-hidden="true"></i>
532 + </a>
533 + <a href="" class="bdt-navigation-next bdt-slidenav-next bdt-icon bdt-slidenav">
534 + <i class="usk-icon-arrow-right-<?php echo esc_attr($settings['nav_arrows_icon']); ?>"
535 + aria-hidden="true"></i>
536 + </a>
537 + </div>
538 + </div>
539 + <?php
540 + endif;
541 + }
542 +
543 + protected function render_pagination()
544 + {
545 + $settings = $this->get_settings_for_display();
546 +
547 + if ('dots' == $settings['navigation'] or 'arrows-fraction' == $settings['navigation']): ?>
548 + <div class="bdt-position-z-index bdt-position-<?php echo esc_attr($settings['dots_position']); ?>">
549 + <div class="bdt-dots-container">
550 + <div class="swiper-pagination"></div>
551 + </div>
552 + </div>
553 +
554 + <?php
555 + elseif ('progressbar' == $settings['navigation']): ?>
556 + <div
557 + class="swiper-pagination bdt-position-z-index bdt-position-<?php echo esc_attr($settings['progress_position']); ?>">
558 + </div>
559 + <?php
560 + endif;
561 + }
562 +
563 + protected function render_both_navigation()
564 + {
565 + $settings = $this->get_settings_for_display();
566 + $hide_arrow_on_mobile = $settings['hide_arrow_on_mobile'] ? 'bdt-visible@m' : '';
567 +
568 + ?>
569 + <div class="bdt-position-z-index bdt-position-<?php echo esc_attr($settings['both_position']); ?>">
570 + <div class="bdt-arrows-dots-container bdt-slidenav-container ">
571 +
572 + <div class="bdt-flex bdt-flex-middle">
573 + <div class="<?php
574 + echo esc_attr($hide_arrow_on_mobile); ?>">
575 + <a href="" class="bdt-navigation-prev bdt-slidenav-previous bdt-icon bdt-slidenav">
576 + <i class="usk-icon-arrow-left-<?php echo esc_attr($settings['nav_arrows_icon']); ?>"
577 + aria-hidden="true"></i>
578 + </a>
579 + </div>
580 +
581 + <?php
582 + if ('center' !== $settings['both_position']): ?>
583 + <div class="swiper-pagination"></div>
584 + <?php
585 + endif; ?>
586 +
587 + <div class="<?php
588 + echo esc_attr($hide_arrow_on_mobile); ?>">
589 + <a href="" class="bdt-navigation-next bdt-slidenav-next bdt-icon bdt-slidenav">
590 + <i class="usk-icon-arrow-right-<?php echo esc_attr($settings['nav_arrows_icon']); ?>"
591 + aria-hidden="true"></i>
592 + </a>
593 + </div>
594 +
595 + </div>
596 + </div>
597 + </div>
598 + <?php
599 + }
600 + protected function render_arrows_fraction()
601 + {
602 + $settings = $this->get_settings_for_display();
603 + $hide_arrow_on_mobile = $settings['hide_arrow_on_mobile'] ? 'bdt-visible@m' : ''; ?>
604 + <div
605 + class="bdt-position-z-index bdt-position-<?php echo esc_attr($settings['arrows_fraction_position']); ?>">
606 + <div class="bdt-arrows-fraction-container bdt-slidenav-container ">
607 +
608 + <div class="bdt-flex bdt-flex-middle">
609 + <div class="<?php
610 + echo esc_attr($hide_arrow_on_mobile); ?>">
611 + <a href="" class="bdt-navigation-prev bdt-slidenav-previous bdt-icon bdt-slidenav">
612 + <i class="usk-icon-arrow-left-<?php echo esc_attr($settings['nav_arrows_icon']); ?>"
613 + aria-hidden="true"></i>
614 + </a>
615 + </div>
616 +
617 + <?php
618 + if ('center' !== $settings['arrows_fraction_position']): ?>
619 + <div class="swiper-pagination"></div>
620 + <?php
621 + endif; ?>
622 +
623 + <div class="<?php
624 + echo esc_attr($hide_arrow_on_mobile); ?>">
625 + <a href="" class="bdt-navigation-next bdt-slidenav-next bdt-icon bdt-slidenav">
626 + <i class="usk-icon-arrow-right-<?php echo esc_attr($settings['nav_arrows_icon']); ?>"
627 + aria-hidden="true"></i>
628 + </a>
629 + </div>
630 +
631 + </div>
632 + </div>
633 + </div>
634 + <?php
635 + }
636 + protected function render_footer()
637 + {
638 + $settings = $this->get_settings_for_display(); ?>
639 + </div>
640 + <?php
641 + if ('yes' === $settings['show_scrollbar']): ?>
642 + <div class="swiper-scrollbar"></div>
643 + <?php
644 + endif; ?>
645 + </div>
646 +
647 + <?php
648 + if ('both' == $settings['navigation']): ?>
649 + <?php $this->render_both_navigation(); ?>
650 + <?php
651 + if ('center' === $settings['both_position']): ?>
652 + <div class="bdt-position-z-index bdt-position-bottom">
653 + <div class="bdt-dots-container">
654 + <div class="swiper-pagination"></div>
655 + </div>
656 + </div>
657 + <?php
658 + endif; ?>
659 + <?php
660 + elseif ('arrows-fraction' == $settings['navigation']): ?>
661 + <?php $this->render_arrows_fraction(); ?>
662 + <?php
663 + if ('center' === $settings['arrows_fraction_position']): ?>
664 + <div class="bdt-dots-container">
665 + <div class="swiper-pagination"></div>
666 + </div>
667 + <?php
668 + endif; ?>
669 + <?php
670 + else: ?>
671 + <?php $this->render_pagination(); ?>
672 + <?php $this->render_navigation(); ?>
673 + <?php
674 + endif; ?>
675 +
676 + </div>
677 + </div>
678 +
679 + <?php
680 + }
681 +}