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