PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.13
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.13
1.8.13 1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 1.7.0.9 All 211 releases
← All changes | includes/data/class-charitable-donors-db.php +37 -12 1.6.60 → 1.8.13 View file →
@@ -2,13 +2,13 @@
2 2 /**
3 3 * Charitable Donors DB class.
4 4 *
5 5 * @package Charitable/Classes/Charitable_Donors_DB
6 - * @author Eric Daams
7 - * @copyright Copyright (c) 2022, Studio 164a
6 + * @author David Bisset
7 + * @copyright Copyright (c) 2023, WP Charitable LLC
8 8 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9 9 * @since 1.0.0
10 - * @version 1.6.5
10 + * @version 1.8.9.1
11 11 */
12 12
13 13 // Exit if accessed directly.
14 14 if ( ! defined( 'ABSPATH' ) ) {
@@ -110,9 +110,9 @@
110 110 public function get_db_columns() {
111 111 if ( ! isset( $this->db_columns ) ) {
112 112 global $wpdb;
113 113
114 - $columns = $wpdb->get_results( "SHOW COLUMNS FROM $this->table_name" );
114 + $columns = $wpdb->get_results( "SHOW COLUMNS FROM $this->table_name" ); // phpcs:ignore
115 115 $this->db_columns = $columns ? wp_list_pluck( $columns, 'Field' ) : array();
116 116 }
117 117
118 118 return $this->db_columns;
@@ -143,8 +143,9 @@
143 143 /**
144 144 * Default column values.
145 145 *
146 146 * @since 1.0.0
147 + * @version 1.8.9.1
147 148 *
148 149 * @return array
149 150 */
150 151 public function get_column_defaults() {
@@ -149,9 +150,9 @@
149 150 */
150 151 public function get_column_defaults() {
151 152 $defaults = array(
152 153 'user_id' => 0,
153 - 'date_joined' => date( 'Y-m-d H:i:s' ),
154 + 'date_joined' => date( 'Y-m-d H:i:s' ), // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
154 155 );
155 156
156 157 return array_intersect_key( $defaults, array_flip( $this->get_db_columns() ) );
157 158 }
@@ -321,11 +322,11 @@
321 322 */
322 323 public function get_personal_data( $email ) {
323 324 global $wpdb;
324 325
325 - return $wpdb->get_results(
326 + return $wpdb->get_results( // phpcs:ignore
326 327 $wpdb->prepare(
327 - "SELECT donor_id, email, first_name, last_name FROM {$this->table_name} WHERE email = %s;",
328 + "SELECT donor_id, email, first_name, last_name FROM {$this->table_name} WHERE email = %s;", // phpcs:ignore
328 329 $email
329 330 )
330 331 );
331 332 }
@@ -330,8 +331,32 @@
330 331 );
331 332 }
332 333
333 334 /**
335 + * Return a donor's personal data, given their donor id.
336 + *
337 + * @since 1.8.1
338 + *
339 + * @global $wpdb WPDB
340 + * @param int $donor_id Donor ID.
341 + * @return array|object|null Database query results
342 + */
343 + public function get_personal_data_by_donor_id( $donor_id = 0 ) {
344 + global $wpdb;
345 +
346 + if ( 0 === $donor_id ) {
347 + return array();
348 + }
349 +
350 + return $wpdb->get_results( // phpcs:ignore
351 + $wpdb->prepare(
352 + "SELECT donor_id, email, first_name, last_name, user_id FROM {$this->table_name} WHERE donor_id = %d;", // phpcs:ignore
353 + $donor_id
354 + )
355 + );
356 + }
357 +
358 + /**
334 359 * Count the number of donors with donations.
335 360 *
336 361 * @since 1.3.4
337 362 *
@@ -348,11 +373,11 @@
348 373
349 374 if ( empty( $statuses ) ) {
350 375 $status_clause = '';
351 376 } else {
352 - $statuses = array_filter( $statuses, 'charitable_is_valid_donation_status' );
377 + $statuses = array_filter( $statuses, 'charitable_is_valid_donation_status' );
353 378 $placeholders = array_fill( 0, count( $statuses ), '%s' );
354 - $in = implode( ', ', $placeholders );
379 + $in = implode( ', ', $placeholders );
355 380 $status_clause = "AND p.post_status IN ( $in )";
356 381 }
357 382
358 383 $sql = "SELECT COUNT( DISTINCT(d.donor_id) )
@@ -361,9 +386,9 @@
361 386 INNER JOIN $wpdb->posts p ON cd.donation_id = p.ID
362 387 WHERE 1 = 1
363 388 $status_clause;";
364 389
365 - return $wpdb->get_var( $wpdb->prepare( $sql, $statuses ) );
390 + return $wpdb->get_var( $wpdb->prepare( $sql, $statuses ) ); // phpcs:ignore
366 391 }
367 392
368 393 /**
369 394 * Erase personal data for given donor IDs.
@@ -417,9 +442,9 @@
417 442 WHERE donor_id IN ( $placeholders )";
418 443
419 444 }
420 445
421 - return $wpdb->query( $wpdb->prepare( $sql, $parameters ) );
446 + return $wpdb->query( $wpdb->prepare( $sql, $parameters ) ); // phpcs:ignore
422 447 }
423 448
424 449 /**
425 450 * Checks whether the passed email is an anonymized email address.
@@ -429,9 +454,9 @@
429 454 * @param string $email The email address.
430 455 * @return boolean
431 456 */
432 457 private function is_anonymized_email( $email ) {
433 - return function_exists( 'wp_privacy_anonymize_data' ) && wp_privacy_anonymize_data( 'email' ) == $email;
458 + return function_exists( 'wp_privacy_anonymize_data' ) && wp_privacy_anonymize_data( 'email' ) === $email;
434 459 }
435 460 }
436 461
437 462 endif;