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-standard-grid / widgets / edd-standard-grid.php

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

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