PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 2.1.0
GiveWP – Donation Plugin and Fundraising Platform v2.1.0
4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 2.32.0 2.33.0 2.33.1 2.33.2 2.33.3 2.33.4 2.33.5 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.5.0 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.9.0 2.9.1 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.10.0 3.11.0 3.12.0 3.12.1 3.12.2 3.12.3 3.13.0 3.14.0 3.14.1 3.14.2 3.15.0 3.15.1 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.16.5 3.17.0 3.17.1 3.17.2 3.18.0 3.19.0 3.19.1 3.19.2 3.19.3 3.19.4 3.2.0 3.2.1 3.2.2 3.20.0 3.21.0 3.21.1 3.22.0 3.22.1 3.22.2 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 3.6.0 3.6.1 3.6.2 3.7.0 3.8.0 3.9.0 4.0.0 4.1.0 4.1.1 4.10.0 4.10.1 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.14.5 4.14.6 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.1 4.7.0 4.7.1 4.8.0 4.8.1 4.9.0 trunk 1.9.0 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.2 2.11.3 2.12.0 2.12.1 2.12.2 2.12.3 2.13.0 2.13.1 2.13.2 2.13.3 2.13.4 2.14.0 2.15.0 2.16.0 2.16.1 2.17.0 2.17.1 2.17.3 2.18.0 2.18.1 2.19.1 2.19.2 2.19.3 2.19.4 2.19.5 2.19.6 2.19.7 2.19.8 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.20.0 2.20.1 2.20.2 2.21.0 2.21.1 2.21.2 2.21.3 2.21.4 2.22.0 2.22.1 2.22.2 2.22.3 2.23.0 2.23.1 2.23.2 2.24.0 2.24.1 2.24.2 2.25.0 2.25.1 2.25.2 2.25.3 2.26.0 2.27.0 2.27.1 2.27.2 2.27.3 2.28.0 2.29.0 2.29.1 2.29.2
give / includes / payments / class-payments-query.php
give / includes / payments Last commit date
actions.php 8 years ago backward-compatibility.php 8 years ago class-give-payment.php 8 years ago class-give-sequential-donation-number.php 8 years ago class-payment-stats.php 8 years ago class-payments-query.php 8 years ago functions.php 8 years ago
class-payments-query.php
837 lines
1 <?php
2 /**
3 * Payments Query
4 *
5 * @package Give
6 * @subpackage Classes/Stats
7 * @copyright Copyright (c) 2016, WordImpress
8 * @license https://opensource.org/licenses/gpl-license GNU Public License
9 * @since 1.0
10 */
11
12 // Exit if accessed directly.
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 /**
18 * Give_Payments_Query Class
19 *
20 * This class is for retrieving payments data.
21 *
22 * Payments can be retrieved for date ranges and pre-defined periods.
23 *
24 * @since 1.0
25 */
26 class Give_Payments_Query extends Give_Stats {
27
28 /**
29 * Preserve args
30 *
31 * @since 1.8.17
32 * @access public
33 *
34 * @var array
35 */
36 public $_args = array();
37
38 /**
39 * The args to pass to the give_get_payments() query
40 *
41 * @since 1.0
42 * @access public
43 *
44 * @var array
45 */
46 public $args = array();
47
48 /**
49 * The payments found based on the criteria set
50 *
51 * @since 1.0
52 * @access public
53 *
54 * @var array
55 */
56 public $payments = array();
57
58 /**
59 * Default query arguments.
60 *
61 * Not all of these are valid arguments that can be passed to WP_Query. The ones that are not, are modified before
62 * the query is run to convert them to the proper syntax.
63 *
64 * @since 1.0
65 * @access public
66 *
67 * @param $args array The array of arguments that can be passed in and used for setting up this payment query.
68 */
69 public function __construct( $args = array() ) {
70 $defaults = array(
71 'output' => 'payments',
72 'post_type' => array( 'give_payment' ),
73 'start_date' => false,
74 'end_date' => false,
75 'number' => 20,
76 'page' => null,
77 'orderby' => 'ID',
78 'order' => 'DESC',
79 'user' => null,
80 'donor' => null,
81 'status' => give_get_payment_status_keys(),
82 'meta_key' => null,
83 'year' => null,
84 'month' => null,
85 'day' => null,
86 's' => null,
87 'search_in_notes' => false,
88 'children' => false,
89 'fields' => null,
90 'gateway' => null,
91 'give_forms' => null,
92 'offset' => null,
93
94 // Currently these params only works with get_payment_by_group
95 'group_by' => '',
96 'count' => false,
97 );
98
99 $this->args = $this->_args = wp_parse_args( $args, $defaults );
100
101 $this->init();
102 }
103
104 /**
105 * Set a query variable.
106 *
107 * @since 1.0
108 * @access public
109 *
110 * @param $query_var
111 * @param $value
112 */
113 public function __set( $query_var, $value ) {
114 if ( in_array( $query_var, array( 'meta_query', 'tax_query' ) ) ) {
115 $this->args[ $query_var ][] = $value;
116 } else {
117 $this->args[ $query_var ] = $value;
118 }
119 }
120
121 /**
122 * Unset a query variable.
123 *
124 * @since 1.0
125 * @access public
126 *
127 * @param $query_var
128 */
129 public function __unset( $query_var ) {
130 unset( $this->args[ $query_var ] );
131 }
132
133 /**
134 * Modify the query/query arguments before we retrieve payments.
135 *
136 * @since 1.0
137 * @access public
138 *
139 * @return void
140 */
141 public function init() {
142 }
143
144
145 /**
146 * Set query filter.
147 *
148 * @since 1.8.9
149 * @access private
150 */
151 private function set_filters() {
152 // Reset param to apply filters.
153 // While set filters $args will get override and multiple get_payments call will not work.
154 $this->args = $this->_args;
155
156 $this->date_filter_pre();
157 $this->orderby();
158 $this->status();
159 $this->month();
160 $this->per_page();
161 $this->page();
162 $this->user();
163 $this->donor();
164 $this->search();
165 $this->mode();
166 $this->children();
167 $this->give_forms();
168 $this->gateway_filter();
169
170 add_filter( 'posts_orderby', array( $this, 'custom_orderby' ), 10, 2 );
171
172 /**
173 * Fires after setup filters.
174 *
175 * @since 1.0
176 *
177 * @param Give_Payments_Query $this Payments query object.
178 */
179 do_action( 'give_pre_get_payments', $this );
180 }
181
182 /**
183 * Unset query filter.
184 *
185 * @since 1.8.9
186 * @access private
187 */
188 private function unset_filters() {
189 remove_filter( 'posts_orderby', array( $this, 'custom_orderby' ) );
190
191 /**
192 * Fires after retrieving payments.
193 *
194 * @since 1.0
195 *
196 * @param Give_Payments_Query $this Payments query object.
197 */
198 do_action( 'give_post_get_payments', $this );
199 }
200
201
202 /**
203 * Retrieve payments.
204 *
205 * The query can be modified in two ways; either the action before the
206 * query is run, or the filter on the arguments (existing mainly for backwards
207 * compatibility).
208 *
209 * @since 1.0
210 * @access public
211 *
212 * @return array
213 */
214 public function get_payments() {
215 global $post;
216
217 $cache_key = Give_Cache::get_key( 'give_payment_query', $this->args, false );
218 $this->payments = Give_Cache::get_db_query( $cache_key );
219
220 // Return cached result.
221 if ( ! is_null( $this->payments ) ) {
222 return $this->payments;
223 }
224
225
226 // Modify the query/query arguments before we retrieve payments.
227 $this->set_filters();
228
229 $query = new WP_Query( $this->args );
230 $this->payments = array();
231
232 $custom_output = array(
233 'payments',
234 'give_payments',
235 );
236
237 if ( ! in_array( $this->args['output'], $custom_output ) ) {
238 return $query->posts;
239 }
240
241 if ( $query->have_posts() ) {
242 $previous_post = $post;
243
244 while ( $query->have_posts() ) {
245 $query->the_post();
246
247 $payment_id = get_post()->ID;
248 $payment = new Give_Payment( $payment_id );
249
250 $this->payments[] = apply_filters( 'give_payment', $payment, $payment_id, $this );
251 }
252
253 wp_reset_postdata();
254
255 // Prevent nest loop from producing unexpected results.
256 if( $previous_post instanceof WP_Post ) {
257 $post = $previous_post;
258 setup_postdata( $post );
259 }
260 }
261
262 Give_Cache::set_db_query( $cache_key, $this->payments );
263
264 // Remove query filters after we retrieve payments.
265 $this->unset_filters();
266
267 return $this->payments;
268 }
269
270 /**
271 * Get payments by group
272 *
273 * @since 1.8.17
274 * @access public
275 *
276 * @return array
277 */
278 public function get_payment_by_group() {
279 global $wpdb;
280
281 $allowed_groups = array( 'post_status' );
282 $result = array();
283
284
285 if ( in_array( $this->args['group_by'], $allowed_groups ) ) {
286 // Set only count in result.
287 if ( $this->args['count'] ) {
288
289 $this->set_filters();
290
291 $new_results = $wpdb->get_results( $this->get_sql(), ARRAY_N );
292
293 $this->unset_filters();
294
295 foreach ( $new_results as $results ) {
296 $result[ $results[0] ] = $results[1];
297 }
298
299 switch ( $this->args['group_by'] ) {
300 case 'post_status':
301
302 /* @var Give_Payment $donation */
303 foreach ( give_get_payment_status_keys() as $status ) {
304 if ( ! isset( $result[ $status ] ) ) {
305 $result[ $status ] = 0;
306 }
307 }
308
309 break;
310 }
311 } else {
312 $donations = $this->get_payments();
313
314 /* @var $donation Give_Payment */
315 foreach ( $donations as $donation ) {
316 $result[ $donation->{$this->args['group_by']} ][] = $donation;
317 }
318 }
319 }
320
321
322 /**
323 * Filter the result
324 *
325 * @since 1.8.17
326 */
327 return apply_filters( 'give_get_payment_by_group', $result, $this );
328 }
329
330 /**
331 * If querying a specific date, add the proper filters.
332 *
333 * @since 1.0
334 * @access public
335 *
336 * @return void
337 */
338 public function date_filter_pre() {
339 if ( ! ( $this->args['start_date'] || $this->args['end_date'] ) ) {
340 return;
341 }
342
343 $this->setup_dates( $this->args['start_date'], $this->args['end_date'] );
344 $is_start_date = property_exists( __CLASS__, 'start_date' );
345 $is_end_date = property_exists( __CLASS__, 'end_date' );
346
347 if ( $is_start_date || $is_end_date ) {
348 $date_query = array();
349
350 if ( $is_start_date && ! is_wp_error( $this->start_date ) ) {
351 $date_query['after'] = date( 'Y-m-d H:i:s', $this->start_date );
352 }
353
354 if ( $is_end_date && ! is_wp_error( $this->end_date ) ) {
355 $date_query['before'] = date( 'Y-m-d H:i:s', $this->end_date );
356 }
357
358 // Include Start Date and End Date while querying.
359 $date_query['inclusive'] = true;
360
361 $this->__set( 'date_query', $date_query );
362
363 }
364 }
365
366 /**
367 * Post Status
368 *
369 * @since 1.0
370 * @access public
371 *
372 * @return void
373 */
374 public function status() {
375 if ( ! isset( $this->args['status'] ) ) {
376 return;
377 }
378
379 $this->__set( 'post_status', $this->args['status'] );
380 $this->__unset( 'status' );
381 }
382
383 /**
384 * Current Page
385 *
386 * @since 1.0
387 * @access public
388 *
389 * @return void
390 */
391 public function page() {
392 if ( ! isset( $this->args['page'] ) ) {
393 return;
394 }
395
396 $this->__set( 'paged', $this->args['page'] );
397 $this->__unset( 'page' );
398 }
399
400 /**
401 * Posts Per Page
402 *
403 * @since 1.0
404 * @access public
405 *
406 * @return void
407 */
408 public function per_page() {
409
410 if ( ! isset( $this->args['number'] ) ) {
411 return;
412 }
413
414 if ( $this->args['number'] == - 1 ) {
415 $this->__set( 'nopaging', true );
416 } else {
417 $this->__set( 'posts_per_page', $this->args['number'] );
418 }
419
420 $this->__unset( 'number' );
421 }
422
423 /**
424 * Current Month
425 *
426 * @since 1.0
427 * @access public
428 *
429 * @return void
430 */
431 public function month() {
432 if ( ! isset( $this->args['month'] ) ) {
433 return;
434 }
435
436 $this->__set( 'monthnum', $this->args['month'] );
437 $this->__unset( 'month' );
438 }
439
440 /**
441 * Order by
442 *
443 * @since 1.0
444 * @access public
445 *
446 * @return void
447 */
448 public function orderby() {
449 switch ( $this->args['orderby'] ) {
450 case 'amount':
451 $this->__set( 'orderby', 'meta_value_num' );
452 $this->__set( 'meta_key', '_give_payment_total' );
453 break;
454
455 case 'status':
456 $this->__set( 'orderby', 'post_status' );
457 break;
458
459 case 'donation_form':
460 $this->__set( 'orderby', 'meta_value' );
461 $this->__set( 'meta_key', '_give_payment_form_title' );
462 break;
463
464 default:
465 $this->__set( 'orderby', $this->args['orderby'] );
466 break;
467 }
468 }
469
470 /**
471 * Custom orderby.
472 * Note: currently custom sorting is only used for donation listing page.
473 *
474 * @since 1.8
475 * @access public
476 *
477 * @param string $order
478 * @param WP_Query $query
479 *
480 * @return mixed
481 */
482 public function custom_orderby( $order, $query ) {
483
484 if ( ! empty( $query->query['post_type'] ) ) {
485 $post_types = is_array( $query->query['post_type'] ) ? $query->query['post_type'] : array( $query->query['post_type'] );
486
487 if ( ! in_array( 'give_payment', $post_types ) || ! isset( $query->query['orderby'] ) || is_array( $query->query['orderby'] ) ) {
488 return $order;
489 }
490
491 global $wpdb;
492 switch ( $query->query['orderby'] ) {
493 case 'post_status':
494 $order = $wpdb->posts . '.post_status ' . strtoupper( $query->query['order'] );
495 break;
496 }
497 }
498
499 return $order;
500 }
501
502 /**
503 * Specific User
504 *
505 * @since 1.0
506 * @access public
507 *
508 * @return void
509 */
510 public function user() {
511 if ( is_null( $this->args['user'] ) ) {
512 return;
513 }
514
515 if ( is_numeric( $this->args['user'] ) ) {
516 $user_key = '_give_payment_donor_id';
517 } else {
518 $user_key = '_give_payment_donor_email';
519 }
520
521 $this->__set(
522 'meta_query', array(
523 'key' => $user_key,
524 'value' => $this->args['user'],
525 )
526 );
527 }
528
529 /**
530 * Specific donor id
531 *
532 * @access public
533 * @since 1.8.9
534 * @return void
535 */
536 public function donor() {
537 if ( is_null( $this->args['donor'] ) || ! is_numeric( $this->args['donor'] ) ) {
538 return;
539 }
540
541 $donor_meta_type = Give()->donor_meta->meta_type;
542
543 $this->__set( 'meta_query', array(
544 'key' => "_give_payment_{$donor_meta_type}_id",
545 'value' => (int) $this->args['donor'],
546 ) );
547 }
548
549 /**
550 * Search
551 *
552 * @since 1.0
553 * @access public
554 *
555 * @return void
556 */
557 public function search() {
558
559 if ( ! isset( $this->args['s'] ) ) {
560 return;
561 }
562
563 $search = trim( $this->args['s'] );
564
565 if ( empty( $search ) ) {
566 return;
567 }
568
569 $is_email = is_email( $search ) || strpos( $search, '@' ) !== false;
570 $is_user = strpos( $search, strtolower( 'user:' ) ) !== false;
571
572 if ( ! empty( $this->args['search_in_notes'] ) ) {
573
574 $notes = give_get_payment_notes( 0, $search );
575
576 if ( ! empty( $notes ) ) {
577
578 $payment_ids = wp_list_pluck( (array) $notes, 'comment_post_ID' );
579
580 $this->__set( 'post__in', $payment_ids );
581 }
582
583 $this->__unset( 's' );
584
585 } elseif ( $is_email || strlen( $search ) == 32 ) {
586
587 $key = $is_email ? '_give_payment_donor_email' : '_give_payment_purchase_key';
588 $search_meta = array(
589 'key' => $key,
590 'value' => $search,
591 'compare' => 'LIKE',
592 );
593
594 $this->__set( 'meta_query', $search_meta );
595 $this->__unset( 's' );
596
597 } elseif ( $is_user ) {
598
599 $search_meta = array(
600 'key' => '_give_payment_donor_id',
601 'value' => trim( str_replace( 'user:', '', strtolower( $search ) ) ),
602 );
603
604 $this->__set( 'meta_query', $search_meta );
605
606 $this->__unset( 's' );
607
608 } elseif ( is_numeric( $search ) ) {
609
610 $post = get_post( $search );
611
612 if ( is_object( $post ) && $post->post_type == 'give_payment' ) {
613
614 $arr = array();
615 $arr[] = $search;
616 $this->__set( 'post__in', $arr );
617 $this->__unset( 's' );
618 }
619 } elseif ( '#' == substr( $search, 0, 1 ) ) {
620
621 $search = str_replace( '#:', '', $search );
622 $search = str_replace( '#', '', $search );
623 $this->__set( 'give_forms', $search );
624 $this->__unset( 's' );
625
626 } else {
627 $this->__set( 's', $search );
628
629 }
630
631 }
632
633 /**
634 * Payment Mode
635 *
636 * @since 1.0
637 * @access public
638 *
639 * @return void
640 */
641 public function mode() {
642 if ( empty( $this->args['mode'] ) || $this->args['mode'] == 'all' ) {
643 $this->__unset( 'mode' );
644
645 return;
646 }
647
648 $this->__set(
649 'meta_query', array(
650 'key' => '_give_payment_mode',
651 'value' => $this->args['mode'],
652 )
653 );
654 }
655
656 /**
657 * Children
658 *
659 * @since 1.0
660 * @access public
661 *
662 * @return void
663 */
664 public function children() {
665 if ( empty( $this->args['children'] ) ) {
666 $this->__set( 'post_parent', 0 );
667 }
668 $this->__unset( 'children' );
669 }
670
671 /**
672 * Specific Give Form
673 *
674 * @since 1.0
675 * @access public
676 *
677 * @return void
678 */
679 public function give_forms() {
680
681 if ( empty( $this->args['give_forms'] ) ) {
682 return;
683 }
684
685 $compare = '=';
686
687 if ( is_array( $this->args['give_forms'] ) ) {
688 $compare = 'IN';
689 }
690
691 $this->__set(
692 'meta_query',
693 array(
694 'key' => '_give_payment_form_id',
695 'value' => $this->args['give_forms'],
696 'compare' => $compare,
697 )
698 );
699
700 $this->__unset( 'give_forms' );
701
702 }
703
704 /**
705 * Specific Gateway
706 *
707 * @since 1.8.17
708 * @access public
709 *
710 * @return void
711 */
712 public function gateway_filter() {
713
714 if ( empty( $this->args['gateway'] ) ) {
715 return;
716 }
717
718 $compare = '=';
719
720 if ( is_array( $this->args['gateway'] ) ) {
721 $compare = 'IN';
722 }
723
724 $this->__set(
725 'meta_query', array(
726 array(
727 'key' => '_give_payment_gateway',
728 'value' => $this->args['gateway'],
729 'compare' => $compare,
730 ),
731 )
732 );
733
734 $this->__unset( 'gateway' );
735
736 }
737
738
739 /**
740 * Get sql query
741 *
742 * Note: Internal purpose only. We are developing on this fn.
743 *
744 * @since 1.8.18
745 * @access public
746 * @global $wpdb
747 *
748 * @return string
749 */
750 private function get_sql() {
751 global $wpdb;
752
753 $where = "WHERE {$wpdb->posts}.post_type = 'give_payment'";
754 $where .= " AND {$wpdb->posts}.post_status IN ('" . implode( "','", $this->args['post_status'] ) . "')";
755
756 if( is_numeric( $this->args['post_parent'] ) ) {
757 $where .= " AND {$wpdb->posts}.post_parent={$this->args['post_parent']}";
758 }
759
760 // Set orderby.
761 $orderby = "ORDER BY {$wpdb->posts}.{$this->args['orderby']}";
762 $group_by = '';
763
764 // Set group by.
765 if ( ! empty( $this->args['group_by'] ) ) {
766 $group_by = "GROUP BY {$wpdb->posts}.{$this->args['group_by']}";
767 }
768
769 // Set offset.
770 if (
771 empty( $this->args['nopaging'] ) &&
772 empty( $this->args['offset'] ) &&
773 ( ! empty( $this->args['page'] ) && 0 < $this->args['page'] )
774 ) {
775 $this->args['offset'] = $this->args['posts_per_page'] * ( $this->args['page'] - 1 );
776 }
777
778 // Set fields.
779 $fields = "{$wpdb->posts}.*";
780 if ( ! empty( $this->args['fields'] ) && 'all' !== $this->args['fields'] ) {
781 if ( is_string( $this->args['fields'] ) ) {
782 $fields = "{$wpdb->posts}.{$this->args['fields']}";
783 } elseif ( is_array( $this->args['fields'] ) ) {
784 $fields = "{$wpdb->posts}." . implode( " , {$wpdb->posts}.", $this->args['fields'] );
785 }
786 }
787
788 // Set count.
789 if ( ! empty( $this->args['count'] ) ) {
790 $fields = "COUNT({$wpdb->posts}.ID)";
791
792 if ( ! empty( $this->args['group_by'] ) ) {
793 $fields = "{$wpdb->posts}.{$this->args['group_by']}, {$fields}";
794 }
795 }
796
797 // Date query.
798 if ( ! empty( $this->args['date_query'] ) ) {
799 $date_query_obj = new WP_Date_Query( $this->args['date_query'] );
800 $where .= str_replace(
801 array(
802 "\n",
803 '( (',
804 '))',
805 ),
806 array(
807 '',
808 '( (',
809 ') )',
810 ),
811 $date_query_obj->get_sql()
812 );
813 }
814
815 // Meta query.
816 if ( ! empty( $this->args['meta_query'] ) ) {
817 $meta_query_obj = new WP_Meta_Query( $this->args['meta_query'] );
818 $where = implode( ' ', $meta_query_obj->get_sql( 'post', $wpdb->posts, 'ID' ) ) . " {$where}";
819 $where = Give()->payment_meta->__rename_meta_table_name( $where, 'posts_where' );
820 }
821
822 // Set sql query.
823 $sql = $wpdb->prepare(
824 "SELECT {$fields} FROM {$wpdb->posts} LIMIT %d,%d;",
825 absint( $this->args['offset'] ),
826 ( empty( $this->args['nopaging'] ) ? absint( $this->args['posts_per_page'] ) : 99999999999 )
827 );
828
829 // $where, $orderby and order already prepared query they can generate notice if you re prepare them in above.
830 // WordPress consider LIKE condition as placeholder if start with s,f, or d.
831 $sql = str_replace( 'LIMIT', "{$where} {$group_by} {$orderby} {$this->args['order']} LIMIT", $sql );
832
833 return $sql;
834 }
835
836 }
837