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

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