PluginProbe
Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder / 2.0.3
Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder v2.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 2.0.3, at modules/edd-standard-carousel/widgets/edd-standard-carousel.php

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