PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 2.9.2
GiveWP – Donation Plugin and Fundraising Platform v2.9.2
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 / class-give-comment.php
give / includes Last commit date
admin 5 years ago api 5 years ago database 6 years ago deprecated 5 years ago donors 5 years ago emails 6 years ago forms 5 years ago frontend 6 years ago gateways 5 years ago libraries 6 years ago payments 5 years ago actions.php 6 years ago ajax-functions.php 5 years ago class-give-async-process.php 6 years ago class-give-background-updater.php 6 years ago class-give-cache-setting.php 5 years ago class-give-cache.php 6 years ago class-give-cli-commands.php 6 years ago class-give-comment.php 6 years ago class-give-cron.php 6 years ago class-give-donate-form.php 6 years ago class-give-donor.php 6 years ago class-give-email-access.php 6 years ago class-give-license-handler.php 5 years ago class-give-logging.php 6 years ago class-give-readme-parser.php 6 years ago class-give-roles.php 6 years ago class-give-scripts.php 5 years ago class-give-session.php 5 years ago class-give-stats.php 6 years ago class-give-template-loader.php 6 years ago class-give-tooltips.php 6 years ago class-give-translation.php 6 years ago class-notices.php 5 years ago country-functions.php 5 years ago currencies-list.php 6 years ago currency-functions.php 6 years ago error-tracking.php 6 years ago filters.php 6 years ago formatting.php 6 years ago install.php 5 years ago login-register.php 6 years ago misc-functions.php 5 years ago plugin-compatibility.php 6 years ago post-types.php 5 years ago price-functions.php 6 years ago process-donation.php 5 years ago setting-functions.php 6 years ago shortcodes.php 6 years ago template-functions.php 6 years ago user-functions.php 6 years ago
class-give-comment.php
717 lines
1 <?php
2
3 /**
4 * Class for managing comments
5 *
6 * @package Give
7 * @subpackage Classes/Give_Cache
8 * @copyright Copyright (c) 2018, GiveWP
9 * @license https://opensource.org/licenses/gpl-license GNU Public License
10 * @since 2.2.0
11 */
12 class Give_Comment {
13 /**
14 * Instance.
15 *
16 * @since 2.2.0
17 * @access private
18 * @var
19 */
20 private static $instance;
21
22 /**
23 * Comment Types.
24 *
25 * @since 2.2.0
26 * @access private
27 * @var array
28 */
29 private $comment_types;
30
31 /**
32 * Comment Table.
33 *
34 * @since 2.3.0
35 * @access public
36 * @var Give_DB_Comments
37 */
38 public $db;
39
40 /**
41 * Comment Meta Table.
42 *
43 * @since 2.3.0
44 * @access public
45 * @var Give_DB_Comment_Meta
46 */
47 public $db_meta;
48
49 /**
50 * Singleton pattern.
51 *
52 * @since 2.2.0
53 * @access private
54 */
55 private function __construct() {
56 }
57
58
59 /**
60 * Get instance.
61 *
62 * @since 2.2.0
63 * @access pu
64 * @return Give_Comment
65 */
66 public static function get_instance() {
67 if ( null === static::$instance ) {
68 self::$instance = new static();
69 self::$instance->init();
70 }
71
72 return self::$instance;
73 }
74
75 /**
76 * Initialize
77 *
78 * @since 2.2.0
79 * @access private
80 */
81 private function init() {
82 $this->db = new Give_DB_Comments();
83 $this->db_meta = new Give_DB_Comment_Meta();
84
85 /**
86 * Filter the comment type
87 *
88 * @since 2.2.0
89 */
90 $this->comment_types = apply_filters(
91 'give_comment_type',
92 self::get_comment_types( array( 'payment', 'donor' ) )
93 );
94
95 // Backward compatibility.
96 if ( ! give_has_upgrade_completed( 'v230_move_donation_note' ) ) {
97 add_action( 'pre_get_comments', array( $this, 'hide_comments' ), 10 );
98 add_filter( 'comments_clauses', array( $this, 'hide_comments_pre_wp_41' ), 10, 1 );
99 add_filter( 'comment_feed_where', array( $this, 'hide_comments_from_feeds' ), 10, 1 );
100 add_filter( 'wp_count_comments', array( $this, 'remove_comments_from_comment_counts' ), 10, 2 );
101 add_filter( 'get_comment_author', array( $this, '__get_comment_author' ), 10, 3 );
102 }
103 }
104
105 /**
106 * Insert/Update comment
107 *
108 * @since 2.2.0
109 * @access public
110 *
111 * @param array $comment_args Comment arguments.
112 *
113 * @return int|WP_Error
114 */
115 public static function add( $comment_args = array() ) {
116 // Backward compatibility.
117 $func_args = func_get_args();
118 $comment_id = self::_bc_add( $func_args );
119 if ( ! is_null( $comment_id ) ) {
120 return $comment_id;
121 }
122
123 // Backward compatibility.
124 if ( is_numeric( $comment_args ) ) {
125 $comment_args = array(
126 'comment_parent' => $func_args[0],
127 'comment_content' => $func_args[1],
128 'comment_type' => 'payment' === $func_args[2] ? 'donation' : $func_args[1],
129 );
130 }
131
132 $comment_args = wp_parse_args(
133 $comment_args,
134 array(
135 'comment_ID' => 0,
136 'comment_parent' => 0,
137 'comment_type' => 'general',
138 )
139 );
140
141 $is_existing_comment = array_key_exists( 'comment_ID', $comment_args ) && ! empty( $comment_args['comment_ID'] );
142 $action_type = $is_existing_comment ? 'update' : 'insert';
143
144 /**
145 * Fires before inserting/updating payment|donor comment.
146 *
147 * @param int $id Payment|Donor ID.
148 * @param string $note Comment text.
149 *
150 * @since 1.0
151 */
152 do_action(
153 "give_pre_{$action_type}_{$comment_args['comment_type']}_note",
154 $comment_args['comment_parent'],
155 $comment_args['comment_content'],
156 $comment_args
157 );
158
159 $comment_id = Give()->comment->db->add(
160 array(
161 'comment_ID' => absint( $comment_args['comment_ID'] ),
162 'comment_content' => $comment_args['comment_content'],
163 'comment_parent' => $comment_args['comment_parent'],
164 'comment_type' => $comment_args['comment_type'],
165 )
166 );
167
168 /**
169 * Fires after payment|donor comment inserted/updated.
170 *
171 * @param int $comment_id Comment ID.
172 * @param int $id Payment|Donor ID.
173 * @param string $note Comment text.
174 *
175 * @since 1.0
176 */
177 do_action(
178 "give_{$action_type}_{$comment_args['comment_type']}_note",
179 $comment_args['comment_ID'],
180 $comment_args['comment_parent'],
181 $comment_args['comment_content'],
182 $comment_args
183 );
184
185 return $comment_id;
186 }
187
188
189 /**
190 * Delete comment
191 *
192 * @since 2.2.0
193 * @access public
194 *
195 * @param int $comment_id The comment ID to delete.
196 *
197 * @since 1.0
198 *
199 * @return bool True on success, false otherwise.
200 */
201 public static function delete( $comment_id ) {
202 // Backward compatibility.
203 $func_args = func_get_args();
204 $ret = self::_bc_delete( $func_args );
205 if ( ! is_null( $ret ) ) {
206 return $ret;
207 }
208
209 $ret = false;
210
211 // Bailout
212 if ( empty( $comment_id ) ) {
213 return $ret;
214 }
215
216 /* @var stdClass $comment */
217 $comment = Give()->comment->db->get_by( 'comment_ID', $comment_id );
218
219 if ( ! is_object( $comment ) ) {
220 return $ret;
221 }
222
223 $comment_type = $comment->comment_type;
224 $comment_parent = $comment->comment_parent;
225
226 /**
227 * Fires before deleting donation note.
228 *
229 * @param int $comment_id Comment ID.
230 * @param int $id Payment|Donor ID.
231 *
232 * @since 1.0
233 */
234 do_action( "give_pre_delete_{$comment_type}_note", $comment_id, $comment_parent );
235
236 $ret = Give()->comment->db->delete( $comment_id );
237
238 // Delete comment meta.
239 Give()->comment->db_meta->delete_all_meta( $comment_id );
240
241 /**
242 * Fires after donation note deleted.
243 *
244 * @param int $comment_id Note ID.
245 * @param int $id Payment|Donor ID.
246 * @param bool $ret Flag to check if comment deleted or not.
247 *
248 * @since 1.0
249 */
250 do_action( "give_post_delete_{$comment_type}_note", $comment_id, $comment_parent, $ret );
251
252 return $ret;
253 }
254
255
256 /**
257 * Get comments
258 *
259 * @since 2.2.0
260 * @access public
261 *
262 * @param array $comment_args
263 *
264 * @return array
265 */
266 public static function get( $comment_args ) {
267 global $wpdb;
268
269 // Backward compatibility.
270 $func_args = func_get_args();
271 $comments = self::_bc_get( $func_args );
272 if ( ! is_null( $comments ) ) {
273 return $comments;
274 }
275
276 // Backward compatibility.
277 if ( is_numeric( $comment_args ) ) {
278 $comment_args = array(
279 'comment_parent' => $func_args[0],
280 'comment_type' => 'payment' === $func_args[1] ? 'donation' : $func_args[1],
281 );
282 }
283
284 $comments = $wpdb->get_results( Give()->comment->db->get_sql( $comment_args ) );
285
286 return $comments;
287 }
288
289 /**
290 * Exclude comments from showing in Recent
291 * Comments widgets
292 *
293 * @since 2.2.0
294 * @access public
295 *
296 * @param object $query WordPress Comment Query Object.
297 *
298 * @return void
299 */
300 public function hide_comments( $query ) {
301 if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '>=' ) ) {
302 $types = isset( $query->query_vars['type__not_in'] ) ? $query->query_vars['type__not_in'] : array();
303 if ( ! is_array( $types ) ) {
304 $types = array( $types );
305 }
306
307 $types = array_filter( array_merge( $types, $this->comment_types ) );
308
309 $query->query_vars['type__not_in'] = $types;
310 }
311 }
312
313 /**
314 * Exclude notes (comments) from showing in Recent Comments widgets
315 *
316 * @since 2.2.0
317 * @access public
318 *
319 * @param array $clauses Comment clauses for comment query.
320 *
321 * @return array $clauses Updated comment clauses.
322 */
323 public function hide_comments_pre_wp_41( $clauses ) {
324 if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '<' ) ) {
325 foreach ( $this->comment_types as $comment_type ) {
326 $clauses['where'] .= " AND comment_type != \"{$comment_type}\"";
327 }
328 }
329
330 return $clauses;
331 }
332
333 /**
334 * Exclude notes (comments) from showing in comment feeds
335 *
336 * @since 2.2.0
337 * @access public
338 *
339 * @param string $where
340 *
341 * @return string $where
342 */
343 public function hide_comments_from_feeds( $where ) {
344 global $wpdb;
345
346 foreach ( $this->comment_types as $comment_type ) {
347 $where .= $wpdb->prepare( ' AND comment_type!=%s', $comment_type );
348 }
349
350 return $where;
351 }
352
353 /**
354 * Remove Give Comments from the wp_count_comments function
355 *
356 * @since 2.2.0
357 * @access public
358 *
359 * @param array $stats (empty from core filter).
360 * @param int $post_id Post ID.
361 *
362 * @return array|object Array of comment counts.
363 */
364 public function remove_comments_from_comment_counts( $stats, $post_id ) {
365 global $wpdb;
366
367 $post_id = (int) $post_id;
368
369 if ( apply_filters( 'give_count_payment_notes_in_comments', false ) ) {
370 return $stats;
371 }
372
373 $stats = Give_Cache::get_group( "comments-{$post_id}", 'counts' );
374
375 // Return result from cache.
376 if ( ! is_null( $stats ) ) {
377 return $stats;
378 }
379
380 $where = 'WHERE';
381
382 foreach ( $this->comment_types as $index => $comment_type ) {
383 $where .= ( $index ? ' AND ' : ' ' ) . "comment_type != \"{$comment_type}\"";
384 }
385
386 if ( $post_id > 0 ) {
387 $where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id );
388 }
389
390 $count = $wpdb->get_results(
391 "
392 SELECT comment_approved, COUNT( * ) AS num_comments
393 FROM {$wpdb->comments} {$where}
394 GROUP BY comment_approved
395 ",
396 ARRAY_A
397 );
398
399 $total = 0;
400 $approved = array(
401 '0' => 'moderated',
402 '1' => 'approved',
403 'spam' => 'spam',
404 'trash' => 'trash',
405 'post-trashed' => 'post-trashed',
406 );
407
408 foreach ( (array) $count as $row ) {
409 // Don't count post-trashed toward totals.
410 if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) {
411 $total += $row['num_comments'];
412 }
413 if ( isset( $approved[ $row['comment_approved'] ] ) ) {
414 $stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments'];
415 }
416 }
417
418 $stats['total_comments'] = $stats['all'] = $total;
419 foreach ( $approved as $key ) {
420 if ( empty( $stats[ $key ] ) ) {
421 $stats[ $key ] = 0;
422 }
423 }
424
425 $stats = (object) $stats;
426
427 Give_Cache::set_group( "comments-{$post_id}", $stats, 'counts' );
428
429 return $stats;
430 }
431
432 /**
433 * Get donor name
434 *
435 * @since 2.2.0
436 * @access public
437 *
438 * @param string $author
439 * @param int $comment_id
440 * @param WP_Comment $comment
441 *
442 * @return mixed
443 */
444 public function __get_comment_author( $author, $comment_id, $comment ) {
445 if ( in_array( $comment->comment_type, $this->comment_types ) ) {
446 switch ( $comment->comment_type ) {
447 case 'give_payment_note':
448 if ( get_comment_meta( $comment_id, '_give_donor_id', true ) ) {
449 $author = give_get_donor_name_by( $comment->comment_post_ID );
450 }
451 }
452 }
453
454 return $author;
455 }
456
457
458 /**
459 * Get comment types
460 *
461 * @since 2.2.0
462 * @access public
463 *
464 * @param array @comment_types
465 *
466 * @return array
467 */
468 public static function get_comment_types( $comment_types ) {
469 $_comment_types = array();
470 foreach ( $comment_types as $comment_type ) {
471 $_comment_types[] = "give_{$comment_type}_note";
472 }
473
474 return $_comment_types;
475 }
476
477 /**
478 * Get comments
479 * Note: This function add backward compatibility for get function
480 *
481 * @since 2.3.0
482 * @access public
483 *
484 * @param array $comment_args
485 *
486 * @return array|null
487 */
488 private static function _bc_get( $comment_args ) {
489 $comments = null;
490
491 if ( ! give_has_upgrade_completed( 'v230_move_donor_note' ) ) {
492 $id = $comment_args[0];
493 $comment_type = $comment_args[1];
494 $comment_args = isset( $comment_args[2] ) ? $comment_args[2] : array();
495 $search = isset( $comment_args[3] ) ? $comment_args[3] : '';
496
497 // Set default meta_query value.
498 if ( ! isset( $comment_args['meta_query'] ) ) {
499 $comment_args['meta_query'] = array();
500 }
501
502 // Bailout
503 if ( empty( $id ) || empty( $comment_type ) ) {
504 return $comments;
505 }
506
507 remove_action( 'pre_get_comments', array( self::$instance, 'hide_comments' ), 10 );
508 remove_filter( 'comments_clauses', array( self::$instance, 'hide_comments_pre_wp_41' ), 10 );
509
510 switch ( $comment_type ) {
511 case 'payment':
512 $comment_args['meta_query'] = ! empty( $comment_args['meta_query'] )
513 ? $comment_args['meta_query']
514 : array(
515 array(
516 'key' => '_give_donor_id',
517 'compare' => 'NOT EXISTS',
518 ),
519 );
520
521 $comments = get_comments(
522 wp_parse_args(
523 $comment_args,
524 array(
525 'post_id' => $id,
526 'order' => 'ASC',
527 'search' => $search,
528 'type' => 'give_payment_note',
529 )
530 )
531 );
532 break;
533
534 case 'donor':
535 $comment_args['meta_query'] = ! empty( $comment_args['meta_query'] )
536 ? $comment_args['meta_query']
537 : array(
538 array(
539 'key' => "_give_{$comment_type}_id",
540 'value' => $id,
541 ),
542 );
543
544 $comments = get_comments(
545 wp_parse_args(
546 $comment_args,
547 array(
548 'order' => 'ASC',
549 'search' => $search,
550 'type' => 'give_donor_note',
551 )
552 )
553 );
554 break;
555 }
556
557 add_action( 'pre_get_comments', array( self::$instance, 'hide_comments' ), 10, 1 );
558 add_filter( 'comments_clauses', array( self::$instance, 'hide_comments_pre_wp_41' ), 10, 1 );
559 }
560
561 return $comments;
562 }
563
564
565 /**
566 * Insert/Update comment
567 * Note: This function add backward compatibility for add function
568 *
569 * @since 2.3.0
570 * @access public
571 *
572 * @param array $comment_args Comment arguments.
573 *
574 * @return int|null|WP_Error
575 */
576 private static function _bc_add( $comment_args = array() ) {
577 $comment_id = null;
578
579 if ( ! give_has_upgrade_completed( 'v230_move_donor_note' ) ) {
580 $id = $comment_args[0];
581 $note = $comment_args[1];
582 $comment_type = $comment_args[2];
583 $comment_args = isset( $comment_args[3] ) ? $comment_args[3] : array();
584
585 // Bailout
586 if ( empty( $id ) || empty( $note ) || empty( $comment_type ) ) {
587 return new WP_Error( 'give_invalid_required_param', __( 'This comment has invalid ID or comment text or comment type', 'give' ) );
588 }
589
590 $is_existing_comment = array_key_exists( 'comment_ID', $comment_args ) && ! empty( $comment_args['comment_ID'] );
591 $action_type = $is_existing_comment ? 'update' : 'insert';
592
593 /**
594 * Fires before inserting/updating payment|donor comment.
595 *
596 * @param int $id Payment|Donor ID.
597 * @param string $note Comment text.
598 *
599 * @since 1.0
600 */
601 do_action( "give_pre_{$action_type}_{$comment_type}_note", $id, $note );
602
603 $comment_args = wp_parse_args(
604 $comment_args,
605 array(
606 'comment_post_ID' => $id,
607 'comment_content' => $note,
608 'user_id' => is_admin() ? get_current_user_id() : 0,
609 'comment_date' => current_time( 'mysql' ),
610 'comment_date_gmt' => current_time( 'mysql', 1 ),
611 'comment_approved' => 1,
612 'comment_parent' => 0,
613 'comment_author' => '',
614 'comment_author_IP' => '',
615 'comment_author_url' => '',
616 'comment_author_email' => '',
617 'comment_type' => "give_{$comment_type}_note",
618
619 )
620 );
621
622 // Check comment max length.
623 $error = wp_check_comment_data_max_lengths( $comment_args );
624 if ( is_wp_error( $error ) ) {
625 return $error;
626 }
627
628 // Remove moderation emails when comment posted.
629 remove_action( 'comment_post', 'wp_new_comment_notify_moderator' );
630 remove_action( 'comment_post', 'wp_new_comment_notify_postauthor' );
631
632 // Remove comment flood check.
633 remove_action( 'check_comment_flood', 'check_comment_flood_db', 10 );
634
635 $comment_id = $is_existing_comment
636 ? wp_update_comment( $comment_args )
637 : wp_new_comment( $comment_args, true );
638
639 // Add moderation emails when comment posted.
640 add_action( 'comment_post', 'wp_new_comment_notify_moderator' );
641 add_action( 'comment_post', 'wp_new_comment_notify_postauthor' );
642
643 // Add comment flood check.
644 add_action( 'check_comment_flood', 'check_comment_flood_db', 10, 4 );
645
646 update_comment_meta( $comment_id, "_give_{$comment_type}_id", $id );
647
648 /**
649 * Fires after payment|donor comment inserted/updated.
650 *
651 * @param int $comment_id Comment ID.
652 * @param int $id Payment|Donor ID.
653 * @param string $note Comment text.
654 *
655 * @since 1.0
656 */
657 do_action( "give_{$action_type}_{$comment_type}_note", $comment_id, $id, $note );
658 }
659
660 return $comment_id;
661 }
662
663 /**
664 * Delete comment
665 * Note: This function add backward compatibility for delete function
666 *
667 * @since 2.3.0
668 * @access public
669 *
670 * @param array $comment_args Comment arguments.
671 *
672 * @since 1.0
673 *
674 * @return bool True on success, false otherwise.
675 */
676 private static function _bc_delete( $comment_args ) {
677 $ret = null;
678
679 if ( ! give_has_upgrade_completed( 'v230_move_donor_note' ) ) {
680 $comment_id = $comment_args[0];
681 $id = $comment_args[1];
682 $comment_type = $comment_args[2];
683
684 $ret = false;
685
686 // Bailout
687 if ( empty( $id ) || empty( $comment_id ) || empty( $comment_type ) ) {
688 return $ret;
689 }
690 /**
691 * Fires before deleting donation note.
692 *
693 * @param int $comment_id Comment ID.
694 * @param int $id Payment|Donor ID.
695 *
696 * @since 1.0
697 */
698 do_action( "give_pre_delete_{$comment_type}_note", $comment_id, $id );
699
700 $ret = wp_delete_comment( $comment_id, true );
701
702 /**
703 * Fires after donation note deleted.
704 *
705 * @param int $comment_id Note ID.
706 * @param int $id Payment|Donor ID.
707 * @param bool $ret Flag to check if comment deleted or not.
708 *
709 * @since 1.0
710 */
711 do_action( "give_post_delete_{$comment_type}_note", $comment_id, $id, $ret );
712 }
713
714 return $ret;
715 }
716 }
717