Completed
Pull Request — master (#1300)
by Ravinder
16:35
created
includes/gateways/paypal-standard.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -661,7 +661,7 @@
 block discarded – undo
661 661
  *
662 662
  * @since 1.6.3
663 663
  *
664
- * @param $pending_reason
664
+ * @param string $pending_reason
665 665
  *
666 666
  * @return string
667 667
  */
Please login to merge, or discard this patch.
Spacing   +168 added lines, -168 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  * @since       1.0
10 10
  */
11 11
 
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit;
14 14
 }
15 15
 
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
  * @access private
22 22
  * @since  1.0
23 23
  */
24
-add_action( 'give_paypal_cc_form', '__return_false' );
24
+add_action('give_paypal_cc_form', '__return_false');
25 25
 
26 26
 /**
27 27
  * Process PayPal Payment.
@@ -32,14 +32,14 @@  discard block
 block discarded – undo
32 32
  *
33 33
  * @return void
34 34
  */
35
-function give_process_paypal_payment( $payment_data ) {
35
+function give_process_paypal_payment($payment_data) {
36 36
 
37
-	if ( ! wp_verify_nonce( $payment_data['gateway_nonce'], 'give-gateway' ) ) {
38
-		wp_die( esc_html__( 'Nonce verification has failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
37
+	if ( ! wp_verify_nonce($payment_data['gateway_nonce'], 'give-gateway')) {
38
+		wp_die(esc_html__('Nonce verification has failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
39 39
 	}
40 40
 
41
-	$form_id  = intval( $payment_data['post_data']['give-form-id'] );
42
-	$price_id = isset( $payment_data['post_data']['give-price-id'] ) ? $payment_data['post_data']['give-price-id'] : '';
41
+	$form_id  = intval($payment_data['post_data']['give-form-id']);
42
+	$price_id = isset($payment_data['post_data']['give-price-id']) ? $payment_data['post_data']['give-price-id'] : '';
43 43
 
44 44
 	// Collect payment data.
45 45
 	$payment_data = array(
@@ -57,101 +57,101 @@  discard block
 block discarded – undo
57 57
 	);
58 58
 
59 59
 	// Record the pending payment.
60
-	$payment_id = give_insert_payment( $payment_data );
60
+	$payment_id = give_insert_payment($payment_data);
61 61
 
62 62
 	// Check payment.
63
-	if ( ! $payment_id ) {
63
+	if ( ! $payment_id) {
64 64
 		// Record the error.
65 65
 		give_record_gateway_error(
66
-			esc_html__( 'Payment Error', 'give' ),
66
+			esc_html__('Payment Error', 'give'),
67 67
 			sprintf(
68 68
 			/* translators: %s: payment data */
69
-				esc_html__( 'Payment creation failed before sending donor to PayPal. Payment data: %s', 'give' ),
70
-				json_encode( $payment_data )
69
+				esc_html__('Payment creation failed before sending donor to PayPal. Payment data: %s', 'give'),
70
+				json_encode($payment_data)
71 71
 			),
72 72
 			$payment_id
73 73
 		);
74 74
 		// Problems? Send back.
75
-		give_send_back_to_checkout( '?payment-mode=' . $payment_data['post_data']['give-gateway'] );
75
+		give_send_back_to_checkout('?payment-mode='.$payment_data['post_data']['give-gateway']);
76 76
 
77 77
 	} else {
78 78
 
79 79
 		// Only send to PayPal if the pending payment is created successfully.
80
-		$listener_url = add_query_arg( 'give-listener', 'IPN', home_url( 'index.php' ) );
80
+		$listener_url = add_query_arg('give-listener', 'IPN', home_url('index.php'));
81 81
 
82 82
 		// Get the success url.
83
-		$return_url = add_query_arg( array(
83
+		$return_url = add_query_arg(array(
84 84
 			'payment-confirmation' => 'paypal',
85 85
 			'payment-id'           => $payment_id
86 86
 
87
-		), get_permalink( give_get_option( 'success_page' ) ) );
87
+		), get_permalink(give_get_option('success_page')));
88 88
 
89 89
 		// Get the PayPal redirect uri.
90
-		$paypal_redirect = trailingslashit( give_get_paypal_redirect() ) . '?';
90
+		$paypal_redirect = trailingslashit(give_get_paypal_redirect()).'?';
91 91
 
92 92
 		//Item name - pass level name if variable priced.
93 93
 		$item_name = $payment_data['post_data']['give-form-title'];
94 94
 
95 95
 		//Verify has variable prices.
96
-		if ( give_has_variable_prices( $form_id ) && isset( $payment_data['post_data']['give-price-id'] ) ) {
96
+		if (give_has_variable_prices($form_id) && isset($payment_data['post_data']['give-price-id'])) {
97 97
 
98
-			$item_price_level_text = give_get_price_option_name( $form_id, $payment_data['post_data']['give-price-id'] );
98
+			$item_price_level_text = give_get_price_option_name($form_id, $payment_data['post_data']['give-price-id']);
99 99
 
100
-			$price_level_amount = give_get_price_option_amount( $form_id, $payment_data['post_data']['give-price-id'] );
100
+			$price_level_amount = give_get_price_option_amount($form_id, $payment_data['post_data']['give-price-id']);
101 101
 
102 102
 			//Donation given doesn't match selected level (must be a custom amount).
103
-			if ( $price_level_amount != give_sanitize_amount( $payment_data['price'] ) ) {
104
-				$custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true );
103
+			if ($price_level_amount != give_sanitize_amount($payment_data['price'])) {
104
+				$custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true);
105 105
 				//user custom amount text if any, fallback to default if not.
106
-				$item_name .= ' - ' . ( ! empty( $custom_amount_text ) ? $custom_amount_text : esc_html__( 'Custom Amount', 'give' ) );
106
+				$item_name .= ' - '.( ! empty($custom_amount_text) ? $custom_amount_text : esc_html__('Custom Amount', 'give'));
107 107
 
108 108
 			} //Is there any donation level text?
109
-			elseif ( ! empty( $item_price_level_text ) ) {
110
-				$item_name .= ' - ' . $item_price_level_text;
109
+			elseif ( ! empty($item_price_level_text)) {
110
+				$item_name .= ' - '.$item_price_level_text;
111 111
 			}
112 112
 
113 113
 		} //Single donation: Custom Amount.
114
-		elseif ( give_get_form_price( $form_id ) !== give_sanitize_amount( $payment_data['price'] ) ) {
115
-			$custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true );
114
+		elseif (give_get_form_price($form_id) !== give_sanitize_amount($payment_data['price'])) {
115
+			$custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true);
116 116
 			//user custom amount text if any, fallback to default if not.
117
-			$item_name .= ' - ' . ( ! empty( $custom_amount_text ) ? $custom_amount_text : esc_html__( 'Custom Amount', 'give' ) );
117
+			$item_name .= ' - '.( ! empty($custom_amount_text) ? $custom_amount_text : esc_html__('Custom Amount', 'give'));
118 118
 		}
119 119
 
120 120
 		// Setup PayPal API params.
121 121
 		$paypal_args = array(
122
-			'business'      => give_get_option( 'paypal_email', false ),
122
+			'business'      => give_get_option('paypal_email', false),
123 123
 			'first_name'    => $payment_data['user_info']['first_name'],
124 124
 			'last_name'     => $payment_data['user_info']['last_name'],
125 125
 			'email'         => $payment_data['user_email'],
126 126
 			'invoice'       => $payment_data['purchase_key'],
127 127
 			'amount'        => $payment_data['price'],
128
-			'item_name'     => stripslashes( $item_name ),
128
+			'item_name'     => stripslashes($item_name),
129 129
 			'no_shipping'   => '1',
130 130
 			'shipping'      => '0',
131 131
 			'no_note'       => '1',
132 132
 			'currency_code' => give_get_currency(),
133
-			'charset'       => get_bloginfo( 'charset' ),
133
+			'charset'       => get_bloginfo('charset'),
134 134
 			'custom'        => $payment_id,
135 135
 			'rm'            => '2',
136 136
 			'return'        => $return_url,
137
-			'cancel_return' => give_get_failed_transaction_uri( '?payment-id=' . $payment_id ),
137
+			'cancel_return' => give_get_failed_transaction_uri('?payment-id='.$payment_id),
138 138
 			'notify_url'    => $listener_url,
139 139
 			'page_style'    => give_get_paypal_page_style(),
140
-			'cbt'           => get_bloginfo( 'name' ),
140
+			'cbt'           => get_bloginfo('name'),
141 141
 			'bn'            => 'givewp_SP'
142 142
 		);
143 143
 
144 144
 		//Add user address if present.
145
-		if ( ! empty( $payment_data['user_info']['address'] ) ) {
146
-			$paypal_args['address1'] = isset( $payment_data['user_info']['address']['line1'] ) ? $payment_data['user_info']['address']['line1'] : '';
147
-			$paypal_args['address2'] = isset( $payment_data['user_info']['address']['line2'] ) ? $payment_data['user_info']['address']['line2'] : '';
148
-			$paypal_args['city']     = isset( $payment_data['user_info']['address']['city'] ) ? $payment_data['user_info']['address']['city'] : '';
149
-			$paypal_args['state']    = isset( $payment_data['user_info']['address']['state'] ) ? $payment_data['user_info']['address']['state'] : '';
150
-			$paypal_args['country']  = isset( $payment_data['user_info']['address']['country'] ) ? $payment_data['user_info']['address']['country'] : '';
145
+		if ( ! empty($payment_data['user_info']['address'])) {
146
+			$paypal_args['address1'] = isset($payment_data['user_info']['address']['line1']) ? $payment_data['user_info']['address']['line1'] : '';
147
+			$paypal_args['address2'] = isset($payment_data['user_info']['address']['line2']) ? $payment_data['user_info']['address']['line2'] : '';
148
+			$paypal_args['city']     = isset($payment_data['user_info']['address']['city']) ? $payment_data['user_info']['address']['city'] : '';
149
+			$paypal_args['state']    = isset($payment_data['user_info']['address']['state']) ? $payment_data['user_info']['address']['state'] : '';
150
+			$paypal_args['country']  = isset($payment_data['user_info']['address']['country']) ? $payment_data['user_info']['address']['country'] : '';
151 151
 		}
152 152
 
153 153
 		//Donations or regular transactions?
154
-		if ( give_get_option( 'paypal_button_type' ) === 'standard' ) {
154
+		if (give_get_option('paypal_button_type') === 'standard') {
155 155
 			$paypal_extra_args = array(
156 156
 				'cmd' => '_xclick',
157 157
 			);
@@ -161,23 +161,23 @@  discard block
 block discarded – undo
161 161
 			);
162 162
 		}
163 163
 
164
-		$paypal_args = array_merge( $paypal_extra_args, $paypal_args );
165
-		$paypal_args = apply_filters( 'give_paypal_redirect_args', $paypal_args, $payment_data );
164
+		$paypal_args = array_merge($paypal_extra_args, $paypal_args);
165
+		$paypal_args = apply_filters('give_paypal_redirect_args', $paypal_args, $payment_data);
166 166
 
167 167
 		// Build query.
168
-		$paypal_redirect .= http_build_query( $paypal_args );
168
+		$paypal_redirect .= http_build_query($paypal_args);
169 169
 
170 170
 		// Fix for some sites that encode the entities.
171
-		$paypal_redirect = str_replace( '&', '&', $paypal_redirect );
171
+		$paypal_redirect = str_replace('&', '&', $paypal_redirect);
172 172
 
173 173
 		// Redirect to PayPal.
174
-		wp_redirect( $paypal_redirect );
174
+		wp_redirect($paypal_redirect);
175 175
 		exit;
176 176
 	}
177 177
 
178 178
 }
179 179
 
180
-add_action( 'give_gateway_paypal', 'give_process_paypal_payment' );
180
+add_action('give_gateway_paypal', 'give_process_paypal_payment');
181 181
 
182 182
 /**
183 183
  * Listens for a PayPal IPN requests and then sends to the processing function
@@ -187,17 +187,17 @@  discard block
 block discarded – undo
187 187
  */
188 188
 function give_listen_for_paypal_ipn() {
189 189
 	// Regular PayPal IPN
190
-	if ( isset( $_GET['give-listener'] ) && $_GET['give-listener'] == 'IPN' ) {
190
+	if (isset($_GET['give-listener']) && $_GET['give-listener'] == 'IPN') {
191 191
 		/**
192 192
 		 * Fires while verifying PayPal IPN
193 193
 		 *
194 194
 		 * @since 1.0
195 195
 		 */
196
-		do_action( 'give_verify_paypal_ipn' );
196
+		do_action('give_verify_paypal_ipn');
197 197
 	}
198 198
 }
199 199
 
200
-add_action( 'init', 'give_listen_for_paypal_ipn' );
200
+add_action('init', 'give_listen_for_paypal_ipn');
201 201
 
202 202
 /**
203 203
  * Process PayPal IPN
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 function give_process_paypal_ipn() {
209 209
 
210 210
 	// Check the request method is POST
211
-	if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) {
211
+	if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') {
212 212
 		return;
213 213
 	}
214 214
 
@@ -216,11 +216,11 @@  discard block
 block discarded – undo
216 216
 	$post_data = '';
217 217
 
218 218
 	// Fallback just in case post_max_size is lower than needed
219
-	if ( ini_get( 'allow_url_fopen' ) ) {
220
-		$post_data = file_get_contents( 'php://input' );
219
+	if (ini_get('allow_url_fopen')) {
220
+		$post_data = file_get_contents('php://input');
221 221
 	} else {
222 222
 		// If allow_url_fopen is not enabled, then make sure that post_max_size is large enough
223
-		ini_set( 'post_max_size', '12M' );
223
+		ini_set('post_max_size', '12M');
224 224
 	}
225 225
 	// Start the encoded data collection with notification command
226 226
 	$encoded_data = 'cmd=_notify-validate';
@@ -229,40 +229,40 @@  discard block
 block discarded – undo
229 229
 	$arg_separator = give_get_php_arg_separator_output();
230 230
 
231 231
 	// Verify there is a post_data
232
-	if ( $post_data || strlen( $post_data ) > 0 ) {
232
+	if ($post_data || strlen($post_data) > 0) {
233 233
 		// Append the data
234
-		$encoded_data .= $arg_separator . $post_data;
234
+		$encoded_data .= $arg_separator.$post_data;
235 235
 	} else {
236 236
 		// Check if POST is empty
237
-		if ( empty( $_POST ) ) {
237
+		if (empty($_POST)) {
238 238
 			// Nothing to do
239 239
 			return;
240 240
 		} else {
241 241
 			// Loop through each POST
242
-			foreach ( $_POST as $key => $value ) {
242
+			foreach ($_POST as $key => $value) {
243 243
 				// Encode the value and append the data.
244
-				$encoded_data .= $arg_separator . "$key=" . urlencode( $value );
244
+				$encoded_data .= $arg_separator."$key=".urlencode($value);
245 245
 			}
246 246
 		}
247 247
 	}
248 248
 
249 249
 	// Convert collected post data to an array.
250
-	parse_str( $encoded_data, $encoded_data_array );
250
+	parse_str($encoded_data, $encoded_data_array);
251 251
 
252
-	foreach ( $encoded_data_array as $key => $value ) {
252
+	foreach ($encoded_data_array as $key => $value) {
253 253
 
254
-		if ( false !== strpos( $key, 'amp;' ) ) {
255
-			$new_key = str_replace( '&', '&', $key );
256
-			$new_key = str_replace( 'amp;', '&', $new_key );
254
+		if (false !== strpos($key, 'amp;')) {
255
+			$new_key = str_replace('&', '&', $key);
256
+			$new_key = str_replace('amp;', '&', $new_key);
257 257
 
258
-			unset( $encoded_data_array[ $key ] );
259
-			$encoded_data_array[ $new_key ] = $value;
258
+			unset($encoded_data_array[$key]);
259
+			$encoded_data_array[$new_key] = $value;
260 260
 		}
261 261
 
262 262
 	}
263 263
 
264 264
 	//Validate IPN request w/ PayPal if user hasn't disabled this security measure
265
-	if ( give_is_setting_enabled( give_get_option( 'paypal_verification' ) ) ) {
265
+	if (give_is_setting_enabled(give_get_option('paypal_verification'))) {
266 266
 
267 267
 		$remote_post_vars = array(
268 268
 			'method'      => 'POST',
@@ -282,28 +282,28 @@  discard block
 block discarded – undo
282 282
 		);
283 283
 
284 284
 		// Validate the IPN.
285
-		$api_response = wp_remote_post( give_get_paypal_redirect(), $remote_post_vars );
285
+		$api_response = wp_remote_post(give_get_paypal_redirect(), $remote_post_vars);
286 286
 
287
-		if ( is_wp_error( $api_response ) ) {
287
+		if (is_wp_error($api_response)) {
288 288
 			give_record_gateway_error(
289
-				esc_html__( 'IPN Error', 'give' ),
289
+				esc_html__('IPN Error', 'give'),
290 290
 				sprintf(
291 291
 				/* translators: %s: Paypal IPN response */
292
-					esc_html__( 'Invalid IPN verification response. IPN data: %s', 'give' ),
293
-					json_encode( $api_response )
292
+					esc_html__('Invalid IPN verification response. IPN data: %s', 'give'),
293
+					json_encode($api_response)
294 294
 				)
295 295
 			);
296 296
 
297 297
 			return; // Something went wrong
298 298
 		}
299 299
 
300
-		if ( $api_response['body'] !== 'VERIFIED' ) {
300
+		if ($api_response['body'] !== 'VERIFIED') {
301 301
 			give_record_gateway_error(
302
-				esc_html__( 'IPN Error', 'give' ),
302
+				esc_html__('IPN Error', 'give'),
303 303
 				sprintf(
304 304
 				/* translators: %s: Paypal IPN response */
305
-					esc_html__( 'Invalid IPN verification response. IPN data: %s', 'give' ),
306
-					json_encode( $api_response )
305
+					esc_html__('Invalid IPN verification response. IPN data: %s', 'give'),
306
+					json_encode($api_response)
307 307
 				)
308 308
 			);
309 309
 
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 	}
314 314
 
315 315
 	// Check if $post_data_array has been populated
316
-	if ( ! is_array( $encoded_data_array ) && ! empty( $encoded_data_array ) ) {
316
+	if ( ! is_array($encoded_data_array) && ! empty($encoded_data_array)) {
317 317
 		return;
318 318
 	}
319 319
 
@@ -322,12 +322,12 @@  discard block
 block discarded – undo
322 322
 		'payment_status' => ''
323 323
 	);
324 324
 
325
-	$encoded_data_array = wp_parse_args( $encoded_data_array, $defaults );
325
+	$encoded_data_array = wp_parse_args($encoded_data_array, $defaults);
326 326
 
327
-	$payment_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0;
327
+	$payment_id = isset($encoded_data_array['custom']) ? absint($encoded_data_array['custom']) : 0;
328 328
 	$txn_type   = $encoded_data_array['txn_type'];
329 329
 
330
-	if ( has_action( 'give_paypal_' . $txn_type ) ) {
330
+	if (has_action('give_paypal_'.$txn_type)) {
331 331
 		/**
332 332
 		 * Fires while processing PayPal IPN $txn_type.
333 333
 		 *
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
 		 * @param array $encoded_data_array Encoded data.
339 339
 		 * @param int   $payment_id         Payment id.
340 340
 		 */
341
-		do_action( "give_paypal_{$txn_type}", $encoded_data_array, $payment_id );
341
+		do_action("give_paypal_{$txn_type}", $encoded_data_array, $payment_id);
342 342
 	} else {
343 343
 		/**
344 344
 		 * Fires while process PayPal IPN.
@@ -350,12 +350,12 @@  discard block
 block discarded – undo
350 350
 		 * @param array $encoded_data_array Encoded data.
351 351
 		 * @param int   $payment_id         Payment id.
352 352
 		 */
353
-		do_action( 'give_paypal_web_accept', $encoded_data_array, $payment_id );
353
+		do_action('give_paypal_web_accept', $encoded_data_array, $payment_id);
354 354
 	}
355 355
 	exit;
356 356
 }
357 357
 
358
-add_action( 'give_verify_paypal_ipn', 'give_process_paypal_ipn' );
358
+add_action('give_verify_paypal_ipn', 'give_process_paypal_ipn');
359 359
 
360 360
 /**
361 361
  * Process web accept (one time) payment IPNs.
@@ -367,128 +367,128 @@  discard block
 block discarded – undo
367 367
  *
368 368
  * @return void
369 369
  */
370
-function give_process_paypal_web_accept_and_cart( $data, $payment_id ) {
370
+function give_process_paypal_web_accept_and_cart($data, $payment_id) {
371 371
 
372 372
 	//Only allow through these transaction types.
373
-	if ( $data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && strtolower( $data['payment_status'] ) != 'refunded' ) {
373
+	if ($data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && strtolower($data['payment_status']) != 'refunded') {
374 374
 		return;
375 375
 	}
376 376
 
377 377
 	//Need $payment_id to continue.
378
-	if ( empty( $payment_id ) ) {
378
+	if (empty($payment_id)) {
379 379
 		return;
380 380
 	}
381 381
 
382 382
 	// Collect donation payment details.
383 383
 	$paypal_amount  = $data['mc_gross'];
384
-	$payment_status = strtolower( $data['payment_status'] );
385
-	$currency_code  = strtolower( $data['mc_currency'] );
386
-	$business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] );
387
-	$payment_meta   = give_get_payment_meta( $payment_id );
384
+	$payment_status = strtolower($data['payment_status']);
385
+	$currency_code  = strtolower($data['mc_currency']);
386
+	$business_email = isset($data['business']) && is_email($data['business']) ? trim($data['business']) : trim($data['receiver_email']);
387
+	$payment_meta   = give_get_payment_meta($payment_id);
388 388
 
389 389
 	// Must be a PayPal standard IPN.
390
-	if ( give_get_payment_gateway( $payment_id ) != 'paypal' ) {
390
+	if (give_get_payment_gateway($payment_id) != 'paypal') {
391 391
 		return;
392 392
 	}
393 393
 
394 394
 	// Verify payment recipient
395
-	if ( strcasecmp( $business_email, trim( give_get_option( 'paypal_email' ) ) ) != 0 ) {
395
+	if (strcasecmp($business_email, trim(give_get_option('paypal_email'))) != 0) {
396 396
 
397 397
 		give_record_gateway_error(
398
-			esc_html__( 'IPN Error', 'give' ),
398
+			esc_html__('IPN Error', 'give'),
399 399
 			sprintf(
400 400
 			/* translators: %s: Paypal IPN response */
401
-				esc_html__( 'Invalid business email in IPN response. IPN data: %s', 'give' ),
402
-				json_encode( $data )
401
+				esc_html__('Invalid business email in IPN response. IPN data: %s', 'give'),
402
+				json_encode($data)
403 403
 			),
404 404
 			$payment_id
405 405
 		);
406
-		give_update_payment_status( $payment_id, 'failed' );
407
-		give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid PayPal business email.', 'give' ) );
406
+		give_update_payment_status($payment_id, 'failed');
407
+		give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid PayPal business email.', 'give'));
408 408
 
409 409
 		return;
410 410
 	}
411 411
 
412 412
 	// Verify payment currency.
413
-	if ( $currency_code != strtolower( $payment_meta['currency'] ) ) {
413
+	if ($currency_code != strtolower($payment_meta['currency'])) {
414 414
 
415 415
 		give_record_gateway_error(
416
-			esc_html__( 'IPN Error', 'give' ),
416
+			esc_html__('IPN Error', 'give'),
417 417
 			sprintf(
418 418
 			/* translators: %s: Paypal IPN response */
419
-				esc_html__( 'Invalid currency in IPN response. IPN data: %s', 'give' ),
420
-				json_encode( $data )
419
+				esc_html__('Invalid currency in IPN response. IPN data: %s', 'give'),
420
+				json_encode($data)
421 421
 			),
422 422
 			$payment_id
423 423
 		);
424
-		give_update_payment_status( $payment_id, 'failed' );
425
-		give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid currency in PayPal IPN.', 'give' ) );
424
+		give_update_payment_status($payment_id, 'failed');
425
+		give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid currency in PayPal IPN.', 'give'));
426 426
 
427 427
 		return;
428 428
 	}
429 429
 
430 430
 	//Process refunds & reversed.
431
-	if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) {
432
-		give_process_paypal_refund( $data, $payment_id );
431
+	if ($payment_status == 'refunded' || $payment_status == 'reversed') {
432
+		give_process_paypal_refund($data, $payment_id);
433 433
 
434 434
 		return;
435 435
 	}
436 436
 
437 437
 	// Only complete payments once.
438
-	if ( get_post_status( $payment_id ) == 'publish' ) {
438
+	if (get_post_status($payment_id) == 'publish') {
439 439
 		return;
440 440
 	}
441 441
 
442 442
 	// Retrieve the total donation amount (before PayPal).
443
-	$payment_amount = give_get_payment_amount( $payment_id );
443
+	$payment_amount = give_get_payment_amount($payment_id);
444 444
 
445 445
 	//Check that the donation PP and local db amounts match.
446
-	if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) {
446
+	if (number_format((float) $paypal_amount, 2) < number_format((float) $payment_amount, 2)) {
447 447
 		// The prices don't match
448 448
 		give_record_gateway_error(
449
-			esc_html__( 'IPN Error', 'give' ),
449
+			esc_html__('IPN Error', 'give'),
450 450
 			sprintf(
451 451
 			/* translators: %s: Paypal IPN response */
452
-				esc_html__( 'Invalid payment amount in IPN response. IPN data: %s', 'give' ),
453
-				json_encode( $data )
452
+				esc_html__('Invalid payment amount in IPN response. IPN data: %s', 'give'),
453
+				json_encode($data)
454 454
 			),
455 455
 			$payment_id
456 456
 		);
457
-		give_update_payment_status( $payment_id, 'failed' );
458
-		give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid amount in PayPal IPN.', 'give' ) );
457
+		give_update_payment_status($payment_id, 'failed');
458
+		give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid amount in PayPal IPN.', 'give'));
459 459
 
460 460
 		return;
461 461
 	}
462 462
 
463 463
 	//Process completed donations.
464
-	if ( $payment_status == 'completed' || give_is_test_mode() ) {
464
+	if ($payment_status == 'completed' || give_is_test_mode()) {
465 465
 
466 466
 		give_insert_payment_note(
467 467
 			$payment_id,
468 468
 			sprintf(
469 469
 			/* translators: %s: Paypal transaction ID */
470
-				esc_html__( 'PayPal Transaction ID: %s', 'give' ),
470
+				esc_html__('PayPal Transaction ID: %s', 'give'),
471 471
 				$data['txn_id']
472 472
 			)
473 473
 		);
474
-		give_set_payment_transaction_id( $payment_id, $data['txn_id'] );
475
-		give_update_payment_status( $payment_id, 'publish' );
474
+		give_set_payment_transaction_id($payment_id, $data['txn_id']);
475
+		give_update_payment_status($payment_id, 'publish');
476 476
 
477
-	} elseif ( 'pending' == $payment_status && isset( $data['pending_reason'] ) ) {
477
+	} elseif ('pending' == $payment_status && isset($data['pending_reason'])) {
478 478
 
479 479
 		// Look for possible pending reasons, such as an echeck.
480
-		$note = give_paypal_get_pending_donation_note( strtolower( $data['pending_reason'] ) );
480
+		$note = give_paypal_get_pending_donation_note(strtolower($data['pending_reason']));
481 481
 
482
-		if ( ! empty( $note ) ) {
482
+		if ( ! empty($note)) {
483 483
 
484
-			give_insert_payment_note( $payment_id, $note );
484
+			give_insert_payment_note($payment_id, $note);
485 485
 
486 486
 		}
487 487
 	}
488 488
 
489 489
 }
490 490
 
491
-add_action( 'give_paypal_web_accept', 'give_process_paypal_web_accept_and_cart', 10, 2 );
491
+add_action('give_paypal_web_accept', 'give_process_paypal_web_accept_and_cart', 10, 2);
492 492
 
493 493
 /**
494 494
  * Process PayPal IPN Refunds
@@ -500,28 +500,28 @@  discard block
 block discarded – undo
500 500
  *
501 501
  * @return void
502 502
  */
503
-function give_process_paypal_refund( $data, $payment_id = 0 ) {
503
+function give_process_paypal_refund($data, $payment_id = 0) {
504 504
 
505 505
 	// Collect payment details
506 506
 
507
-	if ( empty( $payment_id ) ) {
507
+	if (empty($payment_id)) {
508 508
 		return;
509 509
 	}
510 510
 
511
-	if ( get_post_status( $payment_id ) == 'refunded' ) {
511
+	if (get_post_status($payment_id) == 'refunded') {
512 512
 		return; // Only refund payments once
513 513
 	}
514 514
 
515
-	$payment_amount = give_get_payment_amount( $payment_id );
515
+	$payment_amount = give_get_payment_amount($payment_id);
516 516
 	$refund_amount  = $data['payment_gross'] * - 1;
517 517
 
518
-	if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) {
518
+	if (number_format((float) $refund_amount, 2) < number_format((float) $payment_amount, 2)) {
519 519
 
520 520
 		give_insert_payment_note(
521 521
 			$payment_id,
522 522
 			sprintf(
523 523
 			/* translators: %s: Paypal parent transaction ID */
524
-				esc_html__( 'Partial PayPal refund processed: %s', 'give' ),
524
+				esc_html__('Partial PayPal refund processed: %s', 'give'),
525 525
 				$data['parent_txn_id']
526 526
 			)
527 527
 		);
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
 		$payment_id,
535 535
 		sprintf(
536 536
 		/* translators: 1: Paypal parent transaction ID 2. Paypal reason code */
537
-			esc_html__( 'PayPal Payment #%1$s Refunded for reason: %2$s', 'give' ),
537
+			esc_html__('PayPal Payment #%1$s Refunded for reason: %2$s', 'give'),
538 538
 			$data['parent_txn_id'],
539 539
 			$data['reason_code']
540 540
 		)
@@ -543,11 +543,11 @@  discard block
 block discarded – undo
543 543
 		$payment_id,
544 544
 		sprintf(
545 545
 		/* translators: %s: Paypal transaction ID */
546
-			esc_html__( 'PayPal Refund Transaction ID: %s', 'give' ),
546
+			esc_html__('PayPal Refund Transaction ID: %s', 'give'),
547 547
 			$data['txn_id']
548 548
 		)
549 549
 	);
550
-	give_update_payment_status( $payment_id, 'refunded' );
550
+	give_update_payment_status($payment_id, 'refunded');
551 551
 }
552 552
 
553 553
 /**
@@ -559,24 +559,24 @@  discard block
 block discarded – undo
559 559
  *
560 560
  * @return string
561 561
  */
562
-function give_get_paypal_redirect( $ssl_check = false ) {
562
+function give_get_paypal_redirect($ssl_check = false) {
563 563
 
564
-	if ( is_ssl() || ! $ssl_check ) {
564
+	if (is_ssl() || ! $ssl_check) {
565 565
 		$protocal = 'https://';
566 566
 	} else {
567 567
 		$protocal = 'http://';
568 568
 	}
569 569
 
570 570
 	// Check the current payment mode
571
-	if ( give_is_test_mode() ) {
571
+	if (give_is_test_mode()) {
572 572
 		// Test mode
573
-		$paypal_uri = $protocal . 'www.sandbox.paypal.com/cgi-bin/webscr';
573
+		$paypal_uri = $protocal.'www.sandbox.paypal.com/cgi-bin/webscr';
574 574
 	} else {
575 575
 		// Live mode
576
-		$paypal_uri = $protocal . 'www.paypal.com/cgi-bin/webscr';
576
+		$paypal_uri = $protocal.'www.paypal.com/cgi-bin/webscr';
577 577
 	}
578 578
 
579
-	return apply_filters( 'give_paypal_uri', $paypal_uri );
579
+	return apply_filters('give_paypal_uri', $paypal_uri);
580 580
 }
581 581
 
582 582
 /**
@@ -586,9 +586,9 @@  discard block
 block discarded – undo
586 586
  * @return string
587 587
  */
588 588
 function give_get_paypal_page_style() {
589
-	$page_style = trim( give_get_option( 'paypal_page_style', 'PayPal' ) );
589
+	$page_style = trim(give_get_option('paypal_page_style', 'PayPal'));
590 590
 
591
-	return apply_filters( 'give_paypal_page_style', $page_style );
591
+	return apply_filters('give_paypal_page_style', $page_style);
592 592
 }
593 593
 
594 594
 /**
@@ -603,26 +603,26 @@  discard block
 block discarded – undo
603 603
  * @return string
604 604
  *
605 605
  */
606
-function give_paypal_success_page_content( $content ) {
606
+function give_paypal_success_page_content($content) {
607 607
 
608
-	if ( ! isset( $_GET['payment-id'] ) && ! give_get_purchase_session() ) {
608
+	if ( ! isset($_GET['payment-id']) && ! give_get_purchase_session()) {
609 609
 		return $content;
610 610
 	}
611 611
 
612
-	$payment_id = isset( $_GET['payment-id'] ) ? absint( $_GET['payment-id'] ) : false;
612
+	$payment_id = isset($_GET['payment-id']) ? absint($_GET['payment-id']) : false;
613 613
 
614
-	if ( ! $payment_id ) {
614
+	if ( ! $payment_id) {
615 615
 		$session    = give_get_purchase_session();
616
-		$payment_id = give_get_purchase_id_by_key( $session['purchase_key'] );
616
+		$payment_id = give_get_purchase_id_by_key($session['purchase_key']);
617 617
 	}
618 618
 
619
-	$payment = get_post( $payment_id );
620
-	if ( $payment && 'pending' == $payment->post_status ) {
619
+	$payment = get_post($payment_id);
620
+	if ($payment && 'pending' == $payment->post_status) {
621 621
 
622 622
 		// Payment is still pending so show processing indicator to fix the race condition.
623 623
 		ob_start();
624 624
 
625
-		give_get_template_part( 'payment', 'processing' );
625
+		give_get_template_part('payment', 'processing');
626 626
 
627 627
 		$content = ob_get_clean();
628 628
 
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
 
633 633
 }
634 634
 
635
-add_filter( 'give_payment_confirm_paypal', 'give_paypal_success_page_content' );
635
+add_filter('give_payment_confirm_paypal', 'give_paypal_success_page_content');
636 636
 
637 637
 /**
638 638
  * Given a Payment ID, extract the transaction ID
@@ -643,22 +643,22 @@  discard block
 block discarded – undo
643 643
  *
644 644
  * @return string                   Transaction ID
645 645
  */
646
-function give_paypal_get_payment_transaction_id( $payment_id ) {
646
+function give_paypal_get_payment_transaction_id($payment_id) {
647 647
 
648 648
 	$transaction_id = '';
649
-	$notes          = give_get_payment_notes( $payment_id );
649
+	$notes          = give_get_payment_notes($payment_id);
650 650
 
651
-	foreach ( $notes as $note ) {
652
-		if ( preg_match( '/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match ) ) {
651
+	foreach ($notes as $note) {
652
+		if (preg_match('/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match)) {
653 653
 			$transaction_id = $match[1];
654 654
 			continue;
655 655
 		}
656 656
 	}
657 657
 
658
-	return apply_filters( 'give_paypal_set_payment_transaction_id', $transaction_id, $payment_id );
658
+	return apply_filters('give_paypal_set_payment_transaction_id', $transaction_id, $payment_id);
659 659
 }
660 660
 
661
-add_filter( 'give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1 );
661
+add_filter('give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1);
662 662
 
663 663
 /**
664 664
  * Given a transaction ID, generate a link to the PayPal transaction ID details
@@ -670,16 +670,16 @@  discard block
 block discarded – undo
670 670
  *
671 671
  * @return string                 A link to the PayPal transaction details
672 672
  */
673
-function give_paypal_link_transaction_id( $transaction_id, $payment_id ) {
673
+function give_paypal_link_transaction_id($transaction_id, $payment_id) {
674 674
 
675 675
 	$paypal_base_url = 'https://history.paypal.com/cgi-bin/webscr?cmd=_history-details-from-hub&id=';
676
-	$transaction_url = '<a href="' . esc_url( $paypal_base_url . $transaction_id ) . '" target="_blank">' . $transaction_id . '</a>';
676
+	$transaction_url = '<a href="'.esc_url($paypal_base_url.$transaction_id).'" target="_blank">'.$transaction_id.'</a>';
677 677
 
678
-	return apply_filters( 'give_paypal_link_payment_details_transaction_id', $transaction_url );
678
+	return apply_filters('give_paypal_link_payment_details_transaction_id', $transaction_url);
679 679
 
680 680
 }
681 681
 
682
-add_filter( 'give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2 );
682
+add_filter('give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2);
683 683
 
684 684
 
685 685
 /**
@@ -691,64 +691,64 @@  discard block
 block discarded – undo
691 691
  *
692 692
  * @return string
693 693
  */
694
-function give_paypal_get_pending_donation_note( $pending_reason ) {
694
+function give_paypal_get_pending_donation_note($pending_reason) {
695 695
 
696 696
 	$note = '';
697 697
 
698
-	switch ( $pending_reason ) {
698
+	switch ($pending_reason) {
699 699
 
700 700
 		case 'echeck' :
701 701
 
702
-			$note = esc_html__( 'Payment made via eCheck and will clear automatically in 5-8 days.', 'give' );
702
+			$note = esc_html__('Payment made via eCheck and will clear automatically in 5-8 days.', 'give');
703 703
 
704 704
 			break;
705 705
 
706 706
 		case 'address' :
707 707
 
708
-			$note = esc_html__( 'Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give' );
708
+			$note = esc_html__('Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give');
709 709
 
710 710
 			break;
711 711
 
712 712
 		case 'intl' :
713 713
 
714
-			$note = esc_html__( 'Payment must be accepted manually through PayPal due to international account regulations.', 'give' );
714
+			$note = esc_html__('Payment must be accepted manually through PayPal due to international account regulations.', 'give');
715 715
 
716 716
 			break;
717 717
 
718 718
 		case 'multi-currency' :
719 719
 
720
-			$note = esc_html__( 'Payment received in non-shop currency and must be accepted manually through PayPal.', 'give' );
720
+			$note = esc_html__('Payment received in non-shop currency and must be accepted manually through PayPal.', 'give');
721 721
 
722 722
 			break;
723 723
 
724 724
 		case 'paymentreview' :
725 725
 		case 'regulatory_review' :
726 726
 
727
-			$note = esc_html__( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give' );
727
+			$note = esc_html__('Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give');
728 728
 
729 729
 			break;
730 730
 
731 731
 		case 'unilateral' :
732 732
 
733
-			$note = esc_html__( 'Payment was sent to non-confirmed or non-registered email address.', 'give' );
733
+			$note = esc_html__('Payment was sent to non-confirmed or non-registered email address.', 'give');
734 734
 
735 735
 			break;
736 736
 
737 737
 		case 'upgrade' :
738 738
 
739
-			$note = esc_html__( 'PayPal account must be upgraded before this payment can be accepted.', 'give' );
739
+			$note = esc_html__('PayPal account must be upgraded before this payment can be accepted.', 'give');
740 740
 
741 741
 			break;
742 742
 
743 743
 		case 'verify' :
744 744
 
745
-			$note = esc_html__( 'PayPal account is not verified. Verify account in order to accept this donation.', 'give' );
745
+			$note = esc_html__('PayPal account is not verified. Verify account in order to accept this donation.', 'give');
746 746
 
747 747
 			break;
748 748
 
749 749
 		case 'other' :
750 750
 
751
-			$note = esc_html__( 'Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give' );
751
+			$note = esc_html__('Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give');
752 752
 
753 753
 			break;
754 754
 
Please login to merge, or discard this patch.
includes/class-give-cli-commands.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -731,7 +731,7 @@
 block discarded – undo
731 731
 	 * @param    bool   $colon   Check if add colon between heading and message.
732 732
 	 * @param    string $color   Heading color.
733 733
 	 *
734
-	 * @return    mixed
734
+	 * @return    string
735 735
 	 */
736 736
 	private function color_message( $heading, $message = '', $colon = true, $color = 'g' ) {
737 737
 		// Add colon.
Please login to merge, or discard this patch.
Spacing   +196 added lines, -196 removed lines patch added patch discarded remove patch
@@ -7,12 +7,12 @@  discard block
 block discarded – undo
7 7
  */
8 8
 
9 9
 // Exit if accessed directly.
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if ( ! defined('ABSPATH')) {
11 11
 	exit;
12 12
 }
13 13
 
14 14
 // Add give command.
15
-WP_CLI::add_command( 'give', 'GIVE_CLI_COMMAND' );
15
+WP_CLI::add_command('give', 'GIVE_CLI_COMMAND');
16 16
 
17 17
 
18 18
 /**
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
 	 *
69 69
 	 * @subcommand    logo
70 70
 	 */
71
-	public function ascii( $args, $assoc_args ) {
72
-		WP_CLI::log( file_get_contents( GIVE_PLUGIN_DIR . 'assets/images/give-ascii-logo.txt' ) );
71
+	public function ascii($args, $assoc_args) {
72
+		WP_CLI::log(file_get_contents(GIVE_PLUGIN_DIR.'assets/images/give-ascii-logo.txt'));
73 73
 	}
74 74
 
75 75
 
@@ -94,54 +94,54 @@  discard block
 block discarded – undo
94 94
 	 *
95 95
 	 * @subcommand    details
96 96
 	 */
97
-	public function details( $args, $assoc_args ) {
97
+	public function details($args, $assoc_args) {
98 98
 
99 99
 		/**
100 100
 		 * Plugin Information
101 101
 		 */
102
-		WP_CLI::log( $this->color_message( __( 'Give Version: ', 'give' ) ) . GIVE_VERSION );
102
+		WP_CLI::log($this->color_message(__('Give Version: ', 'give')).GIVE_VERSION);
103 103
 
104 104
 		/**
105 105
 		 * General Information.
106 106
 		 */
107
-		WP_CLI::log( "\n####   " . $this->color_message( __( 'General information', 'give' ) ) . '   ####' );
107
+		WP_CLI::log("\n####   ".$this->color_message(__('General information', 'give')).'   ####');
108 108
 
109
-		$success_page = give_get_option( 'success_page' );
110
-		$failure_page = give_get_option( 'failure_page' );
111
-		$history_page = give_get_option( 'history_page' );
109
+		$success_page = give_get_option('success_page');
110
+		$failure_page = give_get_option('failure_page');
111
+		$history_page = give_get_option('history_page');
112 112
 
113
-		WP_CLI::log( $this->color_message( sprintf( __( 'Success Page: ', 'give' ) ) ) . ( $success_page ? "[{$success_page}] " . get_permalink( $success_page ) : __( 'Not Set', 'give' ) ) );
114
-		WP_CLI::log( $this->color_message( __( 'Failed Donation Page: ', 'give' ) ) . ( $failure_page ? "[{$failure_page}] " . get_permalink( $failure_page ) : __( 'Not Set', 'give' ) ) );
115
-		WP_CLI::log( $this->color_message( __( 'Donation History Page: ', 'give' ) ) . ( $history_page ? "[{$history_page}] " . get_permalink( $history_page ) : __( 'Not Set', 'give' ) ) );
116
-		WP_CLI::log( $this->color_message( __( 'Country: ', 'give' ) ) . give_get_country() );
113
+		WP_CLI::log($this->color_message(sprintf(__('Success Page: ', 'give'))).($success_page ? "[{$success_page}] ".get_permalink($success_page) : __('Not Set', 'give')));
114
+		WP_CLI::log($this->color_message(__('Failed Donation Page: ', 'give')).($failure_page ? "[{$failure_page}] ".get_permalink($failure_page) : __('Not Set', 'give')));
115
+		WP_CLI::log($this->color_message(__('Donation History Page: ', 'give')).($history_page ? "[{$history_page}] ".get_permalink($history_page) : __('Not Set', 'give')));
116
+		WP_CLI::log($this->color_message(__('Country: ', 'give')).give_get_country());
117 117
 
118 118
 		/**
119 119
 		 * Currency Information.
120 120
 		 */
121
-		$default_gateway = give_get_option( 'default_gateway' );
121
+		$default_gateway = give_get_option('default_gateway');
122 122
 
123
-		WP_CLI::log( "\n####   " . $this->color_message( __( 'Currency Information', 'give' ) ) . '   ####' );
123
+		WP_CLI::log("\n####   ".$this->color_message(__('Currency Information', 'give')).'   ####');
124 124
 
125
-		WP_CLI::log( $this->color_message( __( 'Currency: ', 'give' ), give_get_currency() ) );
126
-		WP_CLI::log( $this->color_message( __( 'Currency Position: ', 'give' ), give_get_currency_position() ) );
127
-		WP_CLI::log( $this->color_message( __( 'Thousand Separator: ', 'give' ), give_get_price_thousand_separator() ) );
128
-		WP_CLI::log( $this->color_message( __( 'Decimal Separator: ', 'give' ), give_get_price_decimal_separator() ) );
129
-		WP_CLI::log( $this->color_message( __( 'Number of Decimals: ', 'give' ), give_get_price_decimals() ) );
130
-		WP_CLI::log( $this->color_message( __( 'Test Mode: ', 'give' ), ( give_get_option( 'test_mode' ) ? __( 'Yes', 'give' ) : __( 'No', 'give' ) ) ) );
131
-		WP_CLI::log( $this->color_message( __( 'Default Gateway: ', 'give' ), ( $default_gateway ? $default_gateway : __( 'Not Set', 'give' ) ) ) );
125
+		WP_CLI::log($this->color_message(__('Currency: ', 'give'), give_get_currency()));
126
+		WP_CLI::log($this->color_message(__('Currency Position: ', 'give'), give_get_currency_position()));
127
+		WP_CLI::log($this->color_message(__('Thousand Separator: ', 'give'), give_get_price_thousand_separator()));
128
+		WP_CLI::log($this->color_message(__('Decimal Separator: ', 'give'), give_get_price_decimal_separator()));
129
+		WP_CLI::log($this->color_message(__('Number of Decimals: ', 'give'), give_get_price_decimals()));
130
+		WP_CLI::log($this->color_message(__('Test Mode: ', 'give'), (give_get_option('test_mode') ? __('Yes', 'give') : __('No', 'give'))));
131
+		WP_CLI::log($this->color_message(__('Default Gateway: ', 'give'), ($default_gateway ? $default_gateway : __('Not Set', 'give'))));
132 132
 
133 133
 		// Payment gateways Information.
134
-		$gateways = give_get_ordered_payment_gateways( give_get_payment_gateways() );
135
-		WP_CLI::log( $this->color_message( __( 'Enabled Gateways: ', 'give' ) ) );
134
+		$gateways = give_get_ordered_payment_gateways(give_get_payment_gateways());
135
+		WP_CLI::log($this->color_message(__('Enabled Gateways: ', 'give')));
136 136
 
137
-		if ( ! empty( $gateways ) ) {
137
+		if ( ! empty($gateways)) {
138 138
 			self::$counter = 1;
139
-			foreach ( $gateways as $gateway ) {
140
-				WP_CLI::log( '  ' . $this->color_message( self::$counter, $gateway['admin_label'] ) );
141
-				self::$counter ++;
139
+			foreach ($gateways as $gateway) {
140
+				WP_CLI::log('  '.$this->color_message(self::$counter, $gateway['admin_label']));
141
+				self::$counter++;
142 142
 			}
143 143
 		} else {
144
-			WP_CLI::log( __( 'Not any payment gateways found', 'give' ) );
144
+			WP_CLI::log(__('Not any payment gateways found', 'give'));
145 145
 		}
146 146
 	}
147 147
 
@@ -173,15 +173,15 @@  discard block
 block discarded – undo
173 173
 	 *
174 174
 	 * @subcommand    forms
175 175
 	 */
176
-	public function forms( $args, $assoc_args ) {
176
+	public function forms($args, $assoc_args) {
177 177
 		global $wp_query;
178
-		$form_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? absint( $assoc_args['id'] ) : false;
179
-		$number  = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? absint( $assoc_args['number'] ) : 10;
178
+		$form_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? absint($assoc_args['id']) : false;
179
+		$number  = isset($assoc_args) && array_key_exists('number', $assoc_args) ? absint($assoc_args['number']) : 10;
180 180
 		$start   = time();
181 181
 
182 182
 		// Cache previous number query var.
183 183
 		$is_set_number = $cache_per_page = false;
184
-		if ( isset( $wp_query->query_vars['number'] ) ) {
184
+		if (isset($wp_query->query_vars['number'])) {
185 185
 			$cache_per_page = $wp_query->query_vars['number'];
186 186
 			$is_set_number  = true;
187 187
 		}
@@ -190,22 +190,22 @@  discard block
 block discarded – undo
190 190
 		$wp_query->query_vars['number'] = $number;
191 191
 
192 192
 		// Get forms.
193
-		$forms = $form_id ? $this->api->get_forms( $form_id ) : $this->api->get_forms();
193
+		$forms = $form_id ? $this->api->get_forms($form_id) : $this->api->get_forms();
194 194
 
195 195
 		// Reset number query var.
196
-		if ( $is_set_number ) {
196
+		if ($is_set_number) {
197 197
 			$wp_query->query_vars['number'] = $cache_per_page;
198 198
 		}
199 199
 
200 200
 		// Bailout.
201
-		if ( array_key_exists( 'error', $forms ) ) {
201
+		if (array_key_exists('error', $forms)) {
202 202
 
203
-			WP_CLI::warning( $forms['error'] );
203
+			WP_CLI::warning($forms['error']);
204 204
 
205 205
 			return;
206
-		} elseif ( empty( $forms['forms'] ) ) {
206
+		} elseif (empty($forms['forms'])) {
207 207
 
208
-			WP_CLI::error( __( 'No forms found.', 'give' ) );
208
+			WP_CLI::error(__('No forms found.', 'give'));
209 209
 
210 210
 			return;
211 211
 		}
@@ -213,25 +213,25 @@  discard block
 block discarded – undo
213 213
 		// Param to check if form typeis already showed or not.
214 214
 		$is_show_form_type = false;
215 215
 
216
-		if ( 1 === count( $forms ) && $form_id ) {
216
+		if (1 === count($forms) && $form_id) {
217 217
 			// Show single form.
218
-			foreach ( $forms['forms'][0] as $key => $info ) {
219
-				switch ( $key ) {
218
+			foreach ($forms['forms'][0] as $key => $info) {
219
+				switch ($key) {
220 220
 					case 'stats':
221
-						$this->color_main_heading( ucfirst( $key ) );
221
+						$this->color_main_heading(ucfirst($key));
222 222
 
223
-						foreach ( $info as $heading => $data ) {
224
-							$this->color_sub_heading( ucfirst( $heading ) );
225
-							switch ( $heading ) {
223
+						foreach ($info as $heading => $data) {
224
+							$this->color_sub_heading(ucfirst($heading));
225
+							switch ($heading) {
226 226
 								default:
227
-									foreach ( $data as $subheading => $subdata ) {
227
+									foreach ($data as $subheading => $subdata) {
228 228
 
229
-										switch ( $subheading ) {
229
+										switch ($subheading) {
230 230
 											case 'earnings':
231
-												WP_CLI::log( $this->color_message( $subheading . ': ', give_currency_filter( $subdata ) ) );
231
+												WP_CLI::log($this->color_message($subheading.': ', give_currency_filter($subdata)));
232 232
 												break;
233 233
 											default:
234
-												WP_CLI::log( $this->color_message( $subheading . ': ', $subdata ) );
234
+												WP_CLI::log($this->color_message($subheading.': ', $subdata));
235 235
 										}
236 236
 									}
237 237
 							}
@@ -241,26 +241,26 @@  discard block
 block discarded – undo
241 241
 					case 'pricing':
242 242
 					case 'info':
243 243
 					default:
244
-						$this->color_main_heading( ucfirst( $key ) );
244
+						$this->color_main_heading(ucfirst($key));
245 245
 
246 246
 						// Show form type.
247
-						if ( ! $is_show_form_type ) {
248
-							$form              = new Give_Donate_Form( $form_id );
247
+						if ( ! $is_show_form_type) {
248
+							$form              = new Give_Donate_Form($form_id);
249 249
 							$is_show_form_type = true;
250 250
 
251
-							WP_CLI::log( $this->color_message( __( 'form type', 'give' ), $form->get_type() ) );
251
+							WP_CLI::log($this->color_message(__('form type', 'give'), $form->get_type()));
252 252
 						}
253 253
 
254
-						foreach ( $info as $heading => $data ) {
254
+						foreach ($info as $heading => $data) {
255 255
 
256
-							switch ( $heading ) {
256
+							switch ($heading) {
257 257
 								case 'id':
258
-									WP_CLI::log( $this->color_message( $heading, $data ) );
258
+									WP_CLI::log($this->color_message($heading, $data));
259 259
 									break;
260 260
 
261 261
 								default:
262
-									$data = empty( $data ) ? __( 'Not set', 'give' ) : $data;
263
-									WP_CLI::log( $this->color_message( $heading, $data ) );
262
+									$data = empty($data) ? __('Not set', 'give') : $data;
263
+									WP_CLI::log($this->color_message($heading, $data));
264 264
 							}
265 265
 						}
266 266
 				}
@@ -271,37 +271,37 @@  discard block
 block discarded – undo
271 271
 			$is_table_first_row_set = false;
272 272
 			$table_column_count     = 0;
273 273
 
274
-			WP_CLI::line( $this->color_message( sprintf( __( '%d donation forms found', 'give' ), count( $forms['forms'] ) ), '', false ) );
274
+			WP_CLI::line($this->color_message(sprintf(__('%d donation forms found', 'give'), count($forms['forms'])), '', false));
275 275
 
276
-			foreach ( $forms['forms'] as $index => $form_data ) {
276
+			foreach ($forms['forms'] as $index => $form_data) {
277 277
 
278 278
 				// Default table data.
279 279
 				$table_first_row = array();
280 280
 				$table_row       = array();
281 281
 
282
-				foreach ( $form_data['info'] as $key => $form ) {
282
+				foreach ($form_data['info'] as $key => $form) {
283 283
 
284 284
 					// Do not show thumbnail, content and link in table.
285
-					if ( in_array( $key, array( 'content', 'thumbnail', 'link' ), true ) ) {
285
+					if (in_array($key, array('content', 'thumbnail', 'link'), true)) {
286 286
 						continue;
287 287
 					}
288 288
 
289
-					if ( ! $is_table_first_row_set ) {
289
+					if ( ! $is_table_first_row_set) {
290 290
 						$table_first_row[] = $key;
291 291
 					}
292 292
 
293 293
 					$table_row[] = $form;
294 294
 
295
-					if ( 'status' === $key ) {
295
+					if ('status' === $key) {
296 296
 						// First array item will be an form id in our case.
297
-						$form = new Give_Donate_Form( absint( $table_row[0] ) );
297
+						$form = new Give_Donate_Form(absint($table_row[0]));
298 298
 
299 299
 						$table_row[] = $form->get_type();
300 300
 					}
301 301
 				}
302 302
 
303 303
 				// Set table first row.
304
-				if ( ! $is_table_first_row_set ) {
304
+				if ( ! $is_table_first_row_set) {
305 305
 
306 306
 					// Add extra column to table.
307 307
 					$table_first_row[] = 'type';
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 				$table_data[] = $table_row;
315 315
 			}
316 316
 
317
-			$this->display_table( $table_data );
317
+			$this->display_table($table_data);
318 318
 		}
319 319
 	}
320 320
 
@@ -366,37 +366,37 @@  discard block
 block discarded – undo
366 366
 	 *
367 367
 	 * @subcommand    donors
368 368
 	 */
369
-	public function donors( $args, $assoc_args ) {
369
+	public function donors($args, $assoc_args) {
370 370
 		global $wp_query;
371
-		$donor_id = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? absint( $assoc_args['id'] ) : false;
372
-		$email    = isset( $assoc_args ) && array_key_exists( 'email', $assoc_args ) ? $assoc_args['email'] : false;
373
-		$name     = isset( $assoc_args ) && array_key_exists( 'name', $assoc_args ) ? $assoc_args['name'] : '';
374
-		$create   = isset( $assoc_args ) && array_key_exists( 'create', $assoc_args ) ? $assoc_args['create'] : false;
375
-		$number   = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? $assoc_args['number'] : 10;
376
-		$form_id  = isset( $assoc_args ) && array_key_exists( 'form-id', $assoc_args ) ? $assoc_args['form-id'] : 0;
377
-		$format   = isset( $assoc_args ) && array_key_exists( 'format', $assoc_args ) ? $assoc_args['format'] : 'table';
371
+		$donor_id = isset($assoc_args) && array_key_exists('id', $assoc_args) ? absint($assoc_args['id']) : false;
372
+		$email    = isset($assoc_args) && array_key_exists('email', $assoc_args) ? $assoc_args['email'] : false;
373
+		$name     = isset($assoc_args) && array_key_exists('name', $assoc_args) ? $assoc_args['name'] : '';
374
+		$create   = isset($assoc_args) && array_key_exists('create', $assoc_args) ? $assoc_args['create'] : false;
375
+		$number   = isset($assoc_args) && array_key_exists('number', $assoc_args) ? $assoc_args['number'] : 10;
376
+		$form_id  = isset($assoc_args) && array_key_exists('form-id', $assoc_args) ? $assoc_args['form-id'] : 0;
377
+		$format   = isset($assoc_args) && array_key_exists('format', $assoc_args) ? $assoc_args['format'] : 'table';
378 378
 		$start    = time();
379 379
 
380
-		if ( $create ) {
380
+		if ($create) {
381 381
 			$number = 1;
382 382
 
383
-			if ( isset( $assoc_args['email'] ) && ! is_email( $email ) ) {
384
-				WP_CLI::warning( 'Wrong email address provided.', 'give' );
383
+			if (isset($assoc_args['email']) && ! is_email($email)) {
384
+				WP_CLI::warning('Wrong email address provided.', 'give');
385 385
 
386 386
 				return;
387 387
 			}
388 388
 
389 389
 			// Create one or more donors.
390
-			if ( ! $email ) {
390
+			if ( ! $email) {
391 391
 				// If no email is specified, look to see if we are generating arbitrary donor accounts.
392
-				$number = is_numeric( $create ) ? absint( $create ) : 1;
392
+				$number = is_numeric($create) ? absint($create) : 1;
393 393
 			}
394 394
 
395
-			for ( $i = 0; $i < $number; $i ++ ) {
396
-				if ( ! $email ) {
395
+			for ($i = 0; $i < $number; $i++) {
396
+				if ( ! $email) {
397 397
 
398 398
 					// Generate fake email.
399
-					$email = 'customer-' . uniqid() . '@test.com';
399
+					$email = 'customer-'.uniqid().'@test.com';
400 400
 				}
401 401
 
402 402
 				$args = array(
@@ -404,19 +404,19 @@  discard block
 block discarded – undo
404 404
 					'name'  => $name,
405 405
 				);
406 406
 
407
-				$customer_id = Give()->customers->add( $args );
407
+				$customer_id = Give()->customers->add($args);
408 408
 
409
-				if ( $customer_id ) {
410
-					WP_CLI::line( $this->color_message( sprintf( __( 'Donor #%d created successfully', 'give' ), $customer_id ) ) );
409
+				if ($customer_id) {
410
+					WP_CLI::line($this->color_message(sprintf(__('Donor #%d created successfully', 'give'), $customer_id)));
411 411
 				} else {
412
-					WP_CLI::error( __( 'Failed to create donor', 'give' ) );
412
+					WP_CLI::error(__('Failed to create donor', 'give'));
413 413
 				}
414 414
 
415 415
 				// Reset email to false so it is generated on the next loop (if creating donors).
416 416
 				$email = false;
417 417
 			}
418 418
 
419
-			WP_CLI::line( $this->color_message( sprintf( __( '%1$d donors created in %2$d seconds', 'give' ), $number, time() - $start ) ) );
419
+			WP_CLI::line($this->color_message(sprintf(__('%1$d donors created in %2$d seconds', 'give'), $number, time() - $start)));
420 420
 
421 421
 		} else {
422 422
 			// Counter.
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
 			 */
431 431
 			// Cache previous number query var.
432 432
 			$is_set_number = $cache_per_page = false;
433
-			if ( isset( $wp_query->query_vars['number'] ) ) {
433
+			if (isset($wp_query->query_vars['number'])) {
434 434
 				$cache_per_page = $wp_query->query_vars['number'];
435 435
 				$is_set_number  = true;
436 436
 			}
@@ -439,24 +439,24 @@  discard block
 block discarded – undo
439 439
 			$wp_query->query_vars['number'] = $number;
440 440
 
441 441
 			// Get donors.
442
-			if ( $form_id ) {
442
+			if ($form_id) {
443 443
 				// @TODO: Allow user to get a list of donors by donation status.
444
-				$donors = $this->get_donors_by_form_id( $form_id );
444
+				$donors = $this->get_donors_by_form_id($form_id);
445 445
 			} else {
446
-				$donors = $this->api->get_customers( $search );
446
+				$donors = $this->api->get_customers($search);
447 447
 			}
448 448
 
449 449
 			// Reset number query var.
450
-			if ( $is_set_number ) {
450
+			if ($is_set_number) {
451 451
 				$wp_query->query_vars['number'] = $cache_per_page;
452 452
 			}
453 453
 
454
-			if ( isset( $donors['error'] ) ) {
455
-				WP_CLI::error( $donors['error'] );
454
+			if (isset($donors['error'])) {
455
+				WP_CLI::error($donors['error']);
456 456
 			}
457 457
 
458
-			if ( empty( $donors ) ) {
459
-				WP_CLI::error( __( 'No donors found.', 'give' ) );
458
+			if (empty($donors)) {
459
+				WP_CLI::error(__('No donors found.', 'give'));
460 460
 
461 461
 				return;
462 462
 			}
@@ -464,24 +464,24 @@  discard block
 block discarded – undo
464 464
 			$table_data             = array();
465 465
 			$is_table_first_row_set = false;
466 466
 
467
-			foreach ( $donors['donors'] as $donor_data ) {
467
+			foreach ($donors['donors'] as $donor_data) {
468 468
 				// Set default table row data.
469
-				$table_first_row = array( __( 's_no', 'give' ) );
470
-				$table_row       = array( self::$counter );
469
+				$table_first_row = array(__('s_no', 'give'));
470
+				$table_row       = array(self::$counter);
471 471
 
472
-				foreach ( $donor_data as $key => $donor ) {
473
-					switch ( $key ) {
472
+				foreach ($donor_data as $key => $donor) {
473
+					switch ($key) {
474 474
 						case 'stats':
475
-							foreach ( $donor as $heading => $data ) {
475
+							foreach ($donor as $heading => $data) {
476 476
 
477 477
 								// Get first row.
478
-								if ( ! $is_table_first_row_set ) {
478
+								if ( ! $is_table_first_row_set) {
479 479
 									$table_first_row[] = $heading;
480 480
 								}
481 481
 
482
-								switch ( $heading ) {
482
+								switch ($heading) {
483 483
 									case 'total_spent':
484
-										$table_row[] = give_currency_filter( $data );
484
+										$table_row[] = give_currency_filter($data);
485 485
 										break;
486 486
 
487 487
 									default:
@@ -492,10 +492,10 @@  discard block
 block discarded – undo
492 492
 
493 493
 						case 'info':
494 494
 						default:
495
-							foreach ( $donor as $heading => $data ) {
495
+							foreach ($donor as $heading => $data) {
496 496
 
497 497
 								// Get first row.
498
-								if ( ! $is_table_first_row_set ) {
498
+								if ( ! $is_table_first_row_set) {
499 499
 									$table_first_row[] = $heading;
500 500
 								}
501 501
 
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
 				}
506 506
 
507 507
 				// Add first row data to table data.
508
-				if ( ! $is_table_first_row_set ) {
508
+				if ( ! $is_table_first_row_set) {
509 509
 					$table_data[]           = $table_first_row;
510 510
 					$is_table_first_row_set = true;
511 511
 				}
@@ -514,44 +514,44 @@  discard block
 block discarded – undo
514 514
 				$table_data[] = $table_row;
515 515
 
516 516
 				// Increase counter.
517
-				self::$counter ++;
517
+				self::$counter++;
518 518
 			}
519 519
 
520
-			switch ( $format ) {
520
+			switch ($format) {
521 521
 				case 'json':
522 522
 					$table_column_name = $table_data[0];
523
-					unset( $table_data[0] );
523
+					unset($table_data[0]);
524 524
 
525 525
 					$new_table_data = array();
526
-					foreach ( $table_data as $index => $data ) {
527
-						foreach ( $data as $key => $value ) {
528
-							$new_table_data[ $index ][ $table_column_name[ $key ] ] = $value;
526
+					foreach ($table_data as $index => $data) {
527
+						foreach ($data as $key => $value) {
528
+							$new_table_data[$index][$table_column_name[$key]] = $value;
529 529
 						}
530 530
 					}
531 531
 
532
-					WP_CLI::log( json_encode( $new_table_data ) );
532
+					WP_CLI::log(json_encode($new_table_data));
533 533
 					break;
534 534
 
535 535
 				case 'csv':
536
-					$file_path = trailingslashit( WP_CONTENT_DIR ) . 'uploads/give_donors_' . date( 'Y_m_d_s', current_time( 'timestamp' ) ) . '.csv';
537
-					$fp        = fopen( $file_path, 'w' );
536
+					$file_path = trailingslashit(WP_CONTENT_DIR).'uploads/give_donors_'.date('Y_m_d_s', current_time('timestamp')).'.csv';
537
+					$fp        = fopen($file_path, 'w');
538 538
 
539
-					if ( is_writable( $file_path ) ) {
540
-						foreach ( $table_data as $fields ) {
541
-							fputcsv( $fp, $fields );
539
+					if (is_writable($file_path)) {
540
+						foreach ($table_data as $fields) {
541
+							fputcsv($fp, $fields);
542 542
 						}
543 543
 
544
-						fclose( $fp );
544
+						fclose($fp);
545 545
 
546
-						WP_CLI::success( "Donors list csv created successfully: {$file_path}" );
546
+						WP_CLI::success("Donors list csv created successfully: {$file_path}");
547 547
 					} else {
548
-						WP_CLI::warning( "Unable to create donors list csv file: {$file_path} (May folder do not have write permission)" );
548
+						WP_CLI::warning("Unable to create donors list csv file: {$file_path} (May folder do not have write permission)");
549 549
 					}
550 550
 
551 551
 					break;
552 552
 
553 553
 				default:
554
-					$this->display_table( $table_data );
554
+					$this->display_table($table_data);
555 555
 			}
556 556
 		}
557 557
 	}
@@ -581,13 +581,13 @@  discard block
 block discarded – undo
581 581
 	 *
582 582
 	 * @subcommand    donations
583 583
 	 */
584
-	public function donations( $args, $assoc_args ) {
584
+	public function donations($args, $assoc_args) {
585 585
 		global $wp_query;
586
-		$number = isset( $assoc_args ) && array_key_exists( 'number', $assoc_args ) ? $assoc_args['number'] : 10;
586
+		$number = isset($assoc_args) && array_key_exists('number', $assoc_args) ? $assoc_args['number'] : 10;
587 587
 
588 588
 		// Cache previous number query var.
589 589
 		$is_set_number = $cache_per_page = false;
590
-		if ( isset( $wp_query->query_vars['number'] ) ) {
590
+		if (isset($wp_query->query_vars['number'])) {
591 591
 			$cache_per_page = $wp_query->query_vars['number'];
592 592
 			$is_set_number  = true;
593 593
 		}
@@ -599,46 +599,46 @@  discard block
 block discarded – undo
599 599
 		$donations = $this->api->get_recent_donations();
600 600
 
601 601
 		// Reset number query var.
602
-		if ( $is_set_number ) {
602
+		if ($is_set_number) {
603 603
 			$wp_query->query_vars['number'] = $cache_per_page;
604 604
 		}
605 605
 
606
-		if ( empty( $donations ) ) {
607
-			WP_CLI::error( __( 'No donations found.', 'give' ) );
606
+		if (empty($donations)) {
607
+			WP_CLI::error(__('No donations found.', 'give'));
608 608
 
609 609
 			return;
610 610
 		}
611 611
 
612 612
 		self::$counter = 1;
613 613
 
614
-		foreach ( $donations['donations'] as $key => $donation ) {
615
-			$this->color_main_heading( sprintf( __( '%1$s. Donation #%2$s', 'give' ), self::$counter, $donation['ID'] ), 'Y' );
616
-			self::$counter ++;
614
+		foreach ($donations['donations'] as $key => $donation) {
615
+			$this->color_main_heading(sprintf(__('%1$s. Donation #%2$s', 'give'), self::$counter, $donation['ID']), 'Y');
616
+			self::$counter++;
617 617
 
618
-			foreach ( $donation as $column => $data ) {
618
+			foreach ($donation as $column => $data) {
619 619
 
620
-				if ( is_array( $data ) ) {
621
-					$this->color_sub_heading( $column );
622
-					foreach ( $data as $subcolumn => $subdata ) {
620
+				if (is_array($data)) {
621
+					$this->color_sub_heading($column);
622
+					foreach ($data as $subcolumn => $subdata) {
623 623
 
624 624
 						// Decode html codes.
625
-						switch ( $subcolumn ) {
625
+						switch ($subcolumn) {
626 626
 							case 'name':
627
-								$subdata = html_entity_decode( $subdata );
627
+								$subdata = html_entity_decode($subdata);
628 628
 								break;
629 629
 						}
630 630
 
631 631
 						// @TODO Check if multi dimension array information is importent to show or not. For example inside donation array we have array for fees data inside payment meta.
632
-						if ( is_array( $subdata ) ) {
632
+						if (is_array($subdata)) {
633 633
 							continue;
634 634
 						}
635 635
 
636
-						WP_CLI::log( $this->color_message( $subcolumn, $subdata ) );
636
+						WP_CLI::log($this->color_message($subcolumn, $subdata));
637 637
 					}
638 638
 					continue;
639 639
 				}
640 640
 
641
-				WP_CLI::log( $this->color_message( $column, $data ) );
641
+				WP_CLI::log($this->color_message($column, $data));
642 642
 			}
643 643
 		}
644 644
 	}
@@ -677,27 +677,27 @@  discard block
 block discarded – undo
677 677
 	 *
678 678
 	 * @return        void
679 679
 	 */
680
-	public function report( $args, $assoc_args ) {
680
+	public function report($args, $assoc_args) {
681 681
 		$stats      = new Give_Payment_Stats();
682
-		$date       = isset( $assoc_args ) && array_key_exists( 'date', $assoc_args ) ? $assoc_args['date'] : false;
683
-		$start_date = isset( $assoc_args ) && array_key_exists( 'start-date', $assoc_args ) ? $assoc_args['start-date'] : false;
684
-		$end_date   = isset( $assoc_args ) && array_key_exists( 'end-date', $assoc_args ) ? $assoc_args['end-date'] : false;
685
-		$form_id    = isset( $assoc_args ) && array_key_exists( 'id', $assoc_args ) ? $assoc_args['id'] : 0;
682
+		$date       = isset($assoc_args) && array_key_exists('date', $assoc_args) ? $assoc_args['date'] : false;
683
+		$start_date = isset($assoc_args) && array_key_exists('start-date', $assoc_args) ? $assoc_args['start-date'] : false;
684
+		$end_date   = isset($assoc_args) && array_key_exists('end-date', $assoc_args) ? $assoc_args['end-date'] : false;
685
+		$form_id    = isset($assoc_args) && array_key_exists('id', $assoc_args) ? $assoc_args['id'] : 0;
686 686
 
687
-		if ( ! empty( $date ) ) {
687
+		if ( ! empty($date)) {
688 688
 			$start_date = $date;
689 689
 			$end_date   = false;
690
-		} elseif ( empty( $date ) && empty( $start_date ) ) {
690
+		} elseif (empty($date) && empty($start_date)) {
691 691
 			$start_date = 'this_month';
692 692
 			$end_date   = false;
693 693
 		}
694 694
 
695 695
 		// Get stats.
696
-		$earnings = $stats->get_earnings( $form_id, $start_date, $end_date );
697
-		$sales    = $stats->get_sales( $form_id, $start_date, $end_date );
696
+		$earnings = $stats->get_earnings($form_id, $start_date, $end_date);
697
+		$sales    = $stats->get_sales($form_id, $start_date, $end_date);
698 698
 
699
-		WP_CLI::line( $this->color_message( __( 'Earnings', 'give' ), give_currency_filter( $earnings ) ) );
700
-		WP_CLI::line( $this->color_message( __( 'Sales', 'give' ), $sales ) );
699
+		WP_CLI::line($this->color_message(__('Earnings', 'give'), give_currency_filter($earnings)));
700
+		WP_CLI::line($this->color_message(__('Sales', 'give'), $sales));
701 701
 	}
702 702
 
703 703
 
@@ -724,27 +724,27 @@  discard block
 block discarded – undo
724 724
 	 *
725 725
 	 * @subcommand    cache
726 726
 	 */
727
-	public function cache( $args, $assoc_args ) {
728
-		$action = isset( $assoc_args ) && array_key_exists( 'action', $assoc_args ) ? $assoc_args['action'] : false;
727
+	public function cache($args, $assoc_args) {
728
+		$action = isset($assoc_args) && array_key_exists('action', $assoc_args) ? $assoc_args['action'] : false;
729 729
 
730 730
 		// Bailout.
731
-		if ( ! $action || ! in_array( $action, array( 'delete' ), true ) ) {
732
-			WP_CLI::warning( __( 'Type wp give cache --action=delete to delete all stat transients', 'give' ) );
731
+		if ( ! $action || ! in_array($action, array('delete'), true)) {
732
+			WP_CLI::warning(__('Type wp give cache --action=delete to delete all stat transients', 'give'));
733 733
 
734 734
 			return;
735 735
 		}
736 736
 
737
-		switch ( $action ) {
737
+		switch ($action) {
738 738
 			case 'delete' :
739 739
 				// Reset counter.
740 740
 				self::$counter = 1;
741 741
 
742
-				if ( $this->delete_stats_transients() ) {
742
+				if ($this->delete_stats_transients()) {
743 743
 					// Report .eading.
744
-					WP_CLI::success( 'Give cache deleted.' );
744
+					WP_CLI::success('Give cache deleted.');
745 745
 				} else {
746 746
 					// Report .eading.
747
-					WP_CLI::warning( 'We did not find any Give plugin cache to delete :)' );
747
+					WP_CLI::warning('We did not find any Give plugin cache to delete :)');
748 748
 				}
749 749
 				break;
750 750
 		}
@@ -773,27 +773,27 @@  discard block
 block discarded – undo
773 773
 			ARRAY_A
774 774
 		);
775 775
 
776
-		if ( ! empty( $stat_option_names ) ) {
776
+		if ( ! empty($stat_option_names)) {
777 777
 
778
-			foreach ( $stat_option_names as $option_name ) {
778
+			foreach ($stat_option_names as $option_name) {
779 779
 				$error       = false;
780 780
 				$option_name = $option_name['option_name'];
781 781
 
782
-				switch ( true ) {
783
-					case ( false !== strpos( $option_name, 'transient' ) ):
784
-						$option_name = str_replace( '_transient_', '', $option_name );
785
-						$error       = delete_transient( $option_name );
782
+				switch (true) {
783
+					case (false !== strpos($option_name, 'transient')):
784
+						$option_name = str_replace('_transient_', '', $option_name);
785
+						$error       = delete_transient($option_name);
786 786
 						break;
787 787
 
788 788
 					default:
789
-						$error = delete_option( $option_name );
789
+						$error = delete_option($option_name);
790 790
 				}
791 791
 
792
-				if ( $error ) {
793
-					WP_CLI::log( $this->color_message( self::$counter, $option_name ) );
794
-					self::$counter ++;
792
+				if ($error) {
793
+					WP_CLI::log($this->color_message(self::$counter, $option_name));
794
+					self::$counter++;
795 795
 				} else {
796
-					WP_CLI::log( $this->color_message( __( 'Error while deleting this transient', 'give' ), $option_name ) );
796
+					WP_CLI::log($this->color_message(__('Error while deleting this transient', 'give'), $option_name));
797 797
 				}
798 798
 			}
799 799
 
@@ -814,13 +814,13 @@  discard block
 block discarded – undo
814 814
 	 *
815 815
 	 * @return    mixed
816 816
 	 */
817
-	private function color_message( $heading, $message = '', $colon = true, $color = 'g' ) {
817
+	private function color_message($heading, $message = '', $colon = true, $color = 'g') {
818 818
 		// Add colon.
819
-		if ( $colon ) {
820
-			$heading = $heading . ': ';
819
+		if ($colon) {
820
+			$heading = $heading.': ';
821 821
 		}
822 822
 
823
-		return WP_CLI::colorize( "%{$color}" . $heading . '%n' ) . $message;
823
+		return WP_CLI::colorize("%{$color}".$heading.'%n').$message;
824 824
 	}
825 825
 
826 826
 
@@ -835,8 +835,8 @@  discard block
 block discarded – undo
835 835
 	 *
836 836
 	 * @return    void
837 837
 	 */
838
-	private function color_main_heading( $heading, $color = 'g' ) {
839
-		WP_CLI::log( "\n######   " . $this->color_message( $heading, '', false, $color ) . '   ######' );
838
+	private function color_main_heading($heading, $color = 'g') {
839
+		WP_CLI::log("\n######   ".$this->color_message($heading, '', false, $color).'   ######');
840 840
 	}
841 841
 
842 842
 	/**
@@ -849,8 +849,8 @@  discard block
 block discarded – undo
849 849
 	 *
850 850
 	 * @return    void
851 851
 	 */
852
-	private function color_sub_heading( $subheading ) {
853
-		WP_CLI::log( "\n--->" . $subheading . '', '', false );
852
+	private function color_sub_heading($subheading) {
853
+		WP_CLI::log("\n--->".$subheading.'', '', false);
854 854
 	}
855 855
 
856 856
 
@@ -864,17 +864,17 @@  discard block
 block discarded – undo
864 864
 	 *
865 865
 	 * @return    void
866 866
 	 */
867
-	private function display_table( $data ) {
867
+	private function display_table($data) {
868 868
 		$table = new \cli\Table();
869 869
 
870 870
 		// Set table header.
871
-		$table->setHeaders( $data[0] );
871
+		$table->setHeaders($data[0]);
872 872
 
873 873
 		// Remove table header.
874
-		unset( $data[0] );
874
+		unset($data[0]);
875 875
 
876 876
 		// Set table data.
877
-		$table->setRows( $data );
877
+		$table->setRows($data);
878 878
 
879 879
 		// Display table.
880 880
 		$table->display();
@@ -891,14 +891,14 @@  discard block
 block discarded – undo
891 891
 	 * @return array
892 892
 	 */
893 893
 
894
-	private function get_donors_by_form_id( $form_id ) {
894
+	private function get_donors_by_form_id($form_id) {
895 895
 		$donors = array();
896 896
 
897 897
 		$donations = new Give_Payments_Query(
898 898
 			array(
899
-				'give_forms' => array( $form_id ),
900
-				'number'     => - 1,
901
-				'status'     => array( 'publish' ),
899
+				'give_forms' => array($form_id),
900
+				'number'     => -1,
901
+				'status'     => array('publish'),
902 902
 			)
903 903
 		);
904 904
 
@@ -906,16 +906,16 @@  discard block
 block discarded – undo
906 906
 		$skip_donors = array();
907 907
 
908 908
 		/* @var Give_Payment|object $donation Payment object. */
909
-		foreach ( $donations as $donation ) {
909
+		foreach ($donations as $donation) {
910 910
 
911
-			if ( in_array( $donation->customer_id, $skip_donors ) ) {
911
+			if (in_array($donation->customer_id, $skip_donors)) {
912 912
 				continue;
913 913
 			}
914 914
 
915
-			if ( ! empty( $donors ) ) {
916
-				$donors['donors'][] = current( current( $this->api->get_customers( (int) $donation->customer_id ) ) );
915
+			if ( ! empty($donors)) {
916
+				$donors['donors'][] = current(current($this->api->get_customers((int) $donation->customer_id)));
917 917
 			} else {
918
-				$donors = array_merge( $donors, $this->api->get_customers( (int) $donation->customer_id ) );
918
+				$donors = array_merge($donors, $this->api->get_customers((int) $donation->customer_id));
919 919
 			}
920 920
 
921 921
 			$skip_donors[] = $donation->customer_id;
Please login to merge, or discard this patch.
includes/payments/functions.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
  *
327 327
  * @since  1.0
328 328
  *
329
- * @param  int|bool $form_id    Form ID (default: false).
329
+ * @param  boolean $form_id    Form ID (default: false).
330 330
  * @param  int      $payment_id Payment ID.
331 331
  *
332 332
  * @return void
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
  * @param  int $year      Year number. Default is null.
645 645
  * @param  int $hour      Hour number. Default is null.
646 646
  *
647
- * @return int $earnings  Earnings
647
+ * @return double $earnings  Earnings
648 648
  */
649 649
 function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) {
650 650
 
@@ -959,7 +959,7 @@  discard block
 block discarded – undo
959 959
  *
960 960
  * @param int $payment_id Payment ID.
961 961
  *
962
- * @return int $form_id Form ID.
962
+ * @return string $form_id Form ID.
963 963
  */
964 964
 function give_get_payment_form_id( $payment_id ) {
965 965
 	$payment = new Give_Payment( $payment_id );
Please login to merge, or discard this patch.
Spacing   +395 added lines, -395 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
 
@@ -43,15 +43,15 @@  discard block
 block discarded – undo
43 43
  *
44 44
  * @return object $payments Payments retrieved from the database
45 45
  */
46
-function give_get_payments( $args = array() ) {
46
+function give_get_payments($args = array()) {
47 47
 
48 48
 	// Fallback to post objects to ensure backwards compatibility.
49
-	if ( ! isset( $args['output'] ) ) {
49
+	if ( ! isset($args['output'])) {
50 50
 		$args['output'] = 'posts';
51 51
 	}
52 52
 
53
-	$args     = apply_filters( 'give_get_payments_args', $args );
54
-	$payments = new Give_Payments_Query( $args );
53
+	$args     = apply_filters('give_get_payments_args', $args);
54
+	$payments = new Give_Payments_Query($args);
55 55
 
56 56
 	return $payments->get_payments();
57 57
 }
@@ -66,48 +66,48 @@  discard block
 block discarded – undo
66 66
  *
67 67
  * @return mixed
68 68
  */
69
-function give_get_payment_by( $field = '', $value = '' ) {
69
+function give_get_payment_by($field = '', $value = '') {
70 70
 
71
-	if ( empty( $field ) || empty( $value ) ) {
71
+	if (empty($field) || empty($value)) {
72 72
 		return false;
73 73
 	}
74 74
 
75
-	switch ( strtolower( $field ) ) {
75
+	switch (strtolower($field)) {
76 76
 
77 77
 		case 'id':
78
-			$payment = new Give_Payment( $value );
78
+			$payment = new Give_Payment($value);
79 79
 			$id      = $payment->ID;
80 80
 
81
-			if ( empty( $id ) ) {
81
+			if (empty($id)) {
82 82
 				return false;
83 83
 			}
84 84
 
85 85
 			break;
86 86
 
87 87
 		case 'key':
88
-			$payment = give_get_payments( array(
88
+			$payment = give_get_payments(array(
89 89
 				'meta_key'       => '_give_payment_purchase_key',
90 90
 				'meta_value'     => $value,
91 91
 				'posts_per_page' => 1,
92 92
 				'fields'         => 'ids',
93
-			) );
93
+			));
94 94
 
95
-			if ( $payment ) {
96
-				$payment = new Give_Payment( $payment[0] );
95
+			if ($payment) {
96
+				$payment = new Give_Payment($payment[0]);
97 97
 			}
98 98
 
99 99
 			break;
100 100
 
101 101
 		case 'payment_number':
102
-			$payment = give_get_payments( array(
102
+			$payment = give_get_payments(array(
103 103
 				'meta_key'       => '_give_payment_number',
104 104
 				'meta_value'     => $value,
105 105
 				'posts_per_page' => 1,
106 106
 				'fields'         => 'ids',
107
-			) );
107
+			));
108 108
 
109
-			if ( $payment ) {
110
-				$payment = new Give_Payment( $payment[0] );
109
+			if ($payment) {
110
+				$payment = new Give_Payment($payment[0]);
111 111
 			}
112 112
 
113 113
 			break;
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 			return false;
117 117
 	}
118 118
 
119
-	if ( $payment ) {
119
+	if ($payment) {
120 120
 		return $payment;
121 121
 	}
122 122
 
@@ -132,23 +132,23 @@  discard block
 block discarded – undo
132 132
  *
133 133
  * @return int|bool Payment ID if payment is inserted, false otherwise.
134 134
  */
135
-function give_insert_payment( $payment_data = array() ) {
135
+function give_insert_payment($payment_data = array()) {
136 136
 
137
-	if ( empty( $payment_data ) ) {
137
+	if (empty($payment_data)) {
138 138
 		return false;
139 139
 	}
140 140
 
141 141
 	$payment    = new Give_Payment();
142
-	$gateway    = ! empty( $payment_data['gateway'] ) ? $payment_data['gateway'] : '';
143
-	$gateway    = empty( $gateway ) && isset( $_POST['give-gateway'] ) ? $_POST['give-gateway'] : $gateway;
144
-	$form_id    = isset( $payment_data['give_form_id'] ) ? $payment_data['give_form_id'] : 0;
145
-	$price_id   = isset( $payment_data['give_price_id'] ) ? $payment_data['give_price_id'] : give_get_price_id( $payment_data['give_form_id'], $payment_data['price'] );
146
-	$form_title = isset( $payment_data['give_form_title'] ) ? $payment_data['give_form_title'] : get_the_title( $form_id );
142
+	$gateway    = ! empty($payment_data['gateway']) ? $payment_data['gateway'] : '';
143
+	$gateway    = empty($gateway) && isset($_POST['give-gateway']) ? $_POST['give-gateway'] : $gateway;
144
+	$form_id    = isset($payment_data['give_form_id']) ? $payment_data['give_form_id'] : 0;
145
+	$price_id   = isset($payment_data['give_price_id']) ? $payment_data['give_price_id'] : give_get_price_id($payment_data['give_form_id'], $payment_data['price']);
146
+	$form_title = isset($payment_data['give_form_title']) ? $payment_data['give_form_title'] : get_the_title($form_id);
147 147
 
148 148
 	// Set properties.
149 149
 	$payment->total          = $payment_data['price'];
150
-	$payment->status         = ! empty( $payment_data['status'] ) ? $payment_data['status'] : 'pending';
151
-	$payment->currency       = ! empty( $payment_data['currency'] ) ? $payment_data['currency'] : give_get_currency();
150
+	$payment->status         = ! empty($payment_data['status']) ? $payment_data['status'] : 'pending';
151
+	$payment->currency       = ! empty($payment_data['currency']) ? $payment_data['currency'] : give_get_currency();
152 152
 	$payment->user_info      = $payment_data['user_info'];
153 153
 	$payment->gateway        = $gateway;
154 154
 	$payment->form_title     = $form_title;
@@ -162,31 +162,31 @@  discard block
 block discarded – undo
162 162
 	$payment->ip             = give_get_ip();
163 163
 	$payment->key            = $payment_data['purchase_key'];
164 164
 	$payment->mode           = give_is_test_mode() ? 'test' : 'live';
165
-	$payment->parent_payment = ! empty( $payment_data['parent'] ) ? absint( $payment_data['parent'] ) : '';
165
+	$payment->parent_payment = ! empty($payment_data['parent']) ? absint($payment_data['parent']) : '';
166 166
 
167 167
 	// Add the donation.
168 168
 	$args = array(
169 169
 		'price'    => $payment->total,
170 170
 		'price_id' => $payment->price_id,
171
-		'fees'     => isset( $payment_data['fees'] ) ? $payment_data['fees'] : array(),
171
+		'fees'     => isset($payment_data['fees']) ? $payment_data['fees'] : array(),
172 172
 	);
173 173
 
174
-	$payment->add_donation( $payment->form_id, $args );
174
+	$payment->add_donation($payment->form_id, $args);
175 175
 
176 176
 	// Set date if present.
177
-	if ( isset( $payment_data['post_date'] ) ) {
177
+	if (isset($payment_data['post_date'])) {
178 178
 		$payment->date = $payment_data['post_date'];
179 179
 	}
180 180
 
181 181
 	// Handle sequential payments.
182
-	if ( give_get_option( 'enable_sequential' ) ) {
182
+	if (give_get_option('enable_sequential')) {
183 183
 		$number          = give_get_next_payment_number();
184
-		$payment->number = give_format_payment_number( $number );
185
-		update_option( 'give_last_payment_number', $number );
184
+		$payment->number = give_format_payment_number($number);
185
+		update_option('give_last_payment_number', $number);
186 186
 	}
187 187
 
188 188
 	// Clear the user's donation cache.
189
-	delete_transient( 'give_user_' . $payment_data['user_info']['id'] . '_purchases' );
189
+	delete_transient('give_user_'.$payment_data['user_info']['id'].'_purchases');
190 190
 
191 191
 	// Save payment.
192 192
 	$payment->save();
@@ -199,10 +199,10 @@  discard block
 block discarded – undo
199 199
 	 * @param int   $payment_id   The payment ID.
200 200
 	 * @param array $payment_data Arguments passed.
201 201
 	 */
202
-	do_action( 'give_insert_payment', $payment->ID, $payment_data );
202
+	do_action('give_insert_payment', $payment->ID, $payment_data);
203 203
 
204 204
 	// Return payment ID upon success.
205
-	if ( ! empty( $payment->ID ) ) {
205
+	if ( ! empty($payment->ID)) {
206 206
 		return $payment->ID;
207 207
 	}
208 208
 
@@ -221,9 +221,9 @@  discard block
 block discarded – undo
221 221
  *
222 222
  * @return bool
223 223
  */
224
-function give_update_payment_status( $payment_id, $new_status = 'publish' ) {
224
+function give_update_payment_status($payment_id, $new_status = 'publish') {
225 225
 
226
-	$payment         = new Give_Payment( $payment_id );
226
+	$payment         = new Give_Payment($payment_id);
227 227
 	$payment->status = $new_status;
228 228
 	$updated         = $payment->save();
229 229
 
@@ -242,37 +242,37 @@  discard block
 block discarded – undo
242 242
  *
243 243
  * @return void
244 244
  */
245
-function give_delete_purchase( $payment_id = 0, $update_customer = true ) {
245
+function give_delete_purchase($payment_id = 0, $update_customer = true) {
246 246
 	global $give_logs;
247 247
 
248
-	$payment     = new Give_Payment( $payment_id );
249
-	$amount      = give_get_payment_amount( $payment_id );
248
+	$payment     = new Give_Payment($payment_id);
249
+	$amount      = give_get_payment_amount($payment_id);
250 250
 	$status      = $payment->post_status;
251
-	$customer_id = give_get_payment_customer_id( $payment_id );
252
-	$customer    = new Give_Customer( $customer_id );
251
+	$customer_id = give_get_payment_customer_id($payment_id);
252
+	$customer    = new Give_Customer($customer_id);
253 253
 
254 254
 	// Only undo donations that aren't these statuses.
255
-	$dont_undo_statuses = apply_filters( 'give_undo_purchase_statuses', array(
255
+	$dont_undo_statuses = apply_filters('give_undo_purchase_statuses', array(
256 256
 		'pending',
257 257
 		'cancelled',
258
-	) );
258
+	));
259 259
 
260
-	if ( ! in_array( $status, $dont_undo_statuses ) ) {
261
-		give_undo_purchase( false, $payment_id );
260
+	if ( ! in_array($status, $dont_undo_statuses)) {
261
+		give_undo_purchase(false, $payment_id);
262 262
 	}
263 263
 
264
-	if ( $status == 'publish' ) {
264
+	if ($status == 'publish') {
265 265
 
266 266
 		// Only decrease earnings if they haven't already been decreased (or were never increased for this payment).
267
-		give_decrease_total_earnings( $amount );
267
+		give_decrease_total_earnings($amount);
268 268
 		// Clear the This Month earnings (this_monththis_month is NOT a typo).
269
-		delete_transient( md5( 'give_earnings_this_monththis_month' ) );
269
+		delete_transient(md5('give_earnings_this_monththis_month'));
270 270
 
271
-		if ( $customer->id && $update_customer ) {
271
+		if ($customer->id && $update_customer) {
272 272
 
273 273
 			// Decrement the stats for the donor.
274 274
 			$customer->decrease_purchase_count();
275
-			$customer->decrease_value( $amount );
275
+			$customer->decrease_value($amount);
276 276
 
277 277
 		}
278 278
 	}
@@ -284,17 +284,17 @@  discard block
 block discarded – undo
284 284
 	 *
285 285
 	 * @param int $payment_id Payment ID.
286 286
 	 */
287
-	do_action( 'give_payment_delete', $payment_id );
287
+	do_action('give_payment_delete', $payment_id);
288 288
 
289
-	if ( $customer->id && $update_customer ) {
289
+	if ($customer->id && $update_customer) {
290 290
 
291 291
 		// Remove the payment ID from the donor.
292
-		$customer->remove_payment( $payment_id );
292
+		$customer->remove_payment($payment_id);
293 293
 
294 294
 	}
295 295
 
296 296
 	// Remove the payment.
297
-	wp_delete_post( $payment_id, true );
297
+	wp_delete_post($payment_id, true);
298 298
 
299 299
 	// Remove related sale log entries.
300 300
 	$give_logs->delete_logs(
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 	 *
316 316
 	 * @param int $payment_id Payment ID.
317 317
 	 */
318
-	do_action( 'give_payment_deleted', $payment_id );
318
+	do_action('give_payment_deleted', $payment_id);
319 319
 }
320 320
 
321 321
 /**
@@ -331,25 +331,25 @@  discard block
 block discarded – undo
331 331
  *
332 332
  * @return void
333 333
  */
334
-function give_undo_purchase( $form_id = false, $payment_id ) {
334
+function give_undo_purchase($form_id = false, $payment_id) {
335 335
 
336
-	if ( ! empty( $form_id ) ) {
336
+	if ( ! empty($form_id)) {
337 337
 		$form_id = false;
338
-		_give_deprected_argument( 'form_id', 'give_undo_purchase', '1.5' );
338
+		_give_deprected_argument('form_id', 'give_undo_purchase', '1.5');
339 339
 	}
340 340
 
341
-	$payment = new Give_Payment( $payment_id );
341
+	$payment = new Give_Payment($payment_id);
342 342
 
343
-	$maybe_decrease_earnings = apply_filters( 'give_decrease_earnings_on_undo', true, $payment, $payment->form_id );
344
-	if ( true === $maybe_decrease_earnings ) {
343
+	$maybe_decrease_earnings = apply_filters('give_decrease_earnings_on_undo', true, $payment, $payment->form_id);
344
+	if (true === $maybe_decrease_earnings) {
345 345
 		// Decrease earnings.
346
-		give_decrease_earnings( $payment->form_id, $payment->total );
346
+		give_decrease_earnings($payment->form_id, $payment->total);
347 347
 	}
348 348
 
349
-	$maybe_decrease_sales = apply_filters( 'give_decrease_sales_on_undo', true, $payment, $payment->form_id );
350
-	if ( true === $maybe_decrease_sales ) {
349
+	$maybe_decrease_sales = apply_filters('give_decrease_sales_on_undo', true, $payment, $payment->form_id);
350
+	if (true === $maybe_decrease_sales) {
351 351
 		// Decrease donation count.
352
-		give_decrease_purchase_count( $payment->form_id );
352
+		give_decrease_purchase_count($payment->form_id);
353 353
 	}
354 354
 
355 355
 }
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
  *
367 367
  * @return array $count Number of payments sorted by payment status.
368 368
  */
369
-function give_count_payments( $args = array() ) {
369
+function give_count_payments($args = array()) {
370 370
 
371 371
 	global $wpdb;
372 372
 
@@ -378,18 +378,18 @@  discard block
 block discarded – undo
378 378
 		'form_id'    => null,
379 379
 	);
380 380
 
381
-	$args = wp_parse_args( $args, $defaults );
381
+	$args = wp_parse_args($args, $defaults);
382 382
 
383 383
 	$select = 'SELECT p.post_status,count( * ) AS num_posts';
384 384
 	$join   = '';
385 385
 	$where  = "WHERE p.post_type = 'give_payment'";
386 386
 
387 387
 	// Count payments for a specific user.
388
-	if ( ! empty( $args['user'] ) ) {
388
+	if ( ! empty($args['user'])) {
389 389
 
390
-		if ( is_email( $args['user'] ) ) {
390
+		if (is_email($args['user'])) {
391 391
 			$field = 'email';
392
-		} elseif ( is_numeric( $args['user'] ) ) {
392
+		} elseif (is_numeric($args['user'])) {
393 393
 			$field = 'id';
394 394
 		} else {
395 395
 			$field = '';
@@ -397,105 +397,105 @@  discard block
 block discarded – undo
397 397
 
398 398
 		$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
399 399
 
400
-		if ( ! empty( $field ) ) {
400
+		if ( ! empty($field)) {
401 401
 			$where .= "
402 402
 				AND m.meta_key = '_give_payment_user_{$field}'
403 403
 				AND m.meta_value = '{$args['user']}'";
404 404
 		}
405 405
 
406 406
 		// Count payments for a search.
407
-	} elseif ( ! empty( $args['s'] ) ) {
407
+	} elseif ( ! empty($args['s'])) {
408 408
 
409
-		if ( is_email( $args['s'] ) || strlen( $args['s'] ) == 32 ) {
409
+		if (is_email($args['s']) || strlen($args['s']) == 32) {
410 410
 
411
-			if ( is_email( $args['s'] ) ) {
411
+			if (is_email($args['s'])) {
412 412
 				$field = '_give_payment_user_email';
413 413
 			} else {
414 414
 				$field = '_give_payment_purchase_key';
415 415
 			}
416 416
 
417 417
 			$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
418
-			$where .= $wpdb->prepare( '
418
+			$where .= $wpdb->prepare('
419 419
                 AND m.meta_key = %s
420 420
                 AND m.meta_value = %s',
421 421
 				$field,
422 422
 				$args['s']
423 423
 			);
424 424
 
425
-		} elseif ( '#' == substr( $args['s'], 0, 1 ) ) {
425
+		} elseif ('#' == substr($args['s'], 0, 1)) {
426 426
 
427
-			$search = str_replace( '#:', '', $args['s'] );
428
-			$search = str_replace( '#', '', $search );
427
+			$search = str_replace('#:', '', $args['s']);
428
+			$search = str_replace('#', '', $search);
429 429
 
430 430
 			$select = 'SELECT p2.post_status,count( * ) AS num_posts ';
431 431
 			$join   = "LEFT JOIN $wpdb->postmeta m ON m.meta_key = '_give_log_payment_id' AND m.post_id = p.ID ";
432 432
 			$join .= "INNER JOIN $wpdb->posts p2 ON m.meta_value = p2.ID ";
433 433
 			$where = "WHERE p.post_type = 'give_log' ";
434
-			$where .= $wpdb->prepare( 'AND p.post_parent = %d} ', $search );
434
+			$where .= $wpdb->prepare('AND p.post_parent = %d} ', $search);
435 435
 
436
-		} elseif ( is_numeric( $args['s'] ) ) {
436
+		} elseif (is_numeric($args['s'])) {
437 437
 
438 438
 			$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
439
-			$where .= $wpdb->prepare( "
439
+			$where .= $wpdb->prepare("
440 440
 				AND m.meta_key = '_give_payment_user_id'
441 441
 				AND m.meta_value = %d",
442 442
 				$args['s']
443 443
 			);
444 444
 
445 445
 		} else {
446
-			$search = $wpdb->esc_like( $args['s'] );
447
-			$search = '%' . $search . '%';
446
+			$search = $wpdb->esc_like($args['s']);
447
+			$search = '%'.$search.'%';
448 448
 
449
-			$where .= $wpdb->prepare( 'AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search );
449
+			$where .= $wpdb->prepare('AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search);
450 450
 		}
451 451
 	}
452 452
 
453
-	if ( ! empty( $args['form_id'] ) && is_numeric( $args['form_id'] ) ) {
453
+	if ( ! empty($args['form_id']) && is_numeric($args['form_id'])) {
454 454
 
455
-		$where .= $wpdb->prepare( ' AND p.post_parent = %d', $args['form_id'] );
455
+		$where .= $wpdb->prepare(' AND p.post_parent = %d', $args['form_id']);
456 456
 
457 457
 	}
458 458
 	// Limit payments count by date.
459
-	if ( ! empty( $args['start-date'] ) && false !== strpos( $args['start-date'], '/' ) ) {
459
+	if ( ! empty($args['start-date']) && false !== strpos($args['start-date'], '/')) {
460 460
 
461
-		$date_parts = explode( '/', $args['start-date'] );
462
-		$month      = ! empty( $date_parts[0] ) && is_numeric( $date_parts[0] ) ? $date_parts[0] : 0;
463
-		$day        = ! empty( $date_parts[1] ) && is_numeric( $date_parts[1] ) ? $date_parts[1] : 0;
464
-		$year       = ! empty( $date_parts[2] ) && is_numeric( $date_parts[2] ) ? $date_parts[2] : 0;
461
+		$date_parts = explode('/', $args['start-date']);
462
+		$month      = ! empty($date_parts[0]) && is_numeric($date_parts[0]) ? $date_parts[0] : 0;
463
+		$day        = ! empty($date_parts[1]) && is_numeric($date_parts[1]) ? $date_parts[1] : 0;
464
+		$year       = ! empty($date_parts[2]) && is_numeric($date_parts[2]) ? $date_parts[2] : 0;
465 465
 
466
-		$is_date = checkdate( $month, $day, $year );
467
-		if ( false !== $is_date ) {
466
+		$is_date = checkdate($month, $day, $year);
467
+		if (false !== $is_date) {
468 468
 
469
-			$date = new DateTime( $args['start-date'] );
470
-			$where .= $wpdb->prepare( " AND p.post_date >= '%s'", $date->format( 'Y-m-d' ) );
469
+			$date = new DateTime($args['start-date']);
470
+			$where .= $wpdb->prepare(" AND p.post_date >= '%s'", $date->format('Y-m-d'));
471 471
 
472 472
 		}
473 473
 
474 474
 		// Fixes an issue with the payments list table counts when no end date is specified (partiy with stats class).
475
-		if ( empty( $args['end-date'] ) ) {
475
+		if (empty($args['end-date'])) {
476 476
 			$args['end-date'] = $args['start-date'];
477 477
 		}
478 478
 	}
479 479
 
480
-	if ( ! empty( $args['end-date'] ) && false !== strpos( $args['end-date'], '/' ) ) {
480
+	if ( ! empty($args['end-date']) && false !== strpos($args['end-date'], '/')) {
481 481
 
482
-		$date_parts = explode( '/', $args['end-date'] );
482
+		$date_parts = explode('/', $args['end-date']);
483 483
 
484
-		$month = ! empty( $date_parts[0] ) ? $date_parts[0] : 0;
485
-		$day   = ! empty( $date_parts[1] ) ? $date_parts[1] : 0;
486
-		$year  = ! empty( $date_parts[2] ) ? $date_parts[2] : 0;
484
+		$month = ! empty($date_parts[0]) ? $date_parts[0] : 0;
485
+		$day   = ! empty($date_parts[1]) ? $date_parts[1] : 0;
486
+		$year  = ! empty($date_parts[2]) ? $date_parts[2] : 0;
487 487
 
488
-		$is_date = checkdate( $month, $day, $year );
489
-		if ( false !== $is_date ) {
488
+		$is_date = checkdate($month, $day, $year);
489
+		if (false !== $is_date) {
490 490
 
491
-			$date = new DateTime( $args['end-date'] );
492
-			$where .= $wpdb->prepare( " AND p.post_date <= '%s'", $date->format( 'Y-m-d' ) );
491
+			$date = new DateTime($args['end-date']);
492
+			$where .= $wpdb->prepare(" AND p.post_date <= '%s'", $date->format('Y-m-d'));
493 493
 
494 494
 		}
495 495
 	}
496 496
 
497
-	$where = apply_filters( 'give_count_payments_where', $where );
498
-	$join  = apply_filters( 'give_count_payments_join', $join );
497
+	$where = apply_filters('give_count_payments_where', $where);
498
+	$join  = apply_filters('give_count_payments_join', $join);
499 499
 
500 500
 	$query = "$select
501 501
 		FROM $wpdb->posts p
@@ -504,36 +504,36 @@  discard block
 block discarded – undo
504 504
 		GROUP BY p.post_status
505 505
 	";
506 506
 
507
-	$cache_key = md5( $query );
507
+	$cache_key = md5($query);
508 508
 
509
-	$count = wp_cache_get( $cache_key, 'counts' );
510
-	if ( false !== $count ) {
509
+	$count = wp_cache_get($cache_key, 'counts');
510
+	if (false !== $count) {
511 511
 		return $count;
512 512
 	}
513 513
 
514
-	$count = $wpdb->get_results( $query, ARRAY_A );
514
+	$count = $wpdb->get_results($query, ARRAY_A);
515 515
 
516 516
 	$stats    = array();
517 517
 	$statuses = get_post_stati();
518
-	if ( isset( $statuses['private'] ) && empty( $args['s'] ) ) {
519
-		unset( $statuses['private'] );
518
+	if (isset($statuses['private']) && empty($args['s'])) {
519
+		unset($statuses['private']);
520 520
 	}
521 521
 
522
-	foreach ( $statuses as $state ) {
523
-		$stats[ $state ] = 0;
522
+	foreach ($statuses as $state) {
523
+		$stats[$state] = 0;
524 524
 	}
525 525
 
526
-	foreach ( (array) $count as $row ) {
526
+	foreach ((array) $count as $row) {
527 527
 
528
-		if ( 'private' == $row['post_status'] && empty( $args['s'] ) ) {
528
+		if ('private' == $row['post_status'] && empty($args['s'])) {
529 529
 			continue;
530 530
 		}
531 531
 
532
-		$stats[ $row['post_status'] ] = $row['num_posts'];
532
+		$stats[$row['post_status']] = $row['num_posts'];
533 533
 	}
534 534
 
535 535
 	$stats = (object) $stats;
536
-	wp_cache_set( $cache_key, $stats, 'counts' );
536
+	wp_cache_set($cache_key, $stats, 'counts');
537 537
 
538 538
 	return $stats;
539 539
 }
@@ -548,11 +548,11 @@  discard block
 block discarded – undo
548 548
  *
549 549
  * @return bool $exists True if payment exists, false otherwise.
550 550
  */
551
-function give_check_for_existing_payment( $payment_id ) {
551
+function give_check_for_existing_payment($payment_id) {
552 552
 	$exists  = false;
553
-	$payment = new Give_Payment( $payment_id );
553
+	$payment = new Give_Payment($payment_id);
554 554
 
555
-	if ( $payment_id === $payment->ID && 'publish' === $payment->status ) {
555
+	if ($payment_id === $payment->ID && 'publish' === $payment->status) {
556 556
 		$exists = true;
557 557
 	}
558 558
 
@@ -570,31 +570,31 @@  discard block
 block discarded – undo
570 570
  *
571 571
  * @return bool|mixed True if payment status exists, false otherwise.
572 572
  */
573
-function give_get_payment_status( $payment, $return_label = false ) {
573
+function give_get_payment_status($payment, $return_label = false) {
574 574
 
575
-	if ( ! is_object( $payment ) || ! isset( $payment->post_status ) ) {
575
+	if ( ! is_object($payment) || ! isset($payment->post_status)) {
576 576
 		return false;
577 577
 	}
578 578
 
579 579
 	$statuses = give_get_payment_statuses();
580 580
 
581
-	if ( ! is_array( $statuses ) || empty( $statuses ) ) {
581
+	if ( ! is_array($statuses) || empty($statuses)) {
582 582
 		return false;
583 583
 	}
584 584
 
585 585
 	// Get payment object if no already given.
586
-	$payment = $payment instanceof Give_Payment ? $payment : new Give_Payment( $payment->ID );
586
+	$payment = $payment instanceof Give_Payment ? $payment : new Give_Payment($payment->ID);
587 587
 
588
-	if ( array_key_exists( $payment->status, $statuses ) ) {
589
-		if ( true === $return_label ) {
588
+	if (array_key_exists($payment->status, $statuses)) {
589
+		if (true === $return_label) {
590 590
 			// Return translated status label.
591
-			return $statuses[ $payment->status ];
591
+			return $statuses[$payment->status];
592 592
 		} else {
593 593
 			// Account that our 'publish' status is labeled 'Complete'
594 594
 			$post_status = 'publish' == $payment->status ? 'Complete' : $payment->post_status;
595 595
 
596 596
 			// Make sure we're matching cases, since they matter
597
-			return array_search( strtolower( $post_status ), array_map( 'strtolower', $statuses ) );
597
+			return array_search(strtolower($post_status), array_map('strtolower', $statuses));
598 598
 		}
599 599
 	}
600 600
 
@@ -610,17 +610,17 @@  discard block
 block discarded – undo
610 610
  */
611 611
 function give_get_payment_statuses() {
612 612
 	$payment_statuses = array(
613
-		'pending'     => __( 'Pending', 'give' ),
614
-		'publish'     => __( 'Complete', 'give' ),
615
-		'refunded'    => __( 'Refunded', 'give' ),
616
-		'failed'      => __( 'Failed', 'give' ),
617
-		'cancelled'   => __( 'Cancelled', 'give' ),
618
-		'abandoned'   => __( 'Abandoned', 'give' ),
619
-		'preapproval' => __( 'Pre-Approved', 'give' ),
620
-		'revoked'     => __( 'Revoked', 'give' ),
613
+		'pending'     => __('Pending', 'give'),
614
+		'publish'     => __('Complete', 'give'),
615
+		'refunded'    => __('Refunded', 'give'),
616
+		'failed'      => __('Failed', 'give'),
617
+		'cancelled'   => __('Cancelled', 'give'),
618
+		'abandoned'   => __('Abandoned', 'give'),
619
+		'preapproval' => __('Pre-Approved', 'give'),
620
+		'revoked'     => __('Revoked', 'give'),
621 621
 	);
622 622
 
623
-	return apply_filters( 'give_payment_statuses', $payment_statuses );
623
+	return apply_filters('give_payment_statuses', $payment_statuses);
624 624
 }
625 625
 
626 626
 /**
@@ -633,10 +633,10 @@  discard block
 block discarded – undo
633 633
  * @return array $payment_status All the available payment statuses.
634 634
  */
635 635
 function give_get_payment_status_keys() {
636
-	$statuses = array_keys( give_get_payment_statuses() );
637
-	asort( $statuses );
636
+	$statuses = array_keys(give_get_payment_statuses());
637
+	asort($statuses);
638 638
 
639
-	return array_values( $statuses );
639
+	return array_values($statuses);
640 640
 }
641 641
 
642 642
 /**
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
  *
652 652
  * @return int $earnings  Earnings
653 653
  */
654
-function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) {
654
+function give_get_earnings_by_date($day = null, $month_num, $year = null, $hour = null) {
655 655
 
656 656
 	// This is getting deprecated soon. Use Give_Payment_Stats with the get_earnings() method instead.
657 657
 	global $wpdb;
@@ -661,41 +661,41 @@  discard block
 block discarded – undo
661 661
 		'nopaging'               => true,
662 662
 		'year'                   => $year,
663 663
 		'monthnum'               => $month_num,
664
-		'post_status'            => array( 'publish' ),
664
+		'post_status'            => array('publish'),
665 665
 		'fields'                 => 'ids',
666 666
 		'update_post_term_cache' => false,
667 667
 	);
668
-	if ( ! empty( $day ) ) {
668
+	if ( ! empty($day)) {
669 669
 		$args['day'] = $day;
670 670
 	}
671 671
 
672
-	if ( ! empty( $hour ) ) {
672
+	if ( ! empty($hour)) {
673 673
 		$args['hour'] = $hour;
674 674
 	}
675 675
 
676
-	$args = apply_filters( 'give_get_earnings_by_date_args', $args );
677
-	$key  = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 );
676
+	$args = apply_filters('give_get_earnings_by_date_args', $args);
677
+	$key  = 'give_stats_'.substr(md5(serialize($args)), 0, 15);
678 678
 
679
-	if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) {
679
+	if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) {
680 680
 		$earnings = false;
681 681
 	} else {
682
-		$earnings = get_transient( $key );
682
+		$earnings = get_transient($key);
683 683
 	}
684 684
 
685
-	if ( false === $earnings ) {
686
-		$sales    = get_posts( $args );
685
+	if (false === $earnings) {
686
+		$sales    = get_posts($args);
687 687
 		$earnings = 0;
688
-		if ( $sales ) {
689
-			$sales = implode( ',', $sales );
688
+		if ($sales) {
689
+			$sales = implode(',', $sales);
690 690
 
691
-			$earnings = $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$sales})" );
691
+			$earnings = $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$sales})");
692 692
 
693 693
 		}
694 694
 		// Cache the results for one hour.
695
-		set_transient( $key, $earnings, HOUR_IN_SECONDS );
695
+		set_transient($key, $earnings, HOUR_IN_SECONDS);
696 696
 	}
697 697
 
698
-	return round( $earnings, 2 );
698
+	return round($earnings, 2);
699 699
 }
700 700
 
701 701
 /**
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
  *
711 711
  * @return int $count     Sales
712 712
  */
713
-function give_get_sales_by_date( $day = null, $month_num = null, $year = null, $hour = null ) {
713
+function give_get_sales_by_date($day = null, $month_num = null, $year = null, $hour = null) {
714 714
 
715 715
 	// This is getting deprecated soon. Use Give_Payment_Stats with the get_sales() method instead.
716 716
 	$args = array(
@@ -718,14 +718,14 @@  discard block
 block discarded – undo
718 718
 		'nopaging'               => true,
719 719
 		'year'                   => $year,
720 720
 		'fields'                 => 'ids',
721
-		'post_status'            => array( 'publish' ),
721
+		'post_status'            => array('publish'),
722 722
 		'update_post_meta_cache' => false,
723 723
 		'update_post_term_cache' => false,
724 724
 	);
725 725
 
726
-	$show_free = apply_filters( 'give_sales_by_date_show_free', true, $args );
726
+	$show_free = apply_filters('give_sales_by_date_show_free', true, $args);
727 727
 
728
-	if ( false === $show_free ) {
728
+	if (false === $show_free) {
729 729
 		$args['meta_query'] = array(
730 730
 			array(
731 731
 				'key'     => '_give_payment_total',
@@ -736,33 +736,33 @@  discard block
 block discarded – undo
736 736
 		);
737 737
 	}
738 738
 
739
-	if ( ! empty( $month_num ) ) {
739
+	if ( ! empty($month_num)) {
740 740
 		$args['monthnum'] = $month_num;
741 741
 	}
742 742
 
743
-	if ( ! empty( $day ) ) {
743
+	if ( ! empty($day)) {
744 744
 		$args['day'] = $day;
745 745
 	}
746 746
 
747
-	if ( ! empty( $hour ) ) {
747
+	if ( ! empty($hour)) {
748 748
 		$args['hour'] = $hour;
749 749
 	}
750 750
 
751
-	$args = apply_filters( 'give_get_sales_by_date_args', $args );
751
+	$args = apply_filters('give_get_sales_by_date_args', $args);
752 752
 
753
-	$key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 );
753
+	$key = 'give_stats_'.substr(md5(serialize($args)), 0, 15);
754 754
 
755
-	if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) {
755
+	if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) {
756 756
 		$count = false;
757 757
 	} else {
758
-		$count = get_transient( $key );
758
+		$count = get_transient($key);
759 759
 	}
760 760
 
761
-	if ( false === $count ) {
762
-		$sales = new WP_Query( $args );
761
+	if (false === $count) {
762
+		$sales = new WP_Query($args);
763 763
 		$count = (int) $sales->post_count;
764 764
 		// Cache the results for one hour.
765
-		set_transient( $key, $count, HOUR_IN_SECONDS );
765
+		set_transient($key, $count, HOUR_IN_SECONDS);
766 766
 	}
767 767
 
768 768
 	return $count;
@@ -777,19 +777,19 @@  discard block
 block discarded – undo
777 777
  *
778 778
  * @return bool $ret True if complete, false otherwise.
779 779
  */
780
-function give_is_payment_complete( $payment_id ) {
781
-	$payment = new Give_Payment( $payment_id );
780
+function give_is_payment_complete($payment_id) {
781
+	$payment = new Give_Payment($payment_id);
782 782
 
783 783
 	$ret = false;
784 784
 
785
-	if ( $payment->ID > 0 ) {
785
+	if ($payment->ID > 0) {
786 786
 
787
-		if ( (int) $payment_id === (int) $payment->ID && 'publish' == $payment->status ) {
787
+		if ((int) $payment_id === (int) $payment->ID && 'publish' == $payment->status) {
788 788
 			$ret = true;
789 789
 		}
790 790
 	}
791 791
 
792
-	return apply_filters( 'give_is_payment_complete', $ret, $payment_id, $payment->post_status );
792
+	return apply_filters('give_is_payment_complete', $ret, $payment_id, $payment->post_status);
793 793
 }
794 794
 
795 795
 /**
@@ -815,57 +815,57 @@  discard block
 block discarded – undo
815 815
  */
816 816
 function give_get_total_earnings() {
817 817
 
818
-	$total = get_option( 'give_earnings_total', false );
818
+	$total = get_option('give_earnings_total', false);
819 819
 
820 820
 	// If no total stored in DB, use old method of calculating total earnings.
821
-	if ( false === $total ) {
821
+	if (false === $total) {
822 822
 
823 823
 		global $wpdb;
824 824
 
825
-		$total = get_transient( 'give_earnings_total' );
825
+		$total = get_transient('give_earnings_total');
826 826
 
827
-		if ( false === $total ) {
827
+		if (false === $total) {
828 828
 
829 829
 			$total = (float) 0;
830 830
 
831
-			$args = apply_filters( 'give_get_total_earnings_args', array(
831
+			$args = apply_filters('give_get_total_earnings_args', array(
832 832
 				'offset' => 0,
833
-				'number' => - 1,
834
-				'status' => array( 'publish' ),
833
+				'number' => -1,
834
+				'status' => array('publish'),
835 835
 				'fields' => 'ids',
836
-			) );
836
+			));
837 837
 
838
-			$payments = give_get_payments( $args );
839
-			if ( $payments ) {
838
+			$payments = give_get_payments($args);
839
+			if ($payments) {
840 840
 
841 841
 				/**
842 842
 				 * If performing a donation, we need to skip the very last payment in the database,
843 843
 				 * since it calls give_increase_total_earnings() on completion,
844 844
 				 * which results in duplicated earnings for the very first donation.
845 845
 				 */
846
-				if ( did_action( 'give_update_payment_status' ) ) {
847
-					array_pop( $payments );
846
+				if (did_action('give_update_payment_status')) {
847
+					array_pop($payments);
848 848
 				}
849 849
 
850
-				if ( ! empty( $payments ) ) {
851
-					$payments = implode( ',', $payments );
852
-					$total += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})" );
850
+				if ( ! empty($payments)) {
851
+					$payments = implode(',', $payments);
852
+					$total += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})");
853 853
 				}
854 854
 			}
855 855
 
856 856
 			// Cache results for 1 day. This cache is cleared automatically when a payment is made.
857
-			set_transient( 'give_earnings_total', $total, 86400 );
857
+			set_transient('give_earnings_total', $total, 86400);
858 858
 
859 859
 			// Store the total for the first time.
860
-			update_option( 'give_earnings_total', $total );
860
+			update_option('give_earnings_total', $total);
861 861
 		}
862 862
 	}
863 863
 
864
-	if ( $total < 0 ) {
864
+	if ($total < 0) {
865 865
 		$total = 0; // Don't ever show negative earnings.
866 866
 	}
867 867
 
868
-	return apply_filters( 'give_total_earnings', round( $total, give_currency_decimal_filter() ) );
868
+	return apply_filters('give_total_earnings', round($total, give_currency_decimal_filter()));
869 869
 }
870 870
 
871 871
 /**
@@ -878,10 +878,10 @@  discard block
 block discarded – undo
878 878
  *
879 879
  * @return float $total  Total earnings.
880 880
  */
881
-function give_increase_total_earnings( $amount = 0 ) {
881
+function give_increase_total_earnings($amount = 0) {
882 882
 	$total = give_get_total_earnings();
883 883
 	$total += $amount;
884
-	update_option( 'give_earnings_total', $total );
884
+	update_option('give_earnings_total', $total);
885 885
 
886 886
 	return $total;
887 887
 }
@@ -895,13 +895,13 @@  discard block
 block discarded – undo
895 895
  *
896 896
  * @return float $total Total earnings.
897 897
  */
898
-function give_decrease_total_earnings( $amount = 0 ) {
898
+function give_decrease_total_earnings($amount = 0) {
899 899
 	$total = give_get_total_earnings();
900 900
 	$total -= $amount;
901
-	if ( $total < 0 ) {
901
+	if ($total < 0) {
902 902
 		$total = 0;
903 903
 	}
904
-	update_option( 'give_earnings_total', $total );
904
+	update_option('give_earnings_total', $total);
905 905
 
906 906
 	return $total;
907 907
 }
@@ -917,10 +917,10 @@  discard block
 block discarded – undo
917 917
  *
918 918
  * @return mixed $meta Payment Meta.
919 919
  */
920
-function give_get_payment_meta( $payment_id = 0, $meta_key = '_give_payment_meta', $single = true ) {
921
-	$payment = new Give_Payment( $payment_id );
920
+function give_get_payment_meta($payment_id = 0, $meta_key = '_give_payment_meta', $single = true) {
921
+	$payment = new Give_Payment($payment_id);
922 922
 
923
-	return $payment->get_meta( $meta_key, $single );
923
+	return $payment->get_meta($meta_key, $single);
924 924
 }
925 925
 
926 926
 /**
@@ -933,10 +933,10 @@  discard block
 block discarded – undo
933 933
  *
934 934
  * @return mixed Meta ID if successful, false if unsuccessful.
935 935
  */
936
-function give_update_payment_meta( $payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '' ) {
937
-	$payment = new Give_Payment( $payment_id );
936
+function give_update_payment_meta($payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '') {
937
+	$payment = new Give_Payment($payment_id);
938 938
 
939
-	return $payment->update_meta( $meta_key, $meta_value, $prev_value );
939
+	return $payment->update_meta($meta_key, $meta_value, $prev_value);
940 940
 }
941 941
 
942 942
 /**
@@ -948,8 +948,8 @@  discard block
 block discarded – undo
948 948
  *
949 949
  * @return string $user_info User Info Meta Values.
950 950
  */
951
-function give_get_payment_meta_user_info( $payment_id ) {
952
-	$payment = new Give_Payment( $payment_id );
951
+function give_get_payment_meta_user_info($payment_id) {
952
+	$payment = new Give_Payment($payment_id);
953 953
 
954 954
 	return $payment->user_info;
955 955
 }
@@ -965,8 +965,8 @@  discard block
 block discarded – undo
965 965
  *
966 966
  * @return int $form_id Form ID.
967 967
  */
968
-function give_get_payment_form_id( $payment_id ) {
969
-	$payment = new Give_Payment( $payment_id );
968
+function give_get_payment_form_id($payment_id) {
969
+	$payment = new Give_Payment($payment_id);
970 970
 
971 971
 	return $payment->form_id;
972 972
 }
@@ -980,8 +980,8 @@  discard block
 block discarded – undo
980 980
  *
981 981
  * @return string $email User email.
982 982
  */
983
-function give_get_payment_user_email( $payment_id ) {
984
-	$payment = new Give_Payment( $payment_id );
983
+function give_get_payment_user_email($payment_id) {
984
+	$payment = new Give_Payment($payment_id);
985 985
 
986 986
 	return $payment->email;
987 987
 }
@@ -995,11 +995,11 @@  discard block
 block discarded – undo
995 995
  *
996 996
  * @return bool $is_guest_payment If the payment is associated with a user (false) or not (true)
997 997
  */
998
-function give_is_guest_payment( $payment_id ) {
999
-	$payment_user_id  = give_get_payment_user_id( $payment_id );
1000
-	$is_guest_payment = ! empty( $payment_user_id ) && $payment_user_id > 0 ? false : true;
998
+function give_is_guest_payment($payment_id) {
999
+	$payment_user_id  = give_get_payment_user_id($payment_id);
1000
+	$is_guest_payment = ! empty($payment_user_id) && $payment_user_id > 0 ? false : true;
1001 1001
 
1002
-	return (bool) apply_filters( 'give_is_guest_payment', $is_guest_payment, $payment_id );
1002
+	return (bool) apply_filters('give_is_guest_payment', $is_guest_payment, $payment_id);
1003 1003
 }
1004 1004
 
1005 1005
 /**
@@ -1011,8 +1011,8 @@  discard block
 block discarded – undo
1011 1011
  *
1012 1012
  * @return int $user_id User ID.
1013 1013
  */
1014
-function give_get_payment_user_id( $payment_id ) {
1015
-	$payment = new Give_Payment( $payment_id );
1014
+function give_get_payment_user_id($payment_id) {
1015
+	$payment = new Give_Payment($payment_id);
1016 1016
 
1017 1017
 	return $payment->user_id;
1018 1018
 }
@@ -1026,8 +1026,8 @@  discard block
 block discarded – undo
1026 1026
  *
1027 1027
  * @return int $customer_id Customer ID.
1028 1028
  */
1029
-function give_get_payment_customer_id( $payment_id ) {
1030
-	$payment = new Give_Payment( $payment_id );
1029
+function give_get_payment_customer_id($payment_id) {
1030
+	$payment = new Give_Payment($payment_id);
1031 1031
 
1032 1032
 	return $payment->customer_id;
1033 1033
 }
@@ -1041,8 +1041,8 @@  discard block
 block discarded – undo
1041 1041
  *
1042 1042
  * @return string $ip User IP.
1043 1043
  */
1044
-function give_get_payment_user_ip( $payment_id ) {
1045
-	$payment = new Give_Payment( $payment_id );
1044
+function give_get_payment_user_ip($payment_id) {
1045
+	$payment = new Give_Payment($payment_id);
1046 1046
 
1047 1047
 	return $payment->ip;
1048 1048
 }
@@ -1056,8 +1056,8 @@  discard block
 block discarded – undo
1056 1056
  *
1057 1057
  * @return string $date The date the payment was completed.
1058 1058
  */
1059
-function give_get_payment_completed_date( $payment_id = 0 ) {
1060
-	$payment = new Give_Payment( $payment_id );
1059
+function give_get_payment_completed_date($payment_id = 0) {
1060
+	$payment = new Give_Payment($payment_id);
1061 1061
 
1062 1062
 	return $payment->completed_date;
1063 1063
 }
@@ -1071,8 +1071,8 @@  discard block
 block discarded – undo
1071 1071
  *
1072 1072
  * @return string $gateway Gateway.
1073 1073
  */
1074
-function give_get_payment_gateway( $payment_id ) {
1075
-	$payment = new Give_Payment( $payment_id );
1074
+function give_get_payment_gateway($payment_id) {
1075
+	$payment = new Give_Payment($payment_id);
1076 1076
 
1077 1077
 	return $payment->gateway;
1078 1078
 }
@@ -1086,8 +1086,8 @@  discard block
 block discarded – undo
1086 1086
  *
1087 1087
  * @return string $currency The currency code.
1088 1088
  */
1089
-function give_get_payment_currency_code( $payment_id = 0 ) {
1090
-	$payment = new Give_Payment( $payment_id );
1089
+function give_get_payment_currency_code($payment_id = 0) {
1090
+	$payment = new Give_Payment($payment_id);
1091 1091
 
1092 1092
 	return $payment->currency;
1093 1093
 }
@@ -1101,10 +1101,10 @@  discard block
 block discarded – undo
1101 1101
  *
1102 1102
  * @return string $currency The currency name.
1103 1103
  */
1104
-function give_get_payment_currency( $payment_id = 0 ) {
1105
-	$currency = give_get_payment_currency_code( $payment_id );
1104
+function give_get_payment_currency($payment_id = 0) {
1105
+	$currency = give_get_payment_currency_code($payment_id);
1106 1106
 
1107
-	return apply_filters( 'give_payment_currency', give_get_currency_name( $currency ), $payment_id );
1107
+	return apply_filters('give_payment_currency', give_get_currency_name($currency), $payment_id);
1108 1108
 }
1109 1109
 
1110 1110
 /**
@@ -1116,8 +1116,8 @@  discard block
 block discarded – undo
1116 1116
  *
1117 1117
  * @return string $key Donation key.
1118 1118
  */
1119
-function give_get_payment_key( $payment_id = 0 ) {
1120
-	$payment = new Give_Payment( $payment_id );
1119
+function give_get_payment_key($payment_id = 0) {
1120
+	$payment = new Give_Payment($payment_id);
1121 1121
 
1122 1122
 	return $payment->key;
1123 1123
 }
@@ -1133,8 +1133,8 @@  discard block
 block discarded – undo
1133 1133
  *
1134 1134
  * @return string $number Payment order number.
1135 1135
  */
1136
-function give_get_payment_number( $payment_id = 0 ) {
1137
-	$payment = new Give_Payment( $payment_id );
1136
+function give_get_payment_number($payment_id = 0) {
1137
+	$payment = new Give_Payment($payment_id);
1138 1138
 
1139 1139
 	return $payment->number;
1140 1140
 }
@@ -1148,23 +1148,23 @@  discard block
 block discarded – undo
1148 1148
  *
1149 1149
  * @return string      The formatted payment number.
1150 1150
  */
1151
-function give_format_payment_number( $number ) {
1151
+function give_format_payment_number($number) {
1152 1152
 
1153
-	if ( ! give_get_option( 'enable_sequential' ) ) {
1153
+	if ( ! give_get_option('enable_sequential')) {
1154 1154
 		return $number;
1155 1155
 	}
1156 1156
 
1157
-	if ( ! is_numeric( $number ) ) {
1157
+	if ( ! is_numeric($number)) {
1158 1158
 		return $number;
1159 1159
 	}
1160 1160
 
1161
-	$prefix  = give_get_option( 'sequential_prefix' );
1162
-	$number  = absint( $number );
1163
-	$postfix = give_get_option( 'sequential_postfix' );
1161
+	$prefix  = give_get_option('sequential_prefix');
1162
+	$number  = absint($number);
1163
+	$postfix = give_get_option('sequential_postfix');
1164 1164
 
1165
-	$formatted_number = $prefix . $number . $postfix;
1165
+	$formatted_number = $prefix.$number.$postfix;
1166 1166
 
1167
-	return apply_filters( 'give_format_payment_number', $formatted_number, $prefix, $number, $postfix );
1167
+	return apply_filters('give_format_payment_number', $formatted_number, $prefix, $number, $postfix);
1168 1168
 }
1169 1169
 
1170 1170
 /**
@@ -1177,17 +1177,17 @@  discard block
 block discarded – undo
1177 1177
  */
1178 1178
 function give_get_next_payment_number() {
1179 1179
 
1180
-	if ( ! give_get_option( 'enable_sequential' ) ) {
1180
+	if ( ! give_get_option('enable_sequential')) {
1181 1181
 		return false;
1182 1182
 	}
1183 1183
 
1184
-	$number           = get_option( 'give_last_payment_number' );
1185
-	$start            = give_get_option( 'sequential_start', 1 );
1184
+	$number           = get_option('give_last_payment_number');
1185
+	$start            = give_get_option('sequential_start', 1);
1186 1186
 	$increment_number = true;
1187 1187
 
1188
-	if ( false !== $number ) {
1188
+	if (false !== $number) {
1189 1189
 
1190
-		if ( empty( $number ) ) {
1190
+		if (empty($number)) {
1191 1191
 
1192 1192
 			$number           = $start;
1193 1193
 			$increment_number = false;
@@ -1196,24 +1196,24 @@  discard block
 block discarded – undo
1196 1196
 	} else {
1197 1197
 
1198 1198
 		// This case handles the first addition of the new option, as well as if it get's deleted for any reason.
1199
-		$payments     = new Give_Payments_Query( array(
1199
+		$payments = new Give_Payments_Query(array(
1200 1200
 			'number'  => 1,
1201 1201
 			'order'   => 'DESC',
1202 1202
 			'orderby' => 'ID',
1203 1203
 			'output'  => 'posts',
1204 1204
 			'fields'  => 'ids',
1205
-		) );
1205
+		));
1206 1206
 		$last_payment = $payments->get_payments();
1207 1207
 
1208
-		if ( ! empty( $last_payment ) ) {
1208
+		if ( ! empty($last_payment)) {
1209 1209
 
1210
-			$number = give_get_payment_number( $last_payment[0] );
1210
+			$number = give_get_payment_number($last_payment[0]);
1211 1211
 
1212 1212
 		}
1213 1213
 
1214
-		if ( ! empty( $number ) && $number !== (int) $last_payment[0] ) {
1214
+		if ( ! empty($number) && $number !== (int) $last_payment[0]) {
1215 1215
 
1216
-			$number = give_remove_payment_prefix_postfix( $number );
1216
+			$number = give_remove_payment_prefix_postfix($number);
1217 1217
 
1218 1218
 		} else {
1219 1219
 
@@ -1222,13 +1222,13 @@  discard block
 block discarded – undo
1222 1222
 		}
1223 1223
 	}
1224 1224
 
1225
-	$increment_number = apply_filters( 'give_increment_payment_number', $increment_number, $number );
1225
+	$increment_number = apply_filters('give_increment_payment_number', $increment_number, $number);
1226 1226
 
1227
-	if ( $increment_number ) {
1228
-		$number ++;
1227
+	if ($increment_number) {
1228
+		$number++;
1229 1229
 	}
1230 1230
 
1231
-	return apply_filters( 'give_get_next_payment_number', $number );
1231
+	return apply_filters('give_get_next_payment_number', $number);
1232 1232
 }
1233 1233
 
1234 1234
 /**
@@ -1240,25 +1240,25 @@  discard block
 block discarded – undo
1240 1240
  *
1241 1241
  * @return string The new Payment number without prefix and postfix.
1242 1242
  */
1243
-function give_remove_payment_prefix_postfix( $number ) {
1243
+function give_remove_payment_prefix_postfix($number) {
1244 1244
 
1245
-	$prefix  = give_get_option( 'sequential_prefix' );
1246
-	$postfix = give_get_option( 'sequential_postfix' );
1245
+	$prefix  = give_get_option('sequential_prefix');
1246
+	$postfix = give_get_option('sequential_postfix');
1247 1247
 
1248 1248
 	// Remove prefix.
1249
-	$number = preg_replace( '/' . $prefix . '/', '', $number, 1 );
1249
+	$number = preg_replace('/'.$prefix.'/', '', $number, 1);
1250 1250
 
1251 1251
 	// Remove the postfix.
1252
-	$length      = strlen( $number );
1253
-	$postfix_pos = strrpos( $number, $postfix );
1254
-	if ( false !== $postfix_pos ) {
1255
-		$number = substr_replace( $number, '', $postfix_pos, $length );
1252
+	$length      = strlen($number);
1253
+	$postfix_pos = strrpos($number, $postfix);
1254
+	if (false !== $postfix_pos) {
1255
+		$number = substr_replace($number, '', $postfix_pos, $length);
1256 1256
 	}
1257 1257
 
1258 1258
 	// Ensure it's a whole number.
1259
-	$number = intval( $number );
1259
+	$number = intval($number);
1260 1260
 
1261
-	return apply_filters( 'give_remove_payment_prefix_postfix', $number, $prefix, $postfix );
1261
+	return apply_filters('give_remove_payment_prefix_postfix', $number, $prefix, $postfix);
1262 1262
 
1263 1263
 }
1264 1264
 
@@ -1274,10 +1274,10 @@  discard block
 block discarded – undo
1274 1274
  *
1275 1275
  * @return string $amount Fully formatted payment amount.
1276 1276
  */
1277
-function give_payment_amount( $payment_id = 0 ) {
1278
-	$amount = give_get_payment_amount( $payment_id );
1277
+function give_payment_amount($payment_id = 0) {
1278
+	$amount = give_get_payment_amount($payment_id);
1279 1279
 
1280
-	return give_currency_filter( give_format_amount( $amount ), give_get_payment_currency_code( $payment_id ) );
1280
+	return give_currency_filter(give_format_amount($amount), give_get_payment_currency_code($payment_id));
1281 1281
 }
1282 1282
 
1283 1283
 /**
@@ -1290,11 +1290,11 @@  discard block
 block discarded – undo
1290 1290
  *
1291 1291
  * @return mixed|void
1292 1292
  */
1293
-function give_get_payment_amount( $payment_id ) {
1293
+function give_get_payment_amount($payment_id) {
1294 1294
 
1295
-	$payment = new Give_Payment( $payment_id );
1295
+	$payment = new Give_Payment($payment_id);
1296 1296
 
1297
-	return apply_filters( 'give_payment_amount', floatval( $payment->total ), $payment_id );
1297
+	return apply_filters('give_payment_amount', floatval($payment->total), $payment_id);
1298 1298
 }
1299 1299
 
1300 1300
 /**
@@ -1310,10 +1310,10 @@  discard block
 block discarded – undo
1310 1310
  *
1311 1311
  * @return array Fully formatted payment subtotal.
1312 1312
  */
1313
-function give_payment_subtotal( $payment_id = 0 ) {
1314
-	$subtotal = give_get_payment_subtotal( $payment_id );
1313
+function give_payment_subtotal($payment_id = 0) {
1314
+	$subtotal = give_get_payment_subtotal($payment_id);
1315 1315
 
1316
-	return give_currency_filter( give_format_amount( $subtotal ), give_get_payment_currency_code( $payment_id ) );
1316
+	return give_currency_filter(give_format_amount($subtotal), give_get_payment_currency_code($payment_id));
1317 1317
 }
1318 1318
 
1319 1319
 /**
@@ -1327,8 +1327,8 @@  discard block
 block discarded – undo
1327 1327
  *
1328 1328
  * @return float $subtotal Subtotal for payment (non formatted).
1329 1329
  */
1330
-function give_get_payment_subtotal( $payment_id = 0 ) {
1331
-	$payment = new G_Payment( $payment_id );
1330
+function give_get_payment_subtotal($payment_id = 0) {
1331
+	$payment = new G_Payment($payment_id);
1332 1332
 
1333 1333
 	return $payment->subtotal;
1334 1334
 }
@@ -1343,10 +1343,10 @@  discard block
 block discarded – undo
1343 1343
  *
1344 1344
  * @return mixed array if payment fees found, false otherwise.
1345 1345
  */
1346
-function give_get_payment_fees( $payment_id = 0, $type = 'all' ) {
1347
-	$payment = new Give_Payment( $payment_id );
1346
+function give_get_payment_fees($payment_id = 0, $type = 'all') {
1347
+	$payment = new Give_Payment($payment_id);
1348 1348
 
1349
-	return $payment->get_fees( $type );
1349
+	return $payment->get_fees($type);
1350 1350
 }
1351 1351
 
1352 1352
 /**
@@ -1358,8 +1358,8 @@  discard block
 block discarded – undo
1358 1358
  *
1359 1359
  * @return string The donation ID.
1360 1360
  */
1361
-function give_get_payment_transaction_id( $payment_id = 0 ) {
1362
-	$payment = new Give_Payment( $payment_id );
1361
+function give_get_payment_transaction_id($payment_id = 0) {
1362
+	$payment = new Give_Payment($payment_id);
1363 1363
 
1364 1364
 	return $payment->transaction_id;
1365 1365
 }
@@ -1374,15 +1374,15 @@  discard block
 block discarded – undo
1374 1374
  *
1375 1375
  * @return bool|mixed
1376 1376
  */
1377
-function give_set_payment_transaction_id( $payment_id = 0, $transaction_id = '' ) {
1377
+function give_set_payment_transaction_id($payment_id = 0, $transaction_id = '') {
1378 1378
 
1379
-	if ( empty( $payment_id ) || empty( $transaction_id ) ) {
1379
+	if (empty($payment_id) || empty($transaction_id)) {
1380 1380
 		return false;
1381 1381
 	}
1382 1382
 
1383
-	$transaction_id = apply_filters( 'give_set_payment_transaction_id', $transaction_id, $payment_id );
1383
+	$transaction_id = apply_filters('give_set_payment_transaction_id', $transaction_id, $payment_id);
1384 1384
 
1385
-	return give_update_payment_meta( $payment_id, '_give_payment_transaction_id', $transaction_id );
1385
+	return give_update_payment_meta($payment_id, '_give_payment_transaction_id', $transaction_id);
1386 1386
 }
1387 1387
 
1388 1388
 /**
@@ -1395,12 +1395,12 @@  discard block
 block discarded – undo
1395 1395
  *
1396 1396
  * @return int $purchase Donation ID.
1397 1397
  */
1398
-function give_get_purchase_id_by_key( $key ) {
1398
+function give_get_purchase_id_by_key($key) {
1399 1399
 	global $wpdb;
1400 1400
 
1401
-	$purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key ) );
1401
+	$purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key));
1402 1402
 
1403
-	if ( $purchase != null ) {
1403
+	if ($purchase != null) {
1404 1404
 		return $purchase;
1405 1405
 	}
1406 1406
 
@@ -1418,12 +1418,12 @@  discard block
 block discarded – undo
1418 1418
  *
1419 1419
  * @return int $purchase Donation ID.
1420 1420
  */
1421
-function give_get_purchase_id_by_transaction_id( $key ) {
1421
+function give_get_purchase_id_by_transaction_id($key) {
1422 1422
 	global $wpdb;
1423 1423
 
1424
-	$purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key ) );
1424
+	$purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key));
1425 1425
 
1426
-	if ( $purchase != null ) {
1426
+	if ($purchase != null) {
1427 1427
 		return $purchase;
1428 1428
 	}
1429 1429
 
@@ -1440,19 +1440,19 @@  discard block
 block discarded – undo
1440 1440
  *
1441 1441
  * @return array $notes Donation Notes
1442 1442
  */
1443
-function give_get_payment_notes( $payment_id = 0, $search = '' ) {
1443
+function give_get_payment_notes($payment_id = 0, $search = '') {
1444 1444
 
1445
-	if ( empty( $payment_id ) && empty( $search ) ) {
1445
+	if (empty($payment_id) && empty($search)) {
1446 1446
 		return false;
1447 1447
 	}
1448 1448
 
1449
-	remove_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1450
-	remove_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10 );
1449
+	remove_action('pre_get_comments', 'give_hide_payment_notes', 10);
1450
+	remove_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10);
1451 1451
 
1452
-	$notes = get_comments( array( 'post_id' => $payment_id, 'order' => 'ASC', 'search' => $search ) );
1452
+	$notes = get_comments(array('post_id' => $payment_id, 'order' => 'ASC', 'search' => $search));
1453 1453
 
1454
-	add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1455
-	add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 );
1454
+	add_action('pre_get_comments', 'give_hide_payment_notes', 10);
1455
+	add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2);
1456 1456
 
1457 1457
 	return $notes;
1458 1458
 }
@@ -1468,8 +1468,8 @@  discard block
 block discarded – undo
1468 1468
  *
1469 1469
  * @return int The new note ID
1470 1470
  */
1471
-function give_insert_payment_note( $payment_id = 0, $note = '' ) {
1472
-	if ( empty( $payment_id ) ) {
1471
+function give_insert_payment_note($payment_id = 0, $note = '') {
1472
+	if (empty($payment_id)) {
1473 1473
 		return false;
1474 1474
 	}
1475 1475
 
@@ -1481,14 +1481,14 @@  discard block
 block discarded – undo
1481 1481
 	 * @param int    $payment_id Payment ID.
1482 1482
 	 * @param string $note       The note.
1483 1483
 	 */
1484
-	do_action( 'give_pre_insert_payment_note', $payment_id, $note );
1484
+	do_action('give_pre_insert_payment_note', $payment_id, $note);
1485 1485
 
1486
-	$note_id = wp_insert_comment( wp_filter_comment( array(
1486
+	$note_id = wp_insert_comment(wp_filter_comment(array(
1487 1487
 		'comment_post_ID'      => $payment_id,
1488 1488
 		'comment_content'      => $note,
1489 1489
 		'user_id'              => is_admin() ? get_current_user_id() : 0,
1490
-		'comment_date'         => current_time( 'mysql' ),
1491
-		'comment_date_gmt'     => current_time( 'mysql', 1 ),
1490
+		'comment_date'         => current_time('mysql'),
1491
+		'comment_date_gmt'     => current_time('mysql', 1),
1492 1492
 		'comment_approved'     => 1,
1493 1493
 		'comment_parent'       => 0,
1494 1494
 		'comment_author'       => '',
@@ -1497,7 +1497,7 @@  discard block
 block discarded – undo
1497 1497
 		'comment_author_email' => '',
1498 1498
 		'comment_type'         => 'give_payment_note',
1499 1499
 
1500
-	) ) );
1500
+	)));
1501 1501
 
1502 1502
 	/**
1503 1503
 	 * Fires after payment note inserted.
@@ -1508,7 +1508,7 @@  discard block
 block discarded – undo
1508 1508
 	 * @param int    $payment_id Payment ID.
1509 1509
 	 * @param string $note       The note.
1510 1510
 	 */
1511
-	do_action( 'give_insert_payment_note', $note_id, $payment_id, $note );
1511
+	do_action('give_insert_payment_note', $note_id, $payment_id, $note);
1512 1512
 
1513 1513
 	return $note_id;
1514 1514
 }
@@ -1523,8 +1523,8 @@  discard block
 block discarded – undo
1523 1523
  *
1524 1524
  * @return bool True on success, false otherwise.
1525 1525
  */
1526
-function give_delete_payment_note( $comment_id = 0, $payment_id = 0 ) {
1527
-	if ( empty( $comment_id ) ) {
1526
+function give_delete_payment_note($comment_id = 0, $payment_id = 0) {
1527
+	if (empty($comment_id)) {
1528 1528
 		return false;
1529 1529
 	}
1530 1530
 
@@ -1536,9 +1536,9 @@  discard block
 block discarded – undo
1536 1536
 	 * @param int $comment_id Note ID.
1537 1537
 	 * @param int $payment_id Payment ID.
1538 1538
 	 */
1539
-	do_action( 'give_pre_delete_payment_note', $comment_id, $payment_id );
1539
+	do_action('give_pre_delete_payment_note', $comment_id, $payment_id);
1540 1540
 
1541
-	$ret = wp_delete_comment( $comment_id, true );
1541
+	$ret = wp_delete_comment($comment_id, true);
1542 1542
 
1543 1543
 	/**
1544 1544
 	 * Fires after donation note deleted.
@@ -1548,7 +1548,7 @@  discard block
 block discarded – undo
1548 1548
 	 * @param int $comment_id Note ID.
1549 1549
 	 * @param int $payment_id Payment ID.
1550 1550
 	 */
1551
-	do_action( 'give_post_delete_payment_note', $comment_id, $payment_id );
1551
+	do_action('give_post_delete_payment_note', $comment_id, $payment_id);
1552 1552
 
1553 1553
 	return $ret;
1554 1554
 }
@@ -1563,34 +1563,34 @@  discard block
 block discarded – undo
1563 1563
  *
1564 1564
  * @return string
1565 1565
  */
1566
-function give_get_payment_note_html( $note, $payment_id = 0 ) {
1566
+function give_get_payment_note_html($note, $payment_id = 0) {
1567 1567
 
1568
-	if ( is_numeric( $note ) ) {
1569
-		$note = get_comment( $note );
1568
+	if (is_numeric($note)) {
1569
+		$note = get_comment($note);
1570 1570
 	}
1571 1571
 
1572
-	if ( ! empty( $note->user_id ) ) {
1573
-		$user = get_userdata( $note->user_id );
1572
+	if ( ! empty($note->user_id)) {
1573
+		$user = get_userdata($note->user_id);
1574 1574
 		$user = $user->display_name;
1575 1575
 	} else {
1576
-		$user = esc_html__( 'System', 'give' );
1576
+		$user = esc_html__('System', 'give');
1577 1577
 	}
1578 1578
 
1579
-	$date_format = give_date_format() . ', ' . get_option( 'time_format' );
1579
+	$date_format = give_date_format().', '.get_option('time_format');
1580 1580
 
1581
-	$delete_note_url = wp_nonce_url( add_query_arg( array(
1581
+	$delete_note_url = wp_nonce_url(add_query_arg(array(
1582 1582
 		'give-action' => 'delete_payment_note',
1583 1583
 		'note_id'     => $note->comment_ID,
1584 1584
 		'payment_id'  => $payment_id,
1585
-	) ),
1586
-		'give_delete_payment_note_' . $note->comment_ID
1585
+	)),
1586
+		'give_delete_payment_note_'.$note->comment_ID
1587 1587
 	);
1588 1588
 
1589
-	$note_html = '<div class="give-payment-note" id="give-payment-note-' . $note->comment_ID . '">';
1589
+	$note_html = '<div class="give-payment-note" id="give-payment-note-'.$note->comment_ID.'">';
1590 1590
 	$note_html .= '<p>';
1591
-	$note_html .= '<strong>' . $user . '</strong>&nbsp;&ndash;&nbsp;<span style="color:#aaa;font-style:italic;">' . date_i18n( $date_format, strtotime( $note->comment_date ) ) . '</span><br/>';
1591
+	$note_html .= '<strong>'.$user.'</strong>&nbsp;&ndash;&nbsp;<span style="color:#aaa;font-style:italic;">'.date_i18n($date_format, strtotime($note->comment_date)).'</span><br/>';
1592 1592
 	$note_html .= $note->comment_content;
1593
-	$note_html .= '&nbsp;&ndash;&nbsp;<a href="' . esc_url( $delete_note_url ) . '" class="give-delete-payment-note" data-note-id="' . absint( $note->comment_ID ) . '" data-payment-id="' . absint( $payment_id ) . '" aria-label="' . esc_attr__( 'Delete this donation note.', 'give' ) . '">' . esc_html__( 'Delete', 'give' ) . '</a>';
1593
+	$note_html .= '&nbsp;&ndash;&nbsp;<a href="'.esc_url($delete_note_url).'" class="give-delete-payment-note" data-note-id="'.absint($note->comment_ID).'" data-payment-id="'.absint($payment_id).'" aria-label="'.esc_attr__('Delete this donation note.', 'give').'">'.esc_html__('Delete', 'give').'</a>';
1594 1594
 	$note_html .= '</p>';
1595 1595
 	$note_html .= '</div>';
1596 1596
 
@@ -1608,18 +1608,18 @@  discard block
 block discarded – undo
1608 1608
  *
1609 1609
  * @return void
1610 1610
  */
1611
-function give_hide_payment_notes( $query ) {
1612
-	if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '>=' ) ) {
1613
-		$types = isset( $query->query_vars['type__not_in'] ) ? $query->query_vars['type__not_in'] : array();
1614
-		if ( ! is_array( $types ) ) {
1615
-			$types = array( $types );
1611
+function give_hide_payment_notes($query) {
1612
+	if (version_compare(floatval(get_bloginfo('version')), '4.1', '>=')) {
1613
+		$types = isset($query->query_vars['type__not_in']) ? $query->query_vars['type__not_in'] : array();
1614
+		if ( ! is_array($types)) {
1615
+			$types = array($types);
1616 1616
 		}
1617 1617
 		$types[]                           = 'give_payment_note';
1618 1618
 		$query->query_vars['type__not_in'] = $types;
1619 1619
 	}
1620 1620
 }
1621 1621
 
1622
-add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1622
+add_action('pre_get_comments', 'give_hide_payment_notes', 10);
1623 1623
 
1624 1624
 /**
1625 1625
  * Exclude notes (comments) on give_payment post type from showing in Recent Comments widgets
@@ -1631,15 +1631,15 @@  discard block
 block discarded – undo
1631 1631
  *
1632 1632
  * @return array $clauses Updated comment clauses.
1633 1633
  */
1634
-function give_hide_payment_notes_pre_41( $clauses, $wp_comment_query ) {
1635
-	if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '<' ) ) {
1634
+function give_hide_payment_notes_pre_41($clauses, $wp_comment_query) {
1635
+	if (version_compare(floatval(get_bloginfo('version')), '4.1', '<')) {
1636 1636
 		$clauses['where'] .= ' AND comment_type != "give_payment_note"';
1637 1637
 	}
1638 1638
 
1639 1639
 	return $clauses;
1640 1640
 }
1641 1641
 
1642
-add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 );
1642
+add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2);
1643 1643
 
1644 1644
 
1645 1645
 /**
@@ -1652,15 +1652,15 @@  discard block
 block discarded – undo
1652 1652
  *
1653 1653
  * @return string $where
1654 1654
  */
1655
-function give_hide_payment_notes_from_feeds( $where, $wp_comment_query ) {
1655
+function give_hide_payment_notes_from_feeds($where, $wp_comment_query) {
1656 1656
 	global $wpdb;
1657 1657
 
1658
-	$where .= $wpdb->prepare( ' AND comment_type != %s', 'give_payment_note' );
1658
+	$where .= $wpdb->prepare(' AND comment_type != %s', 'give_payment_note');
1659 1659
 
1660 1660
 	return $where;
1661 1661
 }
1662 1662
 
1663
-add_filter( 'comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2 );
1663
+add_filter('comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2);
1664 1664
 
1665 1665
 
1666 1666
 /**
@@ -1674,32 +1674,32 @@  discard block
 block discarded – undo
1674 1674
  *
1675 1675
  * @return array Array of comment counts.
1676 1676
  */
1677
-function give_remove_payment_notes_in_comment_counts( $stats, $post_id ) {
1677
+function give_remove_payment_notes_in_comment_counts($stats, $post_id) {
1678 1678
 	global $wpdb, $pagenow;
1679 1679
 
1680
-	if ( 'index.php' != $pagenow ) {
1680
+	if ('index.php' != $pagenow) {
1681 1681
 		return $stats;
1682 1682
 	}
1683 1683
 
1684 1684
 	$post_id = (int) $post_id;
1685 1685
 
1686
-	if ( apply_filters( 'give_count_payment_notes_in_comments', false ) ) {
1686
+	if (apply_filters('give_count_payment_notes_in_comments', false)) {
1687 1687
 		return $stats;
1688 1688
 	}
1689 1689
 
1690
-	$stats = wp_cache_get( "comments-{$post_id}", 'counts' );
1690
+	$stats = wp_cache_get("comments-{$post_id}", 'counts');
1691 1691
 
1692
-	if ( false !== $stats ) {
1692
+	if (false !== $stats) {
1693 1693
 		return $stats;
1694 1694
 	}
1695 1695
 
1696 1696
 	$where = 'WHERE comment_type != "give_payment_note"';
1697 1697
 
1698
-	if ( $post_id > 0 ) {
1699
-		$where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id );
1698
+	if ($post_id > 0) {
1699
+		$where .= $wpdb->prepare(' AND comment_post_ID = %d', $post_id);
1700 1700
 	}
1701 1701
 
1702
-	$count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A );
1702
+	$count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A);
1703 1703
 
1704 1704
 	$total    = 0;
1705 1705
 	$approved = array(
@@ -1709,30 +1709,30 @@  discard block
 block discarded – undo
1709 1709
 		'trash'        => 'trash',
1710 1710
 		'post-trashed' => 'post-trashed',
1711 1711
 	);
1712
-	foreach ( (array) $count as $row ) {
1712
+	foreach ((array) $count as $row) {
1713 1713
 		// Don't count post-trashed toward totals.
1714
-		if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) {
1714
+		if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) {
1715 1715
 			$total += $row['num_comments'];
1716 1716
 		}
1717
-		if ( isset( $approved[ $row['comment_approved'] ] ) ) {
1718
-			$stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments'];
1717
+		if (isset($approved[$row['comment_approved']])) {
1718
+			$stats[$approved[$row['comment_approved']]] = $row['num_comments'];
1719 1719
 		}
1720 1720
 	}
1721 1721
 
1722 1722
 	$stats['total_comments'] = $total;
1723
-	foreach ( $approved as $key ) {
1724
-		if ( empty( $stats[ $key ] ) ) {
1725
-			$stats[ $key ] = 0;
1723
+	foreach ($approved as $key) {
1724
+		if (empty($stats[$key])) {
1725
+			$stats[$key] = 0;
1726 1726
 		}
1727 1727
 	}
1728 1728
 
1729 1729
 	$stats = (object) $stats;
1730
-	wp_cache_set( "comments-{$post_id}", $stats, 'counts' );
1730
+	wp_cache_set("comments-{$post_id}", $stats, 'counts');
1731 1731
 
1732 1732
 	return $stats;
1733 1733
 }
1734 1734
 
1735
-add_filter( 'wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2 );
1735
+add_filter('wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2);
1736 1736
 
1737 1737
 
1738 1738
 /**
@@ -1745,9 +1745,9 @@  discard block
 block discarded – undo
1745 1745
  *
1746 1746
  * @return string $where Modified where clause.
1747 1747
  */
1748
-function give_filter_where_older_than_week( $where = '' ) {
1748
+function give_filter_where_older_than_week($where = '') {
1749 1749
 	// Payments older than one week.
1750
-	$start = date( 'Y-m-d', strtotime( '-7 days' ) );
1750
+	$start = date('Y-m-d', strtotime('-7 days'));
1751 1751
 	$where .= " AND post_date <= '{$start}'";
1752 1752
 
1753 1753
 	return $where;
@@ -1767,38 +1767,38 @@  discard block
 block discarded – undo
1767 1767
  *
1768 1768
  * @return string $form_title Returns the full title if $only_level is false, otherwise returns the levels title.
1769 1769
  */
1770
-function give_get_payment_form_title( $payment_meta, $only_level = false, $separator = '' ) {
1770
+function give_get_payment_form_title($payment_meta, $only_level = false, $separator = '') {
1771 1771
 
1772
-	$form_id    = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0;
1773
-	$price_id   = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null;
1774
-	$form_title = isset( $payment_meta['form_title'] ) ? $payment_meta['form_title'] : '';
1772
+	$form_id    = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0;
1773
+	$price_id   = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null;
1774
+	$form_title = isset($payment_meta['form_title']) ? $payment_meta['form_title'] : '';
1775 1775
 
1776
-	if ( $only_level == true ) {
1776
+	if ($only_level == true) {
1777 1777
 		$form_title = '';
1778 1778
 	}
1779 1779
 
1780 1780
 	//If multi-level, append to the form title.
1781
-	if ( give_has_variable_prices( $form_id ) ) {
1781
+	if (give_has_variable_prices($form_id)) {
1782 1782
 
1783 1783
 		//Only add separator if there is a form title.
1784
-		if ( ! empty( $form_title ) ) {
1785
-			$form_title .= ' ' . $separator . ' ';
1784
+		if ( ! empty($form_title)) {
1785
+			$form_title .= ' '.$separator.' ';
1786 1786
 		}
1787 1787
 
1788 1788
 		$form_title .= '<span class="donation-level-text-wrap">';
1789 1789
 
1790
-		if ( $price_id == 'custom' ) {
1791
-			$custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true );
1792
-			$form_title .= ! empty( $custom_amount_text ) ? $custom_amount_text : __( 'Custom Amount', 'give' );
1790
+		if ($price_id == 'custom') {
1791
+			$custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true);
1792
+			$form_title .= ! empty($custom_amount_text) ? $custom_amount_text : __('Custom Amount', 'give');
1793 1793
 		} else {
1794
-			$form_title .= give_get_price_option_name( $form_id, $price_id );
1794
+			$form_title .= give_get_price_option_name($form_id, $price_id);
1795 1795
 		}
1796 1796
 
1797 1797
 		$form_title .= '</span>';
1798 1798
 
1799 1799
 	}
1800 1800
 
1801
-	return apply_filters( 'give_get_payment_form_title', $form_title, $payment_meta );
1801
+	return apply_filters('give_get_payment_form_title', $form_title, $payment_meta);
1802 1802
 
1803 1803
 }
1804 1804
 
@@ -1812,20 +1812,20 @@  discard block
 block discarded – undo
1812 1812
  *
1813 1813
  * @return string $price_id
1814 1814
  */
1815
-function give_get_price_id( $form_id, $price ) {
1815
+function give_get_price_id($form_id, $price) {
1816 1816
 
1817 1817
 	$price_id = 0;
1818 1818
 
1819
-	if ( give_has_variable_prices( $form_id ) ) {
1819
+	if (give_has_variable_prices($form_id)) {
1820 1820
 
1821
-		$levels = maybe_unserialize( get_post_meta( $form_id, '_give_donation_levels', true ) );
1821
+		$levels = maybe_unserialize(get_post_meta($form_id, '_give_donation_levels', true));
1822 1822
 
1823
-		foreach ( $levels as $level ) {
1823
+		foreach ($levels as $level) {
1824 1824
 
1825
-			$level_amount = (float) give_sanitize_amount( $level['_give_amount'] );
1825
+			$level_amount = (float) give_sanitize_amount($level['_give_amount']);
1826 1826
 
1827 1827
 			// Check that this indeed the recurring price.
1828
-			if ( $level_amount == $price ) {
1828
+			if ($level_amount == $price) {
1829 1829
 
1830 1830
 				$price_id = $level['_give_id']['level_id'];
1831 1831
 
@@ -1850,10 +1850,10 @@  discard block
 block discarded – undo
1850 1850
  *
1851 1851
  * @return string|void
1852 1852
  */
1853
-function give_get_form_dropdown( $args = array(), $echo = false ) {
1854
-	$form_dropdown_html = Give()->html->forms_dropdown( $args );
1853
+function give_get_form_dropdown($args = array(), $echo = false) {
1854
+	$form_dropdown_html = Give()->html->forms_dropdown($args);
1855 1855
 
1856
-	if ( ! $echo ) {
1856
+	if ( ! $echo) {
1857 1857
 		return $form_dropdown_html;
1858 1858
 	}
1859 1859
 
@@ -1870,17 +1870,17 @@  discard block
 block discarded – undo
1870 1870
  *
1871 1871
  * @return string|void
1872 1872
  */
1873
-function give_get_form_variable_price_dropdown( $args = array(), $echo = false ) {
1873
+function give_get_form_variable_price_dropdown($args = array(), $echo = false) {
1874 1874
 
1875 1875
 	// Check for give form id.
1876
-	if ( empty( $args['id'] ) ) {
1876
+	if (empty($args['id'])) {
1877 1877
 		return false;
1878 1878
 	}
1879 1879
 
1880
-	$form = new Give_Donate_Form( $args['id'] );
1880
+	$form = new Give_Donate_Form($args['id']);
1881 1881
 
1882 1882
 	// Check if form has variable prices or not.
1883
-	if ( ! $form->ID || ! $form->has_variable_prices() ) {
1883
+	if ( ! $form->ID || ! $form->has_variable_prices()) {
1884 1884
 		return false;
1885 1885
 	}
1886 1886
 
@@ -1888,22 +1888,22 @@  discard block
 block discarded – undo
1888 1888
 	$variable_price_options = array();
1889 1889
 
1890 1890
 	// Check if multi donation form support custom donation or not.
1891
-	if ( $form->is_custom_price_mode() ) {
1892
-		$variable_price_options['custom'] = _x( 'Custom', 'custom donation dropdown item', 'give' );
1891
+	if ($form->is_custom_price_mode()) {
1892
+		$variable_price_options['custom'] = _x('Custom', 'custom donation dropdown item', 'give');
1893 1893
 	}
1894 1894
 
1895 1895
 	// Get variable price and ID from variable price array.
1896
-	foreach ( $variable_prices as $variable_price ) {
1897
-		$variable_price_options[ $variable_price['_give_id']['level_id'] ] = ! empty( $variable_price['_give_text'] ) ? $variable_price['_give_text'] : give_currency_filter( give_format_amount( $variable_price['_give_amount'] ) );
1896
+	foreach ($variable_prices as $variable_price) {
1897
+		$variable_price_options[$variable_price['_give_id']['level_id']] = ! empty($variable_price['_give_text']) ? $variable_price['_give_text'] : give_currency_filter(give_format_amount($variable_price['_give_amount']));
1898 1898
 	}
1899 1899
 
1900 1900
 	// Update options.
1901
-	$args = array_merge( $args, array( 'options' => $variable_price_options ) );
1901
+	$args = array_merge($args, array('options' => $variable_price_options));
1902 1902
 
1903 1903
 	// Generate select html.
1904
-	$form_dropdown_html = Give()->html->select( $args );
1904
+	$form_dropdown_html = Give()->html->select($args);
1905 1905
 
1906
-	if ( ! $echo ) {
1906
+	if ( ! $echo) {
1907 1907
 		return $form_dropdown_html;
1908 1908
 	}
1909 1909
 
Please login to merge, or discard this patch.
includes/actions.php 1 patch
Spacing   +32 added lines, -32 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
 
@@ -25,14 +25,14 @@  discard block
 block discarded – undo
25 25
  */
26 26
 function give_get_actions() {
27 27
 
28
-	$_get_action = ! empty( $_GET['give_action'] ) ? $_GET['give_action'] : null;
28
+	$_get_action = ! empty($_GET['give_action']) ? $_GET['give_action'] : null;
29 29
 
30 30
 	// Add backward compatibility to give-action param ( $_GET or $_POST )
31
-	if(  doing_action( 'admin_init' ) && empty( $_get_action ) ) {
32
-		$_get_action = ! empty( $_GET['give-action'] ) ? $_GET['give-action'] : null;
31
+	if (doing_action('admin_init') && empty($_get_action)) {
32
+		$_get_action = ! empty($_GET['give-action']) ? $_GET['give-action'] : null;
33 33
 	}
34 34
 
35
-	if ( isset( $_get_action ) ) {
35
+	if (isset($_get_action)) {
36 36
 		/**
37 37
 		 * Fires in WordPress init or admin init, when give_action is present in $_GET.
38 38
 		 *
@@ -40,13 +40,13 @@  discard block
 block discarded – undo
40 40
 		 *
41 41
 		 * @param array $_GET Array of HTTP GET variables.
42 42
 		 */
43
-		do_action( "give_{$_get_action}", $_GET );
43
+		do_action("give_{$_get_action}", $_GET);
44 44
 	}
45 45
 
46 46
 }
47 47
 
48
-add_action( 'init', 'give_get_actions' );
49
-add_action( 'admin_init', 'give_get_actions' );
48
+add_action('init', 'give_get_actions');
49
+add_action('admin_init', 'give_get_actions');
50 50
 
51 51
 /**
52 52
  * Hooks Give actions, when present in the $_POST superglobal. Every give_action
@@ -59,15 +59,15 @@  discard block
 block discarded – undo
59 59
  */
60 60
 function give_post_actions() {
61 61
 
62
-	$_post_action = ! empty( $_POST['give_action'] ) ? $_POST['give_action'] : null;
62
+	$_post_action = ! empty($_POST['give_action']) ? $_POST['give_action'] : null;
63 63
 
64 64
 
65 65
 	// Add backward compatibility to give-action param ( $_GET or $_POST )
66
-	if(  doing_action( 'admin_init' ) && empty( $_post_action ) ) {
67
-		$_post_action = ! empty( $_POST['give-action'] ) ? $_POST['give-action'] : null;
66
+	if (doing_action('admin_init') && empty($_post_action)) {
67
+		$_post_action = ! empty($_POST['give-action']) ? $_POST['give-action'] : null;
68 68
 	}
69 69
 
70
-	if ( isset( $_post_action ) ) {
70
+	if (isset($_post_action)) {
71 71
 		/**
72 72
 		 * Fires in WordPress init or admin init, when give_action is present in $_POST.
73 73
 		 *
@@ -75,13 +75,13 @@  discard block
 block discarded – undo
75 75
 		 *
76 76
 		 * @param array $_POST Array of HTTP POST variables.
77 77
 		 */
78
-		do_action( "give_{$_post_action}", $_POST );
78
+		do_action("give_{$_post_action}", $_POST);
79 79
 	}
80 80
 
81 81
 }
82 82
 
83
-add_action( 'init', 'give_post_actions' );
84
-add_action( 'admin_init', 'give_post_actions' );
83
+add_action('init', 'give_post_actions');
84
+add_action('admin_init', 'give_post_actions');
85 85
 
86 86
 /**
87 87
  * Connect WordPress user with Donor.
@@ -91,27 +91,27 @@  discard block
 block discarded – undo
91 91
  * @param  array $user_data User Data
92 92
  * @return void
93 93
  */
94
-function give_connect_donor_to_wpuser( $user_id, $user_data ){
95
-	$donor = new Give_Customer( $user_data['user_email'] );
94
+function give_connect_donor_to_wpuser($user_id, $user_data) {
95
+	$donor = new Give_Customer($user_data['user_email']);
96 96
 
97 97
 	// Validate donor id and check if do nor is already connect to wp user or not.
98
-	if( $donor->id && ! $donor->user_id ) {
98
+	if ($donor->id && ! $donor->user_id) {
99 99
 
100 100
 		// Update donor user_id.
101
-		if( $donor->update( array( 'user_id' => $user_id ) ) ) {
102
-			$donor_note = sprintf( esc_html__( 'WordPress user #%d is connected to #%d', 'give' ), $user_id, $donor->id );
103
-			$donor->add_note( $donor_note );
101
+		if ($donor->update(array('user_id' => $user_id))) {
102
+			$donor_note = sprintf(esc_html__('WordPress user #%d is connected to #%d', 'give'), $user_id, $donor->id);
103
+			$donor->add_note($donor_note);
104 104
 
105 105
 			// Update user_id meta in payments.
106
-			if( ! empty( $donor->payment_ids ) && ( $donations = explode( ',', $donor->payment_ids ) ) ) {
107
-				foreach ( $donations as $donation  ) {
108
-					update_post_meta( $donation, '_give_payment_user_id', $user_id );
106
+			if ( ! empty($donor->payment_ids) && ($donations = explode(',', $donor->payment_ids))) {
107
+				foreach ($donations as $donation) {
108
+					update_post_meta($donation, '_give_payment_user_id', $user_id);
109 109
 				}
110 110
 			}
111 111
 		}
112 112
 	}
113 113
 }
114
-add_action( 'give_insert_user', 'give_connect_donor_to_wpuser', 10, 2 );
114
+add_action('give_insert_user', 'give_connect_donor_to_wpuser', 10, 2);
115 115
 
116 116
 
117 117
 /**
@@ -125,21 +125,21 @@  discard block
 block discarded – undo
125 125
 function give_validate_license_when_site_migrated() {
126 126
 	// Store current site address if not already stored.
127 127
 	$homeurl = home_url();
128
-	if( ! get_option( 'give_site_address_before_migrate' ) ) {
128
+	if ( ! get_option('give_site_address_before_migrate')) {
129 129
 		// Update site address.
130
-		update_option( 'give_site_address_before_migrate', $homeurl );
130
+		update_option('give_site_address_before_migrate', $homeurl);
131 131
 
132 132
 		return;
133 133
 	}
134 134
 
135
-	if( $homeurl !== get_option( 'give_site_address_before_migrate' ) ) {
135
+	if ($homeurl !== get_option('give_site_address_before_migrate')) {
136 136
 		// Immediately run cron.
137
-		wp_schedule_single_event( time() , 'give_validate_license_when_site_migrated' );
137
+		wp_schedule_single_event(time(), 'give_validate_license_when_site_migrated');
138 138
 
139 139
 		// Update site address.
140
-		update_option( 'give_site_address_before_migrate', home_url() );
140
+		update_option('give_site_address_before_migrate', home_url());
141 141
 	}
142 142
 
143 143
 }
144
-add_action( 'init', 'give_validate_license_when_site_migrated' );
145
-add_action( 'admin_init', 'give_validate_license_when_site_migrated' );
144
+add_action('init', 'give_validate_license_when_site_migrated');
145
+add_action('admin_init', 'give_validate_license_when_site_migrated');
Please login to merge, or discard this patch.
includes/admin/dashboard-widgets.php 1 patch
Spacing   +32 added lines, -32 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
 
@@ -21,12 +21,12 @@  discard block
 block discarded – undo
21 21
  * @return void
22 22
  */
23 23
 function give_register_dashboard_widgets() {
24
-	if ( current_user_can( apply_filters( 'give_dashboard_stats_cap', 'view_give_reports' ) ) ) {
25
-		wp_add_dashboard_widget( 'give_dashboard_sales', esc_html__( 'Give: Donation Statistics', 'give' ), 'give_dashboard_sales_widget' );
24
+	if (current_user_can(apply_filters('give_dashboard_stats_cap', 'view_give_reports'))) {
25
+		wp_add_dashboard_widget('give_dashboard_sales', esc_html__('Give: Donation Statistics', 'give'), 'give_dashboard_sales_widget');
26 26
 	}
27 27
 }
28 28
 
29
-add_action( 'wp_dashboard_setup', 'give_register_dashboard_widgets', 10 );
29
+add_action('wp_dashboard_setup', 'give_register_dashboard_widgets', 10);
30 30
 
31 31
 /**
32 32
  * Sales Summary Dashboard Widget
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
  */
39 39
 function give_dashboard_sales_widget() {
40 40
 
41
-	if ( ! current_user_can( apply_filters( 'give_dashboard_stats_cap', 'view_give_reports' ) ) ) {
41
+	if ( ! current_user_can(apply_filters('give_dashboard_stats_cap', 'view_give_reports'))) {
42 42
 		return;
43 43
 	}
44 44
 	$stats = new Give_Payment_Stats; ?>
@@ -46,27 +46,27 @@  discard block
 block discarded – undo
46 46
 	<div class="give-dashboard-widget">
47 47
 
48 48
 		<div class="give-dashboard-today give-clearfix">
49
-			<h3 class="give-dashboard-date-today"><?php echo date( _x( 'F j, Y', 'dashboard widget', 'give' ) ); ?></h3>
49
+			<h3 class="give-dashboard-date-today"><?php echo date(_x('F j, Y', 'dashboard widget', 'give')); ?></h3>
50 50
 
51 51
 			<p class="give-dashboard-happy-day"><?php
52 52
 				printf(
53 53
 				/* translators: %s: day of the week */
54
-					esc_html__( 'Happy %s!', 'give' ),
55
-					date( 'l', current_time( 'timestamp' ) )
54
+					esc_html__('Happy %s!', 'give'),
55
+					date('l', current_time('timestamp'))
56 56
 				);
57 57
 			?></p>
58 58
 
59 59
 			<p class="give-dashboard-today-earnings"><?php
60
-				$earnings_today = $stats->get_earnings( 0, 'today', false );
61
-				echo give_currency_filter( give_format_amount( $earnings_today ) );
60
+				$earnings_today = $stats->get_earnings(0, 'today', false);
61
+				echo give_currency_filter(give_format_amount($earnings_today));
62 62
 			?></p>
63 63
 
64 64
 			<p class="give-orders-today"><?php
65
-				$donations_today = $stats->get_sales( 0, 'today', false );
65
+				$donations_today = $stats->get_sales(0, 'today', false);
66 66
 				printf(
67 67
 					/* translators: %s: daily donation count */
68
-					esc_html__( '%s donations today', 'give' ),
69
-					give_format_amount( $donations_today, false )
68
+					esc_html__('%s donations today', 'give'),
69
+					give_format_amount($donations_today, false)
70 70
 				);
71 71
 			?></p>
72 72
 
@@ -76,34 +76,34 @@  discard block
 block discarded – undo
76 76
 		<table class="give-table-stats">
77 77
 			<thead style="display: none;">
78 78
 			<tr>
79
-				<th><?php esc_html_e( 'This Week', 'give' ); ?></th>
80
-				<th><?php esc_html_e( 'This Month', 'give' ); ?></th>
81
-				<th><?php esc_html_e( 'Past 30 Days', 'give' ); ?></th>
79
+				<th><?php esc_html_e('This Week', 'give'); ?></th>
80
+				<th><?php esc_html_e('This Month', 'give'); ?></th>
81
+				<th><?php esc_html_e('Past 30 Days', 'give'); ?></th>
82 82
 			</tr>
83 83
 			</thead>
84 84
 			<tbody>
85 85
 			<tr id="give-table-stats-tr-1">
86 86
 				<td>
87
-					<p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_week' ) ) ); ?></p>
87
+					<p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_week'))); ?></p>
88 88
 
89
-					<p class="give-dashboard-stat-total-label"><?php esc_html_e( 'This Week', 'give' ); ?></p>
89
+					<p class="give-dashboard-stat-total-label"><?php esc_html_e('This Week', 'give'); ?></p>
90 90
 				</td>
91 91
 				<td>
92
-					<p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_month' ) ) ); ?></p>
92
+					<p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_month'))); ?></p>
93 93
 
94
-					<p class="give-dashboard-stat-total-label"><?php esc_html_e( 'This Month', 'give' ); ?></p>
94
+					<p class="give-dashboard-stat-total-label"><?php esc_html_e('This Month', 'give'); ?></p>
95 95
 				</td>
96 96
 			</tr>
97 97
 			<tr id="give-table-stats-tr-2">
98 98
 				<td>
99
-					<p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'last_month' ) ) ) ?></p>
99
+					<p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'last_month'))) ?></p>
100 100
 
101
-					<p class="give-dashboard-stat-total-label"><?php esc_html_e( 'Last Month', 'give' ); ?></p>
101
+					<p class="give-dashboard-stat-total-label"><?php esc_html_e('Last Month', 'give'); ?></p>
102 102
 				</td>
103 103
 				<td>
104
-					<p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_year', false ) ) ) ?></p>
104
+					<p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_year', false))) ?></p>
105 105
 
106
-					<p class="give-dashboard-stat-total-label"><?php esc_html_e( 'This Year', 'give' ); ?></p>
106
+					<p class="give-dashboard-stat-total-label"><?php esc_html_e('This Year', 'give'); ?></p>
107 107
 				</td>
108 108
 			</tr>
109 109
 			</tbody>
@@ -123,23 +123,23 @@  discard block
 block discarded – undo
123 123
  *
124 124
  * @return array
125 125
  */
126
-function give_dashboard_at_a_glance_widget( $items ) {
127
-	$num_posts = wp_count_posts( 'give_forms' );
126
+function give_dashboard_at_a_glance_widget($items) {
127
+	$num_posts = wp_count_posts('give_forms');
128 128
 
129
-	if ( $num_posts && $num_posts->publish ) {
129
+	if ($num_posts && $num_posts->publish) {
130 130
 
131 131
 		$text = sprintf(
132 132
 			/* translators: %s: number of posts published */
133
-			_n( '%s Give Form', '%s Give Forms', $num_posts->publish, 'give' ),
133
+			_n('%s Give Form', '%s Give Forms', $num_posts->publish, 'give'),
134 134
 			$num_posts->publish
135 135
 		);
136 136
 
137
-		$text = sprintf( $text, number_format_i18n( $num_posts->publish ) );
137
+		$text = sprintf($text, number_format_i18n($num_posts->publish));
138 138
 
139
-		if ( current_user_can( 'edit_give_forms', get_current_user_id() ) ) {
139
+		if (current_user_can('edit_give_forms', get_current_user_id())) {
140 140
 			$text = sprintf(
141 141
 				'<a class="give-forms-count" href="%1$s">%2$s</a>',
142
-				admin_url( 'edit.php?post_type=give_forms' ),
142
+				admin_url('edit.php?post_type=give_forms'),
143 143
 				$text
144 144
 			);
145 145
 		} else {
@@ -155,4 +155,4 @@  discard block
 block discarded – undo
155 155
 	return $items;
156 156
 }
157 157
 
158
-add_filter( 'dashboard_glance_items', 'give_dashboard_at_a_glance_widget', 1, 1 );
158
+add_filter('dashboard_glance_items', 'give_dashboard_at_a_glance_widget', 1, 1);
Please login to merge, or discard this patch.
includes/admin/class-i18n-module.php 1 patch
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -66,23 +66,23 @@  discard block
 block discarded – undo
66 66
 	 * @param $args
67 67
 	 *
68 68
 	 */
69
-	public function __construct( $args ) {
69
+	public function __construct($args) {
70 70
 
71 71
 		//Only for admins.
72
-		if ( ! is_admin() ) {
72
+		if ( ! is_admin()) {
73 73
 			return;
74 74
 		}
75 75
 
76 76
 		//This plugin is en_US native.
77 77
 		$this->locale = get_locale();
78
-		if ( 'en_US' === $this->locale ) {
78
+		if ('en_US' === $this->locale) {
79 79
 			return;
80 80
 		}
81 81
 
82
-		$this->init( $args );
82
+		$this->init($args);
83 83
 
84
-		if ( ! $this->hide_promo() ) {
85
-			add_action( $this->hook, array( $this, 'promo' ) );
84
+		if ( ! $this->hide_promo()) {
85
+			add_action($this->hook, array($this, 'promo'));
86 86
 		}
87 87
 	}
88 88
 
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
 	 *
94 94
 	 * @param array $args
95 95
 	 */
96
-	private function init( $args ) {
97
-		foreach ( $args as $key => $arg ) {
96
+	private function init($args) {
97
+		foreach ($args as $key => $arg) {
98 98
 			$this->$key = $arg;
99 99
 		}
100 100
 
@@ -108,11 +108,11 @@  discard block
 block discarded – undo
108 108
 	 * @return bool
109 109
 	 */
110 110
 	private function hide_promo() {
111
-		$hide_promo = get_transient( 'give_i18n_give_promo_hide' );
112
-		if ( ! $hide_promo ) {
113
-			if ( filter_input( INPUT_GET, 'remove_i18n_promo', FILTER_VALIDATE_INT ) === 1 ) {
111
+		$hide_promo = get_transient('give_i18n_give_promo_hide');
112
+		if ( ! $hide_promo) {
113
+			if (filter_input(INPUT_GET, 'remove_i18n_promo', FILTER_VALIDATE_INT) === 1) {
114 114
 				// No expiration time, so this would normally not expire, but it wouldn't be copied to other sites etc.
115
-				set_transient( 'give_i18n_give_promo_hide', true );
115
+				set_transient('give_i18n_give_promo_hide', true);
116 116
 				$hide_promo = true;
117 117
 			}
118 118
 		}
@@ -131,20 +131,20 @@  discard block
 block discarded – undo
131 131
 		$message = false;
132 132
 
133 133
 		//Using a translation less than 90% complete.
134
-		if ( $this->translation_exists && $this->translation_loaded && $this->percent_translated < 90 ) {
135
-			$message = __( 'As you can see, there is a translation of this plugin in %1$s. This translation is currently %3$d%% complete. We need your help to make it complete and to fix any errors. Please register at %4$s to help %5$s to %1$s!', 'give' );
136
-		} elseif ( ! $this->translation_loaded && $this->translation_exists ) {
137
-			$message = __( 'You\'re using WordPress in %1$s. While %2$s has been translated to %1$s for %3$d%%, it\'s not been shipped with the plugin yet. You can help! Register at %4$s to help complete the translation to %1$s!', 'give' );
138
-		} elseif ( ! $this->translation_exists ) {
139
-			$message = __( 'You\'re using WordPress in a language we don\'t support yet. We\'d love for %2$s to be translated in that language too, but unfortunately, it isn\'t right now. You can change that! Register at %4$s to help translate it!', 'give' );
134
+		if ($this->translation_exists && $this->translation_loaded && $this->percent_translated < 90) {
135
+			$message = __('As you can see, there is a translation of this plugin in %1$s. This translation is currently %3$d%% complete. We need your help to make it complete and to fix any errors. Please register at %4$s to help %5$s to %1$s!', 'give');
136
+		} elseif ( ! $this->translation_loaded && $this->translation_exists) {
137
+			$message = __('You\'re using WordPress in %1$s. While %2$s has been translated to %1$s for %3$d%%, it\'s not been shipped with the plugin yet. You can help! Register at %4$s to help complete the translation to %1$s!', 'give');
138
+		} elseif ( ! $this->translation_exists) {
139
+			$message = __('You\'re using WordPress in a language we don\'t support yet. We\'d love for %2$s to be translated in that language too, but unfortunately, it isn\'t right now. You can change that! Register at %4$s to help translate it!', 'give');
140 140
 		}
141 141
 
142 142
 		//Links.
143
-		$registration_link = sprintf( '<a href="%1$s" target="_blank">%2$s</a>', 'https://wordpress.org/support/register.php', esc_html__( 'WordPress.org', 'give' ) );
144
-		$translations_link = sprintf( '<a href="%1$s" target="_blank">%2$s</a>', 'https://translate.wordpress.org/projects/wp-plugins/give', esc_html__( 'complete the translation', 'give' ) );
143
+		$registration_link = sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://wordpress.org/support/register.php', esc_html__('WordPress.org', 'give'));
144
+		$translations_link = sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://translate.wordpress.org/projects/wp-plugins/give', esc_html__('complete the translation', 'give'));
145 145
 
146 146
 		//Message.
147
-		$message = sprintf( $message, esc_html( $this->locale_name ), esc_html( 'Give' ), $this->percent_translated, $registration_link, $translations_link );
147
+		$message = sprintf($message, esc_html($this->locale_name), esc_html('Give'), $this->percent_translated, $registration_link, $translations_link);
148 148
 
149 149
 
150 150
 		return $message;
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 		$this->translation_details();
160 160
 		$message = $this->promo_message();
161 161
 
162
-		if ( $message ) { ?>
162
+		if ($message) { ?>
163 163
 
164 164
 			<style>
165 165
 				/* Banner specific styles */
@@ -212,12 +212,12 @@  discard block
 block discarded – undo
212 212
 				<a href="https://wordpress.org/support/register.php" class="alignleft give-i18n-icon" style="margin:0" target="_blank"><span class="dashicons dashicons-translation" style="font-size: 110px; text-decoration: none;"></span></a>
213 213
 
214 214
 				<div class="give-i18n-notice-content">
215
-					<a href="<?php echo esc_url( add_query_arg( array( 'remove_i18n_promo' => '1' ) ) ); ?>" class="dismiss"><span class="dashicons dashicons-dismiss"></span></a>
215
+					<a href="<?php echo esc_url(add_query_arg(array('remove_i18n_promo' => '1'))); ?>" class="dismiss"><span class="dashicons dashicons-dismiss"></span></a>
216 216
 
217
-					<h2 style="margin: 10px 0;"><?php printf( esc_html__( 'Help Translate Give to %s', 'give' ), $this->locale_name ); ?></h2>
217
+					<h2 style="margin: 10px 0;"><?php printf(esc_html__('Help Translate Give to %s', 'give'), $this->locale_name); ?></h2>
218 218
 					<p><?php echo $message; ?></p>
219 219
 					<p>
220
-						<a href="https://wordpress.org/support/register.php" target="_blank"><?php _e( 'Register now &raquo;', 'give' ); ?></a>
220
+						<a href="https://wordpress.org/support/register.php" target="_blank"><?php _e('Register now &raquo;', 'give'); ?></a>
221 221
 					</p>
222 222
 				</div>
223 223
 			</div>
@@ -234,11 +234,11 @@  discard block
 block discarded – undo
234 234
 	 */
235 235
 	private function find_or_initialize_translation_details() {
236 236
 
237
-		$set = get_transient( 'give_i18n_give_' . $this->locale );
237
+		$set = get_transient('give_i18n_give_'.$this->locale);
238 238
 
239
-		if ( ! $set ) {
239
+		if ( ! $set) {
240 240
 			$set = $this->retrieve_translation_details();
241
-			set_transient( 'give_i18n_give_' . $this->locale, $set, DAY_IN_SECONDS );
241
+			set_transient('give_i18n_give_'.$this->locale, $set, DAY_IN_SECONDS);
242 242
 		}
243 243
 
244 244
 		return $set;
@@ -252,10 +252,10 @@  discard block
 block discarded – undo
252 252
 	private function translation_details() {
253 253
 		$set = $this->find_or_initialize_translation_details();
254 254
 
255
-		$this->translation_exists = ! is_null( $set );
256
-		$this->translation_loaded = is_textdomain_loaded( 'give' );
255
+		$this->translation_exists = ! is_null($set);
256
+		$this->translation_loaded = is_textdomain_loaded('give');
257 257
 
258
-		$this->parse_translation_set( $set );
258
+		$this->parse_translation_set($set);
259 259
 	}
260 260
 
261 261
 	/**
@@ -267,26 +267,26 @@  discard block
 block discarded – undo
267 267
 	 */
268 268
 	private function retrieve_translation_details() {
269 269
 
270
-		$api_url = trailingslashit( $this->glotpress_url );
270
+		$api_url = trailingslashit($this->glotpress_url);
271 271
 
272
-		$resp = wp_remote_get( $api_url );
272
+		$resp = wp_remote_get($api_url);
273 273
 
274
-		if ( is_wp_error( $resp ) || wp_remote_retrieve_response_code( $resp ) === '404' ) {
274
+		if (is_wp_error($resp) || wp_remote_retrieve_response_code($resp) === '404') {
275 275
 			return null;
276 276
 		}
277 277
 
278
-		$body = wp_remote_retrieve_body( $resp );
279
-		unset( $resp );
278
+		$body = wp_remote_retrieve_body($resp);
279
+		unset($resp);
280 280
 
281
-		if ( $body ) {
282
-			$body = json_decode( $body );
281
+		if ($body) {
282
+			$body = json_decode($body);
283 283
 
284
-			foreach ( $body->translation_sets as $set ) {
285
-				if ( ! property_exists( $set, 'wp_locale' ) ) {
284
+			foreach ($body->translation_sets as $set) {
285
+				if ( ! property_exists($set, 'wp_locale')) {
286 286
 					continue;
287 287
 				}
288 288
 
289
-				if ( $this->locale == $set->wp_locale ) {
289
+				if ($this->locale == $set->wp_locale) {
290 290
 					return $set;
291 291
 				}
292 292
 			}
@@ -302,8 +302,8 @@  discard block
 block discarded – undo
302 302
 	 *
303 303
 	 * @access private
304 304
 	 */
305
-	private function parse_translation_set( $set ) {
306
-		if ( $this->translation_exists && is_object( $set ) ) {
305
+	private function parse_translation_set($set) {
306
+		if ($this->translation_exists && is_object($set)) {
307 307
 			$this->locale_name        = $set->name;
308 308
 			$this->percent_translated = $set->percent_translated;
309 309
 		} else {
Please login to merge, or discard this patch.
includes/admin/customers/class-customer-table.php 2 patches
Spacing   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -10,13 +10,13 @@  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
 
17 17
 // Load WP_List_Table if not loaded
18
-if ( ! class_exists( 'WP_List_Table' ) ) {
19
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
18
+if ( ! class_exists('WP_List_Table')) {
19
+	require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
20 20
 }
21 21
 
22 22
 /**
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
 	public function __construct() {
62 62
 
63 63
 		// Set parent defaults
64
-		parent::__construct( array(
65
-			'singular' => esc_html__( 'Donor', 'give' ),     // Singular name of the listed records
66
-			'plural'   => esc_html__( 'Donors', 'give' ),    // Plural name of the listed records
64
+		parent::__construct(array(
65
+			'singular' => esc_html__('Donor', 'give'), // Singular name of the listed records
66
+			'plural'   => esc_html__('Donors', 'give'), // Plural name of the listed records
67 67
 			'ajax'     => false                       // Does this table support ajax?
68
-		) );
68
+		));
69 69
 
70 70
 	}
71 71
 
@@ -80,20 +80,20 @@  discard block
 block discarded – undo
80 80
 	 *
81 81
 	 * @return void
82 82
 	 */
83
-	public function search_box( $text, $input_id ) {
84
-		$input_id = $input_id . '-search-input';
83
+	public function search_box($text, $input_id) {
84
+		$input_id = $input_id.'-search-input';
85 85
 
86
-		if ( ! empty( $_REQUEST['orderby'] ) ) {
87
-			echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
86
+		if ( ! empty($_REQUEST['orderby'])) {
87
+			echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />';
88 88
 		}
89
-		if ( ! empty( $_REQUEST['order'] ) ) {
90
-			echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
89
+		if ( ! empty($_REQUEST['order'])) {
90
+			echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />';
91 91
 		}
92 92
 		?>
93 93
 		<p class="search-box" role="search">
94 94
 			<label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label>
95 95
 			<input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>"/>
96
-			<?php submit_button( $text, 'button', false, false, array( 'ID' => 'search-submit' ) ); ?>
96
+			<?php submit_button($text, 'button', false, false, array('ID' => 'search-submit')); ?>
97 97
 		</p>
98 98
 		<?php
99 99
 	}
@@ -109,29 +109,29 @@  discard block
 block discarded – undo
109 109
 	 *
110 110
 	 * @return string Column Name.
111 111
 	 */
112
-	public function column_default( $item, $column_name ) {
113
-		switch ( $column_name ) {
112
+	public function column_default($item, $column_name) {
113
+		switch ($column_name) {
114 114
 
115 115
 			case 'num_purchases' :
116
-				$value = '<a href="' .
117
-				         admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . urlencode( $item['email'] )
118
-				         ) . '">' . esc_html( $item['num_purchases'] ) . '</a>';
116
+				$value = '<a href="'.
117
+				         admin_url('edit.php?post_type=give_forms&page=give-payment-history&user='.urlencode($item['email'])
118
+				         ).'">'.esc_html($item['num_purchases']).'</a>';
119 119
 				break;
120 120
 
121 121
 			case 'amount_spent' :
122
-				$value = give_currency_filter( give_format_amount( $item[ $column_name ] ) );
122
+				$value = give_currency_filter(give_format_amount($item[$column_name]));
123 123
 				break;
124 124
 
125 125
 			case 'date_created' :
126
-				$value = date_i18n( give_date_format(), strtotime( $item['date_created'] ) );
126
+				$value = date_i18n(give_date_format(), strtotime($item['date_created']));
127 127
 				break;
128 128
 
129 129
 			default:
130
-				$value = isset( $item[ $column_name ] ) ? $item[ $column_name ] : null;
130
+				$value = isset($item[$column_name]) ? $item[$column_name] : null;
131 131
 				break;
132 132
 		}
133 133
 
134
-		return apply_filters( "give_report_column_{$column_name}", $value, $item['id'] );
134
+		return apply_filters("give_report_column_{$column_name}", $value, $item['id']);
135 135
 
136 136
 	}
137 137
 
@@ -142,13 +142,13 @@  discard block
 block discarded – undo
142 142
 	 *
143 143
 	 * @return string
144 144
 	 */
145
-	public function column_name( $item ) {
146
-		$name = '#' . $item['id'] . ' ';
147
-		$name .= ! empty( $item['name'] ) ? $item['name'] : '<em>' . esc_html__( 'Unnamed Donor', 'give' ) . '</em>';
148
-		$view_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $item['id'] );
149
-		$actions  = $this->get_row_actions( $item );
145
+	public function column_name($item) {
146
+		$name = '#'.$item['id'].' ';
147
+		$name .= ! empty($item['name']) ? $item['name'] : '<em>'.esc_html__('Unnamed Donor', 'give').'</em>';
148
+		$view_url = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$item['id']);
149
+		$actions  = $this->get_row_actions($item);
150 150
 
151
-		return '<a href="' . esc_url( $view_url ) . '">' . $name . '</a>' . $this->row_actions( $actions );
151
+		return '<a href="'.esc_url($view_url).'">'.$name.'</a>'.$this->row_actions($actions);
152 152
 	}
153 153
 
154 154
 	/**
@@ -160,14 +160,14 @@  discard block
 block discarded – undo
160 160
 	 */
161 161
 	public function get_columns() {
162 162
 		$columns = array(
163
-			'name'          => esc_html__( 'Name', 'give' ),
164
-			'email'         => esc_html__( 'Email', 'give' ),
165
-			'num_purchases' => esc_html__( 'Donations', 'give' ),
166
-			'amount_spent'  => esc_html__( 'Total Donated', 'give' ),
167
-			'date_created'  => esc_html__( 'Date Created', 'give' )
163
+			'name'          => esc_html__('Name', 'give'),
164
+			'email'         => esc_html__('Email', 'give'),
165
+			'num_purchases' => esc_html__('Donations', 'give'),
166
+			'amount_spent'  => esc_html__('Total Donated', 'give'),
167
+			'date_created'  => esc_html__('Date Created', 'give')
168 168
 		);
169 169
 
170
-		return apply_filters( 'give_report_customer_columns', $columns );
170
+		return apply_filters('give_report_customer_columns', $columns);
171 171
 
172 172
 	}
173 173
 
@@ -180,10 +180,10 @@  discard block
 block discarded – undo
180 180
 	 */
181 181
 	public function get_sortable_columns() {
182 182
 		return array(
183
-			'date_created'  => array( 'date_created', true ),
184
-			'name'          => array( 'name', true ),
185
-			'num_purchases' => array( 'purchase_count', false ),
186
-			'amount_spent'  => array( 'purchase_value', false ),
183
+			'date_created'  => array('date_created', true),
184
+			'name'          => array('name', true),
185
+			'num_purchases' => array('purchase_count', false),
186
+			'amount_spent'  => array('purchase_value', false),
187 187
 		);
188 188
 	}
189 189
 
@@ -195,34 +195,34 @@  discard block
 block discarded – undo
195 195
 	 *
196 196
 	 * @return array An array of action links.
197 197
 	 */
198
-	public function get_row_actions( $item ) {
198
+	public function get_row_actions($item) {
199 199
 
200 200
 		$actions = array(
201 201
 
202 202
 			'view' => sprintf(
203 203
 				'<a href="%1$s" aria-label="%2$s">%3$s</a>',
204
-				admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $item['id'] ),
205
-				sprintf( esc_attr__( 'View "%s"', 'give' ), $item['name'] ),
206
-				esc_html__( 'View Donor', 'give' )
204
+				admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$item['id']),
205
+				sprintf(esc_attr__('View "%s"', 'give'), $item['name']),
206
+				esc_html__('View Donor', 'give')
207 207
 			),
208 208
 
209 209
 			'notes' => sprintf(
210 210
 				'<a href="%1$s" aria-label="%2$s">%3$s</a>',
211
-				admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=notes&id=' . $item['id'] ),
212
-				sprintf( esc_attr__( 'Notes for "%s"', 'give' ), $item['name'] ),
213
-				esc_html__( 'Notes', 'give' )
211
+				admin_url('edit.php?post_type=give_forms&page=give-donors&view=notes&id='.$item['id']),
212
+				sprintf(esc_attr__('Notes for "%s"', 'give'), $item['name']),
213
+				esc_html__('Notes', 'give')
214 214
 			),
215 215
 
216 216
 			'delete' => sprintf(
217 217
 				'<a href="%1$s" aria-label="%2$s">%3$s</a>',
218
-				admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $item['id'] ),
219
-				sprintf( esc_attr__( 'Delete "%s"', 'give' ), $item['name'] ),
220
-				esc_html__( 'Delete', 'give' )
218
+				admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$item['id']),
219
+				sprintf(esc_attr__('Delete "%s"', 'give'), $item['name']),
220
+				esc_html__('Delete', 'give')
221 221
 			)
222 222
 
223 223
 		);
224 224
 
225
-		return apply_filters( 'give_donor_row_actions', $actions, $item );
225
+		return apply_filters('give_donor_row_actions', $actions, $item);
226 226
 
227 227
 	}
228 228
 
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	 * @since  1.0
234 234
 	 * @return void
235 235
 	 */
236
-	public function bulk_actions( $which = '' ) {
236
+	public function bulk_actions($which = '') {
237 237
 		// These aren't really bulk actions but this outputs the markup in the right place.
238 238
 	}
239 239
 
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 	 * @return int Current page number.
246 246
 	 */
247 247
 	public function get_paged() {
248
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
248
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
249 249
 	}
250 250
 
251 251
 	/**
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 	 * @return mixed string If search is present, false otherwise.
257 257
 	 */
258 258
 	public function get_search() {
259
-		return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false;
259
+		return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false;
260 260
 	}
261 261
 
262 262
 	/**
@@ -273,10 +273,10 @@  discard block
 block discarded – undo
273 273
 
274 274
 		$data    = array();
275 275
 		$paged   = $this->get_paged();
276
-		$offset  = $this->per_page * ( $paged - 1 );
276
+		$offset  = $this->per_page * ($paged - 1);
277 277
 		$search  = $this->get_search();
278
-		$order   = isset( $_GET['order'] ) ? sanitize_text_field( $_GET['order'] ) : 'DESC';
279
-		$orderby = isset( $_GET['orderby'] ) ? sanitize_text_field( $_GET['orderby'] ) : 'id';
278
+		$order   = isset($_GET['order']) ? sanitize_text_field($_GET['order']) : 'DESC';
279
+		$orderby = isset($_GET['orderby']) ? sanitize_text_field($_GET['orderby']) : 'id';
280 280
 
281 281
 		$args = array(
282 282
 			'number'  => $this->per_page,
@@ -285,21 +285,21 @@  discard block
 block discarded – undo
285 285
 			'orderby' => $orderby
286 286
 		);
287 287
 
288
-		if ( is_email( $search ) ) {
288
+		if (is_email($search)) {
289 289
 			$args['email'] = $search;
290
-		} elseif ( is_numeric( $search ) ) {
290
+		} elseif (is_numeric($search)) {
291 291
 			$args['id'] = $search;
292 292
 		} else {
293 293
 			$args['name'] = $search;
294 294
 		}
295 295
 
296
-		$customers = Give()->customers->get_customers( $args );
296
+		$customers = Give()->customers->get_customers($args);
297 297
 
298
-		if ( $customers ) {
298
+		if ($customers) {
299 299
 
300
-			foreach ( $customers as $customer ) {
300
+			foreach ($customers as $customer) {
301 301
 
302
-				$user_id = ! empty( $customer->user_id ) ? intval( $customer->user_id ) : 0;
302
+				$user_id = ! empty($customer->user_id) ? intval($customer->user_id) : 0;
303 303
 
304 304
 				$data[] = array(
305 305
 					'id'            => $customer->id,
@@ -333,16 +333,16 @@  discard block
 block discarded – undo
333 333
 		$hidden   = array(); // No hidden columns
334 334
 		$sortable = $this->get_sortable_columns();
335 335
 
336
-		$this->_column_headers = array( $columns, $hidden, $sortable );
336
+		$this->_column_headers = array($columns, $hidden, $sortable);
337 337
 
338 338
 		$this->items = $this->reports_data();
339 339
 
340 340
 		$this->total = give_count_total_customers();
341 341
 
342
-		$this->set_pagination_args( array(
342
+		$this->set_pagination_args(array(
343 343
 			'total_items' => $this->total,
344 344
 			'per_page'    => $this->per_page,
345
-			'total_pages' => ceil( $this->total / $this->per_page )
346
-		) );
345
+			'total_pages' => ceil($this->total / $this->per_page)
346
+		));
347 347
 	}
348 348
 }
349 349
\ No newline at end of file
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -173,8 +173,8 @@
 block discarded – undo
173 173
 
174 174
 			case 'num_purchases' :
175 175
 				$value = '<a href="' .
176
-				         admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . urlencode( $item['email'] )
177
-				         ) . '">' . esc_html( $item['num_purchases'] ) . '</a>';
176
+						 admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . urlencode( $item['email'] )
177
+						 ) . '">' . esc_html( $item['num_purchases'] ) . '</a>';
178 178
 				break;
179 179
 
180 180
 			case 'amount_spent' :
Please login to merge, or discard this patch.
includes/admin/customers/customers.php 1 patch
Spacing   +157 added lines, -157 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
 
@@ -24,9 +24,9 @@  discard block
 block discarded – undo
24 24
  */
25 25
 function give_customers_page() {
26 26
 	$default_views  = give_customer_views();
27
-	$requested_view = isset( $_GET['view'] ) ? sanitize_text_field( $_GET['view'] ) : 'customers';
28
-	if ( array_key_exists( $requested_view, $default_views ) && function_exists( $default_views[ $requested_view ] ) ) {
29
-		give_render_customer_view( $requested_view, $default_views );
27
+	$requested_view = isset($_GET['view']) ? sanitize_text_field($_GET['view']) : 'customers';
28
+	if (array_key_exists($requested_view, $default_views) && function_exists($default_views[$requested_view])) {
29
+		give_render_customer_view($requested_view, $default_views);
30 30
 	} else {
31 31
 		give_customers_list();
32 32
 	}
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 
43 43
 	$views = array();
44 44
 
45
-	return apply_filters( 'give_customer_views', $views );
45
+	return apply_filters('give_customer_views', $views);
46 46
 
47 47
 }
48 48
 
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 
57 57
 	$tabs = array();
58 58
 
59
-	return apply_filters( 'give_customer_tabs', $tabs );
59
+	return apply_filters('give_customer_tabs', $tabs);
60 60
 
61 61
 }
62 62
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
  * @return void
68 68
  */
69 69
 function give_customers_list() {
70
-	include( dirname( __FILE__ ) . '/class-customer-table.php' );
70
+	include(dirname(__FILE__).'/class-customer-table.php');
71 71
 
72 72
 	$customers_table = new Give_Customer_Reports_Table();
73 73
 	$customers_table->prepare_items();
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
 		 *
81 81
 		 * @since 1.0
82 82
 		 */
83
-		do_action( 'give_donors_table_top' );
83
+		do_action('give_donors_table_top');
84 84
 		?>
85
-		<form id="give-donors-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors' ); ?>">
85
+		<form id="give-donors-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors'); ?>">
86 86
 			<?php
87
-			$customers_table->search_box( esc_html__( 'Search Donors', 'give' ), 'give-donors' );
87
+			$customers_table->search_box(esc_html__('Search Donors', 'give'), 'give-donors');
88 88
 			$customers_table->display();
89 89
 			?>
90 90
 			<input type="hidden" name="post_type" value="give_forms" />
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 		 *
98 98
 		 * @since 1.0
99 99
 		 */
100
-		do_action( 'give_donors_table_bottom' );
100
+		do_action('give_donors_table_bottom');
101 101
 		?>
102 102
 	</div>
103 103
 	<?php
@@ -113,27 +113,27 @@  discard block
 block discarded – undo
113 113
  *
114 114
  * @return void
115 115
  */
116
-function give_render_customer_view( $view, $callbacks ) {
116
+function give_render_customer_view($view, $callbacks) {
117 117
 
118 118
 	$render = true;
119 119
 
120
-	$customer_view_role = apply_filters( 'give_view_customers_role', 'view_give_reports' );
120
+	$customer_view_role = apply_filters('give_view_customers_role', 'view_give_reports');
121 121
 
122
-	if ( ! current_user_can( $customer_view_role ) ) {
123
-		give_set_error( 'give-no-access', esc_html__( 'You are not permitted to view this data.', 'give' ) );
122
+	if ( ! current_user_can($customer_view_role)) {
123
+		give_set_error('give-no-access', esc_html__('You are not permitted to view this data.', 'give'));
124 124
 		$render = false;
125 125
 	}
126 126
  
127
-	if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
128
-		give_set_error( 'give-invalid_customer', esc_html__( 'Invalid Donor ID.', 'give' ) );
127
+	if ( ! isset($_GET['id']) || ! is_numeric($_GET['id'])) {
128
+		give_set_error('give-invalid_customer', esc_html__('Invalid Donor ID.', 'give'));
129 129
 		$render = false;
130 130
 	}
131 131
 
132 132
 	$customer_id = (int) $_GET['id'];
133
-	$customer    = new Give_Customer( $customer_id );
133
+	$customer    = new Give_Customer($customer_id);
134 134
 
135
-	if ( empty( $customer->id ) ) {
136
-		give_set_error( 'give-invalid_customer', esc_html__( 'Invalid Donor ID.', 'give' ) );
135
+	if (empty($customer->id)) {
136
+		give_set_error('give-invalid_customer', esc_html__('Invalid Donor ID.', 'give'));
137 137
 		$render = false;
138 138
 	}
139 139
 
@@ -142,34 +142,34 @@  discard block
 block discarded – undo
142 142
 
143 143
 	<div class='wrap'>
144 144
 
145
-		<?php if ( give_get_errors() ) : ?>
145
+		<?php if (give_get_errors()) : ?>
146 146
 			<div class="error settings-error">
147
-				<?php give_print_errors( 0 ); ?>
147
+				<?php give_print_errors(0); ?>
148 148
 			</div>
149 149
 		<?php endif; ?>
150 150
 
151
-		<h1 class="screen-reader-text"><?php esc_html_e( 'Donor', 'give' ); ?></h1>
151
+		<h1 class="screen-reader-text"><?php esc_html_e('Donor', 'give'); ?></h1>
152 152
 
153
-		<?php if ( $customer && $render ) : ?>
153
+		<?php if ($customer && $render) : ?>
154 154
 
155 155
 			<h2 class="nav-tab-wrapper">
156 156
 			<?php
157
-			foreach ( $customer_tabs as $key => $tab ) :
157
+			foreach ($customer_tabs as $key => $tab) :
158 158
 				$active = $key === $view ? true : false;
159 159
 				$class = $active ? 'nav-tab nav-tab-active' : 'nav-tab';
160 160
 				printf(
161 161
 					'<a href="%1$s" class="%2$s"><span class="dashicons %3$s"></span>%4$s</a>'."\n",
162
-					esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=' . $key . '&id=' . $customer->id ) ),
163
-					esc_attr( $class ),
164
-					sanitize_html_class( $tab['dashicon'] ),
165
-					esc_html( $tab['title'] )
162
+					esc_url(admin_url('edit.php?post_type=give_forms&page=give-donors&view='.$key.'&id='.$customer->id)),
163
+					esc_attr($class),
164
+					sanitize_html_class($tab['dashicon']),
165
+					esc_html($tab['title'])
166 166
 				);
167 167
 			endforeach;
168 168
 			?>
169 169
 			</h2>
170 170
 
171 171
 			<div id="give-customer-card-wrapper">
172
-				<?php $callbacks[ $view ]( $customer ) ?>
172
+				<?php $callbacks[$view]($customer) ?>
173 173
 			</div>
174 174
 
175 175
 		<?php endif; ?>
@@ -189,9 +189,9 @@  discard block
 block discarded – undo
189 189
  *
190 190
  * @return void
191 191
  */
192
-function give_customers_view( $customer ) {
192
+function give_customers_view($customer) {
193 193
 
194
-	$customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' );
194
+	$customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments');
195 195
 
196 196
 	/**
197 197
 	 * Fires in donor profile screen, above the donor card.
@@ -200,32 +200,32 @@  discard block
 block discarded – undo
200 200
 	 *
201 201
 	 * @param object $customer The customer object being displayed.
202 202
 	 */
203
-	do_action( 'give_donor_card_top', $customer );
203
+	do_action('give_donor_card_top', $customer);
204 204
 	?>
205 205
 
206 206
 	<div id="donor-summary" class="info-wrapper customer-section postbox">
207 207
 
208
-		<form id="edit-customer-info" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer->id ); ?>">
208
+		<form id="edit-customer-info" method="post" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer->id); ?>">
209 209
 
210 210
 			<div class="customer-info">
211 211
 
212 212
 				<div class="donor-bio-header clearfix">
213 213
 
214 214
 					<div class="avatar-wrap left" id="customer-avatar">
215
-						<?php echo get_avatar( $customer->email ); ?>
215
+						<?php echo get_avatar($customer->email); ?>
216 216
 					</div>
217 217
 
218 218
 					<div id="customer-name-wrap" class="left">
219 219
 						<span class="customer-id">#<?php echo $customer->id; ?></span>
220
-						<span class="customer-name info-item edit-item"><input size="15" data-key="name" name="customerinfo[name]" type="text" value="<?php echo esc_attr( $customer->name ); ?>" placeholder="<?php esc_attr_e( 'Donor Name', 'give' ); ?>" /></span>
220
+						<span class="customer-name info-item edit-item"><input size="15" data-key="name" name="customerinfo[name]" type="text" value="<?php echo esc_attr($customer->name); ?>" placeholder="<?php esc_attr_e('Donor Name', 'give'); ?>" /></span>
221 221
 						<span class="customer-name info-item editable"><span data-key="name"><?php echo $customer->name; ?></span></span>
222 222
 					</div>
223 223
 					<p class="customer-since info-item">
224
-						<?php esc_html_e( 'Donor since', 'give' ); ?>
225
-						<?php echo date_i18n( give_date_format(), strtotime( $customer->date_created ) ) ?>
224
+						<?php esc_html_e('Donor since', 'give'); ?>
225
+						<?php echo date_i18n(give_date_format(), strtotime($customer->date_created)) ?>
226 226
 					</p>
227
-					<?php if ( current_user_can( $customer_edit_role ) ): ?>
228
-						<a href="#" id="edit-customer" class="button info-item editable customer-edit-link"><?php esc_html_e( 'Edit Donor', 'give' ); ?></a>
227
+					<?php if (current_user_can($customer_edit_role)): ?>
228
+						<a href="#" id="edit-customer" class="button info-item editable customer-edit-link"><?php esc_html_e('Edit Donor', 'give'); ?></a>
229 229
 					<?php endif; ?>
230 230
 				</div>
231 231
 				<!-- /donor-bio-header -->
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 					<table class="widefat">
236 236
 						<tbody>
237 237
 						<tr class="alternate">
238
-							<th scope="col"><label for="tablecell"><?php esc_html_e( 'User ID:', 'give' ); ?></label></th>
238
+							<th scope="col"><label for="tablecell"><?php esc_html_e('User ID:', 'give'); ?></label></th>
239 239
 							<td class="row-title">
240 240
 								<span class="customer-user-id info-item edit-item">
241 241
 									<?php
@@ -251,38 +251,38 @@  discard block
 block discarded – undo
251 251
 										'data'  => $data_atts,
252 252
 									);
253 253
 
254
-									if ( ! empty( $user_id ) ) {
255
-										$userdata           = get_userdata( $user_id );
254
+									if ( ! empty($user_id)) {
255
+										$userdata           = get_userdata($user_id);
256 256
 										$user_args['value'] = $userdata->user_login;
257 257
 									}
258 258
 
259
-									echo Give()->html->ajax_user_search( $user_args );
259
+									echo Give()->html->ajax_user_search($user_args);
260 260
 									?>
261 261
 									<input type="hidden" name="customerinfo[user_id]" data-key="user_id" value="<?php echo $customer->user_id; ?>" />
262 262
 								</span>
263 263
 			
264 264
 								<span class="customer-user-id info-item editable">
265
-									<?php if ( intval( $customer->user_id ) > 0 ) { ?>
265
+									<?php if (intval($customer->user_id) > 0) { ?>
266 266
 										<span data-key="user_id"><?php echo $customer->user_id; ?></span>
267 267
 									<?php } else { ?>
268
-										<span data-key="user_id"><?php esc_html_e( 'None', 'give' ); ?></span>
268
+										<span data-key="user_id"><?php esc_html_e('None', 'give'); ?></span>
269 269
 									<?php } ?>
270
-									<?php if ( current_user_can( $customer_edit_role ) && intval( $customer->user_id ) > 0 ) { ?>
271
-										<span class="disconnect-user"> - <a id="disconnect-customer" href="#disconnect" aria-label="<?php esc_attr_e( 'Disconnects the current user ID from this customer record.', 'give' ); ?>"><?php esc_html_e( 'Disconnect User', 'give' ); ?></a></span>
270
+									<?php if (current_user_can($customer_edit_role) && intval($customer->user_id) > 0) { ?>
271
+										<span class="disconnect-user"> - <a id="disconnect-customer" href="#disconnect" aria-label="<?php esc_attr_e('Disconnects the current user ID from this customer record.', 'give'); ?>"><?php esc_html_e('Disconnect User', 'give'); ?></a></span>
272 272
 									<?php } ?>
273 273
 								</span>
274 274
 							</td>
275 275
 						</tr>
276
-						<?php if ( isset( $customer->user_id ) && $customer->user_id > 0 ) : ?>
276
+						<?php if (isset($customer->user_id) && $customer->user_id > 0) : ?>
277 277
 
278 278
 							<tr>
279
-								<th scope="col"><?php esc_html_e( 'Address:', 'give' ); ?></th>
279
+								<th scope="col"><?php esc_html_e('Address:', 'give'); ?></th>
280 280
 								<td class="row-title">
281 281
 
282 282
 									<div class="customer-address-wrapper">
283 283
 
284 284
 										<?php
285
-										$address  = get_user_meta( $customer->user_id, '_give_user_address', true );
285
+										$address  = get_user_meta($customer->user_id, '_give_user_address', true);
286 286
 										$defaults = array(
287 287
 											'line1'   => '',
288 288
 											'line2'   => '',
@@ -292,10 +292,10 @@  discard block
 block discarded – undo
292 292
 											'zip'     => ''
293 293
 										);
294 294
 
295
-										$address = wp_parse_args( $address, $defaults );
295
+										$address = wp_parse_args($address, $defaults);
296 296
 										?>
297 297
 
298
-										<?php if ( ! empty( $address ) ) { ?>
298
+										<?php if ( ! empty($address)) { ?>
299 299
 											<span class="customer-address info-item editable">
300 300
 												<span class="info-item" data-key="line1"><?php echo $address['line1']; ?></span>
301 301
 												<span class="info-item" data-key="line2"><?php echo $address['line2']; ?></span>
@@ -306,43 +306,43 @@  discard block
 block discarded – undo
306 306
 											</span>
307 307
 										<?php } ?>
308 308
 										<span class="customer-address info-item edit-item">
309
-											<input class="info-item" type="text" data-key="line1" name="customerinfo[line1]" placeholder="<?php esc_attr_e( 'Address 1', 'give' ); ?>" value="<?php echo $address['line1']; ?>" />
310
-											<input class="info-item" type="text" data-key="line2" name="customerinfo[line2]" placeholder="<?php esc_attr_e( 'Address 2', 'give' ); ?>" value="<?php echo $address['line2']; ?>" />
311
-											<input class="info-item" type="text" data-key="city" name="customerinfo[city]" placeholder="<?php esc_attr_e( 'City', 'give' ); ?>" value="<?php echo $address['city']; ?>" />
309
+											<input class="info-item" type="text" data-key="line1" name="customerinfo[line1]" placeholder="<?php esc_attr_e('Address 1', 'give'); ?>" value="<?php echo $address['line1']; ?>" />
310
+											<input class="info-item" type="text" data-key="line2" name="customerinfo[line2]" placeholder="<?php esc_attr_e('Address 2', 'give'); ?>" value="<?php echo $address['line2']; ?>" />
311
+											<input class="info-item" type="text" data-key="city" name="customerinfo[city]" placeholder="<?php esc_attr_e('City', 'give'); ?>" value="<?php echo $address['city']; ?>" />
312 312
 											<select data-key="country" name="customerinfo[country]" id="billing_country" class="billing_country give-select edit-item">
313 313
 												<?php
314 314
 
315 315
 												$selected_country = $address['country'];
316 316
 
317 317
 												$countries = give_get_country_list();
318
-												foreach ( $countries as $country_code => $country ) {
319
-													echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>';
318
+												foreach ($countries as $country_code => $country) {
319
+													echo '<option value="'.esc_attr($country_code).'"'.selected($country_code, $selected_country, false).'>'.$country.'</option>';
320 320
 												}
321 321
 												?>
322 322
 											</select>
323 323
 											<?php
324 324
 											$selected_state = give_get_state();
325
-											$states         = give_get_states( $selected_country );
325
+											$states         = give_get_states($selected_country);
326 326
 
327
-											$selected_state = isset( $address['state'] ) ? $address['state'] : $selected_state;
327
+											$selected_state = isset($address['state']) ? $address['state'] : $selected_state;
328 328
 
329
-											if ( ! empty( $states ) ) {
329
+											if ( ! empty($states)) {
330 330
 												?>
331 331
 												<select data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-select info-item">
332 332
 													<?php
333
-													foreach ( $states as $state_code => $state ) {
334
-														echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>';
333
+													foreach ($states as $state_code => $state) {
334
+														echo '<option value="'.$state_code.'"'.selected($state_code, $selected_state, false).'>'.$state.'</option>';
335 335
 													}
336 336
 													?>
337 337
 												</select>
338 338
 												<?php
339 339
 											} else {
340 340
 												?>
341
-												<input type="text" size="6" data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-input info-item" placeholder="<?php esc_attr_e( 'State / Province', 'give' ); ?>" />
341
+												<input type="text" size="6" data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-input info-item" placeholder="<?php esc_attr_e('State / Province', 'give'); ?>" />
342 342
 												<?php
343 343
 											}
344 344
 											?>
345
-											<input class="info-item" type="text" data-key="zip" name="customerinfo[zip]" placeholder="<?php esc_attr_e( 'Zip / Postal Code', 'give' ); ?>" value="<?php echo $address['zip']; ?>" />
345
+											<input class="info-item" type="text" data-key="zip" name="customerinfo[zip]" placeholder="<?php esc_attr_e('Zip / Postal Code', 'give'); ?>" value="<?php echo $address['zip']; ?>" />
346 346
 										</span>
347 347
 
348 348
 									</div>
@@ -358,10 +358,10 @@  discard block
 block discarded – undo
358 358
 
359 359
 			<span id="customer-edit-actions" class="edit-item">
360 360
 				<input type="hidden" data-key="id" name="customerinfo[id]" value="<?php echo $customer->id; ?>" />
361
-				<?php wp_nonce_field( 'edit-customer', '_wpnonce', false, true ); ?>
361
+				<?php wp_nonce_field('edit-customer', '_wpnonce', false, true); ?>
362 362
 				<input type="hidden" name="give_action" value="edit-customer" />
363
-				<input type="submit" id="give-edit-customer-save" class="button-secondary" value="<?php esc_attr_e( 'Update Donor', 'give' ); ?>" />
364
-				<a id="give-edit-customer-cancel" href="" class="delete"><?php esc_html_e( 'Cancel', 'give' ); ?></a>
363
+				<input type="submit" id="give-edit-customer-save" class="button-secondary" value="<?php esc_attr_e('Update Donor', 'give'); ?>" />
364
+				<a id="give-edit-customer-cancel" href="" class="delete"><?php esc_html_e('Cancel', 'give'); ?></a>
365 365
 			</span>
366 366
 
367 367
 		</form>
@@ -376,24 +376,24 @@  discard block
 block discarded – undo
376 376
 	 *
377 377
 	 * @param object $customer The customer object being displayed.
378 378
 	 */
379
-	do_action( 'give_donor_before_stats', $customer );
379
+	do_action('give_donor_before_stats', $customer);
380 380
 	?>
381 381
 
382 382
 	<div id="customer-stats-wrapper" class="customer-section postbox clear">
383 383
 		<ul>
384 384
 			<li>
385
-				<a href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . urlencode( $customer->email ) ); ?>">
385
+				<a href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history&user='.urlencode($customer->email)); ?>">
386 386
 					<span class="dashicons dashicons-heart"></span>
387 387
 					<?php
388 388
 					//Completed Donations
389
-					$completed_donations_text = sprintf( _n( '%d Completed Donation', '%d Completed Donations', $customer->purchase_count, 'give' ), $customer->purchase_count );
390
-					echo apply_filters( 'give_donor_completed_donations', $completed_donations_text, $customer );
389
+					$completed_donations_text = sprintf(_n('%d Completed Donation', '%d Completed Donations', $customer->purchase_count, 'give'), $customer->purchase_count);
390
+					echo apply_filters('give_donor_completed_donations', $completed_donations_text, $customer);
391 391
 					?>
392 392
 				</a>
393 393
 			</li>
394 394
 			<li>
395 395
 				<span class="dashicons dashicons-chart-area"></span>
396
-				<?php echo give_currency_filter( give_format_amount( $customer->purchase_value ) ); ?> <?php esc_html_e( 'Lifetime Donations', 'give' ); ?>
396
+				<?php echo give_currency_filter(give_format_amount($customer->purchase_value)); ?> <?php esc_html_e('Lifetime Donations', 'give'); ?>
397 397
 			</li>
398 398
 			<?php
399 399
 			/**
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 			 *
406 406
 			 * @param object $customer The customer object being displayed.
407 407
 			 */
408
-			do_action( 'give_donor_stats_list', $customer );
408
+			do_action('give_donor_stats_list', $customer);
409 409
 			?>
410 410
 		</ul>
411 411
 	</div>
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 	 *
419 419
 	 * @param object $customer The customer object being displayed.
420 420
 	 */
421
-	do_action( 'give_donor_before_tables_wrapper', $customer );
421
+	do_action('give_donor_before_tables_wrapper', $customer);
422 422
 	?>
423 423
 
424 424
 	<div id="customer-tables-wrapper" class="customer-section">
@@ -431,40 +431,40 @@  discard block
 block discarded – undo
431 431
 		 *
432 432
 		 * @param object $customer The customer object being displayed.
433 433
 		 */
434
-		do_action( 'give_donor_before_tables', $customer );
434
+		do_action('give_donor_before_tables', $customer);
435 435
 		?>
436 436
 
437
-		<h3><?php _e( 'Donor Emails', 'give' ); ?></h3>
437
+		<h3><?php _e('Donor Emails', 'give'); ?></h3>
438 438
 
439 439
 		<table class="wp-list-table widefat striped emails">
440 440
 			<thead>
441 441
 				<tr>
442
-					<th><?php _e( 'Email', 'give' ); ?></th>
443
-					<th><?php _e( 'Actions', 'give' ); ?></th>
442
+					<th><?php _e('Email', 'give'); ?></th>
443
+					<th><?php _e('Actions', 'give'); ?></th>
444 444
 				</tr>
445 445
 			</thead>
446 446
 
447 447
 			<tbody>
448
-				<?php if ( ! empty( $customer->emails ) ) { ?>
448
+				<?php if ( ! empty($customer->emails)) { ?>
449 449
 
450
-					<?php foreach ( $customer->emails as $key => $email ) : ?>
450
+					<?php foreach ($customer->emails as $key => $email) : ?>
451 451
 						<tr data-key="<?php echo $key; ?>">
452 452
 							<td>
453 453
 								<?php echo $email; ?>
454
-								<?php if ( 'primary' === $key ) : ?>
454
+								<?php if ('primary' === $key) : ?>
455 455
 									<span class="dashicons dashicons-star-filled primary-email-icon"></span>
456 456
 								<?php endif; ?>
457 457
 							</td>
458 458
 							<td>
459
-								<?php if ( 'primary' !== $key ) : ?>
459
+								<?php if ('primary' !== $key) : ?>
460 460
 									<?php
461
-									$base_url    = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer->id );
462
-									$promote_url = wp_nonce_url( add_query_arg( array( 'email' => rawurlencode( $email ), 'give_action' => 'set_donor_primary_email'), $base_url ), 'give-set-donor-primary-email' );
463
-									$remove_url  = wp_nonce_url( add_query_arg( array( 'email' => rawurlencode( $email ), 'give_action' => 'remove_donor_email' ), $base_url ), 'give-remove-donor-email'      );
461
+									$base_url    = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer->id);
462
+									$promote_url = wp_nonce_url(add_query_arg(array('email' => rawurlencode($email), 'give_action' => 'set_donor_primary_email'), $base_url), 'give-set-donor-primary-email');
463
+									$remove_url  = wp_nonce_url(add_query_arg(array('email' => rawurlencode($email), 'give_action' => 'remove_donor_email'), $base_url), 'give-remove-donor-email');
464 464
 									?>
465
-									<a href="<?php echo $promote_url; ?>"><?php _e( 'Make Primary', 'give' ); ?></a>
465
+									<a href="<?php echo $promote_url; ?>"><?php _e('Make Primary', 'give'); ?></a>
466 466
 									&nbsp;|&nbsp;
467
-									<a href="<?php echo $remove_url; ?>" class="delete"><?php _e( 'Remove', 'give' ); ?></a>
467
+									<a href="<?php echo $remove_url; ?>" class="delete"><?php _e('Remove', 'give'); ?></a>
468 468
 								<?php endif; ?>
469 469
 							</td>
470 470
 						</tr>
@@ -474,56 +474,56 @@  discard block
 block discarded – undo
474 474
 						<td colspan="2" class="add-customer-email-td">
475 475
 							<div class="add-customer-email-wrapper">
476 476
 								<input type="hidden" name="customer-id" value="<?php echo $customer->id; ?>" />
477
-								<?php wp_nonce_field( 'give_add_donor_email', 'add_email_nonce', false, true ); ?>
478
-								<input type="email" name="additional-email" value="" placeholder="<?php _e( 'Email Address', 'give' ); ?>" />&nbsp;
479
-								<input type="checkbox" name="make-additional-primary" value="1" id="make-additional-primary" />&nbsp;<label for="make-additional-primary"><?php _e( 'Make Primary', 'give' ); ?></label>
480
-								<button class="button-secondary give-add-customer-email" id="add-customer-email"><?php _e( 'Add Email', 'give' ); ?></button>
477
+								<?php wp_nonce_field('give_add_donor_email', 'add_email_nonce', false, true); ?>
478
+								<input type="email" name="additional-email" value="" placeholder="<?php _e('Email Address', 'give'); ?>" />&nbsp;
479
+								<input type="checkbox" name="make-additional-primary" value="1" id="make-additional-primary" />&nbsp;<label for="make-additional-primary"><?php _e('Make Primary', 'give'); ?></label>
480
+								<button class="button-secondary give-add-customer-email" id="add-customer-email"><?php _e('Add Email', 'give'); ?></button>
481 481
 								<span class="spinner"></span>
482 482
 							</div>
483 483
 							<div class="notice-wrap"></div>
484 484
 						</td>
485 485
 					</tr>
486 486
 				<?php } else { ?>
487
-					<tr><td colspan="2"><?php _e( 'No Emails Found', 'easy-digital-downloads' ); ?></td></tr>
487
+					<tr><td colspan="2"><?php _e('No Emails Found', 'easy-digital-downloads'); ?></td></tr>
488 488
 				<?php } ?>
489 489
 			</tbody>
490 490
 		</table>
491 491
 
492
-		<h3><?php esc_html_e( 'Recent Donations', 'give' ); ?></h3>
492
+		<h3><?php esc_html_e('Recent Donations', 'give'); ?></h3>
493 493
 		<?php
494
-		$payment_ids = explode( ',', $customer->payment_ids );
495
-		$payments    = give_get_payments( array( 'post__in' => $payment_ids ) );
496
-		$payments    = array_slice( $payments, 0, 10 );
494
+		$payment_ids = explode(',', $customer->payment_ids);
495
+		$payments    = give_get_payments(array('post__in' => $payment_ids));
496
+		$payments    = array_slice($payments, 0, 10);
497 497
 		?>
498 498
 		<table class="wp-list-table widefat striped payments">
499 499
 			<thead>
500 500
 			<tr>
501
-				<th scope="col"><?php esc_html_e( 'ID', 'give' ); ?></th>
502
-				<th scope="col"><?php esc_html_e( 'Amount', 'give' ); ?></th>
503
-				<th scope="col"><?php esc_html_e( 'Date', 'give' ); ?></th>
504
-				<th scope="col"><?php esc_html_e( 'Status', 'give' ); ?></th>
505
-				<th scope="col"><?php esc_html_e( 'Actions', 'give' ); ?></th>
501
+				<th scope="col"><?php esc_html_e('ID', 'give'); ?></th>
502
+				<th scope="col"><?php esc_html_e('Amount', 'give'); ?></th>
503
+				<th scope="col"><?php esc_html_e('Date', 'give'); ?></th>
504
+				<th scope="col"><?php esc_html_e('Status', 'give'); ?></th>
505
+				<th scope="col"><?php esc_html_e('Actions', 'give'); ?></th>
506 506
 			</tr>
507 507
 			</thead>
508 508
 			<tbody>
509
-			<?php if ( ! empty( $payments ) ) { ?>
510
-				<?php foreach ( $payments as $payment ) : ?>
509
+			<?php if ( ! empty($payments)) { ?>
510
+				<?php foreach ($payments as $payment) : ?>
511 511
 					<tr>
512 512
 						<td><?php echo $payment->ID; ?></td>
513
-						<td><?php echo give_payment_amount( $payment->ID ); ?></td>
514
-						<td><?php echo date_i18n( give_date_format(), strtotime( $payment->post_date ) ); ?></td>
515
-						<td><?php echo give_get_payment_status( $payment, true ); ?></td>
513
+						<td><?php echo give_payment_amount($payment->ID); ?></td>
514
+						<td><?php echo date_i18n(give_date_format(), strtotime($payment->post_date)); ?></td>
515
+						<td><?php echo give_get_payment_status($payment, true); ?></td>
516 516
 						<td>
517 517
 							<?php
518 518
 							printf(
519 519
 								'<a href="%1$s" aria-label="%2$s">%3$s</a>',
520
-								admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $payment->ID ),
520
+								admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id='.$payment->ID),
521 521
 								sprintf(
522 522
 									/* translators: %s: Donation ID */
523
-									esc_attr__( 'View Donation %s.', 'give' ),
523
+									esc_attr__('View Donation %s.', 'give'),
524 524
 									$payment->ID
525 525
 								),
526
-								esc_html__( 'View Donation', 'give' )
526
+								esc_html__('View Donation', 'give')
527 527
 							);
528 528
 							?>
529 529
 
@@ -538,46 +538,46 @@  discard block
 block discarded – undo
538 538
 							 * @param object $customer The customer object being displayed.
539 539
 							 * @param object $payment  The payment object being displayed.
540 540
 							 */
541
-							do_action( 'give_donor_recent_purchases_actions', $customer, $payment );
541
+							do_action('give_donor_recent_purchases_actions', $customer, $payment);
542 542
 							?>
543 543
 						</td>
544 544
 					</tr>
545 545
 				<?php endforeach; ?>
546 546
 			<?php } else { ?>
547 547
 				<tr>
548
-					<td colspan="5"><?php esc_html_e( 'No donations found.', 'give' ); ?></td>
548
+					<td colspan="5"><?php esc_html_e('No donations found.', 'give'); ?></td>
549 549
 				</tr>
550 550
 			<?php } ?>
551 551
 			</tbody>
552 552
 		</table>
553 553
 
554
-		<h3><?php esc_html_e( 'Completed Forms', 'give' ); ?></h3>
554
+		<h3><?php esc_html_e('Completed Forms', 'give'); ?></h3>
555 555
 		<?php
556
-		$donations = give_get_users_completed_donations( $customer->email );
556
+		$donations = give_get_users_completed_donations($customer->email);
557 557
 		?>
558 558
 		<table class="wp-list-table widefat striped donations">
559 559
 			<thead>
560 560
 			<tr>
561
-				<th scope="col"><?php esc_html_e( 'Form', 'give' ); ?></th>
562
-				<th scope="col" width="120px"><?php esc_html_e( 'Actions', 'give' ); ?></th>
561
+				<th scope="col"><?php esc_html_e('Form', 'give'); ?></th>
562
+				<th scope="col" width="120px"><?php esc_html_e('Actions', 'give'); ?></th>
563 563
 			</tr>
564 564
 			</thead>
565 565
 			<tbody>
566
-			<?php if ( ! empty( $donations ) ) { ?>
567
-				<?php foreach ( $donations as $donation ) : ?>
566
+			<?php if ( ! empty($donations)) { ?>
567
+				<?php foreach ($donations as $donation) : ?>
568 568
 					<tr>
569 569
 						<td><?php echo $donation->post_title; ?></td>
570 570
 						<td>
571 571
 							<?php
572 572
 							printf(
573 573
 								'<a href="%1$s" aria-label="%2$s">%3$s</a>',
574
-								esc_url( admin_url( 'post.php?action=edit&post=' . $donation->ID ) ),
574
+								esc_url(admin_url('post.php?action=edit&post='.$donation->ID)),
575 575
 								sprintf(
576 576
 									/* translators: %s: form name */
577
-									esc_attr__( 'View Form %s.', 'give' ),
577
+									esc_attr__('View Form %s.', 'give'),
578 578
 									$donation->post_title
579 579
 								),
580
-								esc_html__( 'View Form', 'give' )
580
+								esc_html__('View Form', 'give')
581 581
 							);
582 582
 							?>
583 583
 						</td>
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
 				<?php endforeach; ?>
586 586
 			<?php } else { ?>
587 587
 				<tr>
588
-					<td colspan="2"><?php esc_html_e( 'No completed donations found.', 'give' ); ?></td>
588
+					<td colspan="2"><?php esc_html_e('No completed donations found.', 'give'); ?></td>
589 589
 				</tr>
590 590
 			<?php } ?>
591 591
 			</tbody>
@@ -599,7 +599,7 @@  discard block
 block discarded – undo
599 599
 		 *
600 600
 		 * @param object $customer The customer object being displayed.
601 601
 		 */
602
-		do_action( 'give_donor_after_tables', $customer );
602
+		do_action('give_donor_after_tables', $customer);
603 603
 		?>
604 604
 
605 605
 	</div>
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
 	 *
613 613
 	 * @param object $customer The customer object being displayed.
614 614
 	 */
615
-	do_action( 'give_donor_card_bottom', $customer );
615
+	do_action('give_donor_card_bottom', $customer);
616 616
 
617 617
 }
618 618
 
@@ -625,30 +625,30 @@  discard block
 block discarded – undo
625 625
  *
626 626
  * @return void
627 627
  */
628
-function give_customer_notes_view( $customer ) {
628
+function give_customer_notes_view($customer) {
629 629
 
630
-	$paged          = isset( $_GET['paged'] ) && is_numeric( $_GET['paged'] ) ? $_GET['paged'] : 1;
631
-	$paged          = absint( $paged );
630
+	$paged          = isset($_GET['paged']) && is_numeric($_GET['paged']) ? $_GET['paged'] : 1;
631
+	$paged          = absint($paged);
632 632
 	$note_count     = $customer->get_notes_count();
633
-	$per_page       = apply_filters( 'give_customer_notes_per_page', 20 );
634
-	$total_pages    = ceil( $note_count / $per_page );
635
-	$customer_notes = $customer->get_notes( $per_page, $paged );
633
+	$per_page       = apply_filters('give_customer_notes_per_page', 20);
634
+	$total_pages    = ceil($note_count / $per_page);
635
+	$customer_notes = $customer->get_notes($per_page, $paged);
636 636
 	?>
637 637
 
638 638
 	<div id="customer-notes-wrapper">
639 639
 		<div class="customer-notes-header">
640
-			<?php echo get_avatar( $customer->email, 30 ); ?> <span><?php echo $customer->name; ?></span>
640
+			<?php echo get_avatar($customer->email, 30); ?> <span><?php echo $customer->name; ?></span>
641 641
 		</div>
642
-		<h3><?php esc_html_e( 'Notes', 'give' ); ?></h3>
642
+		<h3><?php esc_html_e('Notes', 'give'); ?></h3>
643 643
 
644
-		<?php if ( 1 == $paged ) : ?>
644
+		<?php if (1 == $paged) : ?>
645 645
 			<div style="display: block; margin-bottom: 55px;">
646
-				<form id="give-add-customer-note" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=notes&id=' . $customer->id ); ?>">
646
+				<form id="give-add-customer-note" method="post" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=notes&id='.$customer->id); ?>">
647 647
 					<textarea id="customer-note" name="customer_note" class="customer-note-input" rows="10"></textarea>
648 648
 					<br />
649 649
 					<input type="hidden" id="customer-id" name="customer_id" value="<?php echo $customer->id; ?>" />
650 650
 					<input type="hidden" name="give_action" value="add-customer-note" />
651
-					<?php wp_nonce_field( 'add-customer-note', 'add_customer_note_nonce', true, true ); ?>
651
+					<?php wp_nonce_field('add-customer-note', 'add_customer_note_nonce', true, true); ?>
652 652
 					<input id="add-customer-note" class="right button-primary" type="submit" value="Add Note" />
653 653
 				</form>
654 654
 			</div>
@@ -663,26 +663,26 @@  discard block
 block discarded – undo
663 663
 			'show_all' => true
664 664
 		);
665 665
 
666
-		echo paginate_links( $pagination_args );
666
+		echo paginate_links($pagination_args);
667 667
 		?>
668 668
 
669 669
 		<div id="give-customer-notes" class="postbox">
670
-			<?php if ( count( $customer_notes ) > 0 ) { ?>
671
-				<?php foreach ( $customer_notes as $key => $note ) : ?>
670
+			<?php if (count($customer_notes) > 0) { ?>
671
+				<?php foreach ($customer_notes as $key => $note) : ?>
672 672
 					<div class="customer-note-wrapper dashboard-comment-wrap comment-item">
673 673
 					<span class="note-content-wrap">
674
-						<?php echo stripslashes( $note ); ?>
674
+						<?php echo stripslashes($note); ?>
675 675
 					</span>
676 676
 					</div>
677 677
 				<?php endforeach; ?>
678 678
 			<?php } else { ?>
679 679
 				<div class="give-no-customer-notes">
680
-					<?php esc_html_e( 'No donor notes found.', 'give' ); ?>
680
+					<?php esc_html_e('No donor notes found.', 'give'); ?>
681 681
 				</div>
682 682
 			<?php } ?>
683 683
 		</div>
684 684
 
685
-		<?php echo paginate_links( $pagination_args ); ?>
685
+		<?php echo paginate_links($pagination_args); ?>
686 686
 
687 687
 	</div>
688 688
 
@@ -698,9 +698,9 @@  discard block
 block discarded – undo
698 698
  *
699 699
  * @return void
700 700
  */
701
-function give_customers_delete_view( $customer ) {
701
+function give_customers_delete_view($customer) {
702 702
 
703
-	$customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' );
703
+	$customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments');
704 704
 
705 705
 	/**
706 706
 	 * Fires in donor delete screen, above the content.
@@ -709,15 +709,15 @@  discard block
 block discarded – undo
709 709
 	 *
710 710
 	 * @param object $customer The customer object being displayed.
711 711
 	 */
712
-	do_action( 'give_customer_delete_top', $customer );
712
+	do_action('give_customer_delete_top', $customer);
713 713
 	?>
714 714
 
715 715
 	<div class="info-wrapper customer-section">
716 716
 
717
-		<form id="delete-customer" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $customer->id ); ?>">
717
+		<form id="delete-customer" method="post" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$customer->id); ?>">
718 718
 
719 719
 			<div class="customer-notes-header">
720
-				<?php echo get_avatar( $customer->email, 30 ); ?> <span><?php echo $customer->name; ?></span>
720
+				<?php echo get_avatar($customer->email, 30); ?> <span><?php echo $customer->name; ?></span>
721 721
 			</div>
722 722
 
723 723
 
@@ -725,16 +725,16 @@  discard block
 block discarded – undo
725 725
 
726 726
 				<span class="delete-customer-options">
727 727
 					<p>
728
-						<?php echo Give()->html->checkbox( array( 'name' => 'give-customer-delete-confirm' ) ); ?>
729
-						<label for="give-customer-delete-confirm"><?php esc_html_e( 'Are you sure you want to delete this donor?', 'give' ); ?></label>
728
+						<?php echo Give()->html->checkbox(array('name' => 'give-customer-delete-confirm')); ?>
729
+						<label for="give-customer-delete-confirm"><?php esc_html_e('Are you sure you want to delete this donor?', 'give'); ?></label>
730 730
 					</p>
731 731
 
732 732
 					<p>
733
-						<?php echo Give()->html->checkbox( array(
733
+						<?php echo Give()->html->checkbox(array(
734 734
 							'name'    => 'give-customer-delete-records',
735
-							'options' => array( 'disabled' => true )
736
-						) ); ?>
737
-						<label for="give-customer-delete-records"><?php esc_html_e( 'Delete all associated donations and records?', 'give' ); ?></label>
735
+							'options' => array('disabled' => true)
736
+						)); ?>
737
+						<label for="give-customer-delete-records"><?php esc_html_e('Delete all associated donations and records?', 'give'); ?></label>
738 738
 					</p>
739 739
 
740 740
 					<?php
@@ -747,16 +747,16 @@  discard block
 block discarded – undo
747 747
 					 *
748 748
 					 * @param object $customer The customer object being displayed.
749 749
 					 */
750
-					do_action( 'give_customer_delete_inputs', $customer );
750
+					do_action('give_customer_delete_inputs', $customer);
751 751
 					?>
752 752
 				</span>
753 753
 
754 754
 				<span id="customer-edit-actions">
755 755
 					<input type="hidden" name="customer_id" value="<?php echo $customer->id; ?>" />
756
-					<?php wp_nonce_field( 'delete-customer', '_wpnonce', false, true ); ?>
756
+					<?php wp_nonce_field('delete-customer', '_wpnonce', false, true); ?>
757 757
 					<input type="hidden" name="give_action" value="delete-customer" />
758
-					<input type="submit" disabled="disabled" id="give-delete-customer" class="button-primary" value="<?php esc_attr_e( 'Delete Donor', 'give' ); ?>" />
759
-					<a id="give-delete-customer-cancel" href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer->id ); ?>" class="delete"><?php esc_html_e( 'Cancel', 'give' ); ?></a>
758
+					<input type="submit" disabled="disabled" id="give-delete-customer" class="button-primary" value="<?php esc_attr_e('Delete Donor', 'give'); ?>" />
759
+					<a id="give-delete-customer-cancel" href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer->id); ?>" class="delete"><?php esc_html_e('Cancel', 'give'); ?></a>
760 760
 				</span>
761 761
 
762 762
 			</div>
@@ -772,5 +772,5 @@  discard block
 block discarded – undo
772 772
 	 *
773 773
 	 * @param object $customer The customer object being displayed.
774 774
 	 */
775
-	do_action( 'give_customer_delete_bottom', $customer );
775
+	do_action('give_customer_delete_bottom', $customer);
776 776
 }
Please login to merge, or discard this patch.
includes/admin/reporting/class-donor-reports-table.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -173,8 +173,8 @@
 block discarded – undo
173 173
 
174 174
 			case 'num_purchases' :
175 175
 				$value = '<a href="' .
176
-				         admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . urlencode( $item['email'] )
177
-				         ) . '">' . esc_html( $item['num_purchases'] ) . '</a>';
176
+						 admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . urlencode( $item['email'] )
177
+						 ) . '">' . esc_html( $item['num_purchases'] ) . '</a>';
178 178
 				break;
179 179
 
180 180
 			case 'amount_spent' :
Please login to merge, or discard this patch.
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -10,13 +10,13 @@  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
 
17 17
 // Load WP_List_Table if not loaded
18
-if ( ! class_exists( 'WP_List_Table' ) ) {
19
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
18
+if ( ! class_exists('WP_List_Table')) {
19
+	require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
20 20
 }
21 21
 
22 22
 /**
@@ -62,11 +62,11 @@  discard block
 block discarded – undo
62 62
 		global $status, $page;
63 63
 
64 64
 		// Set parent defaults
65
-		parent::__construct( array(
66
-			'singular' => esc_html__( 'Donor', 'give' ),     // Singular name of the listed records
67
-			'plural'   => esc_html__( 'Donors', 'give' ),    // Plural name of the listed records
65
+		parent::__construct(array(
66
+			'singular' => esc_html__('Donor', 'give'), // Singular name of the listed records
67
+			'plural'   => esc_html__('Donors', 'give'), // Plural name of the listed records
68 68
 			'ajax'     => false                        // Does this table support ajax?
69
-		) );
69
+		));
70 70
 
71 71
 	}
72 72
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	 *
84 84
 	 * @return false
85 85
 	 */
86
-	public function search_box( $text, $input_id ) {
86
+	public function search_box($text, $input_id) {
87 87
 		return;
88 88
 	}
89 89
 
@@ -98,20 +98,20 @@  discard block
 block discarded – undo
98 98
 	 *
99 99
 	 * @return void
100 100
 	 */
101
-	public function give_search_box( $text, $input_id ) {
102
-		$input_id = $input_id . '-search-input';
101
+	public function give_search_box($text, $input_id) {
102
+		$input_id = $input_id.'-search-input';
103 103
 
104
-		if ( ! empty( $_REQUEST['orderby'] ) ) {
105
-			echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
104
+		if ( ! empty($_REQUEST['orderby'])) {
105
+			echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />';
106 106
 		}
107
-		if ( ! empty( $_REQUEST['order'] ) ) {
108
-			echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
107
+		if ( ! empty($_REQUEST['order'])) {
108
+			echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />';
109 109
 		}
110 110
 		?>
111 111
 		<p class="search-box donor-search" role="search">
112 112
 			<label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label>
113 113
 			<input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" />
114
-			<?php submit_button( $text, 'button', false, false, array( 'ID' => 'search-submit' ) ); ?>
114
+			<?php submit_button($text, 'button', false, false, array('ID' => 'search-submit')); ?>
115 115
 		</p>
116 116
 	<?php
117 117
 	}
@@ -124,33 +124,33 @@  discard block
 block discarded – undo
124 124
 	 *
125 125
 	 * @param string $which
126 126
 	 */
127
-	protected function display_tablenav( $which ) {
127
+	protected function display_tablenav($which) {
128 128
 
129
-		if ( 'top' === $which ) {
130
-			wp_nonce_field( 'bulk-' . $this->_args['plural'] );
129
+		if ('top' === $which) {
130
+			wp_nonce_field('bulk-'.$this->_args['plural']);
131 131
 		}
132 132
 		?>
133
-		<div class="tablenav give-clearfix <?php echo esc_attr( $which ); ?>">
133
+		<div class="tablenav give-clearfix <?php echo esc_attr($which); ?>">
134 134
 
135
-			<?php if ( 'top' === $which ) { ?>
135
+			<?php if ('top' === $which) { ?>
136 136
 				<h3 class="alignleft reports-earnings-title">
137
-					<span><?php esc_html_e( 'Donors Report', 'give' ); ?></span>
137
+					<span><?php esc_html_e('Donors Report', 'give'); ?></span>
138 138
 				</h3>
139 139
 			<?php } ?>
140 140
 
141 141
 			<div class="alignright tablenav-right">
142 142
 				<div class="actions bulkactions">
143 143
 					<?php
144
-					if ( 'top' === $which ) {
145
-						$this->give_search_box( esc_html__( 'Search Donors', 'give' ), 'give-donors-report-search' );
144
+					if ('top' === $which) {
145
+						$this->give_search_box(esc_html__('Search Donors', 'give'), 'give-donors-report-search');
146 146
 					}
147 147
 
148
-					$this->bulk_actions( $which ); ?>
148
+					$this->bulk_actions($which); ?>
149 149
 
150 150
 				</div>
151 151
 				<?php
152
-				$this->extra_tablenav( $which );
153
-				$this->pagination( $which );
152
+				$this->extra_tablenav($which);
153
+				$this->pagination($which);
154 154
 				?>
155 155
 			</div>
156 156
 
@@ -172,25 +172,25 @@  discard block
 block discarded – undo
172 172
 	 *
173 173
 	 * @return string Column Name
174 174
 	 */
175
-	public function column_default( $item, $column_name ) {
176
-		switch ( $column_name ) {
175
+	public function column_default($item, $column_name) {
176
+		switch ($column_name) {
177 177
 
178 178
 			case 'num_purchases' :
179
-				$value = '<a href="' .
180
-				         admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . urlencode( $item['email'] )
181
-				         ) . '">' . esc_html( $item['num_purchases'] ) . '</a>';
179
+				$value = '<a href="'.
180
+				         admin_url('edit.php?post_type=give_forms&page=give-payment-history&user='.urlencode($item['email'])
181
+				         ).'">'.esc_html($item['num_purchases']).'</a>';
182 182
 				break;
183 183
 
184 184
 			case 'amount_spent' :
185
-				$value = give_currency_filter( give_format_amount( $item[ $column_name ] ) );
185
+				$value = give_currency_filter(give_format_amount($item[$column_name]));
186 186
 				break;
187 187
 
188 188
 			default:
189
-				$value = isset( $item[ $column_name ] ) ? $item[ $column_name ] : null;
189
+				$value = isset($item[$column_name]) ? $item[$column_name] : null;
190 190
 				break;
191 191
 		}
192 192
 
193
-		return apply_filters( "give_report_column_{$column_name}", $value, $item['id'] );
193
+		return apply_filters("give_report_column_{$column_name}", $value, $item['id']);
194 194
 	}
195 195
 
196 196
 	/**
@@ -202,14 +202,14 @@  discard block
 block discarded – undo
202 202
 	 */
203 203
 	public function get_columns() {
204 204
 		$columns = array(
205
-			'name'          => esc_html__( 'Name', 'give' ),
206
-			'id'            => esc_html__( 'ID', 'give' ),
207
-			'email'         => esc_html__( 'Email', 'give' ),
208
-			'num_purchases' => esc_html__( 'Donations', 'give' ),
209
-			'amount_spent'  => esc_html__( 'Total Donated', 'give' )
205
+			'name'          => esc_html__('Name', 'give'),
206
+			'id'            => esc_html__('ID', 'give'),
207
+			'email'         => esc_html__('Email', 'give'),
208
+			'num_purchases' => esc_html__('Donations', 'give'),
209
+			'amount_spent'  => esc_html__('Total Donated', 'give')
210 210
 		);
211 211
 
212
-		return apply_filters( 'give_report_donor_columns', $columns );
212
+		return apply_filters('give_report_donor_columns', $columns);
213 213
 
214 214
 	}
215 215
 
@@ -222,10 +222,10 @@  discard block
 block discarded – undo
222 222
 	 */
223 223
 	public function get_sortable_columns() {
224 224
 		return array(
225
-			'id'            => array( 'id', true ),
226
-			'name'          => array( 'name', true ),
227
-			'num_purchases' => array( 'purchase_count', false ),
228
-			'amount_spent'  => array( 'purchase_value', false ),
225
+			'id'            => array('id', true),
226
+			'name'          => array('name', true),
227
+			'num_purchases' => array('purchase_count', false),
228
+			'amount_spent'  => array('purchase_value', false),
229 229
 		);
230 230
 	}
231 231
 
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 	 * @since  1.0
237 237
 	 * @return void
238 238
 	 */
239
-	public function bulk_actions( $which = '' ) {
239
+	public function bulk_actions($which = '') {
240 240
 
241 241
 	}
242 242
 
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 	 * @return int Current page number
249 249
 	 */
250 250
 	public function get_paged() {
251
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
251
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
252 252
 	}
253 253
 
254 254
 	/**
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 	 * @return mixed string If search is present, false otherwise
260 260
 	 */
261 261
 	public function get_search() {
262
-		return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false;
262
+		return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false;
263 263
 	}
264 264
 
265 265
 	/**
@@ -276,10 +276,10 @@  discard block
 block discarded – undo
276 276
 
277 277
 		$data    = array();
278 278
 		$paged   = $this->get_paged();
279
-		$offset  = $this->per_page * ( $paged - 1 );
279
+		$offset  = $this->per_page * ($paged - 1);
280 280
 		$search  = $this->get_search();
281
-		$order   = isset( $_GET['order'] ) ? sanitize_text_field( $_GET['order'] ) : 'DESC';
282
-		$orderby = isset( $_GET['orderby'] ) ? sanitize_text_field( $_GET['orderby'] ) : 'id';
281
+		$order   = isset($_GET['order']) ? sanitize_text_field($_GET['order']) : 'DESC';
282
+		$orderby = isset($_GET['orderby']) ? sanitize_text_field($_GET['orderby']) : 'id';
283 283
 
284 284
 		$args = array(
285 285
 			'number'  => $this->per_page,
@@ -288,21 +288,21 @@  discard block
 block discarded – undo
288 288
 			'orderby' => $orderby
289 289
 		);
290 290
 
291
-		if ( is_email( $search ) ) {
291
+		if (is_email($search)) {
292 292
 			$args['email'] = $search;
293
-		} elseif ( is_numeric( $search ) ) {
293
+		} elseif (is_numeric($search)) {
294 294
 			$args['id'] = $search;
295 295
 		}
296 296
 
297
-		$donors = Give()->customers->get_customers( $args );
297
+		$donors = Give()->customers->get_customers($args);
298 298
 
299
-		if ( $donors ) {
299
+		if ($donors) {
300 300
 
301
-			$this->count = count( $donors );
301
+			$this->count = count($donors);
302 302
 
303
-			foreach ( $donors as $donor ) {
303
+			foreach ($donors as $donor) {
304 304
 
305
-				$user_id = ! empty( $donor->user_id ) ? absint( $donor->user_id ) : 0;
305
+				$user_id = ! empty($donor->user_id) ? absint($donor->user_id) : 0;
306 306
 
307 307
 				$data[] = array(
308 308
 					'id'            => $donor->id,
@@ -335,16 +335,16 @@  discard block
 block discarded – undo
335 335
 		$hidden   = array(); // No hidden columns
336 336
 		$sortable = $this->get_sortable_columns();
337 337
 
338
-		$this->_column_headers = array( $columns, $hidden, $sortable );
338
+		$this->_column_headers = array($columns, $hidden, $sortable);
339 339
 
340 340
 		$this->items = $this->reports_data();
341 341
 
342 342
 		$this->total = give_count_total_customers();
343 343
 
344
-		$this->set_pagination_args( array(
344
+		$this->set_pagination_args(array(
345 345
 			'total_items' => $this->total,
346 346
 			'per_page'    => $this->per_page,
347
-			'total_pages' => ceil( $this->total / $this->per_page )
348
-		) );
347
+			'total_pages' => ceil($this->total / $this->per_page)
348
+		));
349 349
 	}
350 350
 }
351 351
\ No newline at end of file
Please login to merge, or discard this patch.