PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 2.0.2
ShopBuilder – WooCommerce Builder For Elementor v2.0.2
3.4.2 3.4.1 3.4.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 All 63 releases
← All changes | app/Models/QueryArgs.php +15 -151 2.1.22.0.2 View file →
@@ -7,10 +7,8 @@
7 7
8 8 namespace RadiusTheme\SB\Models;
9 9
10 10 // Do not allow directly accessing this file.
11 -use RadiusTheme\SB\Helpers\Fns;
12 -
13 11 if ( ! defined( 'ABSPATH' ) ) {
14 12 exit( 'This script cannot be accessed directly.' );
15 13 }
16 14
@@ -50,25 +48,18 @@
50 48 $this->getPostType();
51 49
52 50 // Building Args.
53 51 $this
54 - ->post_params()
55 - ->order_params()
56 - ->pagination_params( $isCarousel )
57 - ->tax_params();
52 + ->postParams()
53 + ->orderParams()
54 + ->paginationParams( $isCarousel )
55 + ->taxParams();
58 56
59 - } elseif ( 'wc_product' === $type ) {
60 - $this
61 - ->wc_post_params()
62 - ->wc_order_params()
63 - ->wc_pagination_params( $isCarousel )
64 - ->wc_tax_params();
65 -
66 57 } else {
67 58 $this
68 - ->get_tax_type()
69 - ->cat_params()
70 - ->cat_order_params();
59 + ->getTaxType()
60 + ->catParams()
61 + ->catOrderParams();
71 62 }
72 63
73 64 return apply_filters( 'rtsb/elements/' . $type . '_query_args', $this->args, $this->meta );
74 65 }
@@ -79,9 +70,9 @@
79 70 * @return void
80 71 */
81 72 private function getPostType() {
82 73 $this->args['post_type'] = [ rtsb()->post_type ];
83 - $this->args['post_status'] = 'draft';
74 + $this->args['post_status'] = 'publish';
84 75 }
85 76
86 77 /**
87 78 * Post type.
@@ -87,9 +78,9 @@
87 78 * Post type.
88 79 *
89 80 * @return QueryArgs
90 81 */
91 - private function get_tax_type() {
82 + private function getTaxType() {
92 83 $this->args['taxonomy'] = [ 'product_cat' ];
93 84 $this->args['post_status'] = 'publish';
94 85 $this->args['hierarchical'] = 1;
95 86
@@ -100,9 +91,9 @@
100 91 * Post parameters.
101 92 *
102 93 * @return QueryArgs
103 94 */
104 - private function post_params() {
95 + private function postParams() {
105 96 $post_in = isset( $this->meta['post_in'] ) ? sanitize_text_field( implode( ', ', $this->meta['post_in'] ) ) : null;
106 97 $post_not_in = isset( $this->meta['post_not_in'] ) ? sanitize_text_field( implode( ', ', $this->meta['post_not_in'] ) ) : null;
107 98 $author_in = isset( $this->meta['author_in'] ) ? sanitize_text_field( implode( ', ', $this->meta['author_in'] ) ) : null;
108 99 $limit = ( ( empty( $this->meta['limit'] ) || '-1' === $this->meta['limit'] ) ? 10000000 : absint( $this->meta['limit'] ) );
@@ -130,49 +121,15 @@
130 121 }
131 122
132 123 return $this;
133 124 }
134 - /**
135 - * WC Post parameters.
136 - *
137 - * @return QueryArgs
138 - */
139 - private function wc_post_params() {
140 - $post_in = isset( $this->meta['post_in'] ) ? sanitize_text_field( implode( ',', $this->meta['post_in'] ) ) : null;
141 - $post_not_in = isset( $this->meta['post_not_in'] ) ? sanitize_text_field( implode( ', ', $this->meta['post_not_in'] ) ) : null;
142 - $author_in = isset( $this->meta['author_in'] ) ? sanitize_text_field( implode( ',', $this->meta['author_in'] ) ) : null;
143 - $limit = ( ( empty( $this->meta['limit'] ) || '-1' === $this->meta['limit'] ) ? 10000000 : absint( $this->meta['limit'] ) );
144 - $offset = ! empty( $this->meta['offset'] ) ? absint( $this->meta['offset'] ) : 0;
145 125
146 - if ( $post_in ) {
147 - $post_in = explode( ',', $post_in );
148 - $this->args['include'] = $post_in;
149 - }
150 -
151 - if ( $post_not_in ) {
152 - $post_not_in = explode( ',', $post_not_in );
153 - $this->args['exclude'] = $post_not_in;
154 - }
155 -
156 - if ( $author_in ) {
157 - $this->args['author'] = $author_in;
158 - }
159 -
160 - $this->args['limit'] = $limit;
161 -
162 - if ( $offset ) {
163 - $this->args['offset'] = $offset;
164 - }
165 -
166 - return $this;
167 - }
168 -
169 126 /**
170 127 * Category parameters.
171 128 *
172 129 * @return QueryArgs
173 130 */
174 - private function cat_params() {
131 + private function catParams() {
175 132 $cats_in = isset( $this->meta['include_cats'] ) ? sanitize_text_field( implode( ', ', $this->meta['include_cats'] ) ) : null;
176 133 $cat_ids_in = isset( $this->meta['select_cat_ids'] ) ? esc_html( $this->meta['select_cat_ids'] ) : null;
177 134 $cats_not_in = isset( $this->meta['exclude_cats'] ) ? sanitize_text_field( implode( ', ', $this->meta['exclude_cats'] ) ) : null;
178 135 $limit = ( ( empty( $this->meta['cats_limit'] ) || '-1' === $this->meta['cats_limit'] ) ? 10000000 : absint( $this->meta['cats_limit'] ) );
@@ -230,9 +187,9 @@
230 187 * Order & Orderby parameters.
231 188 *
232 189 * @return QueryArgs
233 190 */
234 - private function order_params() {
191 + private function orderParams() {
235 192 $order_by = ( isset( $this->meta['order_by'] ) ? esc_html( $this->meta['order_by'] ) : null );
236 193 $order = ( isset( $this->meta['order'] ) ? esc_html( $this->meta['order'] ) : null );
237 194
238 195 if ( $order ) {
@@ -246,37 +203,13 @@
246 203 return $this;
247 204 }
248 205
249 206 /**
250 - * WC Order & Orderby parameters.
251 - *
252 - * @return QueryArgs
253 - */
254 - private function wc_order_params() {
255 - $order_by = ( isset( $this->meta['order_by'] ) ? esc_html( $this->meta['order_by'] ) : null );
256 - $order = ( isset( $this->meta['order'] ) ? esc_html( $this->meta['order'] ) : null );
257 -
258 - if ( $order ) {
259 - $this->args['order'] = $order;
260 - }
261 -
262 - if ( $order_by ) {
263 - $this->args['orderby'] = $order_by;
264 -
265 - if ( 'menu_order' === $order_by ) {
266 - $this->args['orderby'] = 'menu_order title';
267 - }
268 - }
269 -
270 - return $this;
271 - }
272 -
273 - /**
274 207 * Order & Orderby parameters.
275 208 *
276 209 * @return QueryArgs
277 210 */
278 - private function cat_order_params() {
211 + private function catOrderParams() {
279 212 $order_by = ( isset( $this->meta['cats_order_by'] ) ? esc_html( $this->meta['cats_order_by'] ) : 'name' );
280 213 $order = ( isset( $this->meta['cats_order'] ) ? esc_html( $this->meta['cats_order'] ) : 'DESC' );
281 214
282 215 if ( $order ) {
@@ -300,9 +233,9 @@
300 233 * @param bool $isCarousel Layout type.
301 234 *
302 235 * @return QueryArgs
303 236 */
304 - private function pagination_params( $isCarousel ) {
237 + private function paginationParams( $isCarousel ) {
305 238 $pagination = ! empty( $this->meta['pagination'] );
306 239 $limit = ( ( empty( $this->meta['limit'] ) || '-1' === $this->meta['limit'] ) ? 10000000 : absint( $this->meta['limit'] ) );
307 240
308 241 if ( $pagination ) {
@@ -336,58 +269,13 @@
336 269 return $this;
337 270 }
338 271
339 272 /**
340 - * Pagination parameters.
341 - *
342 - * @param bool $isCarousel Layout type.
343 - *
344 - * @return QueryArgs
345 - */
346 - private function wc_pagination_params( $isCarousel ) {
347 - $pagination = ! empty( $this->meta['pagination'] );
348 - $limit = ( ( empty( $this->meta['limit'] ) || '-1' === $this->meta['limit'] ) ? 10000000 : absint( $this->meta['limit'] ) );
349 -
350 - if ( $pagination ) {
351 - unset( $this->args['offset'] );
352 -
353 - $posts_per_page = ( ! empty( $this->meta['posts_per_page'] ) ? absint( $this->meta['posts_per_page'] ) : $limit );
354 -
355 - if ( $posts_per_page > $limit ) {
356 - $posts_per_page = $limit;
357 - }
358 -
359 - $this->args['paginate'] = true;
360 - $this->args['limit'] = $posts_per_page;
361 -
362 - if ( is_front_page() ) {
363 - $paged = ( get_query_var( 'page' ) ) ? get_query_var( 'page' ) : 1;
364 - } else {
365 - $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
366 - }
367 -
368 - $offset = $posts_per_page * ( (int) $paged - 1 );
369 - $this->args['page'] = $paged;
370 -
371 - if ( absint( $this->args['limit'] ) > $limit - $offset ) {
372 - $this->args['limit'] = $limit - $offset;
373 - $this->args['offset'] = $offset;
374 - }
375 - }
376 -
377 - if ( $isCarousel ) {
378 - $this->args['limit'] = $limit;
379 - }
380 -
381 - return $this;
382 - }
383 -
384 - /**
385 273 * Taxonomy parameters.
386 274 *
387 275 * @return QueryArgs
388 276 */
389 - private function tax_params() {
277 + private function taxParams() {
390 278 $categories = isset( $this->meta['categories'] ) ? array_filter( $this->meta['categories'] ) : [];
391 279 $tags = isset( $this->meta['tags'] ) ? array_filter( $this->meta['tags'] ) : [];
392 280 $attributes = isset( $this->meta['attributes'] ) ? array_filter( $this->meta['attributes'] ) : [];
393 281 $taxQ = [];
@@ -435,29 +323,5 @@
435 323
436 324 return $this;
437 325 }
438 326
439 - /**
440 - * Taxonomy parameters.
441 - *
442 - * @return QueryArgs
443 - */
444 - private function wc_tax_params() {
445 - $categories = isset( $this->meta['categories'] ) ? array_filter( $this->meta['categories'] ) : [];
446 - $tags = isset( $this->meta['tags'] ) ? array_filter( $this->meta['tags'] ) : [];
447 - $attributes = isset( $this->meta['attributes'] ) ? array_filter( $this->meta['attributes'] ) : [];
448 -
449 - if ( ! empty( $categories ) ) {
450 - $this->args['product_category_id'] = $categories;
451 - }
452 -
453 - if ( ! empty( $tags ) ) {
454 - $this->args['product_tag_id'] = $tags;
455 - }
456 -
457 - if ( ! empty( $attributes ) ) {
458 - $this->args['product_attribute_id'] = $attributes;
459 - }
460 -
461 - return $this;
462 - }
463 327 }