PluginProbe
Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder / 2.0.2
Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder v2.0.2
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
ultimate-store-kit / modules / florence-carousel / widgets / florence-carousel.php

florence-carousel.php in Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder 2.0.2, at modules/florence-carousel/widgets/florence-carousel.php

301 lines 11.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace UltimateStoreKit\Modules\FlorenceCarousel\Widgets;
4
5 use Elementor\Controls_Manager;
6 use Elementor\Group_Control_Border;
7 use UltimateStoreKit\Base\Module_Base;
8 use UltimateStoreKit\traits\Global_Widget_Controls;
9 use UltimateStoreKit\traits\Global_Widget_Template;
10 use UltimateStoreKit\Includes\Controls\GroupQuery\Group_Control_Query;
11 use WP_Query;
12
13 if (!defined('ABSPATH')) {
14 exit;
15 }
16
17 // Exit if accessed directly
18
19 class Florence_Carousel extends Module_Base {
20 use Global_Widget_Controls;
21 use Global_Widget_Template;
22 use Group_Control_Query;
23
24 /**
25 * @var \WP_Query
26 */
27 private $_query = null;
28
29
30 public function get_name() {
31 return 'usk-florence-carousel';
32 }
33
34 public function get_title() {
35 return esc_html__('Florence Carousel', 'ultimate-store-kit');
36 }
37
38 public function get_icon() {
39 return 'usk-widget-icon usk-icon-florence-carousel';
40 }
41
42 public function get_categories() {
43 return ['ultimate-store-kit'];
44 }
45
46 public function get_keywords() {
47 return ['product', 'product-carousel', 'table', 'wc'];
48 }
49
50 public function get_script_depends() {
51 return ['micromodal'];
52 }
53
54 public function get_style_depends() {
55 if ($this->usk_is_edit_mode()) {
56 return ['usk-all-styles'];
57 } else {
58 return ['usk-font', 'usk-florence-carousel'];
59 }
60 }
61
62 public function get_custom_help_url() {
63 return 'https://youtu.be/eqAsEwqcKdM';
64 }
65
66 public function get_query() {
67 return $this->_query;
68 }
69 protected function register_controls() {
70
71 $this->start_controls_section(
72 'section_woocommerce_layout',
73 [
74 'label' => esc_html__('Layout', 'ultimate-store-kit'),
75 ]
76 );
77
78 $this->add_responsive_control(
79 'columns',
80 [
81 'label' => esc_html__('Columns', 'ultimate-store-kit'),
82 'type' => Controls_Manager::SELECT,
83 'default' => 3,
84 'tablet_default' => 2,
85 'mobile_default' => 1,
86 'options' => [
87 1 => '1',
88 2 => '2',
89 3 => '3',
90 4 => '4',
91 5 => '5',
92 6 => '6',
93 ],
94 ]
95 );
96 $this->add_responsive_control(
97 'items_gap',
98 [
99 'label' => esc_html__('Item Gap', 'ultimate-store-kit'),
100 'type' => Controls_Manager::SLIDER,
101 'default' => [
102 'size' => 30,
103 ],
104 'range' => [
105 'px' => [
106 'min' => 0,
107 'max' => 100,
108 ],
109 ],
110 'tablet_default' => [
111 'size' => 20,
112 ],
113 'mobile_default' => [
114 'size' => 20,
115 ],
116 ]
117 );
118
119 $this->register_global_controls_grid_layout();
120
121 $this->end_controls_section();
122 $this->start_controls_section(
123 'section_post_query_builder',
124 [
125 'label' => __('Query', 'ultimate-store-kit'),
126 'tab' => Controls_Manager::TAB_CONTENT,
127 ]
128 );
129 $this->register_query_builder_controls();
130 $this->register_controls_wc_additional();
131 $this->end_controls_section();
132 $this->register_global_controls_additional();
133 $this->register_global_controls_carousel_navigation();
134 $this->register_global_controls_carousel_settings();
135 $this->register_global_controls_grid_items();
136 $this->register_global_controls_grid_image();
137 $this->register_global_controls_content();
138 $this->register_global_controls_title();
139 $this->register_global_controls_category();
140 $this->register_global_controls_price();
141 $this->register_global_controls_rating();
142 $this->register_global_controls_badge();
143 $this->register_global_controls_action_btn();
144 $this->register_global_controls_navigation_style();
145 }
146
147 public function render_image() {
148 global $product;
149 $tooltip_position = 'left';
150 $settings = $this->get_settings_for_display();
151 $gallery_thumbs = $product->get_gallery_image_ids();
152 $product_image = wp_get_attachment_image_url(get_post_thumbnail_id(), $settings['image_size']);
153 if ($gallery_thumbs) {
154 foreach ($gallery_thumbs as $key => $gallery_thumb) {
155 if ($key == 0) :
156 $gallery_image_link = wp_get_attachment_image_url($gallery_thumb, $settings['image_size']);
157 endif;
158 }
159 } else {
160 $gallery_image_link = wp_get_attachment_image_url(get_post_thumbnail_id(), $settings['image_size']);
161 }
162 ?>
163 <div class="usk-image">
164 <a href="<?php echo esc_url(get_permalink()); ?>">
165 <img class="img image-default" src="<?php echo esc_url($product_image); ?>" alt="<?php echo esc_html(get_the_title()); ?>">
166 <img class="img image-hover" src="<?php echo esc_url($gallery_image_link); ?>" alt="<?php echo esc_html(get_the_title()); ?>">
167 </a>
168 <div class="usk-shoping">
169 <?php
170 $this->register_global_template_add_to_wishlist($tooltip_position);
171 $this->register_global_template_add_to_compare($tooltip_position);
172 $this->register_global_template_quick_view($product->get_id(), $tooltip_position);
173 $this->register_global_template_add_to_cart($tooltip_position);
174 ?>
175 </div>
176 <div class="usk-badge-label-wrapper">
177 <div class="usk-badge-label-content usk-flex usk-flex-column">
178 <?php $this->register_global_template_badge_label(); ?>
179 </div>
180 </div>
181 </div>
182 <?php
183 }
184 public function render_add_to_cart() {
185 global $product;
186 $settings = $this->get_settings_for_display();
187 if ('yes' == $settings['show_cart']) : ?>
188 <?php if ($product) {
189 $defaults = [
190 'quantity' => 1,
191 'class' => implode(
192 ' usk-button ',
193 array_filter(
194 [
195 'product_type_' . $product->get_type(),
196 $product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '',
197 $product->supports('ajax_add_to_cart') && $product->is_purchasable() && $product->is_in_stock() ? 'ajax_add_to_cart' : '',
198 ]
199 )
200 ),
201 'attributes' => [
202 'data-product_id' => $product->get_id(),
203 'data-product_sku' => $product->get_sku(),
204 'aria-label' => $product->add_to_cart_description(),
205 'rel' => 'nofollow',
206 ],
207 ];
208 $args = apply_filters('woocommerce_loop_add_to_cart_args', wp_parse_args($defaults), $product);
209 if (isset($args['attributes']['aria-label'])) {
210 $args['attributes']['aria-label'] = wp_strip_all_tags($args['attributes']['aria-label']);
211 }
212 echo wp_kses_post(apply_filters(
213 'woocommerce_loop_add_to_cart_link', // WPCS: XSS ok.
214 sprintf(
215 '<a href="%s" data-quantity="%s" class="%s" %s>%s <i class="button-icon usk-icon-arrow-right-8"></i></a>',
216 esc_url($product->add_to_cart_url()),
217 esc_attr(isset($args['quantity']) ? $args['quantity'] : 1),
218 esc_attr(isset($args['class']) ? $args['class'] : 'button'),
219 isset($args['attributes']) ? wc_implode_html_attributes($args['attributes']) : '',
220 esc_html($product->add_to_cart_text())
221 ),
222 $product,
223 $args
224 ));
225 }; ?>
226 <?php endif;
227 }
228 public function print_price_output($output) {
229 $tags = [
230 'del' => ['aria-hidden' => []],
231 'span' => ['class' => []],
232 'bdi' => [],
233 'ins' => [],
234 ];
235
236 if (isset($output)) {
237 echo wp_kses($output, $tags);
238 }
239 }
240 public function render_loop_item() {
241 $settings = $this->get_settings_for_display();
242 $id = 'usk-wc-product-' . $this->get_id();
243 $modal_id = wp_unique_id('modal-id-');
244 $this->query_product();
245 $wp_query = $this->get_query();
246
247 if ($wp_query->have_posts()) { ?>
248 <?php while ($wp_query->have_posts()) : $wp_query->the_post();
249 global $product;
250 $rating_count = $product->get_rating_count();
251 $average = $product->get_average_rating();
252 if ('yes' === $settings['show_rating']) {
253 $this->add_render_attribute('usk-item', 'class', ['swiper-slide', 'usk-item', 'usk-have-rating'], true);
254 } else {
255 $this->add_render_attribute('usk-item', 'class', ['swiper-slide', 'usk-item'], true);
256 }
257
258 $categories = str_replace(',', '', wc_get_product_category_list($product->get_id()));
259 ?>
260 <div <?php $this->print_render_attribute_string('usk-item'); ?>>
261 <div class="usk-item-box">
262 <?php $this->render_image(); ?>
263 <div class="usk-content">
264 <div class="usk-content-inner">
265 <?php if ('yes' == $settings['show_category']) : ?>
266 <?php printf('<%1$s class="usk-category">%2$s</%1$s>', esc_attr($settings['category_tags']), wp_kses_post($categories)); ?>
267 <?php endif; ?>
268 <?php if ('yes' == $settings['show_title']) :
269 printf('<a href="%2$s" class="usk-title"><%1$s class="title">%3$s</%1$s></a>', esc_attr($settings['title_tags']), esc_url($product->get_permalink()), esc_html($product->get_title()));
270 endif; ?>
271 <?php if ('yes' == $settings['show_price']) : ?>
272 <div class="usk-price">
273 <?php $this->print_price_output($product->get_price_html()); ?>
274 </div>
275 <?php endif; ?>
276 <?php if ('yes' == $settings['show_rating']) : ?>
277 <div class="usk-rating">
278 <span><?php echo wp_kses_post($this->register_global_template_wc_rating($average, $rating_count)); ?></span>
279 </div>
280 <?php endif; ?>
281 </div>
282 </div>
283 </div>
284 </div>
285 <?php endwhile;
286 wp_reset_postdata();
287 } else {
288 echo '<div class="usk-alert-warning" usk-alert>' . esc_html__('Ops! There no product to display.', 'ultimate-store-kit') . '</div>';
289 }
290 }
291 public function render() {
292 $this->register_global_template_carousel_header();
293 $this->render_loop_item();
294 $this->usk_register_global_template_carousel_footer();
295 }
296 public function query_product() {
297 $default = $this->getGroupControlQueryArgs();
298 $this->_query = new WP_Query($default);
299 }
300 }
301