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

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

204 lines 7.9 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\EddStandardCarousel\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_Standard_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-standard-carousel';
30 }
31
32 public function get_title() {
33 return esc_html__('EDD Standard Carousel', 'ultimate-store-kit');
34 }
35
36 public function get_icon() {
37 return 'usk-widget-icon usk-icon-edd-standard-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 public function get_style_depends() {
49 if ($this->usk_is_edit_mode()) {
50 return ['swiper', 'usk-all-styles'];
51 } else {
52 return ['swiper', 'usk-font', 'usk-edd-standard-carousel'];
53 }
54 }
55
56 public function get_script_depends() {
57 if ($this->usk_is_edit_mode()) {
58 return ['swiper', 'usk-site'];
59 } else {
60 return ['swiper', 'usk-edd-standard-carousel'];
61 }
62 }
63
64
65 public function get_query() {
66 return $this->_query;
67 }
68 public function has_widget_inner_wrapper(): bool {
69 return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
70 }
71 protected function register_controls() {
72 /**
73 * render controls layout
74 */
75 $this->register_global_edd_controls_carousel_layout();
76 $this->register_global_edd_controls_query();
77 $this->register_global_edd_controls_additional();
78
79 //swiper
80 $this->register_global_controls_carousel_navigation();
81 $this->register_global_controls_carousel_settings();
82
83 /**
84 * render style controls
85 */
86 $this->register_global_edd_style_controls_items();
87 $this->register_global_edd_style_controls_title();
88 $this->register_global_edd_style_controls_category();
89 $this->register_global_edd_style_controls_action_button();
90 $this->register_global_edd_style_controls_price();
91 $this->register_global_controls_navigation_style();
92 }
93
94 public function render_header() {
95 $settings = $this->get_settings_for_display();
96 $this->add_render_attribute('usk-edd-standard-carousel', 'class', ['usk-edd-standard-carousel'], true);
97 $this->add_render_attribute('usk-edd-standard-carousel', 'data-filter', [$settings['show_tab']]);
98 ?>
99 <div class="ultimate-store-kit">
100 <div <?php $this->print_render_attribute_string('usk-edd-standard-carousel'); ?>>
101 <?php
102 }
103 public function render_footer() { ?>
104 </div>
105 </div>
106 <?php
107 }
108
109
110 public function render() {
111 $this->register_global_template_carousel_header();
112 $this->render_loop_item();
113 $this->usk_register_global_template_carousel_footer();
114 }
115 public function render_loop_item() {
116 $settings = $this->get_settings_for_display();
117 $id = 'usk-edd-standard-carousel-' . $this->get_id();
118 $this->query_product();
119 $wp_query = $this->get_query();
120 // print_r($wp_query);
121 if ($wp_query->have_posts()) {
122
123 ?>
124 <?php
125 while ($wp_query->have_posts()) {
126 $wp_query->the_post();
127
128 $this->add_render_attribute('edd-standard-carousel-item', 'class', 'usk-edd-standard-carousel-item swiper-slide', true);
129 ?>
130 <div <?php $this->print_render_attribute_string('edd-standard-carousel-item'); ?>>
131 <div class="usk-edd-standard-carousel-image">
132 <a href="<?php the_permalink(); ?>">
133 <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()); ?>">
134 </a>
135 <div class="usk-action-button">
136 <?php if (function_exists('edd_price')) { ?>
137 <?php if (!edd_has_variable_prices(get_the_ID())) { ?>
138 <?php echo wp_kses_post(edd_get_purchase_link(get_the_ID(), 'Add to Cart', 'button')); ?>
139 <?php } ?>
140 <?php } ?>
141 <div class="usk-details-button">
142 <a href="<?php the_permalink(); ?>"><span><?php esc_html_e('View Details', 'ultimate-store-kit'); ?></span></a>
143 </div>
144 </div>
145 </div>
146 <div class="usk-edd-content">
147 <div class="usk-inner-content">
148 <?php
149 if ($settings['show_category']) :
150 $category_list = wp_get_post_terms(get_the_ID(), 'download_category');
151 foreach ($category_list as $term) {
152 $term_link = get_term_link($term);
153 printf(
154 '<%1$s class="usk-edd-category"><a href="%2$s">%3$s</a></%1$s> ',
155 esc_attr( Utils::get_valid_html_tag( $settings['category_tags'] ) ),
156 esc_url( $term_link ),
157 esc_html( $term->name )
158 );
159 }
160 endif;
161
162 if ($settings['show_title']) :
163 printf(
164 '<%1$s class="usk-edd-title"><a href="%2$s">%3$s</a></%1$s>',
165 esc_attr(Utils::get_valid_html_tag($settings['title_tags'])),
166 esc_url(get_the_permalink()),
167 esc_html(get_the_title())
168 );
169 endif;
170
171 if ($settings['show_price']) : ?>
172 <div class="usk-edd-price">
173 <?php if (edd_has_variable_prices(get_the_ID())) {
174 esc_html_e('Starting at: ', 'ultimate-store-kit');
175 edd_price(get_the_ID());
176 } else {
177 edd_price(get_the_ID());
178 }
179 ?>
180 </div>
181 <?php
182 endif; ?>
183 </div>
184 </div>
185 </div>
186 <?php
187 }
188 ?>
189 <?php
190 wp_reset_postdata();
191 }
192 }
193 public function query_product() {
194 $settings = $this->get_settings_for_display();
195 $args = [];
196 $default = $this->getGroupControlQueryArgs();
197 $args['post_type'] = 'download';
198 $args['posts_per_page'] = $settings['product_limit'];
199 $default = $this->getGroupControlQueryArgs();
200 $args = array_merge($default, $args);
201 $this->_query = new WP_Query($args);
202 }
203 }
204