PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 3.22.2
GiveWP – Donation Plugin and Fundraising Platform v3.22.2
4.16.4 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 / donors / class-give-donor-wall.php
give / includes / donors Last commit date
actions.php 3 years ago backward-compatibility.php 7 years ago class-give-donor-stats.php 6 years ago class-give-donor-wall.php 1 year ago class-give-donors-query.php 1 year ago frontend-donor-functions.php 3 years ago
class-give-donor-wall.php
670 lines
1 <?php
2 /**
3 * Donor Wall
4 *
5 * @package Give
6 * @subpackage Classes/Give_Donor_Wall
7 * @copyright Copyright (c) 2020, GiveWP
8 * @license https://opensource.org/licenses/gpl-license GNU Public License
9 * @since 1.0
10 */
11
12 // Exit if accessed directly.
13 use Give\Donations\ValueObjects\DonationMetaKeys;
14
15 if (!defined('ABSPATH')) {
16 exit;
17 }
18
19
20 /**
21 * Give_Donor_Wall Class
22 *
23 * This class handles donors.
24 *
25 * @since 2.2.0
26 */
27 class Give_Donor_Wall {
28
29 /**
30 * Instance.
31 *
32 * @since 2.2.0
33 * @access private
34 * @var Give_Donor_Wall
35 */
36 private static $instance;
37
38 /**
39 * Singleton pattern.
40 *
41 * @since 2.2.0
42 * @access private
43 */
44 private function __construct() {
45 }
46
47
48 /**
49 * Get instance.
50 *
51 * @since 2.2.0
52 * @access public
53 * @return Give_Donor_Wall
54 */
55 public static function get_instance() {
56 if ( null === static::$instance ) {
57 self::$instance = new static();
58
59 self::$instance->setup_actions();
60 }
61
62 return self::$instance;
63 }
64
65 /**
66 * Setup the default hooks and actions
67 *
68 * @since 2.2.0
69 *
70 * @return void
71 */
72 public function setup_actions() {
73
74 add_shortcode( 'give_donor_wall', [ $this, 'render_shortcode' ] );
75
76 add_action( 'wp_ajax_give_get_donor_comments', [ $this, 'ajax_handler' ] );
77 add_action( 'wp_ajax_nopriv_give_get_donor_comments', [ $this, 'ajax_handler' ] );
78
79 }
80
81
82 /**
83 * Displays donors in a grid layout.
84 *
85 * @since 3.7.0 Sanitize attributes
86 * @since 2.27.0 Moved AJAX nonce verification to ajax_handler method.
87 * @since 2.2.0
88 *
89 * @param array $atts {
90 * Optional. Attributes of the donor wall shortcode.
91 *
92 * @type int $donors_per_page Number of donors per page. Default '20'.
93 * @type int $form_id The donation form to filter donors by. Default is all forms (no filter).
94 * @type bool $paged Whether to paginate donors. Default 'true'.
95 * @type string $ids A comma-separated list of donor IDs to display. Default empty.
96 * @type string $columns Maximum columns to display. Default 'best-fit'.
97 * Accepts 'best-fit', '1', '2', '3', '4'.
98 * @type bool $show_avatar Whether to display the donor's gravatar image if available. Default 'true'.
99 * @type bool $show_name Whether to display the donor's full name, first and last. Default 'true'.
100 * @type bool $show_company_name Whether to display the donor's company name. Default 'false'.
101 * @type bool $show_total Whether to display the donor's donation amount. Default 'true'.
102 * @type bool $show_comments Whether to display the donor's comment if they left one. Default 'true'.
103 * @type int $comment_length The number of words to display for the comments before a "Read more" field
104 * @type int $only_comments Whether to display the donors only with comment. Default 'false'.
105 * @type bool $show_time Whether to display date of the last donation. Default 'true'.
106 *
107 * @type string $readmore_text Link label for modal in which donor can read full comment.
108 * @type string $loadmore_text Button label which will load more donor comments.
109 * @type int $avatar_size Avatar image size in pixels without the "px". Default "75"
110 * @type string $orderby The order in which you want the donations to appear.
111 * Currently we are using this attribute internally and, it will sort donations by created date.
112 * @type string $order The order in which you want the donors to appear. Accepts "ASC". "DESC".
113 *
114 * }
115 * @return string|bool The markup of the form grid or false.
116 */
117 public function render_shortcode( $atts ) {
118 $atts = give_clean($atts);
119
120 $give_settings = give_get_settings();
121
122 $atts = $this->parse_atts( $atts );
123
124 _give_redirect_form_id($atts['form_id']);
125
126 $donations = $this->get_donation_data( $atts );
127 $html = '';
128
129 if ( $donations ) {
130
131 ob_start();
132
133 foreach ( $donations as $donation ) {
134 $donor = new Give_Donor($donation['_give_payment_donor_id']);
135 // Give/templates/shortcode-donor-wall.php.
136 give_get_template(
137 'shortcode-donor-wall',
138 [
139 $donation,
140 $give_settings,
141 $atts,
142 $donor
143 ]
144 );
145 }
146
147 $html = ob_get_clean();
148
149 // Return only donor html.
150 if (
151 isset( $atts['only_donor_html'] )
152 && wp_doing_ajax()
153 && $atts['only_donor_html']
154 ) {
155 return $html;
156 }
157 }
158
159 $temp_atts = $atts;
160 $temp_atts['paged'] = $atts['paged'] + 1;
161
162 $more_btn_html = sprintf(
163 '<input type="hidden" class="give-donor-wall-shortcode-attrs" data-shortcode="%s" data-nonce="%s">',
164 rawurlencode( http_build_query( $atts ) ),
165 wp_create_nonce( 'givewp-donor-wall-more' )
166 );
167
168 if ( $this->has_donations( $temp_atts ) ) {
169 $more_btn_html .= sprintf(
170 '<button class="give-donor__load_more give-button-with-loader"><span class="give-loading-animation"></span>%1$s</button>',
171 $atts['loadmore_text']
172 );
173 }
174
175 $html = $html
176 ? sprintf(
177 '<div class="give-wrap give-grid-ie-utility"><div class="give-grid give-grid--%1$s">%2$s</div>%3$s</div>',
178 esc_attr( $atts['columns'] ),
179 $html,
180 $more_btn_html
181 )
182 : '';
183
184 return $html;
185 }
186
187 /**
188 * Parse shortcode attributes
189 *
190 * @since 2.30.0
191 * @since 2.2.0
192 * @access public
193 *
194 * @param array $atts Shortcode attributes.
195 *
196 * @return array
197 */
198 public function parse_atts( $atts ) {
199 $atts = shortcode_atts(
200 [
201 'donors_per_page' => 12,
202 'form_id' => 0,
203 'paged' => 1,
204 'ids' => '',
205 'cats' => '',
206 'tags' => '',
207 'columns' => '3',
208 'anonymous' => true,
209 'show_avatar' => true,
210 'show_name' => true,
211 'show_company_name' => false,
212 'show_form' => false,
213 'show_total' => true,
214 'show_comments' => true,
215 'show_tributes' => true,
216 'comment_length' => 140,
217 'only_comments' => false,
218 'readmore_text' => esc_html__( 'Read more', 'give' ),
219 'loadmore_text' => esc_html__( 'Load more', 'give' ),
220 'avatar_size' => 75,
221 'color' => "#219653",
222 'orderby' => 'post_date',
223 'order' => 'DESC',
224 'hide_empty' => true, // Deprecated in 2.3.0
225 'only_donor_html' => false, // Only for internal use.,
226 'show_time' => true,
227 ],
228 $atts,
229 'give_donor_wall'
230 );
231
232 // Validate boolean attributes.
233 $boolean_attributes = [
234 'anonymous',
235 'show_avatar',
236 'show_name',
237 'show_company_name',
238 'show_total',
239 'show_comments',
240 'show_tributes',
241 'hide_empty',
242 'only_comments',
243 'only_donor_html',
244 'show_time'
245 ];
246
247 foreach ( $boolean_attributes as $att ) {
248 // Convert numeric to boolean.
249 // It will prevent condition check against boolean value.
250 if ( is_numeric( $atts[ $att ] ) ) {
251 $atts[ $att ] = (bool) $atts[ $att ];
252 }
253
254 $atts[ $att ] = filter_var( $atts[ $att ], FILTER_VALIDATE_BOOLEAN );
255 }
256
257 // Validate numeric attributes.
258 $numeric_attributes = [
259 'donors_per_page',
260 'paged',
261 'comment_length',
262 'avatar_size',
263 ];
264
265 foreach ( $numeric_attributes as $att ) {
266 // It will prevent condition check against numeric value.
267 $atts[ $att ] = absint( $atts[ $att ] );
268 }
269
270 // Validate comma separated numeric attributes and keep original data format ( comma separated string).
271 if ( ! empty( $atts['ids'] ) ) {
272 $atts['ids'] = implode( ',', $this->split_string($atts['ids'], 'absint') );
273 }
274
275 // Validate Form IDs
276 if ( ! empty( $atts['form_id'] ) ) {
277 $atts['form_id'] = implode( ',', $this->split_string($atts['form_id'], 'absint') );
278 }
279
280 // Donation form categories
281 if ( ! empty( $atts['cats'] ) ) {
282 $atts['cats'] = $this->split_string($atts['cats']);
283 }
284
285 // Donation form tags
286 if ( ! empty( $atts['tags'] ) ) {
287 $atts['tags'] = $this->split_string($atts['tags']);
288 }
289
290 return $atts;
291 }
292
293 /**
294 * Get donors
295 *
296 * @since 2.2.0
297 * @access public
298 *
299 * @param array $donor_query Donor query.
300 *
301 * @return array
302 */
303 public function get_donors( $donor_query ) {
304 $donor_query = new Give_Donors_Query( $donor_query );
305
306 return $donor_query->get_donors();
307 }
308
309
310 /**
311 * This function should return donor comment for ajax request.
312 *
313 * @since 2.27.0 Check nonce for AJAX request to prevent scrapping, see https://github.com/impress-org/givewp/issues/6374.
314 * @since 2.2.0
315 * @access public
316 */
317 public function ajax_handler() {
318 $shortcode_atts = array_map( 'give_clean', wp_parse_args( rawurldecode( $_POST['data'] ) ) ); // @codingStandardsIgnoreLine
319
320 // Get next page donor comments.
321 $shortcode_atts['paged'] = $shortcode_atts['paged'] + 1;
322 $shortcode_atts['only_donor_html'] = true;
323
324 check_ajax_referer( 'givewp-donor-wall-more', 'nonce' );
325
326 $donors_comment_html = $this->render_shortcode( $shortcode_atts );
327
328 // Check if donor comment remaining.
329 $temp_atts = $shortcode_atts;
330 $temp_atts['paged'] = $shortcode_atts['paged'] + 1;
331 $has_donors = $this->has_donations( $temp_atts ) ? 1 : 0;
332
333 // Remove internal shortcode param.
334 unset( $shortcode_atts['only_donor_html'] );
335
336 wp_send_json(
337 [
338 'shortcode' => rawurlencode( http_build_query( $shortcode_atts ) ),
339 'html' => $donors_comment_html,
340 'remaining' => $has_donors,
341 ]
342 );
343 }
344
345 /**
346 * Get query params
347 *
348 * @since 2.24.1
349 * @since 2.3.0
350 *
351 * @param array $atts
352 *
353 * @return array
354 */
355 private function get_query_param( $atts = [] ) {
356 $valid_order = [ 'ASC', 'DESC' ];
357 $valid_orderby = [ 'post_date', 'donation_amount' ];
358
359 $query_atts = [];
360
361 $query_atts['order'] = in_array( $atts['order'], $valid_order ) ? $atts['order'] : 'DESC';
362 $query_atts['orderby'] = in_array( $atts['orderby'], $valid_orderby ) ? $atts['orderby'] : 'post_date';
363 $query_atts['limit'] = absint( $atts['donors_per_page'] );
364 $query_atts['offset'] = absint( $atts['donors_per_page'] * ( $atts['paged'] - 1 ) );
365 $query_atts['form_id'] = implode( '\',\'', array_map( 'absint', explode( ',', $atts['form_id'] ) ) );
366 $query_atts['ids'] = implode( '\',\'', array_map( 'absint', explode( ',', $atts['ids'] ) ) );
367 $query_atts['cats'] = $atts['cats'];
368 $query_atts['tags'] = $atts['tags'];
369 $query_atts['only_comments'] = ( true === $atts['only_comments'] );
370 $query_atts['anonymous'] = ( true === $atts['anonymous'] );
371
372 return $query_atts;
373 }
374
375 /**
376 * Get donation data.
377 *
378 * @since 2.27.0 Change to read comment from donations meta table
379 * @since 2.3.0
380 *
381 * @param array $atts
382 *
383 * @return array
384 */
385 private function get_donation_data( $atts = [] ) {
386 global $wpdb;
387
388 // Bailout if donation does not exist.
389 if ( ! ( $donation_ids = $this->get_donations( $atts ) ) ) {
390 return [];
391 }
392
393 $donation_ids = ! empty( $donation_ids )
394 ? '\'' . implode( '\',\'', $donation_ids ) . '\''
395 : '';
396
397 // Backward compatibility
398 $donation_id_col = Give()->payment_meta->get_meta_type() . '_id';
399
400 $sql = "SELECT m1.*, p1.post_date as donation_date FROM {$wpdb->donationmeta} as m1
401 INNER JOIN {$wpdb->posts} as p1 ON (m1.{$donation_id_col}=p1.ID)
402 WHERE m1.{$donation_id_col} IN ( {$donation_ids} )
403 ORDER BY FIELD( p1.ID, {$donation_ids} )
404 ";
405
406 $results = (array) $wpdb->get_results( $sql );
407
408 if ( ! empty( $results ) ) {
409 $temp = [];
410
411 /* @var stdClass $result */
412 foreach ( $results as $result ) {
413 $temp[ $result->{$donation_id_col} ][ $result->meta_key ] = maybe_unserialize( $result->meta_value );
414
415 // Set donation date.
416 if ( empty( $temp[ $result->{$donation_id_col} ]['donation_date'] ) ) {
417 $temp[ $result->{$donation_id_col} ]['donation_date'] = $result->donation_date;
418 }
419 }
420
421 if ( ! empty( $temp ) ) {
422 foreach ( $temp as $donation_id => $donation_data ) {
423 $temp[ $donation_id ]['donation_id'] = $donation_id;
424
425 $temp[ $donation_id ]['name_initial'] = give_get_name_initial(
426 [
427 'firstname' => $donation_data['_give_donor_billing_first_name'],
428 'lastname' => $donation_data['_give_donor_billing_last_name'],
429 ]
430 );
431
432 $temp[$donation_id]['donor_comment'] = give_get_payment_meta(
433 $donation_id,
434 DonationMetaKeys::COMMENT
435 );
436 }
437 }
438
439 $results = ! empty( $temp ) ? $temp : [];
440 }
441
442 return $results;
443 }
444
445 /**
446 * Get donation list for specific query
447 *
448 * @since 3.17.2 fix - filter by only_comments attr
449 * @since 2.3.0
450 *
451 * @param array $atts
452 *
453 * @return array
454 */
455 private function get_donations( $atts = [] ) {
456 global $wpdb;
457
458 // Backward compatibility
459 $donation_id_col = Give()->payment_meta->get_meta_type() . '_id';
460
461 $query_params = $this->get_query_param( $atts );
462
463 $sql = "SELECT p1.ID FROM {$wpdb->posts} as p1";
464 $where = " WHERE p1.post_status IN ('publish') AND p1.post_type = 'give_payment'";
465
466 // exclude donation with zero amount from result.
467 $sql .= " INNER JOIN {$wpdb->donationmeta} as m1 ON (p1.ID = m1.{$donation_id_col})";
468 $where .= " AND m1.meta_key='_give_payment_total' AND m1.meta_value>0";
469
470 if ( $query_params['form_id'] ) {
471 $sql .= " INNER JOIN {$wpdb->donationmeta} as m2 ON (p1.ID = m2.{$donation_id_col})";
472 $where .= " AND m2.meta_key='_give_payment_form_id' AND m2.meta_value IN ('{$query_params['form_id']}')";
473 }
474
475 // Get donations only from specific donors.
476 if ( $query_params['ids'] ) {
477 $sql .= " INNER JOIN {$wpdb->donationmeta} as m3 ON (p1.ID = m3.{$donation_id_col})";
478 $where .= " AND m3.meta_key='_give_payment_donor_id' AND m3.meta_value IN ('{$query_params['ids']}')";
479 }
480
481 // exclude donations which does not has donor comment.
482 if ( $query_params['only_comments'] ) {
483 $sql .= " INNER JOIN {$wpdb->donationmeta} as m4 ON (p1.ID = m4.{$donation_id_col})";
484 $where .= " AND m4.meta_key='_give_donation_comment'";
485 }
486
487 // exclude anonymous donation form query based on query parameters.
488 if (
489 ! $query_params['anonymous']
490 || $query_params['only_comments']
491 ) {
492 $where .= " AND p1.ID NOT IN ( SELECT DISTINCT({$donation_id_col}) FROM {$wpdb->donationmeta} WHERE meta_key='_give_anonymous_donation' AND meta_value='1')";
493 }
494
495 // Handle Taxonomy
496 $args = [
497 'post_type' => 'give_forms',
498 'posts_per_page' => -1,
499 'fields' => 'ids',
500 'tax_query' => [],
501 ];
502
503 // Categories
504 if ( is_array($atts['cats'])) {
505 $args['tax_query']['conditions'] = ['relation' => 'OR'];
506
507 foreach ($atts['cats'] as $category) {
508 $args['tax_query']['conditions'][] = [
509 'operator' => 'IN',
510 'taxonomy' => 'give_forms_category',
511 'field' => 'slug',
512 'terms' => $category,
513 ];
514 }
515 }
516
517 // Tags
518 if ( is_array($atts['tags'])) {
519 if (empty($args['tax_query'])) {
520 $args['tax_query']['conditions'] = ['relation' => 'OR'];
521 }
522
523 foreach($atts['tags'] as $tag) {
524 $args['tax_query']['conditions'][] = [
525 'operator' => 'IN',
526 'taxonomy' => 'give_forms_tag',
527 'field' => 'slug',
528 'terms' => $tag,
529 ];
530 }
531 }
532
533 if ( ! empty( $args['tax_query'] ) ) {
534 $query = new WP_Query( $args );
535
536 if ( ! empty($query->posts) ) {
537 $form_ids = implode("','", $query->posts );
538 $sql .= " INNER JOIN {$wpdb->donationmeta} as m4 ON (p1.ID = m4.{$donation_id_col})";
539 $where .= " AND m4.meta_key='_give_payment_form_id' AND m4.meta_value IN ('{$form_ids}')";
540 }
541 }
542
543 // order by query based on parameter.
544 if ( 'donation_amount' === $query_params['orderby'] ) {
545 $order = " ORDER BY m1.meta_value+0 {$query_params['order']}";
546 } else {
547 $order = " ORDER BY p1.{$query_params['orderby']} {$query_params['order']}, p1.ID {$query_params['order']}";
548 }
549
550 $limit = " LIMIT {$query_params['limit']}";
551 $offset = " OFFSET {$query_params['offset']}";
552
553 $sql .= $where . $order . $limit . $offset;
554
555 return $wpdb->get_col( $sql );
556 }
557
558 /**
559 * Get donor comments
560 *
561 * @since 2.3.0
562 *
563 * @param array $donations_data
564 *
565 * @return array
566 */
567 private function get_donor_comments( $donations_data = [] ) {
568 global $wpdb;
569 $comments = [];
570
571 // Bailout.
572 if ( empty( $donations_data ) ) {
573 return $comments;
574 }
575
576 // Backward compatibility.
577 if (
578 ! give_has_upgrade_completed( 'v230_move_donor_note' )
579 || ! give_has_upgrade_completed( 'v230_move_donation_note' )
580 ) {
581 foreach ( $donations_data as $id => $data ) {
582 $comment = give_get_donor_donation_comment( $id, $data['_give_payment_donor_id'] );
583 $comments[ $id ] = ! empty( $comment ) ? $comment->comment_content : '';
584 }
585
586 return $comments;
587 }
588
589 $sql = "SELECT c1.comment_parent as donation_id, c1.comment_content as comment FROM {$wpdb->give_comments} as c1";
590 $sql .= " INNER JOIN {$wpdb->give_commentmeta} as cm1 ON (c1.comment_ID=cm1.give_comment_id)";
591 $where = [];
592
593 foreach ( $donations_data as $id => $data ) {
594 // Do not fetch comment for anonymous donation.
595 if ( ! empty( $data['_give_anonymous_donation'] ) ) {
596 continue;
597 }
598
599 $where[] = "(c1.comment_parent={$id} AND cm1.meta_key='_give_donor_id' AND cm1.meta_value={$data['_give_payment_donor_id']})";
600 }
601
602 $where = ' WHERE ' . implode( ' OR ', $where );
603 $where .= " AND c1.comment_type='donor_donation'";
604
605 $sql = $sql . $where;
606
607 $comments = (array) $wpdb->get_results( $sql );
608
609 if ( ! empty( $comments ) ) {
610 $comments = array_combine(
611 wp_list_pluck( $comments, 'donation_id' ),
612 wp_list_pluck( $comments, 'comment' )
613 );
614 }
615
616 return $comments;
617 }
618
619 /**
620 * Check if donation exist or not for specific query
621 *
622 * @since 2.3.0
623 *
624 * @param array $atts
625 *
626 * @return bool
627 */
628 private function has_donations( $atts = [] ) {
629 return (bool) $this->get_donations( $atts );
630 }
631
632 /**
633 * @since 2.20.0
634 *
635 * @param string $string
636 * @param null|callable $filter
637 * @param string $separator
638 *
639 * @return array
640 */
641 private function split_string($string, $filter = null, $separator = ',') {
642 if ( false === strpos( $string, $separator ) ) {
643 $string = trim( $string );
644
645 if (is_callable($filter)) {
646 $string = $filter($string);
647 }
648
649 return [$string];
650 }
651
652 return array_filter(
653 array_map(
654 static function( $value ) use ($filter) {
655 $value = trim( $value );
656
657 if (is_callable($filter)) {
658 return $filter($value);
659 }
660 return $value;
661 },
662 explode( $separator, $string )
663 )
664 );
665 }
666 }
667
668 // Initialize shortcode.
669 Give_Donor_Wall::get_instance();
670