Completed
Push — master ( 0af146...0e0d02 )
by Devin
13s
created
includes/admin/customers/customer-actions.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
  * and redirect back to the donor interface for feedback
528 528
  *
529 529
  * @since  1.7
530
- * @return bool|null
530
+ * @return false|null
531 531
  */
532 532
 function give_remove_donor_email() {
533 533
 	if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
  * and redirect back to the donor interface for feedback
569 569
  *
570 570
  * @since  1.7
571
- * @return bool|null
571
+ * @return false|null
572 572
  */
573 573
 function give_set_donor_primary_email() {
574 574
 	if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
Please login to merge, or discard this patch.
Spacing   +184 added lines, -184 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -23,15 +23,15 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @return array $output Response messages
25 25
  */
26
-function give_edit_customer( $args ) {
26
+function give_edit_customer($args) {
27 27
 
28
-	$customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' );
28
+	$customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments');
29 29
 
30
-	if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) {
31
-		wp_die( esc_html__( 'You do not have permission to edit this donor.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
30
+	if ( ! is_admin() || ! current_user_can($customer_edit_role)) {
31
+		wp_die(esc_html__('You do not have permission to edit this donor.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
32 32
 	}
33 33
 
34
-	if ( empty( $args ) ) {
34
+	if (empty($args)) {
35 35
 		return;
36 36
 	}
37 37
 
@@ -39,12 +39,12 @@  discard block
 block discarded – undo
39 39
 	$customer_id   = (int) $args['customerinfo']['id'];
40 40
 	$nonce         = $args['_wpnonce'];
41 41
 
42
-	if ( ! wp_verify_nonce( $nonce, 'edit-customer' ) ) {
43
-		wp_die( esc_html__( 'Cheatin’ uh?', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) );
42
+	if ( ! wp_verify_nonce($nonce, 'edit-customer')) {
43
+		wp_die(esc_html__('Cheatin’ uh?', 'give'), esc_html__('Error', 'give'), array('response' => 400));
44 44
 	}
45 45
 
46
-	$customer = new Give_Customer( $customer_id );
47
-	if ( empty( $customer->id ) ) {
46
+	$customer = new Give_Customer($customer_id);
47
+	if (empty($customer->id)) {
48 48
 		return false;
49 49
 	}
50 50
 
@@ -53,70 +53,70 @@  discard block
 block discarded – undo
53 53
 		'user_id' => 0,
54 54
 	);
55 55
 
56
-	$customer_info = wp_parse_args( $customer_info, $defaults );
56
+	$customer_info = wp_parse_args($customer_info, $defaults);
57 57
 
58
-	if ( (int) $customer_info['user_id'] != (int) $customer->user_id ) {
58
+	if ((int) $customer_info['user_id'] != (int) $customer->user_id) {
59 59
 
60 60
 		// Make sure we don't already have this user attached to a customer
61
-		if ( ! empty( $customer_info['user_id'] ) && false !== Give()->customers->get_customer_by( 'user_id', $customer_info['user_id'] ) ) {
62
-			give_set_error( 'give-invalid-customer-user_id', sprintf( esc_html__( 'The User ID %d is already associated with a different donor.', 'give' ), $customer_info['user_id'] ) );
61
+		if ( ! empty($customer_info['user_id']) && false !== Give()->customers->get_customer_by('user_id', $customer_info['user_id'])) {
62
+			give_set_error('give-invalid-customer-user_id', sprintf(esc_html__('The User ID %d is already associated with a different donor.', 'give'), $customer_info['user_id']));
63 63
 		}
64 64
 
65 65
 		// Make sure it's actually a user
66
-		$user = get_user_by( 'id', $customer_info['user_id'] );
67
-		if ( ! empty( $customer_info['user_id'] ) && false === $user ) {
68
-			give_set_error( 'give-invalid-user_id', sprintf( esc_html__( 'The User ID %d does not exist. Please assign an existing user.', 'give' ), $customer_info['user_id'] ) );
66
+		$user = get_user_by('id', $customer_info['user_id']);
67
+		if ( ! empty($customer_info['user_id']) && false === $user) {
68
+			give_set_error('give-invalid-user_id', sprintf(esc_html__('The User ID %d does not exist. Please assign an existing user.', 'give'), $customer_info['user_id']));
69 69
 		}
70 70
 	}
71 71
 
72 72
 	// Record this for later
73 73
 	$previous_user_id = $customer->user_id;
74 74
 
75
-	if ( give_get_errors() ) {
75
+	if (give_get_errors()) {
76 76
 		return;
77 77
 	}
78 78
 
79 79
 	// Setup the customer address, if present
80 80
 	$address = array();
81
-	if ( intval( $customer_info['user_id'] ) > 0 ) {
81
+	if (intval($customer_info['user_id']) > 0) {
82 82
 
83
-		$current_address = get_user_meta( $customer_info['user_id'], '_give_user_address', true );
83
+		$current_address = get_user_meta($customer_info['user_id'], '_give_user_address', true);
84 84
 
85
-		if ( false === $current_address ) {
86
-			$address['line1']   = isset( $customer_info['line1'] ) ? $customer_info['line1'] : '';
87
-			$address['line2']   = isset( $customer_info['line2'] ) ? $customer_info['line2'] : '';
88
-			$address['city']    = isset( $customer_info['city'] ) ? $customer_info['city'] : '';
89
-			$address['country'] = isset( $customer_info['country'] ) ? $customer_info['country'] : '';
90
-			$address['zip']     = isset( $customer_info['zip'] ) ? $customer_info['zip'] : '';
91
-			$address['state']   = isset( $customer_info['state'] ) ? $customer_info['state'] : '';
85
+		if (false === $current_address) {
86
+			$address['line1']   = isset($customer_info['line1']) ? $customer_info['line1'] : '';
87
+			$address['line2']   = isset($customer_info['line2']) ? $customer_info['line2'] : '';
88
+			$address['city']    = isset($customer_info['city']) ? $customer_info['city'] : '';
89
+			$address['country'] = isset($customer_info['country']) ? $customer_info['country'] : '';
90
+			$address['zip']     = isset($customer_info['zip']) ? $customer_info['zip'] : '';
91
+			$address['state']   = isset($customer_info['state']) ? $customer_info['state'] : '';
92 92
 		} else {
93
-			$current_address    = wp_parse_args( $current_address, array(
93
+			$current_address    = wp_parse_args($current_address, array(
94 94
 				'line1',
95 95
 				'line2',
96 96
 				'city',
97 97
 				'zip',
98 98
 				'state',
99 99
 				'country',
100
-			) );
101
-			$address['line1']   = isset( $customer_info['line1'] ) ? $customer_info['line1'] : $current_address['line1'];
102
-			$address['line2']   = isset( $customer_info['line2'] ) ? $customer_info['line2'] : $current_address['line2'];
103
-			$address['city']    = isset( $customer_info['city'] ) ? $customer_info['city'] : $current_address['city'];
104
-			$address['country'] = isset( $customer_info['country'] ) ? $customer_info['country'] : $current_address['country'];
105
-			$address['zip']     = isset( $customer_info['zip'] ) ? $customer_info['zip'] : $current_address['zip'];
106
-			$address['state']   = isset( $customer_info['state'] ) ? $customer_info['state'] : $current_address['state'];
100
+			));
101
+			$address['line1']   = isset($customer_info['line1']) ? $customer_info['line1'] : $current_address['line1'];
102
+			$address['line2']   = isset($customer_info['line2']) ? $customer_info['line2'] : $current_address['line2'];
103
+			$address['city']    = isset($customer_info['city']) ? $customer_info['city'] : $current_address['city'];
104
+			$address['country'] = isset($customer_info['country']) ? $customer_info['country'] : $current_address['country'];
105
+			$address['zip']     = isset($customer_info['zip']) ? $customer_info['zip'] : $current_address['zip'];
106
+			$address['state']   = isset($customer_info['state']) ? $customer_info['state'] : $current_address['state'];
107 107
 		}
108 108
 	}
109 109
 
110 110
 	// Sanitize the inputs
111 111
 	$customer_data            = array();
112
-	$customer_data['name']    = strip_tags( stripslashes( $customer_info['name'] ) );
112
+	$customer_data['name']    = strip_tags(stripslashes($customer_info['name']));
113 113
 	$customer_data['user_id'] = $customer_info['user_id'];
114 114
 
115
-	$customer_data = apply_filters( 'give_edit_customer_info', $customer_data, $customer_id );
116
-	$address       = apply_filters( 'give_edit_customer_address', $address, $customer_id );
115
+	$customer_data = apply_filters('give_edit_customer_info', $customer_data, $customer_id);
116
+	$address       = apply_filters('give_edit_customer_address', $address, $customer_id);
117 117
 
118
-	$customer_data = array_map( 'sanitize_text_field', $customer_data );
119
-	$address       = array_map( 'sanitize_text_field', $address );
118
+	$customer_data = array_map('sanitize_text_field', $customer_data);
119
+	$address       = array_map('sanitize_text_field', $address);
120 120
 
121 121
 	/**
122 122
 	 * Fires before editing customer.
@@ -127,27 +127,27 @@  discard block
 block discarded – undo
127 127
 	 * @param array $customer_data The customer data.
128 128
 	 * @param array $address       The customer address.
129 129
 	 */
130
-	do_action( 'give_pre_edit_customer', $customer_id, $customer_data, $address );
130
+	do_action('give_pre_edit_customer', $customer_id, $customer_data, $address);
131 131
 
132 132
 	$output = array();
133 133
 
134
-	if ( $customer->update( $customer_data ) ) {
134
+	if ($customer->update($customer_data)) {
135 135
 
136
-		if ( ! empty( $customer->user_id ) && $customer->user_id > 0 ) {
137
-			update_user_meta( $customer->user_id, '_give_user_address', $address );
136
+		if ( ! empty($customer->user_id) && $customer->user_id > 0) {
137
+			update_user_meta($customer->user_id, '_give_user_address', $address);
138 138
 		}
139 139
 
140 140
 		// Update some donation meta if we need to
141
-		$payments_array = explode( ',', $customer->payment_ids );
141
+		$payments_array = explode(',', $customer->payment_ids);
142 142
 
143
-		if ( $customer->user_id != $previous_user_id ) {
144
-			foreach ( $payments_array as $payment_id ) {
145
-				give_update_payment_meta( $payment_id, '_give_payment_user_id', $customer->user_id );
143
+		if ($customer->user_id != $previous_user_id) {
144
+			foreach ($payments_array as $payment_id) {
145
+				give_update_payment_meta($payment_id, '_give_payment_user_id', $customer->user_id);
146 146
 			}
147 147
 		}
148 148
 
149 149
 		$output['success']       = true;
150
-		$customer_data           = array_merge( $customer_data, $address );
150
+		$customer_data           = array_merge($customer_data, $address);
151 151
 		$output['customer_info'] = $customer_data;
152 152
 
153 153
 	} else {
@@ -164,11 +164,11 @@  discard block
 block discarded – undo
164 164
 	 * @param int   $customer_id   The ID of the customer.
165 165
 	 * @param array $customer_data The customer data.
166 166
 	 */
167
-	do_action( 'give_post_edit_customer', $customer_id, $customer_data );
167
+	do_action('give_post_edit_customer', $customer_id, $customer_data);
168 168
 
169
-	if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
170
-		header( 'Content-Type: application/json' );
171
-		echo json_encode( $output );
169
+	if (defined('DOING_AJAX') && DOING_AJAX) {
170
+		header('Content-Type: application/json');
171
+		echo json_encode($output);
172 172
 		wp_die();
173 173
 	}
174 174
 
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 
177 177
 }
178 178
 
179
-add_action( 'give_edit-customer', 'give_edit_customer', 10, 1 );
179
+add_action('give_edit-customer', 'give_edit_customer', 10, 1);
180 180
 
181 181
 /**
182 182
  * Save a customer note being added
@@ -187,36 +187,36 @@  discard block
 block discarded – undo
187 187
  *
188 188
  * @return int         The Note ID that was saved, or 0 if nothing was saved
189 189
  */
190
-function give_customer_save_note( $args ) {
190
+function give_customer_save_note($args) {
191 191
 
192
-	$customer_view_role = apply_filters( 'give_view_customers_role', 'view_give_reports' );
192
+	$customer_view_role = apply_filters('give_view_customers_role', 'view_give_reports');
193 193
 
194
-	if ( ! is_admin() || ! current_user_can( $customer_view_role ) ) {
195
-		wp_die( esc_html__( 'You do not have permission to edit this donor.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
194
+	if ( ! is_admin() || ! current_user_can($customer_view_role)) {
195
+		wp_die(esc_html__('You do not have permission to edit this donor.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
196 196
 	}
197 197
 
198
-	if ( empty( $args ) ) {
198
+	if (empty($args)) {
199 199
 		return;
200 200
 	}
201 201
 
202
-	$customer_note = trim( sanitize_text_field( $args['customer_note'] ) );
202
+	$customer_note = trim(sanitize_text_field($args['customer_note']));
203 203
 	$customer_id   = (int) $args['customer_id'];
204 204
 	$nonce         = $args['add_customer_note_nonce'];
205 205
 
206
-	if ( ! wp_verify_nonce( $nonce, 'add-customer-note' ) ) {
207
-		wp_die( esc_html__( 'Cheatin’ uh?', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) );
206
+	if ( ! wp_verify_nonce($nonce, 'add-customer-note')) {
207
+		wp_die(esc_html__('Cheatin’ uh?', 'give'), esc_html__('Error', 'give'), array('response' => 400));
208 208
 	}
209 209
 
210
-	if ( empty( $customer_note ) ) {
211
-		give_set_error( 'empty-customer-note', esc_html__( 'A note is required.', 'give' ) );
210
+	if (empty($customer_note)) {
211
+		give_set_error('empty-customer-note', esc_html__('A note is required.', 'give'));
212 212
 	}
213 213
 
214
-	if ( give_get_errors() ) {
214
+	if (give_get_errors()) {
215 215
 		return;
216 216
 	}
217 217
 
218
-	$customer = new Give_Customer( $customer_id );
219
-	$new_note = $customer->add_note( $customer_note );
218
+	$customer = new Give_Customer($customer_id);
219
+	$new_note = $customer->add_note($customer_note);
220 220
 
221 221
 	/**
222 222
 	 * Fires before inserting customer note.
@@ -226,22 +226,22 @@  discard block
 block discarded – undo
226 226
 	 * @param int    $customer_id The ID of the customer.
227 227
 	 * @param string $new_note    Note content.
228 228
 	 */
229
-	do_action( 'give_pre_insert_customer_note', $customer_id, $new_note );
229
+	do_action('give_pre_insert_customer_note', $customer_id, $new_note);
230 230
 
231
-	if ( ! empty( $new_note ) && ! empty( $customer->id ) ) {
231
+	if ( ! empty($new_note) && ! empty($customer->id)) {
232 232
 
233 233
 		ob_start();
234 234
 		?>
235 235
 		<div class="customer-note-wrapper dashboard-comment-wrap comment-item">
236 236
 			<span class="note-content-wrap">
237
-				<?php echo stripslashes( $new_note ); ?>
237
+				<?php echo stripslashes($new_note); ?>
238 238
 			</span>
239 239
 		</div>
240 240
 		<?php
241 241
 		$output = ob_get_contents();
242 242
 		ob_end_clean();
243 243
 
244
-		if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
244
+		if (defined('DOING_AJAX') && DOING_AJAX) {
245 245
 			echo $output;
246 246
 			exit;
247 247
 		}
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 
255 255
 }
256 256
 
257
-add_action( 'give_add-customer-note', 'give_customer_save_note', 10, 1 );
257
+add_action('give_add-customer-note', 'give_customer_save_note', 10, 1);
258 258
 
259 259
 /**
260 260
  * Delete a customer
@@ -265,37 +265,37 @@  discard block
 block discarded – undo
265 265
  *
266 266
  * @return int Whether it was a successful deletion
267 267
  */
268
-function give_customer_delete( $args ) {
268
+function give_customer_delete($args) {
269 269
 
270
-	$customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' );
270
+	$customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments');
271 271
 
272
-	if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) {
273
-		wp_die( esc_html__( 'You do not have permission to delete donors.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
272
+	if ( ! is_admin() || ! current_user_can($customer_edit_role)) {
273
+		wp_die(esc_html__('You do not have permission to delete donors.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
274 274
 	}
275 275
 
276
-	if ( empty( $args ) ) {
276
+	if (empty($args)) {
277 277
 		return;
278 278
 	}
279 279
 
280 280
 	$customer_id = (int) $args['customer_id'];
281
-	$confirm     = ! empty( $args['give-customer-delete-confirm'] ) ? true : false;
282
-	$remove_data = ! empty( $args['give-customer-delete-records'] ) ? true : false;
281
+	$confirm     = ! empty($args['give-customer-delete-confirm']) ? true : false;
282
+	$remove_data = ! empty($args['give-customer-delete-records']) ? true : false;
283 283
 	$nonce       = $args['_wpnonce'];
284 284
 
285
-	if ( ! wp_verify_nonce( $nonce, 'delete-customer' ) ) {
286
-		wp_die( esc_html__( 'Cheatin&#8217; uh?', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) );
285
+	if ( ! wp_verify_nonce($nonce, 'delete-customer')) {
286
+		wp_die(esc_html__('Cheatin&#8217; uh?', 'give'), esc_html__('Error', 'give'), array('response' => 400));
287 287
 	}
288 288
 
289
-	if ( ! $confirm ) {
290
-		give_set_error( 'customer-delete-no-confirm', esc_html__( 'Please confirm you want to delete this donor.', 'give' ) );
289
+	if ( ! $confirm) {
290
+		give_set_error('customer-delete-no-confirm', esc_html__('Please confirm you want to delete this donor.', 'give'));
291 291
 	}
292 292
 
293
-	if ( give_get_errors() ) {
294
-		wp_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer_id ) );
293
+	if (give_get_errors()) {
294
+		wp_redirect(admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer_id));
295 295
 		exit;
296 296
 	}
297 297
 
298
-	$customer = new Give_Customer( $customer_id );
298
+	$customer = new Give_Customer($customer_id);
299 299
 
300 300
 	/**
301 301
 	 * Fires before deleting customer.
@@ -306,50 +306,50 @@  discard block
 block discarded – undo
306 306
 	 * @param bool $confirm     Delete confirmation.
307 307
 	 * @param bool $remove_data Records delete confirmation.
308 308
 	 */
309
-	do_action( 'give_pre_delete_customer', $customer_id, $confirm, $remove_data );
309
+	do_action('give_pre_delete_customer', $customer_id, $confirm, $remove_data);
310 310
 
311
-	if ( $customer->id > 0 ) {
311
+	if ($customer->id > 0) {
312 312
 
313
-		$payments_array = explode( ',', $customer->payment_ids );
314
-		$success        = Give()->customers->delete( $customer->id );
313
+		$payments_array = explode(',', $customer->payment_ids);
314
+		$success        = Give()->customers->delete($customer->id);
315 315
 
316
-		if ( $success ) {
316
+		if ($success) {
317 317
 
318
-			if ( $remove_data ) {
318
+			if ($remove_data) {
319 319
 
320 320
 				// Remove all donations, logs, etc
321
-				foreach ( $payments_array as $payment_id ) {
322
-					give_delete_purchase( $payment_id );
321
+				foreach ($payments_array as $payment_id) {
322
+					give_delete_purchase($payment_id);
323 323
 				}
324 324
 			} else {
325 325
 
326 326
 				// Just set the donations to customer_id of 0
327
-				foreach ( $payments_array as $payment_id ) {
328
-					give_update_payment_meta( $payment_id, '_give_payment_customer_id', 0 );
327
+				foreach ($payments_array as $payment_id) {
328
+					give_update_payment_meta($payment_id, '_give_payment_customer_id', 0);
329 329
 				}
330 330
 			}
331 331
 
332
-			$redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&give-message=customer-deleted' );
332
+			$redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&give-message=customer-deleted');
333 333
 
334 334
 		} else {
335 335
 
336
-			give_set_error( 'give-donor-delete-failed', esc_html__( 'Error deleting donor.', 'give' ) );
337
-			$redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $customer_id );
336
+			give_set_error('give-donor-delete-failed', esc_html__('Error deleting donor.', 'give'));
337
+			$redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$customer_id);
338 338
 
339 339
 		}
340 340
 	} else {
341 341
 
342
-		give_set_error( 'give-customer-delete-invalid-id', esc_html__( 'Invalid Donor ID.', 'give' ) );
343
-		$redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors' );
342
+		give_set_error('give-customer-delete-invalid-id', esc_html__('Invalid Donor ID.', 'give'));
343
+		$redirect = admin_url('edit.php?post_type=give_forms&page=give-donors');
344 344
 
345 345
 	}
346 346
 
347
-	wp_redirect( $redirect );
347
+	wp_redirect($redirect);
348 348
 	exit;
349 349
 
350 350
 }
351 351
 
352
-add_action( 'give_delete-customer', 'give_customer_delete', 10, 1 );
352
+add_action('give_delete-customer', 'give_customer_delete', 10, 1);
353 353
 
354 354
 /**
355 355
  * Disconnect a user ID from a donor
@@ -360,27 +360,27 @@  discard block
 block discarded – undo
360 360
  *
361 361
  * @return bool        If the disconnect was successful
362 362
  */
363
-function give_disconnect_customer_user_id( $args ) {
363
+function give_disconnect_customer_user_id($args) {
364 364
 
365
-	$customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' );
365
+	$customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments');
366 366
 
367
-	if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) {
368
-		wp_die( esc_html__( 'You do not have permission to edit this donor.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
367
+	if ( ! is_admin() || ! current_user_can($customer_edit_role)) {
368
+		wp_die(esc_html__('You do not have permission to edit this donor.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
369 369
 	}
370 370
 
371
-	if ( empty( $args ) ) {
371
+	if (empty($args)) {
372 372
 		return;
373 373
 	}
374 374
 
375 375
 	$customer_id = (int) $args['customer_id'];
376 376
 	$nonce       = $args['_wpnonce'];
377 377
 
378
-	if ( ! wp_verify_nonce( $nonce, 'edit-customer' ) ) {
379
-		wp_die( esc_html__( 'Cheatin&#8217; uh?', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) );
378
+	if ( ! wp_verify_nonce($nonce, 'edit-customer')) {
379
+		wp_die(esc_html__('Cheatin&#8217; uh?', 'give'), esc_html__('Error', 'give'), array('response' => 400));
380 380
 	}
381 381
 
382
-	$customer = new Give_Customer( $customer_id );
383
-	if ( empty( $customer->id ) ) {
382
+	$customer = new Give_Customer($customer_id);
383
+	if (empty($customer->id)) {
384 384
 		return false;
385 385
 	}
386 386
 
@@ -394,16 +394,16 @@  discard block
 block discarded – undo
394 394
 	 * @param int $customer_id The ID of the customer.
395 395
 	 * @param int $user_id     The ID of the user.
396 396
 	 */
397
-	do_action( 'give_pre_customer_disconnect_user_id', $customer_id, $user_id );
397
+	do_action('give_pre_customer_disconnect_user_id', $customer_id, $user_id);
398 398
 
399 399
 	$output        = array();
400
-	$customer_args = array( 'user_id' => 0 );
400
+	$customer_args = array('user_id' => 0);
401 401
 
402
-	if ( $customer->update( $customer_args ) ) {
402
+	if ($customer->update($customer_args)) {
403 403
 		global $wpdb;
404 404
 
405
-		if ( ! empty( $customer->payment_ids ) ) {
406
-			$wpdb->query( "UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $customer->payment_ids )" );
405
+		if ( ! empty($customer->payment_ids)) {
406
+			$wpdb->query("UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $customer->payment_ids )");
407 407
 		}
408 408
 
409 409
 		$output['success'] = true;
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
 	} else {
412 412
 
413 413
 		$output['success'] = false;
414
-		give_set_error( 'give-disconnect-user-fail', esc_html__( 'Failed to disconnect user from donor.', 'give' ) );
414
+		give_set_error('give-disconnect-user-fail', esc_html__('Failed to disconnect user from donor.', 'give'));
415 415
 	}
416 416
 
417 417
 	/**
@@ -421,11 +421,11 @@  discard block
 block discarded – undo
421 421
 	 *
422 422
 	 * @param int $customer_id The ID of the customer.
423 423
 	 */
424
-	do_action( 'give_post_customer_disconnect_user_id', $customer_id );
424
+	do_action('give_post_customer_disconnect_user_id', $customer_id);
425 425
 
426
-	if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
427
-		header( 'Content-Type: application/json' );
428
-		echo json_encode( $output );
426
+	if (defined('DOING_AJAX') && DOING_AJAX) {
427
+		header('Content-Type: application/json');
428
+		echo json_encode($output);
429 429
 		wp_die();
430 430
 	}
431 431
 
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 
434 434
 }
435 435
 
436
-add_action( 'give_disconnect-userid', 'give_disconnect_customer_user_id', 10, 1 );
436
+add_action('give_disconnect-userid', 'give_disconnect_customer_user_id', 10, 1);
437 437
 
438 438
 /**
439 439
  * Add an email address to the donor from within the admin and log a donor note
@@ -444,82 +444,82 @@  discard block
 block discarded – undo
444 444
  *
445 445
  * @return mixed        If DOING_AJAX echos out JSON, otherwise returns array of success (bool) and message (string)
446 446
  */
447
-function give_add_donor_email( $args ) {
448
-	$customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' );
447
+function give_add_donor_email($args) {
448
+	$customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments');
449 449
 
450
-	if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) {
451
-		wp_die( esc_html__( 'You do not have permission to edit this donor.', 'edit' ) );
450
+	if ( ! is_admin() || ! current_user_can($customer_edit_role)) {
451
+		wp_die(esc_html__('You do not have permission to edit this donor.', 'edit'));
452 452
 	}
453 453
 
454 454
 	$output = array();
455
-	if ( empty( $args ) || empty( $args['email'] ) || empty( $args['customer_id'] ) ) {
455
+	if (empty($args) || empty($args['email']) || empty($args['customer_id'])) {
456 456
 		$output['success'] = false;
457
-		if ( empty( $args['email'] ) ) {
458
-			$output['message'] = esc_html__( 'Email address is required.', 'give' );
459
-		} elseif ( empty( $args['customer_id'] ) ) {
460
-			$output['message'] = esc_html__( 'Customer ID is required.', 'give' );
457
+		if (empty($args['email'])) {
458
+			$output['message'] = esc_html__('Email address is required.', 'give');
459
+		} elseif (empty($args['customer_id'])) {
460
+			$output['message'] = esc_html__('Customer ID is required.', 'give');
461 461
 		} else {
462
-			$output['message'] = esc_html__( 'An error has occurred. Please try again.', 'give' );
462
+			$output['message'] = esc_html__('An error has occurred. Please try again.', 'give');
463 463
 		}
464
-	} elseif ( ! wp_verify_nonce( $args['_wpnonce'], 'give_add_donor_email' ) ) {
464
+	} elseif ( ! wp_verify_nonce($args['_wpnonce'], 'give_add_donor_email')) {
465 465
 		$output = array(
466 466
 			'success' => false,
467
-			'message' => esc_html__( 'Nonce verification failed.', 'give' ),
467
+			'message' => esc_html__('Nonce verification failed.', 'give'),
468 468
 		);
469
-	} elseif ( ! is_email( $args['email'] ) ) {
469
+	} elseif ( ! is_email($args['email'])) {
470 470
 		$output = array(
471 471
 			'success' => false,
472
-			'message' => esc_html__( 'Invalid email.', 'give' ),
472
+			'message' => esc_html__('Invalid email.', 'give'),
473 473
 		);
474 474
 	} else {
475
-		$email       = sanitize_email( $args['email'] );
475
+		$email       = sanitize_email($args['email']);
476 476
 		$customer_id = (int) $args['customer_id'];
477 477
 		$primary     = 'true' === $args['primary'] ? true : false;
478
-		$customer    = new Give_Customer( $customer_id );
479
-		if ( false === $customer->add_email( $email, $primary ) ) {
480
-			if ( in_array( $email, $customer->emails ) ) {
478
+		$customer    = new Give_Customer($customer_id);
479
+		if (false === $customer->add_email($email, $primary)) {
480
+			if (in_array($email, $customer->emails)) {
481 481
 				$output = array(
482 482
 					'success' => false,
483
-					'message' => esc_html__( 'Email already associated with this donor.', 'give' ),
483
+					'message' => esc_html__('Email already associated with this donor.', 'give'),
484 484
 				);
485 485
 			} else {
486 486
 				$output = array(
487 487
 					'success' => false,
488
-					'message' => esc_html__( 'Email address is already associated with another donor.', 'give' ),
488
+					'message' => esc_html__('Email address is already associated with another donor.', 'give'),
489 489
 				);
490 490
 			}
491 491
 		} else {
492
-			$redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer_id . '&give-message=email-added' );
492
+			$redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer_id.'&give-message=email-added');
493 493
 			$output   = array(
494 494
 				'success'  => true,
495
-				'message'  => esc_html__( 'Email successfully added to donor.', 'give' ),
495
+				'message'  => esc_html__('Email successfully added to donor.', 'give'),
496 496
 				'redirect' => $redirect,
497 497
 			);
498 498
 
499 499
 			$user          = wp_get_current_user();
500
-			$user_login    = ! empty( $user->user_login ) ? $user->user_login : esc_html__( 'System', 'give' );
501
-			$customer_note = sprintf( __( 'Email address %1$s added by %2$s', 'give' ), $email, $user_login );
502
-			$customer->add_note( $customer_note );
500
+			$user_login    = ! empty($user->user_login) ? $user->user_login : esc_html__('System', 'give');
501
+			$customer_note = sprintf(__('Email address %1$s added by %2$s', 'give'), $email, $user_login);
502
+			$customer->add_note($customer_note);
503 503
 
504
-			if ( $primary ) {
505
-				$customer_note = sprintf( __( 'Email address %1$s set as primary by %2$s', 'give' ), $email, $user_login );
506
-				$customer->add_note( $customer_note );
504
+			if ($primary) {
505
+				$customer_note = sprintf(__('Email address %1$s set as primary by %2$s', 'give'), $email, $user_login);
506
+				$customer->add_note($customer_note);
507 507
 			}
508 508
 		}
509 509
 	}
510 510
 
511
-	do_action( 'give_post_add_customer_email', $customer_id, $args );
511
+	do_action('give_post_add_customer_email', $customer_id, $args);
512 512
 
513
-	if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
514
-		header( 'Content-Type: application/json' );
515
-		echo json_encode( $output );
513
+	if (defined('DOING_AJAX') && DOING_AJAX) {
514
+		header('Content-Type: application/json');
515
+		echo json_encode($output);
516 516
 		wp_die();
517 517
 	}
518 518
 
519 519
 	return $output;
520 520
 }
521 521
 
522
-add_action( 'give_add_donor_email', 'give_add_donor_email', 10, 1 );
522
+add_action('give_add_donor_email', 'give_add_donor_email', 10, 1);
523 523
 
524 524
 
525 525
 /**
@@ -530,37 +530,37 @@  discard block
 block discarded – undo
530 530
  * @return bool|null
531 531
  */
532 532
 function give_remove_donor_email() {
533
-	if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
533
+	if (empty($_GET['id']) || ! is_numeric($_GET['id'])) {
534 534
 		return false;
535 535
 	}
536
-	if ( empty( $_GET['email'] ) || ! is_email( $_GET['email'] ) ) {
536
+	if (empty($_GET['email']) || ! is_email($_GET['email'])) {
537 537
 		return false;
538 538
 	}
539
-	if ( empty( $_GET['_wpnonce'] ) ) {
539
+	if (empty($_GET['_wpnonce'])) {
540 540
 		return false;
541 541
 	}
542 542
 
543 543
 	$nonce = $_GET['_wpnonce'];
544
-	if ( ! wp_verify_nonce( $nonce, 'give-remove-donor-email' ) ) {
545
-		wp_die( esc_html__( 'Nonce verification failed', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
544
+	if ( ! wp_verify_nonce($nonce, 'give-remove-donor-email')) {
545
+		wp_die(esc_html__('Nonce verification failed', 'give'), esc_html__('Error', 'give'), array('response' => 403));
546 546
 	}
547 547
 
548
-	$customer = new Give_Customer( $_GET['id'] );
549
-	if ( $customer->remove_email( $_GET['email'] ) ) {
550
-		$url           = add_query_arg( 'give-message', 'email-removed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer->id ) );
548
+	$customer = new Give_Customer($_GET['id']);
549
+	if ($customer->remove_email($_GET['email'])) {
550
+		$url           = add_query_arg('give-message', 'email-removed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer->id));
551 551
 		$user          = wp_get_current_user();
552
-		$user_login    = ! empty( $user->user_login ) ? $user->user_login : esc_html__( 'System', 'give' );
553
-		$customer_note = sprintf( __( 'Email address %1$s removed by %2$s', 'give' ), $_GET['email'], $user_login );
554
-		$customer->add_note( $customer_note );
552
+		$user_login    = ! empty($user->user_login) ? $user->user_login : esc_html__('System', 'give');
553
+		$customer_note = sprintf(__('Email address %1$s removed by %2$s', 'give'), $_GET['email'], $user_login);
554
+		$customer->add_note($customer_note);
555 555
 	} else {
556
-		$url = add_query_arg( 'give-message', 'email-remove-failed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer->id ) );
556
+		$url = add_query_arg('give-message', 'email-remove-failed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer->id));
557 557
 	}
558 558
 
559
-	wp_safe_redirect( $url );
559
+	wp_safe_redirect($url);
560 560
 	exit;
561 561
 }
562 562
 
563
-add_action( 'give_remove_donor_email', 'give_remove_donor_email', 10 );
563
+add_action('give_remove_donor_email', 'give_remove_donor_email', 10);
564 564
 
565 565
 
566 566
 /**
@@ -571,39 +571,39 @@  discard block
 block discarded – undo
571 571
  * @return bool|null
572 572
  */
573 573
 function give_set_donor_primary_email() {
574
-	if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
574
+	if (empty($_GET['id']) || ! is_numeric($_GET['id'])) {
575 575
 		return false;
576 576
 	}
577 577
 
578
-	if ( empty( $_GET['email'] ) || ! is_email( $_GET['email'] ) ) {
578
+	if (empty($_GET['email']) || ! is_email($_GET['email'])) {
579 579
 		return false;
580 580
 	}
581 581
 
582
-	if ( empty( $_GET['_wpnonce'] ) ) {
582
+	if (empty($_GET['_wpnonce'])) {
583 583
 		return false;
584 584
 	}
585 585
 
586 586
 	$nonce = $_GET['_wpnonce'];
587 587
 
588
-	if ( ! wp_verify_nonce( $nonce, 'give-set-donor-primary-email' ) ) {
589
-		wp_die( esc_html__( 'Nonce verification failed', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
588
+	if ( ! wp_verify_nonce($nonce, 'give-set-donor-primary-email')) {
589
+		wp_die(esc_html__('Nonce verification failed', 'give'), esc_html__('Error', 'give'), array('response' => 403));
590 590
 	}
591 591
 
592
-	$donor = new Give_Customer( $_GET['id'] );
592
+	$donor = new Give_Customer($_GET['id']);
593 593
 
594
-	if ( $donor->set_primary_email( $_GET['email'] ) ) {
595
-		$url        = add_query_arg( 'give-message', 'primary-email-updated', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) );
594
+	if ($donor->set_primary_email($_GET['email'])) {
595
+		$url        = add_query_arg('give-message', 'primary-email-updated', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id));
596 596
 		$user       = wp_get_current_user();
597
-		$user_login = ! empty( $user->user_login ) ? $user->user_login : esc_html__( 'System', 'give' );
598
-		$donor_note = sprintf( __( 'Email address %1$s set as primary by %1$s', 'give' ), $_GET['email'], $user_login );
597
+		$user_login = ! empty($user->user_login) ? $user->user_login : esc_html__('System', 'give');
598
+		$donor_note = sprintf(__('Email address %1$s set as primary by %1$s', 'give'), $_GET['email'], $user_login);
599 599
 
600
-		$donor->add_note( $donor_note );
600
+		$donor->add_note($donor_note);
601 601
 	} else {
602
-		$url = add_query_arg( 'give-message', 'primary-email-failed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) );
602
+		$url = add_query_arg('give-message', 'primary-email-failed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id));
603 603
 	}
604 604
 
605
-	wp_safe_redirect( $url );
605
+	wp_safe_redirect($url);
606 606
 	exit;
607 607
 }
608 608
 
609
-add_action( 'give_set_donor_primary_email', 'give_set_donor_primary_email', 10 );
609
+add_action('give_set_donor_primary_email', 'give_set_donor_primary_email', 10);
Please login to merge, or discard this patch.
includes/admin/reporting/class-api-requests-logs-list-table.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -157,7 +157,7 @@
 block discarded – undo
157 157
 	 *
158 158
 	 * @access public
159 159
 	 * @since  1.0
160
-	 * @return string|bool String if search is present, false otherwise
160
+	 * @return string|false String if search is present, false otherwise
161 161
 	 */
162 162
 	public function get_search() {
163 163
 		return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false;
Please login to merge, or discard this patch.
Spacing   +65 added lines, -65 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
 /**
@@ -45,11 +45,11 @@  discard block
 block discarded – undo
45 45
 		global $status, $page;
46 46
 
47 47
 		// Set parent defaults
48
-		parent::__construct( array(
49
-			'singular' => give_get_forms_label_singular(),    // Singular name of the listed records
50
-			'plural'   => give_get_forms_label_plural(),        // Plural name of the listed records
51
-			'ajax'     => false,// Does this table support ajax?
52
-		) );
48
+		parent::__construct(array(
49
+			'singular' => give_get_forms_label_singular(), // Singular name of the listed records
50
+			'plural'   => give_get_forms_label_plural(), // Plural name of the listed records
51
+			'ajax'     => false, // Does this table support ajax?
52
+		));
53 53
 	}
54 54
 
55 55
 	/**
@@ -63,20 +63,20 @@  discard block
 block discarded – undo
63 63
 	 *
64 64
 	 * @return void
65 65
 	 */
66
-	public function search_box( $text, $input_id ) {
67
-		$input_id = $input_id . '-search-input';
66
+	public function search_box($text, $input_id) {
67
+		$input_id = $input_id.'-search-input';
68 68
 
69
-		if ( ! empty( $_REQUEST['orderby'] ) ) {
70
-			echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
69
+		if ( ! empty($_REQUEST['orderby'])) {
70
+			echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />';
71 71
 		}
72
-		if ( ! empty( $_REQUEST['order'] ) ) {
73
-			echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
72
+		if ( ! empty($_REQUEST['order'])) {
73
+			echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />';
74 74
 		}
75 75
 		?>
76 76
 		<p class="search-box" role="search">
77 77
 			<label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label>
78 78
 			<input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>"/>
79
-			<?php submit_button( $text, 'button', false, false, array( 'ID' => 'search-submit' ) ); ?>
79
+			<?php submit_button($text, 'button', false, false, array('ID' => 'search-submit')); ?>
80 80
 		</p>
81 81
 		<?php
82 82
 	}
@@ -90,10 +90,10 @@  discard block
 block discarded – undo
90 90
 	 */
91 91
 	public function get_columns() {
92 92
 		$columns = array(
93
-			'ID'      => esc_html__( 'Log ID', 'give' ),
94
-			'details' => esc_html__( 'Request Details', 'give' ),
95
-			'ip'      => esc_html__( 'Request IP', 'give' ),
96
-			'date'    => esc_html__( 'Date', 'give' ),
93
+			'ID'      => esc_html__('Log ID', 'give'),
94
+			'details' => esc_html__('Request Details', 'give'),
95
+			'ip'      => esc_html__('Request IP', 'give'),
96
+			'date'    => esc_html__('Date', 'give'),
97 97
 		);
98 98
 
99 99
 		return $columns;
@@ -110,10 +110,10 @@  discard block
 block discarded – undo
110 110
 	 *
111 111
 	 * @return string Column Name
112 112
 	 */
113
-	public function column_default( $item, $column_name ) {
114
-		switch ( $column_name ) {
113
+	public function column_default($item, $column_name) {
114
+		switch ($column_name) {
115 115
 			default:
116
-				return $item[ $column_name ];
116
+				return $item[$column_name];
117 117
 		}
118 118
 	}
119 119
 
@@ -127,26 +127,26 @@  discard block
 block discarded – undo
127 127
 	 *
128 128
 	 * @return void
129 129
 	 */
130
-	public function column_details( $item ) {
130
+	public function column_details($item) {
131 131
 		?>
132
-		<a href="#TB_inline?width=640&amp;inlineId=log-details-<?php echo $item['ID']; ?>" class="thickbox"><?php esc_html_e( 'View Request', 'give' ); ?></a>
132
+		<a href="#TB_inline?width=640&amp;inlineId=log-details-<?php echo $item['ID']; ?>" class="thickbox"><?php esc_html_e('View Request', 'give'); ?></a>
133 133
 		<div id="log-details-<?php echo $item['ID']; ?>" style="display:none;">
134 134
 			<?php
135 135
 
136
-			$request = get_post_field( 'post_excerpt', $item['ID'] );
137
-			$error   = get_post_field( 'post_content', $item['ID'] );
138
-			echo '<p><strong>' . esc_html__( 'API Request:', 'give' ) . '</strong></p>';
139
-			echo '<div>' . $request . '</div>';
140
-			if ( ! empty( $error ) ) {
141
-				echo '<p><strong>' . esc_html__( 'Error', 'give' ) . '</strong></p>';
142
-				echo '<div>' . esc_html( $error ) . '</div>';
136
+			$request = get_post_field('post_excerpt', $item['ID']);
137
+			$error   = get_post_field('post_content', $item['ID']);
138
+			echo '<p><strong>'.esc_html__('API Request:', 'give').'</strong></p>';
139
+			echo '<div>'.$request.'</div>';
140
+			if ( ! empty($error)) {
141
+				echo '<p><strong>'.esc_html__('Error', 'give').'</strong></p>';
142
+				echo '<div>'.esc_html($error).'</div>';
143 143
 			}
144
-			echo '<p><strong>' . esc_html__( 'API User:', 'give' ) . '</strong></p>';
145
-			echo '<div>' . get_post_meta( $item['ID'], '_give_log_user', true ) . '</div>';
146
-			echo '<p><strong>' . esc_html__( 'API Key:', 'give' ) . '</strong></p>';
147
-			echo '<div>' . get_post_meta( $item['ID'], '_give_log_key', true ) . '</div>';
148
-			echo '<p><strong>' . esc_html__( 'Request Date:', 'give' ) . '</strong></p>';
149
-			echo '<div>' . get_post_field( 'post_date', $item['ID'] ) . '</div>';
144
+			echo '<p><strong>'.esc_html__('API User:', 'give').'</strong></p>';
145
+			echo '<div>'.get_post_meta($item['ID'], '_give_log_user', true).'</div>';
146
+			echo '<p><strong>'.esc_html__('API Key:', 'give').'</strong></p>';
147
+			echo '<div>'.get_post_meta($item['ID'], '_give_log_key', true).'</div>';
148
+			echo '<p><strong>'.esc_html__('Request Date:', 'give').'</strong></p>';
149
+			echo '<div>'.get_post_field('post_date', $item['ID']).'</div>';
150 150
 			?>
151 151
 		</div>
152 152
 		<?php
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 	 * @return string|bool String if search is present, false otherwise
161 161
 	 */
162 162
 	public function get_search() {
163
-		return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false;
163
+		return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false;
164 164
 	}
165 165
 
166 166
 
@@ -176,19 +176,19 @@  discard block
 block discarded – undo
176 176
 	 *
177 177
 	 * @param string $which
178 178
 	 */
179
-	protected function display_tablenav( $which ) {
180
-		if ( 'top' === $which ) {
181
-			wp_nonce_field( 'bulk-' . $this->_args['plural'] );
179
+	protected function display_tablenav($which) {
180
+		if ('top' === $which) {
181
+			wp_nonce_field('bulk-'.$this->_args['plural']);
182 182
 		}
183 183
 		?>
184
-		<div class="tablenav <?php echo esc_attr( $which ); ?>">
184
+		<div class="tablenav <?php echo esc_attr($which); ?>">
185 185
 
186 186
 			<div class="alignleft actions bulkactions">
187
-				<?php $this->bulk_actions( $which ); ?>
187
+				<?php $this->bulk_actions($which); ?>
188 188
 			</div>
189 189
 			<?php
190
-			$this->extra_tablenav( $which );
191
-			$this->pagination( $which );
190
+			$this->extra_tablenav($which);
191
+			$this->pagination($which);
192 192
 			?>
193 193
 
194 194
 			<br class="clear"/>
@@ -210,31 +210,31 @@  discard block
 block discarded – undo
210 210
 
211 211
 		$search = $this->get_search();
212 212
 
213
-		if ( $search ) {
214
-			if ( filter_var( $search, FILTER_VALIDATE_IP ) ) {
213
+		if ($search) {
214
+			if (filter_var($search, FILTER_VALIDATE_IP)) {
215 215
 				// This is an IP address search
216 216
 				$key = '_give_log_request_ip';
217
-			} elseif ( is_email( $search ) ) {
217
+			} elseif (is_email($search)) {
218 218
 				// This is an email search
219
-				$userdata = get_user_by( 'email', $search );
219
+				$userdata = get_user_by('email', $search);
220 220
 
221
-				if ( $userdata ) {
221
+				if ($userdata) {
222 222
 					$search = $userdata->ID;
223 223
 				}
224 224
 
225 225
 				$key = '_give_log_user';
226
-			} elseif ( strlen( $search ) == 32 ) {
226
+			} elseif (strlen($search) == 32) {
227 227
 				// Look for an API key
228 228
 				$key = '_give_log_key';
229
-			} elseif ( stristr( $search, 'token:' ) ) {
229
+			} elseif (stristr($search, 'token:')) {
230 230
 				// Look for an API token
231
-				$search = str_ireplace( 'token:', '', $search );
231
+				$search = str_ireplace('token:', '', $search);
232 232
 				$key    = '_give_log_token';
233 233
 			} else {
234 234
 				// This is (probably) a user ID search
235
-				$userdata = get_userdata( $search );
235
+				$userdata = get_userdata($search);
236 236
 
237
-				if ( $userdata ) {
237
+				if ($userdata) {
238 238
 					$search = $userdata->ID;
239 239
 				}
240 240
 
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 	 * @return int Current page number
261 261
 	 */
262 262
 	public function get_paged() {
263
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
263
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
264 264
 	}
265 265
 
266 266
 	/**
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 	 * @since  1.0
271 271
 	 * @return void
272 272
 	 */
273
-	function bulk_actions( $which = '' ) {
273
+	function bulk_actions($which = '') {
274 274
 		give_log_views();
275 275
 	}
276 276
 
@@ -293,14 +293,14 @@  discard block
 block discarded – undo
293 293
 			'meta_query' => $this->get_meta_query(),
294 294
 		);
295 295
 
296
-		$logs = $give_logs->get_connected_logs( $log_query );
296
+		$logs = $give_logs->get_connected_logs($log_query);
297 297
 
298
-		if ( $logs ) {
299
-			foreach ( $logs as $log ) {
298
+		if ($logs) {
299
+			foreach ($logs as $log) {
300 300
 
301 301
 				$logs_data[] = array(
302 302
 					'ID'   => $log->ID,
303
-					'ip'   => get_post_meta( $log->ID, '_give_log_request_ip', true ),
303
+					'ip'   => get_post_meta($log->ID, '_give_log_request_ip', true),
304 304
 					'date' => $log->post_date,
305 305
 				);
306 306
 			}
@@ -328,14 +328,14 @@  discard block
 block discarded – undo
328 328
 		$columns               = $this->get_columns();
329 329
 		$hidden                = array(); // No hidden columns
330 330
 		$sortable              = $this->get_sortable_columns();
331
-		$this->_column_headers = array( $columns, $hidden, $sortable );
331
+		$this->_column_headers = array($columns, $hidden, $sortable);
332 332
 		$this->items           = $this->get_logs();
333
-		$total_items           = $give_logs->get_log_count( 0, 'api_requests' );
333
+		$total_items           = $give_logs->get_log_count(0, 'api_requests');
334 334
 
335
-		$this->set_pagination_args( array(
335
+		$this->set_pagination_args(array(
336 336
 				'total_items' => $total_items,
337 337
 				'per_page'    => $this->per_page,
338
-				'total_pages' => ceil( $total_items / $this->per_page ),
338
+				'total_pages' => ceil($total_items / $this->per_page),
339 339
 			)
340 340
 		);
341 341
 	}
Please login to merge, or discard this patch.
includes/admin/reporting/class-sales-logs-list-table.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -157,7 +157,7 @@
 block discarded – undo
157 157
 	 *
158 158
 	 * @access public
159 159
 	 * @since  1.0
160
-	 * @return string|bool string If search is present, false otherwise
160
+	 * @return string|false string If search is present, false otherwise
161 161
 	 */
162 162
 	public function get_search() {
163 163
 		return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false;
Please login to merge, or discard this patch.
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -9,13 +9,13 @@  discard block
 block discarded – undo
9 9
  */
10 10
 
11 11
 // Exit if accessed directly.
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit;
14 14
 }
15 15
 
16 16
 // Load WP_List_Table if not loaded
17
-if ( ! class_exists( 'WP_List_Table' ) ) {
18
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
17
+if ( ! class_exists('WP_List_Table')) {
18
+	require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
19 19
 }
20 20
 
21 21
 /**
@@ -44,13 +44,13 @@  discard block
 block discarded – undo
44 44
 		global $status, $page;
45 45
 
46 46
 		// Set parent defaults
47
-		parent::__construct( array(
48
-			'singular' => give_get_forms_label_singular(),    // Singular name of the listed records
49
-			'plural'   => give_get_forms_label_plural(),        // Plural name of the listed records
50
-			'ajax'     => false,// Does this table support ajax?
51
-		) );
47
+		parent::__construct(array(
48
+			'singular' => give_get_forms_label_singular(), // Singular name of the listed records
49
+			'plural'   => give_get_forms_label_plural(), // Plural name of the listed records
50
+			'ajax'     => false, // Does this table support ajax?
51
+		));
52 52
 
53
-		add_action( 'give_log_view_actions', array( $this, 'give_forms_filter' ) );
53
+		add_action('give_log_view_actions', array($this, 'give_forms_filter'));
54 54
 	}
55 55
 
56 56
 	/**
@@ -64,37 +64,37 @@  discard block
 block discarded – undo
64 64
 	 *
65 65
 	 * @return string Column Name
66 66
 	 */
67
-	public function column_default( $item, $column_name ) {
67
+	public function column_default($item, $column_name) {
68 68
 
69
-		$payment = give_get_payment_by( 'id', $item['payment_id'] );
69
+		$payment = give_get_payment_by('id', $item['payment_id']);
70 70
 
71
-		switch ( $column_name ) {
71
+		switch ($column_name) {
72 72
 			case 'form' :
73
-				return '<a href="' . esc_url( add_query_arg( 'form', $item[ $column_name ] ) ) . '" >' . get_the_title( $item[ $column_name ] ) . '</a>';
73
+				return '<a href="'.esc_url(add_query_arg('form', $item[$column_name])).'" >'.get_the_title($item[$column_name]).'</a>';
74 74
 
75 75
 			case 'user_id' :
76
-				return '<a href="' .
77
-					   admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . ( ! empty( $item['user_id'] ) ? urlencode( $item['user_id'] ) : give_get_payment_user_email( $item['payment_id'] ) ) ) .
78
-					   '">' . $item['user_name'] . '</a>';
76
+				return '<a href="'.
77
+					   admin_url('edit.php?post_type=give_forms&page=give-payment-history&user='.( ! empty($item['user_id']) ? urlencode($item['user_id']) : give_get_payment_user_email($item['payment_id']))).
78
+					   '">'.$item['user_name'].'</a>';
79 79
 
80 80
 			case 'amount' :
81
-				return give_currency_filter( give_format_amount( $item['amount'] ) );
81
+				return give_currency_filter(give_format_amount($item['amount']));
82 82
 
83 83
 			case 'status' :
84 84
 
85
-				$value = '<div class="give-donation-status status-' . sanitize_title( give_get_payment_status( $payment, true ) ) . '"><span class="give-donation-status-icon"></span> ' . give_get_payment_status( $payment, true ) . '</div>';
85
+				$value = '<div class="give-donation-status status-'.sanitize_title(give_get_payment_status($payment, true)).'"><span class="give-donation-status-icon"></span> '.give_get_payment_status($payment, true).'</div>';
86 86
 
87
-				if ( $payment->mode == 'test' ) {
88
-					$value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="' . esc_attr__( 'This donation was made in test mode.', 'give' ) . '">' . esc_html__( 'Test', 'give' ) . '</span>';
87
+				if ($payment->mode == 'test') {
88
+					$value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="'.esc_attr__('This donation was made in test mode.', 'give').'">'.esc_html__('Test', 'give').'</span>';
89 89
 				}
90 90
 
91 91
 				return $value;
92 92
 
93 93
 			case 'payment_id' :
94
-				return '<a href="' . admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $item['payment_id'] ) . '">' . give_get_payment_number( $item['payment_id'] ) . '</a>';
94
+				return '<a href="'.admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id='.$item['payment_id']).'">'.give_get_payment_number($item['payment_id']).'</a>';
95 95
 
96 96
 			default:
97
-				return $item[ $column_name ];
97
+				return $item[$column_name];
98 98
 		}
99 99
 	}
100 100
 
@@ -107,13 +107,13 @@  discard block
 block discarded – undo
107 107
 	 */
108 108
 	public function get_columns() {
109 109
 		$columns = array(
110
-			'ID'         => esc_html__( 'Log ID', 'give' ),
111
-			'user_id'    => esc_html__( 'Donor', 'give' ),
112
-			'form'       => esc_html__( 'Form', 'give' ),
113
-			'amount'     => esc_html__( 'Donation Amount', 'give' ),
114
-			'status'     => esc_html__( 'Status', 'give' ),
115
-			'payment_id' => esc_html__( 'Transaction ID', 'give' ),
116
-			'date'       => esc_html__( 'Date', 'give' ),
110
+			'ID'         => esc_html__('Log ID', 'give'),
111
+			'user_id'    => esc_html__('Donor', 'give'),
112
+			'form'       => esc_html__('Form', 'give'),
113
+			'amount'     => esc_html__('Donation Amount', 'give'),
114
+			'status'     => esc_html__('Status', 'give'),
115
+			'payment_id' => esc_html__('Transaction ID', 'give'),
116
+			'date'       => esc_html__('Date', 'give'),
117 117
 		);
118 118
 
119 119
 		return $columns;
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 	 * @return int Current page number
128 128
 	 */
129 129
 	public function get_paged() {
130
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
130
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
131 131
 	}
132 132
 
133 133
 	/**
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 	 * @return mixed int If User ID, string If Email/Login
139 139
 	 */
140 140
 	public function get_filtered_user() {
141
-		return isset( $_GET['user'] ) ? absint( $_GET['user'] ) : false;
141
+		return isset($_GET['user']) ? absint($_GET['user']) : false;
142 142
 	}
143 143
 
144 144
 	/**
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 	 * @return int Download ID
150 150
 	 */
151 151
 	public function get_filtered_give_form() {
152
-		return ! empty( $_GET['form'] ) ? absint( $_GET['form'] ) : false;
152
+		return ! empty($_GET['form']) ? absint($_GET['form']) : false;
153 153
 	}
154 154
 
155 155
 	/**
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 	 * @return string|bool string If search is present, false otherwise
161 161
 	 */
162 162
 	public function get_search() {
163
-		return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false;
163
+		return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false;
164 164
 	}
165 165
 
166 166
 
@@ -176,20 +176,20 @@  discard block
 block discarded – undo
176 176
 	 *
177 177
 	 * @param string $which
178 178
 	 */
179
-	protected function display_tablenav( $which ) {
179
+	protected function display_tablenav($which) {
180 180
 
181
-		if ( 'top' === $which ) {
182
-			wp_nonce_field( 'bulk-' . $this->_args['plural'] );
181
+		if ('top' === $which) {
182
+			wp_nonce_field('bulk-'.$this->_args['plural']);
183 183
 		}
184 184
 		?>
185
-		<div class="tablenav <?php echo esc_attr( $which ); ?>">
185
+		<div class="tablenav <?php echo esc_attr($which); ?>">
186 186
 
187 187
 			<div class="alignleft actions bulkactions">
188
-				<?php $this->bulk_actions( $which ); ?>
188
+				<?php $this->bulk_actions($which); ?>
189 189
 			</div>
190 190
 			<?php
191
-			$this->extra_tablenav( $which );
192
-			$this->pagination( $which );
191
+			$this->extra_tablenav($which);
192
+			$this->pagination($which);
193 193
 			?>
194 194
 
195 195
 			<br class="clear"/>
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 
213 213
 		$meta_query = array();
214 214
 
215
-		if ( $user ) {
215
+		if ($user) {
216 216
 			// Show only logs from a specific user
217 217
 			$meta_query[] = array(
218 218
 				'key'   => '_give_log_user_id',
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
 		}
222 222
 
223 223
 		$search = $this->get_search();
224
-		if ( $search ) {
225
-			if ( is_email( $search ) ) {
224
+		if ($search) {
225
+			if (is_email($search)) {
226 226
 				// This is an email search. We use this to ensure it works for guest users and logged-in users
227 227
 				$key     = '_give_log_user_info';
228 228
 				$compare = 'LIKE';
@@ -231,32 +231,32 @@  discard block
 block discarded – undo
231 231
 				$key     = '_give_log_user_id';
232 232
 				$compare = 'LIKE';
233 233
 
234
-				if ( ! is_numeric( $search ) ) {
234
+				if ( ! is_numeric($search)) {
235 235
 					// Searching for user by username
236
-					$user = get_user_by( 'login', $search );
236
+					$user = get_user_by('login', $search);
237 237
 
238
-					if ( $user ) {
238
+					if ($user) {
239 239
 						// Found one, set meta value to user's ID
240 240
 						$search = $user->ID;
241 241
 					} else {
242 242
 						// No user found so let's do a real search query
243
-						$users = new WP_User_Query( array(
243
+						$users = new WP_User_Query(array(
244 244
 							'search'         => $search,
245
-							'search_columns' => array( 'user_url', 'user_nicename' ),
245
+							'search_columns' => array('user_url', 'user_nicename'),
246 246
 							'number'         => 1,
247 247
 							'fields'         => 'ids',
248
-						) );
248
+						));
249 249
 
250 250
 						$found_user = $users->get_results();
251 251
 
252
-						if ( $found_user ) {
252
+						if ($found_user) {
253 253
 							$search = $found_user[0];
254 254
 						}
255 255
 					}
256 256
 				}
257 257
 			}
258 258
 
259
-			if ( ! $this->file_search ) {
259
+			if ( ! $this->file_search) {
260 260
 				// Meta query only works for non file name searche
261 261
 				$meta_query[] = array(
262 262
 					'key'     => $key,
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 	 * @since  1.0
278 278
 	 * @return void
279 279
 	 */
280
-	function bulk_actions( $which = '' ) {
280
+	function bulk_actions($which = '') {
281 281
 		give_log_views();
282 282
 	}
283 283
 
@@ -289,22 +289,22 @@  discard block
 block discarded – undo
289 289
 	 * @return void
290 290
 	 */
291 291
 	public function give_forms_filter() {
292
-		$give_forms = get_posts( array(
292
+		$give_forms = get_posts(array(
293 293
 			'post_type'              => 'give_forms',
294 294
 			'post_status'            => 'any',
295
-			'posts_per_page'         => - 1,
295
+			'posts_per_page'         => -1,
296 296
 			'orderby'                => 'title',
297 297
 			'order'                  => 'ASC',
298 298
 			'fields'                 => 'ids',
299 299
 			'update_post_meta_cache' => false,
300 300
 			'update_post_term_cache' => false,
301
-		) );
301
+		));
302 302
 
303
-		if ( $give_forms ) {
303
+		if ($give_forms) {
304 304
 			echo '<select name="form" id="give-log-form-filter">';
305
-			echo '<option value="0">' . esc_html__( 'All', 'give' ) . '</option>';
306
-			foreach ( $give_forms as $form ) {
307
-				echo '<option value="' . $form . '"' . selected( $form, $this->get_filtered_give_form() ) . '>' . esc_html( get_the_title( $form ) ) . '</option>';
305
+			echo '<option value="0">'.esc_html__('All', 'give').'</option>';
306
+			foreach ($give_forms as $form) {
307
+				echo '<option value="'.$form.'"'.selected($form, $this->get_filtered_give_form()).'>'.esc_html(get_the_title($form)).'</option>';
308 308
 			}
309 309
 			echo '</select>';
310 310
 		}
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 
325 325
 		$logs_data = array();
326 326
 		$paged     = $this->get_paged();
327
-		$give_form = empty( $_GET['s'] ) ? $this->get_filtered_give_form() : null;
327
+		$give_form = empty($_GET['s']) ? $this->get_filtered_give_form() : null;
328 328
 		$user      = $this->get_filtered_user();
329 329
 
330 330
 		$log_query = array(
@@ -334,39 +334,39 @@  discard block
 block discarded – undo
334 334
 			'meta_query'  => $this->get_meta_query(),
335 335
 		);
336 336
 
337
-		$cache_key = give_get_cache_key( 'get_logs', $log_query );
337
+		$cache_key = give_get_cache_key('get_logs', $log_query);
338 338
 
339 339
 		// Return result from cache if exist.
340
-		if ( ! ( $logs_data = get_option( $cache_key ) ) ) {
340
+		if ( ! ($logs_data = get_option($cache_key))) {
341 341
 
342
-			$logs = $give_logs->get_connected_logs( $log_query );
342
+			$logs = $give_logs->get_connected_logs($log_query);
343 343
 
344
-			if ( $logs ) {
345
-				foreach ( $logs as $log ) {
346
-					$payment_id = get_post_meta( $log->ID, '_give_log_payment_id', true );
344
+			if ($logs) {
345
+				foreach ($logs as $log) {
346
+					$payment_id = get_post_meta($log->ID, '_give_log_payment_id', true);
347 347
 
348 348
 					// Make sure this payment hasn't been deleted
349
-					if ( get_post( $payment_id ) ) :
350
-						$user_info      = give_get_payment_meta_user_info( $payment_id );
351
-						$payment_meta   = give_get_payment_meta( $payment_id );
352
-						$payment_amount = give_get_payment_amount( $payment_id );
349
+					if (get_post($payment_id)) :
350
+						$user_info      = give_get_payment_meta_user_info($payment_id);
351
+						$payment_meta   = give_get_payment_meta($payment_id);
352
+						$payment_amount = give_get_payment_amount($payment_id);
353 353
 
354 354
 						$logs_data[] = array(
355
-							'ID'         => '<span class="give-item-label give-item-label-gray">' . $log->ID . '</span>',
355
+							'ID'         => '<span class="give-item-label give-item-label-gray">'.$log->ID.'</span>',
356 356
 							'payment_id' => $payment_id,
357 357
 							'form'       => $log->post_parent,
358 358
 							'amount'     => $payment_amount,
359 359
 							'user_id'    => $user_info['id'],
360
-							'user_name'  => $user_info['first_name'] . ' ' . $user_info['last_name'],
361
-							'date'       => get_post_field( 'post_date', $payment_id ),
360
+							'user_name'  => $user_info['first_name'].' '.$user_info['last_name'],
361
+							'date'       => get_post_field('post_date', $payment_id),
362 362
 						);
363 363
 
364 364
 					endif;
365 365
 				}
366 366
 
367 367
 				// Cache results.
368
-				if ( ! empty( $logs_data ) ) {
369
-					add_option( $cache_key, $logs_data, '', 'no' );
368
+				if ( ! empty($logs_data)) {
369
+					add_option($cache_key, $logs_data, '', 'no');
370 370
 				}
371 371
 			}
372 372
 		}
@@ -394,15 +394,15 @@  discard block
 block discarded – undo
394 394
 		$columns               = $this->get_columns();
395 395
 		$hidden                = array();
396 396
 		$sortable              = $this->get_sortable_columns();
397
-		$this->_column_headers = array( $columns, $hidden, $sortable );
397
+		$this->_column_headers = array($columns, $hidden, $sortable);
398 398
 		$current_page          = $this->get_pagenum();
399 399
 		$this->items           = $this->get_logs();
400
-		$total_items           = $give_logs->get_log_count( $this->get_filtered_give_form(), 'sale', $this->get_meta_query() );
400
+		$total_items           = $give_logs->get_log_count($this->get_filtered_give_form(), 'sale', $this->get_meta_query());
401 401
 
402
-		$this->set_pagination_args( array(
402
+		$this->set_pagination_args(array(
403 403
 				'total_items' => $total_items,
404 404
 				'per_page'    => $this->per_page,
405
-				'total_pages' => ceil( $total_items / $this->per_page ),
405
+				'total_pages' => ceil($total_items / $this->per_page),
406 406
 			)
407 407
 		);
408 408
 	}
Please login to merge, or discard this patch.
includes/api/class-give-api.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -664,7 +664,7 @@
 block discarded – undo
664 664
 	 *
665 665
 	 * @param array $args Arguments to override defaults
666 666
 	 *
667
-	 * @return array $dates
667
+	 * @return integer|null $dates
668 668
 	 */
669 669
 	public function get_dates( $args = array() ) {
670 670
 		$dates = array();
Please login to merge, or discard this patch.
Spacing   +482 added lines, -482 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly.
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -140,27 +140,27 @@  discard block
 block discarded – undo
140 140
 			'v1' => 'GIVE_API_V1',
141 141
 		);
142 142
 
143
-		foreach ( $this->get_versions() as $version => $class ) {
144
-			require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api-' . $version . '.php';
143
+		foreach ($this->get_versions() as $version => $class) {
144
+			require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api-'.$version.'.php';
145 145
 		}
146 146
 
147
-		add_action( 'init', array( $this, 'add_endpoint' ) );
148
-		add_action( 'wp', array( $this, 'process_query' ), - 1 );
149
-		add_filter( 'query_vars', array( $this, 'query_vars' ) );
150
-		add_action( 'show_user_profile', array( $this, 'user_key_field' ) );
151
-		add_action( 'edit_user_profile', array( $this, 'user_key_field' ) );
152
-		add_action( 'personal_options_update', array( $this, 'update_key' ) );
153
-		add_action( 'edit_user_profile_update', array( $this, 'update_key' ) );
154
-		add_action( 'give_process_api_key', array( $this, 'process_api_key' ) );
147
+		add_action('init', array($this, 'add_endpoint'));
148
+		add_action('wp', array($this, 'process_query'), - 1);
149
+		add_filter('query_vars', array($this, 'query_vars'));
150
+		add_action('show_user_profile', array($this, 'user_key_field'));
151
+		add_action('edit_user_profile', array($this, 'user_key_field'));
152
+		add_action('personal_options_update', array($this, 'update_key'));
153
+		add_action('edit_user_profile_update', array($this, 'update_key'));
154
+		add_action('give_process_api_key', array($this, 'process_api_key'));
155 155
 
156 156
 		// Setup a backwards compatibility check for user API Keys
157
-		add_filter( 'get_user_metadata', array( $this, 'api_key_backwards_compat' ), 10, 4 );
157
+		add_filter('get_user_metadata', array($this, 'api_key_backwards_compat'), 10, 4);
158 158
 
159 159
 		// Determine if JSON_PRETTY_PRINT is available
160
-		$this->pretty_print = defined( 'JSON_PRETTY_PRINT' ) ? JSON_PRETTY_PRINT : null;
160
+		$this->pretty_print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : null;
161 161
 
162 162
 		// Allow API request logging to be turned off
163
-		$this->log_requests = apply_filters( 'give_api_log_requests', $this->log_requests );
163
+		$this->log_requests = apply_filters('give_api_log_requests', $this->log_requests);
164 164
 
165 165
 		// Setup Give_Payment_Stats instance
166 166
 		$this->stats = new Give_Payment_Stats;
@@ -176,8 +176,8 @@  discard block
 block discarded – undo
176 176
 	 *
177 177
 	 * @since  1.1
178 178
 	 */
179
-	public function add_endpoint( $rewrite_rules ) {
180
-		add_rewrite_endpoint( 'give-api', EP_ALL );
179
+	public function add_endpoint($rewrite_rules) {
180
+		add_rewrite_endpoint('give-api', EP_ALL);
181 181
 	}
182 182
 
183 183
 	/**
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	 *
191 191
 	 * @return string[] $vars New query vars
192 192
 	 */
193
-	public function query_vars( $vars ) {
193
+	public function query_vars($vars) {
194 194
 
195 195
 		$vars[] = 'token';
196 196
 		$vars[] = 'key';
@@ -241,11 +241,11 @@  discard block
 block discarded – undo
241 241
 	 */
242 242
 	public function get_default_version() {
243 243
 
244
-		$version = get_option( 'give_default_api_version' );
244
+		$version = get_option('give_default_api_version');
245 245
 
246
-		if ( defined( 'GIVE_API_VERSION' ) ) {
246
+		if (defined('GIVE_API_VERSION')) {
247 247
 			$version = GIVE_API_VERSION;
248
-		} elseif ( ! $version ) {
248
+		} elseif ( ! $version) {
249 249
 			$version = 'v1';
250 250
 		}
251 251
 
@@ -266,14 +266,14 @@  discard block
 block discarded – undo
266 266
 
267 267
 		$version = $wp_query->query_vars['give-api'];
268 268
 
269
-		if ( strpos( $version, '/' ) ) {
269
+		if (strpos($version, '/')) {
270 270
 
271
-			$version = explode( '/', $version );
272
-			$version = strtolower( $version[0] );
271
+			$version = explode('/', $version);
272
+			$version = strtolower($version[0]);
273 273
 
274
-			$wp_query->query_vars['give-api'] = str_replace( $version . '/', '', $wp_query->query_vars['give-api'] );
274
+			$wp_query->query_vars['give-api'] = str_replace($version.'/', '', $wp_query->query_vars['give-api']);
275 275
 
276
-			if ( array_key_exists( $version, $this->versions ) ) {
276
+			if (array_key_exists($version, $this->versions)) {
277 277
 
278 278
 				$this->queried_version = $version;
279 279
 
@@ -309,32 +309,32 @@  discard block
 block discarded – undo
309 309
 		$this->override = false;
310 310
 
311 311
 		// Make sure we have both user and api key
312
-		if ( ! empty( $wp_query->query_vars['give-api'] ) && ( $wp_query->query_vars['give-api'] != 'forms' || ! empty( $wp_query->query_vars['token'] ) ) ) {
312
+		if ( ! empty($wp_query->query_vars['give-api']) && ($wp_query->query_vars['give-api'] != 'forms' || ! empty($wp_query->query_vars['token']))) {
313 313
 
314
-			if ( empty( $wp_query->query_vars['token'] ) || empty( $wp_query->query_vars['key'] ) ) {
314
+			if (empty($wp_query->query_vars['token']) || empty($wp_query->query_vars['key'])) {
315 315
 				$this->missing_auth();
316 316
 			}
317 317
 
318 318
 			// Retrieve the user by public API key and ensure they exist
319
-			if ( ! ( $user = $this->get_user( $wp_query->query_vars['key'] ) ) ) {
319
+			if ( ! ($user = $this->get_user($wp_query->query_vars['key']))) {
320 320
 
321 321
 				$this->invalid_key();
322 322
 
323 323
 			} else {
324 324
 
325
-				$token  = urldecode( $wp_query->query_vars['token'] );
326
-				$secret = $this->get_user_secret_key( $user );
327
-				$public = urldecode( $wp_query->query_vars['key'] );
325
+				$token  = urldecode($wp_query->query_vars['token']);
326
+				$secret = $this->get_user_secret_key($user);
327
+				$public = urldecode($wp_query->query_vars['key']);
328 328
 
329
-				if ( hash_equals( md5( $secret . $public ), $token ) ) {
329
+				if (hash_equals(md5($secret.$public), $token)) {
330 330
 					$this->is_valid_request = true;
331 331
 				} else {
332 332
 					$this->invalid_auth();
333 333
 				}
334 334
 			}
335
-		} elseif ( ! empty( $wp_query->query_vars['give-api'] ) && $wp_query->query_vars['give-api'] == 'forms' ) {
335
+		} elseif ( ! empty($wp_query->query_vars['give-api']) && $wp_query->query_vars['give-api'] == 'forms') {
336 336
 			$this->is_valid_request = true;
337
-			$wp_query->set( 'key', 'public' );
337
+			$wp_query->set('key', 'public');
338 338
 		}
339 339
 	}
340 340
 
@@ -350,25 +350,25 @@  discard block
 block discarded – undo
350 350
 	 *
351 351
 	 * @return bool if user ID is found, false otherwise
352 352
 	 */
353
-	public function get_user( $key = '' ) {
353
+	public function get_user($key = '') {
354 354
 		global $wpdb, $wp_query;
355 355
 
356
-		if ( empty( $key ) ) {
357
-			$key = urldecode( $wp_query->query_vars['key'] );
356
+		if (empty($key)) {
357
+			$key = urldecode($wp_query->query_vars['key']);
358 358
 		}
359 359
 
360
-		if ( empty( $key ) ) {
360
+		if (empty($key)) {
361 361
 			return false;
362 362
 		}
363 363
 
364
-		$user = get_transient( md5( 'give_api_user_' . $key ) );
364
+		$user = get_transient(md5('give_api_user_'.$key));
365 365
 
366
-		if ( false === $user ) {
367
-			$user = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key ) );
368
-			set_transient( md5( 'give_api_user_' . $key ), $user, DAY_IN_SECONDS );
366
+		if (false === $user) {
367
+			$user = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key));
368
+			set_transient(md5('give_api_user_'.$key), $user, DAY_IN_SECONDS);
369 369
 		}
370 370
 
371
-		if ( $user != null ) {
371
+		if ($user != null) {
372 372
 			$this->user_id = $user;
373 373
 
374 374
 			return $user;
@@ -377,37 +377,37 @@  discard block
 block discarded – undo
377 377
 		return false;
378 378
 	}
379 379
 
380
-	public function get_user_public_key( $user_id = 0 ) {
380
+	public function get_user_public_key($user_id = 0) {
381 381
 		global $wpdb;
382 382
 
383
-		if ( empty( $user_id ) ) {
383
+		if (empty($user_id)) {
384 384
 			return '';
385 385
 		}
386 386
 
387
-		$cache_key       = md5( 'give_api_user_public_key' . $user_id );
388
-		$user_public_key = get_transient( $cache_key );
387
+		$cache_key       = md5('give_api_user_public_key'.$user_id);
388
+		$user_public_key = get_transient($cache_key);
389 389
 
390
-		if ( empty( $user_public_key ) ) {
391
-			$user_public_key = $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_public_key' AND user_id = %d", $user_id ) );
392
-			set_transient( $cache_key, $user_public_key, HOUR_IN_SECONDS );
390
+		if (empty($user_public_key)) {
391
+			$user_public_key = $wpdb->get_var($wpdb->prepare("SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_public_key' AND user_id = %d", $user_id));
392
+			set_transient($cache_key, $user_public_key, HOUR_IN_SECONDS);
393 393
 		}
394 394
 
395 395
 		return $user_public_key;
396 396
 	}
397 397
 
398
-	public function get_user_secret_key( $user_id = 0 ) {
398
+	public function get_user_secret_key($user_id = 0) {
399 399
 		global $wpdb;
400 400
 
401
-		if ( empty( $user_id ) ) {
401
+		if (empty($user_id)) {
402 402
 			return '';
403 403
 		}
404 404
 
405
-		$cache_key       = md5( 'give_api_user_secret_key' . $user_id );
406
-		$user_secret_key = get_transient( $cache_key );
405
+		$cache_key       = md5('give_api_user_secret_key'.$user_id);
406
+		$user_secret_key = get_transient($cache_key);
407 407
 
408
-		if ( empty( $user_secret_key ) ) {
409
-			$user_secret_key = $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_secret_key' AND user_id = %d", $user_id ) );
410
-			set_transient( $cache_key, $user_secret_key, HOUR_IN_SECONDS );
408
+		if (empty($user_secret_key)) {
409
+			$user_secret_key = $wpdb->get_var($wpdb->prepare("SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_secret_key' AND user_id = %d", $user_id));
410
+			set_transient($cache_key, $user_secret_key, HOUR_IN_SECONDS);
411 411
 		}
412 412
 
413 413
 		return $user_secret_key;
@@ -423,10 +423,10 @@  discard block
 block discarded – undo
423 423
 	 */
424 424
 	private function missing_auth() {
425 425
 		$error          = array();
426
-		$error['error'] = esc_html__( 'You must specify both a token and API key.', 'give' );
426
+		$error['error'] = esc_html__('You must specify both a token and API key.', 'give');
427 427
 
428 428
 		$this->data = $error;
429
-		$this->output( 401 );
429
+		$this->output(401);
430 430
 	}
431 431
 
432 432
 	/**
@@ -440,10 +440,10 @@  discard block
 block discarded – undo
440 440
 	 */
441 441
 	private function invalid_auth() {
442 442
 		$error          = array();
443
-		$error['error'] = esc_html__( 'Your request could not be authenticated.', 'give' );
443
+		$error['error'] = esc_html__('Your request could not be authenticated.', 'give');
444 444
 
445 445
 		$this->data = $error;
446
-		$this->output( 403 );
446
+		$this->output(403);
447 447
 	}
448 448
 
449 449
 	/**
@@ -457,10 +457,10 @@  discard block
 block discarded – undo
457 457
 	 */
458 458
 	private function invalid_key() {
459 459
 		$error          = array();
460
-		$error['error'] = esc_html__( 'Invalid API key.', 'give' );
460
+		$error['error'] = esc_html__('Invalid API key.', 'give');
461 461
 
462 462
 		$this->data = $error;
463
-		$this->output( 403 );
463
+		$this->output(403);
464 464
 	}
465 465
 
466 466
 	/**
@@ -473,10 +473,10 @@  discard block
 block discarded – undo
473 473
 	 */
474 474
 	private function invalid_version() {
475 475
 		$error          = array();
476
-		$error['error'] = esc_html__( 'Invalid API version.', 'give' );
476
+		$error['error'] = esc_html__('Invalid API version.', 'give');
477 477
 
478 478
 		$this->data = $error;
479
-		$this->output( 404 );
479
+		$this->output(404);
480 480
 	}
481 481
 
482 482
 	/**
@@ -492,10 +492,10 @@  discard block
 block discarded – undo
492 492
 		global $wp_query;
493 493
 
494 494
 		// Start logging how long the request takes for logging
495
-		$before = microtime( true );
495
+		$before = microtime(true);
496 496
 
497 497
 		// Check for give-api var. Get out if not present
498
-		if ( empty( $wp_query->query_vars['give-api'] ) ) {
498
+		if (empty($wp_query->query_vars['give-api'])) {
499 499
 			return;
500 500
 		}
501 501
 
@@ -509,45 +509,45 @@  discard block
 block discarded – undo
509 509
 		$this->validate_request();
510 510
 
511 511
 		// Only proceed if no errors have been noted
512
-		if ( ! $this->is_valid_request ) {
512
+		if ( ! $this->is_valid_request) {
513 513
 			return;
514 514
 		}
515 515
 
516
-		if ( ! defined( 'GIVE_DOING_API' ) ) {
517
-			define( 'GIVE_DOING_API', true );
516
+		if ( ! defined('GIVE_DOING_API')) {
517
+			define('GIVE_DOING_API', true);
518 518
 		}
519 519
 
520 520
 		$data         = array();
521 521
 		$this->routes = new $this->versions[$this->get_queried_version()];
522 522
 		$this->routes->validate_request();
523 523
 
524
-		switch ( $this->endpoint ) :
524
+		switch ($this->endpoint) :
525 525
 
526 526
 			case 'stats' :
527 527
 
528
-				$data = $this->routes->get_stats( array(
529
-					'type'      => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null,
530
-					'form'      => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null,
531
-					'date'      => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null,
532
-					'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null,
533
-					'enddate'   => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null,
534
-				) );
528
+				$data = $this->routes->get_stats(array(
529
+					'type'      => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null,
530
+					'form'      => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null,
531
+					'date'      => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null,
532
+					'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null,
533
+					'enddate'   => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null,
534
+				));
535 535
 
536 536
 				break;
537 537
 
538 538
 			case 'forms' :
539 539
 
540
-				$form = isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null;
540
+				$form = isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null;
541 541
 
542
-				$data = $this->routes->get_forms( $form );
542
+				$data = $this->routes->get_forms($form);
543 543
 
544 544
 				break;
545 545
 
546 546
 			case 'donors' :
547 547
 
548
-				$customer = isset( $wp_query->query_vars['donor'] ) ? $wp_query->query_vars['donor'] : null;
548
+				$customer = isset($wp_query->query_vars['donor']) ? $wp_query->query_vars['donor'] : null;
549 549
 
550
-				$data = $this->routes->get_customers( $customer );
550
+				$data = $this->routes->get_customers($customer);
551 551
 
552 552
 				break;
553 553
 
@@ -560,14 +560,14 @@  discard block
 block discarded – undo
560 560
 		endswitch;
561 561
 
562 562
 		// Allow extensions to setup their own return data
563
-		$this->data = apply_filters( 'give_api_output_data', $data, $this->endpoint, $this );
563
+		$this->data = apply_filters('give_api_output_data', $data, $this->endpoint, $this);
564 564
 
565
-		$after                       = microtime( true );
566
-		$request_time                = ( $after - $before );
565
+		$after                       = microtime(true);
566
+		$request_time                = ($after - $before);
567 567
 		$this->data['request_speed'] = $request_time;
568 568
 
569 569
 		// Log this API request, if enabled. We log it here because we have access to errors.
570
-		$this->log_request( $this->data );
570
+		$this->log_request($this->data);
571 571
 
572 572
 		// Send out data to the output function
573 573
 		$this->output();
@@ -597,25 +597,25 @@  discard block
 block discarded – undo
597 597
 		global $wp_query;
598 598
 
599 599
 		// Whitelist our query options
600
-		$accepted = apply_filters( 'give_api_valid_query_modes', array(
600
+		$accepted = apply_filters('give_api_valid_query_modes', array(
601 601
 			'stats',
602 602
 			'forms',
603 603
 			'donors',
604 604
 			'donations',
605
-		) );
605
+		));
606 606
 
607
-		$query = isset( $wp_query->query_vars['give-api'] ) ? $wp_query->query_vars['give-api'] : null;
608
-		$query = str_replace( $this->queried_version . '/', '', $query );
607
+		$query = isset($wp_query->query_vars['give-api']) ? $wp_query->query_vars['give-api'] : null;
608
+		$query = str_replace($this->queried_version.'/', '', $query);
609 609
 
610 610
 		$error = array();
611 611
 
612 612
 		// Make sure our query is valid
613
-		if ( ! in_array( $query, $accepted ) ) {
614
-			$error['error'] = esc_html__( 'Invalid query.', 'give' );
613
+		if ( ! in_array($query, $accepted)) {
614
+			$error['error'] = esc_html__('Invalid query.', 'give');
615 615
 
616 616
 			$this->data = $error;
617 617
 			// 400 is Bad Request
618
-			$this->output( 400 );
618
+			$this->output(400);
619 619
 		}
620 620
 
621 621
 		$this->endpoint = $query;
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
 	public function get_paged() {
633 633
 		global $wp_query;
634 634
 
635
-		return isset( $wp_query->query_vars['page'] ) ? $wp_query->query_vars['page'] : 1;
635
+		return isset($wp_query->query_vars['page']) ? $wp_query->query_vars['page'] : 1;
636 636
 	}
637 637
 
638 638
 
@@ -647,13 +647,13 @@  discard block
 block discarded – undo
647 647
 	public function per_page() {
648 648
 		global $wp_query;
649 649
 
650
-		$per_page = isset( $wp_query->query_vars['number'] ) ? $wp_query->query_vars['number'] : 10;
650
+		$per_page = isset($wp_query->query_vars['number']) ? $wp_query->query_vars['number'] : 10;
651 651
 
652
-		if ( $per_page < 0 && $this->get_query_mode() == 'donors' ) {
652
+		if ($per_page < 0 && $this->get_query_mode() == 'donors') {
653 653
 			$per_page = 99999999;
654 654
 		} // Customers query doesn't support -1
655 655
 
656
-		return apply_filters( 'give_api_results_per_page', $per_page );
656
+		return apply_filters('give_api_results_per_page', $per_page);
657 657
 	}
658 658
 
659 659
 	/**
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
 	 *
667 667
 	 * @return array $dates
668 668
 	 */
669
-	public function get_dates( $args = array() ) {
669
+	public function get_dates($args = array()) {
670 670
 		$dates = array();
671 671
 
672 672
 		$defaults = array(
@@ -677,60 +677,60 @@  discard block
 block discarded – undo
677 677
 			'enddate'   => null,
678 678
 		);
679 679
 
680
-		$args = wp_parse_args( $args, $defaults );
680
+		$args = wp_parse_args($args, $defaults);
681 681
 
682
-		$current_time = current_time( 'timestamp' );
682
+		$current_time = current_time('timestamp');
683 683
 
684
-		if ( 'range' === $args['date'] ) {
685
-			$startdate          = strtotime( $args['startdate'] );
686
-			$enddate            = strtotime( $args['enddate'] );
687
-			$dates['day_start'] = date( 'd', $startdate );
688
-			$dates['day_end']   = date( 'd', $enddate );
689
-			$dates['m_start']   = date( 'n', $startdate );
690
-			$dates['m_end']     = date( 'n', $enddate );
691
-			$dates['year']      = date( 'Y', $startdate );
692
-			$dates['year_end']  = date( 'Y', $enddate );
684
+		if ('range' === $args['date']) {
685
+			$startdate          = strtotime($args['startdate']);
686
+			$enddate            = strtotime($args['enddate']);
687
+			$dates['day_start'] = date('d', $startdate);
688
+			$dates['day_end']   = date('d', $enddate);
689
+			$dates['m_start']   = date('n', $startdate);
690
+			$dates['m_end']     = date('n', $enddate);
691
+			$dates['year']      = date('Y', $startdate);
692
+			$dates['year_end']  = date('Y', $enddate);
693 693
 		} else {
694 694
 			// Modify dates based on predefined ranges
695
-			switch ( $args['date'] ) :
695
+			switch ($args['date']) :
696 696
 
697 697
 				case 'this_month' :
698 698
 					$dates['day']     = null;
699
-					$dates['m_start'] = date( 'n', $current_time );
700
-					$dates['m_end']   = date( 'n', $current_time );
701
-					$dates['year']    = date( 'Y', $current_time );
699
+					$dates['m_start'] = date('n', $current_time);
700
+					$dates['m_end']   = date('n', $current_time);
701
+					$dates['year']    = date('Y', $current_time);
702 702
 					break;
703 703
 
704 704
 				case 'last_month' :
705 705
 					$dates['day']     = null;
706
-					$dates['m_start'] = date( 'n', $current_time ) == 1 ? 12 : date( 'n', $current_time ) - 1;
706
+					$dates['m_start'] = date('n', $current_time) == 1 ? 12 : date('n', $current_time) - 1;
707 707
 					$dates['m_end']   = $dates['m_start'];
708
-					$dates['year']    = date( 'n', $current_time ) == 1 ? date( 'Y', $current_time ) - 1 : date( 'Y', $current_time );
708
+					$dates['year']    = date('n', $current_time) == 1 ? date('Y', $current_time) - 1 : date('Y', $current_time);
709 709
 					break;
710 710
 
711 711
 				case 'today' :
712
-					$dates['day']     = date( 'd', $current_time );
713
-					$dates['m_start'] = date( 'n', $current_time );
714
-					$dates['m_end']   = date( 'n', $current_time );
715
-					$dates['year']    = date( 'Y', $current_time );
712
+					$dates['day']     = date('d', $current_time);
713
+					$dates['m_start'] = date('n', $current_time);
714
+					$dates['m_end']   = date('n', $current_time);
715
+					$dates['year']    = date('Y', $current_time);
716 716
 					break;
717 717
 
718 718
 				case 'yesterday' :
719 719
 
720
-					$year  = date( 'Y', $current_time );
721
-					$month = date( 'n', $current_time );
722
-					$day   = date( 'd', $current_time );
720
+					$year  = date('Y', $current_time);
721
+					$month = date('n', $current_time);
722
+					$day   = date('d', $current_time);
723 723
 
724
-					if ( $month == 1 && $day == 1 ) {
724
+					if ($month == 1 && $day == 1) {
725 725
 
726 726
 						$year -= 1;
727 727
 						$month = 12;
728
-						$day   = cal_days_in_month( CAL_GREGORIAN, $month, $year );
728
+						$day   = cal_days_in_month(CAL_GREGORIAN, $month, $year);
729 729
 
730
-					} elseif ( $month > 1 && $day == 1 ) {
730
+					} elseif ($month > 1 && $day == 1) {
731 731
 
732 732
 						$month -= 1;
733
-						$day = cal_days_in_month( CAL_GREGORIAN, $month, $year );
733
+						$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
734 734
 
735 735
 					} else {
736 736
 
@@ -746,65 +746,65 @@  discard block
 block discarded – undo
746 746
 					break;
747 747
 
748 748
 				case 'this_quarter' :
749
-					$month_now = date( 'n', $current_time );
749
+					$month_now = date('n', $current_time);
750 750
 
751 751
 					$dates['day'] = null;
752 752
 
753
-					if ( $month_now <= 3 ) {
753
+					if ($month_now <= 3) {
754 754
 
755 755
 						$dates['m_start'] = 1;
756 756
 						$dates['m_end']   = 3;
757
-						$dates['year']    = date( 'Y', $current_time );
757
+						$dates['year']    = date('Y', $current_time);
758 758
 
759
-					} elseif ( $month_now <= 6 ) {
759
+					} elseif ($month_now <= 6) {
760 760
 
761 761
 						$dates['m_start'] = 4;
762 762
 						$dates['m_end']   = 6;
763
-						$dates['year']    = date( 'Y', $current_time );
763
+						$dates['year']    = date('Y', $current_time);
764 764
 
765
-					} elseif ( $month_now <= 9 ) {
765
+					} elseif ($month_now <= 9) {
766 766
 
767 767
 						$dates['m_start'] = 7;
768 768
 						$dates['m_end']   = 9;
769
-						$dates['year']    = date( 'Y', $current_time );
769
+						$dates['year']    = date('Y', $current_time);
770 770
 
771 771
 					} else {
772 772
 
773 773
 						$dates['m_start'] = 10;
774 774
 						$dates['m_end']   = 12;
775
-						$dates['year']    = date( 'Y', $current_time );
775
+						$dates['year']    = date('Y', $current_time);
776 776
 
777 777
 					}
778 778
 					break;
779 779
 
780 780
 				case 'last_quarter' :
781
-					$month_now = date( 'n', $current_time );
781
+					$month_now = date('n', $current_time);
782 782
 
783 783
 					$dates['day'] = null;
784 784
 
785
-					if ( $month_now <= 3 ) {
785
+					if ($month_now <= 3) {
786 786
 
787 787
 						$dates['m_start'] = 10;
788 788
 						$dates['m_end']   = 12;
789
-						$dates['year']    = date( 'Y', $current_time ) - 1; // Previous year
789
+						$dates['year']    = date('Y', $current_time) - 1; // Previous year
790 790
 
791
-					} elseif ( $month_now <= 6 ) {
791
+					} elseif ($month_now <= 6) {
792 792
 
793 793
 						$dates['m_start'] = 1;
794 794
 						$dates['m_end']   = 3;
795
-						$dates['year']    = date( 'Y', $current_time );
795
+						$dates['year']    = date('Y', $current_time);
796 796
 
797
-					} elseif ( $month_now <= 9 ) {
797
+					} elseif ($month_now <= 9) {
798 798
 
799 799
 						$dates['m_start'] = 4;
800 800
 						$dates['m_end']   = 6;
801
-						$dates['year']    = date( 'Y', $current_time );
801
+						$dates['year']    = date('Y', $current_time);
802 802
 
803 803
 					} else {
804 804
 
805 805
 						$dates['m_start'] = 7;
806 806
 						$dates['m_end']   = 9;
807
-						$dates['year']    = date( 'Y', $current_time );
807
+						$dates['year']    = date('Y', $current_time);
808 808
 
809 809
 					}
810 810
 					break;
@@ -813,14 +813,14 @@  discard block
 block discarded – undo
813 813
 					$dates['day']     = null;
814 814
 					$dates['m_start'] = null;
815 815
 					$dates['m_end']   = null;
816
-					$dates['year']    = date( 'Y', $current_time );
816
+					$dates['year']    = date('Y', $current_time);
817 817
 					break;
818 818
 
819 819
 				case 'last_year' :
820 820
 					$dates['day']     = null;
821 821
 					$dates['m_start'] = null;
822 822
 					$dates['m_end']   = null;
823
-					$dates['year']    = date( 'Y', $current_time ) - 1;
823
+					$dates['year']    = date('Y', $current_time) - 1;
824 824
 					break;
825 825
 
826 826
 			endswitch;
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
 		 *
834 834
 		 * @param array $dates The dates used for retrieving earnings/donations
835 835
 		 */
836
-		return apply_filters( 'give_api_stat_dates', $dates );
836
+		return apply_filters('give_api_stat_dates', $dates);
837 837
 	}
838 838
 
839 839
 	/**
@@ -848,11 +848,11 @@  discard block
 block discarded – undo
848 848
 	 *
849 849
 	 * @return array $customers Multidimensional array of the customers
850 850
 	 */
851
-	public function get_customers( $customer = null ) {
851
+	public function get_customers($customer = null) {
852 852
 
853 853
 		$customers = array();
854 854
 		$error     = array();
855
-		if ( ! user_can( $this->user_id, 'view_give_sensitive_data' ) && ! $this->override ) {
855
+		if ( ! user_can($this->user_id, 'view_give_sensitive_data') && ! $this->override) {
856 856
 			return $customers;
857 857
 		}
858 858
 
@@ -860,63 +860,63 @@  discard block
 block discarded – undo
860 860
 
861 861
 		$paged    = $this->get_paged();
862 862
 		$per_page = $this->per_page();
863
-		$offset   = $per_page * ( $paged - 1 );
863
+		$offset   = $per_page * ($paged - 1);
864 864
 
865
-		if ( is_numeric( $customer ) ) {
865
+		if (is_numeric($customer)) {
866 866
 			$field = 'id';
867 867
 		} else {
868 868
 			$field = 'email';
869 869
 		}
870 870
 
871
-		$customer_query = Give()->customers->get_customers( array(
871
+		$customer_query = Give()->customers->get_customers(array(
872 872
 			'number' => $per_page,
873 873
 			'offset' => $offset,
874 874
 			$field   => $customer,
875
-		) );
875
+		));
876 876
 		$customer_count = 0;
877 877
 
878
-		if ( $customer_query ) {
878
+		if ($customer_query) {
879 879
 
880
-			foreach ( $customer_query as $customer_obj ) {
880
+			foreach ($customer_query as $customer_obj) {
881 881
 
882
-				$names      = explode( ' ', $customer_obj->name );
883
-				$first_name = ! empty( $names[0] ) ? $names[0] : '';
882
+				$names      = explode(' ', $customer_obj->name);
883
+				$first_name = ! empty($names[0]) ? $names[0] : '';
884 884
 				$last_name  = '';
885
-				if ( ! empty( $names[1] ) ) {
886
-					unset( $names[0] );
887
-					$last_name = implode( ' ', $names );
885
+				if ( ! empty($names[1])) {
886
+					unset($names[0]);
887
+					$last_name = implode(' ', $names);
888 888
 				}
889 889
 
890
-				$customers['donors'][ $customer_count ]['info']['user_id']      = '';
891
-				$customers['donors'][ $customer_count ]['info']['username']     = '';
892
-				$customers['donors'][ $customer_count ]['info']['display_name'] = '';
893
-				$customers['donors'][ $customer_count ]['info']['customer_id']  = $customer_obj->id;
894
-				$customers['donors'][ $customer_count ]['info']['first_name']   = $first_name;
895
-				$customers['donors'][ $customer_count ]['info']['last_name']    = $last_name;
896
-				$customers['donors'][ $customer_count ]['info']['email']        = $customer_obj->email;
890
+				$customers['donors'][$customer_count]['info']['user_id']      = '';
891
+				$customers['donors'][$customer_count]['info']['username']     = '';
892
+				$customers['donors'][$customer_count]['info']['display_name'] = '';
893
+				$customers['donors'][$customer_count]['info']['customer_id']  = $customer_obj->id;
894
+				$customers['donors'][$customer_count]['info']['first_name']   = $first_name;
895
+				$customers['donors'][$customer_count]['info']['last_name']    = $last_name;
896
+				$customers['donors'][$customer_count]['info']['email']        = $customer_obj->email;
897 897
 
898
-				if ( ! empty( $customer_obj->user_id ) ) {
898
+				if ( ! empty($customer_obj->user_id)) {
899 899
 
900
-					$user_data = get_userdata( $customer_obj->user_id );
900
+					$user_data = get_userdata($customer_obj->user_id);
901 901
 
902 902
 					// Customer with registered account.
903
-					$customers['donors'][ $customer_count ]['info']['user_id']      = $customer_obj->user_id;
904
-					$customers['donors'][ $customer_count ]['info']['username']     = $user_data->user_login;
905
-					$customers['donors'][ $customer_count ]['info']['display_name'] = $user_data->display_name;
903
+					$customers['donors'][$customer_count]['info']['user_id']      = $customer_obj->user_id;
904
+					$customers['donors'][$customer_count]['info']['username']     = $user_data->user_login;
905
+					$customers['donors'][$customer_count]['info']['display_name'] = $user_data->display_name;
906 906
 
907 907
 				}
908 908
 
909
-				$customers['donors'][ $customer_count ]['stats']['total_donations'] = $customer_obj->purchase_count;
910
-				$customers['donors'][ $customer_count ]['stats']['total_spent']     = $customer_obj->purchase_value;
909
+				$customers['donors'][$customer_count]['stats']['total_donations'] = $customer_obj->purchase_count;
910
+				$customers['donors'][$customer_count]['stats']['total_spent']     = $customer_obj->purchase_value;
911 911
 
912
-				$customer_count ++;
912
+				$customer_count++;
913 913
 
914 914
 			}
915
-		} elseif ( $customer ) {
915
+		} elseif ($customer) {
916 916
 
917 917
 			$error['error'] = sprintf(
918 918
 			/* translators: %s: customer */
919
-				esc_html__( 'Donor %s not found.', 'give' ),
919
+				esc_html__('Donor %s not found.', 'give'),
920 920
 				$customer
921 921
 			);
922 922
 
@@ -924,7 +924,7 @@  discard block
 block discarded – undo
924 924
 
925 925
 		} else {
926 926
 
927
-			$error['error'] = esc_html__( 'No donors found.', 'give' );
927
+			$error['error'] = esc_html__('No donors found.', 'give');
928 928
 
929 929
 			return $error;
930 930
 
@@ -943,38 +943,38 @@  discard block
 block discarded – undo
943 943
 	 *
944 944
 	 * @return array $customers Multidimensional array of the forms
945 945
 	 */
946
-	public function get_forms( $form = null ) {
946
+	public function get_forms($form = null) {
947 947
 
948 948
 		$forms = array();
949 949
 		$error = array();
950 950
 
951
-		if ( $form == null ) {
951
+		if ($form == null) {
952 952
 			$forms['forms'] = array();
953 953
 
954
-			$form_list = get_posts( array(
954
+			$form_list = get_posts(array(
955 955
 				'post_type'        => 'give_forms',
956 956
 				'posts_per_page'   => $this->per_page(),
957 957
 				'suppress_filters' => true,
958 958
 				'paged'            => $this->get_paged(),
959
-			) );
959
+			));
960 960
 
961
-			if ( $form_list ) {
961
+			if ($form_list) {
962 962
 				$i = 0;
963
-				foreach ( $form_list as $form_info ) {
964
-					$forms['forms'][ $i ] = $this->get_form_data( $form_info );
965
-					$i ++;
963
+				foreach ($form_list as $form_info) {
964
+					$forms['forms'][$i] = $this->get_form_data($form_info);
965
+					$i++;
966 966
 				}
967 967
 			}
968 968
 		} else {
969
-			if ( get_post_type( $form ) == 'give_forms' ) {
970
-				$form_info = get_post( $form );
969
+			if (get_post_type($form) == 'give_forms') {
970
+				$form_info = get_post($form);
971 971
 
972
-				$forms['forms'][0] = $this->get_form_data( $form_info );
972
+				$forms['forms'][0] = $this->get_form_data($form_info);
973 973
 
974 974
 			} else {
975 975
 				$error['error'] = sprintf(
976 976
 				/* translators: %s: form */
977
-					esc_html__( 'Form %s not found.', 'give' ),
977
+					esc_html__('Form %s not found.', 'give'),
978 978
 					$form
979 979
 				);
980 980
 
@@ -994,7 +994,7 @@  discard block
 block discarded – undo
994 994
 	 *
995 995
 	 * @return array                Array of post data to return back in the API
996 996
 	 */
997
-	private function get_form_data( $form_info ) {
997
+	private function get_form_data($form_info) {
998 998
 
999 999
 		$form = array();
1000 1000
 
@@ -1004,50 +1004,50 @@  discard block
 block discarded – undo
1004 1004
 		$form['info']['create_date']   = $form_info->post_date;
1005 1005
 		$form['info']['modified_date'] = $form_info->post_modified;
1006 1006
 		$form['info']['status']        = $form_info->post_status;
1007
-		$form['info']['link']          = html_entity_decode( $form_info->guid );
1008
-		$form['info']['content']       = get_post_meta( $form_info->ID, '_give_form_content', true );
1009
-		$form['info']['thumbnail']     = wp_get_attachment_url( get_post_thumbnail_id( $form_info->ID ) );
1007
+		$form['info']['link']          = html_entity_decode($form_info->guid);
1008
+		$form['info']['content']       = get_post_meta($form_info->ID, '_give_form_content', true);
1009
+		$form['info']['thumbnail']     = wp_get_attachment_url(get_post_thumbnail_id($form_info->ID));
1010 1010
 
1011
-		if ( give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ) ) {
1012
-			$form['info']['category'] = get_the_terms( $form_info, 'give_forms_category' );
1013
-			$form['info']['tags']     = get_the_terms( $form_info, 'give_forms_tag' );
1011
+		if (give_is_setting_enabled(give_get_option('categories', 'disabled'))) {
1012
+			$form['info']['category'] = get_the_terms($form_info, 'give_forms_category');
1013
+			$form['info']['tags']     = get_the_terms($form_info, 'give_forms_tag');
1014 1014
 		}
1015
-		if ( give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) ) ) {
1016
-			$form['info']['tags'] = get_the_terms( $form_info, 'give_forms_tag' );
1015
+		if (give_is_setting_enabled(give_get_option('tags', 'disabled'))) {
1016
+			$form['info']['tags'] = get_the_terms($form_info, 'give_forms_tag');
1017 1017
 		}
1018 1018
 
1019
-		if ( user_can( $this->user_id, 'view_give_reports' ) || $this->override ) {
1020
-			$form['stats']['total']['donations']           = give_get_form_sales_stats( $form_info->ID );
1021
-			$form['stats']['total']['earnings']            = give_get_form_earnings_stats( $form_info->ID );
1022
-			$form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales( $form_info->ID );
1023
-			$form['stats']['monthly_average']['earnings']  = give_get_average_monthly_form_earnings( $form_info->ID );
1019
+		if (user_can($this->user_id, 'view_give_reports') || $this->override) {
1020
+			$form['stats']['total']['donations']           = give_get_form_sales_stats($form_info->ID);
1021
+			$form['stats']['total']['earnings']            = give_get_form_earnings_stats($form_info->ID);
1022
+			$form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales($form_info->ID);
1023
+			$form['stats']['monthly_average']['earnings']  = give_get_average_monthly_form_earnings($form_info->ID);
1024 1024
 		}
1025 1025
 
1026 1026
 		$counter = 0;
1027
-		if ( give_has_variable_prices( $form_info->ID ) ) {
1028
-			foreach ( give_get_variable_prices( $form_info->ID ) as $price ) {
1029
-				$counter ++;
1027
+		if (give_has_variable_prices($form_info->ID)) {
1028
+			foreach (give_get_variable_prices($form_info->ID) as $price) {
1029
+				$counter++;
1030 1030
 				// muli-level item
1031
-				$level                                     = isset( $price['_give_text'] ) ? $price['_give_text'] : 'level-' . $counter;
1032
-				$form['pricing'][ sanitize_key( $level ) ] = $price['_give_amount'];
1031
+				$level                                     = isset($price['_give_text']) ? $price['_give_text'] : 'level-'.$counter;
1032
+				$form['pricing'][sanitize_key($level)] = $price['_give_amount'];
1033 1033
 
1034 1034
 			}
1035 1035
 		} else {
1036
-			$form['pricing']['amount'] = give_get_form_price( $form_info->ID );
1036
+			$form['pricing']['amount'] = give_get_form_price($form_info->ID);
1037 1037
 		}
1038 1038
 
1039
-		if ( user_can( $this->user_id, 'view_give_sensitive_data' ) || $this->override ) {
1039
+		if (user_can($this->user_id, 'view_give_sensitive_data') || $this->override) {
1040 1040
 
1041 1041
 			/**
1042 1042
 			 * Fires when generating API sensitive data.
1043 1043
 			 *
1044 1044
 			 * @since 1.1
1045 1045
 			 */
1046
-			do_action( 'give_api_sensitive_data' );
1046
+			do_action('give_api_sensitive_data');
1047 1047
 
1048 1048
 		}
1049 1049
 
1050
-		return apply_filters( 'give_api_forms_form', $form );
1050
+		return apply_filters('give_api_forms_form', $form);
1051 1051
 
1052 1052
 	}
1053 1053
 
@@ -1062,7 +1062,7 @@  discard block
 block discarded – undo
1062 1062
 	 *
1063 1063
 	 * @return array
1064 1064
 	 */
1065
-	public function get_stats( $args = array() ) {
1065
+	public function get_stats($args = array()) {
1066 1066
 		$defaults = array(
1067 1067
 			'type'      => null,
1068 1068
 			'form'      => null,
@@ -1071,9 +1071,9 @@  discard block
 block discarded – undo
1071 1071
 			'enddate'   => null,
1072 1072
 		);
1073 1073
 
1074
-		$args = wp_parse_args( $args, $defaults );
1074
+		$args = wp_parse_args($args, $defaults);
1075 1075
 
1076
-		$dates = $this->get_dates( $args );
1076
+		$dates = $this->get_dates($args);
1077 1077
 
1078 1078
 		$stats    = array();
1079 1079
 		$earnings = array(
@@ -1084,40 +1084,40 @@  discard block
 block discarded – undo
1084 1084
 		);
1085 1085
 		$error    = array();
1086 1086
 
1087
-		if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) {
1087
+		if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) {
1088 1088
 			return $stats;
1089 1089
 		}
1090 1090
 
1091
-		if ( $args['type'] == 'donations' ) {
1091
+		if ($args['type'] == 'donations') {
1092 1092
 
1093
-			if ( $args['form'] == null ) {
1094
-				if ( $args['date'] == null ) {
1093
+			if ($args['form'] == null) {
1094
+				if ($args['date'] == null) {
1095 1095
 					$sales = $this->get_default_sales_stats();
1096
-				} elseif ( $args['date'] === 'range' ) {
1096
+				} elseif ($args['date'] === 'range') {
1097 1097
 					// Return sales for a date range
1098 1098
 					// Ensure the end date is later than the start date
1099
-					if ( $args['enddate'] < $args['startdate'] ) {
1100
-						$error['error'] = esc_html__( 'The end date must be later than the start date.', 'give' );
1099
+					if ($args['enddate'] < $args['startdate']) {
1100
+						$error['error'] = esc_html__('The end date must be later than the start date.', 'give');
1101 1101
 					}
1102 1102
 
1103 1103
 					// Ensure both the start and end date are specified
1104
-					if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) {
1105
-						$error['error'] = esc_html__( 'Invalid or no date range specified.', 'give' );
1104
+					if (empty($args['startdate']) || empty($args['enddate'])) {
1105
+						$error['error'] = esc_html__('Invalid or no date range specified.', 'give');
1106 1106
 					}
1107 1107
 
1108 1108
 					$total = 0;
1109 1109
 
1110 1110
 					// Loop through the years
1111 1111
 					$y = $dates['year'];
1112
-					while ( $y <= $dates['year_end'] ) :
1112
+					while ($y <= $dates['year_end']) :
1113 1113
 
1114
-						if ( $dates['year'] == $dates['year_end'] ) {
1114
+						if ($dates['year'] == $dates['year_end']) {
1115 1115
 							$month_start = $dates['m_start'];
1116 1116
 							$month_end   = $dates['m_end'];
1117
-						} elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) {
1117
+						} elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) {
1118 1118
 							$month_start = $dates['m_start'];
1119 1119
 							$month_end   = 12;
1120
-						} elseif ( $y == $dates['year_end'] ) {
1120
+						} elseif ($y == $dates['year_end']) {
1121 1121
 							$month_start = 1;
1122 1122
 							$month_end   = $dates['m_end'];
1123 1123
 						} else {
@@ -1126,112 +1126,112 @@  discard block
 block discarded – undo
1126 1126
 						}
1127 1127
 
1128 1128
 						$i = $month_start;
1129
-						while ( $i <= $month_end ) :
1129
+						while ($i <= $month_end) :
1130 1130
 
1131
-							if ( $i == $dates['m_start'] ) {
1131
+							if ($i == $dates['m_start']) {
1132 1132
 								$d = $dates['day_start'];
1133 1133
 							} else {
1134 1134
 								$d = 1;
1135 1135
 							}
1136 1136
 
1137
-							if ( $i == $dates['m_end'] ) {
1137
+							if ($i == $dates['m_end']) {
1138 1138
 								$num_of_days = $dates['day_end'];
1139 1139
 							} else {
1140
-								$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
1140
+								$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
1141 1141
 							}
1142 1142
 
1143
-							while ( $d <= $num_of_days ) :
1144
-								$sale_count = give_get_sales_by_date( $d, $i, $y );
1145
-								$date_key   = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) );
1146
-								if ( ! isset( $sales['sales'][ $date_key ] ) ) {
1147
-									$sales['sales'][ $date_key ] = 0;
1143
+							while ($d <= $num_of_days) :
1144
+								$sale_count = give_get_sales_by_date($d, $i, $y);
1145
+								$date_key   = date('Ymd', strtotime($y.'/'.$i.'/'.$d));
1146
+								if ( ! isset($sales['sales'][$date_key])) {
1147
+									$sales['sales'][$date_key] = 0;
1148 1148
 								}
1149
-								$sales['sales'][ $date_key ] += $sale_count;
1149
+								$sales['sales'][$date_key] += $sale_count;
1150 1150
 								$total += $sale_count;
1151
-								$d ++;
1151
+								$d++;
1152 1152
 							endwhile;
1153
-							$i ++;
1153
+							$i++;
1154 1154
 						endwhile;
1155 1155
 
1156
-						$y ++;
1156
+						$y++;
1157 1157
 					endwhile;
1158 1158
 
1159 1159
 					$sales['totals'] = $total;
1160 1160
 				} else {
1161
-					if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) {
1161
+					if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') {
1162 1162
 						$sales_count = 0;
1163 1163
 
1164 1164
 						// Loop through the months
1165 1165
 						$month = $dates['m_start'];
1166 1166
 
1167
-						while ( $month <= $dates['m_end'] ) :
1168
-							$sales_count += give_get_sales_by_date( null, $month, $dates['year'] );
1169
-							$month ++;
1167
+						while ($month <= $dates['m_end']) :
1168
+							$sales_count += give_get_sales_by_date(null, $month, $dates['year']);
1169
+							$month++;
1170 1170
 						endwhile;
1171 1171
 
1172
-						$sales['donations'][ $args['date'] ] = $sales_count;
1172
+						$sales['donations'][$args['date']] = $sales_count;
1173 1173
 					} else {
1174
-						$sales['donations'][ $args['date'] ] = give_get_sales_by_date( $dates['day'], $dates['m_start'], $dates['year'] );
1174
+						$sales['donations'][$args['date']] = give_get_sales_by_date($dates['day'], $dates['m_start'], $dates['year']);
1175 1175
 					}
1176 1176
 				}
1177
-			} elseif ( $args['form'] == 'all' ) {
1178
-				$forms = get_posts( array( 'post_type' => 'give_forms', 'nopaging' => true ) );
1177
+			} elseif ($args['form'] == 'all') {
1178
+				$forms = get_posts(array('post_type' => 'give_forms', 'nopaging' => true));
1179 1179
 				$i     = 0;
1180
-				foreach ( $forms as $form_info ) {
1181
-					$sales['donations'][ $i ] = array( $form_info->post_name => give_get_form_sales_stats( $form_info->ID ) );
1182
-					$i ++;
1180
+				foreach ($forms as $form_info) {
1181
+					$sales['donations'][$i] = array($form_info->post_name => give_get_form_sales_stats($form_info->ID));
1182
+					$i++;
1183 1183
 				}
1184 1184
 			} else {
1185
-				if ( get_post_type( $args['form'] ) == 'give_forms' ) {
1186
-					$form_info             = get_post( $args['form'] );
1187
-					$sales['donations'][0] = array( $form_info->post_name => give_get_form_sales_stats( $args['form'] ) );
1185
+				if (get_post_type($args['form']) == 'give_forms') {
1186
+					$form_info             = get_post($args['form']);
1187
+					$sales['donations'][0] = array($form_info->post_name => give_get_form_sales_stats($args['form']));
1188 1188
 				} else {
1189 1189
 					$error['error'] = sprintf(
1190 1190
 					/* translators: %s: form */
1191
-						esc_html__( 'Form %s not found.', 'give' ),
1191
+						esc_html__('Form %s not found.', 'give'),
1192 1192
 						$args['form']
1193 1193
 					);
1194 1194
 				}
1195 1195
 			}
1196 1196
 
1197
-			if ( ! empty( $error ) ) {
1197
+			if ( ! empty($error)) {
1198 1198
 				return $error;
1199 1199
 			}
1200 1200
 
1201 1201
 			return $sales;
1202 1202
 
1203
-		} elseif ( $args['type'] == 'earnings' ) {
1204
-			if ( $args['form'] == null ) {
1205
-				if ( $args['date'] == null ) {
1203
+		} elseif ($args['type'] == 'earnings') {
1204
+			if ($args['form'] == null) {
1205
+				if ($args['date'] == null) {
1206 1206
 					$earnings = $this->get_default_earnings_stats();
1207
-				} elseif ( $args['date'] === 'range' ) {
1207
+				} elseif ($args['date'] === 'range') {
1208 1208
 					// Return sales for a date range
1209 1209
 					// Ensure the end date is later than the start date
1210
-					if ( $args['enddate'] < $args['startdate'] ) {
1211
-						$error['error'] = esc_html__( 'The end date must be later than the start date.', 'give' );
1210
+					if ($args['enddate'] < $args['startdate']) {
1211
+						$error['error'] = esc_html__('The end date must be later than the start date.', 'give');
1212 1212
 					}
1213 1213
 
1214 1214
 					// Ensure both the start and end date are specified
1215
-					if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) {
1216
-						$error['error'] = esc_html__( 'Invalid or no date range specified.', 'give' );
1215
+					if (empty($args['startdate']) || empty($args['enddate'])) {
1216
+						$error['error'] = esc_html__('Invalid or no date range specified.', 'give');
1217 1217
 					}
1218 1218
 
1219 1219
 					$total = (float) 0.00;
1220 1220
 
1221 1221
 					// Loop through the years
1222 1222
 					$y = $dates['year'];
1223
-					if ( ! isset( $earnings['earnings'] ) ) {
1223
+					if ( ! isset($earnings['earnings'])) {
1224 1224
 						$earnings['earnings'] = array();
1225 1225
 					}
1226
-					while ( $y <= $dates['year_end'] ) :
1226
+					while ($y <= $dates['year_end']) :
1227 1227
 
1228
-						if ( $dates['year'] == $dates['year_end'] ) {
1228
+						if ($dates['year'] == $dates['year_end']) {
1229 1229
 							$month_start = $dates['m_start'];
1230 1230
 							$month_end   = $dates['m_end'];
1231
-						} elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) {
1231
+						} elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) {
1232 1232
 							$month_start = $dates['m_start'];
1233 1233
 							$month_end   = 12;
1234
-						} elseif ( $y == $dates['year_end'] ) {
1234
+						} elseif ($y == $dates['year_end']) {
1235 1235
 							$month_start = 1;
1236 1236
 							$month_end   = $dates['m_end'];
1237 1237
 						} else {
@@ -1240,92 +1240,92 @@  discard block
 block discarded – undo
1240 1240
 						}
1241 1241
 
1242 1242
 						$i = $month_start;
1243
-						while ( $i <= $month_end ) :
1243
+						while ($i <= $month_end) :
1244 1244
 
1245
-							if ( $i == $dates['m_start'] ) {
1245
+							if ($i == $dates['m_start']) {
1246 1246
 								$d = $dates['day_start'];
1247 1247
 							} else {
1248 1248
 								$d = 1;
1249 1249
 							}
1250 1250
 
1251
-							if ( $i == $dates['m_end'] ) {
1251
+							if ($i == $dates['m_end']) {
1252 1252
 								$num_of_days = $dates['day_end'];
1253 1253
 							} else {
1254
-								$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
1254
+								$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
1255 1255
 							}
1256 1256
 
1257
-							while ( $d <= $num_of_days ) :
1258
-								$earnings_stat = give_get_earnings_by_date( $d, $i, $y );
1259
-								$date_key      = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) );
1260
-								if ( ! isset( $earnings['earnings'][ $date_key ] ) ) {
1261
-									$earnings['earnings'][ $date_key ] = 0;
1257
+							while ($d <= $num_of_days) :
1258
+								$earnings_stat = give_get_earnings_by_date($d, $i, $y);
1259
+								$date_key      = date('Ymd', strtotime($y.'/'.$i.'/'.$d));
1260
+								if ( ! isset($earnings['earnings'][$date_key])) {
1261
+									$earnings['earnings'][$date_key] = 0;
1262 1262
 								}
1263
-								$earnings['earnings'][ $date_key ] += $earnings_stat;
1263
+								$earnings['earnings'][$date_key] += $earnings_stat;
1264 1264
 								$total += $earnings_stat;
1265
-								$d ++;
1265
+								$d++;
1266 1266
 							endwhile;
1267 1267
 
1268
-							$i ++;
1268
+							$i++;
1269 1269
 						endwhile;
1270 1270
 
1271
-						$y ++;
1271
+						$y++;
1272 1272
 					endwhile;
1273 1273
 
1274 1274
 					$earnings['totals'] = $total;
1275 1275
 				} else {
1276
-					if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) {
1276
+					if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') {
1277 1277
 						$earnings_count = (float) 0.00;
1278 1278
 
1279 1279
 						// Loop through the months
1280 1280
 						$month = $dates['m_start'];
1281 1281
 
1282
-						while ( $month <= $dates['m_end'] ) :
1283
-							$earnings_count += give_get_earnings_by_date( null, $month, $dates['year'] );
1284
-							$month ++;
1282
+						while ($month <= $dates['m_end']) :
1283
+							$earnings_count += give_get_earnings_by_date(null, $month, $dates['year']);
1284
+							$month++;
1285 1285
 						endwhile;
1286 1286
 
1287
-						$earnings['earnings'][ $args['date'] ] = $earnings_count;
1287
+						$earnings['earnings'][$args['date']] = $earnings_count;
1288 1288
 					} else {
1289
-						$earnings['earnings'][ $args['date'] ] = give_get_earnings_by_date( $dates['day'], $dates['m_start'], $dates['year'] );
1289
+						$earnings['earnings'][$args['date']] = give_get_earnings_by_date($dates['day'], $dates['m_start'], $dates['year']);
1290 1290
 					}
1291 1291
 				}
1292
-			} elseif ( $args['form'] == 'all' ) {
1293
-				$forms = get_posts( array( 'post_type' => 'give_forms', 'nopaging' => true ) );
1292
+			} elseif ($args['form'] == 'all') {
1293
+				$forms = get_posts(array('post_type' => 'give_forms', 'nopaging' => true));
1294 1294
 
1295 1295
 				$i = 0;
1296
-				foreach ( $forms as $form_info ) {
1297
-					$earnings['earnings'][ $i ] = array( $form_info->post_name => give_get_form_earnings_stats( $form_info->ID ) );
1298
-					$i ++;
1296
+				foreach ($forms as $form_info) {
1297
+					$earnings['earnings'][$i] = array($form_info->post_name => give_get_form_earnings_stats($form_info->ID));
1298
+					$i++;
1299 1299
 				}
1300 1300
 			} else {
1301
-				if ( get_post_type( $args['form'] ) == 'give_forms' ) {
1302
-					$form_info               = get_post( $args['form'] );
1303
-					$earnings['earnings'][0] = array( $form_info->post_name => give_get_form_earnings_stats( $args['form'] ) );
1301
+				if (get_post_type($args['form']) == 'give_forms') {
1302
+					$form_info               = get_post($args['form']);
1303
+					$earnings['earnings'][0] = array($form_info->post_name => give_get_form_earnings_stats($args['form']));
1304 1304
 				} else {
1305 1305
 					$error['error'] = sprintf(
1306 1306
 					/* translators: %s: form */
1307
-						esc_html__( 'Form %s not found.', 'give' ),
1307
+						esc_html__('Form %s not found.', 'give'),
1308 1308
 						$args['form']
1309 1309
 					);
1310 1310
 				}
1311 1311
 			}
1312 1312
 
1313
-			if ( ! empty( $error ) ) {
1313
+			if ( ! empty($error)) {
1314 1314
 				return $error;
1315 1315
 			}
1316 1316
 
1317 1317
 			return $earnings;
1318
-		} elseif ( $args['type'] == 'donors' ) {
1318
+		} elseif ($args['type'] == 'donors') {
1319 1319
 			$customers                          = new Give_DB_Customers();
1320 1320
 			$stats['donations']['total_donors'] = $customers->count();
1321 1321
 
1322 1322
 			return $stats;
1323 1323
 
1324
-		} elseif ( empty( $args['type'] ) ) {
1325
-			$stats = array_merge( $stats, $this->get_default_sales_stats() );
1326
-			$stats = array_merge( $stats, $this->get_default_earnings_stats() );
1324
+		} elseif (empty($args['type'])) {
1325
+			$stats = array_merge($stats, $this->get_default_sales_stats());
1326
+			$stats = array_merge($stats, $this->get_default_earnings_stats());
1327 1327
 
1328
-			return array( 'stats' => $stats );
1328
+			return array('stats' => $stats);
1329 1329
 		}
1330 1330
 	}
1331 1331
 
@@ -1341,18 +1341,18 @@  discard block
 block discarded – undo
1341 1341
 
1342 1342
 		$sales = array();
1343 1343
 
1344
-		if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) {
1344
+		if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) {
1345 1345
 			return $sales;
1346 1346
 		}
1347 1347
 
1348
-		if ( isset( $wp_query->query_vars['id'] ) ) {
1348
+		if (isset($wp_query->query_vars['id'])) {
1349 1349
 			$query   = array();
1350
-			$query[] = new Give_Payment( $wp_query->query_vars['id'] );
1351
-		} elseif ( isset( $wp_query->query_vars['purchasekey'] ) ) {
1350
+			$query[] = new Give_Payment($wp_query->query_vars['id']);
1351
+		} elseif (isset($wp_query->query_vars['purchasekey'])) {
1352 1352
 			$query   = array();
1353
-			$query[] = give_get_payment_by( 'key', $wp_query->query_vars['purchasekey'] );
1354
-		} elseif ( isset( $wp_query->query_vars['email'] ) ) {
1355
-			$args  = array(
1353
+			$query[] = give_get_payment_by('key', $wp_query->query_vars['purchasekey']);
1354
+		} elseif (isset($wp_query->query_vars['email'])) {
1355
+			$args = array(
1356 1356
 				'fields'     => 'ids',
1357 1357
 				'meta_key'   => '_give_payment_user_email',
1358 1358
 				'meta_value' => $wp_query->query_vars['email'],
@@ -1360,7 +1360,7 @@  discard block
 block discarded – undo
1360 1360
 				'page'       => $this->get_paged(),
1361 1361
 				'status'     => 'publish',
1362 1362
 			);
1363
-			$query = give_get_payments( $args );
1363
+			$query = give_get_payments($args);
1364 1364
 		} else {
1365 1365
 			$args  = array(
1366 1366
 				'fields' => 'ids',
@@ -1368,14 +1368,14 @@  discard block
 block discarded – undo
1368 1368
 				'page'   => $this->get_paged(),
1369 1369
 				'status' => 'publish',
1370 1370
 			);
1371
-			$query = give_get_payments( $args );
1371
+			$query = give_get_payments($args);
1372 1372
 		}
1373
-		if ( $query ) {
1373
+		if ($query) {
1374 1374
 			$i = 0;
1375
-			foreach ( $query as $payment ) {
1375
+			foreach ($query as $payment) {
1376 1376
 
1377
-				if ( is_numeric( $payment ) ) {
1378
-					$payment      = new Give_Payment( $payment );
1377
+				if (is_numeric($payment)) {
1378
+					$payment      = new Give_Payment($payment);
1379 1379
 					$payment_meta = $payment->get_meta();
1380 1380
 					$user_info    = $payment->user_info;
1381 1381
 				} else {
@@ -1385,40 +1385,40 @@  discard block
 block discarded – undo
1385 1385
 				$payment_meta = $payment->get_meta();
1386 1386
 				$user_info    = $payment->user_info;
1387 1387
 
1388
-				$first_name = isset( $user_info['first_name'] ) ? $user_info['first_name'] : '';
1389
-				$last_name  = isset( $user_info['last_name'] ) ? $user_info['last_name'] : '';
1390
-
1391
-				$sales['donations'][ $i ]['ID']             = $payment->number;
1392
-				$sales['donations'][ $i ]['transaction_id'] = $payment->transaction_id;
1393
-				$sales['donations'][ $i ]['key']            = $payment->key;
1394
-				$sales['donations'][ $i ]['total']          = $payment->total;
1395
-				$sales['donations'][ $i ]['gateway']        = $payment->gateway;
1396
-				$sales['donations'][ $i ]['name']           = $first_name . ' ' . $last_name;
1397
-				$sales['donations'][ $i ]['fname']          = $first_name;
1398
-				$sales['donations'][ $i ]['lname']          = $last_name;
1399
-				$sales['donations'][ $i ]['email']          = $payment->email;
1400
-				$sales['donations'][ $i ]['date']           = $payment->date;
1401
-
1402
-				$form_id  = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : $payment_meta;
1403
-				$price    = isset( $payment_meta['form_id'] ) ? give_get_form_price( $payment_meta['form_id'] ) : false;
1404
-				$price_id = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null;
1405
-
1406
-				$sales['donations'][ $i ]['form']['id']    = $form_id;
1407
-				$sales['donations'][ $i ]['form']['name']  = get_the_title( $payment_meta['form_id'] );
1408
-				$sales['donations'][ $i ]['form']['price'] = $price;
1409
-
1410
-				if ( give_has_variable_prices( $form_id ) ) {
1411
-					if ( isset( $payment_meta['price_id'] ) ) {
1412
-						$price_name                                     = give_get_price_option_name( $form_id, $payment_meta['price_id'], $payment->ID );
1413
-						$sales['donations'][ $i ]['form']['price_name'] = $price_name;
1414
-						$sales['donations'][ $i ]['form']['price_id']   = $price_id;
1415
-						$sales['donations'][ $i ]['form']['price']      = give_get_price_option_amount( $form_id, $price_id );
1388
+				$first_name = isset($user_info['first_name']) ? $user_info['first_name'] : '';
1389
+				$last_name  = isset($user_info['last_name']) ? $user_info['last_name'] : '';
1390
+
1391
+				$sales['donations'][$i]['ID']             = $payment->number;
1392
+				$sales['donations'][$i]['transaction_id'] = $payment->transaction_id;
1393
+				$sales['donations'][$i]['key']            = $payment->key;
1394
+				$sales['donations'][$i]['total']          = $payment->total;
1395
+				$sales['donations'][$i]['gateway']        = $payment->gateway;
1396
+				$sales['donations'][$i]['name']           = $first_name.' '.$last_name;
1397
+				$sales['donations'][$i]['fname']          = $first_name;
1398
+				$sales['donations'][$i]['lname']          = $last_name;
1399
+				$sales['donations'][$i]['email']          = $payment->email;
1400
+				$sales['donations'][$i]['date']           = $payment->date;
1401
+
1402
+				$form_id  = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : $payment_meta;
1403
+				$price    = isset($payment_meta['form_id']) ? give_get_form_price($payment_meta['form_id']) : false;
1404
+				$price_id = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null;
1405
+
1406
+				$sales['donations'][$i]['form']['id']    = $form_id;
1407
+				$sales['donations'][$i]['form']['name']  = get_the_title($payment_meta['form_id']);
1408
+				$sales['donations'][$i]['form']['price'] = $price;
1409
+
1410
+				if (give_has_variable_prices($form_id)) {
1411
+					if (isset($payment_meta['price_id'])) {
1412
+						$price_name                                     = give_get_price_option_name($form_id, $payment_meta['price_id'], $payment->ID);
1413
+						$sales['donations'][$i]['form']['price_name'] = $price_name;
1414
+						$sales['donations'][$i]['form']['price_id']   = $price_id;
1415
+						$sales['donations'][$i]['form']['price']      = give_get_price_option_amount($form_id, $price_id);
1416 1416
 
1417 1417
 					}
1418 1418
 				}
1419 1419
 
1420 1420
 				// Add custom meta to API
1421
-				foreach ( $payment_meta as $meta_key => $meta_value ) {
1421
+				foreach ($payment_meta as $meta_key => $meta_value) {
1422 1422
 
1423 1423
 					$exceptions = array(
1424 1424
 						'form_title',
@@ -1431,19 +1431,19 @@  discard block
 block discarded – undo
1431 1431
 					);
1432 1432
 
1433 1433
 					// Don't clutter up results with dupes
1434
-					if ( in_array( $meta_key, $exceptions ) ) {
1434
+					if (in_array($meta_key, $exceptions)) {
1435 1435
 						continue;
1436 1436
 					}
1437 1437
 
1438
-					$sales['donations'][ $i ]['payment_meta'][ $meta_key ] = $meta_value;
1438
+					$sales['donations'][$i]['payment_meta'][$meta_key] = $meta_value;
1439 1439
 
1440 1440
 				}
1441 1441
 
1442
-				$i ++;
1442
+				$i++;
1443 1443
 			}
1444 1444
 		}
1445 1445
 
1446
-		return apply_filters( 'give_api_donations_endpoint', $sales );
1446
+		return apply_filters('give_api_donations_endpoint', $sales);
1447 1447
 	}
1448 1448
 
1449 1449
 	/**
@@ -1459,9 +1459,9 @@  discard block
 block discarded – undo
1459 1459
 	public function get_output_format() {
1460 1460
 		global $wp_query;
1461 1461
 
1462
-		$format = isset( $wp_query->query_vars['format'] ) ? $wp_query->query_vars['format'] : 'json';
1462
+		$format = isset($wp_query->query_vars['format']) ? $wp_query->query_vars['format'] : 'json';
1463 1463
 
1464
-		return apply_filters( 'give_api_output_format', $format );
1464
+		return apply_filters('give_api_output_format', $format);
1465 1465
 	}
1466 1466
 
1467 1467
 
@@ -1478,8 +1478,8 @@  discard block
 block discarded – undo
1478 1478
 	 *
1479 1479
 	 * @return void
1480 1480
 	 */
1481
-	private function log_request( $data = array() ) {
1482
-		if ( ! $this->log_requests ) {
1481
+	private function log_request($data = array()) {
1482
+		if ( ! $this->log_requests) {
1483 1483
 			return;
1484 1484
 		}
1485 1485
 
@@ -1495,36 +1495,36 @@  discard block
 block discarded – undo
1495 1495
 
1496 1496
 		$query = array(
1497 1497
 			'give-api'    => $wp_query->query_vars['give-api'],
1498
-			'key'         => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null,
1499
-			'token'       => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null,
1500
-			'query'       => isset( $wp_query->query_vars['query'] ) ? $wp_query->query_vars['query'] : null,
1501
-			'type'        => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null,
1502
-			'form'        => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null,
1503
-			'customer'    => isset( $wp_query->query_vars['customer'] ) ? $wp_query->query_vars['customer'] : null,
1504
-			'date'        => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null,
1505
-			'startdate'   => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null,
1506
-			'enddate'     => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null,
1507
-			'id'          => isset( $wp_query->query_vars['id'] ) ? $wp_query->query_vars['id'] : null,
1508
-			'purchasekey' => isset( $wp_query->query_vars['purchasekey'] ) ? $wp_query->query_vars['purchasekey'] : null,
1509
-			'email'       => isset( $wp_query->query_vars['email'] ) ? $wp_query->query_vars['email'] : null,
1498
+			'key'         => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null,
1499
+			'token'       => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null,
1500
+			'query'       => isset($wp_query->query_vars['query']) ? $wp_query->query_vars['query'] : null,
1501
+			'type'        => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null,
1502
+			'form'        => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null,
1503
+			'customer'    => isset($wp_query->query_vars['customer']) ? $wp_query->query_vars['customer'] : null,
1504
+			'date'        => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null,
1505
+			'startdate'   => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null,
1506
+			'enddate'     => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null,
1507
+			'id'          => isset($wp_query->query_vars['id']) ? $wp_query->query_vars['id'] : null,
1508
+			'purchasekey' => isset($wp_query->query_vars['purchasekey']) ? $wp_query->query_vars['purchasekey'] : null,
1509
+			'email'       => isset($wp_query->query_vars['email']) ? $wp_query->query_vars['email'] : null,
1510 1510
 		);
1511 1511
 
1512 1512
 		$log_data = array(
1513 1513
 			'log_type'     => 'api_request',
1514
-			'post_excerpt' => http_build_query( $query ),
1515
-			'post_content' => ! empty( $data['error'] ) ? $data['error'] : '',
1514
+			'post_excerpt' => http_build_query($query),
1515
+			'post_content' => ! empty($data['error']) ? $data['error'] : '',
1516 1516
 		);
1517 1517
 
1518 1518
 		$log_meta = array(
1519 1519
 			'request_ip' => give_get_ip(),
1520 1520
 			'user'       => $this->user_id,
1521
-			'key'        => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null,
1522
-			'token'      => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null,
1521
+			'key'        => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null,
1522
+			'token'      => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null,
1523 1523
 			'time'       => $data['request_speed'],
1524 1524
 			'version'    => $this->get_queried_version(),
1525 1525
 		);
1526 1526
 
1527
-		$give_logs->insert_log( $log_data, $log_meta );
1527
+		$give_logs->insert_log($log_data, $log_meta);
1528 1528
 	}
1529 1529
 
1530 1530
 
@@ -1548,7 +1548,7 @@  discard block
 block discarded – undo
1548 1548
 	 *
1549 1549
 	 * @param int       $status_code
1550 1550
 	 */
1551
-	public function output( $status_code = 200 ) {
1551
+	public function output($status_code = 200) {
1552 1552
 		/**
1553 1553
 		 * @var WP_Query $wp_query
1554 1554
 		 */
@@ -1556,7 +1556,7 @@  discard block
 block discarded – undo
1556 1556
 
1557 1557
 		$format = $this->get_output_format();
1558 1558
 
1559
-		status_header( $status_code );
1559
+		status_header($status_code);
1560 1560
 
1561 1561
 		/**
1562 1562
 		 * Fires before outputing the API.
@@ -1567,25 +1567,25 @@  discard block
 block discarded – undo
1567 1567
 		 * @param Give_API $this   The Give_API object.
1568 1568
 		 * @param string   $format Output format, XML or JSON. Default is JSON.
1569 1569
 		 */
1570
-		do_action( 'give_api_output_before', $this->data, $this, $format );
1570
+		do_action('give_api_output_before', $this->data, $this, $format);
1571 1571
 
1572
-		switch ( $format ) :
1572
+		switch ($format) :
1573 1573
 
1574 1574
 			case 'xml' :
1575 1575
 
1576
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/array2xml.php';
1577
-				$xml = Array2XML::createXML( 'give', $this->data );
1576
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/array2xml.php';
1577
+				$xml = Array2XML::createXML('give', $this->data);
1578 1578
 				echo $xml->saveXML();
1579 1579
 
1580 1580
 				break;
1581 1581
 
1582 1582
 			case 'json' :
1583 1583
 
1584
-				header( 'Content-Type: application/json' );
1585
-				if ( ! empty( $this->pretty_print ) ) {
1586
-					echo json_encode( $this->data, $this->pretty_print );
1584
+				header('Content-Type: application/json');
1585
+				if ( ! empty($this->pretty_print)) {
1586
+					echo json_encode($this->data, $this->pretty_print);
1587 1587
 				} else {
1588
-					echo json_encode( $this->data );
1588
+					echo json_encode($this->data);
1589 1589
 				}
1590 1590
 
1591 1591
 				break;
@@ -1600,7 +1600,7 @@  discard block
 block discarded – undo
1600 1600
 				 * @param array    $data Response data to return.
1601 1601
 				 * @param Give_API $this The Give_API object.
1602 1602
 				 */
1603
-				do_action( "give_api_output_{$format}", $this->data, $this );
1603
+				do_action("give_api_output_{$format}", $this->data, $this);
1604 1604
 
1605 1605
 				break;
1606 1606
 
@@ -1615,7 +1615,7 @@  discard block
 block discarded – undo
1615 1615
 		 * @param Give_API $this   The Give_API object.
1616 1616
 		 * @param string   $format Output format, XML or JSON. Default is JSON.
1617 1617
 		 */
1618
-		do_action( 'give_api_output_after', $this->data, $this, $format );
1618
+		do_action('give_api_output_after', $this->data, $this, $format);
1619 1619
 
1620 1620
 		give_die();
1621 1621
 	}
@@ -1632,40 +1632,40 @@  discard block
 block discarded – undo
1632 1632
 	 *
1633 1633
 	 * @return void
1634 1634
 	 */
1635
-	function user_key_field( $user ) {
1635
+	function user_key_field($user) {
1636 1636
 
1637
-		if ( ( give_get_option( 'api_allow_user_keys', false ) || current_user_can( 'manage_give_settings' ) ) && current_user_can( 'edit_user', $user->ID ) ) {
1638
-			$user = get_userdata( $user->ID );
1637
+		if ((give_get_option('api_allow_user_keys', false) || current_user_can('manage_give_settings')) && current_user_can('edit_user', $user->ID)) {
1638
+			$user = get_userdata($user->ID);
1639 1639
 			?>
1640 1640
 			<table class="form-table">
1641 1641
 				<tbody>
1642 1642
 					<tr>
1643 1643
 						<th>
1644
-							<?php esc_html_e( 'Give API Keys', 'give' ); ?>
1644
+							<?php esc_html_e('Give API Keys', 'give'); ?>
1645 1645
 						</th>
1646 1646
 						<td>
1647 1647
 							<?php
1648
-							$public_key = $this->get_user_public_key( $user->ID );
1649
-							$secret_key = $this->get_user_secret_key( $user->ID );
1648
+							$public_key = $this->get_user_public_key($user->ID);
1649
+							$secret_key = $this->get_user_secret_key($user->ID);
1650 1650
 							?>
1651
-							<?php if ( empty( $user->give_user_public_key ) ) { ?>
1651
+							<?php if (empty($user->give_user_public_key)) { ?>
1652 1652
 								<input name="give_set_api_key" type="checkbox" id="give_set_api_key" value="0"/>
1653
-								<span class="description"><?php esc_html_e( 'Generate API Key', 'give' ); ?></span>
1653
+								<span class="description"><?php esc_html_e('Generate API Key', 'give'); ?></span>
1654 1654
 							<?php } else { ?>
1655
-								<strong style="display:inline-block; width: 125px;"><?php esc_html_e( 'Public key:', 'give' ); ?>
1655
+								<strong style="display:inline-block; width: 125px;"><?php esc_html_e('Public key:', 'give'); ?>
1656 1656
 									&nbsp;</strong>
1657
-								<input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr( $public_key ); ?>"/>
1657
+								<input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr($public_key); ?>"/>
1658 1658
 								<br/>
1659
-								<strong style="display:inline-block; width: 125px;"><?php esc_html_e( 'Secret key:', 'give' ); ?>
1659
+								<strong style="display:inline-block; width: 125px;"><?php esc_html_e('Secret key:', 'give'); ?>
1660 1660
 									&nbsp;</strong>
1661
-								<input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr( $secret_key ); ?>"/>
1661
+								<input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr($secret_key); ?>"/>
1662 1662
 								<br/>
1663
-								<strong style="display:inline-block; width: 125px;"><?php esc_html_e( 'Token:', 'give' ); ?>
1663
+								<strong style="display:inline-block; width: 125px;"><?php esc_html_e('Token:', 'give'); ?>
1664 1664
 									&nbsp;</strong>
1665
-								<input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr( $this->get_token( $user->ID ) ); ?>"/>
1665
+								<input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr($this->get_token($user->ID)); ?>"/>
1666 1666
 								<br/>
1667 1667
 								<input name="give_set_api_key" type="checkbox" id="give_set_api_key" value="0"/>
1668
-								<span class="description"><label for="give_set_api_key"><?php esc_html_e( 'Revoke API Keys', 'give' ); ?></label></span>
1668
+								<span class="description"><label for="give_set_api_key"><?php esc_html_e('Revoke API Keys', 'give'); ?></label></span>
1669 1669
 							<?php } ?>
1670 1670
 						</td>
1671 1671
 					</tr>
@@ -1684,69 +1684,69 @@  discard block
 block discarded – undo
1684 1684
 	 *
1685 1685
 	 * @return void
1686 1686
 	 */
1687
-	public function process_api_key( $args ) {
1687
+	public function process_api_key($args) {
1688 1688
 
1689
-		if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'give-api-nonce' ) ) {
1689
+		if ( ! wp_verify_nonce($_REQUEST['_wpnonce'], 'give-api-nonce')) {
1690 1690
 
1691
-			wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
1691
+			wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
1692 1692
 
1693 1693
 		}
1694 1694
 
1695
-		if ( empty( $args['user_id'] ) ) {
1696
-			wp_die( esc_html__( 'User ID Required.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 401 ) );
1695
+		if (empty($args['user_id'])) {
1696
+			wp_die(esc_html__('User ID Required.', 'give'), esc_html__('Error', 'give'), array('response' => 401));
1697 1697
 		}
1698 1698
 
1699
-		if ( is_numeric( $args['user_id'] ) ) {
1700
-			$user_id = isset( $args['user_id'] ) ? absint( $args['user_id'] ) : get_current_user_id();
1699
+		if (is_numeric($args['user_id'])) {
1700
+			$user_id = isset($args['user_id']) ? absint($args['user_id']) : get_current_user_id();
1701 1701
 		} else {
1702
-			$userdata = get_user_by( 'login', $args['user_id'] );
1702
+			$userdata = get_user_by('login', $args['user_id']);
1703 1703
 			$user_id  = $userdata->ID;
1704 1704
 		}
1705
-		$process = isset( $args['give_api_process'] ) ? strtolower( $args['give_api_process'] ) : false;
1705
+		$process = isset($args['give_api_process']) ? strtolower($args['give_api_process']) : false;
1706 1706
 
1707
-		if ( $user_id == get_current_user_id() && ! give_get_option( 'allow_user_api_keys' ) && ! current_user_can( 'manage_give_settings' ) ) {
1707
+		if ($user_id == get_current_user_id() && ! give_get_option('allow_user_api_keys') && ! current_user_can('manage_give_settings')) {
1708 1708
 			wp_die(
1709 1709
 				sprintf(
1710 1710
 				/* translators: %s: process */
1711
-					esc_html__( 'You do not have permission to %s API keys for this user.', 'give' ),
1711
+					esc_html__('You do not have permission to %s API keys for this user.', 'give'),
1712 1712
 					$process
1713 1713
 				),
1714
-				esc_html__( 'Error', 'give' ),
1715
-				array( 'response' => 403 )
1714
+				esc_html__('Error', 'give'),
1715
+				array('response' => 403)
1716 1716
 			);
1717
-		} elseif ( ! current_user_can( 'manage_give_settings' ) ) {
1717
+		} elseif ( ! current_user_can('manage_give_settings')) {
1718 1718
 			wp_die(
1719 1719
 				sprintf(
1720 1720
 				/* translators: %s: process */
1721
-					esc_html__( 'You do not have permission to %s API keys for this user.', 'give' ),
1721
+					esc_html__('You do not have permission to %s API keys for this user.', 'give'),
1722 1722
 					$process
1723 1723
 				),
1724
-				esc_html__( 'Error', 'give' ),
1725
-				array( 'response' => 403 )
1724
+				esc_html__('Error', 'give'),
1725
+				array('response' => 403)
1726 1726
 			);
1727 1727
 		}
1728 1728
 
1729
-		switch ( $process ) {
1729
+		switch ($process) {
1730 1730
 			case 'generate':
1731
-				if ( $this->generate_api_key( $user_id ) ) {
1732
-					delete_transient( 'give_total_api_keys' );
1733
-					wp_redirect( add_query_arg( 'give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) );
1731
+				if ($this->generate_api_key($user_id)) {
1732
+					delete_transient('give_total_api_keys');
1733
+					wp_redirect(add_query_arg('give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-tools&tab=api'));
1734 1734
 					exit();
1735 1735
 				} else {
1736
-					wp_redirect( add_query_arg( 'give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) );
1736
+					wp_redirect(add_query_arg('give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-tools&tab=api'));
1737 1737
 					exit();
1738 1738
 				}
1739 1739
 				break;
1740 1740
 			case 'regenerate':
1741
-				$this->generate_api_key( $user_id, true );
1742
-				delete_transient( 'give_total_api_keys' );
1743
-				wp_redirect( add_query_arg( 'give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) );
1741
+				$this->generate_api_key($user_id, true);
1742
+				delete_transient('give_total_api_keys');
1743
+				wp_redirect(add_query_arg('give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-tools&tab=api'));
1744 1744
 				exit();
1745 1745
 				break;
1746 1746
 			case 'revoke':
1747
-				$this->revoke_api_key( $user_id );
1748
-				delete_transient( 'give_total_api_keys' );
1749
-				wp_redirect( add_query_arg( 'give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) );
1747
+				$this->revoke_api_key($user_id);
1748
+				delete_transient('give_total_api_keys');
1749
+				wp_redirect(add_query_arg('give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-tools&tab=api'));
1750 1750
 				exit();
1751 1751
 				break;
1752 1752
 			default;
@@ -1765,34 +1765,34 @@  discard block
 block discarded – undo
1765 1765
 	 *
1766 1766
 	 * @return boolean True if (re)generated succesfully, false otherwise.
1767 1767
 	 */
1768
-	public function generate_api_key( $user_id = 0, $regenerate = false ) {
1768
+	public function generate_api_key($user_id = 0, $regenerate = false) {
1769 1769
 
1770
-		if ( empty( $user_id ) ) {
1770
+		if (empty($user_id)) {
1771 1771
 			return false;
1772 1772
 		}
1773 1773
 
1774
-		$user = get_userdata( $user_id );
1774
+		$user = get_userdata($user_id);
1775 1775
 
1776
-		if ( ! $user ) {
1776
+		if ( ! $user) {
1777 1777
 			return false;
1778 1778
 		}
1779 1779
 
1780
-		$public_key = $this->get_user_public_key( $user_id );
1781
-		$secret_key = $this->get_user_secret_key( $user_id );
1780
+		$public_key = $this->get_user_public_key($user_id);
1781
+		$secret_key = $this->get_user_secret_key($user_id);
1782 1782
 
1783
-		if ( empty( $public_key ) || $regenerate == true ) {
1784
-			$new_public_key = $this->generate_public_key( $user->user_email );
1785
-			$new_secret_key = $this->generate_private_key( $user->ID );
1783
+		if (empty($public_key) || $regenerate == true) {
1784
+			$new_public_key = $this->generate_public_key($user->user_email);
1785
+			$new_secret_key = $this->generate_private_key($user->ID);
1786 1786
 		} else {
1787 1787
 			return false;
1788 1788
 		}
1789 1789
 
1790
-		if ( $regenerate == true ) {
1791
-			$this->revoke_api_key( $user->ID );
1790
+		if ($regenerate == true) {
1791
+			$this->revoke_api_key($user->ID);
1792 1792
 		}
1793 1793
 
1794
-		update_user_meta( $user_id, $new_public_key, 'give_user_public_key' );
1795
-		update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' );
1794
+		update_user_meta($user_id, $new_public_key, 'give_user_public_key');
1795
+		update_user_meta($user_id, $new_secret_key, 'give_user_secret_key');
1796 1796
 
1797 1797
 		return true;
1798 1798
 	}
@@ -1807,26 +1807,26 @@  discard block
 block discarded – undo
1807 1807
 	 *
1808 1808
 	 * @return bool
1809 1809
 	 */
1810
-	public function revoke_api_key( $user_id = 0 ) {
1810
+	public function revoke_api_key($user_id = 0) {
1811 1811
 
1812
-		if ( empty( $user_id ) ) {
1812
+		if (empty($user_id)) {
1813 1813
 			return false;
1814 1814
 		}
1815 1815
 
1816
-		$user = get_userdata( $user_id );
1816
+		$user = get_userdata($user_id);
1817 1817
 
1818
-		if ( ! $user ) {
1818
+		if ( ! $user) {
1819 1819
 			return false;
1820 1820
 		}
1821 1821
 
1822
-		$public_key = $this->get_user_public_key( $user_id );
1823
-		$secret_key = $this->get_user_secret_key( $user_id );
1824
-		if ( ! empty( $public_key ) ) {
1825
-			delete_transient( md5( 'give_api_user_' . $public_key ) );
1826
-			delete_transient( md5( 'give_api_user_public_key' . $user_id ) );
1827
-			delete_transient( md5( 'give_api_user_secret_key' . $user_id ) );
1828
-			delete_user_meta( $user_id, $public_key );
1829
-			delete_user_meta( $user_id, $secret_key );
1822
+		$public_key = $this->get_user_public_key($user_id);
1823
+		$secret_key = $this->get_user_secret_key($user_id);
1824
+		if ( ! empty($public_key)) {
1825
+			delete_transient(md5('give_api_user_'.$public_key));
1826
+			delete_transient(md5('give_api_user_public_key'.$user_id));
1827
+			delete_transient(md5('give_api_user_secret_key'.$user_id));
1828
+			delete_user_meta($user_id, $public_key);
1829
+			delete_user_meta($user_id, $secret_key);
1830 1830
 		} else {
1831 1831
 			return false;
1832 1832
 		}
@@ -1851,22 +1851,22 @@  discard block
 block discarded – undo
1851 1851
 	 *
1852 1852
 	 * @return void
1853 1853
 	 */
1854
-	public function update_key( $user_id ) {
1855
-		if ( current_user_can( 'edit_user', $user_id ) && isset( $_POST['give_set_api_key'] ) ) {
1854
+	public function update_key($user_id) {
1855
+		if (current_user_can('edit_user', $user_id) && isset($_POST['give_set_api_key'])) {
1856 1856
 
1857
-			$user = get_userdata( $user_id );
1857
+			$user = get_userdata($user_id);
1858 1858
 
1859
-			$public_key = $this->get_user_public_key( $user_id );
1860
-			$secret_key = $this->get_user_secret_key( $user_id );
1859
+			$public_key = $this->get_user_public_key($user_id);
1860
+			$secret_key = $this->get_user_secret_key($user_id);
1861 1861
 
1862
-			if ( empty( $public_key ) ) {
1863
-				$new_public_key = $this->generate_public_key( $user->user_email );
1864
-				$new_secret_key = $this->generate_private_key( $user->ID );
1862
+			if (empty($public_key)) {
1863
+				$new_public_key = $this->generate_public_key($user->user_email);
1864
+				$new_secret_key = $this->generate_private_key($user->ID);
1865 1865
 
1866
-				update_user_meta( $user_id, $new_public_key, 'give_user_public_key' );
1867
-				update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' );
1866
+				update_user_meta($user_id, $new_public_key, 'give_user_public_key');
1867
+				update_user_meta($user_id, $new_secret_key, 'give_user_secret_key');
1868 1868
 			} else {
1869
-				$this->revoke_api_key( $user_id );
1869
+				$this->revoke_api_key($user_id);
1870 1870
 			}
1871 1871
 		}
1872 1872
 	}
@@ -1881,9 +1881,9 @@  discard block
 block discarded – undo
1881 1881
 	 *
1882 1882
 	 * @return string
1883 1883
 	 */
1884
-	private function generate_public_key( $user_email = '' ) {
1885
-		$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
1886
-		$public   = hash( 'md5', $user_email . $auth_key . date( 'U' ) );
1884
+	private function generate_public_key($user_email = '') {
1885
+		$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
1886
+		$public   = hash('md5', $user_email.$auth_key.date('U'));
1887 1887
 
1888 1888
 		return $public;
1889 1889
 	}
@@ -1898,9 +1898,9 @@  discard block
 block discarded – undo
1898 1898
 	 *
1899 1899
 	 * @return string
1900 1900
 	 */
1901
-	private function generate_private_key( $user_id = 0 ) {
1902
-		$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
1903
-		$secret   = hash( 'md5', $user_id . $auth_key . date( 'U' ) );
1901
+	private function generate_private_key($user_id = 0) {
1902
+		$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
1903
+		$secret   = hash('md5', $user_id.$auth_key.date('U'));
1904 1904
 
1905 1905
 		return $secret;
1906 1906
 	}
@@ -1915,8 +1915,8 @@  discard block
 block discarded – undo
1915 1915
 	 *
1916 1916
 	 * @return string
1917 1917
 	 */
1918
-	public function get_token( $user_id = 0 ) {
1919
-		return hash( 'md5', $this->get_user_secret_key( $user_id ) . $this->get_user_public_key( $user_id ) );
1918
+	public function get_token($user_id = 0) {
1919
+		return hash('md5', $this->get_user_secret_key($user_id).$this->get_user_public_key($user_id));
1920 1920
 	}
1921 1921
 
1922 1922
 	/**
@@ -1930,9 +1930,9 @@  discard block
 block discarded – undo
1930 1930
 
1931 1931
 		// Default sales return
1932 1932
 		$sales                               = array();
1933
-		$sales['donations']['today']         = $this->stats->get_sales( 0, 'today' );
1934
-		$sales['donations']['current_month'] = $this->stats->get_sales( 0, 'this_month' );
1935
-		$sales['donations']['last_month']    = $this->stats->get_sales( 0, 'last_month' );
1933
+		$sales['donations']['today']         = $this->stats->get_sales(0, 'today');
1934
+		$sales['donations']['current_month'] = $this->stats->get_sales(0, 'this_month');
1935
+		$sales['donations']['last_month']    = $this->stats->get_sales(0, 'last_month');
1936 1936
 		$sales['donations']['totals']        = give_get_total_sales();
1937 1937
 
1938 1938
 		return $sales;
@@ -1949,9 +1949,9 @@  discard block
 block discarded – undo
1949 1949
 
1950 1950
 		// Default earnings return
1951 1951
 		$earnings                              = array();
1952
-		$earnings['earnings']['today']         = $this->stats->get_earnings( 0, 'today' );
1953
-		$earnings['earnings']['current_month'] = $this->stats->get_earnings( 0, 'this_month' );
1954
-		$earnings['earnings']['last_month']    = $this->stats->get_earnings( 0, 'last_month' );
1952
+		$earnings['earnings']['today']         = $this->stats->get_earnings(0, 'today');
1953
+		$earnings['earnings']['current_month'] = $this->stats->get_earnings(0, 'this_month');
1954
+		$earnings['earnings']['last_month']    = $this->stats->get_earnings(0, 'last_month');
1955 1955
 		$earnings['earnings']['totals']        = give_get_total_earnings();
1956 1956
 
1957 1957
 		return $earnings;
@@ -1971,25 +1971,25 @@  discard block
 block discarded – undo
1971 1971
 	 *
1972 1972
 	 * @return string            The API key/secret for the user supplied
1973 1973
 	 */
1974
-	public function api_key_backwards_compat( $check, $object_id, $meta_key, $single ) {
1974
+	public function api_key_backwards_compat($check, $object_id, $meta_key, $single) {
1975 1975
 
1976
-		if ( $meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key' ) {
1976
+		if ($meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key') {
1977 1977
 			return $check;
1978 1978
 		}
1979 1979
 
1980 1980
 		$return = $check;
1981 1981
 
1982
-		switch ( $meta_key ) {
1982
+		switch ($meta_key) {
1983 1983
 			case 'give_user_public_key':
1984
-				$return = Give()->api->get_user_public_key( $object_id );
1984
+				$return = Give()->api->get_user_public_key($object_id);
1985 1985
 				break;
1986 1986
 			case 'give_user_secret_key':
1987
-				$return = Give()->api->get_user_secret_key( $object_id );
1987
+				$return = Give()->api->get_user_secret_key($object_id);
1988 1988
 				break;
1989 1989
 		}
1990 1990
 
1991
-		if ( ! $single ) {
1992
-			$return = array( $return );
1991
+		if ( ! $single) {
1992
+			$return = array($return);
1993 1993
 		}
1994 1994
 
1995 1995
 		return $return;
Please login to merge, or discard this patch.
includes/gateways/paypal-standard.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
  *
566 566
  * @since 1.6.3
567 567
  *
568
- * @param $pending_reason
568
+ * @param string $pending_reason
569 569
  *
570 570
  * @return string
571 571
  */
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
  * @param int   $payment_id   Payment ID
643 643
  * @param array $payment_data Array of payment data.
644 644
  *
645
- * @return mixed|string
645
+ * @return string
646 646
  */
647 647
 function give_build_paypal_url( $payment_id, $payment_data ) {
648 648
 	// Only send to PayPal if the pending payment is created successfully.
Please login to merge, or discard this patch.
Spacing   +164 added lines, -164 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,34 +32,34 @@  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 37
 	// Validate nonce.
38
-	give_validate_nonce( $payment_data['gateway_nonce'], 'give-gateway' );
39
-	$payment_id = give_create_payment( $payment_data );
38
+	give_validate_nonce($payment_data['gateway_nonce'], 'give-gateway');
39
+	$payment_id = give_create_payment($payment_data);
40 40
 
41 41
 	// Check payment.
42
-	if ( empty( $payment_id ) ) {
42
+	if (empty($payment_id)) {
43 43
 		// Record the error.
44 44
 		give_record_gateway_error(
45
-			esc_html__( 'Payment Error', 'give' ),
45
+			esc_html__('Payment Error', 'give'),
46 46
 			sprintf(
47 47
 				/* translators: %s: payment data */
48
-				esc_html__( 'Payment creation failed before sending donor to PayPal. Payment data: %s', 'give' ),
49
-				json_encode( $payment_data )
48
+				esc_html__('Payment creation failed before sending donor to PayPal. Payment data: %s', 'give'),
49
+				json_encode($payment_data)
50 50
 			),
51 51
 			$payment_id
52 52
 		);
53 53
 		// Problems? Send back.
54
-		give_send_back_to_checkout( '?payment-mode=' . $payment_data['post_data']['give-gateway'] );
54
+		give_send_back_to_checkout('?payment-mode='.$payment_data['post_data']['give-gateway']);
55 55
 	}
56 56
 
57 57
 	// Redirect to PayPal.
58
-	wp_redirect( give_build_paypal_url( $payment_id, $payment_data ) );
58
+	wp_redirect(give_build_paypal_url($payment_id, $payment_data));
59 59
 	exit;
60 60
 }
61 61
 
62
-add_action( 'give_gateway_paypal', 'give_process_paypal_payment' );
62
+add_action('give_gateway_paypal', 'give_process_paypal_payment');
63 63
 
64 64
 /**
65 65
  * Listens for a PayPal IPN requests and then sends to the processing function
@@ -69,17 +69,17 @@  discard block
 block discarded – undo
69 69
  */
70 70
 function give_listen_for_paypal_ipn() {
71 71
 	// Regular PayPal IPN
72
-	if ( isset( $_GET['give-listener'] ) && $_GET['give-listener'] == 'IPN' ) {
72
+	if (isset($_GET['give-listener']) && $_GET['give-listener'] == 'IPN') {
73 73
 		/**
74 74
 		 * Fires while verifying PayPal IPN
75 75
 		 *
76 76
 		 * @since 1.0
77 77
 		 */
78
-		do_action( 'give_verify_paypal_ipn' );
78
+		do_action('give_verify_paypal_ipn');
79 79
 	}
80 80
 }
81 81
 
82
-add_action( 'init', 'give_listen_for_paypal_ipn' );
82
+add_action('init', 'give_listen_for_paypal_ipn');
83 83
 
84 84
 /**
85 85
  * Process PayPal IPN
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 function give_process_paypal_ipn() {
91 91
 
92 92
 	// Check the request method is POST
93
-	if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) {
93
+	if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') {
94 94
 		return;
95 95
 	}
96 96
 
@@ -98,11 +98,11 @@  discard block
 block discarded – undo
98 98
 	$post_data = '';
99 99
 
100 100
 	// Fallback just in case post_max_size is lower than needed
101
-	if ( ini_get( 'allow_url_fopen' ) ) {
102
-		$post_data = file_get_contents( 'php://input' );
101
+	if (ini_get('allow_url_fopen')) {
102
+		$post_data = file_get_contents('php://input');
103 103
 	} else {
104 104
 		// If allow_url_fopen is not enabled, then make sure that post_max_size is large enough
105
-		ini_set( 'post_max_size', '12M' );
105
+		ini_set('post_max_size', '12M');
106 106
 	}
107 107
 	// Start the encoded data collection with notification command
108 108
 	$encoded_data = 'cmd=_notify-validate';
@@ -111,39 +111,39 @@  discard block
 block discarded – undo
111 111
 	$arg_separator = give_get_php_arg_separator_output();
112 112
 
113 113
 	// Verify there is a post_data
114
-	if ( $post_data || strlen( $post_data ) > 0 ) {
114
+	if ($post_data || strlen($post_data) > 0) {
115 115
 		// Append the data
116
-		$encoded_data .= $arg_separator . $post_data;
116
+		$encoded_data .= $arg_separator.$post_data;
117 117
 	} else {
118 118
 		// Check if POST is empty
119
-		if ( empty( $_POST ) ) {
119
+		if (empty($_POST)) {
120 120
 			// Nothing to do
121 121
 			return;
122 122
 		} else {
123 123
 			// Loop through each POST
124
-			foreach ( $_POST as $key => $value ) {
124
+			foreach ($_POST as $key => $value) {
125 125
 				// Encode the value and append the data.
126
-				$encoded_data .= $arg_separator . "$key=" . urlencode( $value );
126
+				$encoded_data .= $arg_separator."$key=".urlencode($value);
127 127
 			}
128 128
 		}
129 129
 	}
130 130
 
131 131
 	// Convert collected post data to an array.
132
-	parse_str( $encoded_data, $encoded_data_array );
132
+	parse_str($encoded_data, $encoded_data_array);
133 133
 
134
-	foreach ( $encoded_data_array as $key => $value ) {
134
+	foreach ($encoded_data_array as $key => $value) {
135 135
 
136
-		if ( false !== strpos( $key, 'amp;' ) ) {
137
-			$new_key = str_replace( '&amp;', '&', $key );
138
-			$new_key = str_replace( 'amp;', '&', $new_key );
136
+		if (false !== strpos($key, 'amp;')) {
137
+			$new_key = str_replace('&amp;', '&', $key);
138
+			$new_key = str_replace('amp;', '&', $new_key);
139 139
 
140
-			unset( $encoded_data_array[ $key ] );
141
-			$encoded_data_array[ $new_key ] = $value;
140
+			unset($encoded_data_array[$key]);
141
+			$encoded_data_array[$new_key] = $value;
142 142
 		}
143 143
 	}
144 144
 
145 145
 	// Validate IPN request w/ PayPal if user hasn't disabled this security measure
146
-	if ( give_is_setting_enabled( give_get_option( 'paypal_verification' ) ) ) {
146
+	if (give_is_setting_enabled(give_get_option('paypal_verification'))) {
147 147
 
148 148
 		$remote_post_vars = array(
149 149
 			'method'      => 'POST',
@@ -163,28 +163,28 @@  discard block
 block discarded – undo
163 163
 		);
164 164
 
165 165
 		// Validate the IPN.
166
-		$api_response = wp_remote_post( give_get_paypal_redirect(), $remote_post_vars );
166
+		$api_response = wp_remote_post(give_get_paypal_redirect(), $remote_post_vars);
167 167
 
168
-		if ( is_wp_error( $api_response ) ) {
168
+		if (is_wp_error($api_response)) {
169 169
 			give_record_gateway_error(
170
-				esc_html__( 'IPN Error', 'give' ),
170
+				esc_html__('IPN Error', 'give'),
171 171
 				sprintf(
172 172
 					/* translators: %s: Paypal IPN response */
173
-					esc_html__( 'Invalid IPN verification response. IPN data: %s', 'give' ),
174
-					json_encode( $api_response )
173
+					esc_html__('Invalid IPN verification response. IPN data: %s', 'give'),
174
+					json_encode($api_response)
175 175
 				)
176 176
 			);
177 177
 
178 178
 			return; // Something went wrong
179 179
 		}
180 180
 
181
-		if ( $api_response['body'] !== 'VERIFIED' ) {
181
+		if ($api_response['body'] !== 'VERIFIED') {
182 182
 			give_record_gateway_error(
183
-				esc_html__( 'IPN Error', 'give' ),
183
+				esc_html__('IPN Error', 'give'),
184 184
 				sprintf(
185 185
 					/* translators: %s: Paypal IPN response */
186
-					esc_html__( 'Invalid IPN verification response. IPN data: %s', 'give' ),
187
-					json_encode( $api_response )
186
+					esc_html__('Invalid IPN verification response. IPN data: %s', 'give'),
187
+					json_encode($api_response)
188 188
 				)
189 189
 			);
190 190
 
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 	}
194 194
 
195 195
 	// Check if $post_data_array has been populated
196
-	if ( ! is_array( $encoded_data_array ) && ! empty( $encoded_data_array ) ) {
196
+	if ( ! is_array($encoded_data_array) && ! empty($encoded_data_array)) {
197 197
 		return;
198 198
 	}
199 199
 
@@ -202,12 +202,12 @@  discard block
 block discarded – undo
202 202
 		'payment_status' => '',
203 203
 	);
204 204
 
205
-	$encoded_data_array = wp_parse_args( $encoded_data_array, $defaults );
205
+	$encoded_data_array = wp_parse_args($encoded_data_array, $defaults);
206 206
 
207
-	$payment_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0;
207
+	$payment_id = isset($encoded_data_array['custom']) ? absint($encoded_data_array['custom']) : 0;
208 208
 	$txn_type   = $encoded_data_array['txn_type'];
209 209
 
210
-	if ( has_action( 'give_paypal_' . $txn_type ) ) {
210
+	if (has_action('give_paypal_'.$txn_type)) {
211 211
 		/**
212 212
 		 * Fires while processing PayPal IPN $txn_type.
213 213
 		 *
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 		 * @param array $encoded_data_array Encoded data.
219 219
 		 * @param int   $payment_id         Payment id.
220 220
 		 */
221
-		do_action( "give_paypal_{$txn_type}", $encoded_data_array, $payment_id );
221
+		do_action("give_paypal_{$txn_type}", $encoded_data_array, $payment_id);
222 222
 	} else {
223 223
 		/**
224 224
 		 * Fires while process PayPal IPN.
@@ -230,12 +230,12 @@  discard block
 block discarded – undo
230 230
 		 * @param array $encoded_data_array Encoded data.
231 231
 		 * @param int   $payment_id         Payment id.
232 232
 		 */
233
-		do_action( 'give_paypal_web_accept', $encoded_data_array, $payment_id );
233
+		do_action('give_paypal_web_accept', $encoded_data_array, $payment_id);
234 234
 	}
235 235
 	exit;
236 236
 }
237 237
 
238
-add_action( 'give_verify_paypal_ipn', 'give_process_paypal_ipn' );
238
+add_action('give_verify_paypal_ipn', 'give_process_paypal_ipn');
239 239
 
240 240
 /**
241 241
  * Process web accept (one time) payment IPNs.
@@ -247,128 +247,128 @@  discard block
 block discarded – undo
247 247
  *
248 248
  * @return void
249 249
  */
250
-function give_process_paypal_web_accept_and_cart( $data, $payment_id ) {
250
+function give_process_paypal_web_accept_and_cart($data, $payment_id) {
251 251
 
252 252
 	// Only allow through these transaction types.
253
-	if ( $data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && strtolower( $data['payment_status'] ) != 'refunded' ) {
253
+	if ($data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && strtolower($data['payment_status']) != 'refunded') {
254 254
 		return;
255 255
 	}
256 256
 
257 257
 	// Need $payment_id to continue.
258
-	if ( empty( $payment_id ) ) {
258
+	if (empty($payment_id)) {
259 259
 		return;
260 260
 	}
261 261
 
262 262
 	// Collect donation payment details.
263 263
 	$paypal_amount  = $data['mc_gross'];
264
-	$payment_status = strtolower( $data['payment_status'] );
265
-	$currency_code  = strtolower( $data['mc_currency'] );
266
-	$business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] );
267
-	$payment_meta   = give_get_payment_meta( $payment_id );
264
+	$payment_status = strtolower($data['payment_status']);
265
+	$currency_code  = strtolower($data['mc_currency']);
266
+	$business_email = isset($data['business']) && is_email($data['business']) ? trim($data['business']) : trim($data['receiver_email']);
267
+	$payment_meta   = give_get_payment_meta($payment_id);
268 268
 
269 269
 	// Must be a PayPal standard IPN.
270
-	if ( give_get_payment_gateway( $payment_id ) != 'paypal' ) {
270
+	if (give_get_payment_gateway($payment_id) != 'paypal') {
271 271
 		return;
272 272
 	}
273 273
 
274 274
 	// Verify payment recipient
275
-	if ( strcasecmp( $business_email, trim( give_get_option( 'paypal_email' ) ) ) != 0 ) {
275
+	if (strcasecmp($business_email, trim(give_get_option('paypal_email'))) != 0) {
276 276
 
277 277
 		give_record_gateway_error(
278
-			esc_html__( 'IPN Error', 'give' ),
278
+			esc_html__('IPN Error', 'give'),
279 279
 			sprintf(
280 280
 				/* translators: %s: Paypal IPN response */
281
-				esc_html__( 'Invalid business email in IPN response. IPN data: %s', 'give' ),
282
-				json_encode( $data )
281
+				esc_html__('Invalid business email in IPN response. IPN data: %s', 'give'),
282
+				json_encode($data)
283 283
 			),
284 284
 			$payment_id
285 285
 		);
286
-		give_update_payment_status( $payment_id, 'failed' );
287
-		give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid PayPal business email.', 'give' ) );
286
+		give_update_payment_status($payment_id, 'failed');
287
+		give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid PayPal business email.', 'give'));
288 288
 
289 289
 		return;
290 290
 	}
291 291
 
292 292
 	// Verify payment currency.
293
-	if ( $currency_code != strtolower( $payment_meta['currency'] ) ) {
293
+	if ($currency_code != strtolower($payment_meta['currency'])) {
294 294
 
295 295
 		give_record_gateway_error(
296
-			esc_html__( 'IPN Error', 'give' ),
296
+			esc_html__('IPN Error', 'give'),
297 297
 			sprintf(
298 298
 				/* translators: %s: Paypal IPN response */
299
-				esc_html__( 'Invalid currency in IPN response. IPN data: %s', 'give' ),
300
-				json_encode( $data )
299
+				esc_html__('Invalid currency in IPN response. IPN data: %s', 'give'),
300
+				json_encode($data)
301 301
 			),
302 302
 			$payment_id
303 303
 		);
304
-		give_update_payment_status( $payment_id, 'failed' );
305
-		give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid currency in PayPal IPN.', 'give' ) );
304
+		give_update_payment_status($payment_id, 'failed');
305
+		give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid currency in PayPal IPN.', 'give'));
306 306
 
307 307
 		return;
308 308
 	}
309 309
 
310 310
 	// Process refunds & reversed.
311
-	if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) {
312
-		give_process_paypal_refund( $data, $payment_id );
311
+	if ($payment_status == 'refunded' || $payment_status == 'reversed') {
312
+		give_process_paypal_refund($data, $payment_id);
313 313
 
314 314
 		return;
315 315
 	}
316 316
 
317 317
 	// Only complete payments once.
318
-	if ( get_post_status( $payment_id ) == 'publish' ) {
318
+	if (get_post_status($payment_id) == 'publish') {
319 319
 		return;
320 320
 	}
321 321
 
322 322
 	// Retrieve the total donation amount (before PayPal).
323
-	$payment_amount = give_get_payment_amount( $payment_id );
323
+	$payment_amount = give_get_payment_amount($payment_id);
324 324
 
325 325
 	// Check that the donation PP and local db amounts match.
326
-	if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) {
326
+	if (number_format((float) $paypal_amount, 2) < number_format((float) $payment_amount, 2)) {
327 327
 		// The prices don't match
328 328
 		give_record_gateway_error(
329
-			esc_html__( 'IPN Error', 'give' ),
329
+			esc_html__('IPN Error', 'give'),
330 330
 			sprintf(
331 331
 				/* translators: %s: Paypal IPN response */
332
-				esc_html__( 'Invalid payment amount in IPN response. IPN data: %s', 'give' ),
333
-				json_encode( $data )
332
+				esc_html__('Invalid payment amount in IPN response. IPN data: %s', 'give'),
333
+				json_encode($data)
334 334
 			),
335 335
 			$payment_id
336 336
 		);
337
-		give_update_payment_status( $payment_id, 'failed' );
338
-		give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid amount in PayPal IPN.', 'give' ) );
337
+		give_update_payment_status($payment_id, 'failed');
338
+		give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid amount in PayPal IPN.', 'give'));
339 339
 
340 340
 		return;
341 341
 	}
342 342
 
343 343
 	// Process completed donations.
344
-	if ( $payment_status == 'completed' || give_is_test_mode() ) {
344
+	if ($payment_status == 'completed' || give_is_test_mode()) {
345 345
 
346 346
 		give_insert_payment_note(
347 347
 			$payment_id,
348 348
 			sprintf(
349 349
 				/* translators: %s: Paypal transaction ID */
350
-				esc_html__( 'PayPal Transaction ID: %s', 'give' ),
350
+				esc_html__('PayPal Transaction ID: %s', 'give'),
351 351
 				$data['txn_id']
352 352
 			)
353 353
 		);
354
-		give_set_payment_transaction_id( $payment_id, $data['txn_id'] );
355
-		give_update_payment_status( $payment_id, 'publish' );
354
+		give_set_payment_transaction_id($payment_id, $data['txn_id']);
355
+		give_update_payment_status($payment_id, 'publish');
356 356
 
357
-	} elseif ( 'pending' == $payment_status && isset( $data['pending_reason'] ) ) {
357
+	} elseif ('pending' == $payment_status && isset($data['pending_reason'])) {
358 358
 
359 359
 		// Look for possible pending reasons, such as an echeck.
360
-		$note = give_paypal_get_pending_donation_note( strtolower( $data['pending_reason'] ) );
360
+		$note = give_paypal_get_pending_donation_note(strtolower($data['pending_reason']));
361 361
 
362
-		if ( ! empty( $note ) ) {
362
+		if ( ! empty($note)) {
363 363
 
364
-			give_insert_payment_note( $payment_id, $note );
364
+			give_insert_payment_note($payment_id, $note);
365 365
 
366 366
 		}
367 367
 	}
368 368
 
369 369
 }
370 370
 
371
-add_action( 'give_paypal_web_accept', 'give_process_paypal_web_accept_and_cart', 10, 2 );
371
+add_action('give_paypal_web_accept', 'give_process_paypal_web_accept_and_cart', 10, 2);
372 372
 
373 373
 /**
374 374
  * Process PayPal IPN Refunds
@@ -380,27 +380,27 @@  discard block
 block discarded – undo
380 380
  *
381 381
  * @return void
382 382
  */
383
-function give_process_paypal_refund( $data, $payment_id = 0 ) {
383
+function give_process_paypal_refund($data, $payment_id = 0) {
384 384
 
385 385
 	// Collect payment details
386
-	if ( empty( $payment_id ) ) {
386
+	if (empty($payment_id)) {
387 387
 		return;
388 388
 	}
389 389
 
390
-	if ( get_post_status( $payment_id ) == 'refunded' ) {
390
+	if (get_post_status($payment_id) == 'refunded') {
391 391
 		return; // Only refund payments once
392 392
 	}
393 393
 
394
-	$payment_amount = give_get_payment_amount( $payment_id );
394
+	$payment_amount = give_get_payment_amount($payment_id);
395 395
 	$refund_amount  = $data['payment_gross'] * - 1;
396 396
 
397
-	if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) {
397
+	if (number_format((float) $refund_amount, 2) < number_format((float) $payment_amount, 2)) {
398 398
 
399 399
 		give_insert_payment_note(
400 400
 			$payment_id,
401 401
 			sprintf(
402 402
 				/* translators: %s: Paypal parent transaction ID */
403
-				esc_html__( 'Partial PayPal refund processed: %s', 'give' ),
403
+				esc_html__('Partial PayPal refund processed: %s', 'give'),
404 404
 				$data['parent_txn_id']
405 405
 			)
406 406
 		);
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
 		$payment_id,
414 414
 		sprintf(
415 415
 			/* translators: 1: Paypal parent transaction ID 2. Paypal reason code */
416
-			esc_html__( 'PayPal Payment #%1$s Refunded for reason: %2$s', 'give' ),
416
+			esc_html__('PayPal Payment #%1$s Refunded for reason: %2$s', 'give'),
417 417
 			$data['parent_txn_id'],
418 418
 			$data['reason_code']
419 419
 		)
@@ -422,11 +422,11 @@  discard block
 block discarded – undo
422 422
 		$payment_id,
423 423
 		sprintf(
424 424
 			/* translators: %s: Paypal transaction ID */
425
-			esc_html__( 'PayPal Refund Transaction ID: %s', 'give' ),
425
+			esc_html__('PayPal Refund Transaction ID: %s', 'give'),
426 426
 			$data['txn_id']
427 427
 		)
428 428
 	);
429
-	give_update_payment_status( $payment_id, 'refunded' );
429
+	give_update_payment_status($payment_id, 'refunded');
430 430
 }
431 431
 
432 432
 /**
@@ -438,24 +438,24 @@  discard block
 block discarded – undo
438 438
  *
439 439
  * @return string
440 440
  */
441
-function give_get_paypal_redirect( $ssl_check = false ) {
441
+function give_get_paypal_redirect($ssl_check = false) {
442 442
 
443
-	if ( is_ssl() || ! $ssl_check ) {
443
+	if (is_ssl() || ! $ssl_check) {
444 444
 		$protocol = 'https://';
445 445
 	} else {
446 446
 		$protocol = 'http://';
447 447
 	}
448 448
 
449 449
 	// Check the current payment mode
450
-	if ( give_is_test_mode() ) {
450
+	if (give_is_test_mode()) {
451 451
 		// Test mode
452
-		$paypal_uri = $protocol . 'www.sandbox.paypal.com/cgi-bin/webscr';
452
+		$paypal_uri = $protocol.'www.sandbox.paypal.com/cgi-bin/webscr';
453 453
 	} else {
454 454
 		// Live mode
455
-		$paypal_uri = $protocol . 'www.paypal.com/cgi-bin/webscr';
455
+		$paypal_uri = $protocol.'www.paypal.com/cgi-bin/webscr';
456 456
 	}
457 457
 
458
-	return apply_filters( 'give_paypal_uri', $paypal_uri );
458
+	return apply_filters('give_paypal_uri', $paypal_uri);
459 459
 }
460 460
 
461 461
 /**
@@ -465,9 +465,9 @@  discard block
 block discarded – undo
465 465
  * @return string
466 466
  */
467 467
 function give_get_paypal_page_style() {
468
-	$page_style = trim( give_get_option( 'paypal_page_style', 'PayPal' ) );
468
+	$page_style = trim(give_get_option('paypal_page_style', 'PayPal'));
469 469
 
470
-	return apply_filters( 'give_paypal_page_style', $page_style );
470
+	return apply_filters('give_paypal_page_style', $page_style);
471 471
 }
472 472
 
473 473
 /**
@@ -481,26 +481,26 @@  discard block
 block discarded – undo
481 481
  *
482 482
  * @return string
483 483
  */
484
-function give_paypal_success_page_content( $content ) {
484
+function give_paypal_success_page_content($content) {
485 485
 
486
-	if ( ! isset( $_GET['payment-id'] ) && ! give_get_purchase_session() ) {
486
+	if ( ! isset($_GET['payment-id']) && ! give_get_purchase_session()) {
487 487
 		return $content;
488 488
 	}
489 489
 
490
-	$payment_id = isset( $_GET['payment-id'] ) ? absint( $_GET['payment-id'] ) : false;
490
+	$payment_id = isset($_GET['payment-id']) ? absint($_GET['payment-id']) : false;
491 491
 
492
-	if ( ! $payment_id ) {
492
+	if ( ! $payment_id) {
493 493
 		$session    = give_get_purchase_session();
494
-		$payment_id = give_get_purchase_id_by_key( $session['purchase_key'] );
494
+		$payment_id = give_get_purchase_id_by_key($session['purchase_key']);
495 495
 	}
496 496
 
497
-	$payment = get_post( $payment_id );
498
-	if ( $payment && 'pending' == $payment->post_status ) {
497
+	$payment = get_post($payment_id);
498
+	if ($payment && 'pending' == $payment->post_status) {
499 499
 
500 500
 		// Payment is still pending so show processing indicator to fix the race condition.
501 501
 		ob_start();
502 502
 
503
-		give_get_template_part( 'payment', 'processing' );
503
+		give_get_template_part('payment', 'processing');
504 504
 
505 505
 		$content = ob_get_clean();
506 506
 
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
 
511 511
 }
512 512
 
513
-add_filter( 'give_payment_confirm_paypal', 'give_paypal_success_page_content' );
513
+add_filter('give_payment_confirm_paypal', 'give_paypal_success_page_content');
514 514
 
515 515
 /**
516 516
  * Given a Payment ID, extract the transaction ID
@@ -521,22 +521,22 @@  discard block
 block discarded – undo
521 521
  *
522 522
  * @return string                   Transaction ID
523 523
  */
524
-function give_paypal_get_payment_transaction_id( $payment_id ) {
524
+function give_paypal_get_payment_transaction_id($payment_id) {
525 525
 
526 526
 	$transaction_id = '';
527
-	$notes          = give_get_payment_notes( $payment_id );
527
+	$notes          = give_get_payment_notes($payment_id);
528 528
 
529
-	foreach ( $notes as $note ) {
530
-		if ( preg_match( '/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match ) ) {
529
+	foreach ($notes as $note) {
530
+		if (preg_match('/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match)) {
531 531
 			$transaction_id = $match[1];
532 532
 			continue;
533 533
 		}
534 534
 	}
535 535
 
536
-	return apply_filters( 'give_paypal_set_payment_transaction_id', $transaction_id, $payment_id );
536
+	return apply_filters('give_paypal_set_payment_transaction_id', $transaction_id, $payment_id);
537 537
 }
538 538
 
539
-add_filter( 'give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1 );
539
+add_filter('give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1);
540 540
 
541 541
 /**
542 542
  * Given a transaction ID, generate a link to the PayPal transaction ID details
@@ -548,16 +548,16 @@  discard block
 block discarded – undo
548 548
  *
549 549
  * @return string                 A link to the PayPal transaction details
550 550
  */
551
-function give_paypal_link_transaction_id( $transaction_id, $payment_id ) {
551
+function give_paypal_link_transaction_id($transaction_id, $payment_id) {
552 552
 
553 553
 	$paypal_base_url = 'https://history.paypal.com/cgi-bin/webscr?cmd=_history-details-from-hub&id=';
554
-	$transaction_url = '<a href="' . esc_url( $paypal_base_url . $transaction_id ) . '" target="_blank">' . $transaction_id . '</a>';
554
+	$transaction_url = '<a href="'.esc_url($paypal_base_url.$transaction_id).'" target="_blank">'.$transaction_id.'</a>';
555 555
 
556
-	return apply_filters( 'give_paypal_link_payment_details_transaction_id', $transaction_url );
556
+	return apply_filters('give_paypal_link_payment_details_transaction_id', $transaction_url);
557 557
 
558 558
 }
559 559
 
560
-add_filter( 'give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2 );
560
+add_filter('give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2);
561 561
 
562 562
 
563 563
 /**
@@ -569,64 +569,64 @@  discard block
 block discarded – undo
569 569
  *
570 570
  * @return string
571 571
  */
572
-function give_paypal_get_pending_donation_note( $pending_reason ) {
572
+function give_paypal_get_pending_donation_note($pending_reason) {
573 573
 
574 574
 	$note = '';
575 575
 
576
-	switch ( $pending_reason ) {
576
+	switch ($pending_reason) {
577 577
 
578 578
 		case 'echeck' :
579 579
 
580
-			$note = esc_html__( 'Payment made via eCheck and will clear automatically in 5-8 days.', 'give' );
580
+			$note = esc_html__('Payment made via eCheck and will clear automatically in 5-8 days.', 'give');
581 581
 
582 582
 			break;
583 583
 
584 584
 		case 'address' :
585 585
 
586
-			$note = esc_html__( 'Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give' );
586
+			$note = esc_html__('Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give');
587 587
 
588 588
 			break;
589 589
 
590 590
 		case 'intl' :
591 591
 
592
-			$note = esc_html__( 'Payment must be accepted manually through PayPal due to international account regulations.', 'give' );
592
+			$note = esc_html__('Payment must be accepted manually through PayPal due to international account regulations.', 'give');
593 593
 
594 594
 			break;
595 595
 
596 596
 		case 'multi-currency' :
597 597
 
598
-			$note = esc_html__( 'Payment received in non-shop currency and must be accepted manually through PayPal.', 'give' );
598
+			$note = esc_html__('Payment received in non-shop currency and must be accepted manually through PayPal.', 'give');
599 599
 
600 600
 			break;
601 601
 
602 602
 		case 'paymentreview' :
603 603
 		case 'regulatory_review' :
604 604
 
605
-			$note = esc_html__( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give' );
605
+			$note = esc_html__('Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give');
606 606
 
607 607
 			break;
608 608
 
609 609
 		case 'unilateral' :
610 610
 
611
-			$note = esc_html__( 'Payment was sent to non-confirmed or non-registered email address.', 'give' );
611
+			$note = esc_html__('Payment was sent to non-confirmed or non-registered email address.', 'give');
612 612
 
613 613
 			break;
614 614
 
615 615
 		case 'upgrade' :
616 616
 
617
-			$note = esc_html__( 'PayPal account must be upgraded before this payment can be accepted.', 'give' );
617
+			$note = esc_html__('PayPal account must be upgraded before this payment can be accepted.', 'give');
618 618
 
619 619
 			break;
620 620
 
621 621
 		case 'verify' :
622 622
 
623
-			$note = esc_html__( 'PayPal account is not verified. Verify account in order to accept this donation.', 'give' );
623
+			$note = esc_html__('PayPal account is not verified. Verify account in order to accept this donation.', 'give');
624 624
 
625 625
 			break;
626 626
 
627 627
 		case 'other' :
628 628
 
629
-			$note = esc_html__( 'Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give' );
629
+			$note = esc_html__('Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give');
630 630
 
631 631
 			break;
632 632
 
@@ -644,49 +644,49 @@  discard block
 block discarded – undo
644 644
  *
645 645
  * @return mixed|string
646 646
  */
647
-function give_build_paypal_url( $payment_id, $payment_data ) {
647
+function give_build_paypal_url($payment_id, $payment_data) {
648 648
 	// Only send to PayPal if the pending payment is created successfully.
649
-	$listener_url = add_query_arg( 'give-listener', 'IPN', home_url( 'index.php' ) );
649
+	$listener_url = add_query_arg('give-listener', 'IPN', home_url('index.php'));
650 650
 
651 651
 	// Get the success url.
652
-	$return_url = add_query_arg( array(
652
+	$return_url = add_query_arg(array(
653 653
 		'payment-confirmation' => 'paypal',
654 654
 		'payment-id'           => $payment_id,
655 655
 
656
-	), get_permalink( give_get_option( 'success_page' ) ) );
656
+	), get_permalink(give_get_option('success_page')));
657 657
 
658 658
 	// Get the PayPal redirect uri.
659
-	$paypal_redirect = trailingslashit( give_get_paypal_redirect() ) . '?';
659
+	$paypal_redirect = trailingslashit(give_get_paypal_redirect()).'?';
660 660
 
661 661
 	// Item name.
662
-	$item_name = give_build_paypal_item_title( $payment_data );
662
+	$item_name = give_build_paypal_item_title($payment_data);
663 663
 
664 664
 	// Setup PayPal API params.
665 665
 	$paypal_args = array(
666
-		'business'      => give_get_option( 'paypal_email', false ),
666
+		'business'      => give_get_option('paypal_email', false),
667 667
 		'first_name'    => $payment_data['user_info']['first_name'],
668 668
 		'last_name'     => $payment_data['user_info']['last_name'],
669 669
 		'email'         => $payment_data['user_email'],
670 670
 		'invoice'       => $payment_data['purchase_key'],
671 671
 		'amount'        => $payment_data['price'],
672
-		'item_name'     => stripslashes( $item_name ),
672
+		'item_name'     => stripslashes($item_name),
673 673
 		'no_shipping'   => '1',
674 674
 		'shipping'      => '0',
675 675
 		'no_note'       => '1',
676 676
 		'currency_code' => give_get_currency(),
677
-		'charset'       => get_bloginfo( 'charset' ),
677
+		'charset'       => get_bloginfo('charset'),
678 678
 		'custom'        => $payment_id,
679 679
 		'rm'            => '2',
680 680
 		'return'        => $return_url,
681
-		'cancel_return' => give_get_failed_transaction_uri( '?payment-id=' . $payment_id ),
681
+		'cancel_return' => give_get_failed_transaction_uri('?payment-id='.$payment_id),
682 682
 		'notify_url'    => $listener_url,
683 683
 		'page_style'    => give_get_paypal_page_style(),
684
-		'cbt'           => get_bloginfo( 'name' ),
684
+		'cbt'           => get_bloginfo('name'),
685 685
 		'bn'            => 'givewp_SP',
686 686
 	);
687 687
 
688 688
 	// Add user address if present.
689
-	if ( ! empty( $payment_data['user_info']['address'] ) ) {
689
+	if ( ! empty($payment_data['user_info']['address'])) {
690 690
 		$default_address = array(
691 691
 			'line1'   => '',
692 692
 			'line2'   => '',
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
 			'country' => '',
696 696
 		);
697 697
 
698
-		$address = wp_parse_args( $payment_data['user_info']['address'], $default_address );
698
+		$address = wp_parse_args($payment_data['user_info']['address'], $default_address);
699 699
 
700 700
 		$paypal_args['address1'] = $address['line1'];
701 701
 		$paypal_args['address2'] = $address['line2'];
@@ -715,13 +715,13 @@  discard block
 block discarded – undo
715 715
 	 * @param array $paypal_args
716 716
 	 * @param array $payment_data
717 717
 	 */
718
-	$paypal_args = apply_filters( 'give_paypal_redirect_args', $paypal_args, $payment_data );
718
+	$paypal_args = apply_filters('give_paypal_redirect_args', $paypal_args, $payment_data);
719 719
 
720 720
 	// Build query.
721
-	$paypal_redirect .= http_build_query( $paypal_args );
721
+	$paypal_redirect .= http_build_query($paypal_args);
722 722
 
723 723
 	// Fix for some sites that encode the entities.
724
-	$paypal_redirect = str_replace( '&amp;', '&', $paypal_redirect );
724
+	$paypal_redirect = str_replace('&amp;', '&', $paypal_redirect);
725 725
 
726 726
 	return $paypal_redirect;
727 727
 }
@@ -736,7 +736,7 @@  discard block
 block discarded – undo
736 736
 function give_get_paypal_button_type() {
737 737
 	// paypal_button_type can be donation or standard.
738 738
 	$paypal_button_type = '_donations';
739
-	if ( give_get_option( 'paypal_button_type' ) === 'standard' ) {
739
+	if (give_get_option('paypal_button_type') === 'standard') {
740 740
 		$paypal_button_type = '_xclick';
741 741
 	}
742 742
 
@@ -752,32 +752,32 @@  discard block
 block discarded – undo
752 752
  *
753 753
  * @return string
754 754
  */
755
-function give_build_paypal_item_title( $payment_data ) {
756
-	$form_id   = intval( $payment_data['post_data']['give-form-id'] );
755
+function give_build_paypal_item_title($payment_data) {
756
+	$form_id   = intval($payment_data['post_data']['give-form-id']);
757 757
 	$item_name = $payment_data['post_data']['give-form-title'];
758 758
 
759 759
 	// Verify has variable prices.
760
-	if ( give_has_variable_prices( $form_id ) && isset( $payment_data['post_data']['give-price-id'] ) ) {
760
+	if (give_has_variable_prices($form_id) && isset($payment_data['post_data']['give-price-id'])) {
761 761
 
762
-		$item_price_level_text = give_get_price_option_name( $form_id, $payment_data['post_data']['give-price-id'] );
763
-		$price_level_amount    = give_get_price_option_amount( $form_id, $payment_data['post_data']['give-price-id'] );
762
+		$item_price_level_text = give_get_price_option_name($form_id, $payment_data['post_data']['give-price-id']);
763
+		$price_level_amount    = give_get_price_option_amount($form_id, $payment_data['post_data']['give-price-id']);
764 764
 
765 765
 		// Donation given doesn't match selected level (must be a custom amount).
766
-		if ( $price_level_amount != give_sanitize_amount( $payment_data['price'] ) ) {
767
-			$custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true );
766
+		if ($price_level_amount != give_sanitize_amount($payment_data['price'])) {
767
+			$custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true);
768 768
 			// user custom amount text if any, fallback to default if not.
769
-			$item_name .= ' - ' . give_check_variable( $custom_amount_text, 'empty', esc_html__( 'Custom Amount', 'give' ) );
769
+			$item_name .= ' - '.give_check_variable($custom_amount_text, 'empty', esc_html__('Custom Amount', 'give'));
770 770
 
771 771
 		} //Is there any donation level text?
772
-		elseif ( ! empty( $item_price_level_text ) ) {
773
-			$item_name .= ' - ' . $item_price_level_text;
772
+		elseif ( ! empty($item_price_level_text)) {
773
+			$item_name .= ' - '.$item_price_level_text;
774 774
 		}
775 775
 
776 776
 	} //Single donation: Custom Amount.
777
-	elseif ( give_get_form_price( $form_id ) !== give_sanitize_amount( $payment_data['price'] ) ) {
778
-		$custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true );
777
+	elseif (give_get_form_price($form_id) !== give_sanitize_amount($payment_data['price'])) {
778
+		$custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true);
779 779
 		// user custom amount text if any, fallback to default if not.
780
-		$item_name .= ' - ' . give_check_variable( $custom_amount_text, 'empty', esc_html__( 'Custom Amount', 'give' ) );
780
+		$item_name .= ' - '.give_check_variable($custom_amount_text, 'empty', esc_html__('Custom Amount', 'give'));
781 781
 	}
782 782
 
783 783
 	return $item_name;
Please login to merge, or discard this patch.
give.php 1 patch
Spacing   +138 added lines, -138 removed lines patch added patch discarded remove patch
@@ -40,11 +40,11 @@  discard block
 block discarded – undo
40 40
  */
41 41
 
42 42
 // Exit if accessed directly.
43
-if ( ! defined( 'ABSPATH' ) ) {
43
+if ( ! defined('ABSPATH')) {
44 44
 	exit;
45 45
 }
46 46
 
47
-if ( ! class_exists( 'Give' ) ) :
47
+if ( ! class_exists('Give')) :
48 48
 
49 49
 	/**
50 50
 	 * Main Give Class
@@ -195,11 +195,11 @@  discard block
 block discarded – undo
195 195
 		 * @return    Give
196 196
 		 */
197 197
 		public static function instance() {
198
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Give ) ) {
198
+			if ( ! isset(self::$instance) && ! (self::$instance instanceof Give)) {
199 199
 				self::$instance = new Give;
200 200
 				self::$instance->setup_constants();
201 201
 
202
-				add_action( 'plugins_loaded', array( self::$instance, 'load_textdomain' ) );
202
+				add_action('plugins_loaded', array(self::$instance, 'load_textdomain'));
203 203
 
204 204
 				self::$instance->includes();
205 205
 				self::$instance->roles           = new Give_Roles();
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 		 */
233 233
 		public function __clone() {
234 234
 			// Cloning instances of the class is forbidden
235
-			_doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'give' ), '1.0' );
235
+			_doing_it_wrong(__FUNCTION__, __('Cheatin&#8217; huh?', 'give'), '1.0');
236 236
 		}
237 237
 
238 238
 		/**
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 		 */
246 246
 		public function __wakeup() {
247 247
 			// Unserializing instances of the class is forbidden.
248
-			_doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'give' ), '1.0' );
248
+			_doing_it_wrong(__FUNCTION__, __('Cheatin&#8217; huh?', 'give'), '1.0');
249 249
 		}
250 250
 
251 251
 		/**
@@ -259,33 +259,33 @@  discard block
 block discarded – undo
259 259
 		private function setup_constants() {
260 260
 
261 261
 			// Plugin version
262
-			if ( ! defined( 'GIVE_VERSION' ) ) {
263
-				define( 'GIVE_VERSION', '1.8' );
262
+			if ( ! defined('GIVE_VERSION')) {
263
+				define('GIVE_VERSION', '1.8');
264 264
 			}
265 265
 
266 266
 			// Plugin Folder Path
267
-			if ( ! defined( 'GIVE_PLUGIN_DIR' ) ) {
268
-				define( 'GIVE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
267
+			if ( ! defined('GIVE_PLUGIN_DIR')) {
268
+				define('GIVE_PLUGIN_DIR', plugin_dir_path(__FILE__));
269 269
 			}
270 270
 
271 271
 			// Plugin Folder URL
272
-			if ( ! defined( 'GIVE_PLUGIN_URL' ) ) {
273
-				define( 'GIVE_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
272
+			if ( ! defined('GIVE_PLUGIN_URL')) {
273
+				define('GIVE_PLUGIN_URL', plugin_dir_url(__FILE__));
274 274
 			}
275 275
 
276 276
 			// Plugin Basename aka: "give/give.php"
277
-			if ( ! defined( 'GIVE_PLUGIN_BASENAME' ) ) {
278
-				define( 'GIVE_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
277
+			if ( ! defined('GIVE_PLUGIN_BASENAME')) {
278
+				define('GIVE_PLUGIN_BASENAME', plugin_basename(__FILE__));
279 279
 			}
280 280
 
281 281
 			// Plugin Root File
282
-			if ( ! defined( 'GIVE_PLUGIN_FILE' ) ) {
283
-				define( 'GIVE_PLUGIN_FILE', __FILE__ );
282
+			if ( ! defined('GIVE_PLUGIN_FILE')) {
283
+				define('GIVE_PLUGIN_FILE', __FILE__);
284 284
 			}
285 285
 
286 286
 			// Make sure CAL_GREGORIAN is defined
287
-			if ( ! defined( 'CAL_GREGORIAN' ) ) {
288
-				define( 'CAL_GREGORIAN', 1 );
287
+			if ( ! defined('CAL_GREGORIAN')) {
288
+				define('CAL_GREGORIAN', 1);
289 289
 			}
290 290
 		}
291 291
 
@@ -300,122 +300,122 @@  discard block
 block discarded – undo
300 300
 		private function includes() {
301 301
 			global $give_options;
302 302
 
303
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/class-admin-settings.php';
304
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/class-give-settings.php';
303
+			require_once GIVE_PLUGIN_DIR.'includes/admin/class-admin-settings.php';
304
+			require_once GIVE_PLUGIN_DIR.'includes/admin/class-give-settings.php';
305 305
 			$give_options = give_get_settings();
306 306
 
307
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/give-metabox-functions.php';
308
-			require_once GIVE_PLUGIN_DIR . 'includes/post-types.php';
309
-			require_once GIVE_PLUGIN_DIR . 'includes/scripts.php';
310
-			require_once GIVE_PLUGIN_DIR . 'includes/ajax-functions.php';
311
-			require_once GIVE_PLUGIN_DIR . 'includes/actions.php';
312
-			require_once GIVE_PLUGIN_DIR . 'includes/filters.php';
313
-			require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api.php';
314
-
315
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-roles.php';
316
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-template-loader.php';
317
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-donate-form.php';
318
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-db.php';
319
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-customers.php';
320
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-customer-meta.php';
321
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-customer.php';
322
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-stats.php';
323
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-session.php';
324
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-html-elements.php';
325
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-logging.php';
326
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-license-handler.php';
327
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-cron.php';
328
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-email-access.php';
329
-
330
-			require_once GIVE_PLUGIN_DIR . 'includes/country-functions.php';
331
-			require_once GIVE_PLUGIN_DIR . 'includes/template-functions.php';
332
-			require_once GIVE_PLUGIN_DIR . 'includes/misc-functions.php';
333
-			require_once GIVE_PLUGIN_DIR . 'includes/forms/functions.php';
334
-			require_once GIVE_PLUGIN_DIR . 'includes/forms/template.php';
335
-			require_once GIVE_PLUGIN_DIR . 'includes/forms/widget.php';
336
-			require_once GIVE_PLUGIN_DIR . 'includes/shortcodes.php';
337
-			require_once GIVE_PLUGIN_DIR . 'includes/formatting.php';
338
-			require_once GIVE_PLUGIN_DIR . 'includes/price-functions.php';
339
-			require_once GIVE_PLUGIN_DIR . 'includes/error-tracking.php';
340
-			require_once GIVE_PLUGIN_DIR . 'includes/process-donation.php';
341
-			require_once GIVE_PLUGIN_DIR . 'includes/login-register.php';
342
-			require_once GIVE_PLUGIN_DIR . 'includes/user-functions.php';
343
-			require_once GIVE_PLUGIN_DIR . 'includes/plugin-compatibility.php';
344
-			require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-functions.php';
345
-			require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-actions.php';
346
-			require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-filters.php';
347
-
348
-			require_once GIVE_PLUGIN_DIR . 'includes/payments/functions.php';
349
-			require_once GIVE_PLUGIN_DIR . 'includes/payments/actions.php';
350
-			require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payment-stats.php';
351
-			require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payments-query.php';
352
-			require_once GIVE_PLUGIN_DIR . 'includes/payments/class-give-payment.php';
353
-
354
-			require_once GIVE_PLUGIN_DIR . 'includes/gateways/functions.php';
355
-			require_once GIVE_PLUGIN_DIR . 'includes/gateways/actions.php';
356
-			require_once GIVE_PLUGIN_DIR . 'includes/gateways/paypal-standard.php';
357
-			require_once GIVE_PLUGIN_DIR . 'includes/gateways/offline-donations.php';
358
-			require_once GIVE_PLUGIN_DIR . 'includes/gateways/manual.php';
359
-
360
-			require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-emails.php';
361
-			require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-email-tags.php';
362
-			require_once GIVE_PLUGIN_DIR . 'includes/emails/functions.php';
363
-			require_once GIVE_PLUGIN_DIR . 'includes/emails/template.php';
364
-			require_once GIVE_PLUGIN_DIR . 'includes/emails/actions.php';
365
-
366
-            if( defined( 'WP_CLI' ) && WP_CLI ) {
367
-                require_once GIVE_PLUGIN_DIR . 'includes/class-give-cli-commands.php';
307
+			require_once GIVE_PLUGIN_DIR.'includes/admin/give-metabox-functions.php';
308
+			require_once GIVE_PLUGIN_DIR.'includes/post-types.php';
309
+			require_once GIVE_PLUGIN_DIR.'includes/scripts.php';
310
+			require_once GIVE_PLUGIN_DIR.'includes/ajax-functions.php';
311
+			require_once GIVE_PLUGIN_DIR.'includes/actions.php';
312
+			require_once GIVE_PLUGIN_DIR.'includes/filters.php';
313
+			require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api.php';
314
+
315
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-roles.php';
316
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-template-loader.php';
317
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-donate-form.php';
318
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-db.php';
319
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-db-customers.php';
320
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-db-customer-meta.php';
321
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-customer.php';
322
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-stats.php';
323
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-session.php';
324
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-html-elements.php';
325
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-logging.php';
326
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-license-handler.php';
327
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-cron.php';
328
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-email-access.php';
329
+
330
+			require_once GIVE_PLUGIN_DIR.'includes/country-functions.php';
331
+			require_once GIVE_PLUGIN_DIR.'includes/template-functions.php';
332
+			require_once GIVE_PLUGIN_DIR.'includes/misc-functions.php';
333
+			require_once GIVE_PLUGIN_DIR.'includes/forms/functions.php';
334
+			require_once GIVE_PLUGIN_DIR.'includes/forms/template.php';
335
+			require_once GIVE_PLUGIN_DIR.'includes/forms/widget.php';
336
+			require_once GIVE_PLUGIN_DIR.'includes/shortcodes.php';
337
+			require_once GIVE_PLUGIN_DIR.'includes/formatting.php';
338
+			require_once GIVE_PLUGIN_DIR.'includes/price-functions.php';
339
+			require_once GIVE_PLUGIN_DIR.'includes/error-tracking.php';
340
+			require_once GIVE_PLUGIN_DIR.'includes/process-donation.php';
341
+			require_once GIVE_PLUGIN_DIR.'includes/login-register.php';
342
+			require_once GIVE_PLUGIN_DIR.'includes/user-functions.php';
343
+			require_once GIVE_PLUGIN_DIR.'includes/plugin-compatibility.php';
344
+			require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-functions.php';
345
+			require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-actions.php';
346
+			require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-filters.php';
347
+
348
+			require_once GIVE_PLUGIN_DIR.'includes/payments/functions.php';
349
+			require_once GIVE_PLUGIN_DIR.'includes/payments/actions.php';
350
+			require_once GIVE_PLUGIN_DIR.'includes/payments/class-payment-stats.php';
351
+			require_once GIVE_PLUGIN_DIR.'includes/payments/class-payments-query.php';
352
+			require_once GIVE_PLUGIN_DIR.'includes/payments/class-give-payment.php';
353
+
354
+			require_once GIVE_PLUGIN_DIR.'includes/gateways/functions.php';
355
+			require_once GIVE_PLUGIN_DIR.'includes/gateways/actions.php';
356
+			require_once GIVE_PLUGIN_DIR.'includes/gateways/paypal-standard.php';
357
+			require_once GIVE_PLUGIN_DIR.'includes/gateways/offline-donations.php';
358
+			require_once GIVE_PLUGIN_DIR.'includes/gateways/manual.php';
359
+
360
+			require_once GIVE_PLUGIN_DIR.'includes/emails/class-give-emails.php';
361
+			require_once GIVE_PLUGIN_DIR.'includes/emails/class-give-email-tags.php';
362
+			require_once GIVE_PLUGIN_DIR.'includes/emails/functions.php';
363
+			require_once GIVE_PLUGIN_DIR.'includes/emails/template.php';
364
+			require_once GIVE_PLUGIN_DIR.'includes/emails/actions.php';
365
+
366
+            if (defined('WP_CLI') && WP_CLI) {
367
+                require_once GIVE_PLUGIN_DIR.'includes/class-give-cli-commands.php';
368 368
             }
369 369
 
370
-			if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
371
-
372
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-footer.php';
373
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/welcome.php';
374
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-pages.php';
375
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/class-admin-notices.php';
376
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/class-api-keys-table.php';
377
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/class-i18n-module.php';
378
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-actions.php';
379
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-filters.php';
380
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/system-info.php';
381
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/add-ons.php';
382
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/plugins.php';
383
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/dashboard-widgets.php';
384
-
385
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/actions.php';
386
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/payments-history.php';
387
-
388
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/customers/customers.php';
389
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/customers/customer-functions.php';
390
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/customers/customer-actions.php';
391
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/metabox.php';
392
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/class-metabox-form-data.php';
393
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/dashboard-columns.php';
394
-
395
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/export-functions.php';
396
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/reports.php';
397
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools.php';
398
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/tools/tools-actions.php';
399
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/pdf-reports.php';
400
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-give-graph.php';
401
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/graphing.php';
402
-
403
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/abstract-shortcode-generator.php';
404
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/class-shortcode-button.php';
405
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-form.php';
406
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-goal.php';
407
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-login.php';
408
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-register.php';
409
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-profile-editor.php';
410
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-donation-history.php';
411
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-receipt.php';
412
-
413
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php';
414
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrades.php';
370
+			if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
371
+
372
+				require_once GIVE_PLUGIN_DIR.'includes/admin/admin-footer.php';
373
+				require_once GIVE_PLUGIN_DIR.'includes/admin/welcome.php';
374
+				require_once GIVE_PLUGIN_DIR.'includes/admin/admin-pages.php';
375
+				require_once GIVE_PLUGIN_DIR.'includes/admin/class-admin-notices.php';
376
+				require_once GIVE_PLUGIN_DIR.'includes/admin/class-api-keys-table.php';
377
+				require_once GIVE_PLUGIN_DIR.'includes/admin/class-i18n-module.php';
378
+				require_once GIVE_PLUGIN_DIR.'includes/admin/admin-actions.php';
379
+				require_once GIVE_PLUGIN_DIR.'includes/admin/admin-filters.php';
380
+				require_once GIVE_PLUGIN_DIR.'includes/admin/system-info.php';
381
+				require_once GIVE_PLUGIN_DIR.'includes/admin/add-ons.php';
382
+				require_once GIVE_PLUGIN_DIR.'includes/admin/plugins.php';
383
+				require_once GIVE_PLUGIN_DIR.'includes/admin/dashboard-widgets.php';
384
+
385
+				require_once GIVE_PLUGIN_DIR.'includes/admin/payments/actions.php';
386
+				require_once GIVE_PLUGIN_DIR.'includes/admin/payments/payments-history.php';
387
+
388
+				require_once GIVE_PLUGIN_DIR.'includes/admin/customers/customers.php';
389
+				require_once GIVE_PLUGIN_DIR.'includes/admin/customers/customer-functions.php';
390
+				require_once GIVE_PLUGIN_DIR.'includes/admin/customers/customer-actions.php';
391
+				require_once GIVE_PLUGIN_DIR.'includes/admin/forms/metabox.php';
392
+				require_once GIVE_PLUGIN_DIR.'includes/admin/forms/class-metabox-form-data.php';
393
+				require_once GIVE_PLUGIN_DIR.'includes/admin/forms/dashboard-columns.php';
394
+
395
+				require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/export-functions.php';
396
+				require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/reports.php';
397
+				require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/tools.php';
398
+				require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/tools/tools-actions.php';
399
+				require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/pdf-reports.php';
400
+				require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-give-graph.php';
401
+				require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/graphing.php';
402
+
403
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/abstract-shortcode-generator.php';
404
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/class-shortcode-button.php';
405
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-form.php';
406
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-goal.php';
407
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-login.php';
408
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-register.php';
409
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-profile-editor.php';
410
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-donation-history.php';
411
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-receipt.php';
412
+
413
+				require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php';
414
+				require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrades.php';
415 415
 
416 416
 			}
417 417
 
418
-			require_once GIVE_PLUGIN_DIR . 'includes/install.php';
418
+			require_once GIVE_PLUGIN_DIR.'includes/install.php';
419 419
 
420 420
 		}
421 421
 
@@ -429,26 +429,26 @@  discard block
 block discarded – undo
429 429
 		 */
430 430
 		public function load_textdomain() {
431 431
 			// Set filter for Give's languages directory
432
-			$give_lang_dir = dirname( plugin_basename( GIVE_PLUGIN_FILE ) ) . '/languages/';
433
-			$give_lang_dir = apply_filters( 'give_languages_directory', $give_lang_dir );
432
+			$give_lang_dir = dirname(plugin_basename(GIVE_PLUGIN_FILE)).'/languages/';
433
+			$give_lang_dir = apply_filters('give_languages_directory', $give_lang_dir);
434 434
 
435 435
 			// Traditional WordPress plugin locale filter
436
-			$locale = apply_filters( 'plugin_locale', get_locale(), 'give' );
437
-			$mofile = sprintf( '%1$s-%2$s.mo', 'give', $locale );
436
+			$locale = apply_filters('plugin_locale', get_locale(), 'give');
437
+			$mofile = sprintf('%1$s-%2$s.mo', 'give', $locale);
438 438
 
439 439
 			// Setup paths to current locale file
440
-			$mofile_local  = $give_lang_dir . $mofile;
441
-			$mofile_global = WP_LANG_DIR . '/give/' . $mofile;
440
+			$mofile_local  = $give_lang_dir.$mofile;
441
+			$mofile_global = WP_LANG_DIR.'/give/'.$mofile;
442 442
 
443
-			if ( file_exists( $mofile_global ) ) {
443
+			if (file_exists($mofile_global)) {
444 444
 				// Look in global /wp-content/languages/give folder
445
-				load_textdomain( 'give', $mofile_global );
446
-			} elseif ( file_exists( $mofile_local ) ) {
445
+				load_textdomain('give', $mofile_global);
446
+			} elseif (file_exists($mofile_local)) {
447 447
 				// Look in local location from filter `give_languages_directory`
448
-				load_textdomain( 'give', $mofile_local );
448
+				load_textdomain('give', $mofile_local);
449 449
 			} else {
450 450
 				// Load the default language files packaged up w/ Give
451
-				load_plugin_textdomain( 'give', false, $give_lang_dir );
451
+				load_plugin_textdomain('give', false, $give_lang_dir);
452 452
 			}
453 453
 		}
454 454
 
Please login to merge, or discard this patch.
includes/admin/tools/class-settings-logs.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -9,11 +9,11 @@  discard block
 block discarded – undo
9 9
  * @since       1.8
10 10
  */
11 11
 
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit; // Exit if accessed directly
14 14
 }
15 15
 
16
-if ( ! class_exists( 'Give_Settings_Logs' ) ) :
16
+if ( ! class_exists('Give_Settings_Logs')) :
17 17
 
18 18
 	/**
19 19
 	 * Give_Settings_Logs.
@@ -43,16 +43,16 @@  discard block
 block discarded – undo
43 43
 		 */
44 44
 		public function __construct() {
45 45
 			$this->id    = 'logs';
46
-			$this->label = esc_html__( 'Logs', 'give' );
46
+			$this->label = esc_html__('Logs', 'give');
47 47
 
48 48
 			$this->default_tab = 'sales';
49 49
 
50 50
 			parent::__construct();
51 51
 
52 52
 			// Do not use main form for this tab.
53
-			if ( give_get_current_setting_tab() === $this->id ) {
54
-				add_action( 'give-tools_open_form', '__return_empty_string' );
55
-				add_action( 'give-tools_close_form', '__return_empty_string' );
53
+			if (give_get_current_setting_tab() === $this->id) {
54
+				add_action('give-tools_open_form', '__return_empty_string');
55
+				add_action('give-tools_close_form', '__return_empty_string');
56 56
 			}
57 57
 		}
58 58
 
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
 		 *
66 66
 		 * @return array
67 67
 		 */
68
-		public function add_settings_page( $pages ) {
69
-			$pages[ $this->id ] = $this->label;
68
+		public function add_settings_page($pages) {
69
+			$pages[$this->id] = $this->label;
70 70
 
71 71
 			return $pages;
72 72
 		}
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 			$GLOBALS['give_hide_save_button'] = true;
83 83
 
84 84
 			// Get settings.
85
-			$settings = apply_filters( 'give_settings_system', array(
85
+			$settings = apply_filters('give_settings_system', array(
86 86
 				array(
87 87
 					'id'         => 'give_tools_logs',
88 88
 					'type'       => 'title',
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 				),
91 91
 				array(
92 92
 					'id'   => 'api',
93
-					'name' => esc_html__( 'Log', 'give' ),
93
+					'name' => esc_html__('Log', 'give'),
94 94
 					'type' => 'logs',
95 95
 
96 96
 				),
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 					'type'       => 'sectionend',
100 100
 					'table_html' => false,
101 101
 				),
102
-			) );
102
+			));
103 103
 
104 104
 			/**
105 105
 			 * Filter the settings.
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 			 *
109 109
 			 * @param  array $settings
110 110
 			 */
111
-			$settings = apply_filters( 'give_get_settings_' . $this->id, $settings );
111
+			$settings = apply_filters('give_get_settings_'.$this->id, $settings);
112 112
 
113 113
 			// Output.
114 114
 			return $settings;
@@ -122,14 +122,14 @@  discard block
 block discarded – undo
122 122
 		 */
123 123
 		public function get_sections() {
124 124
 			$sections = array(
125
-				'sales'          => esc_html__( 'Donations', 'give' ),
126
-				'gateway_errors' => esc_html__( 'Payment Errors', 'give' ),
127
-				'api_requests'   => esc_html__( 'API Requests', 'give' ),
125
+				'sales'          => esc_html__('Donations', 'give'),
126
+				'gateway_errors' => esc_html__('Payment Errors', 'give'),
127
+				'api_requests'   => esc_html__('API Requests', 'give'),
128 128
 			);
129 129
 
130
-			$sections = apply_filters( 'give_log_views', $sections );
130
+			$sections = apply_filters('give_log_views', $sections);
131 131
 
132
-			return apply_filters( 'give_get_sections_' . $this->id, $sections );
132
+			return apply_filters('give_get_sections_'.$this->id, $sections);
133 133
 		}
134 134
 
135 135
 		/**
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 		public function output() {
142 142
 			$settings = $this->get_settings();
143 143
 
144
-			Give_Admin_Settings::output_fields( $settings, 'give_settings' );
144
+			Give_Admin_Settings::output_fields($settings, 'give_settings');
145 145
 		}
146 146
 	}
147 147
 
Please login to merge, or discard this patch.
includes/admin/settings/class-settings-license.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -9,11 +9,11 @@  discard block
 block discarded – undo
9 9
  * @since       1.8
10 10
  */
11 11
 
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit; // Exit if accessed directly
14 14
 }
15 15
 
16
-if ( ! class_exists( 'Give_Settings_License' ) ) :
16
+if ( ! class_exists('Give_Settings_License')) :
17 17
 
18 18
 	/**
19 19
 	 * Give_Settings_License.
@@ -43,10 +43,10 @@  discard block
 block discarded – undo
43 43
 		 */
44 44
 		public function __construct() {
45 45
 			$this->id    = 'licenses';
46
-			$this->label = esc_html__( 'Licenses', 'give' );
46
+			$this->label = esc_html__('Licenses', 'give');
47 47
 
48
-			add_filter( 'give-settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
49
-			add_action( "give-settings_settings_{$this->id}_page", array( $this, 'output' ) );
48
+			add_filter('give-settings_tabs_array', array($this, 'add_settings_page'), 20);
49
+			add_action("give-settings_settings_{$this->id}_page", array($this, 'output'));
50 50
 		}
51 51
 
52 52
 		/**
@@ -56,11 +56,11 @@  discard block
 block discarded – undo
56 56
 		 * @param  array $pages Lst of pages.
57 57
 		 * @return array
58 58
 		 */
59
-		public function add_settings_page( $pages ) {
59
+		public function add_settings_page($pages) {
60 60
 			$setting = $this->get_settings();
61 61
 			// Bailout: Do not add licenses setting tab if it does not contain any setting fields.
62
-			if( ! empty( $setting ) ) {
63
-				$pages[ $this->id ] = $this->label;
62
+			if ( ! empty($setting)) {
63
+				$pages[$this->id] = $this->label;
64 64
 			}
65 65
 
66 66
 			return $pages;
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 			 * Filter the licenses settings.
80 80
 			 * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8
81 81
 			 */
82
-			$settings = apply_filters( 'give_settings_licenses', $settings );
82
+			$settings = apply_filters('give_settings_licenses', $settings);
83 83
 
84 84
 			/**
85 85
 			 * Filter the settings.
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 			 * @since  1.8
88 88
 			 * @param  array $settings
89 89
 			 */
90
-			$settings = apply_filters( 'give_get_settings_' . $this->id, $settings );
90
+			$settings = apply_filters('give_get_settings_'.$this->id, $settings);
91 91
 
92 92
 			// Output.
93 93
 			return $settings;
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 		public function output() {
103 103
 			$settings = $this->get_settings();
104 104
 
105
-			Give_Admin_Settings::output_fields( $settings, 'give_settings' );
105
+			Give_Admin_Settings::output_fields($settings, 'give_settings');
106 106
 		}
107 107
 	}
108 108
 
Please login to merge, or discard this patch.
includes/admin/settings/class-settings-addon.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -9,11 +9,11 @@  discard block
 block discarded – undo
9 9
  * @since       1.8
10 10
  */
11 11
 
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit; // Exit if accessed directly
14 14
 }
15 15
 
16
-if ( ! class_exists( 'Give_Settings_Addon' ) ) :
16
+if ( ! class_exists('Give_Settings_Addon')) :
17 17
 
18 18
 	/**
19 19
 	 * Give_Settings_Addon.
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 		 */
27 27
 		public function __construct() {
28 28
 			$this->id    = 'addons';
29
-			$this->label = esc_html__( 'Add-ons', 'give' );
29
+			$this->label = esc_html__('Add-ons', 'give');
30 30
 
31 31
 			parent::__construct();
32 32
 		}
@@ -38,12 +38,12 @@  discard block
 block discarded – undo
38 38
 		 * @param  $setting_tab
39 39
 		 * @return string
40 40
 		 */
41
-		function set_default_setting_tab( $setting_tab ) {
41
+		function set_default_setting_tab($setting_tab) {
42 42
 			$default_tab = '';
43 43
 
44 44
 			// Set default tab to first setting tab.
45
-			if( $sections = array_keys( $this->get_sections() ) ) {
46
-				$default_tab = current( $sections );
45
+			if ($sections = array_keys($this->get_sections())) {
46
+				$default_tab = current($sections);
47 47
 			}
48 48
 			return $default_tab;
49 49
 		}
@@ -55,11 +55,11 @@  discard block
 block discarded – undo
55 55
 		 * @param  array $pages Lst of pages.
56 56
 		 * @return array
57 57
 		 */
58
-		public function add_settings_page( $pages ) {
58
+		public function add_settings_page($pages) {
59 59
 			$setting = $this->get_settings();
60 60
 			// Bailout: Do not add addons setting tab if it does not contain any setting fields.
61
-			if( ! empty( $setting ) ) {
62
-				$pages[ $this->id ] = $this->label;
61
+			if ( ! empty($setting)) {
62
+				$pages[$this->id] = $this->label;
63 63
 			}
64 64
 
65 65
 			return $pages;
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 			 * Filter the addons settings.
79 79
 			 * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8
80 80
 			 */
81
-			$settings = apply_filters( 'give_settings_addons', $settings );
81
+			$settings = apply_filters('give_settings_addons', $settings);
82 82
 
83 83
 			/**
84 84
 			 * Filter the settings.
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 			 * @since  1.8
87 87
 			 * @param  array $settings
88 88
 			 */
89
-			$settings = apply_filters( 'give_get_settings_' . $this->id, $settings );
89
+			$settings = apply_filters('give_get_settings_'.$this->id, $settings);
90 90
 
91 91
 			// Output.
92 92
 			return $settings;
Please login to merge, or discard this patch.