Completed
Pull Request — master (#1055)
by Rami
19:01
created
includes/ajax-functions.php 1 patch
Spacing   +102 added lines, -102 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
 
@@ -26,27 +26,27 @@  discard block
 block discarded – undo
26 26
 function give_test_ajax_works() {
27 27
 
28 28
 	// Check if the Airplane Mode plugin is installed
29
-	if ( class_exists( 'Airplane_Mode_Core' ) ) {
29
+	if (class_exists('Airplane_Mode_Core')) {
30 30
 
31 31
 		$airplane = Airplane_Mode_Core::getInstance();
32 32
 
33
-		if ( method_exists( $airplane, 'enabled' ) ) {
33
+		if (method_exists($airplane, 'enabled')) {
34 34
 
35
-			if ( $airplane->enabled() ) {
35
+			if ($airplane->enabled()) {
36 36
 				return true;
37 37
 			}
38 38
 
39 39
 		} else {
40 40
 
41
-			if ( $airplane->check_status() == 'on' ) {
41
+			if ($airplane->check_status() == 'on') {
42 42
 				return true;
43 43
 			}
44 44
 		}
45 45
 	}
46 46
 
47
-	add_filter( 'block_local_requests', '__return_false' );
47
+	add_filter('block_local_requests', '__return_false');
48 48
 
49
-	if ( get_transient( '_give_ajax_works' ) ) {
49
+	if (get_transient('_give_ajax_works')) {
50 50
 		return true;
51 51
 	}
52 52
 
@@ -58,35 +58,35 @@  discard block
 block discarded – undo
58 58
 		)
59 59
 	);
60 60
 
61
-	$ajax  = wp_remote_post( give_get_ajax_url(), $params );
61
+	$ajax  = wp_remote_post(give_get_ajax_url(), $params);
62 62
 	$works = true;
63 63
 
64
-	if ( is_wp_error( $ajax ) ) {
64
+	if (is_wp_error($ajax)) {
65 65
 
66 66
 		$works = false;
67 67
 
68 68
 	} else {
69 69
 
70
-		if ( empty( $ajax['response'] ) ) {
70
+		if (empty($ajax['response'])) {
71 71
 			$works = false;
72 72
 		}
73 73
 
74
-		if ( empty( $ajax['response']['code'] ) || 200 !== (int) $ajax['response']['code'] ) {
74
+		if (empty($ajax['response']['code']) || 200 !== (int) $ajax['response']['code']) {
75 75
 			$works = false;
76 76
 		}
77 77
 
78
-		if ( empty( $ajax['response']['message'] ) || 'OK' !== $ajax['response']['message'] ) {
78
+		if (empty($ajax['response']['message']) || 'OK' !== $ajax['response']['message']) {
79 79
 			$works = false;
80 80
 		}
81 81
 
82
-		if ( ! isset( $ajax['body'] ) || 0 !== (int) $ajax['body'] ) {
82
+		if ( ! isset($ajax['body']) || 0 !== (int) $ajax['body']) {
83 83
 			$works = false;
84 84
 		}
85 85
 
86 86
 	}
87 87
 
88
-	if ( $works ) {
89
-		set_transient( '_give_ajax_works', '1', DAY_IN_SECONDS );
88
+	if ($works) {
89
+		set_transient('_give_ajax_works', '1', DAY_IN_SECONDS);
90 90
 	}
91 91
 
92 92
 	return $works;
@@ -101,16 +101,16 @@  discard block
 block discarded – undo
101 101
  * @return string
102 102
  */
103 103
 function give_get_ajax_url() {
104
-	$scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin';
104
+	$scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin';
105 105
 
106 106
 	$current_url = give_get_current_page_url();
107
-	$ajax_url    = admin_url( 'admin-ajax.php', $scheme );
107
+	$ajax_url    = admin_url('admin-ajax.php', $scheme);
108 108
 
109
-	if ( preg_match( '/^https/', $current_url ) && ! preg_match( '/^https/', $ajax_url ) ) {
110
-		$ajax_url = preg_replace( '/^http/', 'https', $ajax_url );
109
+	if (preg_match('/^https/', $current_url) && ! preg_match('/^https/', $ajax_url)) {
110
+		$ajax_url = preg_replace('/^http/', 'https', $ajax_url);
111 111
 	}
112 112
 
113
-	return apply_filters( 'give_ajax_url', $ajax_url );
113
+	return apply_filters('give_ajax_url', $ajax_url);
114 114
 }
115 115
 
116 116
 /**
@@ -126,12 +126,12 @@  discard block
 block discarded – undo
126 126
 	 *
127 127
 	 * @since 1.7
128 128
 	 */
129
-	do_action( 'give_donation_form_login_fields' );
129
+	do_action('give_donation_form_login_fields');
130 130
 
131 131
 	give_die();
132 132
 }
133 133
 
134
-add_action( 'wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields' );
134
+add_action('wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields');
135 135
 
136 136
 /**
137 137
  * Load Checkout Fields
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
  * @return void
142 142
  */
143 143
 function give_load_checkout_fields() {
144
-	$form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : '';
144
+	$form_id = isset($_POST['form_id']) ? $_POST['form_id'] : '';
145 145
 
146 146
 	ob_start();
147 147
 
@@ -150,18 +150,18 @@  discard block
 block discarded – undo
150 150
 	 *
151 151
 	 * @since 1.7
152 152
 	 */
153
-	do_action( 'give_donation_form_register_login_fields', $form_id );
153
+	do_action('give_donation_form_register_login_fields', $form_id);
154 154
 
155 155
 	$fields = ob_get_clean();
156 156
 
157
-	wp_send_json( array(
158
-		'fields' => wp_json_encode( $fields ),
159
-		'submit' => wp_json_encode( give_checkout_button_purchase( $form_id ) ),
160
-	) );
157
+	wp_send_json(array(
158
+		'fields' => wp_json_encode($fields),
159
+		'submit' => wp_json_encode(give_checkout_button_purchase($form_id)),
160
+	));
161 161
 }
162 162
 
163
-add_action( 'wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields' );
164
-add_action( 'wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields' );
163
+add_action('wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields');
164
+add_action('wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields');
165 165
 
166 166
 /**
167 167
  * Get Form Title via AJAX (used only in WordPress Admin)
@@ -171,9 +171,9 @@  discard block
 block discarded – undo
171 171
  * @return void
172 172
  */
173 173
 function give_ajax_get_form_title() {
174
-	if ( isset( $_POST['form_id'] ) ) {
175
-		$title = get_the_title( $_POST['form_id'] );
176
-		if ( $title ) {
174
+	if (isset($_POST['form_id'])) {
175
+		$title = get_the_title($_POST['form_id']);
176
+		if ($title) {
177 177
 			echo $title;
178 178
 		} else {
179 179
 			echo 'fail';
@@ -182,8 +182,8 @@  discard block
 block discarded – undo
182 182
 	give_die();
183 183
 }
184 184
 
185
-add_action( 'wp_ajax_give_get_form_title', 'give_ajax_get_form_title' );
186
-add_action( 'wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title' );
185
+add_action('wp_ajax_give_get_form_title', 'give_ajax_get_form_title');
186
+add_action('wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title');
187 187
 
188 188
 /**
189 189
  * Retrieve a states drop down
@@ -194,23 +194,23 @@  discard block
 block discarded – undo
194 194
  */
195 195
 function give_ajax_get_states_field() {
196 196
 
197
-	if ( empty( $_POST['country'] ) ) {
197
+	if (empty($_POST['country'])) {
198 198
 		$_POST['country'] = give_get_country();
199 199
 	}
200
-	$states = give_get_states( $_POST['country'] );
200
+	$states = give_get_states($_POST['country']);
201 201
 
202
-	if ( ! empty( $states ) ) {
202
+	if ( ! empty($states)) {
203 203
 
204 204
 		$args = array(
205 205
 			'name'             => $_POST['field_name'],
206 206
 			'id'               => $_POST['field_name'],
207
-			'class'            => $_POST['field_name'] . '  give-select',
208
-			'options'          => give_get_states( $_POST['country'] ),
207
+			'class'            => $_POST['field_name'].'  give-select',
208
+			'options'          => give_get_states($_POST['country']),
209 209
 			'show_option_all'  => false,
210 210
 			'show_option_none' => false
211 211
 		);
212 212
 
213
-		$response = Give()->html->select( $args );
213
+		$response = Give()->html->select($args);
214 214
 
215 215
 	} else {
216 216
 
@@ -222,8 +222,8 @@  discard block
 block discarded – undo
222 222
 	give_die();
223 223
 }
224 224
 
225
-add_action( 'wp_ajax_give_get_states', 'give_ajax_get_states_field' );
226
-add_action( 'wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field' );
225
+add_action('wp_ajax_give_get_states', 'give_ajax_get_states_field');
226
+add_action('wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field');
227 227
 
228 228
 /**
229 229
  * Retrieve a states drop down
@@ -235,17 +235,17 @@  discard block
 block discarded – undo
235 235
 function give_ajax_form_search() {
236 236
 	global $wpdb;
237 237
 
238
-	$search  = esc_sql( sanitize_text_field( $_GET['s'] ) );
238
+	$search  = esc_sql(sanitize_text_field($_GET['s']));
239 239
 	$results = array();
240
-	if ( current_user_can( 'edit_give_forms' ) ) {
241
-		$items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50" );
240
+	if (current_user_can('edit_give_forms')) {
241
+		$items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50");
242 242
 	} else {
243
-		$items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50" );
243
+		$items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50");
244 244
 	}
245 245
 
246
-	if ( $items ) {
246
+	if ($items) {
247 247
 
248
-		foreach ( $items as $item ) {
248
+		foreach ($items as $item) {
249 249
 
250 250
 			$results[] = array(
251 251
 				'id'   => $item->ID,
@@ -257,18 +257,18 @@  discard block
 block discarded – undo
257 257
 
258 258
 		$items[] = array(
259 259
 			'id'   => 0,
260
-			'name' => esc_html__( 'No forms found.', 'give' )
260
+			'name' => esc_html__('No forms found.', 'give')
261 261
 		);
262 262
 
263 263
 	}
264 264
 
265
-	echo json_encode( $results );
265
+	echo json_encode($results);
266 266
 
267 267
 	give_die();
268 268
 }
269 269
 
270
-add_action( 'wp_ajax_give_form_search', 'give_ajax_form_search' );
271
-add_action( 'wp_ajax_nopriv_give_form_search', 'give_ajax_form_search' );
270
+add_action('wp_ajax_give_form_search', 'give_ajax_form_search');
271
+add_action('wp_ajax_nopriv_give_form_search', 'give_ajax_form_search');
272 272
 
273 273
 /**
274 274
  * Search the donors database via Ajax
@@ -280,21 +280,21 @@  discard block
 block discarded – undo
280 280
 function give_ajax_donor_search() {
281 281
 	global $wpdb;
282 282
 
283
-	$search  = esc_sql( sanitize_text_field( $_GET['s'] ) );
283
+	$search  = esc_sql(sanitize_text_field($_GET['s']));
284 284
 	$results = array();
285
-	if ( ! current_user_can( 'view_give_reports' ) ) {
285
+	if ( ! current_user_can('view_give_reports')) {
286 286
 		$donors = array();
287 287
 	} else {
288
-		$donors = $wpdb->get_results( "SELECT id,name,email FROM {$wpdb->prefix}give_donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50" );
288
+		$donors = $wpdb->get_results("SELECT id,name,email FROM {$wpdb->prefix}give_donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50");
289 289
 	}
290 290
 
291
-	if ( $donors ) {
291
+	if ($donors) {
292 292
 
293
-		foreach ( $donors as $donor ) {
293
+		foreach ($donors as $donor) {
294 294
 
295 295
 			$results[] = array(
296 296
 				'id'   => $donor->id,
297
-				'name' => $donor->name . '(' . $donor->email . ')'
297
+				'name' => $donor->name.'('.$donor->email.')'
298 298
 			);
299 299
 		}
300 300
 
@@ -302,17 +302,17 @@  discard block
 block discarded – undo
302 302
 
303 303
 		$donors[] = array(
304 304
 			'id'   => 0,
305
-			'name' => esc_html__( 'No donors found.', 'give' )
305
+			'name' => esc_html__('No donors found.', 'give')
306 306
 		);
307 307
 
308 308
 	}
309 309
 
310
-	echo json_encode( $results );
310
+	echo json_encode($results);
311 311
 
312 312
 	give_die();
313 313
 }
314 314
 
315
-add_action( 'wp_ajax_give_donor_search', 'give_ajax_donor_search' );
315
+add_action('wp_ajax_give_donor_search', 'give_ajax_donor_search');
316 316
 
317 317
 
318 318
 /**
@@ -324,42 +324,42 @@  discard block
 block discarded – undo
324 324
  */
325 325
 function give_ajax_search_users() {
326 326
 
327
-	if ( current_user_can( 'manage_give_settings' ) ) {
327
+	if (current_user_can('manage_give_settings')) {
328 328
 
329
-		$search_query = trim( $_POST['user_name'] );
330
-		$exclude      = trim( $_POST['exclude'] );
329
+		$search_query = trim($_POST['user_name']);
330
+		$exclude      = trim($_POST['exclude']);
331 331
 
332 332
 		$get_users_args = array(
333 333
 			'number' => 9999,
334
-			'search' => $search_query . '*'
334
+			'search' => $search_query.'*'
335 335
 		);
336 336
 
337
-		if ( ! empty( $exclude ) ) {
338
-			$exclude_array             = explode( ',', $exclude );
337
+		if ( ! empty($exclude)) {
338
+			$exclude_array             = explode(',', $exclude);
339 339
 			$get_users_args['exclude'] = $exclude_array;
340 340
 		}
341 341
 
342
-		$get_users_args = apply_filters( 'give_search_users_args', $get_users_args );
342
+		$get_users_args = apply_filters('give_search_users_args', $get_users_args);
343 343
 
344
-		$found_users = apply_filters( 'give_ajax_found_users', get_users( $get_users_args ), $search_query );
344
+		$found_users = apply_filters('give_ajax_found_users', get_users($get_users_args), $search_query);
345 345
 
346 346
 		$user_list = '<ul>';
347
-		if ( $found_users ) {
348
-			foreach ( $found_users as $user ) {
349
-				$user_list .= '<li><a href="#" data-userid="' . esc_attr( $user->ID ) . '" data-login="' . esc_attr( $user->user_login ) . '">' . esc_html( $user->user_login ) . '</a></li>';
347
+		if ($found_users) {
348
+			foreach ($found_users as $user) {
349
+				$user_list .= '<li><a href="#" data-userid="'.esc_attr($user->ID).'" data-login="'.esc_attr($user->user_login).'">'.esc_html($user->user_login).'</a></li>';
350 350
 			}
351 351
 		} else {
352
-			$user_list .= '<li>' . esc_html__( 'No users found.', 'give' ) . '</li>';
352
+			$user_list .= '<li>'.esc_html__('No users found.', 'give').'</li>';
353 353
 		}
354 354
 		$user_list .= '</ul>';
355 355
 
356
-		echo json_encode( array( 'results' => $user_list ) );
356
+		echo json_encode(array('results' => $user_list));
357 357
 
358 358
 	}
359 359
 	die();
360 360
 }
361 361
 
362
-add_action( 'wp_ajax_give_search_users', 'give_ajax_search_users' );
362
+add_action('wp_ajax_give_search_users', 'give_ajax_search_users');
363 363
 
364 364
 
365 365
 /**
@@ -371,32 +371,32 @@  discard block
 block discarded – undo
371 371
  */
372 372
 function give_check_for_form_price_variations() {
373 373
 
374
-	if ( ! current_user_can( 'edit_give_forms', get_current_user_id() ) ) {
375
-		die( '-1' );
374
+	if ( ! current_user_can('edit_give_forms', get_current_user_id())) {
375
+		die('-1');
376 376
 	}
377 377
 
378
-	$form_id = intval( $_POST['form_id'] );
379
-	$form    = get_post( $form_id );
378
+	$form_id = intval($_POST['form_id']);
379
+	$form    = get_post($form_id);
380 380
 
381
-	if ( 'give_forms' != $form->post_type ) {
382
-		die( '-2' );
381
+	if ('give_forms' != $form->post_type) {
382
+		die('-2');
383 383
 	}
384 384
 
385
-	if ( give_has_variable_prices( $form_id ) ) {
386
-		$variable_prices = give_get_variable_prices( $form_id );
385
+	if (give_has_variable_prices($form_id)) {
386
+		$variable_prices = give_get_variable_prices($form_id);
387 387
 
388
-		if ( $variable_prices ) {
388
+		if ($variable_prices) {
389 389
 			$ajax_response = '<select class="give_price_options_select give-select give-select" name="give_price_option">';
390 390
 
391
-			if ( isset( $_POST['all_prices'] ) ) {
392
-				$ajax_response .= '<option value="">' . esc_html__( 'All Levels', 'give' ) . '</option>';
391
+			if (isset($_POST['all_prices'])) {
392
+				$ajax_response .= '<option value="">'.esc_html__('All Levels', 'give').'</option>';
393 393
 			}
394 394
 
395
-			foreach ( $variable_prices as $key => $price ) {
395
+			foreach ($variable_prices as $key => $price) {
396 396
 
397
-				$level_text = ! empty( $price['_give_text'] ) ? esc_html( $price['_give_text'] ) : give_currency_filter( give_format_amount( $price['_give_amount'] ) );
397
+				$level_text = ! empty($price['_give_text']) ? esc_html($price['_give_text']) : give_currency_filter(give_format_amount($price['_give_amount']));
398 398
 				
399
-				$ajax_response .= '<option value="' . esc_attr( $price['_give_id']['level_id'] ) . '">' . $level_text . '</option>';
399
+				$ajax_response .= '<option value="'.esc_attr($price['_give_id']['level_id']).'">'.$level_text.'</option>';
400 400
 			}
401 401
 			$ajax_response .= '</select>';
402 402
 			echo $ajax_response;
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
 	give_die();
408 408
 }
409 409
 
410
-add_action( 'wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations' );
410
+add_action('wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations');
411 411
 
412 412
 
413 413
 /**
@@ -418,30 +418,30 @@  discard block
 block discarded – undo
418 418
  * @return void
419 419
  */
420 420
 function give_check_for_form_price_variations_html() {
421
-	if ( ! current_user_can( 'edit_give_payments', get_current_user_id() ) ) {
421
+	if ( ! current_user_can('edit_give_payments', get_current_user_id())) {
422 422
 		wp_die();
423 423
 	}
424 424
 
425
-	$form_id = intval( $_POST['form_id'] );
426
-	$payment_id = intval( $_POST['payment_id'] );
427
-	$form    = get_post( $form_id );
425
+	$form_id = intval($_POST['form_id']);
426
+	$payment_id = intval($_POST['payment_id']);
427
+	$form    = get_post($form_id);
428 428
 
429
-	if ( 'give_forms' != $form->post_type ) {
429
+	if ('give_forms' != $form->post_type) {
430 430
 		wp_die();
431 431
 	}
432 432
 
433
-    if ( ! give_has_variable_prices( $form_id ) ) {
434
-        esc_html_e( 'n/a', 'give' );
433
+    if ( ! give_has_variable_prices($form_id)) {
434
+        esc_html_e('n/a', 'give');
435 435
     } else {
436 436
         // Payment object.
437
-        $payment = new Give_Payment( $payment_id );
437
+        $payment = new Give_Payment($payment_id);
438 438
 
439 439
         // Payment meta.
440 440
         $payment_meta = $payment->get_meta();
441 441
 
442 442
 
443 443
         // Variable price dropdown options.
444
-        $variable_price_dropdown_option =  array(
444
+        $variable_price_dropdown_option = array(
445 445
             'id'                => $form_id,
446 446
             'name'              => 'give-variable-price',
447 447
             'chosen'            => true,
@@ -450,10 +450,10 @@  discard block
 block discarded – undo
450 450
         );
451 451
 
452 452
         // Render variable prices select tag html.
453
-        give_get_form_variable_price_dropdown( $variable_price_dropdown_option, true );
453
+        give_get_form_variable_price_dropdown($variable_price_dropdown_option, true);
454 454
     }
455 455
 
456 456
     give_die();
457 457
 }
458 458
 
459
-add_action( 'wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html' );
459
+add_action('wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html');
Please login to merge, or discard this patch.
includes/api/class-give-api.php 1 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
 
@@ -310,32 +310,32 @@  discard block
 block discarded – undo
310 310
 		$this->override = false;
311 311
 
312 312
 		// Make sure we have both user and api key
313
-		if ( ! empty( $wp_query->query_vars['give-api'] ) && ( $wp_query->query_vars['give-api'] != 'forms' || ! empty( $wp_query->query_vars['token'] ) ) ) {
313
+		if ( ! empty($wp_query->query_vars['give-api']) && ($wp_query->query_vars['give-api'] != 'forms' || ! empty($wp_query->query_vars['token']))) {
314 314
 
315
-			if ( empty( $wp_query->query_vars['token'] ) || empty( $wp_query->query_vars['key'] ) ) {
315
+			if (empty($wp_query->query_vars['token']) || empty($wp_query->query_vars['key'])) {
316 316
 				$this->missing_auth();
317 317
 			}
318 318
 
319 319
 			// Retrieve the user by public API key and ensure they exist
320
-			if ( ! ( $user = $this->get_user( $wp_query->query_vars['key'] ) ) ) {
320
+			if ( ! ($user = $this->get_user($wp_query->query_vars['key']))) {
321 321
 
322 322
 				$this->invalid_key();
323 323
 
324 324
 			} else {
325 325
 
326
-				$token  = urldecode( $wp_query->query_vars['token'] );
327
-				$secret = $this->get_user_secret_key( $user );
328
-				$public = urldecode( $wp_query->query_vars['key'] );
326
+				$token  = urldecode($wp_query->query_vars['token']);
327
+				$secret = $this->get_user_secret_key($user);
328
+				$public = urldecode($wp_query->query_vars['key']);
329 329
 
330
-				if ( hash_equals( md5( $secret . $public ), $token ) ) {
330
+				if (hash_equals(md5($secret.$public), $token)) {
331 331
 					$this->is_valid_request = true;
332 332
 				} else {
333 333
 					$this->invalid_auth();
334 334
 				}
335 335
 			}
336
-		} elseif ( ! empty( $wp_query->query_vars['give-api'] ) && $wp_query->query_vars['give-api'] == 'forms' ) {
336
+		} elseif ( ! empty($wp_query->query_vars['give-api']) && $wp_query->query_vars['give-api'] == 'forms') {
337 337
 			$this->is_valid_request = true;
338
-			$wp_query->set( 'key', 'public' );
338
+			$wp_query->set('key', 'public');
339 339
 		}
340 340
 	}
341 341
 
@@ -351,25 +351,25 @@  discard block
 block discarded – undo
351 351
 	 *
352 352
 	 * @return bool if user ID is found, false otherwise
353 353
 	 */
354
-	public function get_user( $key = '' ) {
354
+	public function get_user($key = '') {
355 355
 		global $wpdb, $wp_query;
356 356
 
357
-		if ( empty( $key ) ) {
358
-			$key = urldecode( $wp_query->query_vars['key'] );
357
+		if (empty($key)) {
358
+			$key = urldecode($wp_query->query_vars['key']);
359 359
 		}
360 360
 
361
-		if ( empty( $key ) ) {
361
+		if (empty($key)) {
362 362
 			return false;
363 363
 		}
364 364
 
365
-		$user = get_transient( md5( 'give_api_user_' . $key ) );
365
+		$user = get_transient(md5('give_api_user_'.$key));
366 366
 
367
-		if ( false === $user ) {
368
-			$user = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key ) );
369
-			set_transient( md5( 'give_api_user_' . $key ), $user, DAY_IN_SECONDS );
367
+		if (false === $user) {
368
+			$user = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key));
369
+			set_transient(md5('give_api_user_'.$key), $user, DAY_IN_SECONDS);
370 370
 		}
371 371
 
372
-		if ( $user != null ) {
372
+		if ($user != null) {
373 373
 			$this->user_id = $user;
374 374
 
375 375
 			return $user;
@@ -378,37 +378,37 @@  discard block
 block discarded – undo
378 378
 		return false;
379 379
 	}
380 380
 
381
-	public function get_user_public_key( $user_id = 0 ) {
381
+	public function get_user_public_key($user_id = 0) {
382 382
 		global $wpdb;
383 383
 
384
-		if ( empty( $user_id ) ) {
384
+		if (empty($user_id)) {
385 385
 			return '';
386 386
 		}
387 387
 
388
-		$cache_key       = md5( 'give_api_user_public_key' . $user_id );
389
-		$user_public_key = get_transient( $cache_key );
388
+		$cache_key       = md5('give_api_user_public_key'.$user_id);
389
+		$user_public_key = get_transient($cache_key);
390 390
 
391
-		if ( empty( $user_public_key ) ) {
392
-			$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 ) );
393
-			set_transient( $cache_key, $user_public_key, HOUR_IN_SECONDS );
391
+		if (empty($user_public_key)) {
392
+			$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));
393
+			set_transient($cache_key, $user_public_key, HOUR_IN_SECONDS);
394 394
 		}
395 395
 
396 396
 		return $user_public_key;
397 397
 	}
398 398
 
399
-	public function get_user_secret_key( $user_id = 0 ) {
399
+	public function get_user_secret_key($user_id = 0) {
400 400
 		global $wpdb;
401 401
 
402
-		if ( empty( $user_id ) ) {
402
+		if (empty($user_id)) {
403 403
 			return '';
404 404
 		}
405 405
 
406
-		$cache_key       = md5( 'give_api_user_secret_key' . $user_id );
407
-		$user_secret_key = get_transient( $cache_key );
406
+		$cache_key       = md5('give_api_user_secret_key'.$user_id);
407
+		$user_secret_key = get_transient($cache_key);
408 408
 
409
-		if ( empty( $user_secret_key ) ) {
410
-			$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 ) );
411
-			set_transient( $cache_key, $user_secret_key, HOUR_IN_SECONDS );
409
+		if (empty($user_secret_key)) {
410
+			$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));
411
+			set_transient($cache_key, $user_secret_key, HOUR_IN_SECONDS);
412 412
 		}
413 413
 
414 414
 		return $user_secret_key;
@@ -424,10 +424,10 @@  discard block
 block discarded – undo
424 424
 	 */
425 425
 	private function missing_auth() {
426 426
 		$error          = array();
427
-		$error['error'] = esc_html__( 'You must specify both a token and API key.', 'give' );
427
+		$error['error'] = esc_html__('You must specify both a token and API key.', 'give');
428 428
 
429 429
 		$this->data = $error;
430
-		$this->output( 401 );
430
+		$this->output(401);
431 431
 	}
432 432
 
433 433
 	/**
@@ -441,10 +441,10 @@  discard block
 block discarded – undo
441 441
 	 */
442 442
 	private function invalid_auth() {
443 443
 		$error          = array();
444
-		$error['error'] = esc_html__( 'Your request could not be authenticated.', 'give' );
444
+		$error['error'] = esc_html__('Your request could not be authenticated.', 'give');
445 445
 
446 446
 		$this->data = $error;
447
-		$this->output( 403 );
447
+		$this->output(403);
448 448
 	}
449 449
 
450 450
 	/**
@@ -458,10 +458,10 @@  discard block
 block discarded – undo
458 458
 	 */
459 459
 	private function invalid_key() {
460 460
 		$error          = array();
461
-		$error['error'] = esc_html__( 'Invalid API key.', 'give' );
461
+		$error['error'] = esc_html__('Invalid API key.', 'give');
462 462
 
463 463
 		$this->data = $error;
464
-		$this->output( 403 );
464
+		$this->output(403);
465 465
 	}
466 466
 
467 467
 	/**
@@ -474,10 +474,10 @@  discard block
 block discarded – undo
474 474
 	 */
475 475
 	private function invalid_version() {
476 476
 		$error          = array();
477
-		$error['error'] = esc_html__( 'Invalid API version.', 'give' );
477
+		$error['error'] = esc_html__('Invalid API version.', 'give');
478 478
 
479 479
 		$this->data = $error;
480
-		$this->output( 404 );
480
+		$this->output(404);
481 481
 	}
482 482
 
483 483
 	/**
@@ -493,10 +493,10 @@  discard block
 block discarded – undo
493 493
 		global $wp_query;
494 494
 
495 495
 		// Start logging how long the request takes for logging
496
-		$before = microtime( true );
496
+		$before = microtime(true);
497 497
 
498 498
 		// Check for give-api var. Get out if not present
499
-		if ( empty( $wp_query->query_vars['give-api'] ) ) {
499
+		if (empty($wp_query->query_vars['give-api'])) {
500 500
 			return;
501 501
 		}
502 502
 
@@ -510,45 +510,45 @@  discard block
 block discarded – undo
510 510
 		$this->validate_request();
511 511
 
512 512
 		// Only proceed if no errors have been noted
513
-		if ( ! $this->is_valid_request ) {
513
+		if ( ! $this->is_valid_request) {
514 514
 			return;
515 515
 		}
516 516
 
517
-		if ( ! defined( 'GIVE_DOING_API' ) ) {
518
-			define( 'GIVE_DOING_API', true );
517
+		if ( ! defined('GIVE_DOING_API')) {
518
+			define('GIVE_DOING_API', true);
519 519
 		}
520 520
 
521 521
 		$data         = array();
522 522
 		$this->routes = new $this->versions[$this->get_queried_version()];
523 523
 		$this->routes->validate_request();
524 524
 
525
-		switch ( $this->endpoint ) :
525
+		switch ($this->endpoint) :
526 526
 
527 527
 			case 'stats' :
528 528
 
529
-				$data = $this->routes->get_stats( array(
530
-					'type'      => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null,
531
-					'form'      => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null,
532
-					'date'      => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null,
533
-					'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null,
534
-					'enddate'   => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null
535
-				) );
529
+				$data = $this->routes->get_stats(array(
530
+					'type'      => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null,
531
+					'form'      => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null,
532
+					'date'      => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null,
533
+					'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null,
534
+					'enddate'   => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null
535
+				));
536 536
 
537 537
 				break;
538 538
 
539 539
 			case 'forms' :
540 540
 
541
-				$form = isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null;
541
+				$form = isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null;
542 542
 
543
-				$data = $this->routes->get_forms( $form );
543
+				$data = $this->routes->get_forms($form);
544 544
 
545 545
 				break;
546 546
 
547 547
 			case 'donors' :
548 548
 
549
-				$customer = isset( $wp_query->query_vars['donor'] ) ? $wp_query->query_vars['donor'] : null;
549
+				$customer = isset($wp_query->query_vars['donor']) ? $wp_query->query_vars['donor'] : null;
550 550
 
551
-				$data = $this->routes->get_customers( $customer );
551
+				$data = $this->routes->get_customers($customer);
552 552
 
553 553
 				break;
554 554
 
@@ -561,14 +561,14 @@  discard block
 block discarded – undo
561 561
 		endswitch;
562 562
 
563 563
 		// Allow extensions to setup their own return data
564
-		$this->data = apply_filters( 'give_api_output_data', $data, $this->endpoint, $this );
564
+		$this->data = apply_filters('give_api_output_data', $data, $this->endpoint, $this);
565 565
 
566
-		$after                       = microtime( true );
567
-		$request_time                = ( $after - $before );
566
+		$after                       = microtime(true);
567
+		$request_time                = ($after - $before);
568 568
 		$this->data['request_speed'] = $request_time;
569 569
 
570 570
 		// Log this API request, if enabled. We log it here because we have access to errors.
571
-		$this->log_request( $this->data );
571
+		$this->log_request($this->data);
572 572
 
573 573
 		// Send out data to the output function
574 574
 		$this->output();
@@ -598,25 +598,25 @@  discard block
 block discarded – undo
598 598
 		global $wp_query;
599 599
 
600 600
 		// Whitelist our query options
601
-		$accepted = apply_filters( 'give_api_valid_query_modes', array(
601
+		$accepted = apply_filters('give_api_valid_query_modes', array(
602 602
 			'stats',
603 603
 			'forms',
604 604
 			'donors',
605 605
 			'donations'
606
-		) );
606
+		));
607 607
 
608
-		$query = isset( $wp_query->query_vars['give-api'] ) ? $wp_query->query_vars['give-api'] : null;
609
-		$query = str_replace( $this->queried_version . '/', '', $query );
608
+		$query = isset($wp_query->query_vars['give-api']) ? $wp_query->query_vars['give-api'] : null;
609
+		$query = str_replace($this->queried_version.'/', '', $query);
610 610
 
611 611
 		$error = array();
612 612
 
613 613
 		// Make sure our query is valid
614
-		if ( ! in_array( $query, $accepted ) ) {
615
-			$error['error'] = esc_html__( 'Invalid query.', 'give' );
614
+		if ( ! in_array($query, $accepted)) {
615
+			$error['error'] = esc_html__('Invalid query.', 'give');
616 616
 
617 617
 			$this->data = $error;
618 618
 			// 400 is Bad Request
619
-			$this->output( 400 );
619
+			$this->output(400);
620 620
 		}
621 621
 
622 622
 		$this->endpoint = $query;
@@ -633,7 +633,7 @@  discard block
 block discarded – undo
633 633
 	public function get_paged() {
634 634
 		global $wp_query;
635 635
 
636
-		return isset( $wp_query->query_vars['page'] ) ? $wp_query->query_vars['page'] : 1;
636
+		return isset($wp_query->query_vars['page']) ? $wp_query->query_vars['page'] : 1;
637 637
 	}
638 638
 
639 639
 
@@ -648,13 +648,13 @@  discard block
 block discarded – undo
648 648
 	public function per_page() {
649 649
 		global $wp_query;
650 650
 
651
-		$per_page = isset( $wp_query->query_vars['number'] ) ? $wp_query->query_vars['number'] : 10;
651
+		$per_page = isset($wp_query->query_vars['number']) ? $wp_query->query_vars['number'] : 10;
652 652
 
653
-		if ( $per_page < 0 && $this->get_query_mode() == 'donors' ) {
653
+		if ($per_page < 0 && $this->get_query_mode() == 'donors') {
654 654
 			$per_page = 99999999;
655 655
 		} // Customers query doesn't support -1
656 656
 
657
-		return apply_filters( 'give_api_results_per_page', $per_page );
657
+		return apply_filters('give_api_results_per_page', $per_page);
658 658
 	}
659 659
 
660 660
 	/**
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
 	 *
668 668
 	 * @return array $dates
669 669
 	 */
670
-	public function get_dates( $args = array() ) {
670
+	public function get_dates($args = array()) {
671 671
 		$dates = array();
672 672
 
673 673
 		$defaults = array(
@@ -678,60 +678,60 @@  discard block
 block discarded – undo
678 678
 			'enddate'   => null
679 679
 		);
680 680
 
681
-		$args = wp_parse_args( $args, $defaults );
681
+		$args = wp_parse_args($args, $defaults);
682 682
 
683
-		$current_time = current_time( 'timestamp' );
683
+		$current_time = current_time('timestamp');
684 684
 
685
-		if ( 'range' === $args['date'] ) {
686
-			$startdate          = strtotime( $args['startdate'] );
687
-			$enddate            = strtotime( $args['enddate'] );
688
-			$dates['day_start'] = date( 'd', $startdate );
689
-			$dates['day_end']   = date( 'd', $enddate );
690
-			$dates['m_start']   = date( 'n', $startdate );
691
-			$dates['m_end']     = date( 'n', $enddate );
692
-			$dates['year']      = date( 'Y', $startdate );
693
-			$dates['year_end']  = date( 'Y', $enddate );
685
+		if ('range' === $args['date']) {
686
+			$startdate          = strtotime($args['startdate']);
687
+			$enddate            = strtotime($args['enddate']);
688
+			$dates['day_start'] = date('d', $startdate);
689
+			$dates['day_end']   = date('d', $enddate);
690
+			$dates['m_start']   = date('n', $startdate);
691
+			$dates['m_end']     = date('n', $enddate);
692
+			$dates['year']      = date('Y', $startdate);
693
+			$dates['year_end']  = date('Y', $enddate);
694 694
 		} else {
695 695
 			// Modify dates based on predefined ranges
696
-			switch ( $args['date'] ) :
696
+			switch ($args['date']) :
697 697
 
698 698
 				case 'this_month' :
699 699
 					$dates['day']     = null;
700
-					$dates['m_start'] = date( 'n', $current_time );
701
-					$dates['m_end']   = date( 'n', $current_time );
702
-					$dates['year']    = date( 'Y', $current_time );
700
+					$dates['m_start'] = date('n', $current_time);
701
+					$dates['m_end']   = date('n', $current_time);
702
+					$dates['year']    = date('Y', $current_time);
703 703
 					break;
704 704
 
705 705
 				case 'last_month' :
706 706
 					$dates['day']     = null;
707
-					$dates['m_start'] = date( 'n', $current_time ) == 1 ? 12 : date( 'n', $current_time ) - 1;
707
+					$dates['m_start'] = date('n', $current_time) == 1 ? 12 : date('n', $current_time) - 1;
708 708
 					$dates['m_end']   = $dates['m_start'];
709
-					$dates['year']    = date( 'n', $current_time ) == 1 ? date( 'Y', $current_time ) - 1 : date( 'Y', $current_time );
709
+					$dates['year']    = date('n', $current_time) == 1 ? date('Y', $current_time) - 1 : date('Y', $current_time);
710 710
 					break;
711 711
 
712 712
 				case 'today' :
713
-					$dates['day']     = date( 'd', $current_time );
714
-					$dates['m_start'] = date( 'n', $current_time );
715
-					$dates['m_end']   = date( 'n', $current_time );
716
-					$dates['year']    = date( 'Y', $current_time );
713
+					$dates['day']     = date('d', $current_time);
714
+					$dates['m_start'] = date('n', $current_time);
715
+					$dates['m_end']   = date('n', $current_time);
716
+					$dates['year']    = date('Y', $current_time);
717 717
 					break;
718 718
 
719 719
 				case 'yesterday' :
720 720
 
721
-					$year  = date( 'Y', $current_time );
722
-					$month = date( 'n', $current_time );
723
-					$day   = date( 'd', $current_time );
721
+					$year  = date('Y', $current_time);
722
+					$month = date('n', $current_time);
723
+					$day   = date('d', $current_time);
724 724
 
725
-					if ( $month == 1 && $day == 1 ) {
725
+					if ($month == 1 && $day == 1) {
726 726
 
727 727
 						$year -= 1;
728 728
 						$month = 12;
729
-						$day   = cal_days_in_month( CAL_GREGORIAN, $month, $year );
729
+						$day   = cal_days_in_month(CAL_GREGORIAN, $month, $year);
730 730
 
731
-					} elseif ( $month > 1 && $day == 1 ) {
731
+					} elseif ($month > 1 && $day == 1) {
732 732
 
733 733
 						$month -= 1;
734
-						$day = cal_days_in_month( CAL_GREGORIAN, $month, $year );
734
+						$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
735 735
 
736 736
 					} else {
737 737
 
@@ -747,65 +747,65 @@  discard block
 block discarded – undo
747 747
 					break;
748 748
 
749 749
 				case 'this_quarter' :
750
-					$month_now = date( 'n', $current_time );
750
+					$month_now = date('n', $current_time);
751 751
 
752 752
 					$dates['day'] = null;
753 753
 
754
-					if ( $month_now <= 3 ) {
754
+					if ($month_now <= 3) {
755 755
 
756 756
 						$dates['m_start'] = 1;
757 757
 						$dates['m_end']   = 3;
758
-						$dates['year']    = date( 'Y', $current_time );
758
+						$dates['year']    = date('Y', $current_time);
759 759
 
760
-					} else if ( $month_now <= 6 ) {
760
+					} else if ($month_now <= 6) {
761 761
 
762 762
 						$dates['m_start'] = 4;
763 763
 						$dates['m_end']   = 6;
764
-						$dates['year']    = date( 'Y', $current_time );
764
+						$dates['year']    = date('Y', $current_time);
765 765
 
766
-					} else if ( $month_now <= 9 ) {
766
+					} else if ($month_now <= 9) {
767 767
 
768 768
 						$dates['m_start'] = 7;
769 769
 						$dates['m_end']   = 9;
770
-						$dates['year']    = date( 'Y', $current_time );
770
+						$dates['year']    = date('Y', $current_time);
771 771
 
772 772
 					} else {
773 773
 
774 774
 						$dates['m_start'] = 10;
775 775
 						$dates['m_end']   = 12;
776
-						$dates['year']    = date( 'Y', $current_time );
776
+						$dates['year']    = date('Y', $current_time);
777 777
 
778 778
 					}
779 779
 					break;
780 780
 
781 781
 				case 'last_quarter' :
782
-					$month_now = date( 'n', $current_time );
782
+					$month_now = date('n', $current_time);
783 783
 
784 784
 					$dates['day'] = null;
785 785
 
786
-					if ( $month_now <= 3 ) {
786
+					if ($month_now <= 3) {
787 787
 
788 788
 						$dates['m_start'] = 10;
789 789
 						$dates['m_end']   = 12;
790
-						$dates['year']    = date( 'Y', $current_time ) - 1; // Previous year
790
+						$dates['year']    = date('Y', $current_time) - 1; // Previous year
791 791
 
792
-					} else if ( $month_now <= 6 ) {
792
+					} else if ($month_now <= 6) {
793 793
 
794 794
 						$dates['m_start'] = 1;
795 795
 						$dates['m_end']   = 3;
796
-						$dates['year']    = date( 'Y', $current_time );
796
+						$dates['year']    = date('Y', $current_time);
797 797
 
798
-					} else if ( $month_now <= 9 ) {
798
+					} else if ($month_now <= 9) {
799 799
 
800 800
 						$dates['m_start'] = 4;
801 801
 						$dates['m_end']   = 6;
802
-						$dates['year']    = date( 'Y', $current_time );
802
+						$dates['year']    = date('Y', $current_time);
803 803
 
804 804
 					} else {
805 805
 
806 806
 						$dates['m_start'] = 7;
807 807
 						$dates['m_end']   = 9;
808
-						$dates['year']    = date( 'Y', $current_time );
808
+						$dates['year']    = date('Y', $current_time);
809 809
 
810 810
 					}
811 811
 					break;
@@ -814,14 +814,14 @@  discard block
 block discarded – undo
814 814
 					$dates['day']     = null;
815 815
 					$dates['m_start'] = null;
816 816
 					$dates['m_end']   = null;
817
-					$dates['year']    = date( 'Y', $current_time );
817
+					$dates['year']    = date('Y', $current_time);
818 818
 					break;
819 819
 
820 820
 				case 'last_year' :
821 821
 					$dates['day']     = null;
822 822
 					$dates['m_start'] = null;
823 823
 					$dates['m_end']   = null;
824
-					$dates['year']    = date( 'Y', $current_time ) - 1;
824
+					$dates['year']    = date('Y', $current_time) - 1;
825 825
 					break;
826 826
 
827 827
 			endswitch;
@@ -835,7 +835,7 @@  discard block
 block discarded – undo
835 835
 		 * @param object $dates The dates used for retrieving earnings/donations
836 836
 		 */
837 837
 
838
-		return apply_filters( 'give_api_stat_dates', $dates );
838
+		return apply_filters('give_api_stat_dates', $dates);
839 839
 	}
840 840
 
841 841
 	/**
@@ -850,11 +850,11 @@  discard block
 block discarded – undo
850 850
 	 *
851 851
 	 * @return array $customers Multidimensional array of the customers
852 852
 	 */
853
-	public function get_customers( $customer = null ) {
853
+	public function get_customers($customer = null) {
854 854
 
855 855
 		$customers = array();
856 856
 		$error     = array();
857
-		if ( ! user_can( $this->user_id, 'view_give_sensitive_data' ) && ! $this->override ) {
857
+		if ( ! user_can($this->user_id, 'view_give_sensitive_data') && ! $this->override) {
858 858
 			return $customers;
859 859
 		}
860 860
 
@@ -862,64 +862,64 @@  discard block
 block discarded – undo
862 862
 
863 863
 		$paged    = $this->get_paged();
864 864
 		$per_page = $this->per_page();
865
-		$offset   = $per_page * ( $paged - 1 );
865
+		$offset   = $per_page * ($paged - 1);
866 866
 
867
-		if ( is_numeric( $customer ) ) {
867
+		if (is_numeric($customer)) {
868 868
 			$field = 'id';
869 869
 		} else {
870 870
 			$field = 'email';
871 871
 		}
872 872
 
873
-		$customer_query = Give()->customers->get_customers( array(
873
+		$customer_query = Give()->customers->get_customers(array(
874 874
 			'number' => $per_page,
875 875
 			'offset' => $offset,
876 876
 			$field   => $customer
877
-		) );
877
+		));
878 878
 		$customer_count = 0;
879 879
 
880
-		if ( $customer_query ) {
880
+		if ($customer_query) {
881 881
 
882
-			foreach ( $customer_query as $customer_obj ) {
882
+			foreach ($customer_query as $customer_obj) {
883 883
 
884
-				$names      = explode( ' ', $customer_obj->name );
885
-				$first_name = ! empty( $names[0] ) ? $names[0] : '';
884
+				$names      = explode(' ', $customer_obj->name);
885
+				$first_name = ! empty($names[0]) ? $names[0] : '';
886 886
 				$last_name  = '';
887
-				if ( ! empty( $names[1] ) ) {
888
-					unset( $names[0] );
889
-					$last_name = implode( ' ', $names );
887
+				if ( ! empty($names[1])) {
888
+					unset($names[0]);
889
+					$last_name = implode(' ', $names);
890 890
 				}
891 891
 
892
-				$customers['donors'][ $customer_count ]['info']['user_id']      = '';
893
-				$customers['donors'][ $customer_count ]['info']['username']     = '';
894
-				$customers['donors'][ $customer_count ]['info']['display_name'] = '';
895
-				$customers['donors'][ $customer_count ]['info']['customer_id']  = $customer_obj->id;
896
-				$customers['donors'][ $customer_count ]['info']['first_name']   = $first_name;
897
-				$customers['donors'][ $customer_count ]['info']['last_name']    = $last_name;
898
-				$customers['donors'][ $customer_count ]['info']['email']        = $customer_obj->email;
892
+				$customers['donors'][$customer_count]['info']['user_id']      = '';
893
+				$customers['donors'][$customer_count]['info']['username']     = '';
894
+				$customers['donors'][$customer_count]['info']['display_name'] = '';
895
+				$customers['donors'][$customer_count]['info']['customer_id']  = $customer_obj->id;
896
+				$customers['donors'][$customer_count]['info']['first_name']   = $first_name;
897
+				$customers['donors'][$customer_count]['info']['last_name']    = $last_name;
898
+				$customers['donors'][$customer_count]['info']['email']        = $customer_obj->email;
899 899
 
900
-				if ( ! empty( $customer_obj->user_id ) ) {
900
+				if ( ! empty($customer_obj->user_id)) {
901 901
 
902
-					$user_data = get_userdata( $customer_obj->user_id );
902
+					$user_data = get_userdata($customer_obj->user_id);
903 903
 
904 904
 					// Customer with registered account
905
-					$customers['donors'][ $customer_count ]['info']['user_id']      = $customer_obj->user_id;
906
-					$customers['donors'][ $customer_count ]['info']['username']     = $user_data->user_login;
907
-					$customers['donors'][ $customer_count ]['info']['display_name'] = $user_data->display_name;
905
+					$customers['donors'][$customer_count]['info']['user_id']      = $customer_obj->user_id;
906
+					$customers['donors'][$customer_count]['info']['username']     = $user_data->user_login;
907
+					$customers['donors'][$customer_count]['info']['display_name'] = $user_data->display_name;
908 908
 
909 909
 				}
910 910
 
911
-				$customers['donors'][ $customer_count ]['stats']['total_donations'] = $customer_obj->purchase_count;
912
-				$customers['donors'][ $customer_count ]['stats']['total_spent']     = $customer_obj->purchase_value;
911
+				$customers['donors'][$customer_count]['stats']['total_donations'] = $customer_obj->purchase_count;
912
+				$customers['donors'][$customer_count]['stats']['total_spent']     = $customer_obj->purchase_value;
913 913
 
914
-				$customer_count ++;
914
+				$customer_count++;
915 915
 
916 916
 			}
917 917
 
918
-		} elseif ( $customer ) {
918
+		} elseif ($customer) {
919 919
 
920 920
 			$error['error'] = sprintf(
921 921
 				/* translators: %s: customer */
922
-				esc_html__( 'Donor %s not found.', 'give' ),
922
+				esc_html__('Donor %s not found.', 'give'),
923 923
 				$customer
924 924
 			);
925 925
 
@@ -927,7 +927,7 @@  discard block
 block discarded – undo
927 927
 
928 928
 		} else {
929 929
 
930
-			$error['error'] = esc_html__( 'No donors found.', 'give' );
930
+			$error['error'] = esc_html__('No donors found.', 'give');
931 931
 
932 932
 			return $error;
933 933
 
@@ -946,38 +946,38 @@  discard block
 block discarded – undo
946 946
 	 *
947 947
 	 * @return array $customers Multidimensional array of the forms
948 948
 	 */
949
-	public function get_forms( $form = null ) {
949
+	public function get_forms($form = null) {
950 950
 
951 951
 		$forms = array();
952 952
 		$error = array();
953 953
 
954
-		if ( $form == null ) {
954
+		if ($form == null) {
955 955
 			$forms['forms'] = array();
956 956
 
957
-			$form_list = get_posts( array(
957
+			$form_list = get_posts(array(
958 958
 				'post_type'        => 'give_forms',
959 959
 				'posts_per_page'   => $this->per_page(),
960 960
 				'suppress_filters' => true,
961 961
 				'paged'            => $this->get_paged()
962
-			) );
962
+			));
963 963
 
964
-			if ( $form_list ) {
964
+			if ($form_list) {
965 965
 				$i = 0;
966
-				foreach ( $form_list as $form_info ) {
967
-					$forms['forms'][ $i ] = $this->get_form_data( $form_info );
968
-					$i ++;
966
+				foreach ($form_list as $form_info) {
967
+					$forms['forms'][$i] = $this->get_form_data($form_info);
968
+					$i++;
969 969
 				}
970 970
 			}
971 971
 		} else {
972
-			if ( get_post_type( $form ) == 'give_forms' ) {
973
-				$form_info = get_post( $form );
972
+			if (get_post_type($form) == 'give_forms') {
973
+				$form_info = get_post($form);
974 974
 
975
-				$forms['forms'][0] = $this->get_form_data( $form_info );
975
+				$forms['forms'][0] = $this->get_form_data($form_info);
976 976
 
977 977
 			} else {
978 978
 				$error['error'] = sprintf(
979 979
 					/* translators: %s: form */
980
-					esc_html__( 'Form %s not found.', 'give' ),
980
+					esc_html__('Form %s not found.', 'give'),
981 981
 					$form
982 982
 				);
983 983
 
@@ -997,7 +997,7 @@  discard block
 block discarded – undo
997 997
 	 *
998 998
 	 * @return array                Array of post data to return back in the API
999 999
 	 */
1000
-	private function get_form_data( $form_info ) {
1000
+	private function get_form_data($form_info) {
1001 1001
 
1002 1002
 		$form = array();
1003 1003
 
@@ -1007,50 +1007,50 @@  discard block
 block discarded – undo
1007 1007
 		$form['info']['create_date']   = $form_info->post_date;
1008 1008
 		$form['info']['modified_date'] = $form_info->post_modified;
1009 1009
 		$form['info']['status']        = $form_info->post_status;
1010
-		$form['info']['link']          = html_entity_decode( $form_info->guid );
1011
-		$form['info']['content']       = get_post_meta( $form_info->ID, '_give_form_content', true );
1012
-		$form['info']['thumbnail']     = wp_get_attachment_url( get_post_thumbnail_id( $form_info->ID ) );
1010
+		$form['info']['link']          = html_entity_decode($form_info->guid);
1011
+		$form['info']['content']       = get_post_meta($form_info->ID, '_give_form_content', true);
1012
+		$form['info']['thumbnail']     = wp_get_attachment_url(get_post_thumbnail_id($form_info->ID));
1013 1013
 
1014
-		if ( give_get_option( 'enable_categories' ) == 'on' ) {
1015
-			$form['info']['category'] = get_the_terms( $form_info, 'give_forms_category' );
1016
-			$form['info']['tags']     = get_the_terms( $form_info, 'give_forms_tag' );
1014
+		if (give_get_option('enable_categories') == 'on') {
1015
+			$form['info']['category'] = get_the_terms($form_info, 'give_forms_category');
1016
+			$form['info']['tags']     = get_the_terms($form_info, 'give_forms_tag');
1017 1017
 		}
1018
-		if ( give_get_option( 'enable_tags' ) == 'on' ) {
1019
-			$form['info']['tags'] = get_the_terms( $form_info, 'give_forms_tag' );
1018
+		if (give_get_option('enable_tags') == 'on') {
1019
+			$form['info']['tags'] = get_the_terms($form_info, 'give_forms_tag');
1020 1020
 		}
1021 1021
 
1022
-		if ( user_can( $this->user_id, 'view_give_reports' ) || $this->override ) {
1023
-			$form['stats']['total']['donations']           = give_get_form_sales_stats( $form_info->ID );
1024
-			$form['stats']['total']['earnings']            = give_get_form_earnings_stats( $form_info->ID );
1025
-			$form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales( $form_info->ID );
1026
-			$form['stats']['monthly_average']['earnings']  = give_get_average_monthly_form_earnings( $form_info->ID );
1022
+		if (user_can($this->user_id, 'view_give_reports') || $this->override) {
1023
+			$form['stats']['total']['donations']           = give_get_form_sales_stats($form_info->ID);
1024
+			$form['stats']['total']['earnings']            = give_get_form_earnings_stats($form_info->ID);
1025
+			$form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales($form_info->ID);
1026
+			$form['stats']['monthly_average']['earnings']  = give_get_average_monthly_form_earnings($form_info->ID);
1027 1027
 		}
1028 1028
 
1029 1029
 		$counter = 0;
1030
-		if ( give_has_variable_prices( $form_info->ID ) ) {
1031
-			foreach ( give_get_variable_prices( $form_info->ID ) as $price ) {
1032
-				$counter ++;
1030
+		if (give_has_variable_prices($form_info->ID)) {
1031
+			foreach (give_get_variable_prices($form_info->ID) as $price) {
1032
+				$counter++;
1033 1033
 				//muli-level item
1034
-				$level                                     = isset( $price['_give_text'] ) ? $price['_give_text'] : 'level-' . $counter;
1035
-				$form['pricing'][ sanitize_key( $level ) ] = $price['_give_amount'];
1034
+				$level                                     = isset($price['_give_text']) ? $price['_give_text'] : 'level-'.$counter;
1035
+				$form['pricing'][sanitize_key($level)] = $price['_give_amount'];
1036 1036
 
1037 1037
 			}
1038 1038
 		} else {
1039
-			$form['pricing']['amount'] = give_get_form_price( $form_info->ID );
1039
+			$form['pricing']['amount'] = give_get_form_price($form_info->ID);
1040 1040
 		}
1041 1041
 
1042
-		if ( user_can( $this->user_id, 'view_give_sensitive_data' ) || $this->override ) {
1042
+		if (user_can($this->user_id, 'view_give_sensitive_data') || $this->override) {
1043 1043
 
1044 1044
 			/**
1045 1045
 			 * Fires when generating API sensitive data.
1046 1046
 			 *
1047 1047
 			 * @since 1.1
1048 1048
 			 */
1049
-			do_action( 'give_api_sensitive_data' );
1049
+			do_action('give_api_sensitive_data');
1050 1050
 
1051 1051
 		}
1052 1052
 
1053
-		return apply_filters( 'give_api_forms_form', $form );
1053
+		return apply_filters('give_api_forms_form', $form);
1054 1054
 
1055 1055
 	}
1056 1056
 
@@ -1065,7 +1065,7 @@  discard block
 block discarded – undo
1065 1065
 	 *
1066 1066
 	 * @return array
1067 1067
 	 */
1068
-	public function get_stats( $args = array() ) {
1068
+	public function get_stats($args = array()) {
1069 1069
 		$defaults = array(
1070 1070
 			'type'      => null,
1071 1071
 			'form'      => null,
@@ -1074,9 +1074,9 @@  discard block
 block discarded – undo
1074 1074
 			'enddate'   => null
1075 1075
 		);
1076 1076
 
1077
-		$args = wp_parse_args( $args, $defaults );
1077
+		$args = wp_parse_args($args, $defaults);
1078 1078
 
1079
-		$dates = $this->get_dates( $args );
1079
+		$dates = $this->get_dates($args);
1080 1080
 
1081 1081
 		$stats    = array();
1082 1082
 		$earnings = array(
@@ -1087,41 +1087,41 @@  discard block
 block discarded – undo
1087 1087
 		);
1088 1088
 		$error    = array();
1089 1089
 
1090
-		if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) {
1090
+		if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) {
1091 1091
 			return $stats;
1092 1092
 		}
1093 1093
 
1094
-		if ( $args['type'] == 'donations' ) {
1094
+		if ($args['type'] == 'donations') {
1095 1095
 
1096
-			if ( $args['form'] == null ) {
1097
-				if ( $args['date'] == null ) {
1096
+			if ($args['form'] == null) {
1097
+				if ($args['date'] == null) {
1098 1098
 					$sales = $this->get_default_sales_stats();
1099
-				} elseif ( $args['date'] === 'range' ) {
1099
+				} elseif ($args['date'] === 'range') {
1100 1100
 					// Return sales for a date range
1101 1101
 
1102 1102
 					// Ensure the end date is later than the start date
1103
-					if ( $args['enddate'] < $args['startdate'] ) {
1104
-						$error['error'] = esc_html__( 'The end date must be later than the start date.', 'give' );
1103
+					if ($args['enddate'] < $args['startdate']) {
1104
+						$error['error'] = esc_html__('The end date must be later than the start date.', 'give');
1105 1105
 					}
1106 1106
 
1107 1107
 					// Ensure both the start and end date are specified
1108
-					if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) {
1109
-						$error['error'] = esc_html__( 'Invalid or no date range specified.', 'give' );
1108
+					if (empty($args['startdate']) || empty($args['enddate'])) {
1109
+						$error['error'] = esc_html__('Invalid or no date range specified.', 'give');
1110 1110
 					}
1111 1111
 
1112 1112
 					$total = 0;
1113 1113
 
1114 1114
 					// Loop through the years
1115 1115
 					$y = $dates['year'];
1116
-					while ( $y <= $dates['year_end'] ) :
1116
+					while ($y <= $dates['year_end']) :
1117 1117
 
1118
-						if ( $dates['year'] == $dates['year_end'] ) {
1118
+						if ($dates['year'] == $dates['year_end']) {
1119 1119
 							$month_start = $dates['m_start'];
1120 1120
 							$month_end   = $dates['m_end'];
1121
-						} elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) {
1121
+						} elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) {
1122 1122
 							$month_start = $dates['m_start'];
1123 1123
 							$month_end   = 12;
1124
-						} elseif ( $y == $dates['year_end'] ) {
1124
+						} elseif ($y == $dates['year_end']) {
1125 1125
 							$month_start = 1;
1126 1126
 							$month_end   = $dates['m_end'];
1127 1127
 						} else {
@@ -1130,113 +1130,113 @@  discard block
 block discarded – undo
1130 1130
 						}
1131 1131
 
1132 1132
 						$i = $month_start;
1133
-						while ( $i <= $month_end ) :
1133
+						while ($i <= $month_end) :
1134 1134
 
1135
-							if ( $i == $dates['m_start'] ) {
1135
+							if ($i == $dates['m_start']) {
1136 1136
 								$d = $dates['day_start'];
1137 1137
 							} else {
1138 1138
 								$d = 1;
1139 1139
 							}
1140 1140
 
1141
-							if ( $i == $dates['m_end'] ) {
1141
+							if ($i == $dates['m_end']) {
1142 1142
 								$num_of_days = $dates['day_end'];
1143 1143
 							} else {
1144
-								$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
1144
+								$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
1145 1145
 							}
1146 1146
 
1147
-							while ( $d <= $num_of_days ) :
1148
-								$sale_count = give_get_sales_by_date( $d, $i, $y );
1149
-								$date_key   = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) );
1150
-								if ( ! isset( $sales['sales'][ $date_key ] ) ) {
1151
-									$sales['sales'][ $date_key ] = 0;
1147
+							while ($d <= $num_of_days) :
1148
+								$sale_count = give_get_sales_by_date($d, $i, $y);
1149
+								$date_key   = date('Ymd', strtotime($y.'/'.$i.'/'.$d));
1150
+								if ( ! isset($sales['sales'][$date_key])) {
1151
+									$sales['sales'][$date_key] = 0;
1152 1152
 								}
1153
-								$sales['sales'][ $date_key ] += $sale_count;
1153
+								$sales['sales'][$date_key] += $sale_count;
1154 1154
 								$total += $sale_count;
1155
-								$d ++;
1155
+								$d++;
1156 1156
 							endwhile;
1157
-							$i ++;
1157
+							$i++;
1158 1158
 						endwhile;
1159 1159
 
1160
-						$y ++;
1160
+						$y++;
1161 1161
 					endwhile;
1162 1162
 
1163 1163
 					$sales['totals'] = $total;
1164 1164
 				} else {
1165
-					if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) {
1165
+					if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') {
1166 1166
 						$sales_count = 0;
1167 1167
 
1168 1168
 						// Loop through the months
1169 1169
 						$month = $dates['m_start'];
1170 1170
 
1171
-						while ( $month <= $dates['m_end'] ) :
1172
-							$sales_count += give_get_sales_by_date( null, $month, $dates['year'] );
1173
-							$month ++;
1171
+						while ($month <= $dates['m_end']) :
1172
+							$sales_count += give_get_sales_by_date(null, $month, $dates['year']);
1173
+							$month++;
1174 1174
 						endwhile;
1175 1175
 
1176
-						$sales['donations'][ $args['date'] ] = $sales_count;
1176
+						$sales['donations'][$args['date']] = $sales_count;
1177 1177
 					} else {
1178
-						$sales['donations'][ $args['date'] ] = give_get_sales_by_date( $dates['day'], $dates['m_start'], $dates['year'] );
1178
+						$sales['donations'][$args['date']] = give_get_sales_by_date($dates['day'], $dates['m_start'], $dates['year']);
1179 1179
 					}
1180 1180
 				}
1181
-			} elseif ( $args['form'] == 'all' ) {
1182
-				$forms = get_posts( array( 'post_type' => 'give_forms', 'nopaging' => true ) );
1181
+			} elseif ($args['form'] == 'all') {
1182
+				$forms = get_posts(array('post_type' => 'give_forms', 'nopaging' => true));
1183 1183
 				$i     = 0;
1184
-				foreach ( $forms as $form_info ) {
1185
-					$sales['donations'][ $i ] = array( $form_info->post_name => give_get_form_sales_stats( $form_info->ID ) );
1186
-					$i ++;
1184
+				foreach ($forms as $form_info) {
1185
+					$sales['donations'][$i] = array($form_info->post_name => give_get_form_sales_stats($form_info->ID));
1186
+					$i++;
1187 1187
 				}
1188 1188
 			} else {
1189
-				if ( get_post_type( $args['form'] ) == 'give_forms' ) {
1190
-					$form_info             = get_post( $args['form'] );
1191
-					$sales['donations'][0] = array( $form_info->post_name => give_get_form_sales_stats( $args['form'] ) );
1189
+				if (get_post_type($args['form']) == 'give_forms') {
1190
+					$form_info             = get_post($args['form']);
1191
+					$sales['donations'][0] = array($form_info->post_name => give_get_form_sales_stats($args['form']));
1192 1192
 				} else {
1193 1193
 					$error['error'] = sprintf(
1194 1194
 						/* translators: %s: form */
1195
-						esc_html__( 'Form %s not found.', 'give' ),
1195
+						esc_html__('Form %s not found.', 'give'),
1196 1196
 						$args['form']
1197 1197
 					);
1198 1198
 				}
1199 1199
 			}
1200 1200
 
1201
-			if ( ! empty( $error ) ) {
1201
+			if ( ! empty($error)) {
1202 1202
 				return $error;
1203 1203
 			}
1204 1204
 
1205 1205
 			return $sales;
1206 1206
 
1207
-		} elseif ( $args['type'] == 'earnings' ) {
1208
-			if ( $args['form'] == null ) {
1209
-				if ( $args['date'] == null ) {
1207
+		} elseif ($args['type'] == 'earnings') {
1208
+			if ($args['form'] == null) {
1209
+				if ($args['date'] == null) {
1210 1210
 					$earnings = $this->get_default_earnings_stats();
1211
-				} elseif ( $args['date'] === 'range' ) {
1211
+				} elseif ($args['date'] === 'range') {
1212 1212
 					// Return sales for a date range
1213 1213
 
1214 1214
 					// Ensure the end date is later than the start date
1215
-					if ( $args['enddate'] < $args['startdate'] ) {
1216
-						$error['error'] = esc_html__( 'The end date must be later than the start date.', 'give' );
1215
+					if ($args['enddate'] < $args['startdate']) {
1216
+						$error['error'] = esc_html__('The end date must be later than the start date.', 'give');
1217 1217
 					}
1218 1218
 
1219 1219
 					// Ensure both the start and end date are specified
1220
-					if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) {
1221
-						$error['error'] = esc_html__( 'Invalid or no date range specified.', 'give' );
1220
+					if (empty($args['startdate']) || empty($args['enddate'])) {
1221
+						$error['error'] = esc_html__('Invalid or no date range specified.', 'give');
1222 1222
 					}
1223 1223
 
1224 1224
 					$total = (float) 0.00;
1225 1225
 
1226 1226
 					// Loop through the years
1227 1227
 					$y = $dates['year'];
1228
-					if ( ! isset( $earnings['earnings'] ) ) {
1228
+					if ( ! isset($earnings['earnings'])) {
1229 1229
 						$earnings['earnings'] = array();
1230 1230
 					}
1231
-					while ( $y <= $dates['year_end'] ) :
1231
+					while ($y <= $dates['year_end']) :
1232 1232
 
1233
-						if ( $dates['year'] == $dates['year_end'] ) {
1233
+						if ($dates['year'] == $dates['year_end']) {
1234 1234
 							$month_start = $dates['m_start'];
1235 1235
 							$month_end   = $dates['m_end'];
1236
-						} elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) {
1236
+						} elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) {
1237 1237
 							$month_start = $dates['m_start'];
1238 1238
 							$month_end   = 12;
1239
-						} elseif ( $y == $dates['year_end'] ) {
1239
+						} elseif ($y == $dates['year_end']) {
1240 1240
 							$month_start = 1;
1241 1241
 							$month_end   = $dates['m_end'];
1242 1242
 						} else {
@@ -1245,92 +1245,92 @@  discard block
 block discarded – undo
1245 1245
 						}
1246 1246
 
1247 1247
 						$i = $month_start;
1248
-						while ( $i <= $month_end ) :
1248
+						while ($i <= $month_end) :
1249 1249
 
1250
-							if ( $i == $dates['m_start'] ) {
1250
+							if ($i == $dates['m_start']) {
1251 1251
 								$d = $dates['day_start'];
1252 1252
 							} else {
1253 1253
 								$d = 1;
1254 1254
 							}
1255 1255
 
1256
-							if ( $i == $dates['m_end'] ) {
1256
+							if ($i == $dates['m_end']) {
1257 1257
 								$num_of_days = $dates['day_end'];
1258 1258
 							} else {
1259
-								$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
1259
+								$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
1260 1260
 							}
1261 1261
 
1262
-							while ( $d <= $num_of_days ) :
1263
-								$earnings_stat = give_get_earnings_by_date( $d, $i, $y );
1264
-								$date_key      = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) );
1265
-								if ( ! isset( $earnings['earnings'][ $date_key ] ) ) {
1266
-									$earnings['earnings'][ $date_key ] = 0;
1262
+							while ($d <= $num_of_days) :
1263
+								$earnings_stat = give_get_earnings_by_date($d, $i, $y);
1264
+								$date_key      = date('Ymd', strtotime($y.'/'.$i.'/'.$d));
1265
+								if ( ! isset($earnings['earnings'][$date_key])) {
1266
+									$earnings['earnings'][$date_key] = 0;
1267 1267
 								}
1268
-								$earnings['earnings'][ $date_key ] += $earnings_stat;
1268
+								$earnings['earnings'][$date_key] += $earnings_stat;
1269 1269
 								$total += $earnings_stat;
1270
-								$d ++;
1270
+								$d++;
1271 1271
 							endwhile;
1272 1272
 
1273
-							$i ++;
1273
+							$i++;
1274 1274
 						endwhile;
1275 1275
 
1276
-						$y ++;
1276
+						$y++;
1277 1277
 					endwhile;
1278 1278
 
1279 1279
 					$earnings['totals'] = $total;
1280 1280
 				} else {
1281
-					if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) {
1281
+					if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') {
1282 1282
 						$earnings_count = (float) 0.00;
1283 1283
 
1284 1284
 						// Loop through the months
1285 1285
 						$month = $dates['m_start'];
1286 1286
 
1287
-						while ( $month <= $dates['m_end'] ) :
1288
-							$earnings_count += give_get_earnings_by_date( null, $month, $dates['year'] );
1289
-							$month ++;
1287
+						while ($month <= $dates['m_end']) :
1288
+							$earnings_count += give_get_earnings_by_date(null, $month, $dates['year']);
1289
+							$month++;
1290 1290
 						endwhile;
1291 1291
 
1292
-						$earnings['earnings'][ $args['date'] ] = $earnings_count;
1292
+						$earnings['earnings'][$args['date']] = $earnings_count;
1293 1293
 					} else {
1294
-						$earnings['earnings'][ $args['date'] ] = give_get_earnings_by_date( $dates['day'], $dates['m_start'], $dates['year'] );
1294
+						$earnings['earnings'][$args['date']] = give_get_earnings_by_date($dates['day'], $dates['m_start'], $dates['year']);
1295 1295
 					}
1296 1296
 				}
1297
-			} elseif ( $args['form'] == 'all' ) {
1298
-				$forms = get_posts( array( 'post_type' => 'give_forms', 'nopaging' => true ) );
1297
+			} elseif ($args['form'] == 'all') {
1298
+				$forms = get_posts(array('post_type' => 'give_forms', 'nopaging' => true));
1299 1299
 
1300 1300
 				$i = 0;
1301
-				foreach ( $forms as $form_info ) {
1302
-					$earnings['earnings'][ $i ] = array( $form_info->post_name => give_get_form_earnings_stats( $form_info->ID ) );
1303
-					$i ++;
1301
+				foreach ($forms as $form_info) {
1302
+					$earnings['earnings'][$i] = array($form_info->post_name => give_get_form_earnings_stats($form_info->ID));
1303
+					$i++;
1304 1304
 				}
1305 1305
 			} else {
1306
-				if ( get_post_type( $args['form'] ) == 'give_forms' ) {
1307
-					$form_info               = get_post( $args['form'] );
1308
-					$earnings['earnings'][0] = array( $form_info->post_name => give_get_form_earnings_stats( $args['form'] ) );
1306
+				if (get_post_type($args['form']) == 'give_forms') {
1307
+					$form_info               = get_post($args['form']);
1308
+					$earnings['earnings'][0] = array($form_info->post_name => give_get_form_earnings_stats($args['form']));
1309 1309
 				} else {
1310 1310
 					$error['error'] = sprintf(
1311 1311
 						/* translators: %s: form */
1312
-						esc_html__( 'Form %s not found.', 'give' ),
1312
+						esc_html__('Form %s not found.', 'give'),
1313 1313
 						$args['form']
1314 1314
 					);
1315 1315
 				}
1316 1316
 			}
1317 1317
 
1318
-			if ( ! empty( $error ) ) {
1318
+			if ( ! empty($error)) {
1319 1319
 				return $error;
1320 1320
 			}
1321 1321
 
1322 1322
 			return $earnings;
1323
-		} elseif ( $args['type'] == 'donors' ) {
1323
+		} elseif ($args['type'] == 'donors') {
1324 1324
 			$customers                          = new Give_DB_Customers();
1325 1325
 			$stats['donations']['total_donors'] = $customers->count();
1326 1326
 
1327 1327
 			return $stats;
1328 1328
 
1329
-		} elseif ( empty( $args['type'] ) ) {
1330
-			$stats = array_merge( $stats, $this->get_default_sales_stats() );
1331
-			$stats = array_merge( $stats, $this->get_default_earnings_stats() );
1329
+		} elseif (empty($args['type'])) {
1330
+			$stats = array_merge($stats, $this->get_default_sales_stats());
1331
+			$stats = array_merge($stats, $this->get_default_earnings_stats());
1332 1332
 
1333
-			return array( 'stats' => $stats );
1333
+			return array('stats' => $stats);
1334 1334
 		}
1335 1335
 	}
1336 1336
 
@@ -1346,18 +1346,18 @@  discard block
 block discarded – undo
1346 1346
 
1347 1347
 		$sales = array();
1348 1348
 
1349
-		if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) {
1349
+		if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) {
1350 1350
 			return $sales;
1351 1351
 		}
1352 1352
 
1353
-		if ( isset( $wp_query->query_vars['id'] ) ) {
1353
+		if (isset($wp_query->query_vars['id'])) {
1354 1354
 			$query   = array();
1355
-			$query[] = new Give_Payment( $wp_query->query_vars['id'] );
1356
-		} elseif ( isset( $wp_query->query_vars['purchasekey'] ) ) {
1355
+			$query[] = new Give_Payment($wp_query->query_vars['id']);
1356
+		} elseif (isset($wp_query->query_vars['purchasekey'])) {
1357 1357
 			$query   = array();
1358
-			$query[] = give_get_payment_by( 'key', $wp_query->query_vars['purchasekey'] );
1359
-		} elseif ( isset( $wp_query->query_vars['email'] ) ) {
1360
-			$args  = array(
1358
+			$query[] = give_get_payment_by('key', $wp_query->query_vars['purchasekey']);
1359
+		} elseif (isset($wp_query->query_vars['email'])) {
1360
+			$args = array(
1361 1361
 				'fields'     => 'ids',
1362 1362
 				'meta_key'   => '_give_payment_user_email',
1363 1363
 				'meta_value' => $wp_query->query_vars['email'],
@@ -1365,7 +1365,7 @@  discard block
 block discarded – undo
1365 1365
 				'page'       => $this->get_paged(),
1366 1366
 				'status'     => 'publish'
1367 1367
 			);
1368
-			$query = give_get_payments( $args );
1368
+			$query = give_get_payments($args);
1369 1369
 		} else {
1370 1370
 			$args  = array(
1371 1371
 				'fields' => 'ids',
@@ -1373,14 +1373,14 @@  discard block
 block discarded – undo
1373 1373
 				'page'   => $this->get_paged(),
1374 1374
 				'status' => 'publish'
1375 1375
 			);
1376
-			$query = give_get_payments( $args );
1376
+			$query = give_get_payments($args);
1377 1377
 		}
1378
-		if ( $query ) {
1378
+		if ($query) {
1379 1379
 			$i = 0;
1380
-			foreach ( $query as $payment ) {
1380
+			foreach ($query as $payment) {
1381 1381
 
1382
-				if ( is_numeric( $payment ) ) {
1383
-					$payment      = new Give_Payment( $payment );
1382
+				if (is_numeric($payment)) {
1383
+					$payment      = new Give_Payment($payment);
1384 1384
 					$payment_meta = $payment->get_meta();
1385 1385
 					$user_info    = $payment->user_info;
1386 1386
 				} else {
@@ -1390,40 +1390,40 @@  discard block
 block discarded – undo
1390 1390
 				$payment_meta = $payment->get_meta();
1391 1391
 				$user_info    = $payment->user_info;
1392 1392
 
1393
-				$first_name = isset( $user_info['first_name'] ) ? $user_info['first_name'] : '';
1394
-				$last_name  = isset( $user_info['last_name'] ) ? $user_info['last_name'] : '';
1395
-
1396
-				$sales['donations'][ $i ]['ID']             = $payment->number;
1397
-				$sales['donations'][ $i ]['transaction_id'] = $payment->transaction_id;
1398
-				$sales['donations'][ $i ]['key']            = $payment->key;
1399
-				$sales['donations'][ $i ]['total']          = $payment->total;
1400
-				$sales['donations'][ $i ]['gateway']        = $payment->gateway;
1401
-				$sales['donations'][ $i ]['name']           = $first_name . ' ' . $last_name;
1402
-				$sales['donations'][ $i ]['fname']          = $first_name;
1403
-				$sales['donations'][ $i ]['lname']          = $last_name;
1404
-				$sales['donations'][ $i ]['email']          = $payment->email;
1405
-				$sales['donations'][ $i ]['date']           = $payment->date;
1406
-
1407
-				$form_id  = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : $payment_meta;
1408
-				$price    = isset( $payment_meta['form_id'] ) ? give_get_form_price( $payment_meta['form_id'] ) : false;
1409
-				$price_id = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null;
1410
-
1411
-				$sales['donations'][ $i ]['form']['id']    = $form_id;
1412
-				$sales['donations'][ $i ]['form']['name']  = get_the_title( $payment_meta['form_id'] );
1413
-				$sales['donations'][ $i ]['form']['price'] = $price;
1414
-
1415
-				if ( give_has_variable_prices( $form_id ) ) {
1416
-					if ( isset( $payment_meta['price_id'] ) ) {
1417
-						$price_name                                     = give_get_price_option_name( $form_id, $payment_meta['price_id'], $payment->ID );
1418
-						$sales['donations'][ $i ]['form']['price_name'] = $price_name;
1419
-						$sales['donations'][ $i ]['form']['price_id']   = $price_id;
1420
-						$sales['donations'][ $i ]['form']['price']      = give_get_price_option_amount( $form_id, $price_id );
1393
+				$first_name = isset($user_info['first_name']) ? $user_info['first_name'] : '';
1394
+				$last_name  = isset($user_info['last_name']) ? $user_info['last_name'] : '';
1395
+
1396
+				$sales['donations'][$i]['ID']             = $payment->number;
1397
+				$sales['donations'][$i]['transaction_id'] = $payment->transaction_id;
1398
+				$sales['donations'][$i]['key']            = $payment->key;
1399
+				$sales['donations'][$i]['total']          = $payment->total;
1400
+				$sales['donations'][$i]['gateway']        = $payment->gateway;
1401
+				$sales['donations'][$i]['name']           = $first_name.' '.$last_name;
1402
+				$sales['donations'][$i]['fname']          = $first_name;
1403
+				$sales['donations'][$i]['lname']          = $last_name;
1404
+				$sales['donations'][$i]['email']          = $payment->email;
1405
+				$sales['donations'][$i]['date']           = $payment->date;
1406
+
1407
+				$form_id  = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : $payment_meta;
1408
+				$price    = isset($payment_meta['form_id']) ? give_get_form_price($payment_meta['form_id']) : false;
1409
+				$price_id = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null;
1410
+
1411
+				$sales['donations'][$i]['form']['id']    = $form_id;
1412
+				$sales['donations'][$i]['form']['name']  = get_the_title($payment_meta['form_id']);
1413
+				$sales['donations'][$i]['form']['price'] = $price;
1414
+
1415
+				if (give_has_variable_prices($form_id)) {
1416
+					if (isset($payment_meta['price_id'])) {
1417
+						$price_name                                     = give_get_price_option_name($form_id, $payment_meta['price_id'], $payment->ID);
1418
+						$sales['donations'][$i]['form']['price_name'] = $price_name;
1419
+						$sales['donations'][$i]['form']['price_id']   = $price_id;
1420
+						$sales['donations'][$i]['form']['price']      = give_get_price_option_amount($form_id, $price_id);
1421 1421
 
1422 1422
 					}
1423 1423
 				}
1424 1424
 
1425 1425
 				//Add custom meta to API
1426
-				foreach ( $payment_meta as $meta_key => $meta_value ) {
1426
+				foreach ($payment_meta as $meta_key => $meta_value) {
1427 1427
 
1428 1428
 					$exceptions = array(
1429 1429
 						'form_title',
@@ -1436,19 +1436,19 @@  discard block
 block discarded – undo
1436 1436
 					);
1437 1437
 
1438 1438
 					//Don't clutter up results with dupes
1439
-					if ( in_array( $meta_key, $exceptions ) ) {
1439
+					if (in_array($meta_key, $exceptions)) {
1440 1440
 						continue;
1441 1441
 					}
1442 1442
 
1443
-					$sales['donations'][ $i ]['payment_meta'][ $meta_key ] = $meta_value;
1443
+					$sales['donations'][$i]['payment_meta'][$meta_key] = $meta_value;
1444 1444
 
1445 1445
 				}
1446 1446
 
1447
-				$i ++;
1447
+				$i++;
1448 1448
 			}
1449 1449
 		}
1450 1450
 
1451
-		return apply_filters( 'give_api_donations_endpoint', $sales );
1451
+		return apply_filters('give_api_donations_endpoint', $sales);
1452 1452
 	}
1453 1453
 
1454 1454
 	/**
@@ -1464,9 +1464,9 @@  discard block
 block discarded – undo
1464 1464
 	public function get_output_format() {
1465 1465
 		global $wp_query;
1466 1466
 
1467
-		$format = isset( $wp_query->query_vars['format'] ) ? $wp_query->query_vars['format'] : 'json';
1467
+		$format = isset($wp_query->query_vars['format']) ? $wp_query->query_vars['format'] : 'json';
1468 1468
 
1469
-		return apply_filters( 'give_api_output_format', $format );
1469
+		return apply_filters('give_api_output_format', $format);
1470 1470
 	}
1471 1471
 
1472 1472
 
@@ -1483,8 +1483,8 @@  discard block
 block discarded – undo
1483 1483
 	 *
1484 1484
 	 * @return void
1485 1485
 	 */
1486
-	private function log_request( $data = array() ) {
1487
-		if ( ! $this->log_requests ) {
1486
+	private function log_request($data = array()) {
1487
+		if ( ! $this->log_requests) {
1488 1488
 			return;
1489 1489
 		}
1490 1490
 
@@ -1500,36 +1500,36 @@  discard block
 block discarded – undo
1500 1500
 
1501 1501
 		$query = array(
1502 1502
 			'give-api'    => $wp_query->query_vars['give-api'],
1503
-			'key'         => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null,
1504
-			'token'       => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null,
1505
-			'query'       => isset( $wp_query->query_vars['query'] ) ? $wp_query->query_vars['query'] : null,
1506
-			'type'        => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null,
1507
-			'form'        => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null,
1508
-			'customer'    => isset( $wp_query->query_vars['customer'] ) ? $wp_query->query_vars['customer'] : null,
1509
-			'date'        => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null,
1510
-			'startdate'   => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null,
1511
-			'enddate'     => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null,
1512
-			'id'          => isset( $wp_query->query_vars['id'] ) ? $wp_query->query_vars['id'] : null,
1513
-			'purchasekey' => isset( $wp_query->query_vars['purchasekey'] ) ? $wp_query->query_vars['purchasekey'] : null,
1514
-			'email'       => isset( $wp_query->query_vars['email'] ) ? $wp_query->query_vars['email'] : null,
1503
+			'key'         => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null,
1504
+			'token'       => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null,
1505
+			'query'       => isset($wp_query->query_vars['query']) ? $wp_query->query_vars['query'] : null,
1506
+			'type'        => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null,
1507
+			'form'        => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null,
1508
+			'customer'    => isset($wp_query->query_vars['customer']) ? $wp_query->query_vars['customer'] : null,
1509
+			'date'        => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null,
1510
+			'startdate'   => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null,
1511
+			'enddate'     => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null,
1512
+			'id'          => isset($wp_query->query_vars['id']) ? $wp_query->query_vars['id'] : null,
1513
+			'purchasekey' => isset($wp_query->query_vars['purchasekey']) ? $wp_query->query_vars['purchasekey'] : null,
1514
+			'email'       => isset($wp_query->query_vars['email']) ? $wp_query->query_vars['email'] : null,
1515 1515
 		);
1516 1516
 
1517 1517
 		$log_data = array(
1518 1518
 			'log_type'     => 'api_request',
1519
-			'post_excerpt' => http_build_query( $query ),
1520
-			'post_content' => ! empty( $data['error'] ) ? $data['error'] : '',
1519
+			'post_excerpt' => http_build_query($query),
1520
+			'post_content' => ! empty($data['error']) ? $data['error'] : '',
1521 1521
 		);
1522 1522
 
1523 1523
 		$log_meta = array(
1524 1524
 			'request_ip' => give_get_ip(),
1525 1525
 			'user'       => $this->user_id,
1526
-			'key'        => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null,
1527
-			'token'      => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null,
1526
+			'key'        => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null,
1527
+			'token'      => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null,
1528 1528
 			'time'       => $data['request_speed'],
1529 1529
 			'version'    => $this->get_queried_version()
1530 1530
 		);
1531 1531
 
1532
-		$give_logs->insert_log( $log_data, $log_meta );
1532
+		$give_logs->insert_log($log_data, $log_meta);
1533 1533
 	}
1534 1534
 
1535 1535
 
@@ -1553,7 +1553,7 @@  discard block
 block discarded – undo
1553 1553
 	 *
1554 1554
 	 * @param int $status_code
1555 1555
 	 */
1556
-	public function output( $status_code = 200 ) {
1556
+	public function output($status_code = 200) {
1557 1557
         /**
1558 1558
          * @var WP_Query $wp_query
1559 1559
          */
@@ -1561,7 +1561,7 @@  discard block
 block discarded – undo
1561 1561
 
1562 1562
 		$format = $this->get_output_format();
1563 1563
 
1564
-		status_header( $status_code );
1564
+		status_header($status_code);
1565 1565
 
1566 1566
 		/**
1567 1567
 		 * Fires before outputing the API.
@@ -1572,25 +1572,25 @@  discard block
 block discarded – undo
1572 1572
 		 * @param Give_API $this   The Give_API object.
1573 1573
 		 * @param string   $format Output format, XML or JSON. Default is JSON.
1574 1574
 		 */
1575
-		do_action( 'give_api_output_before', $this->data, $this, $format );
1575
+		do_action('give_api_output_before', $this->data, $this, $format);
1576 1576
 
1577
-		switch ( $format ) :
1577
+		switch ($format) :
1578 1578
 
1579 1579
 			case 'xml' :
1580 1580
 
1581
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/array2xml.php';
1582
-				$xml = Array2XML::createXML( 'give', $this->data );
1581
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/array2xml.php';
1582
+				$xml = Array2XML::createXML('give', $this->data);
1583 1583
 				echo $xml->saveXML();
1584 1584
 
1585 1585
 				break;
1586 1586
 
1587 1587
 			case 'json' :
1588 1588
 
1589
-				header( 'Content-Type: application/json' );
1590
-				if ( ! empty( $this->pretty_print ) ) {
1591
-					echo json_encode( $this->data, $this->pretty_print );
1589
+				header('Content-Type: application/json');
1590
+				if ( ! empty($this->pretty_print)) {
1591
+					echo json_encode($this->data, $this->pretty_print);
1592 1592
 				} else {
1593
-					echo json_encode( $this->data );
1593
+					echo json_encode($this->data);
1594 1594
 				}
1595 1595
 
1596 1596
 				break;
@@ -1606,7 +1606,7 @@  discard block
 block discarded – undo
1606 1606
 				 * @param array    $data Response data to return.
1607 1607
 				 * @param Give_API $this The Give_API object.
1608 1608
 				 */
1609
-				do_action( "give_api_output_{$format}", $this->data, $this );
1609
+				do_action("give_api_output_{$format}", $this->data, $this);
1610 1610
 
1611 1611
 				break;
1612 1612
 
@@ -1621,7 +1621,7 @@  discard block
 block discarded – undo
1621 1621
 		 * @param Give_API $this   The Give_API object.
1622 1622
 		 * @param string   $format Output format, XML or JSON. Default is JSON.
1623 1623
 		 */
1624
-		do_action( 'give_api_output_after', $this->data, $this, $format );
1624
+		do_action('give_api_output_after', $this->data, $this, $format);
1625 1625
 
1626 1626
 		give_die();
1627 1627
 	}
@@ -1638,37 +1638,37 @@  discard block
 block discarded – undo
1638 1638
 	 *
1639 1639
 	 * @return void
1640 1640
 	 */
1641
-	function user_key_field( $user ) {
1641
+	function user_key_field($user) {
1642 1642
 
1643
-		if ( ( give_get_option( 'api_allow_user_keys', false ) || current_user_can( 'manage_give_settings' ) ) && current_user_can( 'edit_user', $user->ID ) ) {
1644
-			$user = get_userdata( $user->ID );
1643
+		if ((give_get_option('api_allow_user_keys', false) || current_user_can('manage_give_settings')) && current_user_can('edit_user', $user->ID)) {
1644
+			$user = get_userdata($user->ID);
1645 1645
 			?>
1646 1646
 			<table class="form-table">
1647 1647
 				<tbody>
1648 1648
 				<tr>
1649 1649
 					<th>
1650
-						<?php esc_html_e( 'Give API Keys', 'give' ); ?>
1650
+						<?php esc_html_e('Give API Keys', 'give'); ?>
1651 1651
 					</th>
1652 1652
 					<td>
1653 1653
 						<?php
1654
-						$public_key = $this->get_user_public_key( $user->ID );
1655
-						$secret_key = $this->get_user_secret_key( $user->ID );
1654
+						$public_key = $this->get_user_public_key($user->ID);
1655
+						$secret_key = $this->get_user_secret_key($user->ID);
1656 1656
 						?>
1657
-						<?php if ( empty( $user->give_user_public_key ) ) { ?>
1657
+						<?php if (empty($user->give_user_public_key)) { ?>
1658 1658
 							<input name="give_set_api_key" type="checkbox" id="give_set_api_key" value="0"/>
1659
-							<span class="description"><?php esc_html_e( 'Generate API Key', 'give' ); ?></span>
1659
+							<span class="description"><?php esc_html_e('Generate API Key', 'give'); ?></span>
1660 1660
 						<?php } else { ?>
1661
-							<strong style="display:inline-block; width: 125px;"><?php esc_html_e( 'Public key:', 'give' ); ?>&nbsp;</strong>
1662
-							<input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr( $public_key ); ?>"/>
1661
+							<strong style="display:inline-block; width: 125px;"><?php esc_html_e('Public key:', 'give'); ?>&nbsp;</strong>
1662
+							<input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr($public_key); ?>"/>
1663 1663
 							<br/>
1664
-							<strong style="display:inline-block; width: 125px;"><?php esc_html_e( 'Secret key:', 'give' ); ?>&nbsp;</strong>
1665
-							<input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr( $secret_key ); ?>"/>
1664
+							<strong style="display:inline-block; width: 125px;"><?php esc_html_e('Secret key:', 'give'); ?>&nbsp;</strong>
1665
+							<input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr($secret_key); ?>"/>
1666 1666
 							<br/>
1667
-							<strong style="display:inline-block; width: 125px;"><?php esc_html_e( 'Token:', 'give' ); ?>&nbsp;</strong>
1668
-							<input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr( $this->get_token( $user->ID ) ); ?>"/>
1667
+							<strong style="display:inline-block; width: 125px;"><?php esc_html_e('Token:', 'give'); ?>&nbsp;</strong>
1668
+							<input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr($this->get_token($user->ID)); ?>"/>
1669 1669
 							<br/>
1670 1670
 							<input name="give_set_api_key" type="checkbox" id="give_set_api_key" value="0"/>
1671
-							<span class="description"><label for="give_set_api_key"><?php esc_html_e( 'Revoke API Keys', 'give' ); ?></label></span>
1671
+							<span class="description"><label for="give_set_api_key"><?php esc_html_e('Revoke API Keys', 'give'); ?></label></span>
1672 1672
 						<?php } ?>
1673 1673
 					</td>
1674 1674
 				</tr>
@@ -1687,69 +1687,69 @@  discard block
 block discarded – undo
1687 1687
 	 *
1688 1688
 	 * @return void
1689 1689
 	 */
1690
-	public function process_api_key( $args ) {
1690
+	public function process_api_key($args) {
1691 1691
 
1692
-		if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'give-api-nonce' ) ) {
1692
+		if ( ! wp_verify_nonce($_REQUEST['_wpnonce'], 'give-api-nonce')) {
1693 1693
 
1694
-			wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
1694
+			wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
1695 1695
 
1696 1696
 		}
1697 1697
 
1698
-		if ( empty( $args['user_id'] ) ) {
1699
-			wp_die( esc_html__( 'User ID Required.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 401 ) );
1698
+		if (empty($args['user_id'])) {
1699
+			wp_die(esc_html__('User ID Required.', 'give'), esc_html__('Error', 'give'), array('response' => 401));
1700 1700
 		}
1701 1701
 
1702
-		if ( is_numeric( $args['user_id'] ) ) {
1703
-			$user_id = isset( $args['user_id'] ) ? absint( $args['user_id'] ) : get_current_user_id();
1702
+		if (is_numeric($args['user_id'])) {
1703
+			$user_id = isset($args['user_id']) ? absint($args['user_id']) : get_current_user_id();
1704 1704
 		} else {
1705
-			$userdata = get_user_by( 'login', $args['user_id'] );
1705
+			$userdata = get_user_by('login', $args['user_id']);
1706 1706
 			$user_id  = $userdata->ID;
1707 1707
 		}
1708
-		$process = isset( $args['give_api_process'] ) ? strtolower( $args['give_api_process'] ) : false;
1708
+		$process = isset($args['give_api_process']) ? strtolower($args['give_api_process']) : false;
1709 1709
 
1710
-		if ( $user_id == get_current_user_id() && ! give_get_option( 'allow_user_api_keys' ) && ! current_user_can( 'manage_give_settings' ) ) {
1710
+		if ($user_id == get_current_user_id() && ! give_get_option('allow_user_api_keys') && ! current_user_can('manage_give_settings')) {
1711 1711
 			wp_die(
1712 1712
 				sprintf(
1713 1713
 					/* translators: %s: process */
1714
-					esc_html__( 'You do not have permission to %s API keys for this user.', 'give' ),
1714
+					esc_html__('You do not have permission to %s API keys for this user.', 'give'),
1715 1715
 					$process
1716 1716
 				),
1717
-				esc_html__( 'Error', 'give' ),
1718
-				array( 'response' => 403 )
1717
+				esc_html__('Error', 'give'),
1718
+				array('response' => 403)
1719 1719
 			);
1720
-		} elseif ( ! current_user_can( 'manage_give_settings' ) ) {
1720
+		} elseif ( ! current_user_can('manage_give_settings')) {
1721 1721
 			wp_die(
1722 1722
 				sprintf(
1723 1723
 					/* translators: %s: process */
1724
-					esc_html__( 'You do not have permission to %s API keys for this user.', 'give' ),
1724
+					esc_html__('You do not have permission to %s API keys for this user.', 'give'),
1725 1725
 					$process
1726 1726
 				),
1727
-				esc_html__( 'Error', 'give' ),
1728
-				array( 'response' => 403 )
1727
+				esc_html__('Error', 'give'),
1728
+				array('response' => 403)
1729 1729
 			);
1730 1730
 		}
1731 1731
 
1732
-		switch ( $process ) {
1732
+		switch ($process) {
1733 1733
 			case 'generate':
1734
-				if ( $this->generate_api_key( $user_id ) ) {
1735
-					delete_transient( 'give_total_api_keys' );
1736
-					wp_redirect( add_query_arg( 'give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) );
1734
+				if ($this->generate_api_key($user_id)) {
1735
+					delete_transient('give_total_api_keys');
1736
+					wp_redirect(add_query_arg('give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-settings&tab=api'));
1737 1737
 					exit();
1738 1738
 				} else {
1739
-					wp_redirect( add_query_arg( 'give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) );
1739
+					wp_redirect(add_query_arg('give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-settings&tab=api'));
1740 1740
 					exit();
1741 1741
 				}
1742 1742
 				break;
1743 1743
 			case 'regenerate':
1744
-				$this->generate_api_key( $user_id, true );
1745
-				delete_transient( 'give_total_api_keys' );
1746
-				wp_redirect( add_query_arg( 'give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) );
1744
+				$this->generate_api_key($user_id, true);
1745
+				delete_transient('give_total_api_keys');
1746
+				wp_redirect(add_query_arg('give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-settings&tab=api'));
1747 1747
 				exit();
1748 1748
 				break;
1749 1749
 			case 'revoke':
1750
-				$this->revoke_api_key( $user_id );
1751
-				delete_transient( 'give_total_api_keys' );
1752
-				wp_redirect( add_query_arg( 'give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) );
1750
+				$this->revoke_api_key($user_id);
1751
+				delete_transient('give_total_api_keys');
1752
+				wp_redirect(add_query_arg('give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-settings&tab=api'));
1753 1753
 				exit();
1754 1754
 				break;
1755 1755
 			default;
@@ -1768,34 +1768,34 @@  discard block
 block discarded – undo
1768 1768
 	 *
1769 1769
 	 * @return boolean True if (re)generated succesfully, false otherwise.
1770 1770
 	 */
1771
-	public function generate_api_key( $user_id = 0, $regenerate = false ) {
1771
+	public function generate_api_key($user_id = 0, $regenerate = false) {
1772 1772
 
1773
-		if ( empty( $user_id ) ) {
1773
+		if (empty($user_id)) {
1774 1774
 			return false;
1775 1775
 		}
1776 1776
 
1777
-		$user = get_userdata( $user_id );
1777
+		$user = get_userdata($user_id);
1778 1778
 
1779
-		if ( ! $user ) {
1779
+		if ( ! $user) {
1780 1780
 			return false;
1781 1781
 		}
1782 1782
 
1783
-		$public_key = $this->get_user_public_key( $user_id );
1784
-		$secret_key = $this->get_user_secret_key( $user_id );
1783
+		$public_key = $this->get_user_public_key($user_id);
1784
+		$secret_key = $this->get_user_secret_key($user_id);
1785 1785
 
1786
-		if ( empty( $public_key ) || $regenerate == true ) {
1787
-			$new_public_key = $this->generate_public_key( $user->user_email );
1788
-			$new_secret_key = $this->generate_private_key( $user->ID );
1786
+		if (empty($public_key) || $regenerate == true) {
1787
+			$new_public_key = $this->generate_public_key($user->user_email);
1788
+			$new_secret_key = $this->generate_private_key($user->ID);
1789 1789
 		} else {
1790 1790
 			return false;
1791 1791
 		}
1792 1792
 
1793
-		if ( $regenerate == true ) {
1794
-			$this->revoke_api_key( $user->ID );
1793
+		if ($regenerate == true) {
1794
+			$this->revoke_api_key($user->ID);
1795 1795
 		}
1796 1796
 
1797
-		update_user_meta( $user_id, $new_public_key, 'give_user_public_key' );
1798
-		update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' );
1797
+		update_user_meta($user_id, $new_public_key, 'give_user_public_key');
1798
+		update_user_meta($user_id, $new_secret_key, 'give_user_secret_key');
1799 1799
 
1800 1800
 		return true;
1801 1801
 	}
@@ -1810,26 +1810,26 @@  discard block
 block discarded – undo
1810 1810
 	 *
1811 1811
 	 * @return string
1812 1812
 	 */
1813
-	public function revoke_api_key( $user_id = 0 ) {
1813
+	public function revoke_api_key($user_id = 0) {
1814 1814
 
1815
-		if ( empty( $user_id ) ) {
1815
+		if (empty($user_id)) {
1816 1816
 			return false;
1817 1817
 		}
1818 1818
 
1819
-		$user = get_userdata( $user_id );
1819
+		$user = get_userdata($user_id);
1820 1820
 
1821
-		if ( ! $user ) {
1821
+		if ( ! $user) {
1822 1822
 			return false;
1823 1823
 		}
1824 1824
 
1825
-		$public_key = $this->get_user_public_key( $user_id );
1826
-		$secret_key = $this->get_user_secret_key( $user_id );
1827
-		if ( ! empty( $public_key ) ) {
1828
-			delete_transient( md5( 'give_api_user_' . $public_key ) );
1829
-			delete_transient( md5( 'give_api_user_public_key' . $user_id ) );
1830
-			delete_transient( md5( 'give_api_user_secret_key' . $user_id ) );
1831
-			delete_user_meta( $user_id, $public_key );
1832
-			delete_user_meta( $user_id, $secret_key );
1825
+		$public_key = $this->get_user_public_key($user_id);
1826
+		$secret_key = $this->get_user_secret_key($user_id);
1827
+		if ( ! empty($public_key)) {
1828
+			delete_transient(md5('give_api_user_'.$public_key));
1829
+			delete_transient(md5('give_api_user_public_key'.$user_id));
1830
+			delete_transient(md5('give_api_user_secret_key'.$user_id));
1831
+			delete_user_meta($user_id, $public_key);
1832
+			delete_user_meta($user_id, $secret_key);
1833 1833
 		} else {
1834 1834
 			return false;
1835 1835
 		}
@@ -1854,22 +1854,22 @@  discard block
 block discarded – undo
1854 1854
 	 *
1855 1855
 	 * @return void
1856 1856
 	 */
1857
-	public function update_key( $user_id ) {
1858
-		if ( current_user_can( 'edit_user', $user_id ) && isset( $_POST['give_set_api_key'] ) ) {
1857
+	public function update_key($user_id) {
1858
+		if (current_user_can('edit_user', $user_id) && isset($_POST['give_set_api_key'])) {
1859 1859
 
1860
-			$user = get_userdata( $user_id );
1860
+			$user = get_userdata($user_id);
1861 1861
 
1862
-			$public_key = $this->get_user_public_key( $user_id );
1863
-			$secret_key = $this->get_user_secret_key( $user_id );
1862
+			$public_key = $this->get_user_public_key($user_id);
1863
+			$secret_key = $this->get_user_secret_key($user_id);
1864 1864
 
1865
-			if ( empty( $public_key ) ) {
1866
-				$new_public_key = $this->generate_public_key( $user->user_email );
1867
-				$new_secret_key = $this->generate_private_key( $user->ID );
1865
+			if (empty($public_key)) {
1866
+				$new_public_key = $this->generate_public_key($user->user_email);
1867
+				$new_secret_key = $this->generate_private_key($user->ID);
1868 1868
 
1869
-				update_user_meta( $user_id, $new_public_key, 'give_user_public_key' );
1870
-				update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' );
1869
+				update_user_meta($user_id, $new_public_key, 'give_user_public_key');
1870
+				update_user_meta($user_id, $new_secret_key, 'give_user_secret_key');
1871 1871
 			} else {
1872
-				$this->revoke_api_key( $user_id );
1872
+				$this->revoke_api_key($user_id);
1873 1873
 			}
1874 1874
 		}
1875 1875
 	}
@@ -1884,9 +1884,9 @@  discard block
 block discarded – undo
1884 1884
 	 *
1885 1885
 	 * @return string
1886 1886
 	 */
1887
-	private function generate_public_key( $user_email = '' ) {
1888
-		$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
1889
-		$public   = hash( 'md5', $user_email . $auth_key . date( 'U' ) );
1887
+	private function generate_public_key($user_email = '') {
1888
+		$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
1889
+		$public   = hash('md5', $user_email.$auth_key.date('U'));
1890 1890
 
1891 1891
 		return $public;
1892 1892
 	}
@@ -1901,9 +1901,9 @@  discard block
 block discarded – undo
1901 1901
 	 *
1902 1902
 	 * @return string
1903 1903
 	 */
1904
-	private function generate_private_key( $user_id = 0 ) {
1905
-		$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
1906
-		$secret   = hash( 'md5', $user_id . $auth_key . date( 'U' ) );
1904
+	private function generate_private_key($user_id = 0) {
1905
+		$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
1906
+		$secret   = hash('md5', $user_id.$auth_key.date('U'));
1907 1907
 
1908 1908
 		return $secret;
1909 1909
 	}
@@ -1918,8 +1918,8 @@  discard block
 block discarded – undo
1918 1918
 	 *
1919 1919
 	 * @return string
1920 1920
 	 */
1921
-	public function get_token( $user_id = 0 ) {
1922
-		return hash( 'md5', $this->get_user_secret_key( $user_id ) . $this->get_user_public_key( $user_id ) );
1921
+	public function get_token($user_id = 0) {
1922
+		return hash('md5', $this->get_user_secret_key($user_id).$this->get_user_public_key($user_id));
1923 1923
 	}
1924 1924
 
1925 1925
 	/**
@@ -1933,9 +1933,9 @@  discard block
 block discarded – undo
1933 1933
 
1934 1934
 		// Default sales return
1935 1935
 		$sales                               = array();
1936
-		$sales['donations']['today']         = $this->stats->get_sales( 0, 'today' );
1937
-		$sales['donations']['current_month'] = $this->stats->get_sales( 0, 'this_month' );
1938
-		$sales['donations']['last_month']    = $this->stats->get_sales( 0, 'last_month' );
1936
+		$sales['donations']['today']         = $this->stats->get_sales(0, 'today');
1937
+		$sales['donations']['current_month'] = $this->stats->get_sales(0, 'this_month');
1938
+		$sales['donations']['last_month']    = $this->stats->get_sales(0, 'last_month');
1939 1939
 		$sales['donations']['totals']        = give_get_total_sales();
1940 1940
 
1941 1941
 		return $sales;
@@ -1952,9 +1952,9 @@  discard block
 block discarded – undo
1952 1952
 
1953 1953
 		// Default earnings return
1954 1954
 		$earnings                              = array();
1955
-		$earnings['earnings']['today']         = $this->stats->get_earnings( 0, 'today' );
1956
-		$earnings['earnings']['current_month'] = $this->stats->get_earnings( 0, 'this_month' );
1957
-		$earnings['earnings']['last_month']    = $this->stats->get_earnings( 0, 'last_month' );
1955
+		$earnings['earnings']['today']         = $this->stats->get_earnings(0, 'today');
1956
+		$earnings['earnings']['current_month'] = $this->stats->get_earnings(0, 'this_month');
1957
+		$earnings['earnings']['last_month']    = $this->stats->get_earnings(0, 'last_month');
1958 1958
 		$earnings['earnings']['totals']        = give_get_total_earnings();
1959 1959
 
1960 1960
 		return $earnings;
@@ -1974,25 +1974,25 @@  discard block
 block discarded – undo
1974 1974
 	 *
1975 1975
 	 * @return string            The API key/secret for the user supplied
1976 1976
 	 */
1977
-	public function api_key_backwards_compat( $check, $object_id, $meta_key, $single ) {
1977
+	public function api_key_backwards_compat($check, $object_id, $meta_key, $single) {
1978 1978
 
1979
-		if ( $meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key' ) {
1979
+		if ($meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key') {
1980 1980
 			return $check;
1981 1981
 		}
1982 1982
 
1983 1983
 		$return = $check;
1984 1984
 
1985
-		switch ( $meta_key ) {
1985
+		switch ($meta_key) {
1986 1986
 			case 'give_user_public_key':
1987
-				$return = Give()->api->get_user_public_key( $object_id );
1987
+				$return = Give()->api->get_user_public_key($object_id);
1988 1988
 				break;
1989 1989
 			case 'give_user_secret_key':
1990
-				$return = Give()->api->get_user_secret_key( $object_id );
1990
+				$return = Give()->api->get_user_secret_key($object_id);
1991 1991
 				break;
1992 1992
 		}
1993 1993
 
1994
-		if ( ! $single ) {
1995
-			$return = array( $return );
1994
+		if ( ! $single) {
1995
+			$return = array($return);
1996 1996
 		}
1997 1997
 
1998 1998
 		return $return;
Please login to merge, or discard this patch.
includes/api/class-give-api-v1.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 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
 
Please login to merge, or discard this patch.
includes/forms/widget.php 1 patch
Spacing   +49 added lines, -49 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
 
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
  *
20 20
  * @since 1.0
21 21
  */
22
-class Give_Forms_Widget extends WP_Widget{
22
+class Give_Forms_Widget extends WP_Widget {
23 23
 	/**
24 24
 	 * The widget class name
25 25
 	 *
@@ -30,19 +30,19 @@  discard block
 block discarded – undo
30 30
 	/**
31 31
 	 * Instantiate the class
32 32
 	 */
33
-	public function __construct(){
34
-		$this->self = get_class( $this );
33
+	public function __construct() {
34
+		$this->self = get_class($this);
35 35
 
36 36
 		parent::__construct(
37
-			strtolower( $this->self ),
38
-			esc_html__( 'Give - Donation Form', 'give' ),
37
+			strtolower($this->self),
38
+			esc_html__('Give - Donation Form', 'give'),
39 39
 			array(
40
-				'description' => esc_html__( 'Display a Give Donation Form in your theme\'s widget powered sidebar.', 'give' )
40
+				'description' => esc_html__('Display a Give Donation Form in your theme\'s widget powered sidebar.', 'give')
41 41
 			)
42 42
 		);
43 43
 
44
-		add_action( 'widgets_init',          array( $this, 'widget_init' ) );
45
-		add_action( 'admin_enqueue_scripts', array( $this, 'admin_widget_scripts' ) );
44
+		add_action('widgets_init', array($this, 'widget_init'));
45
+		add_action('admin_enqueue_scripts', array($this, 'admin_widget_scripts'));
46 46
 	}
47 47
 
48 48
 	/**
@@ -52,23 +52,23 @@  discard block
 block discarded – undo
52 52
 	 *
53 53
 	 * @return void
54 54
 	 */
55
-	public function admin_widget_scripts( $hook ){
55
+	public function admin_widget_scripts($hook) {
56 56
 		// Directories of assets
57
-		$js_dir     = GIVE_PLUGIN_URL . 'assets/js/admin/';
58
-		$js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/';
59
-		$css_dir    = GIVE_PLUGIN_URL . 'assets/css/';
57
+		$js_dir     = GIVE_PLUGIN_URL.'assets/js/admin/';
58
+		$js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/';
59
+		$css_dir    = GIVE_PLUGIN_URL.'assets/css/';
60 60
 
61 61
 		// Use minified libraries if SCRIPT_DEBUG is turned off
62
-		$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
62
+		$suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
63 63
 
64 64
 		// Widget Script
65
-		if ( $hook == 'widgets.php' ) {
65
+		if ($hook == 'widgets.php') {
66 66
 
67
-			wp_enqueue_style( 'give-qtip-css', $css_dir . 'jquery.qtip' . $suffix . '.css' );
67
+			wp_enqueue_style('give-qtip-css', $css_dir.'jquery.qtip'.$suffix.'.css');
68 68
 
69
-			wp_enqueue_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION );
69
+			wp_enqueue_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION);
70 70
 
71
-			wp_enqueue_script( 'give-admin-widgets-scripts', $js_dir . 'admin-widgets' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
71
+			wp_enqueue_script('give-admin-widgets-scripts', $js_dir.'admin-widgets'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
72 72
 		}
73 73
 	}
74 74
 
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
 	 *                        before_widget, and after_widget.
80 80
 	 * @param array $instance The settings for the particular instance of the widget.
81 81
 	 */
82
-	public function widget( $args, $instance ){
83
-		$title = !empty( $instance['title'] ) ? $instance['title'] : '';
84
-		$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
82
+	public function widget($args, $instance) {
83
+		$title = ! empty($instance['title']) ? $instance['title'] : '';
84
+		$title = apply_filters('widget_title', $title, $instance, $this->id_base);
85 85
 
86 86
 		echo $args['before_widget'];
87 87
 
@@ -90,11 +90,11 @@  discard block
 block discarded – undo
90 90
 		 *
91 91
 		 * @since 1.0
92 92
 		 */
93
-		do_action( 'give_before_forms_widget' );
93
+		do_action('give_before_forms_widget');
94 94
 
95
-		echo $title ? $args['before_title'] . $title . $args['after_title'] : '';
95
+		echo $title ? $args['before_title'].$title.$args['after_title'] : '';
96 96
 
97
-		give_get_donation_form( $instance );
97
+		give_get_donation_form($instance);
98 98
 
99 99
 		echo $args['after_widget'];
100 100
 
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 		 *
104 104
 		 * @since 1.0
105 105
 		 */
106
-		do_action( 'give_after_forms_widget' );
106
+		do_action('give_after_forms_widget');
107 107
 	}
108 108
 
109 109
 	/**
@@ -113,55 +113,55 @@  discard block
 block discarded – undo
113 113
 	 *
114 114
 	 * @return string
115 115
 	 */
116
-	public function form( $instance ){
116
+	public function form($instance) {
117 117
 		$defaults = array(
118 118
 			'title'        => '',
119 119
 			'id'           => '',
120 120
 			'float_labels' => '',
121 121
 		);
122 122
 
123
-		$instance = wp_parse_args( (array) $instance, $defaults );
123
+		$instance = wp_parse_args((array) $instance, $defaults);
124 124
 
125 125
 		// Query Give Forms
126 126
 		$args = array(
127 127
 			'post_type'      => 'give_forms',
128
-			'posts_per_page' => - 1,
128
+			'posts_per_page' => -1,
129 129
 			'post_status'    => 'publish',
130 130
 		);
131 131
 
132
-		$give_forms = get_posts( $args );
132
+		$give_forms = get_posts($args);
133 133
 
134 134
 		// Widget: Title
135 135
 
136 136
 		?><p>
137
-			<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'give' ); ?></label>
138
-			<input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo esc_attr( $instance['title'] ); ?>" /><br>
139
-			<small><?php esc_html_e( 'Leave blank to hide the widget title.', 'give' ); ?></small>
137
+			<label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('Title:', 'give'); ?></label>
138
+			<input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo esc_attr($instance['title']); ?>" /><br>
139
+			<small><?php esc_html_e('Leave blank to hide the widget title.', 'give'); ?></small>
140 140
 		</p><?php
141 141
 
142 142
 		// Widget: Give Form
143 143
 
144 144
 		?><p>
145
-			<label for="<?php echo esc_attr( $this->get_field_id( 'id' ) ); ?>"><?php esc_html_e( 'Give Form:', 'give' ); ?></label>
146
-			<select class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'id' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'id' ) ); ?>">
147
-				<option value="current"><?php esc_html_e( '- Select -', 'give' ); ?></option>
148
-				<?php foreach ( $give_forms as $give_form ) { ?>
149
-					<option <?php selected( absint( $instance['id'] ), $give_form->ID ); ?> value="<?php echo esc_attr( $give_form->ID ); ?>"><?php echo $give_form->post_title; ?></option>
145
+			<label for="<?php echo esc_attr($this->get_field_id('id')); ?>"><?php esc_html_e('Give Form:', 'give'); ?></label>
146
+			<select class="widefat" name="<?php echo esc_attr($this->get_field_name('id')); ?>" id="<?php echo esc_attr($this->get_field_id('id')); ?>">
147
+				<option value="current"><?php esc_html_e('- Select -', 'give'); ?></option>
148
+				<?php foreach ($give_forms as $give_form) { ?>
149
+					<option <?php selected(absint($instance['id']), $give_form->ID); ?> value="<?php echo esc_attr($give_form->ID); ?>"><?php echo $give_form->post_title; ?></option>
150 150
 				<?php } ?>
151 151
 			</select><br>
152
-			<small><?php esc_html_e( 'Select a Give Form to embed in this widget.', 'give' ); ?></small>
152
+			<small><?php esc_html_e('Select a Give Form to embed in this widget.', 'give'); ?></small>
153 153
 		</p><?php
154 154
 
155 155
 		// Widget: Floating Labels
156 156
 
157 157
 		?><p>
158
-			<label for="<?php echo esc_attr( $this->get_field_id( 'float_labels' ) ); ?>"><?php esc_html_e( 'Floating Labels:', 'give' ); ?></label>
159
-			<select class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'float_labels' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'float_labels' ) ); ?>">
160
-				<option value="" <?php selected( esc_attr( $instance['float_labels'] ), '' ) ?>><?php esc_html_e( '- Select -', 'give' ); ?></option>
161
-				<option value="enabled" <?php selected( esc_attr( $instance['float_labels'] ), 'enabled' ) ?>><?php esc_html_e( 'Enabled', 'give' ); ?></option>
162
-				<option value="disabled" <?php selected( esc_attr( $instance['float_labels'] ), 'disabled' ) ?>><?php esc_html_e( 'Disabled', 'give' ); ?></option>
158
+			<label for="<?php echo esc_attr($this->get_field_id('float_labels')); ?>"><?php esc_html_e('Floating Labels:', 'give'); ?></label>
159
+			<select class="widefat" name="<?php echo esc_attr($this->get_field_name('float_labels')); ?>" id="<?php echo esc_attr($this->get_field_id('float_labels')); ?>">
160
+				<option value="" <?php selected(esc_attr($instance['float_labels']), '') ?>><?php esc_html_e('- Select -', 'give'); ?></option>
161
+				<option value="enabled" <?php selected(esc_attr($instance['float_labels']), 'enabled') ?>><?php esc_html_e('Enabled', 'give'); ?></option>
162
+				<option value="disabled" <?php selected(esc_attr($instance['float_labels']), 'disabled') ?>><?php esc_html_e('Disabled', 'give'); ?></option>
163 163
 			</select><br>
164
-			<small><?php esc_html_e( 'Override the default floating labels setting for this form.', 'give' ); ?></small>
164
+			<small><?php esc_html_e('Override the default floating labels setting for this form.', 'give'); ?></small>
165 165
 		</p><?php
166 166
 	}
167 167
 
@@ -170,8 +170,8 @@  discard block
 block discarded – undo
170 170
 	 *
171 171
 	 * @return void
172 172
 	 */
173
-	function widget_init(){
174
-		register_widget( $this->self );
173
+	function widget_init() {
174
+		register_widget($this->self);
175 175
 	}
176 176
 
177 177
 	/**
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 	 *
183 183
 	 * @return array
184 184
 	 */
185
-	public function update( $new_instance, $old_instance ){
185
+	public function update($new_instance, $old_instance) {
186 186
 		$this->flush_widget_cache();
187 187
 
188 188
 		return $new_instance;
@@ -193,8 +193,8 @@  discard block
 block discarded – undo
193 193
 	 *
194 194
 	 * @return void
195 195
 	 */
196
-	public function flush_widget_cache(){
197
-		wp_cache_delete( $this->self, 'widget' );
196
+	public function flush_widget_cache() {
197
+		wp_cache_delete($this->self, 'widget');
198 198
 	}
199 199
 }
200 200
 
Please login to merge, or discard this patch.
includes/post-types.php 1 patch
Spacing   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -23,37 +23,37 @@  discard block
 block discarded – undo
23 23
 function give_setup_post_types() {
24 24
 
25 25
 	/** Give Forms Post Type */
26
-	$give_forms_singular = give_get_option( 'disable_forms_singular' ) !== 'on' ? true : false;
26
+	$give_forms_singular = give_get_option('disable_forms_singular') !== 'on' ? true : false;
27 27
 
28
-	$give_forms_archives = give_get_option( 'disable_forms_archives' ) !== 'on' ? true : false;
28
+	$give_forms_archives = give_get_option('disable_forms_archives') !== 'on' ? true : false;
29 29
 
30
-	$give_forms_slug = defined( 'GIVE_SLUG' ) ? GIVE_SLUG : 'donations';
30
+	$give_forms_slug = defined('GIVE_SLUG') ? GIVE_SLUG : 'donations';
31 31
 	//support for old 'GIVE_FORMS_SLUG' constant
32
-	if ( defined( 'GIVE_FORMS_SLUG' ) ) {
32
+	if (defined('GIVE_FORMS_SLUG')) {
33 33
 		$give_forms_slug = GIVE_FORMS_SLUG;
34 34
 	}
35 35
 
36
-	$give_forms_rewrite = defined( 'GIVE_DISABLE_FORMS_REWRITE' ) && GIVE_DISABLE_FORMS_REWRITE ? false : array(
36
+	$give_forms_rewrite = defined('GIVE_DISABLE_FORMS_REWRITE') && GIVE_DISABLE_FORMS_REWRITE ? false : array(
37 37
 		'slug'       => $give_forms_slug,
38 38
 		'with_front' => false
39 39
 	);
40 40
 
41
-	$give_forms_labels = apply_filters( 'give_forms_labels', array(
42
-		'name'               => esc_html__( 'Donation Forms', 'give' ),
43
-		'singular_name'      => esc_html__( 'Form', 'give' ),
44
-		'add_new'            => esc_html__( 'Add Form', 'give' ),
45
-		'add_new_item'       => esc_html__( 'Add New Donation Form', 'give' ),
46
-		'edit_item'          => esc_html__( 'Edit Donation Form', 'give' ),
47
-		'new_item'           => esc_html__( 'New Form', 'give' ),
48
-		'all_items'          => esc_html__( 'All Forms', 'give' ),
49
-		'view_item'          => esc_html__( 'View Form', 'give' ),
50
-		'search_items'       => esc_html__( 'Search Forms', 'give' ),
51
-		'not_found'          => esc_html__( 'No forms found.', 'give' ),
52
-		'not_found_in_trash' => esc_html__( 'No forms found in Trash.', 'give' ),
41
+	$give_forms_labels = apply_filters('give_forms_labels', array(
42
+		'name'               => esc_html__('Donation Forms', 'give'),
43
+		'singular_name'      => esc_html__('Form', 'give'),
44
+		'add_new'            => esc_html__('Add Form', 'give'),
45
+		'add_new_item'       => esc_html__('Add New Donation Form', 'give'),
46
+		'edit_item'          => esc_html__('Edit Donation Form', 'give'),
47
+		'new_item'           => esc_html__('New Form', 'give'),
48
+		'all_items'          => esc_html__('All Forms', 'give'),
49
+		'view_item'          => esc_html__('View Form', 'give'),
50
+		'search_items'       => esc_html__('Search Forms', 'give'),
51
+		'not_found'          => esc_html__('No forms found.', 'give'),
52
+		'not_found_in_trash' => esc_html__('No forms found in Trash.', 'give'),
53 53
 		'parent_item_colon'  => '',
54
-		'menu_name'          => apply_filters( 'give_menu_name', esc_html__( 'Donations', 'give' ) ),
55
-		'name_admin_bar'     => apply_filters( 'give_name_admin_bar_name', esc_html__( 'Donation Form', 'give' ) )
56
-	) );
54
+		'menu_name'          => apply_filters('give_menu_name', esc_html__('Donations', 'give')),
55
+		'name_admin_bar'     => apply_filters('give_name_admin_bar_name', esc_html__('Donation Form', 'give'))
56
+	));
57 57
 
58 58
 	//Default give_forms supports
59 59
 	$give_form_supports = array(
@@ -65,14 +65,14 @@  discard block
 block discarded – undo
65 65
 	);
66 66
 
67 67
 	//Has the user disabled the excerpt
68
-	if ( give_get_option( 'disable_forms_excerpt' ) === 'on' ) {
69
-		unset( $give_form_supports[2] );
68
+	if (give_get_option('disable_forms_excerpt') === 'on') {
69
+		unset($give_form_supports[2]);
70 70
 	}
71 71
 
72 72
 	//Has user disabled the featured image?
73
-	if ( give_get_option( 'disable_form_featured_img' ) === 'on' ) {
74
-		unset( $give_form_supports[1] );
75
-		remove_action( 'give_before_single_form_summary', 'give_show_form_images' );
73
+	if (give_get_option('disable_form_featured_img') === 'on') {
74
+		unset($give_form_supports[1]);
75
+		remove_action('give_before_single_form_summary', 'give_show_form_images');
76 76
 	}
77 77
 
78 78
 	$give_forms_args = array(
@@ -88,42 +88,42 @@  discard block
 block discarded – undo
88 88
 		'has_archive'        => $give_forms_archives,
89 89
 		'menu_icon'          => 'dashicons-give',
90 90
 		'hierarchical'       => false,
91
-		'supports'           => apply_filters( 'give_forms_supports', $give_form_supports ),
91
+		'supports'           => apply_filters('give_forms_supports', $give_form_supports),
92 92
 	);
93
-	register_post_type( 'give_forms', apply_filters( 'give_forms_post_type_args', $give_forms_args ) );
93
+	register_post_type('give_forms', apply_filters('give_forms_post_type_args', $give_forms_args));
94 94
 	
95 95
 	/** Donation Post Type */
96 96
 	$payment_labels = array(
97
-		'name'               => _x( 'Donations', 'post type general name', 'give' ),
98
-		'singular_name'      => _x( 'Donation', 'post type singular name', 'give' ),
99
-		'add_new'            => esc_html__( 'Add New', 'give' ),
100
-		'add_new_item'       => esc_html__( 'Add New Donation', 'give' ),
101
-		'edit_item'          => esc_html__( 'Edit Donation', 'give' ),
102
-		'new_item'           => esc_html__( 'New Donation', 'give' ),
103
-		'all_items'          => esc_html__( 'All Donations', 'give' ),
104
-		'view_item'          => esc_html__( 'View Donation', 'give' ),
105
-		'search_items'       => esc_html__( 'Search Donations', 'give' ),
106
-		'not_found'          => esc_html__( 'No donations found.', 'give' ),
107
-		'not_found_in_trash' => esc_html__( 'No donations found in Trash.', 'give' ),
97
+		'name'               => _x('Donations', 'post type general name', 'give'),
98
+		'singular_name'      => _x('Donation', 'post type singular name', 'give'),
99
+		'add_new'            => esc_html__('Add New', 'give'),
100
+		'add_new_item'       => esc_html__('Add New Donation', 'give'),
101
+		'edit_item'          => esc_html__('Edit Donation', 'give'),
102
+		'new_item'           => esc_html__('New Donation', 'give'),
103
+		'all_items'          => esc_html__('All Donations', 'give'),
104
+		'view_item'          => esc_html__('View Donation', 'give'),
105
+		'search_items'       => esc_html__('Search Donations', 'give'),
106
+		'not_found'          => esc_html__('No donations found.', 'give'),
107
+		'not_found_in_trash' => esc_html__('No donations found in Trash.', 'give'),
108 108
 		'parent_item_colon'  => '',
109
-		'menu_name'          => esc_html__( 'Donations', 'give' )
109
+		'menu_name'          => esc_html__('Donations', 'give')
110 110
 	);
111 111
 
112 112
 	$payment_args = array(
113
-		'labels'          => apply_filters( 'give_donation_labels', $payment_labels ),
113
+		'labels'          => apply_filters('give_donation_labels', $payment_labels),
114 114
 		'public'          => false,
115 115
 		'query_var'       => false,
116 116
 		'rewrite'         => false,
117 117
 		'map_meta_cap'    => true,
118 118
 		'capability_type' => 'give_payment',
119
-		'supports'        => array( 'title' ),
119
+		'supports'        => array('title'),
120 120
 		'can_export'      => true
121 121
 	);
122
-	register_post_type( 'give_payment', $payment_args );
122
+	register_post_type('give_payment', $payment_args);
123 123
 
124 124
 }
125 125
 
126
-add_action( 'init', 'give_setup_post_types', 1 );
126
+add_action('init', 'give_setup_post_types', 1);
127 127
 
128 128
 
129 129
 /**
@@ -136,30 +136,30 @@  discard block
 block discarded – undo
136 136
  */
137 137
 function give_setup_taxonomies() {
138 138
 
139
-	$slug = defined( 'GIVE_FORMS_SLUG' ) ? GIVE_FORMS_SLUG : 'donations';
139
+	$slug = defined('GIVE_FORMS_SLUG') ? GIVE_FORMS_SLUG : 'donations';
140 140
 
141 141
 	/** Categories */
142 142
 	$category_labels = array(
143
-		'name'              => _x( 'Form Categories', 'taxonomy general name', 'give' ),
144
-		'singular_name'     => _x( 'Category', 'taxonomy singular name', 'give' ),
145
-		'search_items'      => esc_html__( 'Search Categories', 'give' ),
146
-		'all_items'         => esc_html__( 'All Categories', 'give' ),
147
-		'parent_item'       => esc_html__( 'Parent Category', 'give' ),
148
-		'parent_item_colon' => esc_html__( 'Parent Category:', 'give' ),
149
-		'edit_item'         => esc_html__( 'Edit Category', 'give' ),
150
-		'update_item'       => esc_html__( 'Update Category', 'give' ),
151
-		'add_new_item'      => esc_html__( 'Add New Category', 'give' ),
152
-		'new_item_name'     => esc_html__( 'New Category Name', 'give' ),
153
-		'menu_name'         => esc_html__( 'Categories', 'give' ),
143
+		'name'              => _x('Form Categories', 'taxonomy general name', 'give'),
144
+		'singular_name'     => _x('Category', 'taxonomy singular name', 'give'),
145
+		'search_items'      => esc_html__('Search Categories', 'give'),
146
+		'all_items'         => esc_html__('All Categories', 'give'),
147
+		'parent_item'       => esc_html__('Parent Category', 'give'),
148
+		'parent_item_colon' => esc_html__('Parent Category:', 'give'),
149
+		'edit_item'         => esc_html__('Edit Category', 'give'),
150
+		'update_item'       => esc_html__('Update Category', 'give'),
151
+		'add_new_item'      => esc_html__('Add New Category', 'give'),
152
+		'new_item_name'     => esc_html__('New Category Name', 'give'),
153
+		'menu_name'         => esc_html__('Categories', 'give'),
154 154
 	);
155 155
 
156
-	$category_args = apply_filters( 'give_forms_category_args', array(
156
+	$category_args = apply_filters('give_forms_category_args', array(
157 157
 			'hierarchical' => true,
158
-			'labels'       => apply_filters( 'give_forms_category_labels', $category_labels ),
158
+			'labels'       => apply_filters('give_forms_category_labels', $category_labels),
159 159
 			'show_ui'      => true,
160 160
 			'query_var'    => 'give_forms_category',
161 161
 			'rewrite'      => array(
162
-				'slug'         => $slug . '/category',
162
+				'slug'         => $slug.'/category',
163 163
 				'with_front'   => false,
164 164
 				'hierarchical' => true
165 165
 			),
@@ -173,34 +173,34 @@  discard block
 block discarded – undo
173 173
 	);
174 174
 
175 175
 	//Does the user want categories?
176
-	if ( give_get_option( 'enable_categories' ) == 'on' ) {
177
-		register_taxonomy( 'give_forms_category', array( 'give_forms' ), $category_args );
178
-		register_taxonomy_for_object_type( 'give_forms_category', 'give_forms' );
176
+	if (give_get_option('enable_categories') == 'on') {
177
+		register_taxonomy('give_forms_category', array('give_forms'), $category_args);
178
+		register_taxonomy_for_object_type('give_forms_category', 'give_forms');
179 179
 	}
180 180
 
181 181
 
182 182
 	/** Tags */
183 183
 	$tag_labels = array(
184
-		'name'                  => _x( 'Form Tags', 'taxonomy general name', 'give' ),
185
-		'singular_name'         => _x( 'Tag', 'taxonomy singular name', 'give' ),
186
-		'search_items'          => esc_html__( 'Search Tags', 'give' ),
187
-		'all_items'             => esc_html__( 'All Tags', 'give' ),
188
-		'parent_item'           => esc_html__( 'Parent Tag', 'give' ),
189
-		'parent_item_colon'     => esc_html__( 'Parent Tag:', 'give' ),
190
-		'edit_item'             => esc_html__( 'Edit Tag', 'give' ),
191
-		'update_item'           => esc_html__( 'Update Tag', 'give' ),
192
-		'add_new_item'          => esc_html__( 'Add New Tag', 'give' ),
193
-		'new_item_name'         => esc_html__( 'New Tag Name', 'give' ),
194
-		'menu_name'             => esc_html__( 'Tags', 'give' ),
195
-		'choose_from_most_used' => esc_html__( 'Choose from most used tags.', 'give' ),
184
+		'name'                  => _x('Form Tags', 'taxonomy general name', 'give'),
185
+		'singular_name'         => _x('Tag', 'taxonomy singular name', 'give'),
186
+		'search_items'          => esc_html__('Search Tags', 'give'),
187
+		'all_items'             => esc_html__('All Tags', 'give'),
188
+		'parent_item'           => esc_html__('Parent Tag', 'give'),
189
+		'parent_item_colon'     => esc_html__('Parent Tag:', 'give'),
190
+		'edit_item'             => esc_html__('Edit Tag', 'give'),
191
+		'update_item'           => esc_html__('Update Tag', 'give'),
192
+		'add_new_item'          => esc_html__('Add New Tag', 'give'),
193
+		'new_item_name'         => esc_html__('New Tag Name', 'give'),
194
+		'menu_name'             => esc_html__('Tags', 'give'),
195
+		'choose_from_most_used' => esc_html__('Choose from most used tags.', 'give'),
196 196
 	);
197 197
 
198
-	$tag_args = apply_filters( 'give_forms_tag_args', array(
198
+	$tag_args = apply_filters('give_forms_tag_args', array(
199 199
 			'hierarchical' => false,
200
-			'labels'       => apply_filters( 'give_forms_tag_labels', $tag_labels ),
200
+			'labels'       => apply_filters('give_forms_tag_labels', $tag_labels),
201 201
 			'show_ui'      => true,
202 202
 			'query_var'    => 'give_forms_tag',
203
-			'rewrite'      => array( 'slug' => $slug . '/tag', 'with_front' => false, 'hierarchical' => true ),
203
+			'rewrite'      => array('slug' => $slug.'/tag', 'with_front' => false, 'hierarchical' => true),
204 204
 			'capabilities' => array(
205 205
 				'manage_terms' => 'manage_give_form_terms',
206 206
 				'edit_terms'   => 'edit_give_form_terms',
@@ -210,15 +210,15 @@  discard block
 block discarded – undo
210 210
 		)
211 211
 	);
212 212
 
213
-	if ( give_get_option( 'enable_tags' ) == 'on' ) {
214
-		register_taxonomy( 'give_forms_tag', array( 'give_forms' ), $tag_args );
215
-		register_taxonomy_for_object_type( 'give_forms_tag', 'give_forms' );
213
+	if (give_get_option('enable_tags') == 'on') {
214
+		register_taxonomy('give_forms_tag', array('give_forms'), $tag_args);
215
+		register_taxonomy_for_object_type('give_forms_tag', 'give_forms');
216 216
 	}
217 217
 
218 218
 
219 219
 }
220 220
 
221
-add_action( 'init', 'give_setup_taxonomies', 0 );
221
+add_action('init', 'give_setup_taxonomies', 0);
222 222
 
223 223
 
224 224
 /**
@@ -229,11 +229,11 @@  discard block
 block discarded – undo
229 229
  */
230 230
 function give_get_default_form_labels() {
231 231
 	$defaults = array(
232
-		'singular' => esc_html__( 'Form', 'give' ),
233
-		'plural'   => esc_html__( 'Forms', 'give' )
232
+		'singular' => esc_html__('Form', 'give'),
233
+		'plural'   => esc_html__('Forms', 'give')
234 234
 	);
235 235
 
236
-	return apply_filters( 'give_default_form_name', $defaults );
236
+	return apply_filters('give_default_form_name', $defaults);
237 237
 }
238 238
 
239 239
 /**
@@ -245,10 +245,10 @@  discard block
 block discarded – undo
245 245
  *
246 246
  * @return string $defaults['singular'] Singular label
247 247
  */
248
-function give_get_forms_label_singular( $lowercase = false ) {
248
+function give_get_forms_label_singular($lowercase = false) {
249 249
 	$defaults = give_get_default_form_labels();
250 250
 
251
-	return ( $lowercase ) ? strtolower( $defaults['singular'] ) : $defaults['singular'];
251
+	return ($lowercase) ? strtolower($defaults['singular']) : $defaults['singular'];
252 252
 }
253 253
 
254 254
 /**
@@ -257,10 +257,10 @@  discard block
 block discarded – undo
257 257
  * @since 1.0
258 258
  * @return string $defaults['plural'] Plural label
259 259
  */
260
-function give_get_forms_label_plural( $lowercase = false ) {
260
+function give_get_forms_label_plural($lowercase = false) {
261 261
 	$defaults = give_get_default_form_labels();
262 262
 
263
-	return ( $lowercase ) ? strtolower( $defaults['plural'] ) : $defaults['plural'];
263
+	return ($lowercase) ? strtolower($defaults['plural']) : $defaults['plural'];
264 264
 }
265 265
 
266 266
 /**
@@ -272,24 +272,24 @@  discard block
 block discarded – undo
272 272
  *
273 273
  * @return string $title New placeholder text
274 274
  */
275
-function give_change_default_title( $title ) {
275
+function give_change_default_title($title) {
276 276
 	// If a frontend plugin uses this filter (check extensions before changing this function)
277
-	if ( ! is_admin() ) {
278
-		$title = esc_html__( 'Enter form title here', 'give' );
277
+	if ( ! is_admin()) {
278
+		$title = esc_html__('Enter form title here', 'give');
279 279
 
280 280
 		return $title;
281 281
 	}
282 282
 
283 283
 	$screen = get_current_screen();
284 284
 
285
-	if ( 'give_forms' == $screen->post_type ) {
286
-		$title = esc_html__( 'Enter form title here', 'give' );
285
+	if ('give_forms' == $screen->post_type) {
286
+		$title = esc_html__('Enter form title here', 'give');
287 287
 	}
288 288
 
289 289
 	return $title;
290 290
 }
291 291
 
292
-add_filter( 'enter_title_here', 'give_change_default_title' );
292
+add_filter('enter_title_here', 'give_change_default_title');
293 293
 
294 294
 /**
295 295
  * Registers Custom Post Statuses which are used by the Payments
@@ -299,50 +299,50 @@  discard block
 block discarded – undo
299 299
  */
300 300
 function give_register_post_type_statuses() {
301 301
 	// Payment Statuses
302
-	register_post_status( 'refunded', array(
303
-		'label'                     => __( 'Refunded', 'give' ),
302
+	register_post_status('refunded', array(
303
+		'label'                     => __('Refunded', 'give'),
304 304
 		'public'                    => true,
305 305
 		'exclude_from_search'       => false,
306 306
 		'show_in_admin_all_list'    => true,
307 307
 		'show_in_admin_status_list' => true,
308
-		'label_count'               => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give' )
309
-	) );
310
-	register_post_status( 'failed', array(
311
-		'label'                     => __( 'Failed', 'give' ),
308
+		'label_count'               => _n_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give')
309
+	));
310
+	register_post_status('failed', array(
311
+		'label'                     => __('Failed', 'give'),
312 312
 		'public'                    => true,
313 313
 		'exclude_from_search'       => false,
314 314
 		'show_in_admin_all_list'    => true,
315 315
 		'show_in_admin_status_list' => true,
316
-		'label_count'               => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give' )
317
-	) );
318
-	register_post_status( 'revoked', array(
319
-		'label'                     => __( 'Revoked', 'give' ),
316
+		'label_count'               => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give')
317
+	));
318
+	register_post_status('revoked', array(
319
+		'label'                     => __('Revoked', 'give'),
320 320
 		'public'                    => true,
321 321
 		'exclude_from_search'       => false,
322 322
 		'show_in_admin_all_list'    => true,
323 323
 		'show_in_admin_status_list' => true,
324
-		'label_count'               => _n_noop( 'Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give' )
325
-	) );
326
-	register_post_status( 'cancelled', array(
327
-		'label'                     => __( 'Cancelled', 'give' ),
324
+		'label_count'               => _n_noop('Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give')
325
+	));
326
+	register_post_status('cancelled', array(
327
+		'label'                     => __('Cancelled', 'give'),
328 328
 		'public'                    => true,
329 329
 		'exclude_from_search'       => false,
330 330
 		'show_in_admin_all_list'    => true,
331 331
 		'show_in_admin_status_list' => true,
332
-		'label_count'               => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'give' )
333
-	) );
334
-	register_post_status( 'abandoned', array(
335
-		'label'                     => __( 'Abandoned', 'give' ),
332
+		'label_count'               => _n_noop('Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'give')
333
+	));
334
+	register_post_status('abandoned', array(
335
+		'label'                     => __('Abandoned', 'give'),
336 336
 		'public'                    => true,
337 337
 		'exclude_from_search'       => false,
338 338
 		'show_in_admin_all_list'    => true,
339 339
 		'show_in_admin_status_list' => true,
340
-		'label_count'               => _n_noop( 'Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give' )
341
-	) );
340
+		'label_count'               => _n_noop('Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give')
341
+	));
342 342
 
343 343
 }
344 344
 
345
-add_action( 'init', 'give_register_post_type_statuses' );
345
+add_action('init', 'give_register_post_type_statuses');
346 346
 
347 347
 /**
348 348
  * Updated Messages
@@ -355,42 +355,42 @@  discard block
 block discarded – undo
355 355
  *
356 356
  * @return array $messages New post updated messages
357 357
  */
358
-function give_updated_messages( $messages ) {
358
+function give_updated_messages($messages) {
359 359
 	global $post, $post_ID;
360 360
 
361
-	$url1 = '<a href="' . get_permalink( $post_ID ) . '">';
361
+	$url1 = '<a href="'.get_permalink($post_ID).'">';
362 362
 	$url2 = '</a>';
363 363
 
364 364
 	$messages['give_forms'] = array(
365
-		1 => sprintf( __( 'Form updated. %1$sView Form%2$s.', 'give' ), $url1, $url2 ),
366
-		4 => sprintf( __( 'Form updated. %1$sView Form%2$s.', 'give' ), $url1, $url2 ),
367
-		6 => sprintf( __( 'Form published. %1$sView Form%2$s.', 'give' ), $url1, $url2 ),
368
-		7 => sprintf( __( 'Form saved. %1$sView Form%2$s.', 'give' ), $url1, $url2 ),
369
-		8 => sprintf( __( 'Form submitted. %1$sView Form%2$s.', 'give' ), $url1, $url2 )
365
+		1 => sprintf(__('Form updated. %1$sView Form%2$s.', 'give'), $url1, $url2),
366
+		4 => sprintf(__('Form updated. %1$sView Form%2$s.', 'give'), $url1, $url2),
367
+		6 => sprintf(__('Form published. %1$sView Form%2$s.', 'give'), $url1, $url2),
368
+		7 => sprintf(__('Form saved. %1$sView Form%2$s.', 'give'), $url1, $url2),
369
+		8 => sprintf(__('Form submitted. %1$sView Form%2$s.', 'give'), $url1, $url2)
370 370
 	);
371 371
 
372 372
 	return $messages;
373 373
 }
374 374
 
375
-add_filter( 'post_updated_messages', 'give_updated_messages' );
375
+add_filter('post_updated_messages', 'give_updated_messages');
376 376
 
377 377
 
378 378
 /**
379 379
  * Setup Post Type Images
380 380
  */
381
-add_action( 'after_setup_theme', 'give_add_thumbnail_support', 10 );
381
+add_action('after_setup_theme', 'give_add_thumbnail_support', 10);
382 382
 
383 383
 /**
384 384
  * Ensure post thumbnail support is turned on
385 385
  */
386 386
 function give_add_thumbnail_support() {
387
-	if ( give_get_option( 'disable_form_featured_img' ) === 'on' ) {
387
+	if (give_get_option('disable_form_featured_img') === 'on') {
388 388
 		return;
389 389
 	}
390
-	if ( ! current_theme_supports( 'post-thumbnails' ) ) {
391
-		add_theme_support( 'post-thumbnails' );
390
+	if ( ! current_theme_supports('post-thumbnails')) {
391
+		add_theme_support('post-thumbnails');
392 392
 	}
393
-	add_post_type_support( 'give_forms', 'thumbnail' );
393
+	add_post_type_support('give_forms', 'thumbnail');
394 394
 }
395 395
 
396 396
 /**
@@ -402,19 +402,19 @@  discard block
 block discarded – undo
402 402
 function give_widgets_init() {
403 403
 
404 404
 	//Single Give Forms (disabled if single turned off in settings)
405
-	if ( give_get_option( 'disable_forms_singular' ) !== 'on' && give_get_option( 'disable_form_sidebar' ) !== 'on' ) {
405
+	if (give_get_option('disable_forms_singular') !== 'on' && give_get_option('disable_form_sidebar') !== 'on') {
406 406
 
407
-		register_sidebar( apply_filters( 'give_forms_single_sidebar', array(
408
-			'name'          => esc_html__( 'Give Single Form Sidebar', 'give' ),
407
+		register_sidebar(apply_filters('give_forms_single_sidebar', array(
408
+			'name'          => esc_html__('Give Single Form Sidebar', 'give'),
409 409
 			'id'            => 'give-forms-sidebar',
410
-			'description'   => esc_html__( 'Widgets in this area will be shown on the single Give forms aside area. This sidebar will not display for embedded forms.', 'give' ),
410
+			'description'   => esc_html__('Widgets in this area will be shown on the single Give forms aside area. This sidebar will not display for embedded forms.', 'give'),
411 411
 			'before_widget' => '<div id="%1$s" class="widget %2$s">',
412 412
 			'after_widget'  => '</div>',
413 413
 			'before_title'  => '<h3 class="widgettitle widget-title">',
414 414
 			'after_title'   => '</h3>',
415
-		) ) );
415
+		)));
416 416
 
417 417
 	}
418 418
 }
419 419
 
420
-add_action( 'widgets_init', 'give_widgets_init', 999 );
420
+add_action('widgets_init', 'give_widgets_init', 999);
Please login to merge, or discard this patch.
includes/process-purchase.php 1 patch
Spacing   +260 added lines, -260 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
 
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @since 1.0
32 32
 	 */
33
-	do_action( 'give_pre_process_purchase' );
33
+	do_action('give_pre_process_purchase');
34 34
 
35 35
 	// Validate the form $_POST data
36 36
 	$valid_data = give_purchase_form_validate_fields();
@@ -45,26 +45,26 @@  discard block
 block discarded – undo
45 45
 	 * @param bool|array $valid_data Validate fields.
46 46
 	 * @param array      $_POST      Array of variables passed via the HTTP POST.
47 47
 	 */
48
-	do_action( 'give_checkout_error_checks', $valid_data, $_POST );
48
+	do_action('give_checkout_error_checks', $valid_data, $_POST);
49 49
 
50
-	$is_ajax = isset( $_POST['give_ajax'] );
50
+	$is_ajax = isset($_POST['give_ajax']);
51 51
 
52 52
 	// Process the login form
53
-	if ( isset( $_POST['give_login_submit'] ) ) {
53
+	if (isset($_POST['give_login_submit'])) {
54 54
 		give_process_form_login();
55 55
 	}
56 56
 
57 57
 	// Validate the user
58
-	$user = give_get_purchase_form_user( $valid_data );
58
+	$user = give_get_purchase_form_user($valid_data);
59 59
 
60
-	if ( false === $valid_data || give_get_errors() || ! $user ) {
61
-		if ( $is_ajax ) {
60
+	if (false === $valid_data || give_get_errors() || ! $user) {
61
+		if ($is_ajax) {
62 62
 			/**
63 63
 			 * Fires when AJAX sends back errors from the donation form.
64 64
 			 *
65 65
 			 * @since 1.0
66 66
 			 */
67
-			do_action( 'give_ajax_checkout_errors' );
67
+			do_action('give_ajax_checkout_errors');
68 68
 			give_die();
69 69
 		} else {
70 70
 			return false;
@@ -72,17 +72,17 @@  discard block
 block discarded – undo
72 72
 	}
73 73
 
74 74
 	//If AJAX send back success to proceed with form submission
75
-	if ( $is_ajax ) {
75
+	if ($is_ajax) {
76 76
 		echo 'success';
77 77
 		give_die();
78 78
 	}
79 79
 
80 80
 	//After AJAX: Setup session if not using php_sessions
81
-	if ( ! Give()->session->use_php_sessions() ) {
81
+	if ( ! Give()->session->use_php_sessions()) {
82 82
 		//Double-check that set_cookie is publicly accessible;
83 83
 		// we're using a slightly modified class-wp-sessions.php
84
-		$session_reflection = new ReflectionMethod( 'WP_Session', 'set_cookie' );
85
-		if ( $session_reflection->isPublic() ) {
84
+		$session_reflection = new ReflectionMethod('WP_Session', 'set_cookie');
85
+		if ($session_reflection->isPublic()) {
86 86
 			// Manually set the cookie.
87 87
 			Give()->session->init()->set_cookie();
88 88
 		}
@@ -97,18 +97,18 @@  discard block
 block discarded – undo
97 97
 		'address'    => $user['address']
98 98
 	);
99 99
 
100
-	$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
100
+	$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
101 101
 
102
-	$price        = isset( $_POST['give-amount'] ) ? (float) apply_filters( 'give_donation_total', give_sanitize_amount( give_format_amount( $_POST['give-amount'] ) ) ) : '0.00';
103
-	$purchase_key = strtolower( md5( $user['user_email'] . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) );
102
+	$price        = isset($_POST['give-amount']) ? (float) apply_filters('give_donation_total', give_sanitize_amount(give_format_amount($_POST['give-amount']))) : '0.00';
103
+	$purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true)));
104 104
 
105 105
 	// Setup donation information
106 106
 	$purchase_data = array(
107 107
 		'price'        => $price,
108 108
 		'purchase_key' => $purchase_key,
109 109
 		'user_email'   => $user['user_email'],
110
-		'date'         => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ),
111
-		'user_info'    => stripslashes_deep( $user_info ),
110
+		'date'         => date('Y-m-d H:i:s', current_time('timestamp')),
111
+		'user_info'    => stripslashes_deep($user_info),
112 112
 		'post_data'    => $_POST,
113 113
 		'gateway'      => $valid_data['gateway'],
114 114
 		'card_info'    => $valid_data['cc_info']
@@ -128,10 +128,10 @@  discard block
 block discarded – undo
128 128
 	 * @param array      $user_info  Array containing basic user information.
129 129
 	 * @param bool|array $valid_data Validate fields.
130 130
 	 */
131
-	do_action( 'give_checkout_before_gateway', $_POST, $user_info, $valid_data );
131
+	do_action('give_checkout_before_gateway', $_POST, $user_info, $valid_data);
132 132
 
133 133
 	//Sanity check for price
134
-	if ( ! $purchase_data['price'] ) {
134
+	if ( ! $purchase_data['price']) {
135 135
 		// Revert to manual
136 136
 		$purchase_data['gateway'] = 'manual';
137 137
 		$_POST['give-gateway']    = 'manual';
@@ -142,27 +142,27 @@  discard block
 block discarded – undo
142 142
 	 *
143 143
 	 * @since 1.7
144 144
 	 */
145
-	$purchase_data = apply_filters( 'give_donation_data_before_gateway', $purchase_data, $valid_data );
145
+	$purchase_data = apply_filters('give_donation_data_before_gateway', $purchase_data, $valid_data);
146 146
 
147 147
 	// Setup the data we're storing in the donation session
148 148
 	$session_data = $purchase_data;
149 149
 
150 150
 	// Make sure credit card numbers are never stored in sessions
151
-	unset( $session_data['card_info']['card_number'] );
152
-	unset( $session_data['post_data']['card_number'] );
151
+	unset($session_data['card_info']['card_number']);
152
+	unset($session_data['post_data']['card_number']);
153 153
 
154 154
 	// Used for showing data to non logged-in users after donation, and for other plugins needing donation data.
155
-	give_set_purchase_session( $session_data );
155
+	give_set_purchase_session($session_data);
156 156
 
157 157
 	// Send info to the gateway for payment processing
158
-	give_send_to_gateway( $purchase_data['gateway'], $purchase_data );
158
+	give_send_to_gateway($purchase_data['gateway'], $purchase_data);
159 159
 	give_die();
160 160
 
161 161
 }
162 162
 
163
-add_action( 'give_purchase', 'give_process_purchase_form' );
164
-add_action( 'wp_ajax_give_process_checkout', 'give_process_purchase_form' );
165
-add_action( 'wp_ajax_nopriv_give_process_checkout', 'give_process_purchase_form' );
163
+add_action('give_purchase', 'give_process_purchase_form');
164
+add_action('wp_ajax_give_process_checkout', 'give_process_purchase_form');
165
+add_action('wp_ajax_nopriv_give_process_checkout', 'give_process_purchase_form');
166 166
 
167 167
 
168 168
 /**
@@ -173,25 +173,25 @@  discard block
 block discarded – undo
173 173
  * @param  array $post       Additional $_POST data submitted
174 174
  * @return void
175 175
  */
176
-function give_checkout_check_existing_email( $valid_data, $post ) {
176
+function give_checkout_check_existing_email($valid_data, $post) {
177 177
 	
178 178
 	// Verify that the email address belongs to this customer
179
-	if ( is_user_logged_in() ) {
179
+	if (is_user_logged_in()) {
180 180
 
181 181
 		$email    = $valid_data['logged_in_user']['user_email'];
182
-		$customer = new Give_Customer( get_current_user_id(), true );
182
+		$customer = new Give_Customer(get_current_user_id(), true);
183 183
 
184 184
 		// If this email address is not registered with this customer, see if it belongs to any other customer
185
-		if ( $email !== $customer->email && ( is_array( $customer->emails ) && ! in_array( $email, $customer->emails ) ) ) {
186
-			$found_customer = new Give_Customer( $email );
185
+		if ($email !== $customer->email && (is_array($customer->emails) && ! in_array($email, $customer->emails))) {
186
+			$found_customer = new Give_Customer($email);
187 187
 			
188
-			if ( $found_customer->id > 0 ) {
189
-				give_set_error( 'give-customer-email-exists', __( sprintf( 'The email address %s is already in use.', $email ), 'give' ) );
188
+			if ($found_customer->id > 0) {
189
+				give_set_error('give-customer-email-exists', __(sprintf('The email address %s is already in use.', $email), 'give'));
190 190
 			}
191 191
 		}
192 192
 	}
193 193
 }
194
-add_action( 'give_checkout_error_checks', 'give_checkout_check_existing_email', 10, 2 );
194
+add_action('give_checkout_error_checks', 'give_checkout_check_existing_email', 10, 2);
195 195
 
196 196
 /**
197 197
  * Process the checkout login form
@@ -202,37 +202,37 @@  discard block
 block discarded – undo
202 202
  */
203 203
 function give_process_form_login() {
204 204
 
205
-	$is_ajax = isset( $_POST['give_ajax'] );
205
+	$is_ajax = isset($_POST['give_ajax']);
206 206
 
207 207
 	$user_data = give_purchase_form_validate_user_login();
208 208
 
209
-	if ( give_get_errors() || $user_data['user_id'] < 1 ) {
210
-		if ( $is_ajax ) {
209
+	if (give_get_errors() || $user_data['user_id'] < 1) {
210
+		if ($is_ajax) {
211 211
 			/**
212 212
 			 * Fires when AJAX sends back errors from the donation form.
213 213
 			 *
214 214
 			 * @since 1.0
215 215
 			 */
216
-			do_action( 'give_ajax_checkout_errors' );
216
+			do_action('give_ajax_checkout_errors');
217 217
 			give_die();
218 218
 		} else {
219
-			wp_redirect( $_SERVER['HTTP_REFERER'] );
219
+			wp_redirect($_SERVER['HTTP_REFERER']);
220 220
 			exit;
221 221
 		}
222 222
 	}
223 223
 
224
-	give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] );
224
+	give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']);
225 225
 
226
-	if ( $is_ajax ) {
226
+	if ($is_ajax) {
227 227
 		echo 'success';
228 228
 		give_die();
229 229
 	} else {
230
-		wp_redirect( $_SERVER['HTTP_REFERER'] );
230
+		wp_redirect($_SERVER['HTTP_REFERER']);
231 231
 	}
232 232
 }
233 233
 
234
-add_action( 'wp_ajax_give_process_checkout_login', 'give_process_form_login' );
235
-add_action( 'wp_ajax_nopriv_give_process_checkout_login', 'give_process_form_login' );
234
+add_action('wp_ajax_give_process_checkout_login', 'give_process_form_login');
235
+add_action('wp_ajax_nopriv_give_process_checkout_login', 'give_process_form_login');
236 236
 
237 237
 /**
238 238
  * Donation Form Validate Fields
@@ -244,45 +244,45 @@  discard block
 block discarded – undo
244 244
 function give_purchase_form_validate_fields() {
245 245
 
246 246
 	// Check if there is $_POST
247
-	if ( empty( $_POST ) ) {
247
+	if (empty($_POST)) {
248 248
 		return false;
249 249
 	}
250 250
 
251
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
251
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
252 252
 
253 253
 	// Start an array to collect valid data
254 254
 	$valid_data = array(
255 255
 		'gateway'          => give_purchase_form_validate_gateway(), // Gateway fallback (amount is validated here)
256
-		'need_new_user'    => false,     // New user flag
257
-		'need_user_login'  => false,     // Login user flag
258
-		'logged_user_data' => array(),   // Logged user collected data
259
-		'new_user_data'    => array(),   // New user collected data
260
-		'login_user_data'  => array(),   // Login user collected data
261
-		'guest_user_data'  => array(),   // Guest user collected data
256
+		'need_new_user'    => false, // New user flag
257
+		'need_user_login'  => false, // Login user flag
258
+		'logged_user_data' => array(), // Logged user collected data
259
+		'new_user_data'    => array(), // New user collected data
260
+		'login_user_data'  => array(), // Login user collected data
261
+		'guest_user_data'  => array(), // Guest user collected data
262 262
 		'cc_info'          => give_purchase_form_validate_cc()    // Credit card info
263 263
 	);
264 264
 
265 265
 	//Validate Honeypot First
266
-	if ( ! empty( $_POST['give-honeypot'] ) ) {
267
-		give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) );
266
+	if ( ! empty($_POST['give-honeypot'])) {
267
+		give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give'));
268 268
 	}
269 269
 
270 270
 	// Validate agree to terms
271
-	$terms_option = get_post_meta( $form_id, '_give_terms_option', true );
272
-	if ( isset( $terms_option ) && $terms_option === 'yes' ) {
271
+	$terms_option = get_post_meta($form_id, '_give_terms_option', true);
272
+	if (isset($terms_option) && $terms_option === 'yes') {
273 273
 		give_purchase_form_validate_agree_to_terms();
274 274
 	}
275 275
 
276
-	if ( is_user_logged_in() ) {
276
+	if (is_user_logged_in()) {
277 277
 		// Collect logged in user data
278 278
 		$valid_data['logged_in_user'] = give_purchase_form_validate_logged_in_user();
279
-	} else if ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' ) {
279
+	} else if (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register') {
280 280
 		// Set new user registration as required
281 281
 		$valid_data['need_new_user'] = true;
282 282
 		// Validate new user data
283 283
 		$valid_data['new_user_data'] = give_purchase_form_validate_new_user();
284 284
 		// Check if login validation is needed
285
-	} else if ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) {
285
+	} else if (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') {
286 286
 		// Set user login as required
287 287
 		$valid_data['need_user_login'] = true;
288 288
 		// Validate users login info
@@ -307,41 +307,41 @@  discard block
 block discarded – undo
307 307
  */
308 308
 function give_purchase_form_validate_gateway() {
309 309
 
310
-	$form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0;
311
-	$amount  = isset( $_REQUEST['give-amount'] ) ? give_sanitize_amount( $_REQUEST['give-amount'] ) : 0;
312
-	$gateway = give_get_default_gateway( $form_id );
310
+	$form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;
311
+	$amount  = isset($_REQUEST['give-amount']) ? give_sanitize_amount($_REQUEST['give-amount']) : 0;
312
+	$gateway = give_get_default_gateway($form_id);
313 313
 
314 314
 	// Check if a gateway value is present
315
-	if ( ! empty( $_REQUEST['give-gateway'] ) ) {
315
+	if ( ! empty($_REQUEST['give-gateway'])) {
316 316
 
317
-		$gateway = sanitize_text_field( $_REQUEST['give-gateway'] );
317
+		$gateway = sanitize_text_field($_REQUEST['give-gateway']);
318 318
 
319 319
 		//Is amount being donated in LIVE mode 0.00? If so, error:
320
-		if ( $amount == 0 && ! give_is_test_mode() ) {
320
+		if ($amount == 0 && ! give_is_test_mode()) {
321 321
 
322
-			give_set_error( 'invalid_donation_amount', esc_html__( 'Please insert a valid donation amount.', 'give' ) );
322
+			give_set_error('invalid_donation_amount', esc_html__('Please insert a valid donation amount.', 'give'));
323 323
 
324 324
 		} //Check for a minimum custom amount
325
-		elseif ( ! give_verify_minimum_price() ) {
325
+		elseif ( ! give_verify_minimum_price()) {
326 326
 
327 327
 			give_set_error(
328 328
 				'invalid_donation_minimum',
329 329
 				sprintf(
330 330
 					/* translators: %s: minimum donation amount */
331
-					esc_html__( 'This form has a minimum donation amount of %s.', 'give' ),
332
-					give_currency_filter( give_format_amount( give_get_form_minimum_price( $form_id ) ) )
331
+					esc_html__('This form has a minimum donation amount of %s.', 'give'),
332
+					give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id)))
333 333
 				)
334 334
 			);
335 335
 
336 336
 		} //Is this test mode zero donation? Let it through but set to manual gateway
337
-		elseif ( $amount == 0 && give_is_test_mode() ) {
337
+		elseif ($amount == 0 && give_is_test_mode()) {
338 338
 
339 339
 			$gateway = 'manual';
340 340
 
341 341
 		} //Check if this gateway is active
342
-		elseif ( ! give_is_gateway_active( $gateway ) ) {
342
+		elseif ( ! give_is_gateway_active($gateway)) {
343 343
 
344
-			give_set_error( 'invalid_gateway', esc_html__( 'The selected payment gateway is not enabled.', 'give' ) );
344
+			give_set_error('invalid_gateway', esc_html__('The selected payment gateway is not enabled.', 'give'));
345 345
 
346 346
 		}
347 347
 
@@ -360,23 +360,23 @@  discard block
 block discarded – undo
360 360
  */
361 361
 function give_verify_minimum_price() {
362 362
 
363
-	$amount          = give_sanitize_amount( $_REQUEST['give-amount'] );
364
-	$form_id         = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0;
365
-	$price_id        = isset( $_REQUEST['give-price-id'] ) ? $_REQUEST['give-price-id'] : 0;
366
-	$variable_prices = give_has_variable_prices( $form_id );
363
+	$amount          = give_sanitize_amount($_REQUEST['give-amount']);
364
+	$form_id         = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;
365
+	$price_id        = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : 0;
366
+	$variable_prices = give_has_variable_prices($form_id);
367 367
 
368
-	if ( $variable_prices && ! empty( $price_id ) ) {
368
+	if ($variable_prices && ! empty($price_id)) {
369 369
 
370
-		$price_level_amount = give_get_price_option_amount( $form_id, $price_id );
370
+		$price_level_amount = give_get_price_option_amount($form_id, $price_id);
371 371
 
372
-		if ( $price_level_amount == $amount ) {
372
+		if ($price_level_amount == $amount) {
373 373
 			return true;
374 374
 		}
375 375
 	}
376 376
 
377
-	$minimum = give_get_form_minimum_price( $form_id );
377
+	$minimum = give_get_form_minimum_price($form_id);
378 378
 
379
-	if ( $minimum > $amount ) {
379
+	if ($minimum > $amount) {
380 380
 		return false;
381 381
 	}
382 382
 
@@ -392,9 +392,9 @@  discard block
 block discarded – undo
392 392
  */
393 393
 function give_purchase_form_validate_agree_to_terms() {
394 394
 	// Validate agree to terms
395
-	if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) {
395
+	if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) {
396 396
 		// User did not agree
397
-		give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', esc_html__( 'You must agree to the terms of use.', 'give' ) ) );
397
+		give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', esc_html__('You must agree to the terms of use.', 'give')));
398 398
 	}
399 399
 }
400 400
 
@@ -408,43 +408,43 @@  discard block
 block discarded – undo
408 408
  *
409 409
  * @return      array
410 410
  */
411
-function give_purchase_form_required_fields( $form_id ) {
411
+function give_purchase_form_required_fields($form_id) {
412 412
 
413
-	$payment_mode = give_get_chosen_gateway( $form_id );
413
+	$payment_mode = give_get_chosen_gateway($form_id);
414 414
 
415 415
 	$required_fields = array(
416 416
 		'give_email' => array(
417 417
 			'error_id'      => 'invalid_email',
418
-			'error_message' => esc_html__( 'Please enter a valid email address.', 'give' )
418
+			'error_message' => esc_html__('Please enter a valid email address.', 'give')
419 419
 		),
420 420
 		'give_first' => array(
421 421
 			'error_id'      => 'invalid_first_name',
422
-			'error_message' => esc_html__( 'Please enter your first name.', 'give' )
422
+			'error_message' => esc_html__('Please enter your first name.', 'give')
423 423
 		)
424 424
 	);
425 425
 
426
-	$require_address = give_require_billing_address( $payment_mode );
426
+	$require_address = give_require_billing_address($payment_mode);
427 427
 
428
-	if ( $require_address ) {
429
-		$required_fields['card_address']    = array(
428
+	if ($require_address) {
429
+		$required_fields['card_address'] = array(
430 430
 			'error_id'      => 'invalid_card_address',
431
-			'error_message' => esc_html__( 'Please enter your primary billing address.', 'give' )
431
+			'error_message' => esc_html__('Please enter your primary billing address.', 'give')
432 432
 		);
433
-		$required_fields['card_zip']        = array(
433
+		$required_fields['card_zip'] = array(
434 434
 			'error_id'      => 'invalid_zip_code',
435
-			'error_message' => esc_html__( 'Please enter your zip / postal code.', 'give' )
435
+			'error_message' => esc_html__('Please enter your zip / postal code.', 'give')
436 436
 		);
437
-		$required_fields['card_city']       = array(
437
+		$required_fields['card_city'] = array(
438 438
 			'error_id'      => 'invalid_city',
439
-			'error_message' => esc_html__( 'Please enter your billing city.', 'give' )
439
+			'error_message' => esc_html__('Please enter your billing city.', 'give')
440 440
 		);
441 441
 		$required_fields['billing_country'] = array(
442 442
 			'error_id'      => 'invalid_country',
443
-			'error_message' => esc_html__( 'Please select your billing country.', 'give' )
443
+			'error_message' => esc_html__('Please select your billing country.', 'give')
444 444
 		);
445
-		$required_fields['card_state']      = array(
445
+		$required_fields['card_state'] = array(
446 446
 			'error_id'      => 'invalid_state',
447
-			'error_message' => esc_html__( 'Please enter billing state / province.', 'give' )
447
+			'error_message' => esc_html__('Please enter billing state / province.', 'give')
448 448
 		);
449 449
 	}
450 450
 
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 	 *
454 454
 	 * @since 1.7
455 455
 	 */
456
-	$required_fields = apply_filters( 'give_donation_form_required_fields', $required_fields, $form_id );
456
+	$required_fields = apply_filters('give_donation_form_required_fields', $required_fields, $form_id);
457 457
 
458 458
 	return $required_fields;
459 459
 
@@ -468,16 +468,16 @@  discard block
 block discarded – undo
468 468
  *
469 469
  * @return mixed|void
470 470
  */
471
-function give_require_billing_address( $payment_mode ) {
471
+function give_require_billing_address($payment_mode) {
472 472
 
473 473
 	$return = false;
474 474
 
475
-	if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) {
475
+	if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) {
476 476
 		$return = true;
477 477
 	}
478 478
 
479 479
 	// Let payment gateways and other extensions determine if address fields should be required
480
-	return apply_filters( 'give_require_billing_address', $return );
480
+	return apply_filters('give_require_billing_address', $return);
481 481
 
482 482
 }
483 483
 
@@ -491,43 +491,43 @@  discard block
 block discarded – undo
491 491
 function give_purchase_form_validate_logged_in_user() {
492 492
 	global $user_ID;
493 493
 
494
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
494
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
495 495
 
496 496
 	// Start empty array to collect valid user data
497 497
 	$valid_user_data = array(
498 498
 		// Assume there will be errors
499
-		'user_id' => - 1
499
+		'user_id' => -1
500 500
 	);
501 501
 
502 502
 	// Verify there is a user_ID
503
-	if ( $user_ID > 0 ) {
503
+	if ($user_ID > 0) {
504 504
 		// Get the logged in user data
505
-		$user_data = get_userdata( $user_ID );
505
+		$user_data = get_userdata($user_ID);
506 506
 
507 507
 		// Loop through required fields and show error messages
508
-		foreach ( give_purchase_form_required_fields( $form_id ) as $field_name => $value ) {
509
-			if ( in_array( $value, give_purchase_form_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
510
-				give_set_error( $value['error_id'], $value['error_message'] );
508
+		foreach (give_purchase_form_required_fields($form_id) as $field_name => $value) {
509
+			if (in_array($value, give_purchase_form_required_fields($form_id)) && empty($_POST[$field_name])) {
510
+				give_set_error($value['error_id'], $value['error_message']);
511 511
 			}
512 512
 		}
513 513
 
514 514
 		// Verify data
515
-		if ( $user_data ) {
515
+		if ($user_data) {
516 516
 			// Collected logged in user data
517 517
 			$valid_user_data = array(
518 518
 				'user_id'    => $user_ID,
519
-				'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email,
520
-				'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name,
521
-				'user_last'  => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name,
519
+				'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email,
520
+				'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name,
521
+				'user_last'  => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name,
522 522
 			);
523 523
 
524
-			if ( ! is_email( $valid_user_data['user_email'] ) ) {
525
-				give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
524
+			if ( ! is_email($valid_user_data['user_email'])) {
525
+				give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
526 526
 			}
527 527
 
528 528
 		} else {
529 529
 			// Set invalid user error
530
-			give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) );
530
+			give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give'));
531 531
 		}
532 532
 	}
533 533
 
@@ -545,90 +545,90 @@  discard block
 block discarded – undo
545 545
 function give_purchase_form_validate_new_user() {
546 546
 
547 547
 	$registering_new_user = false;
548
-	$form_id              = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
548
+	$form_id              = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
549 549
 
550 550
 	// Start an empty array to collect valid user data
551 551
 	$valid_user_data = array(
552 552
 		// Assume there will be errors
553
-		'user_id'    => - 1,
553
+		'user_id'    => -1,
554 554
 		// Get first name
555
-		'user_first' => isset( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : '',
555
+		'user_first' => isset($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : '',
556 556
 		// Get last name
557
-		'user_last'  => isset( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : '',
557
+		'user_last'  => isset($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : '',
558 558
 	);
559 559
 
560 560
 	// Check the new user's credentials against existing ones
561
-	$user_login   = isset( $_POST['give_user_login'] ) ? trim( $_POST['give_user_login'] ) : false;
562
-	$user_email   = isset( $_POST['give_email'] ) ? trim( $_POST['give_email'] ) : false;
563
-	$user_pass    = isset( $_POST['give_user_pass'] ) ? trim( $_POST['give_user_pass'] ) : false;
564
-	$pass_confirm = isset( $_POST['give_user_pass_confirm'] ) ? trim( $_POST['give_user_pass_confirm'] ) : false;
561
+	$user_login   = isset($_POST['give_user_login']) ? trim($_POST['give_user_login']) : false;
562
+	$user_email   = isset($_POST['give_email']) ? trim($_POST['give_email']) : false;
563
+	$user_pass    = isset($_POST['give_user_pass']) ? trim($_POST['give_user_pass']) : false;
564
+	$pass_confirm = isset($_POST['give_user_pass_confirm']) ? trim($_POST['give_user_pass_confirm']) : false;
565 565
 
566 566
 	// Loop through required fields and show error messages
567
-	foreach ( give_purchase_form_required_fields( $form_id ) as $field_name => $value ) {
568
-		if ( in_array( $value, give_purchase_form_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
569
-			give_set_error( $value['error_id'], $value['error_message'] );
567
+	foreach (give_purchase_form_required_fields($form_id) as $field_name => $value) {
568
+		if (in_array($value, give_purchase_form_required_fields($form_id)) && empty($_POST[$field_name])) {
569
+			give_set_error($value['error_id'], $value['error_message']);
570 570
 		}
571 571
 	}
572 572
 
573 573
 	// Check if we have an username to register
574
-	if ( $user_login && strlen( $user_login ) > 0 ) {
574
+	if ($user_login && strlen($user_login) > 0) {
575 575
 		$registering_new_user = true;
576 576
 
577 577
 		// We have an user name, check if it already exists
578
-		if ( username_exists( $user_login ) ) {
578
+		if (username_exists($user_login)) {
579 579
 			// Username already registered
580
-			give_set_error( 'username_unavailable', esc_html__( 'Username already taken.', 'give' ) );
580
+			give_set_error('username_unavailable', esc_html__('Username already taken.', 'give'));
581 581
 			// Check if it's valid
582
-		} else if ( ! give_validate_username( $user_login ) ) {
582
+		} else if ( ! give_validate_username($user_login)) {
583 583
 			// Invalid username
584
-			if ( is_multisite() ) {
585
-				give_set_error( 'username_invalid', esc_html__( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ) );
584
+			if (is_multisite()) {
585
+				give_set_error('username_invalid', esc_html__('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give'));
586 586
 			} else {
587
-				give_set_error( 'username_invalid', esc_html__( 'Invalid username.', 'give' ) );
587
+				give_set_error('username_invalid', esc_html__('Invalid username.', 'give'));
588 588
 			}
589 589
 		} else {
590 590
 			// All the checks have run and it's good to go
591 591
 			$valid_user_data['user_login'] = $user_login;
592 592
 		}
593
-	} elseif ( give_logged_in_only( $form_id ) ) {
594
-		give_set_error( 'registration_required', esc_html__( 'You must register or login to complete your donation.', 'give' ) );
593
+	} elseif (give_logged_in_only($form_id)) {
594
+		give_set_error('registration_required', esc_html__('You must register or login to complete your donation.', 'give'));
595 595
 	}
596 596
 
597 597
 	// Check if we have an email to verify
598
-	if ( $user_email && strlen( $user_email ) > 0 ) {
598
+	if ($user_email && strlen($user_email) > 0) {
599 599
 		// Validate email
600
-		if ( ! is_email( $user_email ) ) {
601
-			give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
600
+		if ( ! is_email($user_email)) {
601
+			give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
602 602
 			// Check if email exists
603
-		} else if ( email_exists( $user_email ) && $registering_new_user ) {
604
-			give_set_error( 'email_used', esc_html__( 'The email already active for another user.', 'give' ) );
603
+		} else if (email_exists($user_email) && $registering_new_user) {
604
+			give_set_error('email_used', esc_html__('The email already active for another user.', 'give'));
605 605
 		} else {
606 606
 			// All the checks have run and it's good to go
607 607
 			$valid_user_data['user_email'] = $user_email;
608 608
 		}
609 609
 	} else {
610 610
 		// No email
611
-		give_set_error( 'email_empty', esc_html__( 'Enter an email.', 'give' ) );
611
+		give_set_error('email_empty', esc_html__('Enter an email.', 'give'));
612 612
 	}
613 613
 
614 614
 	// Check password
615
-	if ( $user_pass && $pass_confirm ) {
615
+	if ($user_pass && $pass_confirm) {
616 616
 		// Verify confirmation matches
617
-		if ( $user_pass != $pass_confirm ) {
617
+		if ($user_pass != $pass_confirm) {
618 618
 			// Passwords do not match
619
-			give_set_error( 'password_mismatch', esc_html__( 'Passwords don\'t match.', 'give' ) );
619
+			give_set_error('password_mismatch', esc_html__('Passwords don\'t match.', 'give'));
620 620
 		} else {
621 621
 			// All is good to go
622 622
 			$valid_user_data['user_pass'] = $user_pass;
623 623
 		}
624 624
 	} else {
625 625
 		// Password or confirmation missing
626
-		if ( ! $user_pass && $registering_new_user ) {
626
+		if ( ! $user_pass && $registering_new_user) {
627 627
 			// The password is invalid
628
-			give_set_error( 'password_empty', esc_html__( 'Enter a password.', 'give' ) );
629
-		} else if ( ! $pass_confirm && $registering_new_user ) {
628
+			give_set_error('password_empty', esc_html__('Enter a password.', 'give'));
629
+		} else if ( ! $pass_confirm && $registering_new_user) {
630 630
 			// Confirmation password is invalid
631
-			give_set_error( 'confirmation_empty', esc_html__( 'Enter the password confirmation.', 'give' ) );
631
+			give_set_error('confirmation_empty', esc_html__('Enter the password confirmation.', 'give'));
632 632
 		}
633 633
 	}
634 634
 
@@ -647,36 +647,36 @@  discard block
 block discarded – undo
647 647
 	// Start an array to collect valid user data
648 648
 	$valid_user_data = array(
649 649
 		// Assume there will be errors
650
-		'user_id' => - 1
650
+		'user_id' => -1
651 651
 	);
652 652
 
653 653
 	// Username
654
-	if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) {
655
-		give_set_error( 'must_log_in', esc_html__( 'You must register or login to complete your donation.', 'give' ) );
654
+	if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') {
655
+		give_set_error('must_log_in', esc_html__('You must register or login to complete your donation.', 'give'));
656 656
 
657 657
 		return $valid_user_data;
658 658
 	}
659 659
 
660 660
 	// Get the user by login
661
-	$user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) );
661
+	$user_data = get_user_by('login', strip_tags($_POST['give_user_login']));
662 662
 
663 663
 	// Check if user exists
664
-	if ( $user_data ) {
664
+	if ($user_data) {
665 665
 		// Get password
666
-		$user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false;
666
+		$user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false;
667 667
 
668 668
 		// Check user_pass
669
-		if ( $user_pass ) {
669
+		if ($user_pass) {
670 670
 			// Check if password is valid
671
-			if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) {
671
+			if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) {
672 672
 				// Incorrect password
673 673
 				give_set_error(
674 674
 					'password_incorrect',
675 675
 					sprintf(
676 676
 						'%1$s <a href="%2$s">%3$s</a>',
677
-						esc_html__( 'The password you entered is incorrect.', 'give' ),
678
-						wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ),
679
-						esc_html__( 'Reset Password', 'give' )
677
+						esc_html__('The password you entered is incorrect.', 'give'),
678
+						wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"),
679
+						esc_html__('Reset Password', 'give')
680 680
 					)
681 681
 				);
682 682
 				// All is correct
@@ -693,11 +693,11 @@  discard block
 block discarded – undo
693 693
 			}
694 694
 		} else {
695 695
 			// Empty password
696
-			give_set_error( 'password_empty', esc_html__( 'Enter a password.', 'give' ) );
696
+			give_set_error('password_empty', esc_html__('Enter a password.', 'give'));
697 697
 		}
698 698
 	} else {
699 699
 		// no username
700
-		give_set_error( 'username_incorrect', esc_html__( 'The username you entered does not exist.', 'give' ) );
700
+		give_set_error('username_incorrect', esc_html__('The username you entered does not exist.', 'give'));
701 701
 	}
702 702
 
703 703
 	return $valid_user_data;
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
  */
713 713
 function give_purchase_form_validate_guest_user() {
714 714
 
715
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
715
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
716 716
 
717 717
 	// Start an array to collect valid user data
718 718
 	$valid_user_data = array(
@@ -721,38 +721,38 @@  discard block
 block discarded – undo
721 721
 	);
722 722
 
723 723
 	// Show error message if user must be logged in
724
-	if ( give_logged_in_only( $form_id ) ) {
725
-		give_set_error( 'logged_in_only', esc_html__( 'You must be logged in to donate.', 'give' ) );
724
+	if (give_logged_in_only($form_id)) {
725
+		give_set_error('logged_in_only', esc_html__('You must be logged in to donate.', 'give'));
726 726
 	}
727 727
 
728 728
 	// Get the guest email
729
-	$guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false;
729
+	$guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false;
730 730
 
731 731
 	// Check email
732
-	if ( $guest_email && strlen( $guest_email ) > 0 ) {
732
+	if ($guest_email && strlen($guest_email) > 0) {
733 733
 		// Validate email
734
-		if ( ! is_email( $guest_email ) ) {
734
+		if ( ! is_email($guest_email)) {
735 735
 			// Invalid email
736
-			give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
736
+			give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
737 737
 		} else {
738 738
 			// All is good to go
739 739
 			$valid_user_data['user_email'] = $guest_email;
740 740
 
741 741
 			// Get user_id from donor if exist.
742
-			$donor = new Give_Customer( $guest_email );
743
-			if( $donor->id && $donor->user_id ) {
742
+			$donor = new Give_Customer($guest_email);
743
+			if ($donor->id && $donor->user_id) {
744 744
 				$valid_user_data['user_id'] = $donor->user_id;
745 745
 			}
746 746
 		}
747 747
 	} else {
748 748
 		// No email
749
-		give_set_error( 'email_empty', esc_html__( 'Enter an email.', 'give' ) );
749
+		give_set_error('email_empty', esc_html__('Enter an email.', 'give'));
750 750
 	}
751 751
 
752 752
 	// Loop through required fields and show error messages
753
-	foreach ( give_purchase_form_required_fields( $form_id ) as $field_name => $value ) {
754
-		if ( in_array( $value, give_purchase_form_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
755
-			give_set_error( $value['error_id'], $value['error_message'] );
753
+	foreach (give_purchase_form_required_fields($form_id) as $field_name => $value) {
754
+		if (in_array($value, give_purchase_form_required_fields($form_id)) && empty($_POST[$field_name])) {
755
+			give_set_error($value['error_id'], $value['error_message']);
756 756
 		}
757 757
 	}
758 758
 
@@ -768,36 +768,36 @@  discard block
 block discarded – undo
768 768
  * @since   1.0
769 769
  * @return  integer
770 770
  */
771
-function give_register_and_login_new_user( $user_data = array() ) {
771
+function give_register_and_login_new_user($user_data = array()) {
772 772
 	// Verify the array
773
-	if ( empty( $user_data ) ) {
774
-		return - 1;
773
+	if (empty($user_data)) {
774
+		return -1;
775 775
 	}
776 776
 
777
-	if ( give_get_errors() ) {
778
-		return - 1;
777
+	if (give_get_errors()) {
778
+		return -1;
779 779
 	}
780 780
 
781
-	$user_args = apply_filters( 'give_insert_user_args', array(
782
-		'user_login'      => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '',
783
-		'user_pass'       => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '',
784
-		'user_email'      => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '',
785
-		'first_name'      => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '',
786
-		'last_name'       => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '',
787
-		'user_registered' => date( 'Y-m-d H:i:s' ),
788
-		'role'            => get_option( 'default_role' )
789
-	), $user_data );
781
+	$user_args = apply_filters('give_insert_user_args', array(
782
+		'user_login'      => isset($user_data['user_login']) ? $user_data['user_login'] : '',
783
+		'user_pass'       => isset($user_data['user_pass']) ? $user_data['user_pass'] : '',
784
+		'user_email'      => isset($user_data['user_email']) ? $user_data['user_email'] : '',
785
+		'first_name'      => isset($user_data['user_first']) ? $user_data['user_first'] : '',
786
+		'last_name'       => isset($user_data['user_last']) ? $user_data['user_last'] : '',
787
+		'user_registered' => date('Y-m-d H:i:s'),
788
+		'role'            => get_option('default_role')
789
+	), $user_data);
790 790
 
791 791
 	// Insert new user
792
-	$user_id = wp_insert_user( $user_args );
792
+	$user_id = wp_insert_user($user_args);
793 793
 
794 794
 	// Validate inserted user
795
-	if ( is_wp_error( $user_id ) ) {
796
-		return - 1;
795
+	if (is_wp_error($user_id)) {
796
+		return -1;
797 797
 	}
798 798
 
799 799
 	// Allow themes and plugins to filter the user data
800
-	$user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args );
800
+	$user_data = apply_filters('give_insert_user_data', $user_data, $user_args);
801 801
 
802 802
 	/**
803 803
 	 * Fires after inserting user.
@@ -807,10 +807,10 @@  discard block
 block discarded – undo
807 807
 	 * @param int   $user_id   User id.
808 808
 	 * @param array $user_data Array containing user data.
809 809
 	 */
810
-	do_action( 'give_insert_user', $user_id, $user_data );
810
+	do_action('give_insert_user', $user_id, $user_data);
811 811
 
812 812
 	// Login new user
813
-	give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] );
813
+	give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']);
814 814
 
815 815
 	// Return user id
816 816
 	return $user_id;
@@ -825,27 +825,27 @@  discard block
 block discarded – undo
825 825
  * @since   1.0
826 826
  * @return  array
827 827
  */
828
-function give_get_purchase_form_user( $valid_data = array() ) {
828
+function give_get_purchase_form_user($valid_data = array()) {
829 829
 
830 830
 	// Initialize user
831 831
 	$user    = false;
832
-	$is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
832
+	$is_ajax = defined('DOING_AJAX') && DOING_AJAX;
833 833
 
834
-	if ( $is_ajax ) {
834
+	if ($is_ajax) {
835 835
 		// Do not create or login the user during the ajax submission (check for errors only)
836 836
 		return true;
837
-	} else if ( is_user_logged_in() ) {
837
+	} else if (is_user_logged_in()) {
838 838
 		// Set the valid user as the logged in collected data
839 839
 		$user = $valid_data['logged_in_user'];
840
-	} else if ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) {
840
+	} else if ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) {
841 841
 		// New user registration
842
-		if ( $valid_data['need_new_user'] === true ) {
842
+		if ($valid_data['need_new_user'] === true) {
843 843
 			// Set user
844 844
 			$user = $valid_data['new_user_data'];
845 845
 			// Register and login new user
846
-			$user['user_id'] = give_register_and_login_new_user( $user );
846
+			$user['user_id'] = give_register_and_login_new_user($user);
847 847
 			// User login
848
-		} else if ( $valid_data['need_user_login'] === true && ! $is_ajax ) {
848
+		} else if ($valid_data['need_user_login'] === true && ! $is_ajax) {
849 849
 
850 850
 			/*
851 851
 			 * The login form is now processed in the give_process_purchase_login() function.
@@ -860,48 +860,48 @@  discard block
 block discarded – undo
860 860
 			// Set user
861 861
 			$user = $valid_data['login_user_data'];
862 862
 			// Login user
863
-			give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] );
863
+			give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']);
864 864
 		}
865 865
 	}
866 866
 
867 867
 	// Check guest checkout
868
-	if ( false === $user && false === give_logged_in_only( $_POST['give-form-id'] ) ) {
868
+	if (false === $user && false === give_logged_in_only($_POST['give-form-id'])) {
869 869
 		// Set user
870 870
 		$user = $valid_data['guest_user_data'];
871 871
 	}
872 872
 
873 873
 	// Verify we have an user
874
-	if ( false === $user || empty( $user ) ) {
874
+	if (false === $user || empty($user)) {
875 875
 		// Return false
876 876
 		return false;
877 877
 	}
878 878
 
879 879
 	// Get user first name
880
-	if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) {
881
-		$user['user_first'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : '';
880
+	if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) {
881
+		$user['user_first'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : '';
882 882
 	}
883 883
 
884 884
 	// Get user last name
885
-	if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) {
886
-		$user['user_last'] = isset( $_POST['give_last'] ) ? strip_tags( trim( $_POST['give_last'] ) ) : '';
885
+	if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) {
886
+		$user['user_last'] = isset($_POST['give_last']) ? strip_tags(trim($_POST['give_last'])) : '';
887 887
 	}
888 888
 
889 889
 	// Get the user's billing address details
890 890
 	$user['address']            = array();
891
-	$user['address']['line1']   = ! empty( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : false;
892
-	$user['address']['line2']   = ! empty( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : false;
893
-	$user['address']['city']    = ! empty( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : false;
894
-	$user['address']['state']   = ! empty( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : false;
895
-	$user['address']['country'] = ! empty( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : false;
896
-	$user['address']['zip']     = ! empty( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : false;
897
-
898
-	if ( empty( $user['address']['country'] ) ) {
891
+	$user['address']['line1']   = ! empty($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : false;
892
+	$user['address']['line2']   = ! empty($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : false;
893
+	$user['address']['city']    = ! empty($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : false;
894
+	$user['address']['state']   = ! empty($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : false;
895
+	$user['address']['country'] = ! empty($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : false;
896
+	$user['address']['zip']     = ! empty($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : false;
897
+
898
+	if (empty($user['address']['country'])) {
899 899
 		$user['address'] = false;
900 900
 	} // Country will always be set if address fields are present
901 901
 
902
-	if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) {
902
+	if ( ! empty($user['user_id']) && $user['user_id'] > 0 && ! empty($user['address'])) {
903 903
 		// Store the address in the user's meta so the donation form can be pre-populated with it on return purchases
904
-		update_user_meta( $user['user_id'], '_give_user_address', $user['address'] );
904
+		update_user_meta($user['user_id'], '_give_user_address', $user['address']);
905 905
 	}
906 906
 
907 907
 	// Return valid user
@@ -920,16 +920,16 @@  discard block
 block discarded – undo
920 920
 	$card_data = give_get_purchase_cc_info();
921 921
 
922 922
 	// Validate the card zip
923
-	if ( ! empty( $card_data['card_zip'] ) ) {
924
-		if ( ! give_purchase_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) {
925
-			give_set_error( 'invalid_cc_zip', esc_html__( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) );
923
+	if ( ! empty($card_data['card_zip'])) {
924
+		if ( ! give_purchase_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) {
925
+			give_set_error('invalid_cc_zip', esc_html__('The zip / postal code you entered for your billing address is invalid.', 'give'));
926 926
 		}
927 927
 	}
928 928
 
929 929
 	//Ensure no spaces
930
-	if ( ! empty( $card_data['card_number'] ) ) {
931
-		$card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); //no "+" signs
932
-		$card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces
930
+	if ( ! empty($card_data['card_number'])) {
931
+		$card_data['card_number'] = str_replace('+', '', $card_data['card_number']); //no "+" signs
932
+		$card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces
933 933
 	}
934 934
 
935 935
 	// This should validate card numbers at some point too
@@ -945,17 +945,17 @@  discard block
 block discarded – undo
945 945
  */
946 946
 function give_get_purchase_cc_info() {
947 947
 	$cc_info                   = array();
948
-	$cc_info['card_name']      = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : '';
949
-	$cc_info['card_number']    = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : '';
950
-	$cc_info['card_cvc']       = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : '';
951
-	$cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : '';
952
-	$cc_info['card_exp_year']  = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : '';
953
-	$cc_info['card_address']   = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : '';
954
-	$cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : '';
955
-	$cc_info['card_city']      = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : '';
956
-	$cc_info['card_state']     = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : '';
957
-	$cc_info['card_country']   = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : '';
958
-	$cc_info['card_zip']       = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : '';
948
+	$cc_info['card_name']      = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : '';
949
+	$cc_info['card_number']    = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : '';
950
+	$cc_info['card_cvc']       = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : '';
951
+	$cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : '';
952
+	$cc_info['card_exp_year']  = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : '';
953
+	$cc_info['card_address']   = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : '';
954
+	$cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : '';
955
+	$cc_info['card_city']      = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : '';
956
+	$cc_info['card_state']     = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : '';
957
+	$cc_info['card_country']   = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : '';
958
+	$cc_info['card_zip']       = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : '';
959 959
 
960 960
 	// Return cc info
961 961
 	return $cc_info;
@@ -971,14 +971,14 @@  discard block
 block discarded – undo
971 971
  *
972 972
  * @return bool|mixed|void
973 973
  */
974
-function give_purchase_form_validate_cc_zip( $zip = 0, $country_code = '' ) {
974
+function give_purchase_form_validate_cc_zip($zip = 0, $country_code = '') {
975 975
 	$ret = false;
976 976
 
977
-	if ( empty( $zip ) || empty( $country_code ) ) {
977
+	if (empty($zip) || empty($country_code)) {
978 978
 		return $ret;
979 979
 	}
980 980
 
981
-	$country_code = strtoupper( $country_code );
981
+	$country_code = strtoupper($country_code);
982 982
 
983 983
 	$zip_regex = array(
984 984
 		"AD" => "AD\d{3}",
@@ -1138,11 +1138,11 @@  discard block
 block discarded – undo
1138 1138
 		"ZM" => "\d{5}"
1139 1139
 	);
1140 1140
 
1141
-	if ( ! isset ( $zip_regex[ $country_code ] ) || preg_match( "/" . $zip_regex[ $country_code ] . "/i", $zip ) ) {
1141
+	if ( ! isset ($zip_regex[$country_code]) || preg_match("/".$zip_regex[$country_code]."/i", $zip)) {
1142 1142
 		$ret = true;
1143 1143
 	}
1144 1144
 
1145
-	return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code );
1145
+	return apply_filters('give_is_zip_valid', $ret, $zip, $country_code);
1146 1146
 }
1147 1147
 
1148 1148
 
@@ -1156,37 +1156,37 @@  discard block
 block discarded – undo
1156 1156
  *
1157 1157
  * @return bool
1158 1158
  */
1159
-function give_validate_multi_donation_form_level(  $valid_data, $data ) {
1159
+function give_validate_multi_donation_form_level($valid_data, $data) {
1160 1160
     /* @var Give_Donate_Form $form*/
1161
-    $form = new Give_Donate_Form( $data['give-form-id'] );
1161
+    $form = new Give_Donate_Form($data['give-form-id']);
1162 1162
 
1163 1163
     $donation_level_matched = false;
1164 1164
 
1165
-    if( $form->is_multi_type_donation_form() ) {
1165
+    if ($form->is_multi_type_donation_form()) {
1166 1166
 
1167 1167
         // Bailout.
1168
-        if( ! ( $variable_prices = $form->get_prices() ) ) {
1168
+        if ( ! ($variable_prices = $form->get_prices())) {
1169 1169
             return false;
1170 1170
         }
1171 1171
 
1172 1172
         // Sanitize donation amount.
1173
-        $data['give-amount'] = give_sanitize_amount( $data['give-amount'] );
1173
+        $data['give-amount'] = give_sanitize_amount($data['give-amount']);
1174 1174
 
1175 1175
         // Get number of decimals.
1176 1176
         $default_decimals = give_get_price_decimals();
1177 1177
 
1178
-        if( $data['give-amount'] === give_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ), $default_decimals ) ){
1178
+        if ($data['give-amount'] === give_sanitize_amount(give_get_price_option_amount($data['give-form-id'], $data['give-price-id']), $default_decimals)) {
1179 1179
             return true;
1180 1180
         }
1181 1181
 
1182 1182
         
1183 1183
         // Find correct donation level from all donation levels.
1184
-        foreach ( $variable_prices as $variable_price ) {
1184
+        foreach ($variable_prices as $variable_price) {
1185 1185
             // Sanitize level amount.
1186
-            $variable_price['_give_amount'] = give_sanitize_amount( $variable_price['_give_amount'], $default_decimals );
1186
+            $variable_price['_give_amount'] = give_sanitize_amount($variable_price['_give_amount'], $default_decimals);
1187 1187
 
1188 1188
             // Set first match donation level ID.
1189
-            if( $data['give-amount'] === $variable_price['_give_amount'] ) {
1189
+            if ($data['give-amount'] === $variable_price['_give_amount']) {
1190 1190
                 $_POST['give-price-id'] = $variable_price['_give_id']['level_id'];
1191 1191
                 $donation_level_matched = true;
1192 1192
                 break;
@@ -1195,20 +1195,20 @@  discard block
 block discarded – undo
1195 1195
 
1196 1196
         // If donation amount is not find in donation levels then check if form has custom donation feature enable or not.
1197 1197
         // If yes then set price id to custom if amount is greater then custom minimum amount (if any).
1198
-        if(
1198
+        if (
1199 1199
             ! $donation_level_matched
1200
-            && ( 'yes' === get_post_meta( $data['give-form-id'], '_give_custom_amount', true ) )
1200
+            && ('yes' === get_post_meta($data['give-form-id'], '_give_custom_amount', true))
1201 1201
         ) {
1202 1202
             // Sanitize custom minimum amount.
1203
-            $custom_minimum_amount = give_sanitize_amount( get_post_meta( $data['give-form-id'], '_give_custom_amount_minimum', true ), $default_decimals );
1203
+            $custom_minimum_amount = give_sanitize_amount(get_post_meta($data['give-form-id'], '_give_custom_amount_minimum', true), $default_decimals);
1204 1204
 
1205
-            if( $data['give-amount'] >= $custom_minimum_amount ) {
1205
+            if ($data['give-amount'] >= $custom_minimum_amount) {
1206 1206
                 $_POST['give-price-id'] = 'custom';
1207
-                $donation_level_matched  = true;
1207
+                $donation_level_matched = true;
1208 1208
             }
1209 1209
         }
1210 1210
     }
1211 1211
 
1212
-    return ( $donation_level_matched ? true : false );
1212
+    return ($donation_level_matched ? true : false);
1213 1213
 }
1214
-add_action( 'give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2 );
1215 1214
\ No newline at end of file
1215
+add_action('give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2);
1216 1216
\ No newline at end of file
Please login to merge, or discard this patch.
includes/scripts.php 1 patch
Spacing   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -25,106 +25,106 @@  discard block
 block discarded – undo
25 25
  */
26 26
 function give_load_scripts() {
27 27
 
28
-	$js_dir         = GIVE_PLUGIN_URL . 'assets/js/frontend/';
29
-	$js_plugins     = GIVE_PLUGIN_URL . 'assets/js/plugins/';
30
-	$scripts_footer = ( give_get_option( 'scripts_footer' ) == 'on' ) ? true : false;
28
+	$js_dir         = GIVE_PLUGIN_URL.'assets/js/frontend/';
29
+	$js_plugins     = GIVE_PLUGIN_URL.'assets/js/plugins/';
30
+	$scripts_footer = (give_get_option('scripts_footer') == 'on') ? true : false;
31 31
 
32 32
 	// Use minified libraries if SCRIPT_DEBUG is turned off
33
-	$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
33
+	$suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
34 34
 
35 35
 	//Localize / PHP to AJAX vars
36
-	$localize_give_checkout = apply_filters( 'give_global_script_vars', array(
36
+	$localize_give_checkout = apply_filters('give_global_script_vars', array(
37 37
 		'ajaxurl'             => give_get_ajax_url(),
38
-		'checkout_nonce'      => wp_create_nonce( 'give_checkout_nonce' ),
39
-		'currency_sign'       => give_currency_filter( '' ),
38
+		'checkout_nonce'      => wp_create_nonce('give_checkout_nonce'),
39
+		'currency_sign'       => give_currency_filter(''),
40 40
 		'currency_pos'        => give_get_currency_position(),
41 41
 		'thousands_separator' => give_get_price_thousand_separator(),
42 42
 		'decimal_separator'   => give_get_price_decimal_separator(),
43
-		'no_gateway'          => esc_html__( 'Please select a payment method.', 'give' ),
44
-		'bad_minimum'         => esc_html__( 'The minimum donation amount for this form is', 'give' ),
45
-		'general_loading'     => esc_html__( 'Loading...', 'give' ),
46
-		'purchase_loading'    => esc_html__( 'Please Wait...', 'give' ),
43
+		'no_gateway'          => esc_html__('Please select a payment method.', 'give'),
44
+		'bad_minimum'         => esc_html__('The minimum donation amount for this form is', 'give'),
45
+		'general_loading'     => esc_html__('Loading...', 'give'),
46
+		'purchase_loading'    => esc_html__('Please Wait...', 'give'),
47 47
 		'number_decimals'     => give_get_price_decimals(),
48 48
 		'give_version'        => GIVE_VERSION,
49 49
 		'form_translation'    => apply_filters(
50 50
 			'give_form_translation_js',
51 51
 			array(
52 52
 				// Field name               Validation message.
53
-				'payment-mode'           => esc_html__( 'Please select payment mode.', 'give' ),
54
-				'give_first'             => esc_html__( 'Please enter your first name.', 'give' ),
55
-				'give_email'             => esc_html__( 'Please enter a valid email address.', 'give' ),
56
-				'give_user_login'        => esc_html__( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ),
57
-				'give_user_pass'         => esc_html__( 'Enter a password.', 'give' ),
58
-				'give_user_pass_confirm' => esc_html__( 'Enter a confirm password.', 'give' ),
53
+				'payment-mode'           => esc_html__('Please select payment mode.', 'give'),
54
+				'give_first'             => esc_html__('Please enter your first name.', 'give'),
55
+				'give_email'             => esc_html__('Please enter a valid email address.', 'give'),
56
+				'give_user_login'        => esc_html__('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give'),
57
+				'give_user_pass'         => esc_html__('Enter a password.', 'give'),
58
+				'give_user_pass_confirm' => esc_html__('Enter a confirm password.', 'give'),
59 59
 			)
60 60
 		)
61
-	) );
62
-	$localize_give_ajax     = apply_filters( 'give_global_ajax_vars', array(
61
+	));
62
+	$localize_give_ajax = apply_filters('give_global_ajax_vars', array(
63 63
 		'ajaxurl'         => give_get_ajax_url(),
64
-		'loading'         => esc_html__( 'Loading', 'give' ),
64
+		'loading'         => esc_html__('Loading', 'give'),
65 65
 		// General loading message
66
-		'select_option'   => esc_html__( 'Please select an option', 'give' ),
66
+		'select_option'   => esc_html__('Please select an option', 'give'),
67 67
 		// Variable pricing error with multi-donation option enabled
68
-		'default_gateway' => give_get_default_gateway( null ),
69
-		'permalinks'      => get_option( 'permalink_structure' ) ? '1' : '0',
68
+		'default_gateway' => give_get_default_gateway(null),
69
+		'permalinks'      => get_option('permalink_structure') ? '1' : '0',
70 70
 		'number_decimals' => give_get_price_decimals()
71
-	) );
71
+	));
72 72
 
73 73
 	//DEBUG is On
74
-	if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
74
+	if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) {
75 75
 
76
-		if ( give_is_cc_verify_enabled() ) {
77
-			wp_register_script( 'give-cc-validator', $js_plugins . 'jquery.payment' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
78
-			wp_enqueue_script( 'give-cc-validator' );
76
+		if (give_is_cc_verify_enabled()) {
77
+			wp_register_script('give-cc-validator', $js_plugins.'jquery.payment'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
78
+			wp_enqueue_script('give-cc-validator');
79 79
 		}
80 80
 
81
-		wp_register_script( 'give-float-labels', $js_plugins . 'float-labels' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
82
-		wp_enqueue_script( 'give-float-labels' );
81
+		wp_register_script('give-float-labels', $js_plugins.'float-labels'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
82
+		wp_enqueue_script('give-float-labels');
83 83
 
84
-		wp_register_script( 'give-blockui', $js_plugins . 'jquery.blockUI' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
85
-		wp_enqueue_script( 'give-blockui' );
84
+		wp_register_script('give-blockui', $js_plugins.'jquery.blockUI'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
85
+		wp_enqueue_script('give-blockui');
86 86
 
87
-		wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
88
-		wp_enqueue_script( 'give-qtip' );
87
+		wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
88
+		wp_enqueue_script('give-qtip');
89 89
 
90
-		wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
91
-		wp_enqueue_script( 'give-accounting' );
90
+		wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
91
+		wp_enqueue_script('give-accounting');
92 92
 
93
-		wp_register_script( 'give-magnific', $js_plugins . 'jquery.magnific-popup' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
94
-		wp_enqueue_script( 'give-magnific' );
93
+		wp_register_script('give-magnific', $js_plugins.'jquery.magnific-popup'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
94
+		wp_enqueue_script('give-magnific');
95 95
 
96
-		wp_register_script( 'give-checkout-global', $js_dir . 'give-checkout-global' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
97
-		wp_enqueue_script( 'give-checkout-global' );
96
+		wp_register_script('give-checkout-global', $js_dir.'give-checkout-global'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
97
+		wp_enqueue_script('give-checkout-global');
98 98
 
99 99
 		//General scripts
100
-		wp_register_script( 'give-scripts', $js_dir . 'give' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
101
-		wp_enqueue_script( 'give-scripts' );
100
+		wp_register_script('give-scripts', $js_dir.'give'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
101
+		wp_enqueue_script('give-scripts');
102 102
 
103 103
 		// Load AJAX scripts, if enabled
104
-		wp_register_script( 'give-ajax', $js_dir . 'give-ajax' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
105
-		wp_enqueue_script( 'give-ajax' );
104
+		wp_register_script('give-ajax', $js_dir.'give-ajax'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
105
+		wp_enqueue_script('give-ajax');
106 106
 
107 107
 		//Localize / Pass AJAX vars from PHP
108
-		wp_localize_script( 'give-checkout-global', 'give_global_vars', $localize_give_checkout );
109
-		wp_localize_script( 'give-ajax', 'give_scripts', $localize_give_ajax );
108
+		wp_localize_script('give-checkout-global', 'give_global_vars', $localize_give_checkout);
109
+		wp_localize_script('give-ajax', 'give_scripts', $localize_give_ajax);
110 110
 
111 111
 
112 112
 	} else {
113 113
 
114 114
 		//DEBUG is OFF (one JS file to rule them all!)
115
-		wp_register_script( 'give', $js_dir . 'give.all.min.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
116
-		wp_enqueue_script( 'give' );
115
+		wp_register_script('give', $js_dir.'give.all.min.js', array('jquery'), GIVE_VERSION, $scripts_footer);
116
+		wp_enqueue_script('give');
117 117
 
118 118
 		//Localize / Pass AJAX vars from PHP
119
-		wp_localize_script( 'give', 'give_global_vars', $localize_give_checkout );
120
-		wp_localize_script( 'give', 'give_scripts', $localize_give_ajax );
119
+		wp_localize_script('give', 'give_global_vars', $localize_give_checkout);
120
+		wp_localize_script('give', 'give_scripts', $localize_give_ajax);
121 121
 
122 122
 	}
123 123
 
124 124
 
125 125
 }
126 126
 
127
-add_action( 'wp_enqueue_scripts', 'give_load_scripts' );
127
+add_action('wp_enqueue_scripts', 'give_load_scripts');
128 128
 
129 129
 /**
130 130
  * Register styles.
@@ -136,16 +136,16 @@  discard block
 block discarded – undo
136 136
  */
137 137
 function give_register_styles() {
138 138
 
139
-	if ( give_get_option( 'disable_css', false ) ) {
139
+	if (give_get_option('disable_css', false)) {
140 140
 		return;
141 141
 	}
142 142
 
143
-	wp_register_style( 'give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all' );
144
-	wp_enqueue_style( 'give-styles' );
143
+	wp_register_style('give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all');
144
+	wp_enqueue_style('give-styles');
145 145
 
146 146
 }
147 147
 
148
-add_action( 'wp_enqueue_scripts', 'give_register_styles' );
148
+add_action('wp_enqueue_scripts', 'give_register_styles');
149 149
 
150 150
 
151 151
 /**
@@ -157,42 +157,42 @@  discard block
 block discarded – undo
157 157
 function give_get_stylesheet_uri() {
158 158
 
159 159
 	// Use minified libraries if SCRIPT_DEBUG is turned off
160
-	$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
160
+	$suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
161 161
 
162 162
 	// LTR or RTL files
163
-	$direction = ( is_rtl() ) ? '-rtl' : '';
163
+	$direction = (is_rtl()) ? '-rtl' : '';
164 164
 
165
-	$file          = 'give' . $direction . $suffix . '.css';
165
+	$file          = 'give'.$direction.$suffix.'.css';
166 166
 	$templates_dir = give_get_theme_template_dir_name();
167 167
 
168
-	$child_theme_style_sheet    = trailingslashit( get_stylesheet_directory() ) . $templates_dir . $file;
169
-	$child_theme_style_sheet_2  = trailingslashit( get_stylesheet_directory() ) . $templates_dir . 'give' . $direction . '.css';
170
-	$parent_theme_style_sheet   = trailingslashit( get_template_directory() ) . $templates_dir . $file;
171
-	$parent_theme_style_sheet_2 = trailingslashit( get_template_directory() ) . $templates_dir . 'give' . $direction . '.css';
172
-	$give_plugin_style_sheet    = trailingslashit( give_get_templates_dir() ) . $file;
168
+	$child_theme_style_sheet    = trailingslashit(get_stylesheet_directory()).$templates_dir.$file;
169
+	$child_theme_style_sheet_2  = trailingslashit(get_stylesheet_directory()).$templates_dir.'give'.$direction.'.css';
170
+	$parent_theme_style_sheet   = trailingslashit(get_template_directory()).$templates_dir.$file;
171
+	$parent_theme_style_sheet_2 = trailingslashit(get_template_directory()).$templates_dir.'give'.$direction.'.css';
172
+	$give_plugin_style_sheet    = trailingslashit(give_get_templates_dir()).$file;
173 173
 
174 174
 	$uri = false;
175 175
 
176 176
 	// Look in the child theme directory first, followed by the parent theme, followed by the Give core templates directory
177 177
 	// Also look for the min version first, followed by non minified version, even if SCRIPT_DEBUG is not enabled.
178 178
 	// This allows users to copy just give.css to their theme
179
-	if ( file_exists( $child_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $child_theme_style_sheet_2 ) ) ) ) {
180
-		if ( ! empty( $nonmin ) ) {
181
-			$uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . 'give' . $direction . '.css';
179
+	if (file_exists($child_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($child_theme_style_sheet_2)))) {
180
+		if ( ! empty($nonmin)) {
181
+			$uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.'give'.$direction.'.css';
182 182
 		} else {
183
-			$uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . $file;
183
+			$uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.$file;
184 184
 		}
185
-	} elseif ( file_exists( $parent_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $parent_theme_style_sheet_2 ) ) ) ) {
186
-		if ( ! empty( $nonmin ) ) {
187
-			$uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . 'give' . $direction . '.css';
185
+	} elseif (file_exists($parent_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($parent_theme_style_sheet_2)))) {
186
+		if ( ! empty($nonmin)) {
187
+			$uri = trailingslashit(get_template_directory_uri()).$templates_dir.'give'.$direction.'.css';
188 188
 		} else {
189
-			$uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . $file;
189
+			$uri = trailingslashit(get_template_directory_uri()).$templates_dir.$file;
190 190
 		}
191
-	} elseif ( file_exists( $give_plugin_style_sheet ) || file_exists( $give_plugin_style_sheet ) ) {
192
-		$uri = trailingslashit( give_get_templates_url() ) . $file;
191
+	} elseif (file_exists($give_plugin_style_sheet) || file_exists($give_plugin_style_sheet)) {
192
+		$uri = trailingslashit(give_get_templates_url()).$file;
193 193
 	}
194 194
 
195
-	return apply_filters( 'give_get_stylesheet_uri', $uri );
195
+	return apply_filters('give_get_stylesheet_uri', $uri);
196 196
 
197 197
 }
198 198
 
@@ -209,70 +209,70 @@  discard block
 block discarded – undo
209 209
  *
210 210
  * @return void
211 211
  */
212
-function give_load_admin_scripts( $hook ) {
212
+function give_load_admin_scripts($hook) {
213 213
 
214 214
 	global $post, $post_type;
215 215
 
216 216
 	$give_options = give_get_settings();
217 217
 
218 218
 	//Directories of assets
219
-	$js_dir     = GIVE_PLUGIN_URL . 'assets/js/admin/';
220
-	$js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/';
221
-	$css_dir    = GIVE_PLUGIN_URL . 'assets/css/';
219
+	$js_dir     = GIVE_PLUGIN_URL.'assets/js/admin/';
220
+	$js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/';
221
+	$css_dir    = GIVE_PLUGIN_URL.'assets/css/';
222 222
 
223 223
 	// Use minified libraries if SCRIPT_DEBUG is turned off
224
-	$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
224
+	$suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
225 225
 
226 226
 	// LTR or RTL files
227
-	$direction = ( is_rtl() ) ? '-rtl' : '';
227
+	$direction = (is_rtl()) ? '-rtl' : '';
228 228
 
229 229
 	//Global Admin:
230
-	wp_register_style( 'give-admin-bar-notification', $css_dir . 'adminbar-style.css' );
231
-	wp_enqueue_style( 'give-admin-bar-notification' );
230
+	wp_register_style('give-admin-bar-notification', $css_dir.'adminbar-style.css');
231
+	wp_enqueue_style('give-admin-bar-notification');
232 232
 
233 233
 	//Give Admin Only:
234
-	if ( ! apply_filters( 'give_load_admin_scripts', give_is_admin_page(), $hook ) ) {
234
+	if ( ! apply_filters('give_load_admin_scripts', give_is_admin_page(), $hook)) {
235 235
 		return;
236 236
 	}
237 237
 
238 238
 	//CSS
239
-	wp_register_style( 'jquery-ui-css', $css_dir . 'jquery-ui-fresh' . $suffix . '.css' );
240
-	wp_enqueue_style( 'jquery-ui-css' );
241
-	wp_register_style( 'give-admin', $css_dir . 'give-admin' . $direction . $suffix . '.css', GIVE_VERSION );
242
-	wp_enqueue_style( 'give-admin' );
243
-	wp_register_style( 'jquery-chosen', $css_dir . 'chosen' . $suffix . '.css', array(), GIVE_VERSION );
244
-	wp_enqueue_style( 'jquery-chosen' );
245
-	wp_enqueue_style( 'thickbox' );
239
+	wp_register_style('jquery-ui-css', $css_dir.'jquery-ui-fresh'.$suffix.'.css');
240
+	wp_enqueue_style('jquery-ui-css');
241
+	wp_register_style('give-admin', $css_dir.'give-admin'.$direction.$suffix.'.css', GIVE_VERSION);
242
+	wp_enqueue_style('give-admin');
243
+	wp_register_style('jquery-chosen', $css_dir.'chosen'.$suffix.'.css', array(), GIVE_VERSION);
244
+	wp_enqueue_style('jquery-chosen');
245
+	wp_enqueue_style('thickbox');
246 246
 
247 247
 	//JS
248
-	wp_register_script( 'jquery-chosen', $js_plugins . 'chosen.jquery' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION );
249
-	wp_enqueue_script( 'jquery-chosen' );
248
+	wp_register_script('jquery-chosen', $js_plugins.'chosen.jquery'.$suffix.'.js', array('jquery'), GIVE_VERSION);
249
+	wp_enqueue_script('jquery-chosen');
250 250
 
251
-	wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
252
-	wp_enqueue_script( 'give-accounting' );
251
+	wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
252
+	wp_enqueue_script('give-accounting');
253 253
 
254
-	wp_register_script( 'give-admin-scripts', $js_dir . 'admin-scripts' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
255
-	wp_enqueue_script( 'give-admin-scripts' );
254
+	wp_register_script('give-admin-scripts', $js_dir.'admin-scripts'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
255
+	wp_enqueue_script('give-admin-scripts');
256 256
 
257
-	wp_register_script( 'jquery-flot', $js_plugins . 'jquery.flot' . $suffix . '.js' );
258
-	wp_enqueue_script( 'jquery-flot' );
257
+	wp_register_script('jquery-flot', $js_plugins.'jquery.flot'.$suffix.'.js');
258
+	wp_enqueue_script('jquery-flot');
259 259
 
260
-	wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
261
-	wp_enqueue_script( 'give-qtip' );
260
+	wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
261
+	wp_enqueue_script('give-qtip');
262 262
 
263
-	wp_enqueue_script( 'jquery-ui-datepicker' );
264
-	wp_enqueue_script( 'thickbox' );
263
+	wp_enqueue_script('jquery-ui-datepicker');
264
+	wp_enqueue_script('thickbox');
265 265
 
266 266
 	// Forms CPT Script.
267
-	if ( $post_type === 'give_forms' ) {
268
-		wp_register_script( 'give-admin-forms-scripts', $js_dir . 'admin-forms' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
269
-		wp_enqueue_script( 'give-admin-forms-scripts' );
267
+	if ($post_type === 'give_forms') {
268
+		wp_register_script('give-admin-forms-scripts', $js_dir.'admin-forms'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
269
+		wp_enqueue_script('give-admin-forms-scripts');
270 270
 	}
271 271
 
272 272
 	//Settings Scripts
273
-	if ( isset( $_GET['page'] ) && $_GET['page'] == 'give-settings' ) {
274
-		wp_register_script( 'give-admin-settings-scripts', $js_dir . 'admin-settings' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
275
-		wp_enqueue_script( 'give-admin-settings-scripts' );
273
+	if (isset($_GET['page']) && $_GET['page'] == 'give-settings') {
274
+		wp_register_script('give-admin-settings-scripts', $js_dir.'admin-settings'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
275
+		wp_enqueue_script('give-admin-settings-scripts');
276 276
 	}
277 277
 
278 278
 	// Price Separators.
@@ -280,46 +280,46 @@  discard block
 block discarded – undo
280 280
 	$decimal_separator  = give_get_price_decimal_separator();
281 281
 
282 282
 	//Localize strings & variables for JS
283
-	wp_localize_script( 'give-admin-scripts', 'give_vars', array(
284
-		'post_id'                 => isset( $post->ID ) ? $post->ID : null,
283
+	wp_localize_script('give-admin-scripts', 'give_vars', array(
284
+		'post_id'                 => isset($post->ID) ? $post->ID : null,
285 285
 		'give_version'            => GIVE_VERSION,
286 286
 		'thousands_separator'     => $thousand_separator,
287 287
 		'decimal_separator'       => $decimal_separator,
288
-		'quick_edit_warning'      => esc_html__( 'Not available for variable priced forms.', 'give' ),
289
-		'delete_payment'          => esc_html__( 'Are you sure you wish to delete this payment?', 'give' ),
290
-		'delete_payment_note'     => esc_html__( 'Are you sure you wish to delete this note?', 'give' ),
291
-		'revoke_api_key'          => esc_html__( 'Are you sure you wish to revoke this API key?', 'give' ),
292
-		'regenerate_api_key'      => esc_html__( 'Are you sure you wish to regenerate this API key?', 'give' ),
293
-		'resend_receipt'          => esc_html__( 'Are you sure you wish to resend the donation receipt?', 'give' ),
294
-		'copy_download_link_text' => esc_html__( 'Copy these links to your clipboard and give them to your donor.', 'give' ),
295
-		'delete_payment_download' => esc_html__( 'Are you sure you wish to delete this form?', 'give' ),
296
-		'one_price_min'           => esc_html__( 'You must have at least one price.', 'give' ),
297
-		'one_file_min'            => esc_html__( 'You must have at least one file.', 'give' ),
298
-		'one_field_min'           => esc_html__( 'You must have at least one field.', 'give' ),
299
-		'one_option'              => esc_html__( 'Choose a form', 'give' ),
300
-		'one_or_more_option'      => esc_html__( 'Choose one or more forms', 'give' ),
301
-		'numeric_item_price'      => esc_html__( 'Item price must be numeric.', 'give' ),
302
-		'numeric_quantity'        => esc_html__( 'Quantity must be numeric.', 'give' ),
303
-		'currency_sign'           => give_currency_filter( '' ),
304
-		'currency_pos'            => isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before',
305
-		'currency_decimals'       => give_currency_decimal_filter( give_get_price_decimals() ),
306
-		'new_media_ui'            => apply_filters( 'give_use_35_media_ui', 1 ),
307
-		'remove_text'             => esc_html__( 'Remove', 'give' ),
308
-		'type_to_search'          => esc_html__( 'Type to search forms', 'give' ),
309
-		'batch_export_no_class'   => esc_html__( 'You must choose a method.', 'give' ),
310
-		'batch_export_no_reqs'    => esc_html__( 'Required fields not completed.', 'give' ),
311
-		'reset_stats_warn'        => __( 'Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give' ),
312
-		'price_format_guide'      => sprintf( esc_html__( 'Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give' ), $decimal_separator, $thousand_separator )
313
-	) );
314
-
315
-	if ( function_exists( 'wp_enqueue_media' ) && version_compare( get_bloginfo( 'version' ), '3.5', '>=' ) ) {
288
+		'quick_edit_warning'      => esc_html__('Not available for variable priced forms.', 'give'),
289
+		'delete_payment'          => esc_html__('Are you sure you wish to delete this payment?', 'give'),
290
+		'delete_payment_note'     => esc_html__('Are you sure you wish to delete this note?', 'give'),
291
+		'revoke_api_key'          => esc_html__('Are you sure you wish to revoke this API key?', 'give'),
292
+		'regenerate_api_key'      => esc_html__('Are you sure you wish to regenerate this API key?', 'give'),
293
+		'resend_receipt'          => esc_html__('Are you sure you wish to resend the donation receipt?', 'give'),
294
+		'copy_download_link_text' => esc_html__('Copy these links to your clipboard and give them to your donor.', 'give'),
295
+		'delete_payment_download' => esc_html__('Are you sure you wish to delete this form?', 'give'),
296
+		'one_price_min'           => esc_html__('You must have at least one price.', 'give'),
297
+		'one_file_min'            => esc_html__('You must have at least one file.', 'give'),
298
+		'one_field_min'           => esc_html__('You must have at least one field.', 'give'),
299
+		'one_option'              => esc_html__('Choose a form', 'give'),
300
+		'one_or_more_option'      => esc_html__('Choose one or more forms', 'give'),
301
+		'numeric_item_price'      => esc_html__('Item price must be numeric.', 'give'),
302
+		'numeric_quantity'        => esc_html__('Quantity must be numeric.', 'give'),
303
+		'currency_sign'           => give_currency_filter(''),
304
+		'currency_pos'            => isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before',
305
+		'currency_decimals'       => give_currency_decimal_filter(give_get_price_decimals()),
306
+		'new_media_ui'            => apply_filters('give_use_35_media_ui', 1),
307
+		'remove_text'             => esc_html__('Remove', 'give'),
308
+		'type_to_search'          => esc_html__('Type to search forms', 'give'),
309
+		'batch_export_no_class'   => esc_html__('You must choose a method.', 'give'),
310
+		'batch_export_no_reqs'    => esc_html__('Required fields not completed.', 'give'),
311
+		'reset_stats_warn'        => __('Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give'),
312
+		'price_format_guide'      => sprintf(esc_html__('Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give'), $decimal_separator, $thousand_separator)
313
+	));
314
+
315
+	if (function_exists('wp_enqueue_media') && version_compare(get_bloginfo('version'), '3.5', '>=')) {
316 316
 		//call for new media manager
317 317
 		wp_enqueue_media();
318 318
 	}
319 319
 
320 320
 }
321 321
 
322
-add_action( 'admin_enqueue_scripts', 'give_load_admin_scripts', 100 );
322
+add_action('admin_enqueue_scripts', 'give_load_admin_scripts', 100);
323 323
 
324 324
 /**
325 325
  * Admin Give Icon
@@ -334,14 +334,14 @@  discard block
 block discarded – undo
334 334
 	?>
335 335
 	<style type="text/css" media="screen">
336 336
 
337
-		<?php if( version_compare( get_bloginfo( 'version' ), '3.8-RC', '>=' ) || version_compare( get_bloginfo( 'version' ), '3.8', '>=' ) ) { ?>
337
+		<?php if (version_compare(get_bloginfo('version'), '3.8-RC', '>=') || version_compare(get_bloginfo('version'), '3.8', '>=')) { ?>
338 338
 		@font-face {
339 339
 			font-family: 'give-icomoon';
340
-			src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?-ngjl88'; ?>');
341
-			src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?#iefix-ngjl88'?>') format('embedded-opentype'),
342
-			url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.woff?-ngjl88'; ?>') format('woff'),
343
-			url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.ttf?-ngjl88'; ?>') format('truetype'),
344
-			url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.svg?-ngjl88#icomoon'; ?>') format('svg');
340
+			src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?-ngjl88'; ?>');
341
+			src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?#iefix-ngjl88'?>') format('embedded-opentype'),
342
+			url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.woff?-ngjl88'; ?>') format('woff'),
343
+			url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.ttf?-ngjl88'; ?>') format('truetype'),
344
+			url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.svg?-ngjl88#icomoon'; ?>') format('svg');
345 345
 			font-weight: normal;
346 346
 			font-style: normal;
347 347
 		}
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 	<?php
361 361
 }
362 362
 
363
-add_action( 'admin_head', 'give_admin_icon' );
363
+add_action('admin_head', 'give_admin_icon');
364 364
 
365 365
 /**
366 366
  * Admin js code
@@ -390,4 +390,4 @@  discard block
 block discarded – undo
390 390
 	<?php
391 391
 }
392 392
 
393
-add_action( 'admin_head', 'give_admin_hide_notice_shortly_js' );
393
+add_action('admin_head', 'give_admin_hide_notice_shortly_js');
Please login to merge, or discard this patch.
includes/gateways/paypal-standard.php 1 patch
Spacing   +183 added lines, -183 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 Purchase.
@@ -32,14 +32,14 @@  discard block
 block discarded – undo
32 32
  *
33 33
  * @return void
34 34
  */
35
-function give_process_paypal_purchase( $purchase_data ) {
35
+function give_process_paypal_purchase($purchase_data) {
36 36
 
37
-	if ( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'give-gateway' ) ) {
38
-		wp_die( esc_html__( 'Nonce verification has failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
37
+	if ( ! wp_verify_nonce($purchase_data['gateway_nonce'], 'give-gateway')) {
38
+		wp_die(esc_html__('Nonce verification has failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
39 39
 	}
40 40
 
41
-	$form_id  = intval( $purchase_data['post_data']['give-form-id'] );
42
-	$price_id = isset( $purchase_data['post_data']['give-price-id'] ) ? $purchase_data['post_data']['give-price-id'] : '';
41
+	$form_id  = intval($purchase_data['post_data']['give-form-id']);
42
+	$price_id = isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : '';
43 43
 
44 44
 	// Collect payment data.
45 45
 	$payment_data = array(
@@ -57,69 +57,69 @@  discard block
 block discarded – undo
57 57
 	);
58 58
 
59 59
 	// Record the pending payment.
60
-	$payment = give_insert_payment( $payment_data );
60
+	$payment = give_insert_payment($payment_data);
61 61
 
62 62
 	// Check payment.
63
-	if ( ! $payment ) {
63
+	if ( ! $payment) {
64 64
 		// Record the error.
65 65
 		give_record_gateway_error(
66
-			esc_html__( 'Payment Error', 'give' ),
66
+			esc_html__('Payment Error', 'give'),
67 67
 			sprintf(
68 68
 			/* translators: %s: payment data */
69
-				esc_html__( 'Payment creation failed before sending buyer to PayPal. Payment data: %s', 'give' ),
70
-				json_encode( $payment_data )
69
+				esc_html__('Payment creation failed before sending buyer to PayPal. Payment data: %s', 'give'),
70
+				json_encode($payment_data)
71 71
 			),
72 72
 			$payment
73 73
 		);
74 74
 		// Problems? Send back.
75
-		give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] );
75
+		give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']);
76 76
 
77 77
 	} else {
78 78
 
79 79
 		// Only send to PayPal if the pending payment is created successfully.
80
-		$listener_url = add_query_arg( 'give-listener', 'IPN', home_url( 'index.php' ) );
80
+		$listener_url = add_query_arg('give-listener', 'IPN', home_url('index.php'));
81 81
 
82 82
 		// Get the success url
83
-		$return_url = add_query_arg( array(
83
+		$return_url = add_query_arg(array(
84 84
 			'payment-confirmation' => 'paypal',
85 85
 			'payment-id'           => $payment
86 86
 
87
-		), get_permalink( give_get_option( 'success_page' ) ) );
87
+		), get_permalink(give_get_option('success_page')));
88 88
 
89 89
 		// Get the PayPal redirect uri
90
-		$paypal_redirect = trailingslashit( give_get_paypal_redirect() ) . '?';
90
+		$paypal_redirect = trailingslashit(give_get_paypal_redirect()).'?';
91 91
 
92 92
 		//Item name - pass level name if variable priced
93 93
 		$item_name = $purchase_data['post_data']['give-form-title'];
94 94
 
95 95
 		//Verify has variable prices
96
-		if ( give_has_variable_prices( $form_id ) && isset( $purchase_data['post_data']['give-price-id'] ) ) {
96
+		if (give_has_variable_prices($form_id) && isset($purchase_data['post_data']['give-price-id'])) {
97 97
 
98
-			$item_price_level_text = give_get_price_option_name( $form_id, $purchase_data['post_data']['give-price-id'] );
98
+			$item_price_level_text = give_get_price_option_name($form_id, $purchase_data['post_data']['give-price-id']);
99 99
 
100
-			$price_level_amount = give_get_price_option_amount( $form_id, $purchase_data['post_data']['give-price-id'] );
100
+			$price_level_amount = give_get_price_option_amount($form_id, $purchase_data['post_data']['give-price-id']);
101 101
 
102 102
 			//Donation given doesn't match selected level (must be a custom amount)
103
-			if ( $price_level_amount != give_sanitize_amount( $purchase_data['price'] ) ) {
104
-				$custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true );
103
+			if ($price_level_amount != give_sanitize_amount($purchase_data['price'])) {
104
+				$custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true);
105 105
 				//user custom amount text if any, fallback to default if not
106
-				$item_name .= ' - ' . ( ! empty( $custom_amount_text ) ? $custom_amount_text : esc_html__( 'Custom Amount', 'give' ) );
106
+				$item_name .= ' - '.( ! empty($custom_amount_text) ? $custom_amount_text : esc_html__('Custom Amount', 'give'));
107 107
 
108 108
 			} //Is there any donation level text?
109
-			elseif ( ! empty( $item_price_level_text ) ) {
110
-				$item_name .= ' - ' . $item_price_level_text;
109
+			elseif ( ! empty($item_price_level_text)) {
110
+				$item_name .= ' - '.$item_price_level_text;
111 111
 			}
112 112
 
113 113
 		} //Single donation: Custom Amount
114
-		elseif ( give_get_form_price( $form_id ) !== give_sanitize_amount( $purchase_data['price'] ) ) {
115
-			$custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true );
114
+		elseif (give_get_form_price($form_id) !== give_sanitize_amount($purchase_data['price'])) {
115
+			$custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true);
116 116
 			//user custom amount text if any, fallback to default if not
117
-			$item_name .= ' - ' . ( ! empty( $custom_amount_text ) ? $custom_amount_text : esc_html__( 'Custom Amount', 'give' ) );
117
+			$item_name .= ' - '.( ! empty($custom_amount_text) ? $custom_amount_text : esc_html__('Custom Amount', 'give'));
118 118
 		}
119 119
 
120 120
 		// Setup PayPal arguments
121 121
 		$paypal_args = array(
122
-			'business'      => give_get_option( 'paypal_email', false ),
122
+			'business'      => give_get_option('paypal_email', false),
123 123
 			'first_name'    => $purchase_data['user_info']['first_name'],
124 124
 			'last_name'     => $purchase_data['user_info']['last_name'],
125 125
 			'email'         => $purchase_data['user_email'],
@@ -132,28 +132,28 @@  discard block
 block discarded – undo
132 132
 			'shipping'      => '0',
133 133
 			'no_note'       => '1',
134 134
 			'currency_code' => give_get_currency(),
135
-			'charset'       => get_bloginfo( 'charset' ),
135
+			'charset'       => get_bloginfo('charset'),
136 136
 			'custom'        => $payment,
137 137
 			'rm'            => '2',
138 138
 			'return'        => $return_url,
139
-			'cancel_return' => give_get_failed_transaction_uri( '?payment-id=' . $payment ),
139
+			'cancel_return' => give_get_failed_transaction_uri('?payment-id='.$payment),
140 140
 			'notify_url'    => $listener_url,
141 141
 			'page_style'    => give_get_paypal_page_style(),
142
-			'cbt'           => get_bloginfo( 'name' ),
142
+			'cbt'           => get_bloginfo('name'),
143 143
 			'bn'            => 'givewp_SP'
144 144
 		);
145 145
 
146 146
 		//Add user address if present.
147
-		if ( ! empty( $purchase_data['user_info']['address'] ) ) {
148
-			$paypal_args['address1'] = isset( $purchase_data['user_info']['address']['line1'] ) ? $purchase_data['user_info']['address']['line1'] : '';
149
-			$paypal_args['address2'] = isset( $purchase_data['user_info']['address']['line2'] ) ? $purchase_data['user_info']['address']['line2'] : '';
150
-			$paypal_args['city']     = isset( $purchase_data['user_info']['address']['city'] ) ? $purchase_data['user_info']['address']['city'] : '';
151
-			$paypal_args['state']    = isset( $purchase_data['user_info']['address']['state'] ) ? $purchase_data['user_info']['address']['state'] : '';
152
-			$paypal_args['country']  = isset( $purchase_data['user_info']['address']['country'] ) ? $purchase_data['user_info']['address']['country'] : '';
147
+		if ( ! empty($purchase_data['user_info']['address'])) {
148
+			$paypal_args['address1'] = isset($purchase_data['user_info']['address']['line1']) ? $purchase_data['user_info']['address']['line1'] : '';
149
+			$paypal_args['address2'] = isset($purchase_data['user_info']['address']['line2']) ? $purchase_data['user_info']['address']['line2'] : '';
150
+			$paypal_args['city']     = isset($purchase_data['user_info']['address']['city']) ? $purchase_data['user_info']['address']['city'] : '';
151
+			$paypal_args['state']    = isset($purchase_data['user_info']['address']['state']) ? $purchase_data['user_info']['address']['state'] : '';
152
+			$paypal_args['country']  = isset($purchase_data['user_info']['address']['country']) ? $purchase_data['user_info']['address']['country'] : '';
153 153
 		}
154 154
 
155 155
 		//Donations or regular transactions?
156
-		if ( give_get_option( 'paypal_button_type' ) === 'standard' ) {
156
+		if (give_get_option('paypal_button_type') === 'standard') {
157 157
 			$paypal_extra_args = array(
158 158
 				'cmd' => '_xclick',
159 159
 			);
@@ -163,23 +163,23 @@  discard block
 block discarded – undo
163 163
 			);
164 164
 		}
165 165
 
166
-		$paypal_args = array_merge( $paypal_extra_args, $paypal_args );
167
-		$paypal_args = apply_filters( 'give_paypal_redirect_args', $paypal_args, $purchase_data );
166
+		$paypal_args = array_merge($paypal_extra_args, $paypal_args);
167
+		$paypal_args = apply_filters('give_paypal_redirect_args', $paypal_args, $purchase_data);
168 168
 
169 169
 		// Build query
170
-		$paypal_redirect .= http_build_query( $paypal_args );
170
+		$paypal_redirect .= http_build_query($paypal_args);
171 171
 
172 172
 		// Fix for some sites that encode the entities
173
-		$paypal_redirect = str_replace( '&amp;', '&', $paypal_redirect );
173
+		$paypal_redirect = str_replace('&amp;', '&', $paypal_redirect);
174 174
 
175 175
 		// Redirect to PayPal
176
-		wp_redirect( $paypal_redirect );
176
+		wp_redirect($paypal_redirect);
177 177
 		exit;
178 178
 	}
179 179
 
180 180
 }
181 181
 
182
-add_action( 'give_gateway_paypal', 'give_process_paypal_purchase' );
182
+add_action('give_gateway_paypal', 'give_process_paypal_purchase');
183 183
 
184 184
 /**
185 185
  * Listens for a PayPal IPN requests and then sends to the processing function
@@ -189,17 +189,17 @@  discard block
 block discarded – undo
189 189
  */
190 190
 function give_listen_for_paypal_ipn() {
191 191
 	// Regular PayPal IPN
192
-	if ( isset( $_GET['give-listener'] ) && $_GET['give-listener'] == 'IPN' ) {
192
+	if (isset($_GET['give-listener']) && $_GET['give-listener'] == 'IPN') {
193 193
 		/**
194 194
 		 * Fires while verifying PayPal IPN
195 195
 		 *
196 196
 		 * @since 1.0
197 197
 		 */
198
-		do_action( 'give_verify_paypal_ipn' );
198
+		do_action('give_verify_paypal_ipn');
199 199
 	}
200 200
 }
201 201
 
202
-add_action( 'init', 'give_listen_for_paypal_ipn' );
202
+add_action('init', 'give_listen_for_paypal_ipn');
203 203
 
204 204
 /**
205 205
  * Process PayPal IPN
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 function give_process_paypal_ipn() {
211 211
 
212 212
 	// Check the request method is POST
213
-	if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) {
213
+	if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') {
214 214
 		return;
215 215
 	}
216 216
 
@@ -218,11 +218,11 @@  discard block
 block discarded – undo
218 218
 	$post_data = '';
219 219
 
220 220
 	// Fallback just in case post_max_size is lower than needed
221
-	if ( ini_get( 'allow_url_fopen' ) ) {
222
-		$post_data = file_get_contents( 'php://input' );
221
+	if (ini_get('allow_url_fopen')) {
222
+		$post_data = file_get_contents('php://input');
223 223
 	} else {
224 224
 		// If allow_url_fopen is not enabled, then make sure that post_max_size is large enough
225
-		ini_set( 'post_max_size', '12M' );
225
+		ini_set('post_max_size', '12M');
226 226
 	}
227 227
 	// Start the encoded data collection with notification command
228 228
 	$encoded_data = 'cmd=_notify-validate';
@@ -231,40 +231,40 @@  discard block
 block discarded – undo
231 231
 	$arg_separator = give_get_php_arg_separator_output();
232 232
 
233 233
 	// Verify there is a post_data
234
-	if ( $post_data || strlen( $post_data ) > 0 ) {
234
+	if ($post_data || strlen($post_data) > 0) {
235 235
 		// Append the data
236
-		$encoded_data .= $arg_separator . $post_data;
236
+		$encoded_data .= $arg_separator.$post_data;
237 237
 	} else {
238 238
 		// Check if POST is empty
239
-		if ( empty( $_POST ) ) {
239
+		if (empty($_POST)) {
240 240
 			// Nothing to do
241 241
 			return;
242 242
 		} else {
243 243
 			// Loop through each POST
244
-			foreach ( $_POST as $key => $value ) {
244
+			foreach ($_POST as $key => $value) {
245 245
 				// Encode the value and append the data
246
-				$encoded_data .= $arg_separator . "$key=" . urlencode( $value );
246
+				$encoded_data .= $arg_separator."$key=".urlencode($value);
247 247
 			}
248 248
 		}
249 249
 	}
250 250
 
251 251
 	// Convert collected post data to an array
252
-	parse_str( $encoded_data, $encoded_data_array );
252
+	parse_str($encoded_data, $encoded_data_array);
253 253
 
254
-	foreach ( $encoded_data_array as $key => $value ) {
254
+	foreach ($encoded_data_array as $key => $value) {
255 255
 
256
-		if ( false !== strpos( $key, 'amp;' ) ) {
257
-			$new_key = str_replace( '&amp;', '&', $key );
258
-			$new_key = str_replace( 'amp;', '&', $new_key );
256
+		if (false !== strpos($key, 'amp;')) {
257
+			$new_key = str_replace('&amp;', '&', $key);
258
+			$new_key = str_replace('amp;', '&', $new_key);
259 259
 
260
-			unset( $encoded_data_array[ $key ] );
261
-			$encoded_data_array[ $new_key ] = $value;
260
+			unset($encoded_data_array[$key]);
261
+			$encoded_data_array[$new_key] = $value;
262 262
 		}
263 263
 
264 264
 	}
265 265
 
266 266
 	//Validate IPN request w/ PayPal if user hasn't disabled this security measure
267
-	if ( ! give_get_option( 'disable_paypal_verification' ) ) {
267
+	if ( ! give_get_option('disable_paypal_verification')) {
268 268
 
269 269
 		$remote_post_vars = array(
270 270
 			'method'      => 'POST',
@@ -284,28 +284,28 @@  discard block
 block discarded – undo
284 284
 		);
285 285
 
286 286
 		// Validate the IPN
287
-		$api_response = wp_remote_post( give_get_paypal_redirect(), $remote_post_vars );
287
+		$api_response = wp_remote_post(give_get_paypal_redirect(), $remote_post_vars);
288 288
 
289
-		if ( is_wp_error( $api_response ) ) {
289
+		if (is_wp_error($api_response)) {
290 290
 			give_record_gateway_error(
291
-				esc_html__( 'IPN Error', 'give' ),
291
+				esc_html__('IPN Error', 'give'),
292 292
 				sprintf(
293 293
 				/* translators: %s: Paypal IPN response */
294
-					esc_html__( 'Invalid IPN verification response. IPN data: %s', 'give' ),
295
-					json_encode( $api_response )
294
+					esc_html__('Invalid IPN verification response. IPN data: %s', 'give'),
295
+					json_encode($api_response)
296 296
 				)
297 297
 			);
298 298
 
299 299
 			return; // Something went wrong
300 300
 		}
301 301
 
302
-		if ( $api_response['body'] !== 'VERIFIED' && give_get_option( 'disable_paypal_verification', false ) ) {
302
+		if ($api_response['body'] !== 'VERIFIED' && give_get_option('disable_paypal_verification', false)) {
303 303
 			give_record_gateway_error(
304
-				esc_html__( 'IPN Error', 'give' ),
304
+				esc_html__('IPN Error', 'give'),
305 305
 				sprintf(
306 306
 				/* translators: %s: Paypal IPN response */
307
-					esc_html__( 'Invalid IPN verification response. IPN data: %s', 'give' ),
308
-					json_encode( $api_response )
307
+					esc_html__('Invalid IPN verification response. IPN data: %s', 'give'),
308
+					json_encode($api_response)
309 309
 				)
310 310
 			);
311 311
 
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 	}
316 316
 
317 317
 	// Check if $post_data_array has been populated
318
-	if ( ! is_array( $encoded_data_array ) && ! empty( $encoded_data_array ) ) {
318
+	if ( ! is_array($encoded_data_array) && ! empty($encoded_data_array)) {
319 319
 		return;
320 320
 	}
321 321
 
@@ -324,12 +324,12 @@  discard block
 block discarded – undo
324 324
 		'payment_status' => ''
325 325
 	);
326 326
 
327
-	$encoded_data_array = wp_parse_args( $encoded_data_array, $defaults );
327
+	$encoded_data_array = wp_parse_args($encoded_data_array, $defaults);
328 328
 
329
-	$payment_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0;
329
+	$payment_id = isset($encoded_data_array['custom']) ? absint($encoded_data_array['custom']) : 0;
330 330
 	$txn_type = $encoded_data_array['txn_type'];
331 331
 
332
-	if ( has_action( 'give_paypal_' . $txn_type ) ) {
332
+	if (has_action('give_paypal_'.$txn_type)) {
333 333
 		/**
334 334
 		 * Fires while processing PayPal IPN $txn_type.
335 335
 		 *
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 		 * @param array $encoded_data_array Encoded data.
341 341
 		 * @param int   $payment_id         Payment id.
342 342
 		 */
343
-		do_action( "give_paypal_{$txn_type}", $encoded_data_array, $payment_id );
343
+		do_action("give_paypal_{$txn_type}", $encoded_data_array, $payment_id);
344 344
 	} else {
345 345
 		/**
346 346
 		 * Fires while process PayPal IPN.
@@ -352,12 +352,12 @@  discard block
 block discarded – undo
352 352
 		 * @param array $encoded_data_array Encoded data.
353 353
 		 * @param int   $payment_id         Payment id.
354 354
 		 */
355
-		do_action( 'give_paypal_web_accept', $encoded_data_array, $payment_id );
355
+		do_action('give_paypal_web_accept', $encoded_data_array, $payment_id);
356 356
 	}
357 357
 	exit;
358 358
 }
359 359
 
360
-add_action( 'give_verify_paypal_ipn', 'give_process_paypal_ipn' );
360
+add_action('give_verify_paypal_ipn', 'give_process_paypal_ipn');
361 361
 
362 362
 /**
363 363
  * Process web accept (one time) payment IPNs.
@@ -368,224 +368,224 @@  discard block
 block discarded – undo
368 368
  *
369 369
  * @return void
370 370
  */
371
-function give_process_paypal_web_accept_and_cart( $data, $payment_id ) {
371
+function give_process_paypal_web_accept_and_cart($data, $payment_id) {
372 372
 
373
-	if ( $data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded' ) {
373
+	if ($data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded') {
374 374
 		return;
375 375
 	}
376 376
 
377
-	if ( empty( $payment_id ) ) {
377
+	if (empty($payment_id)) {
378 378
 		return;
379 379
 	}
380 380
 
381 381
 	// Collect payment details
382
-	$purchase_key   = isset( $data['invoice'] ) ? $data['invoice'] : $data['item_number'];
382
+	$purchase_key   = isset($data['invoice']) ? $data['invoice'] : $data['item_number'];
383 383
 	$paypal_amount  = $data['mc_gross'];
384
-	$payment_status = strtolower( $data['payment_status'] );
385
-	$currency_code  = strtolower( $data['mc_currency'] );
386
-	$business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] );
387
-	$payment_meta   = give_get_payment_meta( $payment_id );
384
+	$payment_status = strtolower($data['payment_status']);
385
+	$currency_code  = strtolower($data['mc_currency']);
386
+	$business_email = isset($data['business']) && is_email($data['business']) ? trim($data['business']) : trim($data['receiver_email']);
387
+	$payment_meta   = give_get_payment_meta($payment_id);
388 388
 
389 389
 
390
-	if ( give_get_payment_gateway( $payment_id ) != 'paypal' ) {
390
+	if (give_get_payment_gateway($payment_id) != 'paypal') {
391 391
 		return; // this isn't a PayPal standard IPN
392 392
 	}
393 393
 
394 394
 	// Verify payment recipient
395
-	if ( strcasecmp( $business_email, trim( give_get_option( 'paypal_email' ) ) ) != 0 ) {
395
+	if (strcasecmp($business_email, trim(give_get_option('paypal_email'))) != 0) {
396 396
 
397 397
 		give_record_gateway_error(
398
-			esc_html__( 'IPN Error', 'give' ),
398
+			esc_html__('IPN Error', 'give'),
399 399
 			sprintf(
400 400
 			/* translators: %s: Paypal IPN response */
401
-				esc_html__( 'Invalid business email in IPN response. IPN data: %s', 'give' ),
402
-				json_encode( $data )
401
+				esc_html__('Invalid business email in IPN response. IPN data: %s', 'give'),
402
+				json_encode($data)
403 403
 			),
404 404
 			$payment_id
405 405
 		);
406
-		give_update_payment_status( $payment_id, 'failed' );
407
-		give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid PayPal business email.', 'give' ) );
406
+		give_update_payment_status($payment_id, 'failed');
407
+		give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid PayPal business email.', 'give'));
408 408
 
409 409
 		return;
410 410
 	}
411 411
 
412 412
 	// Verify payment currency.
413
-	if ( $currency_code != strtolower( $payment_meta['currency'] ) ) {
413
+	if ($currency_code != strtolower($payment_meta['currency'])) {
414 414
 
415 415
 		give_record_gateway_error(
416
-			esc_html__( 'IPN Error', 'give' ),
416
+			esc_html__('IPN Error', 'give'),
417 417
 			sprintf(
418 418
 			/* translators: %s: Paypal IPN response */
419
-				esc_html__( 'Invalid currency in IPN response. IPN data: %s', 'give' ),
420
-				json_encode( $data )
419
+				esc_html__('Invalid currency in IPN response. IPN data: %s', 'give'),
420
+				json_encode($data)
421 421
 			),
422 422
 			$payment_id
423 423
 		);
424
-		give_update_payment_status( $payment_id, 'failed' );
425
-		give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid currency in PayPal IPN.', 'give' ) );
424
+		give_update_payment_status($payment_id, 'failed');
425
+		give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid currency in PayPal IPN.', 'give'));
426 426
 
427 427
 		return;
428 428
 	}
429 429
 
430
-	if ( ! give_get_payment_user_email( $payment_id ) ) {
430
+	if ( ! give_get_payment_user_email($payment_id)) {
431 431
 
432 432
 		// No email associated with the donation, so store from PayPal
433
-		give_update_payment_meta( $payment_id, '_give_payment_user_email', $data['payer_email'] );
433
+		give_update_payment_meta($payment_id, '_give_payment_user_email', $data['payer_email']);
434 434
 
435 435
 		// Setup and store the donors's details.
436 436
 		$address            = array();
437
-		$address['line1']   = ! empty( $data['address_street'] ) ? sanitize_text_field( $data['address_street'] ) : false;
438
-		$address['city']    = ! empty( $data['address_city'] ) ? sanitize_text_field( $data['address_city'] ) : false;
439
-		$address['state']   = ! empty( $data['address_state'] ) ? sanitize_text_field( $data['address_state'] ) : false;
440
-		$address['country'] = ! empty( $data['address_country_code'] ) ? sanitize_text_field( $data['address_country_code'] ) : false;
441
-		$address['zip']     = ! empty( $data['address_zip'] ) ? sanitize_text_field( $data['address_zip'] ) : false;
437
+		$address['line1']   = ! empty($data['address_street']) ? sanitize_text_field($data['address_street']) : false;
438
+		$address['city']    = ! empty($data['address_city']) ? sanitize_text_field($data['address_city']) : false;
439
+		$address['state']   = ! empty($data['address_state']) ? sanitize_text_field($data['address_state']) : false;
440
+		$address['country'] = ! empty($data['address_country_code']) ? sanitize_text_field($data['address_country_code']) : false;
441
+		$address['zip']     = ! empty($data['address_zip']) ? sanitize_text_field($data['address_zip']) : false;
442 442
 
443 443
 		$user_info = array(
444 444
 			'id'         => '-1',
445
-			'email'      => sanitize_text_field( $data['payer_email'] ),
446
-			'first_name' => sanitize_text_field( $data['first_name'] ),
447
-			'last_name'  => sanitize_text_field( $data['last_name'] ),
445
+			'email'      => sanitize_text_field($data['payer_email']),
446
+			'first_name' => sanitize_text_field($data['first_name']),
447
+			'last_name'  => sanitize_text_field($data['last_name']),
448 448
 			'discount'   => '',
449 449
 			'address'    => $address
450 450
 		);
451 451
 
452 452
 		$payment_meta['user_info'] = $user_info;
453
-		give_update_payment_meta( $payment_id, '_give_payment_meta', $payment_meta );
453
+		give_update_payment_meta($payment_id, '_give_payment_meta', $payment_meta);
454 454
 	}
455 455
 
456
-	if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) {
456
+	if ($payment_status == 'refunded' || $payment_status == 'reversed') {
457 457
 
458 458
 		// Process a refund
459
-		give_process_paypal_refund( $data, $payment_id );
459
+		give_process_paypal_refund($data, $payment_id);
460 460
 
461 461
 	} else {
462 462
 
463
-		if ( get_post_status( $payment_id ) == 'publish' ) {
463
+		if (get_post_status($payment_id) == 'publish') {
464 464
 			return; // Only complete payments once
465 465
 		}
466 466
 
467 467
 		// Retrieve the total donation amount (before PayPal)
468
-		$payment_amount = give_get_payment_amount( $payment_id );
468
+		$payment_amount = give_get_payment_amount($payment_id);
469 469
 
470
-		if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) {
470
+		if (number_format((float) $paypal_amount, 2) < number_format((float) $payment_amount, 2)) {
471 471
 			// The prices don't match
472 472
 			give_record_gateway_error(
473
-				esc_html__( 'IPN Error', 'give' ),
473
+				esc_html__('IPN Error', 'give'),
474 474
 				sprintf(
475 475
 				/* translators: %s: Paypal IPN response */
476
-					esc_html__( 'Invalid payment amount in IPN response. IPN data: %s', 'give' ),
477
-					json_encode( $data )
476
+					esc_html__('Invalid payment amount in IPN response. IPN data: %s', 'give'),
477
+					json_encode($data)
478 478
 				),
479 479
 				$payment_id
480 480
 			);
481
-			give_update_payment_status( $payment_id, 'failed' );
482
-			give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid amount in PayPal IPN.', 'give' ) );
481
+			give_update_payment_status($payment_id, 'failed');
482
+			give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid amount in PayPal IPN.', 'give'));
483 483
 
484 484
 			return;
485 485
 		}
486
-		if ( $purchase_key != give_get_payment_key( $payment_id ) ) {
486
+		if ($purchase_key != give_get_payment_key($payment_id)) {
487 487
 			// Keys don't match
488 488
 			give_record_gateway_error(
489
-				esc_html__( 'IPN Error', 'give' ),
489
+				esc_html__('IPN Error', 'give'),
490 490
 				sprintf(
491 491
 					/* translators: %s: Paypal IPN response */
492
-					esc_html__( 'Invalid key in IPN response. IPN data: %s', 'give' ),
493
-					json_encode( $data )
492
+					esc_html__('Invalid key in IPN response. IPN data: %s', 'give'),
493
+					json_encode($data)
494 494
 				),
495 495
 				$payment_id
496 496
 			);
497
-			give_update_payment_status( $payment_id, 'failed' );
498
-			give_insert_payment_note( $payment_id, esc_html__( 'Payment failed due to invalid key in PayPal IPN.', 'give' ) );
497
+			give_update_payment_status($payment_id, 'failed');
498
+			give_insert_payment_note($payment_id, esc_html__('Payment failed due to invalid key in PayPal IPN.', 'give'));
499 499
 
500 500
 			return;
501 501
 		}
502 502
 
503
-		if ( $payment_status == 'completed' || give_is_test_mode() ) {
503
+		if ($payment_status == 'completed' || give_is_test_mode()) {
504 504
 			give_insert_payment_note(
505 505
 				$payment_id,
506 506
 				sprintf(
507 507
 				/* translators: %s: Paypal transaction ID */
508
-					esc_html__( 'PayPal Transaction ID: %s', 'give' ),
508
+					esc_html__('PayPal Transaction ID: %s', 'give'),
509 509
 					$data['txn_id']
510 510
 				)
511 511
 			);
512
-			give_set_payment_transaction_id( $payment_id, $data['txn_id'] );
513
-			give_update_payment_status( $payment_id, 'publish' );
514
-		} else if ( 'pending' == $payment_status && isset( $data['pending_reason'] ) ) {
512
+			give_set_payment_transaction_id($payment_id, $data['txn_id']);
513
+			give_update_payment_status($payment_id, 'publish');
514
+		} else if ('pending' == $payment_status && isset($data['pending_reason'])) {
515 515
 
516 516
 			// Look for possible pending reasons, such as an echeck
517 517
 
518 518
 			$note = '';
519 519
 
520
-			switch ( strtolower( $data['pending_reason'] ) ) {
520
+			switch (strtolower($data['pending_reason'])) {
521 521
 
522 522
 				case 'echeck' :
523 523
 
524
-					$note = esc_html__( 'Payment made via eCheck and will clear automatically in 5-8 days.', 'give' );
524
+					$note = esc_html__('Payment made via eCheck and will clear automatically in 5-8 days.', 'give');
525 525
 
526 526
 					break;
527 527
 
528 528
 				case 'address' :
529 529
 
530
-					$note = esc_html__( 'Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give' );
530
+					$note = esc_html__('Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give');
531 531
 
532 532
 					break;
533 533
 
534 534
 				case 'intl' :
535 535
 
536
-					$note = esc_html__( 'Payment must be accepted manually through PayPal due to international account regulations.', 'give' );
536
+					$note = esc_html__('Payment must be accepted manually through PayPal due to international account regulations.', 'give');
537 537
 
538 538
 					break;
539 539
 
540 540
 				case 'multi-currency' :
541 541
 
542
-					$note = esc_html__( 'Payment received in non-shop currency and must be accepted manually through PayPal.', 'give' );
542
+					$note = esc_html__('Payment received in non-shop currency and must be accepted manually through PayPal.', 'give');
543 543
 
544 544
 					break;
545 545
 
546 546
 				case 'paymentreview' :
547 547
 				case 'regulatory_review' :
548 548
 
549
-					$note = esc_html__( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give' );
549
+					$note = esc_html__('Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give');
550 550
 
551 551
 					break;
552 552
 
553 553
 				case 'unilateral' :
554 554
 
555
-					$note = esc_html__( 'Payment was sent to non-confirmed or non-registered email address.', 'give' );
555
+					$note = esc_html__('Payment was sent to non-confirmed or non-registered email address.', 'give');
556 556
 
557 557
 					break;
558 558
 
559 559
 				case 'upgrade' :
560 560
 
561
-					$note = esc_html__( 'PayPal account must be upgraded before this payment can be accepted.', 'give' );
561
+					$note = esc_html__('PayPal account must be upgraded before this payment can be accepted.', 'give');
562 562
 
563 563
 					break;
564 564
 
565 565
 				case 'verify' :
566 566
 
567
-					$note = esc_html__( 'PayPal account is not verified. Verify account in order to accept this payment.', 'give' );
567
+					$note = esc_html__('PayPal account is not verified. Verify account in order to accept this payment.', 'give');
568 568
 
569 569
 					break;
570 570
 
571 571
 				case 'other' :
572 572
 
573
-					$note = esc_html__( 'Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give' );
573
+					$note = esc_html__('Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give');
574 574
 
575 575
 					break;
576 576
 
577 577
 			}
578 578
 
579
-			if ( ! empty( $note ) ) {
579
+			if ( ! empty($note)) {
580 580
 
581
-				give_insert_payment_note( $payment_id, $note );
581
+				give_insert_payment_note($payment_id, $note);
582 582
 
583 583
 			}
584 584
 		}
585 585
 	}
586 586
 }
587 587
 
588
-add_action( 'give_paypal_web_accept', 'give_process_paypal_web_accept_and_cart', 10, 2 );
588
+add_action('give_paypal_web_accept', 'give_process_paypal_web_accept_and_cart', 10, 2);
589 589
 
590 590
 /**
591 591
  * Process PayPal IPN Refunds
@@ -596,28 +596,28 @@  discard block
 block discarded – undo
596 596
  *
597 597
  * @return void
598 598
  */
599
-function give_process_paypal_refund( $data, $payment_id = 0 ) {
599
+function give_process_paypal_refund($data, $payment_id = 0) {
600 600
 
601 601
 	// Collect payment details
602 602
 
603
-	if ( empty( $payment_id ) ) {
603
+	if (empty($payment_id)) {
604 604
 		return;
605 605
 	}
606 606
 
607
-	if ( get_post_status( $payment_id ) == 'refunded' ) {
607
+	if (get_post_status($payment_id) == 'refunded') {
608 608
 		return; // Only refund payments once
609 609
 	}
610 610
 
611
-	$payment_amount = give_get_payment_amount( $payment_id );
611
+	$payment_amount = give_get_payment_amount($payment_id);
612 612
 	$refund_amount  = $data['payment_gross'] * - 1;
613 613
 
614
-	if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) {
614
+	if (number_format((float) $refund_amount, 2) < number_format((float) $payment_amount, 2)) {
615 615
 
616 616
 		give_insert_payment_note(
617 617
 			$payment_id,
618 618
 			sprintf(
619 619
 			/* translators: %s: Paypal parent transaction ID */
620
-				esc_html__( 'Partial PayPal refund processed: %s', 'give' ),
620
+				esc_html__('Partial PayPal refund processed: %s', 'give'),
621 621
 				$data['parent_txn_id']
622 622
 			)
623 623
 		);
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
 		$payment_id,
631 631
 		sprintf(
632 632
 			/* translators: 1: Paypal parent transaction ID 2. Paypal reason code */
633
-			esc_html__( 'PayPal Payment #%1$s Refunded for reason: %2$s', 'give' ),
633
+			esc_html__('PayPal Payment #%1$s Refunded for reason: %2$s', 'give'),
634 634
 			$data['parent_txn_id'],
635 635
 			$data['reason_code']
636 636
 		)
@@ -639,11 +639,11 @@  discard block
 block discarded – undo
639 639
 		$payment_id,
640 640
 		sprintf(
641 641
 		/* translators: %s: Paypal transaction ID */
642
-			esc_html__( 'PayPal Refund Transaction ID: %s', 'give' ),
642
+			esc_html__('PayPal Refund Transaction ID: %s', 'give'),
643 643
 			$data['txn_id']
644 644
 		)
645 645
 	);
646
-	give_update_payment_status( $payment_id, 'refunded' );
646
+	give_update_payment_status($payment_id, 'refunded');
647 647
 }
648 648
 
649 649
 /**
@@ -655,24 +655,24 @@  discard block
 block discarded – undo
655 655
  *
656 656
  * @return string
657 657
  */
658
-function give_get_paypal_redirect( $ssl_check = false ) {
658
+function give_get_paypal_redirect($ssl_check = false) {
659 659
 
660
-	if ( is_ssl() || ! $ssl_check ) {
660
+	if (is_ssl() || ! $ssl_check) {
661 661
 		$protocal = 'https://';
662 662
 	} else {
663 663
 		$protocal = 'http://';
664 664
 	}
665 665
 
666 666
 	// Check the current payment mode
667
-	if ( give_is_test_mode() ) {
667
+	if (give_is_test_mode()) {
668 668
 		// Test mode
669
-		$paypal_uri = $protocal . 'www.sandbox.paypal.com/cgi-bin/webscr';
669
+		$paypal_uri = $protocal.'www.sandbox.paypal.com/cgi-bin/webscr';
670 670
 	} else {
671 671
 		// Live mode
672
-		$paypal_uri = $protocal . 'www.paypal.com/cgi-bin/webscr';
672
+		$paypal_uri = $protocal.'www.paypal.com/cgi-bin/webscr';
673 673
 	}
674 674
 
675
-	return apply_filters( 'give_paypal_uri', $paypal_uri );
675
+	return apply_filters('give_paypal_uri', $paypal_uri);
676 676
 }
677 677
 
678 678
 /**
@@ -682,9 +682,9 @@  discard block
 block discarded – undo
682 682
  * @return string
683 683
  */
684 684
 function give_get_paypal_page_style() {
685
-	$page_style = trim( give_get_option( 'paypal_page_style', 'PayPal' ) );
685
+	$page_style = trim(give_get_option('paypal_page_style', 'PayPal'));
686 686
 
687
-	return apply_filters( 'give_paypal_page_style', $page_style );
687
+	return apply_filters('give_paypal_page_style', $page_style);
688 688
 }
689 689
 
690 690
 /**
@@ -699,27 +699,27 @@  discard block
 block discarded – undo
699 699
  * @return string
700 700
  *
701 701
  */
702
-function give_paypal_success_page_content( $content ) {
702
+function give_paypal_success_page_content($content) {
703 703
 
704
-	if ( ! isset( $_GET['payment-id'] ) && ! give_get_purchase_session() ) {
704
+	if ( ! isset($_GET['payment-id']) && ! give_get_purchase_session()) {
705 705
 		return $content;
706 706
 	}
707 707
 
708
-	$payment_id = isset( $_GET['payment-id'] ) ? absint( $_GET['payment-id'] ) : false;
708
+	$payment_id = isset($_GET['payment-id']) ? absint($_GET['payment-id']) : false;
709 709
 
710
-	if ( ! $payment_id ) {
710
+	if ( ! $payment_id) {
711 711
 		$session    = give_get_purchase_session();
712
-		$payment_id = give_get_purchase_id_by_key( $session['purchase_key'] );
712
+		$payment_id = give_get_purchase_id_by_key($session['purchase_key']);
713 713
 	}
714 714
 
715
-	$payment = get_post( $payment_id );
715
+	$payment = get_post($payment_id);
716 716
 
717
-	if ( $payment && 'pending' == $payment->post_status ) {
717
+	if ($payment && 'pending' == $payment->post_status) {
718 718
 
719 719
 		// Payment is still pending so show processing indicator to fix the Race Condition
720 720
 		ob_start();
721 721
 
722
-		give_get_template_part( 'payment', 'processing' );
722
+		give_get_template_part('payment', 'processing');
723 723
 
724 724
 		$content = ob_get_clean();
725 725
 
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
 
730 730
 }
731 731
 
732
-add_filter( 'give_payment_confirm_paypal', 'give_paypal_success_page_content' );
732
+add_filter('give_payment_confirm_paypal', 'give_paypal_success_page_content');
733 733
 
734 734
 /**
735 735
  * Given a Payment ID, extract the transaction ID
@@ -740,22 +740,22 @@  discard block
 block discarded – undo
740 740
  *
741 741
  * @return string                   Transaction ID
742 742
  */
743
-function give_paypal_get_payment_transaction_id( $payment_id ) {
743
+function give_paypal_get_payment_transaction_id($payment_id) {
744 744
 
745 745
 	$transaction_id = '';
746
-	$notes          = give_get_payment_notes( $payment_id );
746
+	$notes          = give_get_payment_notes($payment_id);
747 747
 
748
-	foreach ( $notes as $note ) {
749
-		if ( preg_match( '/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match ) ) {
748
+	foreach ($notes as $note) {
749
+		if (preg_match('/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match)) {
750 750
 			$transaction_id = $match[1];
751 751
 			continue;
752 752
 		}
753 753
 	}
754 754
 
755
-	return apply_filters( 'give_paypal_set_payment_transaction_id', $transaction_id, $payment_id );
755
+	return apply_filters('give_paypal_set_payment_transaction_id', $transaction_id, $payment_id);
756 756
 }
757 757
 
758
-add_filter( 'give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1 );
758
+add_filter('give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1);
759 759
 
760 760
 /**
761 761
  * Given a transaction ID, generate a link to the PayPal transaction ID details
@@ -767,13 +767,13 @@  discard block
 block discarded – undo
767 767
  *
768 768
  * @return string                 A link to the PayPal transaction details
769 769
  */
770
-function give_paypal_link_transaction_id( $transaction_id, $payment_id ) {
770
+function give_paypal_link_transaction_id($transaction_id, $payment_id) {
771 771
 
772 772
 	$paypal_base_url = 'https://history.paypal.com/cgi-bin/webscr?cmd=_history-details-from-hub&id=';
773
-	$transaction_url = '<a href="' . esc_url( $paypal_base_url . $transaction_id ) . '" target="_blank">' . $transaction_id . '</a>';
773
+	$transaction_url = '<a href="'.esc_url($paypal_base_url.$transaction_id).'" target="_blank">'.$transaction_id.'</a>';
774 774
 
775
-	return apply_filters( 'give_paypal_link_payment_details_transaction_id', $transaction_url );
775
+	return apply_filters('give_paypal_link_payment_details_transaction_id', $transaction_url);
776 776
 
777 777
 }
778 778
 
779
-add_filter( 'give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2 );
779
+add_filter('give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2);
Please login to merge, or discard this patch.
includes/payments/class-give-payment.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1050,7 +1050,7 @@  discard block
 block discarded – undo
1050 1050
 					//Find a match between price_id and level_id
1051 1051
 					//First verify array keys exists THEN make the match
1052 1052
 					if ( ( isset( $args['price_id'] ) && isset( $price['_give_id']['level_id'] ) )
1053
-					     && $args['price_id'] == $price['_give_id']['level_id']
1053
+						 && $args['price_id'] == $price['_give_id']['level_id']
1054 1054
 					) {
1055 1055
 						$item_price = $price['_give_amount'];
1056 1056
 					}
@@ -1303,7 +1303,7 @@  discard block
 block discarded – undo
1303 1303
 	 * Add a note to a payment
1304 1304
 	 *
1305 1305
 	 * @since  1.5
1306
-     * @access public
1306
+	 * @access public
1307 1307
 	 *
1308 1308
 	 * @param  string $note The note to add
1309 1309
 	 *
@@ -1398,7 +1398,7 @@  discard block
 block discarded – undo
1398 1398
 	 * Set or update the total for a payment.
1399 1399
 	 *
1400 1400
 	 * @since  1.5
1401
-     * @access private
1401
+	 * @access private
1402 1402
 	 *
1403 1403
 	 * @return void
1404 1404
 	 */
@@ -1410,7 +1410,7 @@  discard block
 block discarded – undo
1410 1410
 	 * Set the payment status and run any status specific changes necessary.
1411 1411
 	 *
1412 1412
 	 * @since  1.5
1413
-     * @access public
1413
+	 * @access public
1414 1414
 	 *
1415 1415
 	 * @param  string $status The status to set the payment to.
1416 1416
 	 *
Please login to merge, or discard this patch.
Spacing   +324 added lines, -324 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
 
@@ -390,13 +390,13 @@  discard block
 block discarded – undo
390 390
 	 *
391 391
 	 * @return mixed void|false
392 392
 	 */
393
-	public function __construct( $payment_id = false ) {
393
+	public function __construct($payment_id = false) {
394 394
 
395
-		if ( empty( $payment_id ) ) {
395
+		if (empty($payment_id)) {
396 396
 			return false;
397 397
 		}
398 398
 
399
-		$this->setup_payment( $payment_id );
399
+		$this->setup_payment($payment_id);
400 400
 	}
401 401
 
402 402
 	/**
@@ -409,11 +409,11 @@  discard block
 block discarded – undo
409 409
 	 *
410 410
 	 * @return mixed        The value.
411 411
 	 */
412
-	public function __get( $key ) {
412
+	public function __get($key) {
413 413
 
414
-		if ( method_exists( $this, 'get_' . $key ) ) {
414
+		if (method_exists($this, 'get_'.$key)) {
415 415
 
416
-			$value = call_user_func( array( $this, 'get_' . $key ) );
416
+			$value = call_user_func(array($this, 'get_'.$key));
417 417
 
418 418
 		} else {
419 419
 
@@ -435,18 +435,18 @@  discard block
 block discarded – undo
435 435
 	 * @param  string $key The property name
436 436
 	 * @param  mixed  $value The value of the property
437 437
 	 */
438
-	public function __set( $key, $value ) {
439
-		$ignore = array( '_ID' );
438
+	public function __set($key, $value) {
439
+		$ignore = array('_ID');
440 440
 
441
-		if ( $key === 'status' ) {
441
+		if ($key === 'status') {
442 442
 			$this->old_status = $this->status;
443 443
 		}
444 444
 
445
-		if ( ! in_array( $key, $ignore ) ) {
446
-			$this->pending[ $key ] = $value;
445
+		if ( ! in_array($key, $ignore)) {
446
+			$this->pending[$key] = $value;
447 447
 		}
448 448
 
449
-		if ( '_ID' !== $key ) {
449
+		if ('_ID' !== $key) {
450 450
 			$this->$key = $value;
451 451
 		}
452 452
 	}
@@ -461,9 +461,9 @@  discard block
 block discarded – undo
461 461
 	 *
462 462
 	 * @return boolean       If the item is set or not
463 463
 	 */
464
-	public function __isset( $name ) {
465
-		if ( property_exists( $this, $name ) ) {
466
-			return false === empty( $this->$name );
464
+	public function __isset($name) {
465
+		if (property_exists($this, $name)) {
466
+			return false === empty($this->$name);
467 467
 		} else {
468 468
 			return null;
469 469
 		}
@@ -479,20 +479,20 @@  discard block
 block discarded – undo
479 479
 	 *
480 480
 	 * @return bool            If the setup was successful or not
481 481
 	 */
482
-	private function setup_payment( $payment_id ) {
482
+	private function setup_payment($payment_id) {
483 483
 		$this->pending = array();
484 484
 
485
-		if ( empty( $payment_id ) ) {
485
+		if (empty($payment_id)) {
486 486
 			return false;
487 487
 		}
488 488
 
489
-		$payment = get_post( $payment_id );
489
+		$payment = get_post($payment_id);
490 490
 
491
-		if ( ! $payment || is_wp_error( $payment ) ) {
491
+		if ( ! $payment || is_wp_error($payment)) {
492 492
 			return false;
493 493
 		}
494 494
 
495
-		if ( 'give_payment' !== $payment->post_type ) {
495
+		if ('give_payment' !== $payment->post_type) {
496 496
 			return false;
497 497
 		}
498 498
 
@@ -506,13 +506,13 @@  discard block
 block discarded – undo
506 506
 		 * @param Give_Payment $this       Payment object.
507 507
 		 * @param int          $payment_id The ID of the payment.
508 508
 		 */
509
-		do_action( 'give_pre_setup_payment', $this, $payment_id );
509
+		do_action('give_pre_setup_payment', $this, $payment_id);
510 510
 
511 511
 		// Primary Identifier
512
-		$this->ID = absint( $payment_id );
512
+		$this->ID = absint($payment_id);
513 513
 
514 514
 		// Protected ID that can never be changed
515
-		$this->_ID = absint( $payment_id );
515
+		$this->_ID = absint($payment_id);
516 516
 
517 517
 		// We have a payment, get the generic payment_meta item to reduce calls to it
518 518
 		$this->payment_meta = $this->get_meta();
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
 		$this->parent_payment = $payment->post_parent;
528 528
 
529 529
 		$all_payment_statuses  = give_get_payment_statuses();
530
-		$this->status_nicename = array_key_exists( $this->status, $all_payment_statuses ) ? $all_payment_statuses[ $this->status ] : ucfirst( $this->status );
530
+		$this->status_nicename = array_key_exists($this->status, $all_payment_statuses) ? $all_payment_statuses[$this->status] : ucfirst($this->status);
531 531
 
532 532
 		// Items
533 533
 		$this->fees = $this->setup_fees();
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
 		 * @param Give_Payment $this       Payment object.
570 570
 		 * @param int          $payment_id The ID of the payment.
571 571
 		 */
572
-		do_action( 'give_setup_payment', $this, $payment_id );
572
+		do_action('give_setup_payment', $this, $payment_id);
573 573
 
574 574
 		return true;
575 575
 	}
@@ -587,8 +587,8 @@  discard block
 block discarded – undo
587 587
 	 *
588 588
 	 * @return void
589 589
 	 */
590
-	public function update_payment_setup( $payment_id ) {
591
-		$this->setup_payment( $payment_id );
590
+	public function update_payment_setup($payment_id) {
591
+		$this->setup_payment($payment_id);
592 592
 	}
593 593
 
594 594
 	/**
@@ -603,24 +603,24 @@  discard block
 block discarded – undo
603 603
 
604 604
 		// Construct the payment title
605 605
 		$payment_title = '';
606
-		if ( ! empty( $this->first_name ) && ! empty( $this->last_name ) ) {
607
-			$payment_title = $this->first_name . ' ' . $this->last_name;
608
-		} else if ( ! empty( $this->first_name ) && empty( $this->last_name ) ) {
606
+		if ( ! empty($this->first_name) && ! empty($this->last_name)) {
607
+			$payment_title = $this->first_name.' '.$this->last_name;
608
+		} else if ( ! empty($this->first_name) && empty($this->last_name)) {
609 609
 			$payment_title = $this->first_name;
610
-		} else if ( ! empty( $this->email ) && is_email( $this->email ) ) {
610
+		} else if ( ! empty($this->email) && is_email($this->email)) {
611 611
 			$payment_title = $this->email;
612 612
 		}
613 613
 
614 614
 		//Set Key
615
-		if ( empty( $this->key ) ) {
615
+		if (empty($this->key)) {
616 616
 
617
-			$auth_key             = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
618
-			$this->key            = strtolower( md5( $this->email . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) );  // Unique key
617
+			$auth_key             = defined('AUTH_KEY') ? AUTH_KEY : '';
618
+			$this->key            = strtolower(md5($this->email.date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); // Unique key
619 619
 			$this->pending['key'] = $this->key;
620 620
 		}
621 621
 
622 622
 		//Set IP
623
-		if ( empty( $this->ip ) ) {
623
+		if (empty($this->ip)) {
624 624
 
625 625
 			$this->ip            = give_get_ip();
626 626
 			$this->pending['ip'] = $this->ip;
@@ -647,63 +647,63 @@  discard block
 block discarded – undo
647 647
 			'fees'         => $this->fees,
648 648
 		);
649 649
 
650
-		$args = apply_filters( 'give_insert_payment_args', array(
650
+		$args = apply_filters('give_insert_payment_args', array(
651 651
 			'post_title'    => $payment_title,
652 652
 			'post_status'   => $this->status,
653 653
 			'post_type'     => 'give_payment',
654
-			'post_date'     => ! empty( $this->date ) ? $this->date : null,
655
-			'post_date_gmt' => ! empty( $this->date ) ? get_gmt_from_date( $this->date ) : null,
654
+			'post_date'     => ! empty($this->date) ? $this->date : null,
655
+			'post_date_gmt' => ! empty($this->date) ? get_gmt_from_date($this->date) : null,
656 656
 			'post_parent'   => $this->parent_payment,
657
-		), $payment_data );
657
+		), $payment_data);
658 658
 
659 659
 		// Create a blank payment
660
-		$payment_id = wp_insert_post( $args );
660
+		$payment_id = wp_insert_post($args);
661 661
 
662
-		if ( ! empty( $payment_id ) ) {
662
+		if ( ! empty($payment_id)) {
663 663
 
664 664
 			$this->ID  = $payment_id;
665 665
 			$this->_ID = $payment_id;
666 666
 
667 667
 			$customer = new stdClass;
668 668
 
669
-			if ( did_action( 'give_pre_process_purchase' ) && is_user_logged_in() ) {
670
-				$customer = new Give_Customer( get_current_user_id(), true );
669
+			if (did_action('give_pre_process_purchase') && is_user_logged_in()) {
670
+				$customer = new Give_Customer(get_current_user_id(), true);
671 671
 
672 672
 				// Customer is logged in but used a different email to purchase with so assign to their customer record
673
-				if( ! empty( $customer->id ) && $this->email != $customer->email ) {
674
-					$customer->add_email( $this->email );
673
+				if ( ! empty($customer->id) && $this->email != $customer->email) {
674
+					$customer->add_email($this->email);
675 675
 				}
676 676
 			}
677 677
 
678
-			if ( empty( $customer->id ) ) {
679
-				$customer = new Give_Customer( $this->email );
678
+			if (empty($customer->id)) {
679
+				$customer = new Give_Customer($this->email);
680 680
 			}
681 681
 
682
-			if ( empty( $customer->id ) ) {
682
+			if (empty($customer->id)) {
683 683
 
684 684
 				$customer_data = array(
685
-					'name'    => ! is_email( $payment_title ) ? $this->first_name . ' ' . $this->last_name : '',
685
+					'name'    => ! is_email($payment_title) ? $this->first_name.' '.$this->last_name : '',
686 686
 					'email'   => $this->email,
687 687
 					'user_id' => $this->user_id,
688 688
 				);
689 689
 
690
-				$customer->create( $customer_data );
690
+				$customer->create($customer_data);
691 691
 
692 692
 			}
693 693
 
694 694
 			$this->customer_id            = $customer->id;
695 695
 			$this->pending['customer_id'] = $this->customer_id;
696
-			$customer->attach_payment( $this->ID, false );
696
+			$customer->attach_payment($this->ID, false);
697 697
 
698
-			$this->payment_meta = apply_filters( 'give_donation_meta', $this->payment_meta, $payment_data );
699
-			if ( ! empty( $this->payment_meta['fees'] ) ) {
700
-				$this->fees = array_merge( $this->fees, $this->payment_meta['fees'] );
701
-				foreach ( $this->fees as $fee ) {
702
-					$this->increase_fees( $fee['amount'] );
698
+			$this->payment_meta = apply_filters('give_donation_meta', $this->payment_meta, $payment_data);
699
+			if ( ! empty($this->payment_meta['fees'])) {
700
+				$this->fees = array_merge($this->fees, $this->payment_meta['fees']);
701
+				foreach ($this->fees as $fee) {
702
+					$this->increase_fees($fee['amount']);
703 703
 				}
704 704
 			}
705 705
 
706
-			$this->update_meta( '_give_payment_meta', $this->payment_meta );
706
+			$this->update_meta('_give_payment_meta', $this->payment_meta);
707 707
 			$this->new = true;
708 708
 		}
709 709
 
@@ -725,11 +725,11 @@  discard block
 block discarded – undo
725 725
 		$saved = false;
726 726
 
727 727
 		//Must have an ID 
728
-		if ( empty( $this->ID ) ) {
728
+		if (empty($this->ID)) {
729 729
 
730 730
 			$payment_id = $this->insert_payment();
731 731
 
732
-			if ( false === $payment_id ) {
732
+			if (false === $payment_id) {
733 733
 				$saved = false;
734 734
 			} else {
735 735
 				$this->ID = $payment_id;
@@ -738,48 +738,48 @@  discard block
 block discarded – undo
738 738
 		}
739 739
 
740 740
 		//Set ID if not matching
741
-		if ( $this->ID !== $this->_ID ) {
741
+		if ($this->ID !== $this->_ID) {
742 742
 			$this->ID = $this->_ID;
743 743
 		}
744 744
 
745 745
 		// If we have something pending, let's save it
746
-		if ( ! empty( $this->pending ) ) {
746
+		if ( ! empty($this->pending)) {
747 747
 
748 748
 			$total_increase = 0;
749 749
 			$total_decrease = 0;
750 750
 
751
-			foreach ( $this->pending as $key => $value ) {
751
+			foreach ($this->pending as $key => $value) {
752 752
 
753
-				switch ( $key ) {
753
+				switch ($key) {
754 754
 
755 755
 					case 'donations':
756 756
 						// Update totals for pending donations
757
-						foreach ( $this->pending[ $key ] as $item ) {
757
+						foreach ($this->pending[$key] as $item) {
758 758
 
759
-							$quantity = isset( $item['quantity'] ) ? $item['quantity'] : 1;
760
-							$price_id = isset( $item['price_id'] ) ? $item['price_id'] : 0;
759
+							$quantity = isset($item['quantity']) ? $item['quantity'] : 1;
760
+							$price_id = isset($item['price_id']) ? $item['price_id'] : 0;
761 761
 
762
-							switch ( $item['action'] ) {
762
+							switch ($item['action']) {
763 763
 
764 764
 								case 'add':
765 765
 
766 766
 									$price = $item['price'];
767 767
 
768
-									if ( 'publish' === $this->status || 'complete' === $this->status ) {
768
+									if ('publish' === $this->status || 'complete' === $this->status) {
769 769
 
770 770
 										// Add sales logs
771
-										$log_date = date_i18n( 'Y-m-d G:i:s', current_time( 'timestamp' ) );
771
+										$log_date = date_i18n('Y-m-d G:i:s', current_time('timestamp'));
772 772
 
773 773
 										$y = 0;
774
-										while ( $y < $quantity ) {
774
+										while ($y < $quantity) {
775 775
 
776
-											give_record_sale_in_log( $item['id'], $this->ID, $price_id, $log_date );
777
-											$y ++;
776
+											give_record_sale_in_log($item['id'], $this->ID, $price_id, $log_date);
777
+											$y++;
778 778
 										}
779 779
 
780
-										$form = new Give_Donate_Form( $item['id'] );
781
-										$form->increase_sales( $quantity );
782
-										$form->increase_earnings( $price );
780
+										$form = new Give_Donate_Form($item['id']);
781
+										$form->increase_sales($quantity);
782
+										$form->increase_earnings($price);
783 783
 
784 784
 										$total_increase += $price;
785 785
 									}
@@ -804,15 +804,15 @@  discard block
 block discarded – undo
804 804
 										)
805 805
 									);
806 806
 
807
-									$found_logs = get_posts( $log_args );
808
-									foreach ( $found_logs as $log ) {
809
-										wp_delete_post( $log->ID, true );
807
+									$found_logs = get_posts($log_args);
808
+									foreach ($found_logs as $log) {
809
+										wp_delete_post($log->ID, true);
810 810
 									}
811 811
 
812
-									if ( 'publish' === $this->status || 'complete' === $this->status ) {
813
-										$form = new Give_Donate_Form( $item['id'] );
814
-										$form->decrease_sales( $quantity );
815
-										$form->decrease_earnings( $item['amount'] );
812
+									if ('publish' === $this->status || 'complete' === $this->status) {
813
+										$form = new Give_Donate_Form($item['id']);
814
+										$form->decrease_sales($quantity);
815
+										$form->decrease_earnings($item['amount']);
816 816
 
817 817
 										$total_decrease += $item['amount'];
818 818
 									}
@@ -825,17 +825,17 @@  discard block
 block discarded – undo
825 825
 
826 826
 					case 'fees':
827 827
 
828
-						if ( 'publish' !== $this->status && 'complete' !== $this->status ) {
828
+						if ('publish' !== $this->status && 'complete' !== $this->status) {
829 829
 							break;
830 830
 						}
831 831
 
832
-						if ( empty( $this->pending[ $key ] ) ) {
832
+						if (empty($this->pending[$key])) {
833 833
 							break;
834 834
 						}
835 835
 
836
-						foreach ( $this->pending[ $key ] as $fee ) {
836
+						foreach ($this->pending[$key] as $fee) {
837 837
 
838
-							switch ( $fee['action'] ) {
838
+							switch ($fee['action']) {
839 839
 
840 840
 								case 'add':
841 841
 									$total_increase += $fee['amount'];
@@ -852,43 +852,43 @@  discard block
 block discarded – undo
852 852
 						break;
853 853
 
854 854
 					case 'status':
855
-						$this->update_status( $this->status );
855
+						$this->update_status($this->status);
856 856
 						break;
857 857
 
858 858
 					case 'gateway':
859
-						$this->update_meta( '_give_payment_gateway', $this->gateway );
859
+						$this->update_meta('_give_payment_gateway', $this->gateway);
860 860
 						break;
861 861
 
862 862
 					case 'mode':
863
-						$this->update_meta( '_give_payment_mode', $this->mode );
863
+						$this->update_meta('_give_payment_mode', $this->mode);
864 864
 						break;
865 865
 
866 866
 					case 'transaction_id':
867
-						$this->update_meta( '_give_payment_transaction_id', $this->transaction_id );
867
+						$this->update_meta('_give_payment_transaction_id', $this->transaction_id);
868 868
 						break;
869 869
 
870 870
 					case 'ip':
871
-						$this->update_meta( '_give_payment_user_ip', $this->ip );
871
+						$this->update_meta('_give_payment_user_ip', $this->ip);
872 872
 						break;
873 873
 
874 874
 					case 'customer_id':
875
-						$this->update_meta( '_give_payment_customer_id', $this->customer_id );
875
+						$this->update_meta('_give_payment_customer_id', $this->customer_id);
876 876
 						break;
877 877
 
878 878
 					case 'user_id':
879
-						$this->update_meta( '_give_payment_user_id', $this->user_id );
879
+						$this->update_meta('_give_payment_user_id', $this->user_id);
880 880
 						break;
881 881
 
882 882
 					case 'form_title':
883
-						$this->update_meta( '_give_payment_form_title', $this->form_title );
883
+						$this->update_meta('_give_payment_form_title', $this->form_title);
884 884
 						break;
885 885
 
886 886
 					case 'form_id':
887
-						$this->update_meta( '_give_payment_form_id', $this->form_id );
887
+						$this->update_meta('_give_payment_form_id', $this->form_id);
888 888
 						break;
889 889
 
890 890
 					case 'price_id':
891
-						$this->update_meta( '_give_payment_price_id', $this->price_id );
891
+						$this->update_meta('_give_payment_price_id', $this->price_id);
892 892
 						break;
893 893
 
894 894
 					case 'first_name':
@@ -904,15 +904,15 @@  discard block
 block discarded – undo
904 904
 						break;
905 905
 
906 906
 					case 'email':
907
-						$this->update_meta( '_give_payment_user_email', $this->email );
907
+						$this->update_meta('_give_payment_user_email', $this->email);
908 908
 						break;
909 909
 
910 910
 					case 'key':
911
-						$this->update_meta( '_give_payment_purchase_key', $this->key );
911
+						$this->update_meta('_give_payment_purchase_key', $this->key);
912 912
 						break;
913 913
 
914 914
 					case 'number':
915
-						$this->update_meta( '_give_payment_number', $this->number );
915
+						$this->update_meta('_give_payment_number', $this->number);
916 916
 						break;
917 917
 
918 918
 					case 'date':
@@ -922,11 +922,11 @@  discard block
 block discarded – undo
922 922
 							'edit_date' => true,
923 923
 						);
924 924
 
925
-						wp_update_post( $args );
925
+						wp_update_post($args);
926 926
 						break;
927 927
 
928 928
 					case 'completed_date':
929
-						$this->update_meta( '_give_completed_date', $this->completed_date );
929
+						$this->update_meta('_give_completed_date', $this->completed_date);
930 930
 						break;
931 931
 
932 932
 					case 'parent_payment':
@@ -935,7 +935,7 @@  discard block
 block discarded – undo
935 935
 							'post_parent' => $this->parent_payment,
936 936
 						);
937 937
 
938
-						wp_update_post( $args );
938
+						wp_update_post($args);
939 939
 						break;
940 940
 
941 941
 					default:
@@ -946,34 +946,34 @@  discard block
 block discarded – undo
946 946
 						 *
947 947
 						 * @param Give_Payment $this Payment object.
948 948
 						 */
949
-						do_action( 'give_donation_save', $this, $key );
949
+						do_action('give_donation_save', $this, $key);
950 950
 						break;
951 951
 				}
952 952
 			}
953 953
 
954
-			if ( 'pending' !== $this->status ) {
954
+			if ('pending' !== $this->status) {
955 955
 
956
-				$customer = new Give_Customer( $this->customer_id );
956
+				$customer = new Give_Customer($this->customer_id);
957 957
 
958 958
 				$total_change = $total_increase - $total_decrease;
959
-				if ( $total_change < 0 ) {
959
+				if ($total_change < 0) {
960 960
 
961
-					$total_change = - ( $total_change );
961
+					$total_change = - ($total_change);
962 962
 					// Decrease the customer's donation stats
963
-					$customer->decrease_value( $total_change );
964
-					give_decrease_total_earnings( $total_change );
963
+					$customer->decrease_value($total_change);
964
+					give_decrease_total_earnings($total_change);
965 965
 
966
-				} else if ( $total_change > 0 ) {
966
+				} else if ($total_change > 0) {
967 967
 
968 968
 					// Increase the customer's donation stats
969
-					$customer->increase_value( $total_change );
970
-					give_increase_total_earnings( $total_change );
969
+					$customer->increase_value($total_change);
970
+					give_increase_total_earnings($total_change);
971 971
 
972 972
 				}
973 973
 
974 974
 			}
975 975
 
976
-			$this->update_meta( '_give_payment_total', $this->total );
976
+			$this->update_meta('_give_payment_total', $this->total);
977 977
 
978 978
 			$new_meta = array(
979 979
 				'form_title' => $this->form_title,
@@ -985,12 +985,12 @@  discard block
 block discarded – undo
985 985
 			);
986 986
 
987 987
 			$meta        = $this->get_meta();
988
-			$merged_meta = array_merge( $meta, $new_meta );
988
+			$merged_meta = array_merge($meta, $new_meta);
989 989
 
990 990
 			// Only save the payment meta if it's changed
991
-			if ( md5( serialize( $meta ) ) !== md5( serialize( $merged_meta ) ) ) {
992
-				$updated = $this->update_meta( '_give_payment_meta', $merged_meta );
993
-				if ( false !== $updated ) {
991
+			if (md5(serialize($meta)) !== md5(serialize($merged_meta))) {
992
+				$updated = $this->update_meta('_give_payment_meta', $merged_meta);
993
+				if (false !== $updated) {
994 994
 					$saved = true;
995 995
 				}
996 996
 			}
@@ -999,8 +999,8 @@  discard block
 block discarded – undo
999 999
 			$saved         = true;
1000 1000
 		}
1001 1001
 
1002
-		if ( true === $saved ) {
1003
-			$this->setup_payment( $this->ID );
1002
+		if (true === $saved) {
1003
+			$this->setup_payment($this->ID);
1004 1004
 		}
1005 1005
 
1006 1006
 		return $saved;
@@ -1018,12 +1018,12 @@  discard block
 block discarded – undo
1018 1018
 	 *
1019 1019
 	 * @return bool           True when successful, false otherwise
1020 1020
 	 */
1021
-	public function add_donation( $form_id = 0, $args = array(), $options = array() ) {
1021
+	public function add_donation($form_id = 0, $args = array(), $options = array()) {
1022 1022
 
1023
-		$donation = new Give_Donate_Form( $form_id );
1023
+		$donation = new Give_Donate_Form($form_id);
1024 1024
 
1025 1025
 		// Bail if this post isn't a give donation form
1026
-		if ( ! $donation || $donation->post_type !== 'give_forms' ) {
1026
+		if ( ! $donation || $donation->post_type !== 'give_forms') {
1027 1027
 			return false;
1028 1028
 		}
1029 1029
 
@@ -1034,60 +1034,60 @@  discard block
 block discarded – undo
1034 1034
 			'fees'     => array(),
1035 1035
 		);
1036 1036
 
1037
-		$args = wp_parse_args( apply_filters( 'give_donation_add_donation_args', $args, $donation->ID ), $defaults );
1037
+		$args = wp_parse_args(apply_filters('give_donation_add_donation_args', $args, $donation->ID), $defaults);
1038 1038
 
1039 1039
 		// Allow overriding the price
1040
-		if ( false !== $args['price'] ) {
1040
+		if (false !== $args['price']) {
1041 1041
 			$item_price = $args['price'];
1042 1042
 		} else {
1043 1043
 
1044 1044
 			// Deal with variable pricing
1045
-			if ( give_has_variable_prices( $donation->ID ) ) {
1046
-				$prices     = maybe_unserialize( get_post_meta( $form_id, '_give_donation_levels', true ) );
1045
+			if (give_has_variable_prices($donation->ID)) {
1046
+				$prices     = maybe_unserialize(get_post_meta($form_id, '_give_donation_levels', true));
1047 1047
 				$item_price = '';
1048 1048
 				//Loop through prices
1049
-				foreach ( $prices as $price ) {
1049
+				foreach ($prices as $price) {
1050 1050
 					//Find a match between price_id and level_id
1051 1051
 					//First verify array keys exists THEN make the match
1052
-					if ( ( isset( $args['price_id'] ) && isset( $price['_give_id']['level_id'] ) )
1052
+					if ((isset($args['price_id']) && isset($price['_give_id']['level_id']))
1053 1053
 					     && $args['price_id'] == $price['_give_id']['level_id']
1054 1054
 					) {
1055 1055
 						$item_price = $price['_give_amount'];
1056 1056
 					}
1057 1057
 				}
1058 1058
 				//Fallback to the lowest price point
1059
-				if ( $item_price == '' ) {
1060
-					$item_price       = give_get_lowest_price_option( $donation->ID );
1061
-					$args['price_id'] = give_get_lowest_price_id( $donation->ID );
1059
+				if ($item_price == '') {
1060
+					$item_price       = give_get_lowest_price_option($donation->ID);
1061
+					$args['price_id'] = give_get_lowest_price_id($donation->ID);
1062 1062
 				}
1063 1063
 			} else {
1064 1064
 				//Simple form price
1065
-				$item_price = give_get_form_price( $donation->ID );
1065
+				$item_price = give_get_form_price($donation->ID);
1066 1066
 			}
1067 1067
 
1068 1068
 		}
1069 1069
 
1070 1070
 		// Sanitizing the price here so we don't have a dozen calls later
1071
-		$item_price = give_sanitize_amount( $item_price );
1072
-		$total      = round( $item_price, give_currency_decimal_filter() );
1071
+		$item_price = give_sanitize_amount($item_price);
1072
+		$total      = round($item_price, give_currency_decimal_filter());
1073 1073
 
1074 1074
 		//Add Options
1075 1075
 		$default_options = array();
1076
-		if ( false !== $args['price_id'] ) {
1076
+		if (false !== $args['price_id']) {
1077 1077
 			$default_options['price_id'] = (int) $args['price_id'];
1078 1078
 		}
1079
-		$options = wp_parse_args( $options, $default_options );
1079
+		$options = wp_parse_args($options, $default_options);
1080 1080
 
1081 1081
 		// Do not allow totals to go negative
1082
-		if ( $total < 0 ) {
1082
+		if ($total < 0) {
1083 1083
 			$total = 0;
1084 1084
 		}
1085 1085
 
1086 1086
 		$donation = array(
1087 1087
 			'name'     => $donation->post_title,
1088 1088
 			'id'       => $donation->ID,
1089
-			'price'    => round( $total, give_currency_decimal_filter() ),
1090
-			'subtotal' => round( $total, give_currency_decimal_filter() ),
1089
+			'price'    => round($total, give_currency_decimal_filter()),
1090
+			'subtotal' => round($total, give_currency_decimal_filter()),
1091 1091
 			'fees'     => $args['fees'],
1092 1092
 			'price_id' => $args['price_id'],
1093 1093
 			'action'   => 'add',
@@ -1096,7 +1096,7 @@  discard block
 block discarded – undo
1096 1096
 
1097 1097
 		$this->pending['donations'][] = $donation;
1098 1098
 
1099
-		$this->increase_subtotal( $total );
1099
+		$this->increase_subtotal($total);
1100 1100
 
1101 1101
 		return true;
1102 1102
 
@@ -1113,7 +1113,7 @@  discard block
 block discarded – undo
1113 1113
 	 *
1114 1114
 	 * @return bool           If the item was removed or not
1115 1115
 	 */
1116
-	public function remove_donation( $form_id, $args = array() ) {
1116
+	public function remove_donation($form_id, $args = array()) {
1117 1117
 
1118 1118
 		// Set some defaults
1119 1119
 		$defaults = array(
@@ -1121,12 +1121,12 @@  discard block
 block discarded – undo
1121 1121
 			'price'    => false,
1122 1122
 			'price_id' => false,
1123 1123
 		);
1124
-		$args     = wp_parse_args( $args, $defaults );
1124
+		$args = wp_parse_args($args, $defaults);
1125 1125
 
1126
-		$form = new Give_Donate_Form( $form_id );
1126
+		$form = new Give_Donate_Form($form_id);
1127 1127
 
1128 1128
 		// Bail if this post isn't a valid give donation form
1129
-		if ( ! $form || $form->post_type !== 'give_forms' ) {
1129
+		if ( ! $form || $form->post_type !== 'give_forms') {
1130 1130
 			return false;
1131 1131
 		}
1132 1132
 
@@ -1139,7 +1139,7 @@  discard block
 block discarded – undo
1139 1139
 
1140 1140
 		$this->pending['donations'][] = $pending_args;
1141 1141
 
1142
-		$this->decrease_subtotal( $this->total );
1142
+		$this->decrease_subtotal($this->total);
1143 1143
 
1144 1144
 		return true;
1145 1145
 	}
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
 	 *
1156 1156
 	 * @return bool          If the fee was added
1157 1157
 	 */
1158
-	public function add_fee( $args, $global = true ) {
1158
+	public function add_fee($args, $global = true) {
1159 1159
 
1160 1160
 		$default_args = array(
1161 1161
 			'label'    => '',
@@ -1165,16 +1165,16 @@  discard block
 block discarded – undo
1165 1165
 			'price_id' => 0,
1166 1166
 		);
1167 1167
 
1168
-		$fee          = wp_parse_args( $args, $default_args );
1168
+		$fee          = wp_parse_args($args, $default_args);
1169 1169
 		$this->fees[] = $fee;
1170 1170
 
1171 1171
 
1172 1172
 		$added_fee               = $fee;
1173 1173
 		$added_fee['action']     = 'add';
1174 1174
 		$this->pending['fees'][] = $added_fee;
1175
-		reset( $this->fees );
1175
+		reset($this->fees);
1176 1176
 
1177
-		$this->increase_fees( $fee['amount'] );
1177
+		$this->increase_fees($fee['amount']);
1178 1178
 
1179 1179
 		return true;
1180 1180
 	}
@@ -1189,11 +1189,11 @@  discard block
 block discarded – undo
1189 1189
 	 *
1190 1190
 	 * @return bool     If the fee was removed successfully
1191 1191
 	 */
1192
-	public function remove_fee( $key ) {
1192
+	public function remove_fee($key) {
1193 1193
 		$removed = false;
1194 1194
 
1195
-		if ( is_numeric( $key ) ) {
1196
-			$removed = $this->remove_fee_by( 'index', $key );
1195
+		if (is_numeric($key)) {
1196
+			$removed = $this->remove_fee_by('index', $key);
1197 1197
 		}
1198 1198
 
1199 1199
 		return $removed;
@@ -1212,47 +1212,47 @@  discard block
 block discarded – undo
1212 1212
 	 *
1213 1213
 	 * @return boolean            If the item is removed
1214 1214
 	 */
1215
-	public function remove_fee_by( $key, $value, $global = false ) {
1215
+	public function remove_fee_by($key, $value, $global = false) {
1216 1216
 
1217
-		$allowed_fee_keys = apply_filters( 'give_donation_fee_keys', array(
1217
+		$allowed_fee_keys = apply_filters('give_donation_fee_keys', array(
1218 1218
 			'index',
1219 1219
 			'label',
1220 1220
 			'amount',
1221 1221
 			'type',
1222
-		) );
1222
+		));
1223 1223
 
1224
-		if ( ! in_array( $key, $allowed_fee_keys ) ) {
1224
+		if ( ! in_array($key, $allowed_fee_keys)) {
1225 1225
 			return false;
1226 1226
 		}
1227 1227
 
1228 1228
 		$removed = false;
1229
-		if ( 'index' === $key && array_key_exists( $value, $this->fees ) ) {
1229
+		if ('index' === $key && array_key_exists($value, $this->fees)) {
1230 1230
 
1231
-			$removed_fee             = $this->fees[ $value ];
1231
+			$removed_fee             = $this->fees[$value];
1232 1232
 			$removed_fee['action']   = 'remove';
1233 1233
 			$this->pending['fees'][] = $removed_fee;
1234 1234
 
1235
-			$this->decrease_fees( $removed_fee['amount'] );
1235
+			$this->decrease_fees($removed_fee['amount']);
1236 1236
 
1237
-			unset( $this->fees[ $value ] );
1237
+			unset($this->fees[$value]);
1238 1238
 			$removed = true;
1239 1239
 
1240
-		} else if ( 'index' !== $key ) {
1240
+		} else if ('index' !== $key) {
1241 1241
 
1242
-			foreach ( $this->fees as $index => $fee ) {
1242
+			foreach ($this->fees as $index => $fee) {
1243 1243
 
1244
-				if ( isset( $fee[ $key ] ) && $fee[ $key ] == $value ) {
1244
+				if (isset($fee[$key]) && $fee[$key] == $value) {
1245 1245
 
1246 1246
 					$removed_fee             = $fee;
1247 1247
 					$removed_fee['action']   = 'remove';
1248 1248
 					$this->pending['fees'][] = $removed_fee;
1249 1249
 
1250
-					$this->decrease_fees( $removed_fee['amount'] );
1250
+					$this->decrease_fees($removed_fee['amount']);
1251 1251
 
1252
-					unset( $this->fees[ $index ] );
1252
+					unset($this->fees[$index]);
1253 1253
 					$removed = true;
1254 1254
 
1255
-					if ( false === $global ) {
1255
+					if (false === $global) {
1256 1256
 						break;
1257 1257
 					}
1258 1258
 
@@ -1262,8 +1262,8 @@  discard block
 block discarded – undo
1262 1262
 
1263 1263
 		}
1264 1264
 
1265
-		if ( true === $removed ) {
1266
-			$this->fees = array_values( $this->fees );
1265
+		if (true === $removed) {
1266
+			$this->fees = array_values($this->fees);
1267 1267
 		}
1268 1268
 
1269 1269
 		return $removed;
@@ -1279,14 +1279,14 @@  discard block
 block discarded – undo
1279 1279
 	 *
1280 1280
 	 * @return array        The Fees for the type specified
1281 1281
 	 */
1282
-	public function get_fees( $type = 'all' ) {
1282
+	public function get_fees($type = 'all') {
1283 1283
 		$fees = array();
1284 1284
 
1285
-		if ( ! empty( $this->fees ) && is_array( $this->fees ) ) {
1285
+		if ( ! empty($this->fees) && is_array($this->fees)) {
1286 1286
 
1287
-			foreach ( $this->fees as $fee_id => $fee ) {
1287
+			foreach ($this->fees as $fee_id => $fee) {
1288 1288
 
1289
-				if ( 'all' != $type && ! empty( $fee['type'] ) && $type != $fee['type'] ) {
1289
+				if ('all' != $type && ! empty($fee['type']) && $type != $fee['type']) {
1290 1290
 					continue;
1291 1291
 				}
1292 1292
 
@@ -1296,7 +1296,7 @@  discard block
 block discarded – undo
1296 1296
 			}
1297 1297
 		}
1298 1298
 
1299
-		return apply_filters( 'give_get_payment_fees', $fees, $this->ID, $this );
1299
+		return apply_filters('give_get_payment_fees', $fees, $this->ID, $this);
1300 1300
 	}
1301 1301
 
1302 1302
 	/**
@@ -1309,13 +1309,13 @@  discard block
 block discarded – undo
1309 1309
 	 *
1310 1310
 	 * @return void
1311 1311
 	 */
1312
-	public function add_note( $note = false ) {
1312
+	public function add_note($note = false) {
1313 1313
 		// Bail if no note specified
1314
-		if ( ! $note ) {
1314
+		if ( ! $note) {
1315 1315
 			return false;
1316 1316
 		}
1317 1317
 
1318
-		give_insert_payment_note( $this->ID, $note );
1318
+		give_insert_payment_note($this->ID, $note);
1319 1319
 	}
1320 1320
 
1321 1321
 	/**
@@ -1328,7 +1328,7 @@  discard block
 block discarded – undo
1328 1328
 	 *
1329 1329
 	 * @return void
1330 1330
 	 */
1331
-	private function increase_subtotal( $amount = 0.00 ) {
1331
+	private function increase_subtotal($amount = 0.00) {
1332 1332
 		$amount = (float) $amount;
1333 1333
 		$this->subtotal += $amount;
1334 1334
 
@@ -1345,11 +1345,11 @@  discard block
 block discarded – undo
1345 1345
 	 *
1346 1346
 	 * @return void
1347 1347
 	 */
1348
-	private function decrease_subtotal( $amount = 0.00 ) {
1348
+	private function decrease_subtotal($amount = 0.00) {
1349 1349
 		$amount = (float) $amount;
1350 1350
 		$this->subtotal -= $amount;
1351 1351
 
1352
-		if ( $this->subtotal < 0 ) {
1352
+		if ($this->subtotal < 0) {
1353 1353
 			$this->subtotal = 0;
1354 1354
 		}
1355 1355
 
@@ -1366,7 +1366,7 @@  discard block
 block discarded – undo
1366 1366
 	 *
1367 1367
 	 * @return void
1368 1368
 	 */
1369
-	private function increase_fees( $amount = 0.00 ) {
1369
+	private function increase_fees($amount = 0.00) {
1370 1370
 		$amount = (float) $amount;
1371 1371
 		$this->fees_total += $amount;
1372 1372
 
@@ -1383,11 +1383,11 @@  discard block
 block discarded – undo
1383 1383
 	 *
1384 1384
 	 * @return void
1385 1385
 	 */
1386
-	private function decrease_fees( $amount = 0.00 ) {
1386
+	private function decrease_fees($amount = 0.00) {
1387 1387
 		$amount = (float) $amount;
1388 1388
 		$this->fees_total -= $amount;
1389 1389
 
1390
-		if ( $this->fees_total < 0 ) {
1390
+		if ($this->fees_total < 0) {
1391 1391
 			$this->fees_total = 0;
1392 1392
 		}
1393 1393
 
@@ -1416,25 +1416,25 @@  discard block
 block discarded – undo
1416 1416
 	 *
1417 1417
 	 * @return bool   $updated Returns if the status was successfully updated.
1418 1418
 	 */
1419
-	public function update_status( $status = false ) {
1419
+	public function update_status($status = false) {
1420 1420
 
1421 1421
 		//standardize the 'complete(d)' status
1422
-		if ( $status == 'completed' || $status == 'complete' ) {
1422
+		if ($status == 'completed' || $status == 'complete') {
1423 1423
 			$status = 'publish';
1424 1424
 		}
1425 1425
 
1426
-		$old_status = ! empty( $this->old_status ) ? $this->old_status : false;
1426
+		$old_status = ! empty($this->old_status) ? $this->old_status : false;
1427 1427
 
1428
-		if ( $old_status === $status ) {
1428
+		if ($old_status === $status) {
1429 1429
 			return false; // Don't permit status changes that aren't changes
1430 1430
 		}
1431 1431
 
1432
-		$do_change = apply_filters( 'give_should_update_payment_status', true, $this->ID, $status, $old_status );
1432
+		$do_change = apply_filters('give_should_update_payment_status', true, $this->ID, $status, $old_status);
1433 1433
 
1434 1434
 		$updated = false;
1435 1435
 
1436 1436
 
1437
-		if ( $do_change ) {
1437
+		if ($do_change) {
1438 1438
 
1439 1439
 			/**
1440 1440
 			 * Fires before changing payment status.
@@ -1445,21 +1445,21 @@  discard block
 block discarded – undo
1445 1445
 			 * @param string $status     The new status.
1446 1446
 			 * @param string $old_status The old status.
1447 1447
 			 */
1448
-			do_action( 'give_before_payment_status_change', $this->ID, $status, $old_status );
1448
+			do_action('give_before_payment_status_change', $this->ID, $status, $old_status);
1449 1449
 
1450 1450
 			$update_fields = array(
1451 1451
 				'ID'          => $this->ID,
1452 1452
 				'post_status' => $status,
1453
-				'edit_date'   => current_time( 'mysql' )
1453
+				'edit_date'   => current_time('mysql')
1454 1454
 			);
1455 1455
 
1456
-			$updated = wp_update_post( apply_filters( 'give_update_payment_status_fields', $update_fields ) );
1456
+			$updated = wp_update_post(apply_filters('give_update_payment_status_fields', $update_fields));
1457 1457
 
1458 1458
 			$all_payment_statuses  = give_get_payment_statuses();
1459
-			$this->status_nicename = array_key_exists( $status, $all_payment_statuses ) ? $all_payment_statuses[ $status ] : ucfirst( $status );
1459
+			$this->status_nicename = array_key_exists($status, $all_payment_statuses) ? $all_payment_statuses[$status] : ucfirst($status);
1460 1460
 
1461 1461
 			// Process any specific status functions
1462
-			switch ( $status ) {
1462
+			switch ($status) {
1463 1463
 				case 'refunded':
1464 1464
 					$this->process_refund();
1465 1465
 					break;
@@ -1486,7 +1486,7 @@  discard block
 block discarded – undo
1486 1486
 			 * @param string $status     The new status.
1487 1487
 			 * @param string $old_status The old status.
1488 1488
 			 */
1489
-			do_action( 'give_update_payment_status', $this->ID, $status, $old_status );
1489
+			do_action('give_update_payment_status', $this->ID, $status, $old_status);
1490 1490
 
1491 1491
 		}
1492 1492
 
@@ -1521,32 +1521,32 @@  discard block
 block discarded – undo
1521 1521
 	 *
1522 1522
 	 * @return mixed             The value from the post meta
1523 1523
 	 */
1524
-	public function get_meta( $meta_key = '_give_payment_meta', $single = true ) {
1524
+	public function get_meta($meta_key = '_give_payment_meta', $single = true) {
1525 1525
 
1526
-		$meta = get_post_meta( $this->ID, $meta_key, $single );
1526
+		$meta = get_post_meta($this->ID, $meta_key, $single);
1527 1527
 
1528
-		if ( $meta_key === '_give_payment_meta' ) {
1528
+		if ($meta_key === '_give_payment_meta') {
1529 1529
 
1530
-			if ( empty( $meta['key'] ) ) {
1530
+			if (empty($meta['key'])) {
1531 1531
 				$meta['key'] = $this->setup_payment_key();
1532 1532
 			}
1533 1533
 
1534
-			if ( empty( $meta['form_title'] ) ) {
1534
+			if (empty($meta['form_title'])) {
1535 1535
 				$meta['form_title'] = $this->setup_form_title();
1536 1536
 			}
1537 1537
 
1538
-			if ( empty( $meta['email'] ) ) {
1538
+			if (empty($meta['email'])) {
1539 1539
 				$meta['email'] = $this->setup_email();
1540 1540
 			}
1541 1541
 
1542
-			if ( empty( $meta['date'] ) ) {
1543
-				$meta['date'] = get_post_field( 'post_date', $this->ID );
1542
+			if (empty($meta['date'])) {
1543
+				$meta['date'] = get_post_field('post_date', $this->ID);
1544 1544
 			}
1545 1545
 		}
1546 1546
 
1547
-		$meta = apply_filters( "give_get_payment_meta_{$meta_key}", $meta, $this->ID );
1547
+		$meta = apply_filters("give_get_payment_meta_{$meta_key}", $meta, $this->ID);
1548 1548
 
1549
-		return apply_filters( 'give_get_payment_meta', $meta, $this->ID, $meta_key );
1549
+		return apply_filters('give_get_payment_meta', $meta, $this->ID, $meta_key);
1550 1550
 	}
1551 1551
 
1552 1552
 	/**
@@ -1561,23 +1561,23 @@  discard block
 block discarded – undo
1561 1561
 	 *
1562 1562
 	 * @return int|bool           Meta ID if the key didn't exist, true on successful update, false on failure
1563 1563
 	 */
1564
-	public function update_meta( $meta_key = '', $meta_value = '', $prev_value = '' ) {
1565
-		if ( empty( $meta_key ) ) {
1564
+	public function update_meta($meta_key = '', $meta_value = '', $prev_value = '') {
1565
+		if (empty($meta_key)) {
1566 1566
 			return false;
1567 1567
 		}
1568 1568
 
1569
-		if ( $meta_key == 'key' || $meta_key == 'date' ) {
1569
+		if ($meta_key == 'key' || $meta_key == 'date') {
1570 1570
 
1571 1571
 			$current_meta              = $this->get_meta();
1572
-			$current_meta[ $meta_key ] = $meta_value;
1572
+			$current_meta[$meta_key] = $meta_value;
1573 1573
 
1574 1574
 			$meta_key   = '_give_payment_meta';
1575 1575
 			$meta_value = $current_meta;
1576 1576
 
1577
-		} else if ( $meta_key == 'email' || $meta_key == '_give_payment_user_email' ) {
1577
+		} else if ($meta_key == 'email' || $meta_key == '_give_payment_user_email') {
1578 1578
 
1579
-			$meta_value = apply_filters( "give_give_update_payment_meta_{$meta_key}", $meta_value, $this->ID );
1580
-			update_post_meta( $this->ID, '_give_payment_user_email', $meta_value );
1579
+			$meta_value = apply_filters("give_give_update_payment_meta_{$meta_key}", $meta_value, $this->ID);
1580
+			update_post_meta($this->ID, '_give_payment_user_email', $meta_value);
1581 1581
 
1582 1582
 			$current_meta                       = $this->get_meta();
1583 1583
 			$current_meta['user_info']['email'] = $meta_value;
@@ -1587,9 +1587,9 @@  discard block
 block discarded – undo
1587 1587
 
1588 1588
 		}
1589 1589
 
1590
-		$meta_value = apply_filters( "give_update_payment_meta_{$meta_key}", $meta_value, $this->ID );
1590
+		$meta_value = apply_filters("give_update_payment_meta_{$meta_key}", $meta_value, $this->ID);
1591 1591
 
1592
-		return update_post_meta( $this->ID, $meta_key, $meta_value, $prev_value );
1592
+		return update_post_meta($this->ID, $meta_key, $meta_value, $prev_value);
1593 1593
 	}
1594 1594
 
1595 1595
 	/**
@@ -1604,14 +1604,14 @@  discard block
 block discarded – undo
1604 1604
 		$process_refund = true;
1605 1605
 
1606 1606
 		// If the payment was not in publish or revoked status, don't decrement stats as they were never incremented
1607
-		if ( 'publish' != $this->old_status || 'refunded' != $this->status ) {
1607
+		if ('publish' != $this->old_status || 'refunded' != $this->status) {
1608 1608
 			$process_refund = false;
1609 1609
 		}
1610 1610
 
1611 1611
 		// Allow extensions to filter for their own payment types, Example: Recurring Payments
1612
-		$process_refund = apply_filters( 'give_should_process_refund', $process_refund, $this );
1612
+		$process_refund = apply_filters('give_should_process_refund', $process_refund, $this);
1613 1613
 
1614
-		if ( false === $process_refund ) {
1614
+		if (false === $process_refund) {
1615 1615
 			return;
1616 1616
 		}
1617 1617
 
@@ -1622,17 +1622,17 @@  discard block
 block discarded – undo
1622 1622
 		 *
1623 1623
 		 * @param Give_Payment $this Payment object.
1624 1624
 		 */
1625
-		do_action( 'give_pre_refund_payment', $this );
1625
+		do_action('give_pre_refund_payment', $this);
1626 1626
 
1627
-		$decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_refund', true, $this );
1628
-		$decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_refund', true, $this );
1629
-		$decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_refund', true, $this );
1627
+		$decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_refund', true, $this);
1628
+		$decrease_customer_value = apply_filters('give_decrease_customer_value_on_refund', true, $this);
1629
+		$decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_refund', true, $this);
1630 1630
 
1631
-		$this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count );
1631
+		$this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count);
1632 1632
 		$this->delete_sales_logs();
1633 1633
 
1634 1634
 		// Clear the This Month earnings (this_monththis_month is NOT a typo)
1635
-		delete_transient( md5( 'give_earnings_this_monththis_month' ) );
1635
+		delete_transient(md5('give_earnings_this_monththis_month'));
1636 1636
 
1637 1637
 		/**
1638 1638
 		 * Fires after refunding payment.
@@ -1641,7 +1641,7 @@  discard block
 block discarded – undo
1641 1641
 		 *
1642 1642
 		 * @param Give_Payment $this Payment object.
1643 1643
 		 */
1644
-		do_action( 'give_post_refund_payment', $this );
1644
+		do_action('give_post_refund_payment', $this);
1645 1645
 	}
1646 1646
 
1647 1647
 	/**
@@ -1668,29 +1668,29 @@  discard block
 block discarded – undo
1668 1668
 		$process_pending = true;
1669 1669
 
1670 1670
 		// If the payment was not in publish or revoked status, don't decrement stats as they were never incremented
1671
-		if ( 'publish' != $this->old_status || 'pending' != $this->status ) {
1671
+		if ('publish' != $this->old_status || 'pending' != $this->status) {
1672 1672
 			$process_pending = false;
1673 1673
 		}
1674 1674
 
1675 1675
 		// Allow extensions to filter for their own payment types, Example: Recurring Payments
1676
-		$process_pending = apply_filters( 'give_should_process_pending', $process_pending, $this );
1676
+		$process_pending = apply_filters('give_should_process_pending', $process_pending, $this);
1677 1677
 
1678
-		if ( false === $process_pending ) {
1678
+		if (false === $process_pending) {
1679 1679
 			return;
1680 1680
 		}
1681 1681
 
1682
-		$decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_pending', true, $this );
1683
-		$decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_pending', true, $this );
1684
-		$decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_pending', true, $this );
1682
+		$decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_pending', true, $this);
1683
+		$decrease_customer_value = apply_filters('give_decrease_customer_value_on_pending', true, $this);
1684
+		$decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_pending', true, $this);
1685 1685
 
1686
-		$this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count );
1686
+		$this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count);
1687 1687
 		$this->delete_sales_logs();
1688 1688
 
1689 1689
 		$this->completed_date = false;
1690
-		$this->update_meta( '_give_completed_date', '' );
1690
+		$this->update_meta('_give_completed_date', '');
1691 1691
 
1692 1692
 		// Clear the This Month earnings (this_monththis_month is NOT a typo)
1693
-		delete_transient( md5( 'give_earnings_this_monththis_month' ) );
1693
+		delete_transient(md5('give_earnings_this_monththis_month'));
1694 1694
 	}
1695 1695
 
1696 1696
 	/**
@@ -1705,29 +1705,29 @@  discard block
 block discarded – undo
1705 1705
 		$process_cancelled = true;
1706 1706
 
1707 1707
 		// If the payment was not in publish or revoked status, don't decrement stats as they were never incremented
1708
-		if ( 'publish' != $this->old_status || 'cancelled' != $this->status ) {
1708
+		if ('publish' != $this->old_status || 'cancelled' != $this->status) {
1709 1709
 			$process_cancelled = false;
1710 1710
 		}
1711 1711
 
1712 1712
 		// Allow extensions to filter for their own payment types, Example: Recurring Payments
1713
-		$process_cancelled = apply_filters( 'give_should_process_cancelled', $process_cancelled, $this );
1713
+		$process_cancelled = apply_filters('give_should_process_cancelled', $process_cancelled, $this);
1714 1714
 
1715
-		if ( false === $process_cancelled ) {
1715
+		if (false === $process_cancelled) {
1716 1716
 			return;
1717 1717
 		}
1718 1718
 
1719
-		$decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_cancelled', true, $this );
1720
-		$decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_cancelled', true, $this );
1721
-		$decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_cancelled', true, $this );
1719
+		$decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_cancelled', true, $this);
1720
+		$decrease_customer_value = apply_filters('give_decrease_customer_value_on_cancelled', true, $this);
1721
+		$decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_cancelled', true, $this);
1722 1722
 
1723
-		$this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count );
1723
+		$this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count);
1724 1724
 		$this->delete_sales_logs();
1725 1725
 
1726 1726
 		$this->completed_date = false;
1727
-		$this->update_meta( '_give_completed_date', '' );
1727
+		$this->update_meta('_give_completed_date', '');
1728 1728
 
1729 1729
 		// Clear the This Month earnings (this_monththis_month is NOT a typo)
1730
-		delete_transient( md5( 'give_earnings_this_monththis_month' ) );
1730
+		delete_transient(md5('give_earnings_this_monththis_month'));
1731 1731
 	}
1732 1732
 
1733 1733
 	/**
@@ -1740,29 +1740,29 @@  discard block
 block discarded – undo
1740 1740
 		$process_revoked = true;
1741 1741
 
1742 1742
 		// If the payment was not in publish, don't decrement stats as they were never incremented
1743
-		if ( 'publish' != $this->old_status || 'revoked' != $this->status ) {
1743
+		if ('publish' != $this->old_status || 'revoked' != $this->status) {
1744 1744
 			$process_revoked = false;
1745 1745
 		}
1746 1746
 
1747 1747
 		// Allow extensions to filter for their own payment types, Example: Recurring Payments
1748
-		$process_revoked = apply_filters( 'give_should_process_revoked', $process_revoked, $this );
1748
+		$process_revoked = apply_filters('give_should_process_revoked', $process_revoked, $this);
1749 1749
 
1750
-		if ( false === $process_revoked ) {
1750
+		if (false === $process_revoked) {
1751 1751
 			return;
1752 1752
 		}
1753 1753
 
1754
-		$decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_revoked', true, $this );
1755
-		$decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_revoked', true, $this );
1756
-		$decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_revoked', true, $this );
1754
+		$decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_revoked', true, $this);
1755
+		$decrease_customer_value = apply_filters('give_decrease_customer_value_on_revoked', true, $this);
1756
+		$decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_revoked', true, $this);
1757 1757
 
1758
-		$this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count );
1758
+		$this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count);
1759 1759
 		$this->delete_sales_logs();
1760 1760
 
1761 1761
 		$this->completed_date = false;
1762
-		$this->update_meta( '_give_completed_date', '' );
1762
+		$this->update_meta('_give_completed_date', '');
1763 1763
 
1764 1764
 		// Clear the This Month earnings (this_monththis_month is NOT a typo)
1765
-		delete_transient( md5( 'give_earnings_this_monththis_month' ) );
1765
+		delete_transient(md5('give_earnings_this_monththis_month'));
1766 1766
 	}
1767 1767
 
1768 1768
 	/**
@@ -1777,25 +1777,25 @@  discard block
 block discarded – undo
1777 1777
 	 *
1778 1778
 	 * @return void
1779 1779
 	 */
1780
-	private function maybe_alter_stats( $alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count ) {
1780
+	private function maybe_alter_stats($alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count) {
1781 1781
 
1782
-		give_undo_purchase( false, $this->ID );
1782
+		give_undo_purchase(false, $this->ID);
1783 1783
 
1784 1784
 		// Decrease store earnings
1785
-		if ( true === $alter_store_earnings ) {
1786
-			give_decrease_total_earnings( $this->total );
1785
+		if (true === $alter_store_earnings) {
1786
+			give_decrease_total_earnings($this->total);
1787 1787
 		}
1788 1788
 
1789 1789
 		// Decrement the stats for the customer
1790
-		if ( ! empty( $this->customer_id ) ) {
1790
+		if ( ! empty($this->customer_id)) {
1791 1791
 
1792
-			$customer = new Give_Customer( $this->customer_id );
1792
+			$customer = new Give_Customer($this->customer_id);
1793 1793
 
1794
-			if ( true === $alter_customer_value ) {
1795
-				$customer->decrease_value( $this->total );
1794
+			if (true === $alter_customer_value) {
1795
+				$customer->decrease_value($this->total);
1796 1796
 			}
1797 1797
 
1798
-			if ( true === $alter_customer_purchase_count ) {
1798
+			if (true === $alter_customer_purchase_count) {
1799 1799
 				$customer->decrease_purchase_count();
1800 1800
 			}
1801 1801
 
@@ -1845,13 +1845,13 @@  discard block
 block discarded – undo
1845 1845
 	 * @return string The date the payment was completed
1846 1846
 	 */
1847 1847
 	private function setup_completed_date() {
1848
-		$payment = get_post( $this->ID );
1848
+		$payment = get_post($this->ID);
1849 1849
 
1850
-		if ( 'pending' == $payment->post_status || 'preapproved' == $payment->post_status ) {
1850
+		if ('pending' == $payment->post_status || 'preapproved' == $payment->post_status) {
1851 1851
 			return false; // This payment was never completed
1852 1852
 		}
1853 1853
 
1854
-		$date = ( $date = $this->get_meta( '_give_completed_date', true ) ) ? $date : $payment->modified_date;
1854
+		$date = ($date = $this->get_meta('_give_completed_date', true)) ? $date : $payment->modified_date;
1855 1855
 
1856 1856
 		return $date;
1857 1857
 	}
@@ -1865,7 +1865,7 @@  discard block
 block discarded – undo
1865 1865
 	 * @return string The payment mode
1866 1866
 	 */
1867 1867
 	private function setup_mode() {
1868
-		return $this->get_meta( '_give_payment_mode' );
1868
+		return $this->get_meta('_give_payment_mode');
1869 1869
 	}
1870 1870
 
1871 1871
 	/**
@@ -1877,13 +1877,13 @@  discard block
 block discarded – undo
1877 1877
 	 * @return float The payment total
1878 1878
 	 */
1879 1879
 	private function setup_total() {
1880
-		$amount = $this->get_meta( '_give_payment_total', true );
1880
+		$amount = $this->get_meta('_give_payment_total', true);
1881 1881
 
1882
-		if ( empty( $amount ) && '0.00' != $amount ) {
1883
-			$meta = $this->get_meta( '_give_payment_meta', true );
1884
-			$meta = maybe_unserialize( $meta );
1882
+		if (empty($amount) && '0.00' != $amount) {
1883
+			$meta = $this->get_meta('_give_payment_meta', true);
1884
+			$meta = maybe_unserialize($meta);
1885 1885
 
1886
-			if ( isset( $meta['amount'] ) ) {
1886
+			if (isset($meta['amount'])) {
1887 1887
 				$amount = $meta['amount'];
1888 1888
 			}
1889 1889
 		}
@@ -1916,9 +1916,9 @@  discard block
 block discarded – undo
1916 1916
 	private function setup_fees_total() {
1917 1917
 		$fees_total = (float) 0.00;
1918 1918
 
1919
-		$payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array();
1920
-		if ( ! empty( $payment_fees ) ) {
1921
-			foreach ( $payment_fees as $fee ) {
1919
+		$payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array();
1920
+		if ( ! empty($payment_fees)) {
1921
+			foreach ($payment_fees as $fee) {
1922 1922
 				$fees_total += (float) $fee['amount'];
1923 1923
 			}
1924 1924
 		}
@@ -1936,7 +1936,7 @@  discard block
 block discarded – undo
1936 1936
 	 * @return string The currency for the payment
1937 1937
 	 */
1938 1938
 	private function setup_currency() {
1939
-		$currency = isset( $this->payment_meta['currency'] ) ? $this->payment_meta['currency'] : apply_filters( 'give_donation_currency_default', give_get_currency(), $this );
1939
+		$currency = isset($this->payment_meta['currency']) ? $this->payment_meta['currency'] : apply_filters('give_donation_currency_default', give_get_currency(), $this);
1940 1940
 
1941 1941
 		return $currency;
1942 1942
 	}
@@ -1950,7 +1950,7 @@  discard block
 block discarded – undo
1950 1950
 	 * @return array The Fees
1951 1951
 	 */
1952 1952
 	private function setup_fees() {
1953
-		$payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array();
1953
+		$payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array();
1954 1954
 
1955 1955
 		return $payment_fees;
1956 1956
 	}
@@ -1964,7 +1964,7 @@  discard block
 block discarded – undo
1964 1964
 	 * @return string The gateway
1965 1965
 	 */
1966 1966
 	private function setup_gateway() {
1967
-		$gateway = $this->get_meta( '_give_payment_gateway', true );
1967
+		$gateway = $this->get_meta('_give_payment_gateway', true);
1968 1968
 
1969 1969
 		return $gateway;
1970 1970
 	}
@@ -1978,12 +1978,12 @@  discard block
 block discarded – undo
1978 1978
 	 * @return string The donation ID
1979 1979
 	 */
1980 1980
 	private function setup_transaction_id() {
1981
-		$transaction_id = $this->get_meta( '_give_payment_transaction_id', true );
1981
+		$transaction_id = $this->get_meta('_give_payment_transaction_id', true);
1982 1982
 
1983
-		if ( empty( $transaction_id ) || (int) $transaction_id === (int) $this->ID ) {
1983
+		if (empty($transaction_id) || (int) $transaction_id === (int) $this->ID) {
1984 1984
 
1985 1985
 			$gateway        = $this->gateway;
1986
-			$transaction_id = apply_filters( "give_get_payment_transaction_id-{$gateway}", $this->ID );
1986
+			$transaction_id = apply_filters("give_get_payment_transaction_id-{$gateway}", $this->ID);
1987 1987
 
1988 1988
 		}
1989 1989
 
@@ -1999,7 +1999,7 @@  discard block
 block discarded – undo
1999 1999
 	 * @return string The IP address for the payment
2000 2000
 	 */
2001 2001
 	private function setup_ip() {
2002
-		$ip = $this->get_meta( '_give_payment_user_ip', true );
2002
+		$ip = $this->get_meta('_give_payment_user_ip', true);
2003 2003
 
2004 2004
 		return $ip;
2005 2005
 	}
@@ -2013,7 +2013,7 @@  discard block
 block discarded – undo
2013 2013
 	 * @return int The Customer ID
2014 2014
 	 */
2015 2015
 	private function setup_customer_id() {
2016
-		$customer_id = $this->get_meta( '_give_payment_customer_id', true );
2016
+		$customer_id = $this->get_meta('_give_payment_customer_id', true);
2017 2017
 
2018 2018
 		return $customer_id;
2019 2019
 	}
@@ -2027,7 +2027,7 @@  discard block
 block discarded – undo
2027 2027
 	 * @return int The User ID
2028 2028
 	 */
2029 2029
 	private function setup_user_id() {
2030
-		$user_id = $this->get_meta( '_give_payment_user_id', true );
2030
+		$user_id = $this->get_meta('_give_payment_user_id', true);
2031 2031
 
2032 2032
 		return $user_id;
2033 2033
 	}
@@ -2041,10 +2041,10 @@  discard block
 block discarded – undo
2041 2041
 	 * @return string The email address for the payment
2042 2042
 	 */
2043 2043
 	private function setup_email() {
2044
-		$email = $this->get_meta( '_give_payment_user_email', true );
2044
+		$email = $this->get_meta('_give_payment_user_email', true);
2045 2045
 
2046
-		if ( empty( $email ) ) {
2047
-			$email = Give()->customers->get_column( 'email', $this->customer_id );
2046
+		if (empty($email)) {
2047
+			$email = Give()->customers->get_column('email', $this->customer_id);
2048 2048
 		}
2049 2049
 
2050 2050
 		return $email;
@@ -2064,15 +2064,15 @@  discard block
 block discarded – undo
2064 2064
 			'last_name'  => $this->last_name,
2065 2065
 		);
2066 2066
 
2067
-		$user_info = isset( $this->payment_meta['user_info'] ) ? maybe_unserialize( $this->payment_meta['user_info'] ) : array();
2068
-		$user_info = wp_parse_args( $user_info, $defaults );
2067
+		$user_info = isset($this->payment_meta['user_info']) ? maybe_unserialize($this->payment_meta['user_info']) : array();
2068
+		$user_info = wp_parse_args($user_info, $defaults);
2069 2069
 
2070
-		if ( empty( $user_info ) ) {
2070
+		if (empty($user_info)) {
2071 2071
 			// Get the customer, but only if it's been created
2072
-			$customer = new Give_Customer( $this->customer_id );
2072
+			$customer = new Give_Customer($this->customer_id);
2073 2073
 
2074
-			if ( $customer->id > 0 ) {
2075
-				$name      = explode( ' ', $customer->name, 2 );
2074
+			if ($customer->id > 0) {
2075
+				$name      = explode(' ', $customer->name, 2);
2076 2076
 				$user_info = array(
2077 2077
 					'first_name' => $name[0],
2078 2078
 					'last_name'  => $name[1],
@@ -2082,29 +2082,29 @@  discard block
 block discarded – undo
2082 2082
 			}
2083 2083
 		} else {
2084 2084
 			// Get the customer, but only if it's been created
2085
-			$customer = new Give_Customer( $this->customer_id );
2086
-			if ( $customer->id > 0 ) {
2087
-				foreach ( $user_info as $key => $value ) {
2088
-					if ( ! empty( $value ) ) {
2085
+			$customer = new Give_Customer($this->customer_id);
2086
+			if ($customer->id > 0) {
2087
+				foreach ($user_info as $key => $value) {
2088
+					if ( ! empty($value)) {
2089 2089
 						continue;
2090 2090
 					}
2091 2091
 
2092
-					switch ( $key ) {
2092
+					switch ($key) {
2093 2093
 						case 'first_name':
2094
-							$name = explode( ' ', $customer->name, 2 );
2094
+							$name = explode(' ', $customer->name, 2);
2095 2095
 
2096
-							$user_info[ $key ] = $name[0];
2096
+							$user_info[$key] = $name[0];
2097 2097
 							break;
2098 2098
 
2099 2099
 						case 'last_name':
2100
-							$name      = explode( ' ', $customer->name, 2 );
2101
-							$last_name = ! empty( $name[1] ) ? $name[1] : '';
2100
+							$name      = explode(' ', $customer->name, 2);
2101
+							$last_name = ! empty($name[1]) ? $name[1] : '';
2102 2102
 
2103
-							$user_info[ $key ] = $last_name;
2103
+							$user_info[$key] = $last_name;
2104 2104
 							break;
2105 2105
 
2106 2106
 						case 'email':
2107
-							$user_info[ $key ] = $customer->email;
2107
+							$user_info[$key] = $customer->email;
2108 2108
 							break;
2109 2109
 					}
2110 2110
 				}
@@ -2126,7 +2126,7 @@  discard block
 block discarded – undo
2126 2126
 	 */
2127 2127
 	private function setup_address() {
2128 2128
 
2129
-		$address = ! empty( $this->payment_meta['user_info']['address'] ) ? $this->payment_meta['user_info']['address'] : array(
2129
+		$address = ! empty($this->payment_meta['user_info']['address']) ? $this->payment_meta['user_info']['address'] : array(
2130 2130
 			'line1'   => '',
2131 2131
 			'line2'   => '',
2132 2132
 			'city'    => '',
@@ -2148,7 +2148,7 @@  discard block
 block discarded – undo
2148 2148
 	 */
2149 2149
 	private function setup_form_title() {
2150 2150
 
2151
-		$form_id = $this->get_meta( '_give_payment_form_title', true );
2151
+		$form_id = $this->get_meta('_give_payment_form_title', true);
2152 2152
 
2153 2153
 		return $form_id;
2154 2154
 	}
@@ -2163,7 +2163,7 @@  discard block
 block discarded – undo
2163 2163
 	 */
2164 2164
 	private function setup_form_id() {
2165 2165
 
2166
-		$form_id = $this->get_meta( '_give_payment_form_id', true );
2166
+		$form_id = $this->get_meta('_give_payment_form_id', true);
2167 2167
 
2168 2168
 		return $form_id;
2169 2169
 	}
@@ -2177,7 +2177,7 @@  discard block
 block discarded – undo
2177 2177
 	 * @return int The Form Price ID
2178 2178
 	 */
2179 2179
 	private function setup_price_id() {
2180
-		$price_id = $this->get_meta( '_give_payment_price_id', true );
2180
+		$price_id = $this->get_meta('_give_payment_price_id', true);
2181 2181
 
2182 2182
 		return $price_id;
2183 2183
 	}
@@ -2191,7 +2191,7 @@  discard block
 block discarded – undo
2191 2191
 	 * @return string The Payment Key
2192 2192
 	 */
2193 2193
 	private function setup_payment_key() {
2194
-		$key = $this->get_meta( '_give_payment_purchase_key', true );
2194
+		$key = $this->get_meta('_give_payment_purchase_key', true);
2195 2195
 
2196 2196
 		return $key;
2197 2197
 	}
@@ -2207,11 +2207,11 @@  discard block
 block discarded – undo
2207 2207
 	private function setup_payment_number() {
2208 2208
 		$number = $this->ID;
2209 2209
 
2210
-		if ( give_get_option( 'enable_sequential' ) ) {
2210
+		if (give_get_option('enable_sequential')) {
2211 2211
 
2212
-			$number = $this->get_meta( '_give_payment_number', true );
2212
+			$number = $this->get_meta('_give_payment_number', true);
2213 2213
 
2214
-			if ( ! $number ) {
2214
+			if ( ! $number) {
2215 2215
 
2216 2216
 				$number = $this->ID;
2217 2217
 
@@ -2230,7 +2230,7 @@  discard block
 block discarded – undo
2230 2230
 	 * @return array The payment object as an array
2231 2231
 	 */
2232 2232
 	public function array_convert() {
2233
-		return get_object_vars( $this );
2233
+		return get_object_vars($this);
2234 2234
 	}
2235 2235
 
2236 2236
 	/**
@@ -2242,7 +2242,7 @@  discard block
 block discarded – undo
2242 2242
 	 * @return string Date payment was completed
2243 2243
 	 */
2244 2244
 	private function get_completed_date() {
2245
-		return apply_filters( 'give_donation_completed_date', $this->completed_date, $this->ID, $this );
2245
+		return apply_filters('give_donation_completed_date', $this->completed_date, $this->ID, $this);
2246 2246
 	}
2247 2247
 
2248 2248
 	/**
@@ -2254,7 +2254,7 @@  discard block
 block discarded – undo
2254 2254
 	 * @return float Payment subtotal
2255 2255
 	 */
2256 2256
 	private function get_subtotal() {
2257
-		return apply_filters( 'give_get_payment_subtotal', $this->subtotal, $this->ID, $this );
2257
+		return apply_filters('give_get_payment_subtotal', $this->subtotal, $this->ID, $this);
2258 2258
 	}
2259 2259
 
2260 2260
 	/**
@@ -2266,7 +2266,7 @@  discard block
 block discarded – undo
2266 2266
 	 * @return string Payment currency code
2267 2267
 	 */
2268 2268
 	private function get_currency() {
2269
-		return apply_filters( 'give_donation_currency_code', $this->currency, $this->ID, $this );
2269
+		return apply_filters('give_donation_currency_code', $this->currency, $this->ID, $this);
2270 2270
 	}
2271 2271
 
2272 2272
 	/**
@@ -2278,7 +2278,7 @@  discard block
 block discarded – undo
2278 2278
 	 * @return string Gateway used
2279 2279
 	 */
2280 2280
 	private function get_gateway() {
2281
-		return apply_filters( 'give_donation_gateway', $this->gateway, $this->ID, $this );
2281
+		return apply_filters('give_donation_gateway', $this->gateway, $this->ID, $this);
2282 2282
 	}
2283 2283
 
2284 2284
 	/**
@@ -2290,7 +2290,7 @@  discard block
 block discarded – undo
2290 2290
 	 * @return string Donation ID from merchant processor
2291 2291
 	 */
2292 2292
 	private function get_transaction_id() {
2293
-		return apply_filters( 'give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this );
2293
+		return apply_filters('give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this);
2294 2294
 	}
2295 2295
 
2296 2296
 	/**
@@ -2302,7 +2302,7 @@  discard block
 block discarded – undo
2302 2302
 	 * @return string Payment IP address
2303 2303
 	 */
2304 2304
 	private function get_ip() {
2305
-		return apply_filters( 'give_donation_user_ip', $this->ip, $this->ID, $this );
2305
+		return apply_filters('give_donation_user_ip', $this->ip, $this->ID, $this);
2306 2306
 	}
2307 2307
 
2308 2308
 	/**
@@ -2314,7 +2314,7 @@  discard block
 block discarded – undo
2314 2314
 	 * @return int Payment customer ID
2315 2315
 	 */
2316 2316
 	private function get_customer_id() {
2317
-		return apply_filters( 'give_donation_customer_id', $this->customer_id, $this->ID, $this );
2317
+		return apply_filters('give_donation_customer_id', $this->customer_id, $this->ID, $this);
2318 2318
 	}
2319 2319
 
2320 2320
 	/**
@@ -2326,7 +2326,7 @@  discard block
 block discarded – undo
2326 2326
 	 * @return int Payment user ID
2327 2327
 	 */
2328 2328
 	private function get_user_id() {
2329
-		return apply_filters( 'give_donation_user_id', $this->user_id, $this->ID, $this );
2329
+		return apply_filters('give_donation_user_id', $this->user_id, $this->ID, $this);
2330 2330
 	}
2331 2331
 
2332 2332
 	/**
@@ -2338,7 +2338,7 @@  discard block
 block discarded – undo
2338 2338
 	 * @return string Payment customer email
2339 2339
 	 */
2340 2340
 	private function get_email() {
2341
-		return apply_filters( 'give_donation_user_email', $this->email, $this->ID, $this );
2341
+		return apply_filters('give_donation_user_email', $this->email, $this->ID, $this);
2342 2342
 	}
2343 2343
 
2344 2344
 	/**
@@ -2350,7 +2350,7 @@  discard block
 block discarded – undo
2350 2350
 	 * @return array Payment user info
2351 2351
 	 */
2352 2352
 	private function get_user_info() {
2353
-		return apply_filters( 'give_donation_meta_user_info', $this->user_info, $this->ID, $this );
2353
+		return apply_filters('give_donation_meta_user_info', $this->user_info, $this->ID, $this);
2354 2354
 	}
2355 2355
 
2356 2356
 	/**
@@ -2362,7 +2362,7 @@  discard block
 block discarded – undo
2362 2362
 	 * @return array Payment billing address
2363 2363
 	 */
2364 2364
 	private function get_address() {
2365
-		return apply_filters( 'give_donation_address', $this->address, $this->ID, $this );
2365
+		return apply_filters('give_donation_address', $this->address, $this->ID, $this);
2366 2366
 	}
2367 2367
 
2368 2368
 	/**
@@ -2374,7 +2374,7 @@  discard block
 block discarded – undo
2374 2374
 	 * @return string Payment key
2375 2375
 	 */
2376 2376
 	private function get_key() {
2377
-		return apply_filters( 'give_donation_key', $this->key, $this->ID, $this );
2377
+		return apply_filters('give_donation_key', $this->key, $this->ID, $this);
2378 2378
 	}
2379 2379
 
2380 2380
 	/**
@@ -2386,7 +2386,7 @@  discard block
 block discarded – undo
2386 2386
 	 * @return string Payment form id
2387 2387
 	 */
2388 2388
 	private function get_form_id() {
2389
-		return apply_filters( 'give_donation_form_id', $this->form_id, $this->ID, $this );
2389
+		return apply_filters('give_donation_form_id', $this->form_id, $this->ID, $this);
2390 2390
 	}
2391 2391
 
2392 2392
 	/**
@@ -2398,7 +2398,7 @@  discard block
 block discarded – undo
2398 2398
 	 * @return int|string Payment number
2399 2399
 	 */
2400 2400
 	private function get_number() {
2401
-		return apply_filters( 'give_donation_number', $this->number, $this->ID, $this );
2401
+		return apply_filters('give_donation_number', $this->number, $this->ID, $this);
2402 2402
 	}
2403 2403
 
2404 2404
 }
Please login to merge, or discard this patch.