PluginProbe
Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder / 3.0.2
Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder v3.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 / edd-classic-carousel / widgets / edd-classic-carousel.php

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

208 lines 7.8 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\EddClassicCarousel\Widgets;
4
5 use UltimateStoreKit\Base\Module_Base;
6 use UltimateStoreKit\Traits\Global_Widget_Controls;
7 use UltimateStoreKit\Traits\Global_EDD_Widget_Controls;
8 use UltimateStoreKit\Traits\Global_Widget_Template;
9 use UltimateStoreKit\Includes\Controls\GroupQuery\Group_Control_Query;
10 use UltimateStoreKit\Classes\Utils;
11 use WP_Query;
12
13 if (!defined('ABSPATH')) {
14 exit;
15 }
16
17 // Exit if accessed directly
18
19 class EDD_Classic_Carousel extends Module_Base {
20 use Global_Widget_Controls;
21 use Global_EDD_Widget_Controls;
22 use Global_Widget_Template;
23 use Group_Control_Query;
24 /**
25 * @var \WP_Query
26 */
27 private $_query = null;
28 public function get_name() {
29 return 'usk-edd-classic-carousel';
30 }
31
32 public function get_title() {
33 return esc_html__('EDD Classic Carousel', 'ultimate-store-kit');
34 }
35
36 public function get_icon() {
37 return 'usk-widget-icon usk-icon-edd-classic-carousel';
38 }
39
40 public function get_categories() {
41 return ['ultimate-store-kit'];
42 }
43
44 public function get_keywords() {
45 return ['product', 'product carousel', 'table', 'wc', 'carousel', 'list'];
46 }
47
48
49 public function get_style_depends() {
50 if ($this->usk_is_edit_mode()) {
51 return ['swiper', 'usk-all-styles'];
52 } else {
53 return ['swiper', 'usk-font', 'usk-edd-classic-carousel'];
54 }
55 }
56
57 public function get_script_depends() {
58 if ($this->usk_is_edit_mode()) {
59 return ['swiper', 'usk-site'];
60 } else {
61 return ['swiper', 'usk-edd-classic-carousel'];
62 }
63 }
64
65
66 public function get_query() {
67 return $this->_query;
68 }
69 public function has_widget_inner_wrapper(): bool {
70 return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
71 }
72 protected function register_controls() {
73 /**
74 * render controls layout
75 */
76 $this->register_global_edd_controls_carousel_layout();
77 $this->register_global_edd_controls_query();
78 $this->register_global_edd_controls_additional();
79
80 //swiper
81 $this->register_global_controls_carousel_navigation();
82 $this->register_global_controls_carousel_settings();
83
84 /**
85 * render style controls
86 */
87 $this->register_global_edd_style_controls_items();
88 $this->register_global_edd_style_controls_title();
89 $this->register_global_edd_style_controls_category();
90 $this->register_global_edd_style_controls_action_button();
91 $this->register_global_edd_style_controls_price();
92 $this->register_global_controls_navigation_style();
93 }
94
95 public function render_header() {
96 $settings = $this->get_settings_for_display();
97 $this->add_render_attribute('usk-edd-classic-carousel', 'class', ['usk-edd-classic-carousel'], true);
98 $this->add_render_attribute('usk-edd-classic-carousel', 'data-filter', [$settings['show_tab']]);
99 ?>
100 <div class="ultimate-store-kit">
101 <div <?php $this->print_render_attribute_string('usk-edd-classic-carousel'); ?>>
102 <?php
103 }
104 public function render_footer() { ?>
105 </div>
106 </div>
107 <?php
108 }
109
110
111 public function render() {
112 $this->register_global_template_carousel_header();
113 $this->render_loop_item();
114 $this->usk_register_global_template_carousel_footer();
115 }
116 public function render_loop_item() {
117 $settings = $this->get_settings_for_display();
118 $id = 'bdt-edd-classic-carousel-' . $this->get_id();
119 $this->query_product();
120 $wp_query = $this->get_query();
121 // print_r($wp_query);
122 if ($wp_query->have_posts()) {
123
124 ?>
125 <?php
126 while ($wp_query->have_posts()) {
127 $wp_query->the_post();
128
129 $this->add_render_attribute('edd-classic-carousel-item', 'class', 'usk-edd-classic-carousel-item swiper-slide', true);
130 ?>
131 <div <?php $this->print_render_attribute_string('edd-classic-carousel-item'); ?>>
132 <div class="usk-edd-classic-carousel-image-wrapper">
133 <div class="usk-edd-classic-carousel-image">
134 <a href="<?php the_permalink(); ?>">
135 <img src="<?php echo esc_url(wp_get_attachment_image_url(get_post_thumbnail_id(), $settings['image_size'])); ?>" alt="<?php echo esc_html(get_the_title()); ?>">
136 </a>
137 <div class="usk-action-button">
138 <?php if (function_exists('edd_price')) { ?>
139 <?php if (!edd_has_variable_prices(get_the_ID())) { ?>
140 <?php echo wp_kses_post(edd_get_purchase_link(get_the_ID(), 'Add to Cart', 'button')); ?>
141 <?php } ?>
142 <?php } ?>
143 <div class="usk-details-button">
144 <a href="<?php the_permalink(); ?>"><span><?php esc_html_e('View Details', 'ultimate-store-kit'); ?></span></a>
145 </div>
146 </div>
147 </div>
148
149
150 </div>
151 <div class="usk-edd-content">
152 <?php
153 if ($settings['show_category']) :
154 $category_list = wp_get_post_terms(get_the_ID(), 'download_category');
155 foreach ($category_list as $term) {
156 $term_link = get_term_link($term);
157 printf(
158 '<%1$s class="usk-edd-category"><a href="%2$s">%3$s</a></%1$s> ',
159 esc_attr( Utils::get_valid_html_tag( $settings['category_tags'] ) ),
160 esc_url( $term_link ),
161 esc_html( $term->name )
162 );
163 }
164 endif;
165
166 if ($settings['show_title']) :
167 printf(
168 '<%1$s class="usk-edd-title"><a href="%2$s">%3$s</a></%1$s>',
169 esc_attr(Utils::get_valid_html_tag($settings['title_tags'])),
170 esc_url(get_the_permalink()),
171 esc_html(get_the_title())
172 );
173 endif;
174
175 if ($settings['show_price']) : ?>
176 <div class="usk-edd-price">
177 <?php if (edd_has_variable_prices(get_the_ID())) {
178 esc_html_e('Starting at: ', 'ultimate-store-kit');
179 edd_price(get_the_ID());
180 } else {
181 edd_price(get_the_ID());
182 }
183 ?>
184 </div>
185 <?php
186 endif; ?>
187
188 </div>
189 </div>
190 <?php
191 }
192 ?>
193 <?php
194 wp_reset_postdata();
195 }
196 }
197 public function query_product() {
198 $settings = $this->get_settings_for_display();
199 $args = [];
200 $default = $this->getGroupControlQueryArgs();
201 $args['post_type'] = 'download';
202 $args['posts_per_page'] = $settings['product_limit'];
203 $default = $this->getGroupControlQueryArgs();
204 $args = array_merge($default, $args);
205 $this->_query = new WP_Query($args);
206 }
207 }
208