Test Failed
Push — master ( bb0b3f...21ce85 )
by Devin
06:53 queued 01:10
created
includes/admin/emails/class-email-notification-util.php 1 patch
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if access directly.
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	 * @return static
47 47
 	 */
48 48
 	static function get_instance() {
49
-		if ( null === static::$instance ) {
49
+		if (null === static::$instance) {
50 50
 			self::$instance = new static();
51 51
 		}
52 52
 
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	 *
65 65
 	 * @return bool
66 66
 	 */
67
-	public static function has_preview( Give_Email_Notification $email ) {
67
+	public static function has_preview(Give_Email_Notification $email) {
68 68
 		return $email->config['has_preview'];
69 69
 	}
70 70
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 *
79 79
 	 * @return bool
80 80
 	 */
81
-	public static function has_recipient_field( Give_Email_Notification $email ) {
81
+	public static function has_recipient_field(Give_Email_Notification $email) {
82 82
 		return $email->config['has_recipient_field'];
83 83
 	}
84 84
 
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 	 *
93 93
 	 * @return bool
94 94
 	 */
95
-	public static function is_notification_status_editable( Give_Email_Notification $email ) {
95
+	public static function is_notification_status_editable(Give_Email_Notification $email) {
96 96
 		$user_can_edit = $email->config['notification_status_editable'];
97 97
 
98 98
 		return (bool) $user_can_edit;
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	 *
109 109
 	 * @return bool
110 110
 	 */
111
-	public static function is_content_type_editable( Give_Email_Notification $email ) {
111
+	public static function is_content_type_editable(Give_Email_Notification $email) {
112 112
 		return $email->config['content_type_editable'];
113 113
 	}
114 114
 
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	 *
123 123
 	 * @return bool
124 124
 	 */
125
-	public static function is_email_preview_has_header( Give_Email_Notification $email ) {
125
+	public static function is_email_preview_has_header(Give_Email_Notification $email) {
126 126
 		return $email->config['has_preview_header'];
127 127
 	}
128 128
 
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 	 *
137 137
 	 * @return bool
138 138
 	 */
139
-	public static function is_email_preview( Give_Email_Notification $email ) {
139
+	public static function is_email_preview(Give_Email_Notification $email) {
140 140
 		return $email->config['has_preview'];
141 141
 	}
142 142
 
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 	 *
151 151
 	 * @return bool
152 152
 	 */
153
-	public static function is_show_on_emails_setting_page( Give_Email_Notification $email ){
153
+	public static function is_show_on_emails_setting_page(Give_Email_Notification $email) {
154 154
 		return $email->config['show_on_emails_setting_page'];
155 155
 	}
156 156
 
@@ -165,8 +165,8 @@  discard block
 block discarded – undo
165 165
 	 *
166 166
 	 * @return bool
167 167
 	 */
168
-	public static function can_use_form_email_options( Give_Email_Notification $email, $form_id = null ){
169
-		return give_is_setting_enabled( give_get_meta( $form_id, '_give_email_options', true ) );
168
+	public static function can_use_form_email_options(Give_Email_Notification $email, $form_id = null) {
169
+		return give_is_setting_enabled(give_get_meta($form_id, '_give_email_options', true));
170 170
 	}
171 171
 
172 172
 	/**
@@ -180,13 +180,13 @@  discard block
 block discarded – undo
180 180
 	 *
181 181
 	 * @return string
182 182
 	 */
183
-	public static function is_email_notification_active( Give_Email_Notification $email, $form_id = null ) {
184
-		$notification_status = $email->get_notification_status( $form_id );
183
+	public static function is_email_notification_active(Give_Email_Notification $email, $form_id = null) {
184
+		$notification_status = $email->get_notification_status($form_id);
185 185
 
186 186
 
187
-		$notification_status = empty( $form_id )
188
-			? give_is_setting_enabled( $notification_status )
189
-			: give_is_setting_enabled( give_get_option( "{$email->config['id']}_notification", $email->config['notification_status'] ) ) && give_is_setting_enabled( $notification_status, array( 'enabled', 'global' ) );
187
+		$notification_status = empty($form_id)
188
+			? give_is_setting_enabled($notification_status)
189
+			: give_is_setting_enabled(give_get_option("{$email->config['id']}_notification", $email->config['notification_status'])) && give_is_setting_enabled($notification_status, array('enabled', 'global'));
190 190
 			// To check if email notification is active or not on a per-form basis, email notification must be globally active—otherwise it will be considered disabled.
191 191
 
192 192
 		/**
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 		 *
201 201
 		 * @param bool $notification_status True if notification is enable and false when disable
202 202
 		 */
203
-		return apply_filters( "give_{$email->config['id']}_is_email_notification_active", $notification_status, $email, $form_id );
203
+		return apply_filters("give_{$email->config['id']}_is_email_notification_active", $notification_status, $email, $form_id);
204 204
 	}
205 205
 
206 206
 	/**
@@ -214,8 +214,8 @@  discard block
 block discarded – undo
214 214
 		$is_preview = false;
215 215
 
216 216
 		if (
217
-			current_user_can( 'manage_give_settings' )
218
-			&& ! empty( $_GET['give_action'] )
217
+			current_user_can('manage_give_settings')
218
+			&& ! empty($_GET['give_action'])
219 219
 			&& 'preview_email' === $_GET['give_action']
220 220
 		) {
221 221
 			$is_preview = true;
@@ -235,8 +235,8 @@  discard block
 block discarded – undo
235 235
 		$is_preview = false;
236 236
 
237 237
 		if (
238
-			current_user_can( 'manage_give_settings' )
239
-			&& ! empty( $_GET['give_action'] )
238
+			current_user_can('manage_give_settings')
239
+			&& ! empty($_GET['give_action'])
240 240
 			&& 'send_preview_email' === $_GET['give_action']
241 241
 		) {
242 242
 			$is_preview = true;
@@ -256,13 +256,13 @@  discard block
 block discarded – undo
256 256
 	 *
257 257
 	 * @return string
258 258
 	 */
259
-	public static function get_formatted_email_type( $content_type ) {
259
+	public static function get_formatted_email_type($content_type) {
260 260
 		$email_contents = array(
261
-			'text/html'  => __( 'HTML', 'give' ),
262
-			'text/plain' => __( 'Plain', 'give' ),
261
+			'text/html'  => __('HTML', 'give'),
262
+			'text/plain' => __('Plain', 'give'),
263 263
 		);
264 264
 
265
-		return $email_contents[ $content_type ];
265
+		return $email_contents[$content_type];
266 266
 	}
267 267
 
268 268
 
@@ -279,41 +279,41 @@  discard block
 block discarded – undo
279 279
 	 *
280 280
 	 * @return mixed
281 281
 	 */
282
-	public static function get_value( Give_Email_Notification $email, $option_name, $form_id = null, $default = false ) {
282
+	public static function get_value(Give_Email_Notification $email, $option_name, $form_id = null, $default = false) {
283 283
 		// If form id set then option name can be contain _give_ prefix which is only used for meta key,
284 284
 		// So make sure you are using correct option name.
285
-		$global_option_name = ( 0 === strpos( $option_name, '_give_' )
286
-			? str_replace( '_give_', '', $option_name )
287
-			: $option_name );
288
-		$option_value = give_get_option( $global_option_name, $default );
285
+		$global_option_name = (0 === strpos($option_name, '_give_')
286
+			? str_replace('_give_', '', $option_name)
287
+			: $option_name);
288
+		$option_value = give_get_option($global_option_name, $default);
289 289
 
290 290
 		if (
291
-			! empty( $form_id )
291
+			! empty($form_id)
292 292
 			&& give_is_setting_enabled(
293 293
 				give_get_meta(
294 294
 					$form_id,
295
-					Give_Email_Setting_Field::get_prefix( $email, $form_id ) . 'notification',
295
+					Give_Email_Setting_Field::get_prefix($email, $form_id).'notification',
296 296
 					true,
297 297
 					'global'
298 298
 				)
299 299
 			)
300 300
 		) {
301
-			$option_value = get_post_meta( $form_id, $option_name, true );
301
+			$option_value = get_post_meta($form_id, $option_name, true);
302 302
 
303 303
 			// Get only email field value from recipients setting.
304
-			if( Give_Email_Setting_Field::get_prefix( $email, $form_id ) . 'recipient' === $option_name ) {
305
-				$option_value = wp_list_pluck( $option_value, 'email' );
304
+			if (Give_Email_Setting_Field::get_prefix($email, $form_id).'recipient' === $option_name) {
305
+				$option_value = wp_list_pluck($option_value, 'email');
306 306
 			}
307 307
 		}
308 308
 
309
-		$option_value = empty( $option_value ) ? $default : $option_value;
309
+		$option_value = empty($option_value) ? $default : $option_value;
310 310
 
311 311
 		/**
312 312
 		 * Filter the setting value
313 313
 		 *
314 314
 		 * @since 2.0
315 315
 		 */
316
-		return apply_filters( 'give_email_setting_value', $option_value, $option_name, $email, $form_id, $default );
316
+		return apply_filters('give_email_setting_value', $option_value, $option_name, $email, $form_id, $default);
317 317
 	}
318 318
 
319 319
 
@@ -328,12 +328,12 @@  discard block
 block discarded – undo
328 328
 	 *
329 329
 	 * @return string
330 330
 	 */
331
-	public static function get_email_logo( $form_id ) {
331
+	public static function get_email_logo($form_id) {
332 332
 
333 333
 		// Email logo tag.
334
-		$header_img = $form_id && give_is_setting_enabled( give_get_meta( $form_id, '_give_email_options', true ) )
335
-			? give_get_meta( $form_id, '_give_email_logo', true )
336
-			: give_get_option( 'email_logo', '' );
334
+		$header_img = $form_id && give_is_setting_enabled(give_get_meta($form_id, '_give_email_options', true))
335
+			? give_get_meta($form_id, '_give_email_logo', true)
336
+			: give_get_option('email_logo', '');
337 337
 
338 338
 		return $header_img;
339 339
 	}
Please login to merge, or discard this patch.
includes/admin/settings/class-settings-license.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -9,11 +9,11 @@  discard block
 block discarded – undo
9 9
  * @since       1.8
10 10
  */
11 11
 
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit; // Exit if accessed directly.
14 14
 }
15 15
 
16
-if ( ! class_exists( 'Give_Settings_License' ) ) :
16
+if ( ! class_exists('Give_Settings_License')) :
17 17
 
18 18
 	/**
19 19
 	 * Give_Settings_License.
@@ -27,12 +27,12 @@  discard block
 block discarded – undo
27 27
 		 */
28 28
 		public function __construct() {
29 29
 			$this->id    = 'licenses';
30
-			$this->label = esc_html__( 'Licenses', 'give' );
30
+			$this->label = esc_html__('Licenses', 'give');
31 31
 
32 32
 			parent::__construct();
33 33
 
34 34
 			// Filter to remove the license tab.
35
-			add_filter( 'give-settings_tabs_array', array( $this, 'remove_license_tab' ), 9999999, 1 );
35
+			add_filter('give-settings_tabs_array', array($this, 'remove_license_tab'), 9999999, 1);
36 36
 
37 37
 		}
38 38
 
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 			 * Filter the licenses settings.
50 50
 			 * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8
51 51
 			 */
52
-			$settings = apply_filters( 'give_settings_licenses', $settings );
52
+			$settings = apply_filters('give_settings_licenses', $settings);
53 53
 
54 54
 			/**
55 55
 			 * Filter the settings.
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 			 *
59 59
 			 * @param  array $settings
60 60
 			 */
61
-			$settings = apply_filters( 'give_get_settings_' . $this->id, $settings );
61
+			$settings = apply_filters('give_get_settings_'.$this->id, $settings);
62 62
 
63 63
 			// Output.
64 64
 			return $settings;
@@ -74,13 +74,13 @@  discard block
 block discarded – undo
74 74
 		 *
75 75
 		 * @return array
76 76
 		 */
77
-		public function remove_license_tab( $tabs ) {
77
+		public function remove_license_tab($tabs) {
78 78
 			/**
79 79
 			 * Remove the license tab if no Give licensed addon
80 80
 			 * is activated.
81 81
 			 */
82
-			if ( ! $this->is_show_setting_page() ) {
83
-				unset( $tabs['licenses'] );
82
+			if ( ! $this->is_show_setting_page()) {
83
+				unset($tabs['licenses']);
84 84
 			}
85 85
 
86 86
 			return $tabs;
@@ -97,17 +97,17 @@  discard block
 block discarded – undo
97 97
 		 */
98 98
 		private function is_show_setting_page() {
99 99
 			$licensed_addons   = Give_License::get_licensed_addons();
100
-			$activated_plugins = get_option( 'active_plugins', array() );
100
+			$activated_plugins = get_option('active_plugins', array());
101 101
 
102 102
 			// Get list of network enabled plugin.
103
-			if ( is_multisite() ) {
104
-				$sitewide_activated_plugins = array_keys( get_site_option( 'active_sitewide_plugins', array() ) );
105
-				$activated_plugins = ! empty( $activated_plugins )
106
-					? array_merge( $sitewide_activated_plugins, $activated_plugins )
103
+			if (is_multisite()) {
104
+				$sitewide_activated_plugins = array_keys(get_site_option('active_sitewide_plugins', array()));
105
+				$activated_plugins = ! empty($activated_plugins)
106
+					? array_merge($sitewide_activated_plugins, $activated_plugins)
107 107
 					: $sitewide_activated_plugins;
108 108
 			}
109 109
 
110
-			return (bool) count( array_intersect( $activated_plugins, $licensed_addons ) );
110
+			return (bool) count(array_intersect($activated_plugins, $licensed_addons));
111 111
 		}
112 112
 	}
113 113
 
Please login to merge, or discard this patch.
includes/admin/donors/donor-actions.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
  *
22 22
  * @since 1.0
23 23
  *
24
- * @return array|bool $output Response messages
24
+ * @return false|null $output Response messages
25 25
  */
26 26
 function give_edit_donor( $args ) {
27 27
 
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
  *
435 435
  * @since  1.7
436 436
  *
437
- * @return bool|null
437
+ * @return false|null
438 438
  */
439 439
 function give_remove_donor_email() {
440 440
 	if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
  *
479 479
  * @since  1.7
480 480
  *
481
- * @return bool|null
481
+ * @return false|null
482 482
  */
483 483
 function give_set_donor_primary_email() {
484 484
 	if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
Please login to merge, or discard this patch.
Spacing   +174 added lines, -174 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -23,37 +23,37 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @return array|bool $output Response messages
25 25
  */
26
-function give_edit_donor( $args ) {
26
+function give_edit_donor($args) {
27 27
 
28
-	$donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' );
28
+	$donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments');
29 29
 
30
-	if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) {
31
-		wp_die( esc_html__( 'You do not have permission to edit this donor.', 'give' ), esc_html__( 'Error', 'give' ), array(
30
+	if ( ! is_admin() || ! current_user_can($donor_edit_role)) {
31
+		wp_die(esc_html__('You do not have permission to edit this donor.', 'give'), esc_html__('Error', 'give'), array(
32 32
 			'response' => 403,
33
-		) );
33
+		));
34 34
 	}
35 35
 
36
-	if ( empty( $args ) ) {
36
+	if (empty($args)) {
37 37
 		return false;
38 38
 	}
39 39
 
40 40
 	// Sanitize Data.
41
-	$args = give_clean( $args );
41
+	$args = give_clean($args);
42 42
 
43 43
 	// Verify Nonce.
44
-	if ( ! wp_verify_nonce( $args['_wpnonce'], 'edit-donor' ) ) {
45
-		wp_die( esc_html__( 'Cheatin’ uh?', 'give' ), esc_html__( 'Error', 'give' ), array(
44
+	if ( ! wp_verify_nonce($args['_wpnonce'], 'edit-donor')) {
45
+		wp_die(esc_html__('Cheatin’ uh?', 'give'), esc_html__('Error', 'give'), array(
46 46
 			'response' => 400,
47
-		) );
47
+		));
48 48
 	}
49 49
 
50 50
 	$donor_info = $args['donor_info'];
51
-	$donor_id   = intval( $donor_info['id'] );
51
+	$donor_id   = intval($donor_info['id']);
52 52
 
53
-	$donor = new Give_Donor( $donor_id );
53
+	$donor = new Give_Donor($donor_id);
54 54
 
55 55
 	// Bailout, if donor id doesn't exists.
56
-	if ( empty( $donor->id ) ) {
56
+	if (empty($donor->id)) {
57 57
 		return false;
58 58
 	}
59 59
 
@@ -69,30 +69,30 @@  discard block
 block discarded – undo
69 69
 		'country' => '',
70 70
 	);
71 71
 
72
-	$donor_info = wp_parse_args( $donor_info, $defaults );
72
+	$donor_info = wp_parse_args($donor_info, $defaults);
73 73
 
74
-	if ( (int) $donor_info['user_id'] !== (int) $donor->user_id ) {
74
+	if ((int) $donor_info['user_id'] !== (int) $donor->user_id) {
75 75
 
76 76
 		// Make sure we don't already have this user attached to a donor.
77
-		if ( ! empty( $donor_info['user_id'] ) && false !== Give()->donors->get_donor_by( 'user_id', $donor_info['user_id'] ) ) {
77
+		if ( ! empty($donor_info['user_id']) && false !== Give()->donors->get_donor_by('user_id', $donor_info['user_id'])) {
78 78
 			give_set_error(
79 79
 				'give-invalid-donor-user_id',
80 80
 				sprintf(
81 81
 					/* translators: %d User ID */
82
-					__( 'The User ID #%d is already associated with a different donor.', 'give' ),
82
+					__('The User ID #%d is already associated with a different donor.', 'give'),
83 83
 					$donor_info['user_id']
84 84
 				)
85 85
 			);
86 86
 		}
87 87
 
88 88
 		// Make sure it's actually a user.
89
-		$user = get_user_by( 'id', $donor_info['user_id'] );
90
-		if ( ! empty( $donor_info['user_id'] ) && false === $user ) {
89
+		$user = get_user_by('id', $donor_info['user_id']);
90
+		if ( ! empty($donor_info['user_id']) && false === $user) {
91 91
 			give_set_error(
92 92
 				'give-invalid-user_id',
93 93
 				sprintf(
94 94
 					/* translators: %d User ID */
95
-					__( 'The User ID #%d does not exist. Please assign an existing user.', 'give' ),
95
+					__('The User ID #%d does not exist. Please assign an existing user.', 'give'),
96 96
 					$donor_info['user_id']
97 97
 				)
98 98
 			);
@@ -100,29 +100,29 @@  discard block
 block discarded – undo
100 100
 	}
101 101
 
102 102
 	// Bailout, if errors are present.
103
-	if ( give_get_errors() ) {
103
+	if (give_get_errors()) {
104 104
 		return false;
105 105
 	}
106 106
 
107
-	$donor->update_meta( '_give_anonymous_donor', absint( $args['give_anonymous_donor'] ) );
107
+	$donor->update_meta('_give_anonymous_donor', absint($args['give_anonymous_donor']));
108 108
 
109 109
 	// Save company name in when admin update donor company name from dashboard.
110
-	$donor->update_meta( '_give_donor_company', sanitize_text_field( $args['give_donor_company'] ) );
110
+	$donor->update_meta('_give_donor_company', sanitize_text_field($args['give_donor_company']));
111 111
 
112 112
 	// If First name of donor is empty, then fetch the current first name of donor.
113
-	if ( empty( $donor_info['first_name'] ) ) {
113
+	if (empty($donor_info['first_name'])) {
114 114
 		$donor_info['first_name'] = $donor->get_first_name();
115 115
 	}
116 116
 
117 117
 	// Sanitize the inputs.
118 118
 	$donor_data               = array();
119
-	$donor_data['name']       = trim( "{$donor_info['first_name']} {$donor_info['last_name']}" );
119
+	$donor_data['name']       = trim("{$donor_info['first_name']} {$donor_info['last_name']}");
120 120
 	$donor_data['first_name'] = $donor_info['first_name'];
121 121
 	$donor_data['last_name']  = $donor_info['last_name'];
122 122
 	$donor_data['title']      = $donor_info['title'];
123 123
 	$donor_data['user_id']    = $donor_info['user_id'];
124 124
 
125
-	$donor_data = apply_filters( 'give_edit_donor_info', $donor_data, $donor_id );
125
+	$donor_data = apply_filters('give_edit_donor_info', $donor_data, $donor_id);
126 126
 
127 127
 	/**
128 128
 	 * Filter the address
@@ -131,21 +131,21 @@  discard block
 block discarded – undo
131 131
 	 *
132 132
 	 * @since 1.0
133 133
 	 */
134
-	$address = apply_filters( 'give_edit_donor_address', array(), $donor_id );
134
+	$address = apply_filters('give_edit_donor_address', array(), $donor_id);
135 135
 
136
-	$donor_data = give_clean( $donor_data );
137
-	$address    = give_clean( $address );
136
+	$donor_data = give_clean($donor_data);
137
+	$address    = give_clean($address);
138 138
 
139
-	$output = give_connect_user_donor_profile( $donor, $donor_data, $address );
139
+	$output = give_connect_user_donor_profile($donor, $donor_data, $address);
140 140
 
141
-	if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
142
-		header( 'Content-Type: application/json' );
143
-		echo wp_json_encode( $output );
141
+	if (defined('DOING_AJAX') && DOING_AJAX) {
142
+		header('Content-Type: application/json');
143
+		echo wp_json_encode($output);
144 144
 		wp_die();
145 145
 	}
146 146
 
147
-	if ( $output['success'] ) {
148
-		wp_safe_redirect( add_query_arg(
147
+	if ($output['success']) {
148
+		wp_safe_redirect(add_query_arg(
149 149
 			array(
150 150
 				'post_type'       => 'give_forms',
151 151
 				'page'            => 'give-donors',
@@ -153,15 +153,15 @@  discard block
 block discarded – undo
153 153
 				'id'              => $donor_id,
154 154
 				'give-messages[]' => 'profile-updated'
155 155
 			),
156
-			esc_url( admin_url( 'edit.php' ) )
157
-		) );
156
+			esc_url(admin_url('edit.php'))
157
+		));
158 158
 	}
159 159
 
160 160
 	exit;
161 161
 
162 162
 }
163 163
 
164
-add_action( 'give_edit-donor', 'give_edit_donor', 10, 1 );
164
+add_action('give_edit-donor', 'give_edit_donor', 10, 1);
165 165
 
166 166
 /**
167 167
  * Save a donor note.
@@ -172,40 +172,40 @@  discard block
 block discarded – undo
172 172
  *
173 173
  * @return int The Note ID that was saved, or 0 if nothing was saved.
174 174
  */
175
-function give_donor_save_note( $args ) {
175
+function give_donor_save_note($args) {
176 176
 
177
-	$donor_view_role = apply_filters( 'give_view_donors_role', 'view_give_reports' );
177
+	$donor_view_role = apply_filters('give_view_donors_role', 'view_give_reports');
178 178
 
179
-	if ( ! is_admin() || ! current_user_can( $donor_view_role ) ) {
180
-		wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array(
179
+	if ( ! is_admin() || ! current_user_can($donor_view_role)) {
180
+		wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array(
181 181
 			'response' => 403,
182
-		) );
182
+		));
183 183
 	}
184 184
 
185
-	if ( empty( $args ) ) {
185
+	if (empty($args)) {
186 186
 		return false;
187 187
 	}
188 188
 
189
-	$donor_note = trim( give_clean( $args['donor_note'] ) );
189
+	$donor_note = trim(give_clean($args['donor_note']));
190 190
 	$donor_id   = (int) $args['customer_id'];
191 191
 	$nonce      = $args['add_donor_note_nonce'];
192 192
 
193
-	if ( ! wp_verify_nonce( $nonce, 'add-donor-note' ) ) {
194
-		wp_die( __( 'Cheatin’ uh?', 'give' ), __( 'Error', 'give' ), array(
193
+	if ( ! wp_verify_nonce($nonce, 'add-donor-note')) {
194
+		wp_die(__('Cheatin’ uh?', 'give'), __('Error', 'give'), array(
195 195
 			'response' => 400,
196
-		) );
196
+		));
197 197
 	}
198 198
 
199
-	if ( empty( $donor_note ) ) {
200
-		give_set_error( 'empty-donor-note', __( 'A note is required.', 'give' ) );
199
+	if (empty($donor_note)) {
200
+		give_set_error('empty-donor-note', __('A note is required.', 'give'));
201 201
 	}
202 202
 
203
-	if ( give_get_errors() ) {
203
+	if (give_get_errors()) {
204 204
 		return false;
205 205
 	}
206 206
 
207
-	$donor    = new Give_Donor( $donor_id );
208
-	$new_note = $donor->add_note( $donor_note );
207
+	$donor    = new Give_Donor($donor_id);
208
+	$new_note = $donor->add_note($donor_note);
209 209
 
210 210
 	/**
211 211
 	 * Fires before inserting donor note.
@@ -215,22 +215,22 @@  discard block
 block discarded – undo
215 215
 	 *
216 216
 	 * @since 1.0
217 217
 	 */
218
-	do_action( 'give_pre_insert_donor_note', $donor_id, $new_note );
218
+	do_action('give_pre_insert_donor_note', $donor_id, $new_note);
219 219
 
220
-	if ( ! empty( $new_note ) && ! empty( $donor->id ) ) {
220
+	if ( ! empty($new_note) && ! empty($donor->id)) {
221 221
 
222 222
 		ob_start();
223 223
 		?>
224 224
 		<div class="donor-note-wrapper dashboard-comment-wrap comment-item">
225 225
 			<span class="note-content-wrap">
226
-				<?php echo stripslashes( $new_note ); ?>
226
+				<?php echo stripslashes($new_note); ?>
227 227
 			</span>
228 228
 		</div>
229 229
 		<?php
230 230
 		$output = ob_get_contents();
231 231
 		ob_end_clean();
232 232
 
233
-		if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
233
+		if (defined('DOING_AJAX') && DOING_AJAX) {
234 234
 			echo $output;
235 235
 			exit;
236 236
 		}
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 
244 244
 }
245 245
 
246
-add_action( 'give_add-donor-note', 'give_donor_save_note', 10, 1 );
246
+add_action('give_add-donor-note', 'give_donor_save_note', 10, 1);
247 247
 
248 248
 
249 249
 /**
@@ -255,17 +255,17 @@  discard block
 block discarded – undo
255 255
  *
256 256
  * @return bool|array If the disconnect was successful.
257 257
  */
258
-function give_disconnect_donor_user_id( $args ) {
258
+function give_disconnect_donor_user_id($args) {
259 259
 
260
-	$donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' );
260
+	$donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments');
261 261
 
262
-	if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) {
263
-		wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array(
262
+	if ( ! is_admin() || ! current_user_can($donor_edit_role)) {
263
+		wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array(
264 264
 			'response' => 403,
265
-		) );
265
+		));
266 266
 	}
267 267
 
268
-	if ( empty( $args ) ) {
268
+	if (empty($args)) {
269 269
 		return false;
270 270
 	}
271 271
 
@@ -273,14 +273,14 @@  discard block
 block discarded – undo
273 273
 
274 274
 	$nonce = $args['_wpnonce'];
275 275
 
276
-	if ( ! wp_verify_nonce( $nonce, 'edit-donor' ) ) {
277
-		wp_die( __( 'Cheatin&#8217; uh?', 'give' ), __( 'Error', 'give' ), array(
276
+	if ( ! wp_verify_nonce($nonce, 'edit-donor')) {
277
+		wp_die(__('Cheatin&#8217; uh?', 'give'), __('Error', 'give'), array(
278 278
 			'response' => 400,
279
-		) );
279
+		));
280 280
 	}
281 281
 
282
-	$donor = new Give_Donor( $donor_id );
283
-	if ( empty( $donor->id ) ) {
282
+	$donor = new Give_Donor($donor_id);
283
+	if (empty($donor->id)) {
284 284
 		return false;
285 285
 	}
286 286
 
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 	 *
295 295
 	 * @since 1.0
296 296
 	 */
297
-	do_action( 'give_pre_donor_disconnect_user_id', $donor_id, $user_id );
297
+	do_action('give_pre_donor_disconnect_user_id', $donor_id, $user_id);
298 298
 
299 299
 	$output     = array();
300 300
 	$donor_args = array(
@@ -303,19 +303,19 @@  discard block
 block discarded – undo
303 303
 
304 304
 
305 305
 	$output['success'] = true;
306
-	if ( ! $donor->update( $donor_args ) ) {
307
-		update_user_meta( $user_id, '_give_is_donor_disconnected', true );
308
-		update_user_meta( $user_id, '_give_disconnected_donor_id', $donor->id );
309
-		$donor->update_meta( '_give_disconnected_user_id', $user_id );
306
+	if ( ! $donor->update($donor_args)) {
307
+		update_user_meta($user_id, '_give_is_donor_disconnected', true);
308
+		update_user_meta($user_id, '_give_disconnected_donor_id', $donor->id);
309
+		$donor->update_meta('_give_disconnected_user_id', $user_id);
310 310
 
311 311
 		$output['success'] = true;
312 312
 
313 313
 	} else {
314 314
 		$output['success'] = false;
315
-		give_set_error( 'give-disconnect-user-fail', __( 'Failed to disconnect user from donor.', 'give' ) );
315
+		give_set_error('give-disconnect-user-fail', __('Failed to disconnect user from donor.', 'give'));
316 316
 	}
317 317
 
318
-	$output['redirect'] = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' ) . $donor_id;
318
+	$output['redirect'] = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id=').$donor_id;
319 319
 
320 320
 	/**
321 321
 	 * Fires after disconnecting user ID from a donor.
@@ -324,11 +324,11 @@  discard block
 block discarded – undo
324 324
 	 *
325 325
 	 * @since 1.0
326 326
 	 */
327
-	do_action( 'give_post_donor_disconnect_user_id', $donor_id );
327
+	do_action('give_post_donor_disconnect_user_id', $donor_id);
328 328
 
329
-	if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
330
-		header( 'Content-Type: application/json' );
331
-		echo json_encode( $output );
329
+	if (defined('DOING_AJAX') && DOING_AJAX) {
330
+		header('Content-Type: application/json');
331
+		echo json_encode($output);
332 332
 		wp_die();
333 333
 	}
334 334
 
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 
337 337
 }
338 338
 
339
-add_action( 'give_disconnect-userid', 'give_disconnect_donor_user_id', 10, 1 );
339
+add_action('give_disconnect-userid', 'give_disconnect_donor_user_id', 10, 1);
340 340
 
341 341
 /**
342 342
  * Add an email address to the donor from within the admin and log a donor note.
@@ -347,86 +347,86 @@  discard block
 block discarded – undo
347 347
  *
348 348
  * @return mixed If DOING_AJAX echos out JSON, otherwise returns array of success (bool) and message (string).
349 349
  */
350
-function give_add_donor_email( $args ) {
350
+function give_add_donor_email($args) {
351 351
 
352 352
 	$donor_id = '';
353
-	$donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' );
353
+	$donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments');
354 354
 
355
-	if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) {
356
-		wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array(
355
+	if ( ! is_admin() || ! current_user_can($donor_edit_role)) {
356
+		wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array(
357 357
 			'response' => 403,
358
-		) );
358
+		));
359 359
 	}
360 360
 
361 361
 	$output = array();
362
-	if ( empty( $args ) || empty( $args['email'] ) || empty( $args['customer_id'] ) ) {
362
+	if (empty($args) || empty($args['email']) || empty($args['customer_id'])) {
363 363
 		$output['success'] = false;
364
-		if ( empty( $args['email'] ) ) {
365
-			$output['message'] = __( 'Email address is required.', 'give' );
366
-		} elseif ( empty( $args['customer_id'] ) ) {
367
-			$output['message'] = __( 'Donor ID is required.', 'give' );
364
+		if (empty($args['email'])) {
365
+			$output['message'] = __('Email address is required.', 'give');
366
+		} elseif (empty($args['customer_id'])) {
367
+			$output['message'] = __('Donor ID is required.', 'give');
368 368
 		} else {
369
-			$output['message'] = __( 'An error has occurred. Please try again.', 'give' );
369
+			$output['message'] = __('An error has occurred. Please try again.', 'give');
370 370
 		}
371
-	} elseif ( ! wp_verify_nonce( $args['_wpnonce'], 'give_add_donor_email' ) ) {
371
+	} elseif ( ! wp_verify_nonce($args['_wpnonce'], 'give_add_donor_email')) {
372 372
 		$output = array(
373 373
 			'success' => false,
374
-			'message' => __( 'Nonce verification failed.', 'give' ),
374
+			'message' => __('Nonce verification failed.', 'give'),
375 375
 		);
376
-	} elseif ( ! is_email( $args['email'] ) ) {
376
+	} elseif ( ! is_email($args['email'])) {
377 377
 		$output = array(
378 378
 			'success' => false,
379
-			'message' => __( 'Invalid email.', 'give' ),
379
+			'message' => __('Invalid email.', 'give'),
380 380
 		);
381 381
 	} else {
382
-		$email    = sanitize_email( $args['email'] );
382
+		$email    = sanitize_email($args['email']);
383 383
 		$donor_id = (int) $args['customer_id'];
384 384
 		$primary  = 'true' === $args['primary'] ? true : false;
385
-		$donor    = new Give_Donor( $donor_id );
386
-		if ( false === $donor->add_email( $email, $primary ) ) {
387
-			if ( in_array( $email, $donor->emails ) ) {
385
+		$donor    = new Give_Donor($donor_id);
386
+		if (false === $donor->add_email($email, $primary)) {
387
+			if (in_array($email, $donor->emails)) {
388 388
 				$output = array(
389 389
 					'success' => false,
390
-					'message' => __( 'Email already associated with this donor.', 'give' ),
390
+					'message' => __('Email already associated with this donor.', 'give'),
391 391
 				);
392 392
 			} else {
393 393
 				$output = array(
394 394
 					'success' => false,
395
-					'message' => __( 'Email address is already associated with another donor.', 'give' ),
395
+					'message' => __('Email address is already associated with another donor.', 'give'),
396 396
 				);
397 397
 			}
398 398
 		} else {
399
-			$redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor_id . '&give-messages[]=email-added' );
399
+			$redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor_id.'&give-messages[]=email-added');
400 400
 			$output   = array(
401 401
 				'success'  => true,
402
-				'message'  => __( 'Email successfully added to donor.', 'give' ),
402
+				'message'  => __('Email successfully added to donor.', 'give'),
403 403
 				'redirect' => $redirect,
404 404
 			);
405 405
 
406 406
 			$user       = wp_get_current_user();
407
-			$user_login = ! empty( $user->user_login ) ? $user->user_login : __( 'System', 'give' );
408
-			$donor_note = sprintf( __( 'Email address %1$s added by %2$s', 'give' ), $email, $user_login );
409
-			$donor->add_note( $donor_note );
407
+			$user_login = ! empty($user->user_login) ? $user->user_login : __('System', 'give');
408
+			$donor_note = sprintf(__('Email address %1$s added by %2$s', 'give'), $email, $user_login);
409
+			$donor->add_note($donor_note);
410 410
 
411
-			if ( $primary ) {
412
-				$donor_note = sprintf( __( 'Email address %1$s set as primary by %2$s', 'give' ), $email, $user_login );
413
-				$donor->add_note( $donor_note );
411
+			if ($primary) {
412
+				$donor_note = sprintf(__('Email address %1$s set as primary by %2$s', 'give'), $email, $user_login);
413
+				$donor->add_note($donor_note);
414 414
 			}
415 415
 		}
416 416
 	} // End if().
417 417
 
418
-	do_action( 'give_post_add_donor_email', $donor_id, $args );
418
+	do_action('give_post_add_donor_email', $donor_id, $args);
419 419
 
420
-	if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
421
-		header( 'Content-Type: application/json' );
422
-		echo json_encode( $output );
420
+	if (defined('DOING_AJAX') && DOING_AJAX) {
421
+		header('Content-Type: application/json');
422
+		echo json_encode($output);
423 423
 		wp_die();
424 424
 	}
425 425
 
426 426
 	return $output;
427 427
 }
428 428
 
429
-add_action( 'give_add_donor_email', 'give_add_donor_email', 10, 1 );
429
+add_action('give_add_donor_email', 'give_add_donor_email', 10, 1);
430 430
 
431 431
 
432 432
 /**
@@ -437,39 +437,39 @@  discard block
 block discarded – undo
437 437
  * @return bool|null
438 438
  */
439 439
 function give_remove_donor_email() {
440
-	if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
440
+	if (empty($_GET['id']) || ! is_numeric($_GET['id'])) {
441 441
 		return false;
442 442
 	}
443
-	if ( empty( $_GET['email'] ) || ! is_email( $_GET['email'] ) ) {
443
+	if (empty($_GET['email']) || ! is_email($_GET['email'])) {
444 444
 		return false;
445 445
 	}
446
-	if ( empty( $_GET['_wpnonce'] ) ) {
446
+	if (empty($_GET['_wpnonce'])) {
447 447
 		return false;
448 448
 	}
449 449
 
450 450
 	$nonce = $_GET['_wpnonce'];
451
-	if ( ! wp_verify_nonce( $nonce, 'give-remove-donor-email' ) ) {
452
-		wp_die( __( 'Nonce verification failed', 'give' ), __( 'Error', 'give' ), array(
451
+	if ( ! wp_verify_nonce($nonce, 'give-remove-donor-email')) {
452
+		wp_die(__('Nonce verification failed', 'give'), __('Error', 'give'), array(
453 453
 			'response' => 403,
454
-		) );
454
+		));
455 455
 	}
456 456
 
457
-	$donor = new Give_Donor( $_GET['id'] );
458
-	if ( $donor->remove_email( $_GET['email'] ) ) {
459
-		$url        = add_query_arg( 'give-messages[]', 'email-removed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) );
457
+	$donor = new Give_Donor($_GET['id']);
458
+	if ($donor->remove_email($_GET['email'])) {
459
+		$url        = add_query_arg('give-messages[]', 'email-removed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id));
460 460
 		$user       = wp_get_current_user();
461
-		$user_login = ! empty( $user->user_login ) ? $user->user_login : __( 'System', 'give' );
462
-		$donor_note = sprintf( __( 'Email address %1$s removed by %2$s', 'give' ), $_GET['email'], $user_login );
463
-		$donor->add_note( $donor_note );
461
+		$user_login = ! empty($user->user_login) ? $user->user_login : __('System', 'give');
462
+		$donor_note = sprintf(__('Email address %1$s removed by %2$s', 'give'), $_GET['email'], $user_login);
463
+		$donor->add_note($donor_note);
464 464
 	} else {
465
-		$url = add_query_arg( 'give-messages[]', 'email-remove-failed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) );
465
+		$url = add_query_arg('give-messages[]', 'email-remove-failed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id));
466 466
 	}
467 467
 
468
-	wp_safe_redirect( $url );
468
+	wp_safe_redirect($url);
469 469
 	exit;
470 470
 }
471 471
 
472
-add_action( 'give_remove_donor_email', 'give_remove_donor_email', 10 );
472
+add_action('give_remove_donor_email', 'give_remove_donor_email', 10);
473 473
 
474 474
 
475 475
 /**
@@ -481,44 +481,44 @@  discard block
 block discarded – undo
481 481
  * @return bool|null
482 482
  */
483 483
 function give_set_donor_primary_email() {
484
-	if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
484
+	if (empty($_GET['id']) || ! is_numeric($_GET['id'])) {
485 485
 		return false;
486 486
 	}
487 487
 
488
-	if ( empty( $_GET['email'] ) || ! is_email( $_GET['email'] ) ) {
488
+	if (empty($_GET['email']) || ! is_email($_GET['email'])) {
489 489
 		return false;
490 490
 	}
491 491
 
492
-	if ( empty( $_GET['_wpnonce'] ) ) {
492
+	if (empty($_GET['_wpnonce'])) {
493 493
 		return false;
494 494
 	}
495 495
 
496 496
 	$nonce = $_GET['_wpnonce'];
497 497
 
498
-	if ( ! wp_verify_nonce( $nonce, 'give-set-donor-primary-email' ) ) {
499
-		wp_die( __( 'Nonce verification failed', 'give' ), __( 'Error', 'give' ), array(
498
+	if ( ! wp_verify_nonce($nonce, 'give-set-donor-primary-email')) {
499
+		wp_die(__('Nonce verification failed', 'give'), __('Error', 'give'), array(
500 500
 			'response' => 403,
501
-		) );
501
+		));
502 502
 	}
503 503
 
504
-	$donor = new Give_Donor( $_GET['id'] );
504
+	$donor = new Give_Donor($_GET['id']);
505 505
 
506
-	if ( $donor->set_primary_email( $_GET['email'] ) ) {
507
-		$url        = add_query_arg( 'give-messages[]', 'primary-email-updated', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) );
506
+	if ($donor->set_primary_email($_GET['email'])) {
507
+		$url        = add_query_arg('give-messages[]', 'primary-email-updated', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id));
508 508
 		$user       = wp_get_current_user();
509
-		$user_login = ! empty( $user->user_login ) ? $user->user_login : __( 'System', 'give' );
510
-		$donor_note = sprintf( __( 'Email address %1$s set as primary by %2$s', 'give' ), $_GET['email'], $user_login );
509
+		$user_login = ! empty($user->user_login) ? $user->user_login : __('System', 'give');
510
+		$donor_note = sprintf(__('Email address %1$s set as primary by %2$s', 'give'), $_GET['email'], $user_login);
511 511
 
512
-		$donor->add_note( $donor_note );
512
+		$donor->add_note($donor_note);
513 513
 	} else {
514
-		$url = add_query_arg( 'give-messages[]', 'primary-email-failed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) );
514
+		$url = add_query_arg('give-messages[]', 'primary-email-failed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id));
515 515
 	}
516 516
 
517
-	wp_safe_redirect( $url );
517
+	wp_safe_redirect($url);
518 518
 	exit;
519 519
 }
520 520
 
521
-add_action( 'give_set_donor_primary_email', 'give_set_donor_primary_email', 10 );
521
+add_action('give_set_donor_primary_email', 'give_set_donor_primary_email', 10);
522 522
 
523 523
 
524 524
 /**
@@ -528,15 +528,15 @@  discard block
 block discarded – undo
528 528
  *
529 529
  * @since 2.2
530 530
  */
531
-function give_process_donor_deletion( $args ) {
531
+function give_process_donor_deletion($args) {
532 532
 
533
-	$donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' );
533
+	$donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments');
534 534
 
535 535
 	// Verify user capabilities to proceed for deleting donor.
536
-	if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) {
536
+	if ( ! is_admin() || ! current_user_can($donor_edit_role)) {
537 537
 		wp_die(
538
-			esc_html__( 'You do not have permission to delete donors.', 'give' ),
539
-			esc_html__( 'Error', 'give' ),
538
+			esc_html__('You do not have permission to delete donors.', 'give'),
539
+			esc_html__('Error', 'give'),
540 540
 			array(
541 541
 				'response' => 403,
542 542
 			)
@@ -544,32 +544,32 @@  discard block
 block discarded – undo
544 544
 	}
545 545
 
546 546
 	$nonce_action = '';
547
-	if ( 'delete_bulk_donor' === $args['give_action'] ) {
547
+	if ('delete_bulk_donor' === $args['give_action']) {
548 548
 		$nonce_action = 'bulk-donors';
549
-	} elseif ( 'delete_donor' === $args['give_action'] ) {
549
+	} elseif ('delete_donor' === $args['give_action']) {
550 550
 		$nonce_action = 'give-delete-donor';
551 551
 	}
552 552
 
553 553
 	// Verify Nonce for deleting bulk donors.
554
-	give_validate_nonce( $args['_wpnonce'], $nonce_action );
554
+	give_validate_nonce($args['_wpnonce'], $nonce_action);
555 555
 
556 556
 	$redirect_args            = array();
557
-	$donor_ids                = ( isset( $args['donor'] ) && is_array( $args['donor'] ) ) ? $args['donor'] : array( $args['donor_id'] );
558
-	$redirect_args['order']   = ! empty( $args['order'] ) ? $args['order'] : 'DESC';
559
-	$redirect_args['orderby'] = ! empty( $args['orderby'] ) ? $args['orderby'] : 'ID';
560
-	$redirect_args['s']       = ! empty( $args['s'] ) ? $args['s'] : '';
561
-	$delete_donor             = ! empty( $args['give-donor-delete-confirm'] ) ? give_is_setting_enabled( $args['give-donor-delete-confirm'] ) : false;
562
-	$delete_donation          = ! empty( $args['give-donor-delete-records'] ) ? give_is_setting_enabled( $args['give-donor-delete-records'] ) : false;
557
+	$donor_ids                = (isset($args['donor']) && is_array($args['donor'])) ? $args['donor'] : array($args['donor_id']);
558
+	$redirect_args['order']   = ! empty($args['order']) ? $args['order'] : 'DESC';
559
+	$redirect_args['orderby'] = ! empty($args['orderby']) ? $args['orderby'] : 'ID';
560
+	$redirect_args['s']       = ! empty($args['s']) ? $args['s'] : '';
561
+	$delete_donor             = ! empty($args['give-donor-delete-confirm']) ? give_is_setting_enabled($args['give-donor-delete-confirm']) : false;
562
+	$delete_donation          = ! empty($args['give-donor-delete-records']) ? give_is_setting_enabled($args['give-donor-delete-records']) : false;
563 563
 
564
-	if ( count( $donor_ids ) > 0 ) {
564
+	if (count($donor_ids) > 0) {
565 565
 
566 566
 		// Loop through the selected donors to delete.
567
-		foreach ( $donor_ids as $donor_id ) {
567
+		foreach ($donor_ids as $donor_id) {
568 568
 
569
-			$donor = new Give_Donor( $donor_id );
569
+			$donor = new Give_Donor($donor_id);
570 570
 
571 571
 			// Proceed only if valid donor id is provided.
572
-			if ( $donor->id > 0 ) {
572
+			if ($donor->id > 0) {
573 573
 
574 574
 				/**
575 575
 				 * Fires before deleting donor.
@@ -580,19 +580,19 @@  discard block
 block discarded – undo
580 580
 				 *
581 581
 				 * @since 1.0
582 582
 				 */
583
-				do_action( 'give_pre_delete_donor', $donor->id, $delete_donor, $delete_donation );
583
+				do_action('give_pre_delete_donor', $donor->id, $delete_donor, $delete_donation);
584 584
 
585 585
 				// Proceed only, if user confirmed whether they need to delete the donor.
586
-				if ( $delete_donor ) {
586
+				if ($delete_donor) {
587 587
 
588 588
 					// Delete donor and linked donations.
589
-					$donor_delete_status = give_delete_donor_and_related_donation( $donor, array(
589
+					$donor_delete_status = give_delete_donor_and_related_donation($donor, array(
590 590
 						'delete_donation' => $delete_donation,
591
-					) );
591
+					));
592 592
 
593
-					if ( 1 === $donor_delete_status ) {
593
+					if (1 === $donor_delete_status) {
594 594
 						$redirect_args['give-messages[]'] = 'donor-deleted';
595
-					} elseif ( 2 === $donor_delete_status ) {
595
+					} elseif (2 === $donor_delete_status) {
596 596
 						$redirect_args['give-messages[]'] = 'donor-donations-deleted';
597 597
 					}
598 598
 				} else {
@@ -608,12 +608,12 @@  discard block
 block discarded – undo
608 608
 
609 609
 	$redirect_url = add_query_arg(
610 610
 		$redirect_args,
611
-		admin_url( 'edit.php?post_type=give_forms&page=give-donors' )
611
+		admin_url('edit.php?post_type=give_forms&page=give-donors')
612 612
 	);
613 613
 
614
-	wp_safe_redirect( $redirect_url );
614
+	wp_safe_redirect($redirect_url);
615 615
 	give_die();
616 616
 
617 617
 }
618
-add_action( 'give_delete_donor', 'give_process_donor_deletion' );
619
-add_action( 'give_delete_bulk_donor', 'give_process_donor_deletion' );
618
+add_action('give_delete_donor', 'give_process_donor_deletion');
619
+add_action('give_delete_bulk_donor', 'give_process_donor_deletion');
Please login to merge, or discard this patch.
includes/admin/donors/donor-functions.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -162,7 +162,7 @@
 block discarded – undo
162 162
 /**
163 163
  * This function is used to delete donor and related donation without redirection.
164 164
  *
165
- * @param int|Give_Donor $donor Donor ID or List of Donor IDs.
165
+ * @param Give_Donor $donor Donor ID or List of Donor IDs.
166 166
  * @param array          $args  List of arguments to handle donor and related donation deletion process.
167 167
  *
168 168
  * @type bool delete_donation Delete donor linked donations if set to true. Default is false.
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @return array        The altered list of views.
25 25
  */
26
-function give_register_default_donor_views( $views ) {
26
+function give_register_default_donor_views($views) {
27 27
 
28 28
 	$default_views = array(
29 29
 		'overview' => 'give_donor_view',
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
 		'notes'    => 'give_donor_notes_view',
32 32
 	);
33 33
 
34
-	return array_merge( $views, $default_views );
34
+	return array_merge($views, $default_views);
35 35
 
36 36
 }
37 37
 
38
-add_filter( 'give_donor_views', 'give_register_default_donor_views', 1, 1 );
38
+add_filter('give_donor_views', 'give_register_default_donor_views', 1, 1);
39 39
 
40 40
 /**
41 41
  * Register a tab for the single donor view.
@@ -46,23 +46,23 @@  discard block
 block discarded – undo
46 46
  *
47 47
  * @return array       The altered list of tabs
48 48
  */
49
-function give_register_default_donor_tabs( $tabs ) {
49
+function give_register_default_donor_tabs($tabs) {
50 50
 
51 51
 	$default_tabs = array(
52 52
 		'overview' => array(
53 53
 			'dashicon' => 'dashicons-admin-users',
54
-			'title'    => __( 'Donor Profile', 'give' ),
54
+			'title'    => __('Donor Profile', 'give'),
55 55
 		),
56 56
 		'notes'    => array(
57 57
 			'dashicon' => 'dashicons-admin-comments',
58
-			'title'    => __( 'Donor Notes', 'give' ),
58
+			'title'    => __('Donor Notes', 'give'),
59 59
 		),
60 60
 	);
61 61
 
62
-	return array_merge( $tabs, $default_tabs );
62
+	return array_merge($tabs, $default_tabs);
63 63
 }
64 64
 
65
-add_filter( 'give_donor_tabs', 'give_register_default_donor_tabs', 1, 1 );
65
+add_filter('give_donor_tabs', 'give_register_default_donor_tabs', 1, 1);
66 66
 
67 67
 /**
68 68
  * Register the Delete icon as late as possible so it's at the bottom.
@@ -73,17 +73,17 @@  discard block
 block discarded – undo
73 73
  *
74 74
  * @return array       The altered list of tabs, with 'delete' at the bottom.
75 75
  */
76
-function give_register_delete_donor_tab( $tabs ) {
76
+function give_register_delete_donor_tab($tabs) {
77 77
 
78 78
 	$tabs['delete'] = array(
79 79
 		'dashicon' => 'dashicons-trash',
80
-		'title'    => __( 'Delete Donor', 'give' ),
80
+		'title'    => __('Delete Donor', 'give'),
81 81
 	);
82 82
 
83 83
 	return $tabs;
84 84
 }
85 85
 
86
-add_filter( 'give_donor_tabs', 'give_register_delete_donor_tab', PHP_INT_MAX, 1 );
86
+add_filter('give_donor_tabs', 'give_register_delete_donor_tab', PHP_INT_MAX, 1);
87 87
 
88 88
 /**
89 89
  * Connect and Reconnect Donor with User profile.
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
  *
99 99
  * @return array
100 100
  */
101
-function give_connect_user_donor_profile( $donor, $donor_data, $address ) {
101
+function give_connect_user_donor_profile($donor, $donor_data, $address) {
102 102
 
103 103
 	$donor_id         = $donor->id;
104 104
 	$previous_user_id = $donor->user_id;
@@ -112,32 +112,32 @@  discard block
 block discarded – undo
112 112
 	 *
113 113
 	 * @since 1.0
114 114
 	 */
115
-	do_action( 'give_pre_edit_donor', $donor_id, $donor_data, $address );
115
+	do_action('give_pre_edit_donor', $donor_id, $donor_data, $address);
116 116
 
117 117
 	$output = array();
118 118
 
119
-	if ( $donor->update( $donor_data ) ) {
119
+	if ($donor->update($donor_data)) {
120 120
 
121 121
 		// Create and Update Donor First Name and Last Name in Meta Fields.
122
-		$donor->update_meta( '_give_donor_first_name', $donor_data['first_name'] );
123
-		$donor->update_meta( '_give_donor_last_name', $donor_data['last_name'] );
124
-		$donor->update_meta( '_give_donor_title_prefix', $donor_data['title'] );
122
+		$donor->update_meta('_give_donor_first_name', $donor_data['first_name']);
123
+		$donor->update_meta('_give_donor_last_name', $donor_data['last_name']);
124
+		$donor->update_meta('_give_donor_title_prefix', $donor_data['title']);
125 125
 
126 126
 		// Fetch disconnected user id, if exists.
127
-		$disconnected_user_id = $donor->get_meta( '_give_disconnected_user_id', true );
127
+		$disconnected_user_id = $donor->get_meta('_give_disconnected_user_id', true);
128 128
 
129 129
 		// Flag User and Donor Disconnection.
130
-		delete_user_meta( $disconnected_user_id, '_give_is_donor_disconnected' );
130
+		delete_user_meta($disconnected_user_id, '_give_is_donor_disconnected');
131 131
 
132 132
 		// Check whether the disconnected user id and the reconnected user id are same or not.
133 133
 		// If both are same then delete user id store in donor meta.
134
-		if ( $donor_data['user_id'] === $disconnected_user_id ) {
135
-			delete_user_meta( $disconnected_user_id, '_give_disconnected_donor_id' );
136
-			$donor->delete_meta( '_give_disconnected_user_id' );
134
+		if ($donor_data['user_id'] === $disconnected_user_id) {
135
+			delete_user_meta($disconnected_user_id, '_give_disconnected_donor_id');
136
+			$donor->delete_meta('_give_disconnected_user_id');
137 137
 		}
138 138
 
139 139
 		$output['success']       = true;
140
-		$donor_data              = array_merge( $donor_data, $address );
140
+		$donor_data              = array_merge($donor_data, $address);
141 141
 		$output['customer_info'] = $donor_data;
142 142
 
143 143
 	} else {
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 	 *
155 155
 	 * @since 1.0
156 156
 	 */
157
-	do_action( 'give_post_edit_donor', $donor_id, $donor_data );
157
+	do_action('give_post_edit_donor', $donor_id, $donor_data);
158 158
 
159 159
 	return $output;
160 160
 }
@@ -171,39 +171,39 @@  discard block
 block discarded – undo
171 171
  *
172 172
  * @return int
173 173
  */
174
-function give_delete_donor_and_related_donation( $donor, $args = array() ) {
174
+function give_delete_donor_and_related_donation($donor, $args = array()) {
175 175
 
176 176
 	// Default Arguments.
177 177
 	$default_args = array(
178 178
 		'delete_donation' => false,
179 179
 	);
180 180
 
181
-	$args = wp_parse_args( $args, $default_args );
181
+	$args = wp_parse_args($args, $default_args);
182 182
 
183 183
 	// If $donor not an instance of Give_Donor then create one.
184
-	if ( ! $donor instanceof Give_Donor ) {
185
-		$donor = new Give_Donor( $donor );
184
+	if ( ! $donor instanceof Give_Donor) {
185
+		$donor = new Give_Donor($donor);
186 186
 	}
187 187
 
188
-	if ( $donor->id > 0 ) {
188
+	if ($donor->id > 0) {
189 189
 
190 190
 		// Delete Donor.
191
-		$donor_deleted = Give()->donors->delete( $donor->id );
191
+		$donor_deleted = Give()->donors->delete($donor->id);
192 192
 
193 193
 		// Fetch linked donations of a particular donor.
194
-		$donation_ids  = explode( ',', $donor->payment_ids );
194
+		$donation_ids  = explode(',', $donor->payment_ids);
195 195
 
196 196
 		// Proceed to delete related donation, if user opted and donor is deleted successfully.
197
-		if ( $donor_deleted && $args['delete_donation'] ) {
198
-			foreach ( $donation_ids as $donation_id ) {
199
-				give_delete_donation( $donation_id );
197
+		if ($donor_deleted && $args['delete_donation']) {
198
+			foreach ($donation_ids as $donation_id) {
199
+				give_delete_donation($donation_id);
200 200
 			}
201 201
 
202 202
 			return 2; // Donor and linked Donations deleted.
203 203
 
204 204
 		} else {
205
-			foreach ( $donation_ids as $donation_id ) {
206
-				give_update_payment_meta( $donation_id, '_give_payment_donor_id', 0 );
205
+			foreach ($donation_ids as $donation_id) {
206
+				give_update_payment_meta($donation_id, '_give_payment_donor_id', 0);
207 207
 			}
208 208
 		}
209 209
 
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-delete-import-donors.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -290,7 +290,7 @@
 block discarded – undo
290 290
 	 *
291 291
 	 * @since 1.8.12
292 292
 	 *
293
-	 * @return int
293
+	 * @return double
294 294
 	 */
295 295
 	public function get_percentage_complete() {
296 296
 		return ceil( ( 100 * $this->step_completed ) / $this->total_step );
Please login to merge, or discard this patch.
Spacing   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly.
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
 	 *
135 135
 	 * @param int $_step Steps.
136 136
 	 */
137
-	public function __construct( $_step = 1 ) {
138
-		parent::__construct( $_step );
137
+	public function __construct($_step = 1) {
138
+		parent::__construct($_step);
139 139
 
140 140
 		$this->is_writable = true;
141 141
 	}
@@ -154,38 +154,38 @@  discard block
 block discarded – undo
154 154
 		$donor_ids    = array();
155 155
 
156 156
 		// Check if the ajax request if running for the first time.
157
-		if ( 1 === (int) $this->step ) {
157
+		if (1 === (int) $this->step) {
158 158
 
159 159
 			// Delete all the form ids.
160
-			$this->delete_option( $this->form_key );
160
+			$this->delete_option($this->form_key);
161 161
 
162 162
 			// Delete all the donation ids.
163
-			$this->delete_option( $this->donation_key );
163
+			$this->delete_option($this->donation_key);
164 164
 
165 165
 			// Delete all the donor ids.
166
-			$this->delete_option( $this->donor_key );
166
+			$this->delete_option($this->donor_key);
167 167
 
168 168
 			// Delete all the step and set to 'count' which if the first step in the process of deleting the donors.
169
-			$this->update_option( $this->step_key, 'count' );
169
+			$this->update_option($this->step_key, 'count');
170 170
 
171 171
 			// Delete tha page count of the step.
172
-			$this->update_option( $this->step_on_key, '0' );
172
+			$this->update_option($this->step_on_key, '0');
173 173
 		} else {
174 174
 
175 175
 			// Get the old donors list.
176
-			$donor_ids = $this->get_option( $this->donor_key );
176
+			$donor_ids = $this->get_option($this->donor_key);
177 177
 
178 178
 			// Get the old donation list.
179
-			$donation_ids = $this->get_option( $this->donation_key );
179
+			$donation_ids = $this->get_option($this->donation_key);
180 180
 		}
181 181
 
182 182
 		// Get the step and check for it if it's on the first step( 'count' ) or not.
183 183
 		$step = (int) $this->get_step();
184
-		if ( 1 === $step ) {
184
+		if (1 === $step) {
185 185
 			/**
186 186
 			 * Will add or update the donation and donor data by running wp query.
187 187
 			 */
188
-			$this->count( $step, $donation_ids, $donor_ids );
188
+			$this->count($step, $donation_ids, $donor_ids);
189 189
 		}
190 190
 	}
191 191
 
@@ -196,18 +196,18 @@  discard block
 block discarded – undo
196 196
 	 * @param array  $donation_ids Contain the list of all the donation id's that has being add before this.
197 197
 	 * @param array  $donor_ids    Contain the list of all the donors id's that has being add before this.
198 198
 	 */
199
-	private function count( $step, $donation_ids = array(), $donor_ids = array() ) {
199
+	private function count($step, $donation_ids = array(), $donor_ids = array()) {
200 200
 
201 201
 		// Get the Page count by default it's zero.
202 202
 		$paged = (int) $this->get_step_page();
203 203
 
204 204
 		// Increased the page count by one.
205
-		++ $paged;
205
+		++$paged;
206 206
 
207 207
 		/**
208 208
 		 * Filter add to alter the argument before the wp quest run
209 209
 		 */
210
-		$args = apply_filters( 'give_tools_reset_stats_total_args', array(
210
+		$args = apply_filters('give_tools_reset_stats_total_args', array(
211 211
 			'post_type'      => 'give_payment',
212 212
 			'post_status'    => 'any',
213 213
 			'posts_per_page' => $this->per_step,
@@ -215,41 +215,41 @@  discard block
 block discarded – undo
215 215
 			'meta_key'       => '_give_payment_import',
216 216
 			'meta_value_num' => 1,
217 217
 			'meta_compare'   => '=',
218
-		) );
218
+		));
219 219
 
220 220
 		// Reset the post data.
221 221
 		wp_reset_postdata();
222 222
 
223 223
 		// Getting the new donation.
224
-		$donation_posts = new WP_Query( $args );
224
+		$donation_posts = new WP_Query($args);
225 225
 
226 226
 		// The Loop.
227
-		if ( $donation_posts->have_posts() ) {
228
-			while ( $donation_posts->have_posts() ) {
227
+		if ($donation_posts->have_posts()) {
228
+			while ($donation_posts->have_posts()) {
229 229
 				$add_author = true;
230 230
 				$donation_posts->the_post();
231 231
 				global $post;
232 232
 				// Add the donation id in side the array.
233 233
 				$donation_ids[] = $post->ID;
234 234
 
235
-				$donor_id = (int) give_get_meta( $post->ID, '_give_payment_customer_id', true );
236
-				if ( ! empty( $donor_id ) ) {
237
-					$donor = new Give_Donor( $donor_id );
238
-					if ( ! empty( $donor->id ) ) {
239
-						if ( empty( $donor->user_id ) && ! empty( $donor->payment_ids ) ) {
235
+				$donor_id = (int) give_get_meta($post->ID, '_give_payment_customer_id', true);
236
+				if ( ! empty($donor_id)) {
237
+					$donor = new Give_Donor($donor_id);
238
+					if ( ! empty($donor->id)) {
239
+						if (empty($donor->user_id) && ! empty($donor->payment_ids)) {
240 240
 							$add_author = false;
241
-							$count      = (int) count( $donor->payment_ids );
242
-							if ( 1 === $count ) {
243
-								give_delete_donor_and_related_donation( $donor );
241
+							$count      = (int) count($donor->payment_ids);
242
+							if (1 === $count) {
243
+								give_delete_donor_and_related_donation($donor);
244 244
 							} else {
245
-								$donor->remove_payment( $post->ID );
245
+								$donor->remove_payment($post->ID);
246 246
 								$donor->decrease_donation_count();
247 247
 							}
248 248
 						}
249 249
 					}
250 250
 				}
251 251
 
252
-				if ( ! empty( $add_author ) ) {
252
+				if ( ! empty($add_author)) {
253 253
 					// Add the donor id in side the array.
254 254
 					$donor_ids[] = (int) $post->post_author;
255 255
 				}
@@ -263,24 +263,24 @@  discard block
 block discarded – undo
263 263
 		$max_num_pages = (int) $donation_posts->max_num_pages;
264 264
 
265 265
 		// Check current page is less then max number of page or not.
266
-		if ( $paged < $max_num_pages ) {
266
+		if ($paged < $max_num_pages) {
267 267
 
268 268
 			// Update the current page variable for the next step.
269
-			$this->update_option( $this->step_on_key, $paged );
269
+			$this->update_option($this->step_on_key, $paged);
270 270
 
271 271
 			// Calculating percentage.
272 272
 			$page_remain          = $max_num_pages - $paged;
273
-			$this->total_step     = (int) $max_num_pages + ( $total_donation / $this->per_step ) + ( ( $page_remain * 2 ) * count( $donor_ids ) );
273
+			$this->total_step     = (int) $max_num_pages + ($total_donation / $this->per_step) + (($page_remain * 2) * count($donor_ids));
274 274
 			$this->step_completed = $paged;
275 275
 		} else {
276
-			$donation_ids_count = count( $donor_ids );
277
-			$this->update_option( $this->step_key, 'donation' );
278
-			$this->update_option( $this->step_on_key, '0' );
276
+			$donation_ids_count = count($donor_ids);
277
+			$this->update_option($this->step_key, 'donation');
278
+			$this->update_option($this->step_on_key, '0');
279 279
 		}
280 280
 
281
-		$donor_ids = array_unique( $donor_ids );
282
-		$this->update_option( $this->donor_key, $donor_ids );
283
-		$this->update_option( $this->donation_key, $donation_ids );
281
+		$donor_ids = array_unique($donor_ids);
282
+		$this->update_option($this->donor_key, $donor_ids);
283
+		$this->update_option($this->donation_key, $donation_ids);
284 284
 
285 285
 		wp_reset_postdata();
286 286
 	}
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 	 * @return int
294 294
 	 */
295 295
 	public function get_percentage_complete() {
296
-		return ceil( ( 100 * $this->step_completed ) / $this->total_step );
296
+		return ceil((100 * $this->step_completed) / $this->total_step);
297 297
 	}
298 298
 
299 299
 	/**
@@ -303,10 +303,10 @@  discard block
 block discarded – undo
303 303
 	 */
304 304
 	public function process_step() {
305 305
 
306
-		if ( ! $this->can_export() ) {
306
+		if ( ! $this->can_export()) {
307 307
 			wp_die(
308
-				esc_html__( 'You do not have permission to delete Import transactions.', 'give' ),
309
-				esc_html__( 'Error', 'give' ),
308
+				esc_html__('You do not have permission to delete Import transactions.', 'give'),
309
+				esc_html__('Error', 'give'),
310 310
 				array(
311 311
 					'response' => 403,
312 312
 				)
@@ -315,18 +315,18 @@  discard block
 block discarded – undo
315 315
 
316 316
 		$had_data = $this->get_data();
317 317
 
318
-		if ( $had_data ) {
318
+		if ($had_data) {
319 319
 			$this->done = false;
320 320
 
321 321
 			return true;
322 322
 		} else {
323
-			update_option( 'give_earnings_total', give_get_total_earnings( true ), false );
324
-			Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) );
323
+			update_option('give_earnings_total', give_get_total_earnings(true), false);
324
+			Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats'));
325 325
 
326
-			$this->delete_option( $this->donation_key );
326
+			$this->delete_option($this->donation_key);
327 327
 
328 328
 			$this->done    = true;
329
-			$this->message = __( 'Imported donor and transactions successfully deleted.', 'give' );
329
+			$this->message = __('Imported donor and transactions successfully deleted.', 'give');
330 330
 
331 331
 			return false;
332 332
 		}
@@ -344,12 +344,12 @@  discard block
 block discarded – undo
344 344
 	public function get_data() {
345 345
 
346 346
 		// Get the donation id's.
347
-		$donation_ids = $this->get_option( $this->donation_key );
347
+		$donation_ids = $this->get_option($this->donation_key);
348 348
 
349 349
 		/**
350 350
 		 * Return false id not Import donation is found.
351 351
 		 */
352
-		if ( empty( $donation_ids ) ) {
352
+		if (empty($donation_ids)) {
353 353
 			$this->is_empty   = true;
354 354
 			$this->total_step = 1;
355 355
 
@@ -360,110 +360,110 @@  discard block
 block discarded – undo
360 360
 		$step = (int) $this->get_step();
361 361
 
362 362
 		// Get the donor ids.
363
-		$donor_ids = $this->get_option( $this->donor_key );
363
+		$donor_ids = $this->get_option($this->donor_key);
364 364
 
365 365
 		// Delete all the imported donations.
366
-		if ( 2 === $step ) {
366
+		if (2 === $step) {
367 367
 			$pass_to_donor = false;
368 368
 			$page          = (int) $this->get_step_page();
369
-			$page ++;
370
-			$count = count( $donation_ids );
369
+			$page++;
370
+			$count = count($donation_ids);
371 371
 
372
-			$this->total_step     = ( ( count( $donation_ids ) / $this->per_step ) * 2 ) + count( $donor_ids );
372
+			$this->total_step     = ((count($donation_ids) / $this->per_step) * 2) + count($donor_ids);
373 373
 			$this->step_completed = $page;
374 374
 
375
-			if ( $count > $this->per_step ) {
375
+			if ($count > $this->per_step) {
376 376
 
377
-				$this->update_option( $this->step_on_key, $page );
378
-				$donation_ids = $this->get_delete_ids( $donation_ids, $page );
379
-				$current_page = (int) ceil( $count / $this->per_step );
377
+				$this->update_option($this->step_on_key, $page);
378
+				$donation_ids = $this->get_delete_ids($donation_ids, $page);
379
+				$current_page = (int) ceil($count / $this->per_step);
380 380
 
381
-				if ( $page === $current_page ) {
381
+				if ($page === $current_page) {
382 382
 					$pass_to_donor = true;
383 383
 				}
384 384
 			} else {
385 385
 				$pass_to_donor = true;
386 386
 			}
387 387
 
388
-			if ( true === $pass_to_donor ) {
389
-				$this->update_option( $this->step_key, 'donor' );
390
-				$this->update_option( $this->step_on_key, '0' );
388
+			if (true === $pass_to_donor) {
389
+				$this->update_option($this->step_key, 'donor');
390
+				$this->update_option($this->step_on_key, '0');
391 391
 			}
392 392
 
393 393
 			// Get the old form list.
394
-			$form_ids = (array) $this->get_option( $this->form_key );
394
+			$form_ids = (array) $this->get_option($this->form_key);
395 395
 
396
-			foreach ( $donation_ids as $item ) {
397
-				$form_ids[] = give_get_meta( $item, '_give_payment_form_id', true );
396
+			foreach ($donation_ids as $item) {
397
+				$form_ids[] = give_get_meta($item, '_give_payment_form_id', true);
398 398
 
399 399
 				// Delete the main payment.
400
-				give_delete_donation( absint( $item ) );
400
+				give_delete_donation(absint($item));
401 401
 			}
402 402
 
403 403
 			// Update the new form list.
404
-			$this->update_option( $this->form_key, $form_ids );
404
+			$this->update_option($this->form_key, $form_ids);
405 405
 		} // End if().
406 406
 
407 407
 		// Delete all the donors.
408
-		if ( 3 === $step ) {
408
+		if (3 === $step) {
409 409
 
410 410
 			// Get the old form list.
411
-			$form_ids = (array) $this->get_option( $this->form_key );
412
-			if ( ! empty( $form_ids ) ) {
413
-				$form_ids = array_unique( $form_ids );
414
-				foreach ( $form_ids as $form_id ) {
415
-					give_recount_form_income_donation( (int) $form_id );
411
+			$form_ids = (array) $this->get_option($this->form_key);
412
+			if ( ! empty($form_ids)) {
413
+				$form_ids = array_unique($form_ids);
414
+				foreach ($form_ids as $form_id) {
415
+					give_recount_form_income_donation((int) $form_id);
416 416
 				}
417 417
 			}
418 418
 			// update the new form list.
419
-			$this->update_option( $this->form_key, array() );
419
+			$this->update_option($this->form_key, array());
420 420
 
421 421
 			$page  = (int) $this->get_step_page();
422
-			$count = count( $donor_ids );
422
+			$count = count($donor_ids);
423 423
 
424
-			$this->total_step     = ( ( count( $donation_ids ) / $this->per_step ) * 2 ) + count( $donor_ids );
425
-			$this->step_completed = $page + ( count( $donation_ids ) / $this->per_step );
424
+			$this->total_step     = ((count($donation_ids) / $this->per_step) * 2) + count($donor_ids);
425
+			$this->step_completed = $page + (count($donation_ids) / $this->per_step);
426 426
 
427
-			if ( ! empty( $donor_ids[ $page ] ) ) {
428
-				$args = apply_filters( 'give_tools_reset_stats_total_args', array(
427
+			if ( ! empty($donor_ids[$page])) {
428
+				$args = apply_filters('give_tools_reset_stats_total_args', array(
429 429
 					'post_status'    => 'any',
430 430
 					'posts_per_page' => 1,
431
-					'author'         => $donor_ids[ $page ],
432
-				) );
431
+					'author'         => $donor_ids[$page],
432
+				));
433 433
 
434 434
 				$donations = array();
435
-				$payments  = new Give_Payments_Query( $args );
435
+				$payments  = new Give_Payments_Query($args);
436 436
 				$payments  = $payments->get_payments();
437
-				if ( empty( $payments ) ) {
438
-					Give()->donors->delete_by_user_id( $donor_ids[ $page ] );
437
+				if (empty($payments)) {
438
+					Give()->donors->delete_by_user_id($donor_ids[$page]);
439 439
 
440 440
 					/**
441 441
 					 * If Checked then delete WP user.
442 442
 					 *
443 443
 					 * @since 1.8.14
444 444
 					 */
445
-					$delete_import_donors = isset( $_REQUEST['delete-import-donors'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['delete-import-donors'] ) ) : '';
445
+					$delete_import_donors = isset($_REQUEST['delete-import-donors']) ? sanitize_text_field(wp_unslash($_REQUEST['delete-import-donors'])) : '';
446 446
 
447
-					if ( 'on' === (string) $delete_import_donors ) {
448
-						wp_delete_user( $donor_ids[ $page ] );
447
+					if ('on' === (string) $delete_import_donors) {
448
+						wp_delete_user($donor_ids[$page]);
449 449
 					}
450 450
 				} else {
451
-					foreach ( $payments as $payment ) {
451
+					foreach ($payments as $payment) {
452 452
 						$donations[] = $payment->ID;
453 453
 					}
454 454
 
455
-					$donor          = new Give_Donor( $donor_ids[ $page ], true );
455
+					$donor          = new Give_Donor($donor_ids[$page], true);
456 456
 					$data_to_update = array(
457
-						'purchase_count' => count( $donations ),
458
-						'payment_ids'    => implode( ',', $donations ),
457
+						'purchase_count' => count($donations),
458
+						'payment_ids'    => implode(',', $donations),
459 459
 					);
460
-					$donor->update( $data_to_update );
460
+					$donor->update($data_to_update);
461 461
 				}
462 462
 			} // End if().
463 463
 
464
-			$page ++;
465
-			$this->update_option( $this->step_on_key, $page );
466
-			if ( $count === $page ) {
464
+			$page++;
465
+			$this->update_option($this->step_on_key, $page);
466
+			if ($count === $page) {
467 467
 				$this->is_empty = false;
468 468
 
469 469
 				return false;
@@ -483,24 +483,24 @@  discard block
 block discarded – undo
483 483
 	 *
484 484
 	 * @return mixed
485 485
 	 */
486
-	public function get_delete_ids( $donation_ids, $page ) {
487
-		$index            = $page --;
488
-		$count            = count( $donation_ids );
486
+	public function get_delete_ids($donation_ids, $page) {
487
+		$index            = $page--;
488
+		$count            = count($donation_ids);
489 489
 		$temp             = 0;
490 490
 		$current_page     = 0;
491 491
 		$post_delete      = $this->per_step;
492 492
 		$page_donation_id = array();
493 493
 
494
-		foreach ( $donation_ids as $item ) {
495
-			$temp ++;
496
-			$page_donation_id[ $current_page ][] = $item;
497
-			if ( $temp === $post_delete ) {
498
-				$current_page ++;
494
+		foreach ($donation_ids as $item) {
495
+			$temp++;
496
+			$page_donation_id[$current_page][] = $item;
497
+			if ($temp === $post_delete) {
498
+				$current_page++;
499 499
 				$temp = 0;
500 500
 			}
501 501
 		}
502 502
 
503
-		return $page_donation_id[ $page ];
503
+		return $page_donation_id[$page];
504 504
 	}
505 505
 
506 506
 	/**
@@ -513,8 +513,8 @@  discard block
 block discarded – undo
513 513
 	 *
514 514
 	 * @return mixed Returns the data from the database
515 515
 	 */
516
-	public function get_option( $key, $default_value = false ) {
517
-		return get_option( $key, $default_value );
516
+	public function get_option($key, $default_value = false) {
517
+		return get_option($key, $default_value);
518 518
 	}
519 519
 
520 520
 	/**
@@ -527,8 +527,8 @@  discard block
 block discarded – undo
527 527
 	 *
528 528
 	 * @return void
529 529
 	 */
530
-	public function update_option( $key, $value ) {
531
-		update_option( $key, $value, false );
530
+	public function update_option($key, $value) {
531
+		update_option($key, $value, false);
532 532
 	}
533 533
 
534 534
 	/**
@@ -540,8 +540,8 @@  discard block
 block discarded – undo
540 540
 	 *
541 541
 	 * @return void
542 542
 	 */
543
-	public function delete_option( $key ) {
544
-		delete_option( $key );
543
+	public function delete_option($key) {
544
+		delete_option($key);
545 545
 	}
546 546
 
547 547
 	/**
@@ -552,12 +552,12 @@  discard block
 block discarded – undo
552 552
 	 * @return int|string
553 553
 	 */
554 554
 	private function get_step() {
555
-		$step_key = (string) $this->get_option( $this->step_key, false );
556
-		if ( 'count' === $step_key ) {
555
+		$step_key = (string) $this->get_option($this->step_key, false);
556
+		if ('count' === $step_key) {
557 557
 			return 1;
558
-		} elseif ( 'donation' === $step_key ) {
558
+		} elseif ('donation' === $step_key) {
559 559
 			return 2;
560
-		} elseif ( 'donor' === $step_key ) {
560
+		} elseif ('donor' === $step_key) {
561 561
 			return 3;
562 562
 		} else {
563 563
 			return $step_key;
@@ -568,6 +568,6 @@  discard block
 block discarded – undo
568 568
 	 * Get the current $page value in the ajax.
569 569
 	 */
570 570
 	private function get_step_page() {
571
-		return $this->get_option( $this->step_on_key, false );
571
+		return $this->get_option($this->step_on_key, false);
572 572
 	}
573 573
 }
Please login to merge, or discard this patch.
includes/class-give-comment.php 2 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 	 * @param int        $comment_id
446 446
 	 * @param WP_Comment $comment
447 447
 	 *
448
-	 * @return mixed
448
+	 * @return string
449 449
 	 */
450 450
 	public function __get_comment_author( $author, $comment_id, $comment ) {
451 451
 		if ( in_array( $comment->comment_type, $this->comment_types ) ) {
@@ -468,6 +468,7 @@  discard block
 block discarded – undo
468 468
 	 * @access public
469 469
 	 *
470 470
 	 * @param array @comment_types
471
+	 * @param string[] $comment_types
471 472
 	 *
472 473
 	 * @return array
473 474
 	 */
Please login to merge, or discard this patch.
Spacing   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	 * @return Give_Comment
47 47
 	 */
48 48
 	public static function get_instance() {
49
-		if ( null === static::$instance ) {
49
+		if (null === static::$instance) {
50 50
 			self::$instance = new static();
51 51
 			self::$instance->init();
52 52
 		}
@@ -68,14 +68,14 @@  discard block
 block discarded – undo
68 68
 		 */
69 69
 		$this->comment_types = apply_filters(
70 70
 			'give_comment_type',
71
-			self::get_comment_types( array( 'payment', 'donor' ) )
71
+			self::get_comment_types(array('payment', 'donor'))
72 72
 		);
73 73
 
74
-		add_action( 'pre_get_comments', array( $this, 'hide_comments' ), 10 );
75
-		add_filter( 'comments_clauses', array( $this, 'hide_comments_pre_wp_41' ), 10, 1 );
76
-		add_filter( 'comment_feed_where', array( $this, 'hide_comments_from_feeds' ), 10, 1 );
77
-		add_filter( 'wp_count_comments', array( $this, 'remove_comments_from_comment_counts' ), 10, 2 );
78
-		add_filter( 'get_comment_author', array( $this, '__get_comment_author' ), 10, 3 );
74
+		add_action('pre_get_comments', array($this, 'hide_comments'), 10);
75
+		add_filter('comments_clauses', array($this, 'hide_comments_pre_wp_41'), 10, 1);
76
+		add_filter('comment_feed_where', array($this, 'hide_comments_from_feeds'), 10, 1);
77
+		add_filter('wp_count_comments', array($this, 'remove_comments_from_comment_counts'), 10, 2);
78
+		add_filter('get_comment_author', array($this, '__get_comment_author'), 10, 3);
79 79
 	}
80 80
 
81 81
 	/**
@@ -91,13 +91,13 @@  discard block
 block discarded – undo
91 91
 	 *
92 92
 	 * @return int|WP_Error
93 93
 	 */
94
-	public static function add( $id, $note, $comment_type, $comment_args = array() ) {
94
+	public static function add($id, $note, $comment_type, $comment_args = array()) {
95 95
 		// Bailout
96
-		if ( empty( $id ) || empty( $note ) || empty( $comment_type ) ) {
97
-			return new WP_Error( 'give_invalid_required_param', __( 'This comment has invalid ID or comment text or cooment type', 'give' ) );
96
+		if (empty($id) || empty($note) || empty($comment_type)) {
97
+			return new WP_Error('give_invalid_required_param', __('This comment has invalid ID or comment text or cooment type', 'give'));
98 98
 		}
99 99
 
100
-		$is_existing_comment = array_key_exists( 'comment_ID', $comment_args ) && ! empty( $comment_args['comment_ID'] );
100
+		$is_existing_comment = array_key_exists('comment_ID', $comment_args) && ! empty($comment_args['comment_ID']);
101 101
 		$action_type         = $is_existing_comment ? 'update' : 'insert';
102 102
 
103 103
 		/**
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 		 *
109 109
 		 * @since 1.0
110 110
 		 */
111
-		do_action( "give_pre_{$action_type}_{$comment_type}_note", $id, $note );
111
+		do_action("give_pre_{$action_type}_{$comment_type}_note", $id, $note);
112 112
 
113 113
 		$comment_args = wp_parse_args(
114 114
 			$comment_args,
@@ -116,8 +116,8 @@  discard block
 block discarded – undo
116 116
 				'comment_post_ID'      => $id,
117 117
 				'comment_content'      => $note,
118 118
 				'user_id'              => is_admin() ? get_current_user_id() : 0,
119
-				'comment_date'         => current_time( 'mysql' ),
120
-				'comment_date_gmt'     => current_time( 'mysql', 1 ),
119
+				'comment_date'         => current_time('mysql'),
120
+				'comment_date_gmt'     => current_time('mysql', 1),
121 121
 				'comment_approved'     => 1,
122 122
 				'comment_parent'       => 0,
123 123
 				'comment_author'       => '',
@@ -131,30 +131,30 @@  discard block
 block discarded – undo
131 131
 
132 132
 
133 133
 		// Check comment max length.
134
-		$error = wp_check_comment_data_max_lengths( $comment_args );
135
-		if( is_wp_error( $error ) ) {
134
+		$error = wp_check_comment_data_max_lengths($comment_args);
135
+		if (is_wp_error($error)) {
136 136
 			return $error;
137 137
 		}
138 138
 
139 139
 		// Remove moderation emails when comment posted.
140
-		remove_action( 'comment_post', 'wp_new_comment_notify_moderator' );
141
-		remove_action( 'comment_post', 'wp_new_comment_notify_postauthor' );
140
+		remove_action('comment_post', 'wp_new_comment_notify_moderator');
141
+		remove_action('comment_post', 'wp_new_comment_notify_postauthor');
142 142
 
143 143
 		// Remove comment flood check.
144
-		remove_action( 'check_comment_flood', 'check_comment_flood_db', 10 );
144
+		remove_action('check_comment_flood', 'check_comment_flood_db', 10);
145 145
 
146 146
 		$comment_id = $is_existing_comment
147
-			? wp_update_comment( $comment_args )
148
-			: wp_new_comment( $comment_args, true );
147
+			? wp_update_comment($comment_args)
148
+			: wp_new_comment($comment_args, true);
149 149
 
150 150
 		// Add moderation emails when comment posted.
151
-		add_action( 'comment_post', 'wp_new_comment_notify_moderator' );
152
-		add_action( 'comment_post', 'wp_new_comment_notify_postauthor' );
151
+		add_action('comment_post', 'wp_new_comment_notify_moderator');
152
+		add_action('comment_post', 'wp_new_comment_notify_postauthor');
153 153
 
154 154
 		// Add comment flood check.
155
-		add_action( 'check_comment_flood', 'check_comment_flood_db', 10, 4 );
155
+		add_action('check_comment_flood', 'check_comment_flood_db', 10, 4);
156 156
 
157
-		update_comment_meta( $comment_id, "_give_{$comment_type}_id", $id );
157
+		update_comment_meta($comment_id, "_give_{$comment_type}_id", $id);
158 158
 
159 159
 		/**
160 160
 		 * Fires after payment|donor comment inserted/updated.
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 		 *
166 166
 		 * @since 1.0
167 167
 		 */
168
-		do_action( "give_{$action_type}_{$comment_type}_note", $comment_id, $id, $note );
168
+		do_action("give_{$action_type}_{$comment_type}_note", $comment_id, $id, $note);
169 169
 
170 170
 		return $comment_id;
171 171
 	}
@@ -185,11 +185,11 @@  discard block
 block discarded – undo
185 185
 	 *
186 186
 	 * @return bool True on success, false otherwise.
187 187
 	 */
188
-	public static function delete( $comment_id, $id, $comment_type ) {
188
+	public static function delete($comment_id, $id, $comment_type) {
189 189
 		$ret = false;
190 190
 
191 191
 		// Bailout
192
-		if ( empty( $id ) || empty( $comment_id ) || empty( $comment_type ) ) {
192
+		if (empty($id) || empty($comment_id) || empty($comment_type)) {
193 193
 			return $ret;
194 194
 		}
195 195
 
@@ -201,9 +201,9 @@  discard block
 block discarded – undo
201 201
 		 *
202 202
 		 * @since 1.0
203 203
 		 */
204
-		do_action( "give_pre_delete_{$comment_type}_note", $comment_id, $id );
204
+		do_action("give_pre_delete_{$comment_type}_note", $comment_id, $id);
205 205
 
206
-		$ret = wp_delete_comment( $comment_id, true );
206
+		$ret = wp_delete_comment($comment_id, true);
207 207
 
208 208
 		/**
209 209
 		 * Fires after donation note deleted.
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 		 *
215 215
 		 * @since 1.0
216 216
 		 */
217
-		do_action( "give_post_delete_{$comment_type}_note", $comment_id, $id, $ret );
217
+		do_action("give_post_delete_{$comment_type}_note", $comment_id, $id, $ret);
218 218
 
219 219
 		return $ret;
220 220
 	}
@@ -233,25 +233,25 @@  discard block
 block discarded – undo
233 233
 	 *
234 234
 	 * @return array
235 235
 	 */
236
-	public static function get( $id, $comment_type, $comment_args = array(), $search = '' ) {
236
+	public static function get($id, $comment_type, $comment_args = array(), $search = '') {
237 237
 		$comments = array();
238 238
 
239 239
 		// Set default meta_query value.
240
-		if ( ! isset( $comment_args['meta_query'] ) ) {
240
+		if ( ! isset($comment_args['meta_query'])) {
241 241
 			$comment_args['meta_query'] = array();
242 242
 		}
243 243
 
244 244
 		// Bailout
245
-		if ( empty( $id ) || empty( $comment_type ) ) {
245
+		if (empty($id) || empty($comment_type)) {
246 246
 			return $comments;
247 247
 		}
248 248
 
249
-		remove_action( 'pre_get_comments', array( self::$instance, 'hide_comments' ), 10 );
250
-		remove_filter( 'comments_clauses', array( self::$instance, 'hide_comments_pre_wp_41' ), 10 );
249
+		remove_action('pre_get_comments', array(self::$instance, 'hide_comments'), 10);
250
+		remove_filter('comments_clauses', array(self::$instance, 'hide_comments_pre_wp_41'), 10);
251 251
 
252
-		switch ( $comment_type ) {
252
+		switch ($comment_type) {
253 253
 			case 'payment':
254
-				$comment_args['meta_query'] = ! empty( $comment_args['meta_query'] )
254
+				$comment_args['meta_query'] = ! empty($comment_args['meta_query'])
255 255
 					? $comment_args['meta_query']
256 256
 					: array(
257 257
 						array(
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 						)
261 261
 					);
262 262
 
263
-				$comments = get_comments( wp_parse_args(
263
+				$comments = get_comments(wp_parse_args(
264 264
 					$comment_args,
265 265
 					array(
266 266
 						'post_id' => $id,
@@ -268,11 +268,11 @@  discard block
 block discarded – undo
268 268
 						'search'  => $search,
269 269
 						'type'    => 'give_payment_note'
270 270
 					)
271
-				) );
271
+				));
272 272
 				break;
273 273
 
274 274
 			case 'donor':
275
-				$comment_args['meta_query'] = ! empty( $comment_args['meta_query'] )
275
+				$comment_args['meta_query'] = ! empty($comment_args['meta_query'])
276 276
 					? $comment_args['meta_query']
277 277
 					: array(
278 278
 						array(
@@ -281,19 +281,19 @@  discard block
 block discarded – undo
281 281
 						)
282 282
 					);
283 283
 
284
-				$comments = get_comments( wp_parse_args(
284
+				$comments = get_comments(wp_parse_args(
285 285
 					$comment_args,
286 286
 					array(
287 287
 						'order'  => 'ASC',
288 288
 						'search' => $search,
289 289
 						'type'   => 'give_donor_note'
290 290
 					)
291
-				) );
291
+				));
292 292
 				break;
293 293
 		}
294 294
 
295
-		add_action( 'pre_get_comments', array( self::$instance, 'hide_comments' ), 10, 1 );
296
-		add_filter( 'comments_clauses', array( self::$instance, 'hide_comments_pre_wp_41' ), 10, 1 );
295
+		add_action('pre_get_comments', array(self::$instance, 'hide_comments'), 10, 1);
296
+		add_filter('comments_clauses', array(self::$instance, 'hide_comments_pre_wp_41'), 10, 1);
297 297
 
298 298
 		return $comments;
299 299
 	}
@@ -309,14 +309,14 @@  discard block
 block discarded – undo
309 309
 	 *
310 310
 	 * @return void
311 311
 	 */
312
-	public function hide_comments( $query ) {
313
-		if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '>=' ) ) {
314
-			$types = isset( $query->query_vars['type__not_in'] ) ? $query->query_vars['type__not_in'] : array();
315
-			if ( ! is_array( $types ) ) {
316
-				$types = array( $types );
312
+	public function hide_comments($query) {
313
+		if (version_compare(floatval(get_bloginfo('version')), '4.1', '>=')) {
314
+			$types = isset($query->query_vars['type__not_in']) ? $query->query_vars['type__not_in'] : array();
315
+			if ( ! is_array($types)) {
316
+				$types = array($types);
317 317
 			}
318 318
 
319
-			$types = array_filter( array_merge( $types, $this->comment_types ) );
319
+			$types = array_filter(array_merge($types, $this->comment_types));
320 320
 
321 321
 			$query->query_vars['type__not_in'] = $types;
322 322
 		}
@@ -332,9 +332,9 @@  discard block
 block discarded – undo
332 332
 	 *
333 333
 	 * @return array $clauses Updated comment clauses.
334 334
 	 */
335
-	public function hide_comments_pre_wp_41( $clauses ) {
336
-		if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '<' ) ) {
337
-			foreach ( $this->comment_types as $comment_type ) {
335
+	public function hide_comments_pre_wp_41($clauses) {
336
+		if (version_compare(floatval(get_bloginfo('version')), '4.1', '<')) {
337
+			foreach ($this->comment_types as $comment_type) {
338 338
 				$clauses['where'] .= " AND comment_type != \"{$comment_type}\"";
339 339
 			}
340 340
 		}
@@ -352,11 +352,11 @@  discard block
 block discarded – undo
352 352
 	 *
353 353
 	 * @return string $where
354 354
 	 */
355
-	public function hide_comments_from_feeds( $where ) {
355
+	public function hide_comments_from_feeds($where) {
356 356
 		global $wpdb;
357 357
 
358
-		foreach ( $this->comment_types as $comment_type ) {
359
-			$where .= $wpdb->prepare( ' AND comment_type!=%s', $comment_type );
358
+		foreach ($this->comment_types as $comment_type) {
359
+			$where .= $wpdb->prepare(' AND comment_type!=%s', $comment_type);
360 360
 		}
361 361
 
362 362
 		return $where;
@@ -373,30 +373,30 @@  discard block
 block discarded – undo
373 373
 	 *
374 374
 	 * @return array|object Array of comment counts.
375 375
 	 */
376
-	public function remove_comments_from_comment_counts( $stats, $post_id ) {
376
+	public function remove_comments_from_comment_counts($stats, $post_id) {
377 377
 		global $wpdb;
378 378
 
379 379
 		$post_id = (int) $post_id;
380 380
 
381
-		if ( apply_filters( 'give_count_payment_notes_in_comments', false ) ) {
381
+		if (apply_filters('give_count_payment_notes_in_comments', false)) {
382 382
 			return $stats;
383 383
 		}
384 384
 
385
-		$stats = Give_Cache::get_group( "comments-{$post_id}", 'counts' );
385
+		$stats = Give_Cache::get_group("comments-{$post_id}", 'counts');
386 386
 
387 387
 		// Return result from cache.
388
-		if ( ! is_null( $stats ) ) {
388
+		if ( ! is_null($stats)) {
389 389
 			return $stats;
390 390
 		}
391 391
 
392 392
 		$where = 'WHERE';
393 393
 
394
-		foreach ( $this->comment_types as $index => $comment_type ) {
395
-			$where .= ( $index ? ' AND ' : ' ' ) . "comment_type != \"{$comment_type}\"";
394
+		foreach ($this->comment_types as $index => $comment_type) {
395
+			$where .= ($index ? ' AND ' : ' ')."comment_type != \"{$comment_type}\"";
396 396
 		}
397 397
 
398
-		if ( $post_id > 0 ) {
399
-			$where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id );
398
+		if ($post_id > 0) {
399
+			$where .= $wpdb->prepare(' AND comment_post_ID = %d', $post_id);
400 400
 		}
401 401
 
402 402
 		$count = $wpdb->get_results(
@@ -417,26 +417,26 @@  discard block
 block discarded – undo
417 417
 			'post-trashed' => 'post-trashed',
418 418
 		);
419 419
 
420
-		foreach ( (array) $count as $row ) {
420
+		foreach ((array) $count as $row) {
421 421
 			// Don't count post-trashed toward totals.
422
-			if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) {
422
+			if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) {
423 423
 				$total += $row['num_comments'];
424 424
 			}
425
-			if ( isset( $approved[ $row['comment_approved'] ] ) ) {
426
-				$stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments'];
425
+			if (isset($approved[$row['comment_approved']])) {
426
+				$stats[$approved[$row['comment_approved']]] = $row['num_comments'];
427 427
 			}
428 428
 		}
429 429
 
430 430
 		$stats['total_comments'] = $stats['all'] = $total;
431
-		foreach ( $approved as $key ) {
432
-			if ( empty( $stats[ $key ] ) ) {
433
-				$stats[ $key ] = 0;
431
+		foreach ($approved as $key) {
432
+			if (empty($stats[$key])) {
433
+				$stats[$key] = 0;
434 434
 			}
435 435
 		}
436 436
 
437 437
 		$stats = (object) $stats;
438 438
 
439
-		Give_Cache::set_group( "comments-{$post_id}", $stats, 'counts' );
439
+		Give_Cache::set_group("comments-{$post_id}", $stats, 'counts');
440 440
 
441 441
 		return $stats;
442 442
 	}
@@ -453,12 +453,12 @@  discard block
 block discarded – undo
453 453
 	 *
454 454
 	 * @return mixed
455 455
 	 */
456
-	public function __get_comment_author( $author, $comment_id, $comment ) {
457
-		if ( in_array( $comment->comment_type, $this->comment_types ) ) {
458
-			switch ( $comment->comment_type ) {
456
+	public function __get_comment_author($author, $comment_id, $comment) {
457
+		if (in_array($comment->comment_type, $this->comment_types)) {
458
+			switch ($comment->comment_type) {
459 459
 				case 'give_payment_note':
460
-					if ( get_comment_meta( $comment_id, '_give_donor_id', true ) ) {
461
-						$author = give_get_donor_name_by( $comment->comment_post_ID );
460
+					if (get_comment_meta($comment_id, '_give_donor_id', true)) {
461
+						$author = give_get_donor_name_by($comment->comment_post_ID);
462 462
 					}
463 463
 			}
464 464
 		}
@@ -477,9 +477,9 @@  discard block
 block discarded – undo
477 477
 	 *
478 478
 	 * @return array
479 479
 	 */
480
-	public static function get_comment_types( $comment_types ) {
480
+	public static function get_comment_types($comment_types) {
481 481
 		$_comment_types = array();
482
-		foreach ( $comment_types as $comment_type ) {
482
+		foreach ($comment_types as $comment_type) {
483 483
 			$_comment_types[] = "give_{$comment_type}_note";
484 484
 		}
485 485
 
Please login to merge, or discard this patch.
includes/class-give-db-meta.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 	/**
280 280
 	 * Rename query clauses for new meta table
281 281
 	 *
282
-	 * @param $clause
282
+	 * @param string $clause
283 283
 	 * @param $filter
284 284
 	 *
285 285
 	 * @return mixed
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
 	 * @since  2.0.4
516 516
 	 * @access public
517 517
 	 *
518
-	 * @return string
518
+	 * @return boolean
519 519
 	 */
520 520
 	public function get_meta_type() {
521 521
 		return $this->meta_type;
Please login to merge, or discard this patch.
Spacing   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -77,40 +77,40 @@  discard block
 block discarded – undo
77 77
 		parent::__construct();
78 78
 
79 79
 		// Bailout.
80
-		if ( empty( $this->supports ) || ! $this->is_custom_meta_table_active() ) {
80
+		if (empty($this->supports) || ! $this->is_custom_meta_table_active()) {
81 81
 			return;
82 82
 		}
83 83
 
84
-		if ( in_array( 'add_post_metadata', $this->supports ) ) {
85
-			add_filter( 'add_post_metadata', array( $this, '__add_meta' ), 0, 5 );
84
+		if (in_array('add_post_metadata', $this->supports)) {
85
+			add_filter('add_post_metadata', array($this, '__add_meta'), 0, 5);
86 86
 		}
87 87
 
88
-		if ( in_array( 'get_post_metadata', $this->supports ) ) {
89
-			add_filter( 'get_post_metadata', array( $this, '__get_meta' ), 10, 4 );
88
+		if (in_array('get_post_metadata', $this->supports)) {
89
+			add_filter('get_post_metadata', array($this, '__get_meta'), 10, 4);
90 90
 		}
91 91
 
92
-		if ( in_array( 'update_post_metadata', $this->supports ) ) {
93
-			add_filter( 'update_post_metadata', array( $this, '__update_meta' ), 0, 5 );
92
+		if (in_array('update_post_metadata', $this->supports)) {
93
+			add_filter('update_post_metadata', array($this, '__update_meta'), 0, 5);
94 94
 		}
95 95
 
96
-		if ( in_array( 'delete_post_metadata', $this->supports ) ) {
97
-			add_filter( 'delete_post_metadata', array( $this, '__delete_meta' ), 0, 5 );
96
+		if (in_array('delete_post_metadata', $this->supports)) {
97
+			add_filter('delete_post_metadata', array($this, '__delete_meta'), 0, 5);
98 98
 		}
99 99
 
100
-		if ( in_array( 'posts_where', $this->supports ) ) {
101
-			add_filter( 'posts_where', array( $this, '__rename_meta_table_name_in_query' ), 99999, 2 );
100
+		if (in_array('posts_where', $this->supports)) {
101
+			add_filter('posts_where', array($this, '__rename_meta_table_name_in_query'), 99999, 2);
102 102
 		}
103 103
 
104
-		if ( in_array( 'posts_join', $this->supports ) ) {
105
-			add_filter( 'posts_join', array( $this, '__rename_meta_table_name_in_query' ), 99999, 2 );
104
+		if (in_array('posts_join', $this->supports)) {
105
+			add_filter('posts_join', array($this, '__rename_meta_table_name_in_query'), 99999, 2);
106 106
 		}
107 107
 
108
-		if ( in_array( 'posts_groupby', $this->supports ) ) {
109
-			add_filter( 'posts_groupby', array( $this, '__rename_meta_table_name_in_query' ), 99999, 2 );
108
+		if (in_array('posts_groupby', $this->supports)) {
109
+			add_filter('posts_groupby', array($this, '__rename_meta_table_name_in_query'), 99999, 2);
110 110
 		}
111 111
 
112
-		if ( in_array( 'posts_orderby', $this->supports ) ) {
113
-			add_filter( 'posts_orderby', array( $this, '__rename_meta_table_name_in_query' ), 99999, 2 );
112
+		if (in_array('posts_orderby', $this->supports)) {
113
+			add_filter('posts_orderby', array($this, '__rename_meta_table_name_in_query'), 99999, 2);
114 114
 		}
115 115
 	}
116 116
 
@@ -128,16 +128,16 @@  discard block
 block discarded – undo
128 128
 	 * @return  mixed                 Will be an array if $single is false. Will be value of meta data field if $single
129 129
 	 *                                is true.
130 130
 	 */
131
-	public function get_meta( $id = 0, $meta_key = '', $single = false ) {
132
-		$id = $this->sanitize_id( $id );
131
+	public function get_meta($id = 0, $meta_key = '', $single = false) {
132
+		$id = $this->sanitize_id($id);
133 133
 
134 134
 		// Bailout.
135
-		if ( ! $this->is_valid_post_type( $id ) ) {
135
+		if ( ! $this->is_valid_post_type($id)) {
136 136
 			return $this->check;
137 137
 		}
138 138
 
139
-		if ( $this->raw_result ) {
140
-			if ( ! ( $value = get_metadata( $this->meta_type, $id, $meta_key, false ) ) ) {
139
+		if ($this->raw_result) {
140
+			if ( ! ($value = get_metadata($this->meta_type, $id, $meta_key, false))) {
141 141
 				$value = '';
142 142
 			}
143 143
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 			$this->raw_result = false;
146 146
 
147 147
 		} else {
148
-			$value = get_metadata( $this->meta_type, $id, $meta_key, $single );
148
+			$value = get_metadata($this->meta_type, $id, $meta_key, $single);
149 149
 		}
150 150
 
151 151
 		return $value;
@@ -167,18 +167,18 @@  discard block
 block discarded – undo
167 167
 	 *
168 168
 	 * @return  int|bool                  False for failure. True for success.
169 169
 	 */
170
-	public function add_meta( $id = 0, $meta_key = '', $meta_value, $unique = false ) {
171
-		$id = $this->sanitize_id( $id );
170
+	public function add_meta($id = 0, $meta_key = '', $meta_value, $unique = false) {
171
+		$id = $this->sanitize_id($id);
172 172
 
173 173
 		// Bailout.
174
-		if ( ! $this->is_valid_post_type( $id ) ) {
174
+		if ( ! $this->is_valid_post_type($id)) {
175 175
 			return $this->check;
176 176
 		}
177 177
 
178
-		$meta_id = add_metadata( $this->meta_type, $id, $meta_key, $meta_value, $unique );
178
+		$meta_id = add_metadata($this->meta_type, $id, $meta_key, $meta_value, $unique);
179 179
 
180
-		if ( $meta_id ) {
181
-			$this->delete_cache( $id );
180
+		if ($meta_id) {
181
+			$this->delete_cache($id);
182 182
 		}
183 183
 
184 184
 		return $meta_id;
@@ -204,18 +204,18 @@  discard block
 block discarded – undo
204 204
 	 *
205 205
 	 * @return  int|bool                  False on failure, true if success.
206 206
 	 */
207
-	public function update_meta( $id = 0, $meta_key = '', $meta_value, $prev_value = '' ) {
208
-		$id = $this->sanitize_id( $id );
207
+	public function update_meta($id = 0, $meta_key = '', $meta_value, $prev_value = '') {
208
+		$id = $this->sanitize_id($id);
209 209
 
210 210
 		// Bailout.
211
-		if ( ! $this->is_valid_post_type( $id ) ) {
211
+		if ( ! $this->is_valid_post_type($id)) {
212 212
 			return $this->check;
213 213
 		}
214 214
 
215
-		$meta_id = update_metadata( $this->meta_type, $id, $meta_key, $meta_value, $prev_value );
215
+		$meta_id = update_metadata($this->meta_type, $id, $meta_key, $meta_value, $prev_value);
216 216
 
217
-		if ( $meta_id ) {
218
-			$this->delete_cache( $id );
217
+		if ($meta_id) {
218
+			$this->delete_cache($id);
219 219
 		}
220 220
 
221 221
 		return $meta_id;
@@ -238,18 +238,18 @@  discard block
 block discarded – undo
238 238
 	 *
239 239
 	 * @return  bool                  False for failure. True for success.
240 240
 	 */
241
-	public function delete_meta( $id = 0, $meta_key = '', $meta_value = '', $delete_all = '' ) {
242
-		$id = $this->sanitize_id( $id );
241
+	public function delete_meta($id = 0, $meta_key = '', $meta_value = '', $delete_all = '') {
242
+		$id = $this->sanitize_id($id);
243 243
 
244 244
 		// Bailout.
245
-		if ( ! $this->is_valid_post_type( $id ) ) {
245
+		if ( ! $this->is_valid_post_type($id)) {
246 246
 			return $this->check;
247 247
 		}
248 248
 
249
-		$is_meta_deleted = delete_metadata( $this->meta_type, $id, $meta_key, $meta_value, $delete_all );
249
+		$is_meta_deleted = delete_metadata($this->meta_type, $id, $meta_key, $meta_value, $delete_all);
250 250
 
251
-		if ( $is_meta_deleted ) {
252
-			$this->delete_cache( $id );
251
+		if ($is_meta_deleted) {
252
+			$this->delete_cache($id);
253 253
 		}
254 254
 
255 255
 		return $is_meta_deleted;
@@ -266,10 +266,10 @@  discard block
 block discarded – undo
266 266
 	 *
267 267
 	 * @return string
268 268
 	 */
269
-	public function __rename_meta_table_name_in_query( $clause, $wp_query ) {
269
+	public function __rename_meta_table_name_in_query($clause, $wp_query) {
270 270
 		// Add new table to sql query.
271
-		if ( $this->is_post_type_query( $wp_query ) && ! empty( $wp_query->meta_query->queries ) ) {
272
-			$clause = $this->__rename_meta_table_name( $clause, current_filter() );
271
+		if ($this->is_post_type_query($wp_query) && ! empty($wp_query->meta_query->queries)) {
272
+			$clause = $this->__rename_meta_table_name($clause, current_filter());
273 273
 		}
274 274
 
275 275
 		return $clause;
@@ -284,42 +284,42 @@  discard block
 block discarded – undo
284 284
 	 *
285 285
 	 * @return mixed
286 286
 	 */
287
-	public function __rename_meta_table_name( $clause, $filter ) {
287
+	public function __rename_meta_table_name($clause, $filter) {
288 288
 		global $wpdb;
289 289
 
290
-		$clause = str_replace( "{$wpdb->postmeta}.post_id", "{$this->table_name}.{$this->meta_type}_id", $clause );
291
-		$clause = str_replace( $wpdb->postmeta, $this->table_name, $clause );
290
+		$clause = str_replace("{$wpdb->postmeta}.post_id", "{$this->table_name}.{$this->meta_type}_id", $clause);
291
+		$clause = str_replace($wpdb->postmeta, $this->table_name, $clause);
292 292
 
293
-		switch ( $filter ) {
293
+		switch ($filter) {
294 294
 			case 'posts_join':
295
-				$joins = array( 'INNER JOIN', 'LEFT JOIN' );
295
+				$joins = array('INNER JOIN', 'LEFT JOIN');
296 296
 
297
-				foreach ( $joins as $join ) {
298
-					if ( false !== strpos( $clause, $join ) ) {
299
-						$clause = explode( $join, $clause );
297
+				foreach ($joins as $join) {
298
+					if (false !== strpos($clause, $join)) {
299
+						$clause = explode($join, $clause);
300 300
 
301
-						foreach ( $clause as $key => $clause_part ) {
302
-							if ( empty( $clause_part ) ) {
301
+						foreach ($clause as $key => $clause_part) {
302
+							if (empty($clause_part)) {
303 303
 								continue;
304 304
 							}
305 305
 
306
-							preg_match( '/' . $wpdb->prefix . 'give_' . $this->meta_type . 'meta AS (.*) ON/', $clause_part, $alias_table_name );
306
+							preg_match('/'.$wpdb->prefix.'give_'.$this->meta_type.'meta AS (.*) ON/', $clause_part, $alias_table_name);
307 307
 
308
-							if ( isset( $alias_table_name[1] ) ) {
309
-								$clause[ $key ] = str_replace( "{$alias_table_name[1]}.post_id", "{$alias_table_name[1]}.{$this->meta_type}_id", $clause_part );
308
+							if (isset($alias_table_name[1])) {
309
+								$clause[$key] = str_replace("{$alias_table_name[1]}.post_id", "{$alias_table_name[1]}.{$this->meta_type}_id", $clause_part);
310 310
 							}
311 311
 						}
312 312
 
313
-						$clause = implode( "{$join} ", $clause );
313
+						$clause = implode("{$join} ", $clause);
314 314
 					}
315 315
 				}
316 316
 				break;
317 317
 
318 318
 			case 'posts_where':
319
-				$clause = str_replace( array( 'mt2.post_id', 'mt1.post_id' ), array(
319
+				$clause = str_replace(array('mt2.post_id', 'mt1.post_id'), array(
320 320
 					"mt2.{$this->meta_type}_id",
321 321
 					"mt1.{$this->meta_type}_id"
322
-				), $clause );
322
+				), $clause);
323 323
 				break;
324 324
 		}
325 325
 
@@ -337,19 +337,19 @@  discard block
 block discarded – undo
337 337
 	 *
338 338
 	 * @return bool
339 339
 	 */
340
-	protected function is_post_type_query( $wp_query ) {
340
+	protected function is_post_type_query($wp_query) {
341 341
 		$status = false;
342 342
 
343 343
 		// Check if it is payment query.
344
-		if ( ! empty( $wp_query->query['post_type'] ) ) {
344
+		if ( ! empty($wp_query->query['post_type'])) {
345 345
 			if (
346
-				is_string( $wp_query->query['post_type'] ) &&
346
+				is_string($wp_query->query['post_type']) &&
347 347
 				$this->post_type === $wp_query->query['post_type']
348 348
 			) {
349 349
 				$status = true;
350 350
 			} elseif (
351
-				is_array( $wp_query->query['post_type'] ) &&
352
-				in_array( $this->post_type, $wp_query->query['post_type'] )
351
+				is_array($wp_query->query['post_type']) &&
352
+				in_array($this->post_type, $wp_query->query['post_type'])
353 353
 			) {
354 354
 				$status = true;
355 355
 			}
@@ -368,8 +368,8 @@  discard block
 block discarded – undo
368 368
 	 *
369 369
 	 * @return bool
370 370
 	 */
371
-	protected function is_valid_post_type( $ID ) {
372
-		return $ID && ( $this->post_type === get_post_type( $ID ) );
371
+	protected function is_valid_post_type($ID) {
372
+		return $ID && ($this->post_type === get_post_type($ID));
373 373
 	}
374 374
 
375 375
 	/**
@@ -395,8 +395,8 @@  discard block
 block discarded – undo
395 395
 	 *
396 396
 	 * @return void
397 397
 	 */
398
-	private function delete_cache( $id, $meta_type = '' ) {
399
-		$meta_type = empty( $meta_type ) ? $this->meta_type : $meta_type;
398
+	private function delete_cache($id, $meta_type = '') {
399
+		$meta_type = empty($meta_type) ? $this->meta_type : $meta_type;
400 400
 
401 401
 		$group = array(
402 402
 			'payment'  => 'give-donations', // Backward compatibility
@@ -405,8 +405,8 @@  discard block
 block discarded – undo
405 405
 			'customer' => 'give-donors', // Backward compatibility for pre upgrade in 2.0
406 406
 		);
407 407
 
408
-		if ( array_key_exists( $meta_type, $group ) ) {
409
-			Give_Cache::delete_group( $id, $group[ $meta_type ] );
408
+		if (array_key_exists($meta_type, $group)) {
409
+			Give_Cache::delete_group($id, $group[$meta_type]);
410 410
 		}
411 411
 	}
412 412
 
@@ -421,8 +421,8 @@  discard block
 block discarded – undo
421 421
 	 *
422 422
 	 * @return mixed
423 423
 	 */
424
-	public function __call( $name, $arguments ) {
425
-		switch ( $name ) {
424
+	public function __call($name, $arguments) {
425
+		switch ($name) {
426 426
 			case '__add_meta':
427 427
 				$this->check = $arguments[0];
428 428
 				$id          = $arguments[1];
@@ -431,11 +431,11 @@  discard block
 block discarded – undo
431 431
 				$unique      = $arguments[4];
432 432
 
433 433
 				// Bailout.
434
-				if ( ! $this->is_valid_post_type( $id ) ) {
434
+				if ( ! $this->is_valid_post_type($id)) {
435 435
 					return $this->check;
436 436
 				}
437 437
 
438
-				return $this->add_meta( $id, $meta_key, $meta_value, $unique );
438
+				return $this->add_meta($id, $meta_key, $meta_value, $unique);
439 439
 
440 440
 			case '__get_meta':
441 441
 				$this->check = $arguments[0];
@@ -444,13 +444,13 @@  discard block
 block discarded – undo
444 444
 				$single      = $arguments[3];
445 445
 
446 446
 				// Bailout.
447
-				if ( ! $this->is_valid_post_type( $id ) ) {
447
+				if ( ! $this->is_valid_post_type($id)) {
448 448
 					return $this->check;
449 449
 				}
450 450
 
451 451
 				$this->raw_result = true;
452 452
 
453
-				return $this->get_meta( $id, $meta_key, $single );
453
+				return $this->get_meta($id, $meta_key, $single);
454 454
 
455 455
 			case '__update_meta':
456 456
 				$this->check = $arguments[0];
@@ -459,11 +459,11 @@  discard block
 block discarded – undo
459 459
 				$meta_value  = $arguments[3];
460 460
 
461 461
 				// Bailout.
462
-				if ( ! $this->is_valid_post_type( $id ) ) {
462
+				if ( ! $this->is_valid_post_type($id)) {
463 463
 					return $this->check;
464 464
 				}
465 465
 
466
-				return $this->update_meta( $id, $meta_key, $meta_value );
466
+				return $this->update_meta($id, $meta_key, $meta_value);
467 467
 
468 468
 			case '__delete_meta':
469 469
 				$this->check = $arguments[0];
@@ -473,11 +473,11 @@  discard block
 block discarded – undo
473 473
 				$delete_all  = $arguments[3];
474 474
 
475 475
 				// Bailout.
476
-				if ( ! $this->is_valid_post_type( $id ) ) {
476
+				if ( ! $this->is_valid_post_type($id)) {
477 477
 					return $this->check;
478 478
 				}
479 479
 
480
-				return $this->delete_meta( $id, $meta_key, $meta_value, $delete_all );
480
+				return $this->delete_meta($id, $meta_key, $meta_value, $delete_all);
481 481
 		}
482 482
 	}
483 483
 
@@ -502,10 +502,10 @@  discard block
 block discarded – undo
502 502
 			KEY meta_key (meta_key({$this->min_index_length}))
503 503
 			) {$charset_collate};";
504 504
 
505
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
506
-		dbDelta( $sql );
505
+		require_once(ABSPATH.'wp-admin/includes/upgrade.php');
506
+		dbDelta($sql);
507 507
 
508
-		update_option( $this->table_name . '_db_version', $this->version, false );
508
+		update_option($this->table_name.'_db_version', $this->version, false);
509 509
 	}
510 510
 
511 511
 
@@ -531,12 +531,12 @@  discard block
 block discarded – undo
531 531
 	 *
532 532
 	 * @return  bool  False for failure. True for success.
533 533
 	 */
534
-	public function delete_all_meta( $id = 0 ) {
534
+	public function delete_all_meta($id = 0) {
535 535
 		global $wpdb;
536
-		$status = $wpdb->delete( $this->table_name, array( "{$this->meta_type}_id" => $id ), array( '%d' ) );
536
+		$status = $wpdb->delete($this->table_name, array("{$this->meta_type}_id" => $id), array('%d'));
537 537
 
538
-		if ( $status ) {
539
-			$this->delete_cache( $id, $this->meta_type );
538
+		if ($status) {
539
+			$this->delete_cache($id, $this->meta_type);
540 540
 		}
541 541
 
542 542
 		return $status;
Please login to merge, or discard this patch.
includes/class-give-donor.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1052,7 +1052,7 @@
 block discarded – undo
1052 1052
 	 * @access public
1053 1053
 	 *
1054 1054
 	 * @param  string $meta_key   Metadata name. Default is empty.
1055
-	 * @param  mixed  $meta_value Optional. Metadata value. Default is empty.
1055
+	 * @param  string  $meta_value Optional. Metadata value. Default is empty.
1056 1056
 	 *
1057 1057
 	 * @return bool               False for failure. True for success.
1058 1058
 	 */
Please login to merge, or discard this patch.
Spacing   +273 added lines, -273 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -149,29 +149,29 @@  discard block
 block discarded – undo
149 149
 	 * @param int|bool $_id_or_email
150 150
 	 * @param bool     $by_user_id
151 151
 	 */
152
-	public function __construct( $_id_or_email = false, $by_user_id = false ) {
152
+	public function __construct($_id_or_email = false, $by_user_id = false) {
153 153
 
154 154
 		$this->db = Give()->donors;
155 155
 
156
-		if ( false === $_id_or_email || ( is_numeric( $_id_or_email ) && (int) $_id_or_email !== absint( $_id_or_email ) ) ) {
156
+		if (false === $_id_or_email || (is_numeric($_id_or_email) && (int) $_id_or_email !== absint($_id_or_email))) {
157 157
 			return false;
158 158
 		}
159 159
 
160
-		$by_user_id = is_bool( $by_user_id ) ? $by_user_id : false;
160
+		$by_user_id = is_bool($by_user_id) ? $by_user_id : false;
161 161
 
162
-		if ( is_numeric( $_id_or_email ) ) {
162
+		if (is_numeric($_id_or_email)) {
163 163
 			$field = $by_user_id ? 'user_id' : 'id';
164 164
 		} else {
165 165
 			$field = 'email';
166 166
 		}
167 167
 
168
-		$donor = $this->db->get_donor_by( $field, $_id_or_email );
168
+		$donor = $this->db->get_donor_by($field, $_id_or_email);
169 169
 
170
-		if ( empty( $donor ) || ! is_object( $donor ) ) {
170
+		if (empty($donor) || ! is_object($donor)) {
171 171
 			return false;
172 172
 		}
173 173
 
174
-		$this->setup_donor( $donor );
174
+		$this->setup_donor($donor);
175 175
 
176 176
 	}
177 177
 
@@ -187,19 +187,19 @@  discard block
 block discarded – undo
187 187
 	 *
188 188
 	 * @return bool             If the setup was successful or not.
189 189
 	 */
190
-	private function setup_donor( $donor ) {
190
+	private function setup_donor($donor) {
191 191
 
192
-		if ( ! is_object( $donor ) ) {
192
+		if ( ! is_object($donor)) {
193 193
 			return false;
194 194
 		}
195 195
 
196 196
 		// Get cached donors.
197
-		$donor_vars = Give_Cache::get_group( $donor->id, 'give-donors' );
197
+		$donor_vars = Give_Cache::get_group($donor->id, 'give-donors');
198 198
 
199
-		if ( is_null( $donor_vars ) ) {
200
-			foreach ( $donor as $key => $value ) {
199
+		if (is_null($donor_vars)) {
200
+			foreach ($donor as $key => $value) {
201 201
 
202
-				switch ( $key ) {
202
+				switch ($key) {
203 203
 
204 204
 					case 'notes':
205 205
 						$this->$key = $this->get_notes();
@@ -213,20 +213,20 @@  discard block
 block discarded – undo
213 213
 			}
214 214
 
215 215
 			// Get donor's all email including primary email.
216
-			$this->emails = (array) $this->get_meta( 'additional_email', false );
217
-			$this->emails = array( 'primary' => $this->email ) + $this->emails;
216
+			$this->emails = (array) $this->get_meta('additional_email', false);
217
+			$this->emails = array('primary' => $this->email) + $this->emails;
218 218
 
219 219
 			$this->setup_address();
220 220
 
221
-			Give_Cache::set_group( $donor->id, get_object_vars( $this ), 'give-donors' );
221
+			Give_Cache::set_group($donor->id, get_object_vars($this), 'give-donors');
222 222
 		} else {
223
-			foreach ( $donor_vars as $donor_var => $value ) {
223
+			foreach ($donor_vars as $donor_var => $value) {
224 224
 				$this->$donor_var = $value;
225 225
 			}
226 226
 		}
227 227
 
228 228
 		// Donor ID and email are the only things that are necessary, make sure they exist.
229
-		if ( ! empty( $this->id ) && ! empty( $this->email ) ) {
229
+		if ( ! empty($this->id) && ! empty($this->email)) {
230 230
 			return true;
231 231
 		}
232 232
 
@@ -245,25 +245,25 @@  discard block
 block discarded – undo
245 245
 		global $wpdb;
246 246
 		$meta_type = Give()->donor_meta->meta_type;
247 247
 
248
-		$addresses = $wpdb->get_results( $wpdb->prepare( "
248
+		$addresses = $wpdb->get_results($wpdb->prepare("
249 249
 				SELECT meta_key, meta_value FROM {$wpdb->donormeta}
250 250
 				WHERE meta_key
251 251
 				LIKE '%%%s%%'
252 252
 				AND {$meta_type}_id=%d
253
-				", 'give_donor_address', $this->id ), ARRAY_N );
253
+				", 'give_donor_address', $this->id), ARRAY_N);
254 254
 
255
-		if ( empty( $addresses ) ) {
255
+		if (empty($addresses)) {
256 256
 			return $this->address;
257 257
 		}
258 258
 
259
-		foreach ( $addresses as $address ) {
260
-			$address[0] = str_replace( '_give_donor_address_', '', $address[0] );
261
-			$address[0] = explode( '_', $address[0] );
259
+		foreach ($addresses as $address) {
260
+			$address[0] = str_replace('_give_donor_address_', '', $address[0]);
261
+			$address[0] = explode('_', $address[0]);
262 262
 
263
-			if ( 3 === count( $address[0] ) ) {
264
-				$this->address[ $address[0][0] ][ $address[0][2] ][ $address[0][1] ] = $address[1];
263
+			if (3 === count($address[0])) {
264
+				$this->address[$address[0][0]][$address[0][2]][$address[0][1]] = $address[1];
265 265
 			} else {
266
-				$this->address[ $address[0][0] ][ $address[0][1] ] = $address[1];
266
+				$this->address[$address[0][0]][$address[0][1]] = $address[1];
267 267
 			}
268 268
 		}
269 269
 	}
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 	 *
280 280
 	 * @return array The donor's address, if any
281 281
 	 */
282
-	public function get_donor_address( $args = array() ) {
282
+	public function get_donor_address($args = array()) {
283 283
 		$args = wp_parse_args(
284 284
 			$args,
285 285
 			array(
@@ -297,24 +297,24 @@  discard block
 block discarded – undo
297 297
 		);
298 298
 
299 299
 		// Backward compatibility.
300
-		if ( ! give_has_upgrade_completed( 'v20_upgrades_user_address' ) ) {
300
+		if ( ! give_has_upgrade_completed('v20_upgrades_user_address')) {
301 301
 
302 302
 			// Backward compatibility for user id param.
303
-			return wp_parse_args( (array) get_user_meta( $this->user_id, '_give_user_address', true ), $default_address );
303
+			return wp_parse_args((array) get_user_meta($this->user_id, '_give_user_address', true), $default_address);
304 304
 
305 305
 		}
306 306
 
307
-		if ( ! $this->id || empty( $this->address ) || ! array_key_exists( $args['address_type'], $this->address ) ) {
307
+		if ( ! $this->id || empty($this->address) || ! array_key_exists($args['address_type'], $this->address)) {
308 308
 			return $default_address;
309 309
 		}
310 310
 
311
-		switch ( true ) {
312
-			case is_string( end( $this->address[ $args['address_type'] ] ) ):
313
-				$address = wp_parse_args( $this->address[ $args['address_type'] ], $default_address );
311
+		switch (true) {
312
+			case is_string(end($this->address[$args['address_type']])):
313
+				$address = wp_parse_args($this->address[$args['address_type']], $default_address);
314 314
 				break;
315 315
 
316
-			case is_array( end( $this->address[ $args['address_type'] ] ) ):
317
-				$address = wp_parse_args( array_shift( $this->address[ $args['address_type'] ] ), $default_address );
316
+			case is_array(end($this->address[$args['address_type']])):
317
+				$address = wp_parse_args(array_shift($this->address[$args['address_type']]), $default_address);
318 318
 				break;
319 319
 		}
320 320
 
@@ -331,16 +331,16 @@  discard block
 block discarded – undo
331 331
 	 *
332 332
 	 * @return mixed|\WP_Error
333 333
 	 */
334
-	public function __get( $key ) {
334
+	public function __get($key) {
335 335
 
336
-		if ( method_exists( $this, 'get_' . $key ) ) {
336
+		if (method_exists($this, 'get_'.$key)) {
337 337
 
338
-			return call_user_func( array( $this, 'get_' . $key ) );
338
+			return call_user_func(array($this, 'get_'.$key));
339 339
 
340 340
 		} else {
341 341
 
342 342
 			/* translators: %s: property key */
343
-			return new WP_Error( 'give-donor-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) );
343
+			return new WP_Error('give-donor-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key));
344 344
 
345 345
 		}
346 346
 
@@ -356,9 +356,9 @@  discard block
 block discarded – undo
356 356
 	 *
357 357
 	 * @return bool|int    False if not a valid creation, donor ID if user is found or valid creation.
358 358
 	 */
359
-	public function create( $data = array() ) {
359
+	public function create($data = array()) {
360 360
 
361
-		if ( $this->id != 0 || empty( $data ) ) {
361
+		if ($this->id != 0 || empty($data)) {
362 362
 			return false;
363 363
 		}
364 364
 
@@ -366,15 +366,15 @@  discard block
 block discarded – undo
366 366
 			'payment_ids' => '',
367 367
 		);
368 368
 
369
-		$args = wp_parse_args( $data, $defaults );
370
-		$args = $this->sanitize_columns( $args );
369
+		$args = wp_parse_args($data, $defaults);
370
+		$args = $this->sanitize_columns($args);
371 371
 
372
-		if ( empty( $args['email'] ) || ! is_email( $args['email'] ) ) {
372
+		if (empty($args['email']) || ! is_email($args['email'])) {
373 373
 			return false;
374 374
 		}
375 375
 
376
-		if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) {
377
-			$args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) );
376
+		if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) {
377
+			$args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids'])));
378 378
 		}
379 379
 
380 380
 		/**
@@ -384,18 +384,18 @@  discard block
 block discarded – undo
384 384
 		 *
385 385
 		 * @param array $args Donor attributes.
386 386
 		 */
387
-		do_action( 'give_donor_pre_create', $args );
387
+		do_action('give_donor_pre_create', $args);
388 388
 
389 389
 		$created = false;
390 390
 
391 391
 		// The DB class 'add' implies an update if the donor being asked to be created already exists
392
-		if ( $this->db->add( $data ) ) {
392
+		if ($this->db->add($data)) {
393 393
 
394 394
 			// We've successfully added/updated the donor, reset the class vars with the new data
395
-			$donor = $this->db->get_donor_by( 'email', $args['email'] );
395
+			$donor = $this->db->get_donor_by('email', $args['email']);
396 396
 
397 397
 			// Setup the donor data with the values from DB
398
-			$this->setup_donor( $donor );
398
+			$this->setup_donor($donor);
399 399
 
400 400
 			$created = $this->id;
401 401
 		}
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
 		 * @param bool|int $created False if not a valid creation, donor ID if user is found or valid creation.
409 409
 		 * @param array    $args    Customer attributes.
410 410
 		 */
411
-		do_action( 'give_donor_post_create', $created, $args );
411
+		do_action('give_donor_post_create', $created, $args);
412 412
 
413 413
 		return $created;
414 414
 
@@ -424,13 +424,13 @@  discard block
 block discarded – undo
424 424
 	 *
425 425
 	 * @return bool        If the update was successful or not.
426 426
 	 */
427
-	public function update( $data = array() ) {
427
+	public function update($data = array()) {
428 428
 
429
-		if ( empty( $data ) ) {
429
+		if (empty($data)) {
430 430
 			return false;
431 431
 		}
432 432
 
433
-		$data = $this->sanitize_columns( $data );
433
+		$data = $this->sanitize_columns($data);
434 434
 
435 435
 		/**
436 436
 		 * Fires before updating donors.
@@ -440,15 +440,15 @@  discard block
 block discarded – undo
440 440
 		 * @param int   $donor_id Donor id.
441 441
 		 * @param array $data     Donor attributes.
442 442
 		 */
443
-		do_action( 'give_donor_pre_update', $this->id, $data );
443
+		do_action('give_donor_pre_update', $this->id, $data);
444 444
 
445 445
 		$updated = false;
446 446
 
447
-		if ( $this->db->update( $this->id, $data ) ) {
447
+		if ($this->db->update($this->id, $data)) {
448 448
 
449
-			$donor = $this->db->get_donor_by( 'id', $this->id );
449
+			$donor = $this->db->get_donor_by('id', $this->id);
450 450
 
451
-			$this->setup_donor( $donor );
451
+			$this->setup_donor($donor);
452 452
 
453 453
 			$updated = true;
454 454
 		}
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
 		 * @param int   $donor_id Donor id.
463 463
 		 * @param array $data     Donor attributes.
464 464
 		 */
465
-		do_action( 'give_donor_post_update', $updated, $this->id, $data );
465
+		do_action('give_donor_post_update', $updated, $this->id, $data);
466 466
 
467 467
 		return $updated;
468 468
 	}
@@ -480,27 +480,27 @@  discard block
 block discarded – undo
480 480
 	 *
481 481
 	 * @return bool            If the attachment was successfully.
482 482
 	 */
483
-	public function attach_payment( $payment_id = 0, $update_stats = true ) {
483
+	public function attach_payment($payment_id = 0, $update_stats = true) {
484 484
 
485
-		if ( empty( $payment_id ) ) {
485
+		if (empty($payment_id)) {
486 486
 			return false;
487 487
 		}
488 488
 
489
-		if ( empty( $this->payment_ids ) ) {
489
+		if (empty($this->payment_ids)) {
490 490
 
491 491
 			$new_payment_ids = $payment_id;
492 492
 
493 493
 		} else {
494 494
 
495
-			$payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) );
495
+			$payment_ids = array_map('absint', explode(',', $this->payment_ids));
496 496
 
497
-			if ( in_array( $payment_id, $payment_ids ) ) {
497
+			if (in_array($payment_id, $payment_ids)) {
498 498
 				$update_stats = false;
499 499
 			}
500 500
 
501 501
 			$payment_ids[] = $payment_id;
502 502
 
503
-			$new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) );
503
+			$new_payment_ids = implode(',', array_unique(array_values($payment_ids)));
504 504
 
505 505
 		}
506 506
 
@@ -512,20 +512,20 @@  discard block
 block discarded – undo
512 512
 		 * @param int $payment_id Payment id.
513 513
 		 * @param int $donor_id   Donor id.
514 514
 		 */
515
-		do_action( 'give_donor_pre_attach_payment', $payment_id, $this->id );
515
+		do_action('give_donor_pre_attach_payment', $payment_id, $this->id);
516 516
 
517
-		$payment_added = $this->update( array( 'payment_ids' => $new_payment_ids ) );
517
+		$payment_added = $this->update(array('payment_ids' => $new_payment_ids));
518 518
 
519
-		if ( $payment_added ) {
519
+		if ($payment_added) {
520 520
 
521 521
 			$this->payment_ids = $new_payment_ids;
522 522
 
523 523
 			// We added this payment successfully, increment the stats
524
-			if ( $update_stats ) {
525
-				$payment_amount = give_donation_amount( $payment_id, array( 'type' => 'stats' ) );
524
+			if ($update_stats) {
525
+				$payment_amount = give_donation_amount($payment_id, array('type' => 'stats'));
526 526
 
527
-				if ( ! empty( $payment_amount ) ) {
528
-					$this->increase_value( $payment_amount );
527
+				if ( ! empty($payment_amount)) {
528
+					$this->increase_value($payment_amount);
529 529
 				}
530 530
 
531 531
 				$this->increase_purchase_count();
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
 		 * @param int  $payment_id    Payment id.
542 542
 		 * @param int  $donor_id      Donor id.
543 543
 		 */
544
-		do_action( 'give_donor_post_attach_payment', $payment_added, $payment_id, $this->id );
544
+		do_action('give_donor_post_attach_payment', $payment_added, $payment_id, $this->id);
545 545
 
546 546
 		return $payment_added;
547 547
 	}
@@ -559,33 +559,33 @@  discard block
 block discarded – undo
559 559
 	 *
560 560
 	 * @return boolean               If the removal was successful.
561 561
 	 */
562
-	public function remove_payment( $payment_id = 0, $update_stats = true ) {
562
+	public function remove_payment($payment_id = 0, $update_stats = true) {
563 563
 
564
-		if ( empty( $payment_id ) ) {
564
+		if (empty($payment_id)) {
565 565
 			return false;
566 566
 		}
567 567
 
568
-		$payment = new Give_Payment( $payment_id );
568
+		$payment = new Give_Payment($payment_id);
569 569
 
570
-		if ( 'publish' !== $payment->status && 'revoked' !== $payment->status ) {
570
+		if ('publish' !== $payment->status && 'revoked' !== $payment->status) {
571 571
 			$update_stats = false;
572 572
 		}
573 573
 
574 574
 		$new_payment_ids = '';
575 575
 
576
-		if ( ! empty( $this->payment_ids ) ) {
576
+		if ( ! empty($this->payment_ids)) {
577 577
 
578
-			$payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) );
578
+			$payment_ids = array_map('absint', explode(',', $this->payment_ids));
579 579
 
580
-			$pos = array_search( $payment_id, $payment_ids );
581
-			if ( false === $pos ) {
580
+			$pos = array_search($payment_id, $payment_ids);
581
+			if (false === $pos) {
582 582
 				return false;
583 583
 			}
584 584
 
585
-			unset( $payment_ids[ $pos ] );
586
-			$payment_ids = array_filter( $payment_ids );
585
+			unset($payment_ids[$pos]);
586
+			$payment_ids = array_filter($payment_ids);
587 587
 
588
-			$new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) );
588
+			$new_payment_ids = implode(',', array_unique(array_values($payment_ids)));
589 589
 
590 590
 		}
591 591
 
@@ -597,20 +597,20 @@  discard block
 block discarded – undo
597 597
 		 * @param int $payment_id Payment id.
598 598
 		 * @param int $donor_id   Customer id.
599 599
 		 */
600
-		do_action( 'give_donor_pre_remove_payment', $payment_id, $this->id );
600
+		do_action('give_donor_pre_remove_payment', $payment_id, $this->id);
601 601
 
602
-		$payment_removed = $this->update( array( 'payment_ids' => $new_payment_ids ) );
602
+		$payment_removed = $this->update(array('payment_ids' => $new_payment_ids));
603 603
 
604
-		if ( $payment_removed ) {
604
+		if ($payment_removed) {
605 605
 
606 606
 			$this->payment_ids = $new_payment_ids;
607 607
 
608
-			if ( $update_stats ) {
608
+			if ($update_stats) {
609 609
 				// We removed this payment successfully, decrement the stats
610
-				$payment_amount = give_donation_amount( $payment_id );
610
+				$payment_amount = give_donation_amount($payment_id);
611 611
 
612
-				if ( ! empty( $payment_amount ) ) {
613
-					$this->decrease_value( $payment_amount );
612
+				if ( ! empty($payment_amount)) {
613
+					$this->decrease_value($payment_amount);
614 614
 				}
615 615
 
616 616
 				$this->decrease_donation_count();
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
 		 * @param int  $payment_id      Payment id.
627 627
 		 * @param int  $donor_id        Donor id.
628 628
 		 */
629
-		do_action( 'give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id );
629
+		do_action('give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id);
630 630
 
631 631
 		return $payment_removed;
632 632
 
@@ -642,10 +642,10 @@  discard block
 block discarded – undo
642 642
 	 *
643 643
 	 * @return int        The donation count.
644 644
 	 */
645
-	public function increase_purchase_count( $count = 1 ) {
645
+	public function increase_purchase_count($count = 1) {
646 646
 
647 647
 		// Make sure it's numeric and not negative.
648
-		if ( ! is_numeric( $count ) || $count != absint( $count ) ) {
648
+		if ( ! is_numeric($count) || $count != absint($count)) {
649 649
 			return false;
650 650
 		}
651 651
 
@@ -659,9 +659,9 @@  discard block
 block discarded – undo
659 659
 		 * @param int $count    The number to increase by.
660 660
 		 * @param int $donor_id Donor id.
661 661
 		 */
662
-		do_action( 'give_donor_pre_increase_donation_count', $count, $this->id );
662
+		do_action('give_donor_pre_increase_donation_count', $count, $this->id);
663 663
 
664
-		if ( $this->update( array( 'purchase_count' => $new_total ) ) ) {
664
+		if ($this->update(array('purchase_count' => $new_total))) {
665 665
 			$this->purchase_count = $new_total;
666 666
 		}
667 667
 
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
 		 * @param int $count          The number increased by.
675 675
 		 * @param int $donor_id       Donor id.
676 676
 		 */
677
-		do_action( 'give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id );
677
+		do_action('give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id);
678 678
 
679 679
 		return $this->purchase_count;
680 680
 	}
@@ -689,16 +689,16 @@  discard block
 block discarded – undo
689 689
 	 *
690 690
 	 * @return mixed      If successful, the new count, otherwise false.
691 691
 	 */
692
-	public function decrease_donation_count( $count = 1 ) {
692
+	public function decrease_donation_count($count = 1) {
693 693
 
694 694
 		// Make sure it's numeric and not negative
695
-		if ( ! is_numeric( $count ) || $count != absint( $count ) ) {
695
+		if ( ! is_numeric($count) || $count != absint($count)) {
696 696
 			return false;
697 697
 		}
698 698
 
699 699
 		$new_total = (int) $this->purchase_count - (int) $count;
700 700
 
701
-		if ( $new_total < 0 ) {
701
+		if ($new_total < 0) {
702 702
 			$new_total = 0;
703 703
 		}
704 704
 
@@ -710,9 +710,9 @@  discard block
 block discarded – undo
710 710
 		 * @param int $count    The number to decrease by.
711 711
 		 * @param int $donor_id Customer id.
712 712
 		 */
713
-		do_action( 'give_donor_pre_decrease_donation_count', $count, $this->id );
713
+		do_action('give_donor_pre_decrease_donation_count', $count, $this->id);
714 714
 
715
-		if ( $this->update( array( 'purchase_count' => $new_total ) ) ) {
715
+		if ($this->update(array('purchase_count' => $new_total))) {
716 716
 			$this->purchase_count = $new_total;
717 717
 		}
718 718
 
@@ -725,7 +725,7 @@  discard block
 block discarded – undo
725 725
 		 * @param int $count          The number decreased by.
726 726
 		 * @param int $donor_id       Donor id.
727 727
 		 */
728
-		do_action( 'give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id );
728
+		do_action('give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id);
729 729
 
730 730
 		return $this->purchase_count;
731 731
 	}
@@ -740,9 +740,9 @@  discard block
 block discarded – undo
740 740
 	 *
741 741
 	 * @return mixed        If successful, the new value, otherwise false.
742 742
 	 */
743
-	public function increase_value( $value = 0.00 ) {
743
+	public function increase_value($value = 0.00) {
744 744
 
745
-		$new_value = floatval( $this->purchase_value ) + $value;
745
+		$new_value = floatval($this->purchase_value) + $value;
746 746
 
747 747
 		/**
748 748
 		 * Fires before increasing donor lifetime value.
@@ -752,9 +752,9 @@  discard block
 block discarded – undo
752 752
 		 * @param float $value    The value to increase by.
753 753
 		 * @param int   $donor_id Customer id.
754 754
 		 */
755
-		do_action( 'give_donor_pre_increase_value', $value, $this->id );
755
+		do_action('give_donor_pre_increase_value', $value, $this->id);
756 756
 
757
-		if ( $this->update( array( 'purchase_value' => $new_value ) ) ) {
757
+		if ($this->update(array('purchase_value' => $new_value))) {
758 758
 			$this->purchase_value = $new_value;
759 759
 		}
760 760
 
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
 		 * @param float $value          The value increased by.
768 768
 		 * @param int   $donor_id       Donor id.
769 769
 		 */
770
-		do_action( 'give_donor_post_increase_value', $this->purchase_value, $value, $this->id );
770
+		do_action('give_donor_post_increase_value', $this->purchase_value, $value, $this->id);
771 771
 
772 772
 		return $this->purchase_value;
773 773
 	}
@@ -782,11 +782,11 @@  discard block
 block discarded – undo
782 782
 	 *
783 783
 	 * @return mixed        If successful, the new value, otherwise false.
784 784
 	 */
785
-	public function decrease_value( $value = 0.00 ) {
785
+	public function decrease_value($value = 0.00) {
786 786
 
787
-		$new_value = floatval( $this->purchase_value ) - $value;
787
+		$new_value = floatval($this->purchase_value) - $value;
788 788
 
789
-		if ( $new_value < 0 ) {
789
+		if ($new_value < 0) {
790 790
 			$new_value = 0.00;
791 791
 		}
792 792
 
@@ -798,9 +798,9 @@  discard block
 block discarded – undo
798 798
 		 * @param float $value    The value to decrease by.
799 799
 		 * @param int   $donor_id Donor id.
800 800
 		 */
801
-		do_action( 'give_donor_pre_decrease_value', $value, $this->id );
801
+		do_action('give_donor_pre_decrease_value', $value, $this->id);
802 802
 
803
-		if ( $this->update( array( 'purchase_value' => $new_value ) ) ) {
803
+		if ($this->update(array('purchase_value' => $new_value))) {
804 804
 			$this->purchase_value = $new_value;
805 805
 		}
806 806
 
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
 		 * @param float $value          The value decreased by.
814 814
 		 * @param int   $donor_id       Donor id.
815 815
 		 */
816
-		do_action( 'give_donor_post_decrease_value', $this->purchase_value, $value, $this->id );
816
+		do_action('give_donor_post_decrease_value', $this->purchase_value, $value, $this->id);
817 817
 
818 818
 		return $this->purchase_value;
819 819
 	}
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
 	 *
834 834
 	 * @return mixed              If successful, the new donation stat value, otherwise false.
835 835
 	 */
836
-	public function update_donation_value( $curr_amount, $new_amount ) {
836
+	public function update_donation_value($curr_amount, $new_amount) {
837 837
 		/**
838 838
 		 * Payment total difference value can be:
839 839
 		 *  zero   (in case amount not change)
@@ -843,15 +843,15 @@  discard block
 block discarded – undo
843 843
 		$payment_total_diff = $new_amount - $curr_amount;
844 844
 
845 845
 		// We do not need to update donation stat if donation did not change.
846
-		if ( ! $payment_total_diff ) {
846
+		if ( ! $payment_total_diff) {
847 847
 			return false;
848 848
 		}
849 849
 
850
-		if ( $payment_total_diff > 0 ) {
851
-			$this->increase_value( $payment_total_diff );
850
+		if ($payment_total_diff > 0) {
851
+			$this->increase_value($payment_total_diff);
852 852
 		} else {
853 853
 			// Pass payment total difference as +ve value to decrease amount from user lifetime stat.
854
-			$this->decrease_value( - $payment_total_diff );
854
+			$this->decrease_value( -$payment_total_diff );
855 855
 		}
856 856
 
857 857
 		return $this->purchase_value;
@@ -868,15 +868,15 @@  discard block
 block discarded – undo
868 868
 	 *
869 869
 	 * @return array       The notes requested.
870 870
 	 */
871
-	public function get_notes( $length = 20, $paged = 1 ) {
871
+	public function get_notes($length = 20, $paged = 1) {
872 872
 
873
-		$length = is_numeric( $length ) ? $length : 20;
874
-		$offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0;
873
+		$length = is_numeric($length) ? $length : 20;
874
+		$offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0;
875 875
 
876 876
 		$all_notes   = $this->get_raw_notes();
877
-		$notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) );
877
+		$notes_array = array_reverse(array_filter(explode("\n\n", $all_notes)));
878 878
 
879
-		$desired_notes = array_slice( $notes_array, $offset, $length );
879
+		$desired_notes = array_slice($notes_array, $offset, $length);
880 880
 
881 881
 		return $desired_notes;
882 882
 
@@ -893,9 +893,9 @@  discard block
 block discarded – undo
893 893
 	public function get_notes_count() {
894 894
 
895 895
 		$all_notes   = $this->get_raw_notes();
896
-		$notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) );
896
+		$notes_array = array_reverse(array_filter(explode("\n\n", $all_notes)));
897 897
 
898
-		return count( $notes_array );
898
+		return count($notes_array);
899 899
 
900 900
 	}
901 901
 
@@ -908,7 +908,7 @@  discard block
 block discarded – undo
908 908
 	 *
909 909
 	 * @return string|float
910 910
 	 */
911
-	public function get_total_donation_amount( $args = array() ) {
911
+	public function get_total_donation_amount($args = array()) {
912 912
 
913 913
 		/**
914 914
 		 * Filter total donation amount.
@@ -919,7 +919,7 @@  discard block
 block discarded – undo
919 919
 		 * @param integer      $donor_id       Donor ID.
920 920
 		 * @param array        $args           Pass additional data.
921 921
 		 */
922
-		return apply_filters( 'give_get_total_donation_amount', $this->purchase_value, $this->id, $args );
922
+		return apply_filters('give_get_total_donation_amount', $this->purchase_value, $this->id, $args);
923 923
 	}
924 924
 
925 925
 	/**
@@ -932,22 +932,22 @@  discard block
 block discarded – undo
932 932
 	 *
933 933
 	 * @return string|boolean The new note if added successfully, false otherwise.
934 934
 	 */
935
-	public function add_note( $note = '' ) {
935
+	public function add_note($note = '') {
936 936
 
937
-		$note = trim( $note );
938
-		if ( empty( $note ) ) {
937
+		$note = trim($note);
938
+		if (empty($note)) {
939 939
 			return false;
940 940
 		}
941 941
 
942 942
 		$notes = $this->get_raw_notes();
943 943
 
944
-		if ( empty( $notes ) ) {
944
+		if (empty($notes)) {
945 945
 			$notes = '';
946 946
 		}
947 947
 
948
-		$note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note;
949
-		$new_note    = apply_filters( 'give_customer_add_note_string', $note_string );
950
-		$notes       .= "\n\n" . $new_note;
948
+		$note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')).' - '.$note;
949
+		$new_note    = apply_filters('give_customer_add_note_string', $note_string);
950
+		$notes .= "\n\n".$new_note;
951 951
 
952 952
 		/**
953 953
 		 * Fires before donor note is added.
@@ -957,11 +957,11 @@  discard block
 block discarded – undo
957 957
 		 * @param string $new_note New note to add.
958 958
 		 * @param int    $donor_id Donor id.
959 959
 		 */
960
-		do_action( 'give_donor_pre_add_note', $new_note, $this->id );
960
+		do_action('give_donor_pre_add_note', $new_note, $this->id);
961 961
 
962
-		$updated = $this->update( array( 'notes' => $notes ) );
962
+		$updated = $this->update(array('notes' => $notes));
963 963
 
964
-		if ( $updated ) {
964
+		if ($updated) {
965 965
 			$this->notes = $this->get_notes();
966 966
 		}
967 967
 
@@ -974,7 +974,7 @@  discard block
 block discarded – undo
974 974
 		 * @param string $new_note    New note added.
975 975
 		 * @param int    $donor_id    Donor id.
976 976
 		 */
977
-		do_action( 'give_donor_post_add_note', $this->notes, $new_note, $this->id );
977
+		do_action('give_donor_post_add_note', $this->notes, $new_note, $this->id);
978 978
 
979 979
 		// Return the formatted note, so we can test, as well as update any displays
980 980
 		return $new_note;
@@ -991,7 +991,7 @@  discard block
 block discarded – undo
991 991
 	 */
992 992
 	private function get_raw_notes() {
993 993
 
994
-		$all_notes = $this->db->get_column( 'notes', $this->id );
994
+		$all_notes = $this->db->get_column('notes', $this->id);
995 995
 
996 996
 		return $all_notes;
997 997
 
@@ -1009,8 +1009,8 @@  discard block
 block discarded – undo
1009 1009
 	 * @return mixed            Will be an array if $single is false. Will be value of meta data field if $single is
1010 1010
 	 *                          true.
1011 1011
 	 */
1012
-	public function get_meta( $meta_key = '', $single = true ) {
1013
-		return Give()->donor_meta->get_meta( $this->id, $meta_key, $single );
1012
+	public function get_meta($meta_key = '', $single = true) {
1013
+		return Give()->donor_meta->get_meta($this->id, $meta_key, $single);
1014 1014
 	}
1015 1015
 
1016 1016
 	/**
@@ -1025,8 +1025,8 @@  discard block
 block discarded – undo
1025 1025
 	 *
1026 1026
 	 * @return bool               False for failure. True for success.
1027 1027
 	 */
1028
-	public function add_meta( $meta_key = '', $meta_value, $unique = false ) {
1029
-		return Give()->donor_meta->add_meta( $this->id, $meta_key, $meta_value, $unique );
1028
+	public function add_meta($meta_key = '', $meta_value, $unique = false) {
1029
+		return Give()->donor_meta->add_meta($this->id, $meta_key, $meta_value, $unique);
1030 1030
 	}
1031 1031
 
1032 1032
 	/**
@@ -1041,8 +1041,8 @@  discard block
 block discarded – undo
1041 1041
 	 *
1042 1042
 	 * @return bool               False on failure, true if success.
1043 1043
 	 */
1044
-	public function update_meta( $meta_key = '', $meta_value, $prev_value = '' ) {
1045
-		return Give()->donor_meta->update_meta( $this->id, $meta_key, $meta_value, $prev_value );
1044
+	public function update_meta($meta_key = '', $meta_value, $prev_value = '') {
1045
+		return Give()->donor_meta->update_meta($this->id, $meta_key, $meta_value, $prev_value);
1046 1046
 	}
1047 1047
 
1048 1048
 	/**
@@ -1056,8 +1056,8 @@  discard block
 block discarded – undo
1056 1056
 	 *
1057 1057
 	 * @return bool               False for failure. True for success.
1058 1058
 	 */
1059
-	public function delete_meta( $meta_key = '', $meta_value = '' ) {
1060
-		return Give()->donor_meta->delete_meta( $this->id, $meta_key, $meta_value );
1059
+	public function delete_meta($meta_key = '', $meta_value = '') {
1060
+		return Give()->donor_meta->delete_meta($this->id, $meta_key, $meta_value);
1061 1061
 	}
1062 1062
 
1063 1063
 	/**
@@ -1070,51 +1070,51 @@  discard block
 block discarded – undo
1070 1070
 	 *
1071 1071
 	 * @return array       The sanitized data, based off column defaults.
1072 1072
 	 */
1073
-	private function sanitize_columns( $data ) {
1073
+	private function sanitize_columns($data) {
1074 1074
 
1075 1075
 		$columns        = $this->db->get_columns();
1076 1076
 		$default_values = $this->db->get_column_defaults();
1077 1077
 
1078
-		foreach ( $columns as $key => $type ) {
1078
+		foreach ($columns as $key => $type) {
1079 1079
 
1080 1080
 			// Only sanitize data that we were provided
1081
-			if ( ! array_key_exists( $key, $data ) ) {
1081
+			if ( ! array_key_exists($key, $data)) {
1082 1082
 				continue;
1083 1083
 			}
1084 1084
 
1085
-			switch ( $type ) {
1085
+			switch ($type) {
1086 1086
 
1087 1087
 				case '%s':
1088
-					if ( 'email' == $key ) {
1089
-						$data[ $key ] = sanitize_email( $data[ $key ] );
1090
-					} elseif ( 'notes' == $key ) {
1091
-						$data[ $key ] = strip_tags( $data[ $key ] );
1088
+					if ('email' == $key) {
1089
+						$data[$key] = sanitize_email($data[$key]);
1090
+					} elseif ('notes' == $key) {
1091
+						$data[$key] = strip_tags($data[$key]);
1092 1092
 					} else {
1093
-						$data[ $key ] = sanitize_text_field( $data[ $key ] );
1093
+						$data[$key] = sanitize_text_field($data[$key]);
1094 1094
 					}
1095 1095
 					break;
1096 1096
 
1097 1097
 				case '%d':
1098
-					if ( ! is_numeric( $data[ $key ] ) || (int) $data[ $key ] !== absint( $data[ $key ] ) ) {
1099
-						$data[ $key ] = $default_values[ $key ];
1098
+					if ( ! is_numeric($data[$key]) || (int) $data[$key] !== absint($data[$key])) {
1099
+						$data[$key] = $default_values[$key];
1100 1100
 					} else {
1101
-						$data[ $key ] = absint( $data[ $key ] );
1101
+						$data[$key] = absint($data[$key]);
1102 1102
 					}
1103 1103
 					break;
1104 1104
 
1105 1105
 				case '%f':
1106 1106
 					// Convert what was given to a float
1107
-					$value = floatval( $data[ $key ] );
1107
+					$value = floatval($data[$key]);
1108 1108
 
1109
-					if ( ! is_float( $value ) ) {
1110
-						$data[ $key ] = $default_values[ $key ];
1109
+					if ( ! is_float($value)) {
1110
+						$data[$key] = $default_values[$key];
1111 1111
 					} else {
1112
-						$data[ $key ] = $value;
1112
+						$data[$key] = $value;
1113 1113
 					}
1114 1114
 					break;
1115 1115
 
1116 1116
 				default:
1117
-					$data[ $key ] = sanitize_text_field( $data[ $key ] );
1117
+					$data[$key] = sanitize_text_field($data[$key]);
1118 1118
 					break;
1119 1119
 
1120 1120
 			}
@@ -1134,33 +1134,33 @@  discard block
 block discarded – undo
1134 1134
 	 *
1135 1135
 	 * @return bool            If the email was added successfully
1136 1136
 	 */
1137
-	public function add_email( $email = '', $primary = false ) {
1138
-		if ( ! is_email( $email ) ) {
1137
+	public function add_email($email = '', $primary = false) {
1138
+		if ( ! is_email($email)) {
1139 1139
 			return false;
1140 1140
 		}
1141
-		$existing = new Give_Donor( $email );
1141
+		$existing = new Give_Donor($email);
1142 1142
 
1143
-		if ( $existing->id > 0 ) {
1143
+		if ($existing->id > 0) {
1144 1144
 			// Email address already belongs to another donor
1145 1145
 			return false;
1146 1146
 		}
1147 1147
 
1148
-		if ( email_exists( $email ) ) {
1149
-			$user = get_user_by( 'email', $email );
1150
-			if ( $user->ID != $this->user_id ) {
1148
+		if (email_exists($email)) {
1149
+			$user = get_user_by('email', $email);
1150
+			if ($user->ID != $this->user_id) {
1151 1151
 				return false;
1152 1152
 			}
1153 1153
 		}
1154 1154
 
1155
-		do_action( 'give_donor_pre_add_email', $email, $this->id, $this );
1155
+		do_action('give_donor_pre_add_email', $email, $this->id, $this);
1156 1156
 
1157 1157
 		// Add is used to ensure duplicate emails are not added
1158
-		$ret = (bool) $this->add_meta( 'additional_email', $email );
1158
+		$ret = (bool) $this->add_meta('additional_email', $email);
1159 1159
 
1160
-		do_action( 'give_donor_post_add_email', $email, $this->id, $this );
1160
+		do_action('give_donor_post_add_email', $email, $this->id, $this);
1161 1161
 
1162
-		if ( $ret && true === $primary ) {
1163
-			$this->set_primary_email( $email );
1162
+		if ($ret && true === $primary) {
1163
+			$this->set_primary_email($email);
1164 1164
 		}
1165 1165
 
1166 1166
 		return $ret;
@@ -1176,16 +1176,16 @@  discard block
 block discarded – undo
1176 1176
 	 *
1177 1177
 	 * @return bool          If the email was removed successfully.
1178 1178
 	 */
1179
-	public function remove_email( $email = '' ) {
1180
-		if ( ! is_email( $email ) ) {
1179
+	public function remove_email($email = '') {
1180
+		if ( ! is_email($email)) {
1181 1181
 			return false;
1182 1182
 		}
1183 1183
 
1184
-		do_action( 'give_donor_pre_remove_email', $email, $this->id, $this );
1184
+		do_action('give_donor_pre_remove_email', $email, $this->id, $this);
1185 1185
 
1186
-		$ret = (bool) $this->delete_meta( 'additional_email', $email );
1186
+		$ret = (bool) $this->delete_meta('additional_email', $email);
1187 1187
 
1188
-		do_action( 'give_donor_post_remove_email', $email, $this->id, $this );
1188
+		do_action('give_donor_post_remove_email', $email, $this->id, $this);
1189 1189
 
1190 1190
 		return $ret;
1191 1191
 	}
@@ -1202,16 +1202,16 @@  discard block
 block discarded – undo
1202 1202
 	 *
1203 1203
 	 * @return bool                      If the email was set as primary successfully.
1204 1204
 	 */
1205
-	public function set_primary_email( $new_primary_email = '' ) {
1206
-		if ( ! is_email( $new_primary_email ) ) {
1205
+	public function set_primary_email($new_primary_email = '') {
1206
+		if ( ! is_email($new_primary_email)) {
1207 1207
 			return false;
1208 1208
 		}
1209 1209
 
1210
-		do_action( 'give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this );
1210
+		do_action('give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this);
1211 1211
 
1212
-		$existing = new Give_Donor( $new_primary_email );
1212
+		$existing = new Give_Donor($new_primary_email);
1213 1213
 
1214
-		if ( $existing->id > 0 && (int) $existing->id !== (int) $this->id ) {
1214
+		if ($existing->id > 0 && (int) $existing->id !== (int) $this->id) {
1215 1215
 			// This email belongs to another donor.
1216 1216
 			return false;
1217 1217
 		}
@@ -1219,21 +1219,21 @@  discard block
 block discarded – undo
1219 1219
 		$old_email = $this->email;
1220 1220
 
1221 1221
 		// Update donor record with new email.
1222
-		$update = $this->update( array( 'email' => $new_primary_email ) );
1222
+		$update = $this->update(array('email' => $new_primary_email));
1223 1223
 
1224 1224
 		// Remove new primary from list of additional emails.
1225
-		$remove = $this->remove_email( $new_primary_email );
1225
+		$remove = $this->remove_email($new_primary_email);
1226 1226
 
1227 1227
 		// Add old email to additional emails list.
1228
-		$add = $this->add_email( $old_email );
1228
+		$add = $this->add_email($old_email);
1229 1229
 
1230 1230
 		$ret = $update && $remove && $add;
1231 1231
 
1232
-		if ( $ret ) {
1232
+		if ($ret) {
1233 1233
 			$this->email = $new_primary_email;
1234 1234
 		}
1235 1235
 
1236
-		do_action( 'give_donor_post_set_primary_email', $new_primary_email, $this->id, $this );
1236
+		do_action('give_donor_post_set_primary_email', $new_primary_email, $this->id, $this);
1237 1237
 
1238 1238
 		return $ret;
1239 1239
 	}
@@ -1248,17 +1248,17 @@  discard block
 block discarded – undo
1248 1248
 	 *
1249 1249
 	 * @return bool
1250 1250
 	 */
1251
-	private function is_valid_address( $address ) {
1251
+	private function is_valid_address($address) {
1252 1252
 		$is_valid_address = true;
1253 1253
 
1254 1254
 		// Address ready to process even if only one value set.
1255
-		foreach ( $address as $address_type => $value ) {
1255
+		foreach ($address as $address_type => $value) {
1256 1256
 			// @todo: Handle state field validation on basis of country.
1257
-			if ( in_array( $address_type, array( 'line2', 'state' ) ) ) {
1257
+			if (in_array($address_type, array('line2', 'state'))) {
1258 1258
 				continue;
1259 1259
 			}
1260 1260
 
1261
-			if ( empty( $value ) ) {
1261
+			if (empty($value)) {
1262 1262
 				$is_valid_address = false;
1263 1263
 				break;
1264 1264
 			}
@@ -1285,57 +1285,57 @@  discard block
 block discarded – undo
1285 1285
 	 *
1286 1286
 	 * @return bool
1287 1287
 	 */
1288
-	public function add_address( $address_type, $address ) {
1288
+	public function add_address($address_type, $address) {
1289 1289
 		// Bailout.
1290
-		if ( empty( $address_type ) || ! $this->is_valid_address( $address ) || ! $this->id ) {
1290
+		if (empty($address_type) || ! $this->is_valid_address($address) || ! $this->id) {
1291 1291
 			return false;
1292 1292
 		}
1293 1293
 
1294 1294
 		// Check if multiple address exist or not and set params.
1295 1295
 		$multi_address_id = null;
1296
-		if ( $is_multi_address = ( false !== strpos( $address_type, '[]' ) ) ) {
1297
-			$address_type = $is_multi_address ? str_replace( '[]', '', $address_type ) : $address_type;
1298
-		} elseif ( $is_multi_address = ( false !== strpos( $address_type, '_' ) ) ) {
1299
-			$multi_address_id = $is_multi_address ? array_pop( explode( '_', $address_type ) ) : $address_type;
1296
+		if ($is_multi_address = (false !== strpos($address_type, '[]'))) {
1297
+			$address_type = $is_multi_address ? str_replace('[]', '', $address_type) : $address_type;
1298
+		} elseif ($is_multi_address = (false !== strpos($address_type, '_'))) {
1299
+			$multi_address_id = $is_multi_address ? array_pop(explode('_', $address_type)) : $address_type;
1300 1300
 
1301
-			$address_type = $is_multi_address ? array_shift( explode( '_', $address_type ) ) : $address_type;
1301
+			$address_type = $is_multi_address ? array_shift(explode('_', $address_type)) : $address_type;
1302 1302
 		}
1303 1303
 
1304 1304
 		// Bailout: do not save duplicate orders
1305
-		if ( $this->does_address_exist( $address_type, $address ) ) {
1305
+		if ($this->does_address_exist($address_type, $address)) {
1306 1306
 			return false;
1307 1307
 		}
1308 1308
 
1309 1309
 		// Set default address.
1310
-		$address = wp_parse_args( $address, array(
1310
+		$address = wp_parse_args($address, array(
1311 1311
 			'line1'   => '',
1312 1312
 			'line2'   => '',
1313 1313
 			'city'    => '',
1314 1314
 			'state'   => '',
1315 1315
 			'country' => '',
1316 1316
 			'zip'     => '',
1317
-		) );
1317
+		));
1318 1318
 
1319 1319
 		// Set meta key prefix.
1320 1320
 		global $wpdb;
1321 1321
 		$meta_key_prefix = "_give_donor_address_{$address_type}_{address_name}";
1322 1322
 		$meta_type       = Give()->donor_meta->meta_type;
1323 1323
 
1324
-		if ( $is_multi_address ) {
1325
-			if ( is_null( $multi_address_id ) ) {
1324
+		if ($is_multi_address) {
1325
+			if (is_null($multi_address_id)) {
1326 1326
 				// Get latest address key to set multi address id.
1327
-				$multi_address_id = $wpdb->get_var( $wpdb->prepare( "
1327
+				$multi_address_id = $wpdb->get_var($wpdb->prepare("
1328 1328
 						SELECT meta_key FROM {$wpdb->donormeta}
1329 1329
 						WHERE meta_key
1330 1330
 						LIKE '%%%s%%'
1331 1331
 						AND {$meta_type}_id=%d
1332 1332
 						ORDER BY meta_id DESC
1333 1333
 						LIMIT 1
1334
-						", "_give_donor_address_{$address_type}_line1", $this->id ) );
1334
+						", "_give_donor_address_{$address_type}_line1", $this->id));
1335 1335
 
1336
-				if ( ! empty( $multi_address_id ) ) {
1337
-					$multi_address_id = absint( substr( strrchr( $multi_address_id, '_' ), 1 ) );
1338
-					$multi_address_id ++;
1336
+				if ( ! empty($multi_address_id)) {
1337
+					$multi_address_id = absint(substr(strrchr($multi_address_id, '_'), 1));
1338
+					$multi_address_id++;
1339 1339
 				} else {
1340 1340
 					$multi_address_id = 0;
1341 1341
 				}
@@ -1345,9 +1345,9 @@  discard block
 block discarded – undo
1345 1345
 		}
1346 1346
 
1347 1347
 		// Save donor address.
1348
-		foreach ( $address as $type => $value ) {
1349
-			$meta_key = str_replace( '{address_name}', $type, $meta_key_prefix );
1350
-			Give()->donor_meta->update_meta( $this->id, $meta_key, $value );
1348
+		foreach ($address as $type => $value) {
1349
+			$meta_key = str_replace('{address_name}', $type, $meta_key_prefix);
1350
+			Give()->donor_meta->update_meta($this->id, $meta_key, $value);
1351 1351
 		}
1352 1352
 
1353 1353
 		$this->setup_address();
@@ -1366,31 +1366,31 @@  discard block
 block discarded – undo
1366 1366
 	 *
1367 1367
 	 * @return bool
1368 1368
 	 */
1369
-	public function remove_address( $address_id ) {
1369
+	public function remove_address($address_id) {
1370 1370
 		global $wpdb;
1371 1371
 
1372 1372
 		// Get address type.
1373
-		$is_multi_address = false !== strpos( $address_id, '_' ) ? true : false;
1373
+		$is_multi_address = false !== strpos($address_id, '_') ? true : false;
1374 1374
 
1375
-		$address_type = false !== strpos( $address_id, '_' ) ? array_shift( explode( '_', $address_id ) ) : $address_id;
1375
+		$address_type = false !== strpos($address_id, '_') ? array_shift(explode('_', $address_id)) : $address_id;
1376 1376
 
1377
-		$address_count = false !== strpos( $address_id, '_' ) ? array_pop( explode( '_', $address_id ) ) : null;
1377
+		$address_count = false !== strpos($address_id, '_') ? array_pop(explode('_', $address_id)) : null;
1378 1378
 
1379 1379
 		// Set meta key prefix.
1380 1380
 		$meta_key_prefix = "_give_donor_address_{$address_type}_%";
1381
-		if ( $is_multi_address && is_numeric( $address_count ) ) {
1381
+		if ($is_multi_address && is_numeric($address_count)) {
1382 1382
 			$meta_key_prefix .= "_{$address_count}";
1383 1383
 		}
1384 1384
 
1385 1385
 		$meta_type = Give()->donor_meta->meta_type;
1386 1386
 
1387 1387
 		// Process query.
1388
-		$row_affected = $wpdb->query( $wpdb->prepare( "
1388
+		$row_affected = $wpdb->query($wpdb->prepare("
1389 1389
 				DELETE FROM {$wpdb->donormeta}
1390 1390
 				WHERE meta_key
1391 1391
 				LIKE '%s'
1392 1392
 				AND {$meta_type}_id=%d
1393
-				", $meta_key_prefix, $this->id ) );
1393
+				", $meta_key_prefix, $this->id));
1394 1394
 
1395 1395
 		$this->setup_address();
1396 1396
 
@@ -1409,39 +1409,39 @@  discard block
 block discarded – undo
1409 1409
 	 *
1410 1410
 	 * @return bool
1411 1411
 	 */
1412
-	public function update_address( $address_id, $address ) {
1412
+	public function update_address($address_id, $address) {
1413 1413
 		global $wpdb;
1414 1414
 
1415 1415
 		// Get address type.
1416
-		$is_multi_address = false !== strpos( $address_id, '_' ) ? true : false;
1416
+		$is_multi_address = false !== strpos($address_id, '_') ? true : false;
1417 1417
 
1418
-		$address_type = false !== strpos( $address_id, '_' ) ? array_shift( explode( '_', $address_id ) ) : $address_id;
1418
+		$address_type = false !== strpos($address_id, '_') ? array_shift(explode('_', $address_id)) : $address_id;
1419 1419
 
1420
-		$address_count = false !== strpos( $address_id, '_' ) ? array_pop( explode( '_', $address_id ) ) : null;
1420
+		$address_count = false !== strpos($address_id, '_') ? array_pop(explode('_', $address_id)) : null;
1421 1421
 
1422 1422
 		// Set meta key prefix.
1423 1423
 		$meta_key_prefix = "_give_donor_address_{$address_type}_%";
1424
-		if ( $is_multi_address && is_numeric( $address_count ) ) {
1424
+		if ($is_multi_address && is_numeric($address_count)) {
1425 1425
 			$meta_key_prefix .= "_{$address_count}";
1426 1426
 		}
1427 1427
 
1428 1428
 		$meta_type = Give()->donor_meta->meta_type;
1429 1429
 
1430 1430
 		// Process query.
1431
-		$row_affected = $wpdb->get_results( $wpdb->prepare( "
1431
+		$row_affected = $wpdb->get_results($wpdb->prepare("
1432 1432
 				SELECT meta_key FROM {$wpdb->donormeta}
1433 1433
 				WHERE meta_key
1434 1434
 				LIKE '%s'
1435 1435
 				AND {$meta_type}_id=%d
1436
-				", $meta_key_prefix, $this->id ) );
1436
+				", $meta_key_prefix, $this->id));
1437 1437
 
1438 1438
 		// Return result.
1439
-		if ( ! count( $row_affected ) ) {
1439
+		if ( ! count($row_affected)) {
1440 1440
 			return false;
1441 1441
 		}
1442 1442
 
1443 1443
 		// Update address.
1444
-		if ( ! $this->add_address( $address_id, $address ) ) {
1444
+		if ( ! $this->add_address($address_id, $address)) {
1445 1445
 			return false;
1446 1446
 		}
1447 1447
 
@@ -1460,39 +1460,39 @@  discard block
 block discarded – undo
1460 1460
 	 *
1461 1461
 	 * @return bool|null
1462 1462
 	 */
1463
-	public function does_address_exist( $current_address_type, $current_address ) {
1463
+	public function does_address_exist($current_address_type, $current_address) {
1464 1464
 		$status = false;
1465 1465
 
1466 1466
 		// Bailout.
1467
-		if ( empty( $current_address_type ) || empty( $current_address ) ) {
1467
+		if (empty($current_address_type) || empty($current_address)) {
1468 1468
 			return null;
1469 1469
 		}
1470 1470
 
1471 1471
 		// Bailout.
1472
-		if ( empty( $this->address ) || empty( $this->address[ $current_address_type ] ) ) {
1472
+		if (empty($this->address) || empty($this->address[$current_address_type])) {
1473 1473
 			return $status;
1474 1474
 		}
1475 1475
 
1476 1476
 		// Get address.
1477
-		$address = $this->address[ $current_address_type ];
1477
+		$address = $this->address[$current_address_type];
1478 1478
 
1479
-		switch ( true ) {
1479
+		switch (true) {
1480 1480
 
1481 1481
 			// Single address.
1482
-			case is_string( end( $address ) ) :
1483
-				$status = $this->is_address_match( $current_address, $address );
1482
+			case is_string(end($address)) :
1483
+				$status = $this->is_address_match($current_address, $address);
1484 1484
 				break;
1485 1485
 
1486 1486
 			// Multi address.
1487
-			case is_array( end( $address ) ):
1487
+			case is_array(end($address)):
1488 1488
 				// Compare address.
1489
-				foreach ( $address as $saved_address ) {
1490
-					if ( empty( $saved_address ) ) {
1489
+				foreach ($address as $saved_address) {
1490
+					if (empty($saved_address)) {
1491 1491
 						continue;
1492 1492
 					}
1493 1493
 
1494 1494
 					// Exit loop immediately if address exist.
1495
-					if ( $status = $this->is_address_match( $current_address, $saved_address ) ) {
1495
+					if ($status = $this->is_address_match($current_address, $saved_address)) {
1496 1496
 						break;
1497 1497
 					}
1498 1498
 				}
@@ -1513,10 +1513,10 @@  discard block
 block discarded – undo
1513 1513
 	 *
1514 1514
 	 * @return bool
1515 1515
 	 */
1516
-	private function is_address_match( $address_1, $address_2 ) {
1517
-		$result = array_diff( $address_1, $address_2 );
1516
+	private function is_address_match($address_1, $address_2) {
1517
+		$result = array_diff($address_1, $address_2);
1518 1518
 
1519
-		return empty( $result );
1519
+		return empty($result);
1520 1520
 	}
1521 1521
 
1522 1522
 	/**
@@ -1527,23 +1527,23 @@  discard block
 block discarded – undo
1527 1527
 	 * @since   2.0
1528 1528
 	 * @return  object
1529 1529
 	 */
1530
-	public function split_donor_name( $id ) {
1530
+	public function split_donor_name($id) {
1531 1531
 		$first_name = $last_name = '';
1532
-		$donor      = new Give_Donor( $id );
1532
+		$donor      = new Give_Donor($id);
1533 1533
 
1534
-		$split_donor_name = explode( ' ', $donor->name, 2 );
1534
+		$split_donor_name = explode(' ', $donor->name, 2);
1535 1535
 
1536 1536
 		// Check for existence of first name after split of donor name.
1537
-		if ( is_array( $split_donor_name ) && ! empty( $split_donor_name[0] ) ) {
1537
+		if (is_array($split_donor_name) && ! empty($split_donor_name[0])) {
1538 1538
 			$first_name = $split_donor_name[0];
1539 1539
 		}
1540 1540
 
1541 1541
 		// Check for existence of last name after split of donor name.
1542
-		if ( is_array( $split_donor_name ) && ! empty( $split_donor_name[1] ) ) {
1542
+		if (is_array($split_donor_name) && ! empty($split_donor_name[1])) {
1543 1543
 			$last_name = $split_donor_name[1];
1544 1544
 		}
1545 1545
 
1546
-		return (object) array( 'first_name' => $first_name, 'last_name' => $last_name );
1546
+		return (object) array('first_name' => $first_name, 'last_name' => $last_name);
1547 1547
 	}
1548 1548
 
1549 1549
 	/**
@@ -1553,9 +1553,9 @@  discard block
 block discarded – undo
1553 1553
 	 * @return  string
1554 1554
 	 */
1555 1555
 	public function get_first_name() {
1556
-		$first_name = $this->get_meta( '_give_donor_first_name' );
1557
-		if ( ! $first_name ) {
1558
-			$first_name = $this->split_donor_name( $this->id )->first_name;
1556
+		$first_name = $this->get_meta('_give_donor_first_name');
1557
+		if ( ! $first_name) {
1558
+			$first_name = $this->split_donor_name($this->id)->first_name;
1559 1559
 		}
1560 1560
 
1561 1561
 		return $first_name;
@@ -1568,15 +1568,15 @@  discard block
 block discarded – undo
1568 1568
 	 * @return  string
1569 1569
 	 */
1570 1570
 	public function get_last_name() {
1571
-		$first_name = $this->get_meta( '_give_donor_first_name' );
1572
-		$last_name  = $this->get_meta( '_give_donor_last_name' );
1571
+		$first_name = $this->get_meta('_give_donor_first_name');
1572
+		$last_name  = $this->get_meta('_give_donor_last_name');
1573 1573
 
1574 1574
 		// This condition will prevent unnecessary splitting of donor name to fetch last name.
1575
-		if ( ! $first_name && ! $last_name ) {
1576
-			$last_name = $this->split_donor_name( $this->id )->last_name;
1575
+		if ( ! $first_name && ! $last_name) {
1576
+			$last_name = $this->split_donor_name($this->id)->last_name;
1577 1577
 		}
1578 1578
 
1579
-		return ( $last_name ) ? $last_name : '';
1579
+		return ($last_name) ? $last_name : '';
1580 1580
 	}
1581 1581
 
1582 1582
 	/**
@@ -1587,7 +1587,7 @@  discard block
 block discarded – undo
1587 1587
 	 * @return  string $company_name Donor Company Name
1588 1588
 	 */
1589 1589
 	public function get_company_name() {
1590
-		$company_name = $this->get_meta( '_give_donor_company' );
1590
+		$company_name = $this->get_meta('_give_donor_company');
1591 1591
 
1592 1592
 		return $company_name;
1593 1593
 	}
@@ -1601,9 +1601,9 @@  discard block
 block discarded – undo
1601 1601
 	 */
1602 1602
 	public function get_last_donation() {
1603 1603
 
1604
-		$payments = array_unique( array_values( explode( ',', $this->payment_ids ) ) );
1604
+		$payments = array_unique(array_values(explode(',', $this->payment_ids)));
1605 1605
 
1606
-		return end( $payments );
1606
+		return end($payments);
1607 1607
 
1608 1608
 	}
1609 1609
 
@@ -1616,18 +1616,18 @@  discard block
 block discarded – undo
1616 1616
 	 *
1617 1617
 	 * @return string The date of the last donation.
1618 1618
 	 */
1619
-	public function get_last_donation_date( $formatted = false ) {
1619
+	public function get_last_donation_date($formatted = false) {
1620 1620
 		$completed_data = '';
1621 1621
 
1622 1622
 		// Return if donation id is invalid.
1623
-		if( ! ( $last_donation = absint( $this->get_last_donation() ) ) ) {
1623
+		if ( ! ($last_donation = absint($this->get_last_donation()))) {
1624 1624
 			return $completed_data;
1625 1625
 		}
1626 1626
 
1627
-		$completed_data = give_get_payment_completed_date( $last_donation );
1627
+		$completed_data = give_get_payment_completed_date($last_donation);
1628 1628
 
1629
-		if ( $formatted ) {
1630
-			return date_i18n( give_date_format(), strtotime( $completed_data ) );
1629
+		if ($formatted) {
1630
+			return date_i18n(give_date_format(), strtotime($completed_data));
1631 1631
 		}
1632 1632
 
1633 1633
 		return $completed_data;
@@ -1643,10 +1643,10 @@  discard block
 block discarded – undo
1643 1643
 	 */
1644 1644
 	public function get_donor_initals() {
1645 1645
 
1646
-		$first_name_initial = mb_substr( $this->get_first_name(), 0, 1, 'utf-8' );
1647
-		$last_name_initial  = mb_substr( $this->get_last_name(), 0, 1, 'utf-8' );
1646
+		$first_name_initial = mb_substr($this->get_first_name(), 0, 1, 'utf-8');
1647
+		$last_name_initial  = mb_substr($this->get_last_name(), 0, 1, 'utf-8');
1648 1648
 
1649
-		return apply_filters( 'get_donor_initals', $first_name_initial . $last_name_initial );
1649
+		return apply_filters('get_donor_initals', $first_name_initial.$last_name_initial);
1650 1650
 
1651 1651
 	}
1652 1652
 
Please login to merge, or discard this patch.
includes/donors/frontend-donor-functions.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@
 block discarded – undo
46 46
  *
47 47
  * @since 2.2.0
48 48
  *
49
- * @param string|int $id_or_email
49
+ * @param string $id_or_email
50 50
  *
51 51
  * @return bool
52 52
  */
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -21,15 +21,15 @@  discard block
 block discarded – undo
21 21
  *
22 22
  * @return string HTML output.
23 23
  */
24
-function give_get_donor_avatar( $donor, $size = 60 ) {
24
+function give_get_donor_avatar($donor, $size = 60) {
25 25
 	ob_start();
26 26
 	?>
27 27
 	<div class="give-donor__image">
28 28
 		<?php
29 29
 		// Check if gravatar exists.
30
-		if ( give_validate_gravatar( $donor->email ) ) {
30
+		if (give_validate_gravatar($donor->email)) {
31 31
 			// Return avatar.
32
-			echo get_avatar( $donor->email, $size );
32
+			echo get_avatar($donor->email, $size);
33 33
 		} else {
34 34
 			// No gravatar = output initials.
35 35
 			echo $donor->get_donor_initals();
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	</div>
38 38
 	<?php
39 39
 
40
-	return apply_filters( 'give_get_donor_avatar', ob_get_clean() );
40
+	return apply_filters('give_get_donor_avatar', ob_get_clean());
41 41
 
42 42
 }
43 43
 
@@ -50,51 +50,51 @@  discard block
 block discarded – undo
50 50
  *
51 51
  * @return bool
52 52
  */
53
-function give_validate_gravatar( $id_or_email ) {
53
+function give_validate_gravatar($id_or_email) {
54 54
 
55 55
 	//id or email code borrowed from wp-includes/pluggable.php
56 56
 	$email = '';
57
-	if ( is_numeric( $id_or_email ) ) {
57
+	if (is_numeric($id_or_email)) {
58 58
 		$id   = (int) $id_or_email;
59
-		$user = get_userdata( $id );
60
-		if ( $user ) {
59
+		$user = get_userdata($id);
60
+		if ($user) {
61 61
 			$email = $user->user_email;
62 62
 		}
63
-	} elseif ( is_object( $id_or_email ) ) {
63
+	} elseif (is_object($id_or_email)) {
64 64
 		// No avatar for pingbacks or trackbacks
65
-		$allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) );
66
-		if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) ) {
65
+		$allowed_comment_types = apply_filters('get_avatar_comment_types', array('comment'));
66
+		if ( ! empty($id_or_email->comment_type) && ! in_array($id_or_email->comment_type, (array) $allowed_comment_types)) {
67 67
 			return false;
68 68
 		}
69 69
 
70
-		if ( ! empty( $id_or_email->user_id ) ) {
70
+		if ( ! empty($id_or_email->user_id)) {
71 71
 			$id   = (int) $id_or_email->user_id;
72
-			$user = get_userdata( $id );
73
-			if ( $user ) {
72
+			$user = get_userdata($id);
73
+			if ($user) {
74 74
 				$email = $user->user_email;
75 75
 			}
76
-		} elseif ( ! empty( $id_or_email->comment_author_email ) ) {
76
+		} elseif ( ! empty($id_or_email->comment_author_email)) {
77 77
 			$email = $id_or_email->comment_author_email;
78 78
 		}
79 79
 	} else {
80 80
 		$email = $id_or_email;
81 81
 	}
82 82
 
83
-	$hashkey = md5( strtolower( trim( $email ) ) );
84
-	$uri     = 'http://www.gravatar.com/avatar/' . $hashkey . '?d=404';
83
+	$hashkey = md5(strtolower(trim($email)));
84
+	$uri     = 'http://www.gravatar.com/avatar/'.$hashkey.'?d=404';
85 85
 
86
-	$data = wp_cache_get( $hashkey );
87
-	if ( false === $data ) {
88
-		$response = wp_remote_head( $uri );
89
-		if ( is_wp_error( $response ) ) {
86
+	$data = wp_cache_get($hashkey);
87
+	if (false === $data) {
88
+		$response = wp_remote_head($uri);
89
+		if (is_wp_error($response)) {
90 90
 			$data = 'not200';
91 91
 		} else {
92 92
 			$data = $response['response']['code'];
93 93
 		}
94
-		wp_cache_set( $hashkey, $data, $group = '', $expire = 60 * 5 );
94
+		wp_cache_set($hashkey, $data, $group = '', $expire = 60 * 5);
95 95
 
96 96
 	}
97
-	if ( $data == '200' ) {
97
+	if ($data == '200') {
98 98
 		return true;
99 99
 	} else {
100 100
 		return false;
@@ -114,18 +114,18 @@  discard block
 block discarded – undo
114 114
  *
115 115
  * @return int The new note ID
116 116
  */
117
-function give_insert_donor_donation_comment( $donation_id, $donor, $note, $comment_args = array() ) {
117
+function give_insert_donor_donation_comment($donation_id, $donor, $note, $comment_args = array()) {
118 118
 	$comment_args = wp_parse_args(
119 119
 		$comment_args,
120 120
 		array(
121 121
 			'comment_approved' => 0,
122
-			'comment_parent'   => give_get_payment_form_id( $donation_id )
122
+			'comment_parent'   => give_get_payment_form_id($donation_id)
123 123
 		)
124 124
 	);
125 125
 
126
-	$comment_id = Give_Comment::add( $donation_id, $note, 'payment', $comment_args );
126
+	$comment_id = Give_Comment::add($donation_id, $note, 'payment', $comment_args);
127 127
 
128
-	update_comment_meta( $comment_id, '_give_donor_id', $donor );
128
+	update_comment_meta($comment_id, '_give_donor_id', $donor);
129 129
 
130 130
 	return $comment_id;
131 131
 }
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
  *
145 145
  * @return WP_Comment|array
146 146
  */
147
-function give_get_donor_donation_comment( $donation_id, $donor_id, $search = '' ) {
147
+function give_get_donor_donation_comment($donation_id, $donor_id, $search = '') {
148 148
 	$comments = Give_Comment::get(
149 149
 		$donation_id,
150 150
 		'payment',
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 		$search
161 161
 	);
162 162
 
163
-	return ( ! empty( $comments ) ? current( $comments ) : array() );
163
+	return ( ! empty($comments) ? current($comments) : array());
164 164
 }
165 165
 
166 166
 /**
@@ -176,9 +176,9 @@  discard block
 block discarded – undo
176 176
  *
177 177
  * @return int
178 178
  */
179
-function give_get_donor_donation_comment_id( $donation_id, $donor_id, $search = '' ) {
179
+function give_get_donor_donation_comment_id($donation_id, $donor_id, $search = '') {
180 180
 	/* @var WP_Comment|array $comment */
181
-	$comment    = give_get_donor_donation_comment( $donation_id, $donor_id, $search );
181
+	$comment    = give_get_donor_donation_comment($donation_id, $donor_id, $search);
182 182
 	$comment_id = $comment instanceof WP_Comment ? $comment->comment_ID : 0;
183 183
 
184 184
 	return $comment_id;
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
  *
198 198
  * @return array
199 199
  */
200
-function give_get_donor_donation_comments( $donor_id, $comment_args = array(), $search = '' ) {
200
+function give_get_donor_donation_comments($donor_id, $comment_args = array(), $search = '') {
201 201
 	$comments = Give_Comment::get(
202 202
 		$donor_id,
203 203
 		'payment',
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 		$search
206 206
 	);
207 207
 
208
-	return ( ! empty( $comments ) ? $comments : array() );
208
+	return ( ! empty($comments) ? $comments : array());
209 209
 }
210 210
 
211 211
 
@@ -219,19 +219,19 @@  discard block
 block discarded – undo
219 219
  *
220 220
  * @return string
221 221
  */
222
-function give_get_donor_donation_comment_html( $comment, $payment_id = 0 ) {
222
+function give_get_donor_donation_comment_html($comment, $payment_id = 0) {
223 223
 
224
-	if ( is_numeric( $comment ) ) {
225
-		$comment = get_comment( $comment );
224
+	if (is_numeric($comment)) {
225
+		$comment = get_comment($comment);
226 226
 	}
227 227
 
228
-	$date_format = give_date_format() . ', ' . get_option( 'time_format' );
228
+	$date_format = give_date_format().', '.get_option('time_format');
229 229
 
230 230
 	$comment_html = sprintf(
231 231
 		'<div class="give-payment-note" id="give-payment-note-%s"><p><strong>%s</strong>&nbsp;&ndash;&nbsp;<span style="color:#aaa;font-style:italic;">%s</span><br/>%s</p></div>',
232 232
 		$comment->comment_ID,
233
-		get_comment_author( $comment->comment_ID ),
234
-		date_i18n( $date_format, strtotime( $comment->comment_date ) ),
233
+		get_comment_author($comment->comment_ID),
234
+		date_i18n($date_format, strtotime($comment->comment_date)),
235 235
 		$comment->comment_content
236 236
 	);
237 237
 
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
  *
251 251
  * @return WP_Comment/array
252 252
  */
253
-function give_get_donor_latest_comment( $donor_id, $form_id = 0 ) {
253
+function give_get_donor_latest_comment($donor_id, $form_id = 0) {
254 254
 	$comment_args = array(
255 255
 		'post_id'    => 0,
256 256
 		'orderby'    => 'comment_ID',
@@ -270,11 +270,11 @@  discard block
 block discarded – undo
270 270
 	);
271 271
 
272 272
 	// Get donor donation comment for specific form.
273
-	if ( $form_id ) {
273
+	if ($form_id) {
274 274
 		$comment_args['parent'] = $form_id;
275 275
 	}
276 276
 
277
-	$comment = current( give_get_donor_donation_comments( $donor_id, $comment_args ) );
277
+	$comment = current(give_get_donor_donation_comments($donor_id, $comment_args));
278 278
 
279 279
 	return $comment;
280 280
 }
Please login to merge, or discard this patch.