Completed
Pull Request — master (#1832)
by Devin
04:50
created
give.php 1 patch
Spacing   +146 added lines, -146 removed lines patch added patch discarded remove patch
@@ -40,11 +40,11 @@  discard block
 block discarded – undo
40 40
  */
41 41
 
42 42
 // Exit if accessed directly.
43
-if ( ! defined( 'ABSPATH' ) ) {
43
+if ( ! defined('ABSPATH')) {
44 44
 	exit;
45 45
 }
46 46
 
47
-if ( ! class_exists( 'Give' ) ) :
47
+if ( ! class_exists('Give')) :
48 48
 
49 49
 	/**
50 50
 	 * Main Give Class
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 		 * @return    Give
203 203
 		 */
204 204
 		public static function instance() {
205
-			if ( is_null( self::$_instance ) ) {
205
+			if (is_null(self::$_instance)) {
206 206
 				self::$_instance = new self();
207 207
 			}
208 208
 
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 			$this->includes();
218 218
 			$this->init_hooks();
219 219
 
220
-			do_action( 'give_loaded' );
220
+			do_action('give_loaded');
221 221
 		}
222 222
 
223 223
 		/**
@@ -226,8 +226,8 @@  discard block
 block discarded – undo
226 226
 		 * @since  1.8.9
227 227
 		 */
228 228
 		private function init_hooks() {
229
-			register_activation_hook( __FILE__, 'give_install' );
230
-			add_action( 'plugins_loaded', array( $this, 'init' ), 0 );
229
+			register_activation_hook(__FILE__, 'give_install');
230
+			add_action('plugins_loaded', array($this, 'init'), 0);
231 231
 		}
232 232
 		/**
233 233
 		 * Init Give when WordPress Initializes.
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 			 *
242 242
 			 * @since 1.8.9
243 243
 			 */
244
-			do_action( 'before_give_init' );
244
+			do_action('before_give_init');
245 245
 
246 246
 			// Set up localization.
247 247
 			$this->load_textdomain();
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 			 *
267 267
 			 * @since 1.8.7
268 268
 			 */
269
-			do_action( 'give_init', $this );
269
+			do_action('give_init', $this);
270 270
 
271 271
 		}
272 272
 
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 		 */
284 284
 		public function __clone() {
285 285
 			// Cloning instances of the class is forbidden.
286
-			_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'give' ), '1.0' );
286
+			_doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'give'), '1.0');
287 287
 		}
288 288
 
289 289
 		/**
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 		 */
297 297
 		public function __wakeup() {
298 298
 			// Unserializing instances of the class is forbidden.
299
-			_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'give' ), '1.0' );
299
+			_doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'give'), '1.0');
300 300
 		}
301 301
 
302 302
 		/**
@@ -310,38 +310,38 @@  discard block
 block discarded – undo
310 310
 		private function setup_constants() {
311 311
 
312 312
 			// Plugin version
313
-			if ( ! defined( 'GIVE_VERSION' ) ) {
314
-				define( 'GIVE_VERSION', '1.8.9' );
313
+			if ( ! defined('GIVE_VERSION')) {
314
+				define('GIVE_VERSION', '1.8.9');
315 315
 			}
316 316
 
317 317
 			// Plugin Folder Path
318
-			if ( ! defined( 'GIVE_PLUGIN_DIR' ) ) {
319
-				define( 'GIVE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
318
+			if ( ! defined('GIVE_PLUGIN_DIR')) {
319
+				define('GIVE_PLUGIN_DIR', plugin_dir_path(__FILE__));
320 320
 			}
321 321
 
322 322
 			// Plugin Folder URL
323
-			if ( ! defined( 'GIVE_PLUGIN_URL' ) ) {
324
-				define( 'GIVE_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
323
+			if ( ! defined('GIVE_PLUGIN_URL')) {
324
+				define('GIVE_PLUGIN_URL', plugin_dir_url(__FILE__));
325 325
 			}
326 326
 
327 327
 			// Plugin Basename aka: "give/give.php"
328
-			if ( ! defined( 'GIVE_PLUGIN_BASENAME' ) ) {
329
-				define( 'GIVE_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
328
+			if ( ! defined('GIVE_PLUGIN_BASENAME')) {
329
+				define('GIVE_PLUGIN_BASENAME', plugin_basename(__FILE__));
330 330
 			}
331 331
 
332 332
 			// Plugin Root File
333
-			if ( ! defined( 'GIVE_PLUGIN_FILE' ) ) {
334
-				define( 'GIVE_PLUGIN_FILE', __FILE__ );
333
+			if ( ! defined('GIVE_PLUGIN_FILE')) {
334
+				define('GIVE_PLUGIN_FILE', __FILE__);
335 335
 			}
336 336
 
337 337
 			// Make sure CAL_GREGORIAN is defined
338
-			if ( ! defined( 'CAL_GREGORIAN' ) ) {
339
-				define( 'CAL_GREGORIAN', 1 );
338
+			if ( ! defined('CAL_GREGORIAN')) {
339
+				define('CAL_GREGORIAN', 1);
340 340
 			}
341 341
 
342 342
 			// PHP version
343
-			if ( ! defined( 'GIVE_REQUIRED_PHP_VERSION' ) ) {
344
-				define( 'GIVE_REQUIRED_PHP_VERSION', '5.3' );
343
+			if ( ! defined('GIVE_REQUIRED_PHP_VERSION')) {
344
+				define('GIVE_REQUIRED_PHP_VERSION', '5.3');
345 345
 			}
346 346
 		}
347 347
 
@@ -356,128 +356,128 @@  discard block
 block discarded – undo
356 356
 		private function includes() {
357 357
 			global $give_options;
358 358
 
359
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/class-admin-settings.php';
360
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/class-give-settings.php';
359
+			require_once GIVE_PLUGIN_DIR.'includes/admin/class-admin-settings.php';
360
+			require_once GIVE_PLUGIN_DIR.'includes/admin/class-give-settings.php';
361 361
 			$give_options = give_get_settings();
362 362
 
363
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/give-metabox-functions.php';
364
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-cache.php';
365
-			require_once GIVE_PLUGIN_DIR . 'includes/post-types.php';
366
-			require_once GIVE_PLUGIN_DIR . 'includes/scripts.php';
367
-			require_once GIVE_PLUGIN_DIR . 'includes/ajax-functions.php';
368
-			require_once GIVE_PLUGIN_DIR . 'includes/actions.php';
369
-			require_once GIVE_PLUGIN_DIR . 'includes/filters.php';
370
-			require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api.php';
371
-			require_once GIVE_PLUGIN_DIR . 'includes/class-notices.php';
372
-
373
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-roles.php';
374
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-template-loader.php';
375
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-donate-form.php';
376
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-db.php';
377
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-donors.php';
378
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-donor-meta.php';
379
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-donor.php';
380
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-stats.php';
381
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-session.php';
382
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-html-elements.php';
383
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-logging.php';
384
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-license-handler.php';
385
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-cron.php';
386
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-email-access.php';
387
-
388
-			require_once GIVE_PLUGIN_DIR . 'includes/country-functions.php';
389
-			require_once GIVE_PLUGIN_DIR . 'includes/template-functions.php';
390
-			require_once GIVE_PLUGIN_DIR . 'includes/misc-functions.php';
391
-			require_once GIVE_PLUGIN_DIR . 'includes/forms/functions.php';
392
-			require_once GIVE_PLUGIN_DIR . 'includes/forms/template.php';
393
-			require_once GIVE_PLUGIN_DIR . 'includes/forms/widget.php';
394
-			require_once GIVE_PLUGIN_DIR . 'includes/shortcodes.php';
395
-			require_once GIVE_PLUGIN_DIR . 'includes/formatting.php';
396
-			require_once GIVE_PLUGIN_DIR . 'includes/price-functions.php';
397
-			require_once GIVE_PLUGIN_DIR . 'includes/error-tracking.php';
398
-			require_once GIVE_PLUGIN_DIR . 'includes/process-donation.php';
399
-			require_once GIVE_PLUGIN_DIR . 'includes/login-register.php';
400
-			require_once GIVE_PLUGIN_DIR . 'includes/user-functions.php';
401
-			require_once GIVE_PLUGIN_DIR . 'includes/plugin-compatibility.php';
402
-			require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-classes.php';
403
-			require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-functions.php';
404
-			require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-actions.php';
405
-			require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-filters.php';
406
-
407
-			require_once GIVE_PLUGIN_DIR . 'includes/payments/functions.php';
408
-			require_once GIVE_PLUGIN_DIR . 'includes/payments/actions.php';
409
-			require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payment-stats.php';
410
-			require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payments-query.php';
411
-			require_once GIVE_PLUGIN_DIR . 'includes/payments/class-give-payment.php';
412
-
413
-			require_once GIVE_PLUGIN_DIR . 'includes/gateways/functions.php';
414
-			require_once GIVE_PLUGIN_DIR . 'includes/gateways/actions.php';
415
-			require_once GIVE_PLUGIN_DIR . 'includes/gateways/paypal-standard.php';
416
-			require_once GIVE_PLUGIN_DIR . 'includes/gateways/offline-donations.php';
417
-			require_once GIVE_PLUGIN_DIR . 'includes/gateways/manual.php';
418
-
419
-			require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-emails.php';
420
-			require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-email-tags.php';
421
-			require_once GIVE_PLUGIN_DIR . 'includes/emails/functions.php';
422
-			require_once GIVE_PLUGIN_DIR . 'includes/emails/template.php';
423
-			require_once GIVE_PLUGIN_DIR . 'includes/emails/actions.php';
424
-
425
-			if ( defined( 'WP_CLI' ) && WP_CLI ) {
426
-				require_once GIVE_PLUGIN_DIR . 'includes/class-give-cli-commands.php';
363
+			require_once GIVE_PLUGIN_DIR.'includes/admin/give-metabox-functions.php';
364
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-cache.php';
365
+			require_once GIVE_PLUGIN_DIR.'includes/post-types.php';
366
+			require_once GIVE_PLUGIN_DIR.'includes/scripts.php';
367
+			require_once GIVE_PLUGIN_DIR.'includes/ajax-functions.php';
368
+			require_once GIVE_PLUGIN_DIR.'includes/actions.php';
369
+			require_once GIVE_PLUGIN_DIR.'includes/filters.php';
370
+			require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api.php';
371
+			require_once GIVE_PLUGIN_DIR.'includes/class-notices.php';
372
+
373
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-roles.php';
374
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-template-loader.php';
375
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-donate-form.php';
376
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-db.php';
377
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-db-donors.php';
378
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-db-donor-meta.php';
379
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-donor.php';
380
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-stats.php';
381
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-session.php';
382
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-html-elements.php';
383
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-logging.php';
384
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-license-handler.php';
385
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-cron.php';
386
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-email-access.php';
387
+
388
+			require_once GIVE_PLUGIN_DIR.'includes/country-functions.php';
389
+			require_once GIVE_PLUGIN_DIR.'includes/template-functions.php';
390
+			require_once GIVE_PLUGIN_DIR.'includes/misc-functions.php';
391
+			require_once GIVE_PLUGIN_DIR.'includes/forms/functions.php';
392
+			require_once GIVE_PLUGIN_DIR.'includes/forms/template.php';
393
+			require_once GIVE_PLUGIN_DIR.'includes/forms/widget.php';
394
+			require_once GIVE_PLUGIN_DIR.'includes/shortcodes.php';
395
+			require_once GIVE_PLUGIN_DIR.'includes/formatting.php';
396
+			require_once GIVE_PLUGIN_DIR.'includes/price-functions.php';
397
+			require_once GIVE_PLUGIN_DIR.'includes/error-tracking.php';
398
+			require_once GIVE_PLUGIN_DIR.'includes/process-donation.php';
399
+			require_once GIVE_PLUGIN_DIR.'includes/login-register.php';
400
+			require_once GIVE_PLUGIN_DIR.'includes/user-functions.php';
401
+			require_once GIVE_PLUGIN_DIR.'includes/plugin-compatibility.php';
402
+			require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-classes.php';
403
+			require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-functions.php';
404
+			require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-actions.php';
405
+			require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-filters.php';
406
+
407
+			require_once GIVE_PLUGIN_DIR.'includes/payments/functions.php';
408
+			require_once GIVE_PLUGIN_DIR.'includes/payments/actions.php';
409
+			require_once GIVE_PLUGIN_DIR.'includes/payments/class-payment-stats.php';
410
+			require_once GIVE_PLUGIN_DIR.'includes/payments/class-payments-query.php';
411
+			require_once GIVE_PLUGIN_DIR.'includes/payments/class-give-payment.php';
412
+
413
+			require_once GIVE_PLUGIN_DIR.'includes/gateways/functions.php';
414
+			require_once GIVE_PLUGIN_DIR.'includes/gateways/actions.php';
415
+			require_once GIVE_PLUGIN_DIR.'includes/gateways/paypal-standard.php';
416
+			require_once GIVE_PLUGIN_DIR.'includes/gateways/offline-donations.php';
417
+			require_once GIVE_PLUGIN_DIR.'includes/gateways/manual.php';
418
+
419
+			require_once GIVE_PLUGIN_DIR.'includes/emails/class-give-emails.php';
420
+			require_once GIVE_PLUGIN_DIR.'includes/emails/class-give-email-tags.php';
421
+			require_once GIVE_PLUGIN_DIR.'includes/emails/functions.php';
422
+			require_once GIVE_PLUGIN_DIR.'includes/emails/template.php';
423
+			require_once GIVE_PLUGIN_DIR.'includes/emails/actions.php';
424
+
425
+			if (defined('WP_CLI') && WP_CLI) {
426
+				require_once GIVE_PLUGIN_DIR.'includes/class-give-cli-commands.php';
427 427
 			}
428 428
 
429
-			if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
430
-
431
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-footer.php';
432
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/welcome.php';
433
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-pages.php';
434
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/class-api-keys-table.php';
435
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/class-i18n-module.php';
436
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-actions.php';
437
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-filters.php';
438
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/system-info.php';
439
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/add-ons.php';
440
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/plugins.php';
441
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/dashboard-widgets.php';
442
-
443
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/actions.php';
444
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/payments-history.php';
445
-
446
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/donors/donors.php';
447
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/donors/donor-functions.php';
448
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/donors/donor-actions.php';
449
-
450
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/metabox.php';
451
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/class-metabox-form-data.php';
452
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/dashboard-columns.php';
453
-
454
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/export-functions.php';
455
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/class-export.php';
456
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/export-actions.php';
457
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/pdf-reports.php';
458
-
459
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/reports.php';
460
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-give-graph.php';
461
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/graphing.php';
462
-
463
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/tools-actions.php';
464
-
465
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/abstract-shortcode-generator.php';
466
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/class-shortcode-button.php';
467
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-form.php';
468
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-goal.php';
469
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-login.php';
470
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-register.php';
471
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-profile-editor.php';
472
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-donation-history.php';
473
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-receipt.php';
474
-
475
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php';
476
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrades.php';
429
+			if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
430
+
431
+				require_once GIVE_PLUGIN_DIR.'includes/admin/admin-footer.php';
432
+				require_once GIVE_PLUGIN_DIR.'includes/admin/welcome.php';
433
+				require_once GIVE_PLUGIN_DIR.'includes/admin/admin-pages.php';
434
+				require_once GIVE_PLUGIN_DIR.'includes/admin/class-api-keys-table.php';
435
+				require_once GIVE_PLUGIN_DIR.'includes/admin/class-i18n-module.php';
436
+				require_once GIVE_PLUGIN_DIR.'includes/admin/admin-actions.php';
437
+				require_once GIVE_PLUGIN_DIR.'includes/admin/admin-filters.php';
438
+				require_once GIVE_PLUGIN_DIR.'includes/admin/system-info.php';
439
+				require_once GIVE_PLUGIN_DIR.'includes/admin/add-ons.php';
440
+				require_once GIVE_PLUGIN_DIR.'includes/admin/plugins.php';
441
+				require_once GIVE_PLUGIN_DIR.'includes/admin/dashboard-widgets.php';
442
+
443
+				require_once GIVE_PLUGIN_DIR.'includes/admin/payments/actions.php';
444
+				require_once GIVE_PLUGIN_DIR.'includes/admin/payments/payments-history.php';
445
+
446
+				require_once GIVE_PLUGIN_DIR.'includes/admin/donors/donors.php';
447
+				require_once GIVE_PLUGIN_DIR.'includes/admin/donors/donor-functions.php';
448
+				require_once GIVE_PLUGIN_DIR.'includes/admin/donors/donor-actions.php';
449
+
450
+				require_once GIVE_PLUGIN_DIR.'includes/admin/forms/metabox.php';
451
+				require_once GIVE_PLUGIN_DIR.'includes/admin/forms/class-metabox-form-data.php';
452
+				require_once GIVE_PLUGIN_DIR.'includes/admin/forms/dashboard-columns.php';
453
+
454
+				require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/export-functions.php';
455
+				require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/class-export.php';
456
+				require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/export-actions.php';
457
+				require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/pdf-reports.php';
458
+
459
+				require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/reports.php';
460
+				require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-give-graph.php';
461
+				require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/graphing.php';
462
+
463
+				require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/tools-actions.php';
464
+
465
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/abstract-shortcode-generator.php';
466
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/class-shortcode-button.php';
467
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-form.php';
468
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-goal.php';
469
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-login.php';
470
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-register.php';
471
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-profile-editor.php';
472
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-donation-history.php';
473
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-receipt.php';
474
+
475
+				require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php';
476
+				require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrades.php';
477 477
 
478 478
 			}// End if().
479 479
 
480
-			require_once GIVE_PLUGIN_DIR . 'includes/install.php';
480
+			require_once GIVE_PLUGIN_DIR.'includes/install.php';
481 481
 
482 482
 		}
483 483
 
@@ -492,16 +492,16 @@  discard block
 block discarded – undo
492 492
 		public function load_textdomain() {
493 493
 
494 494
 			// Set filter for Give's languages directory
495
-			$give_lang_dir = dirname( plugin_basename( GIVE_PLUGIN_FILE ) ) . '/languages/';
496
-			$give_lang_dir = apply_filters( 'give_languages_directory', $give_lang_dir );
495
+			$give_lang_dir = dirname(plugin_basename(GIVE_PLUGIN_FILE)).'/languages/';
496
+			$give_lang_dir = apply_filters('give_languages_directory', $give_lang_dir);
497 497
 
498 498
 			// Traditional WordPress plugin locale filter.
499
-			$locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
500
-			$locale = apply_filters( 'plugin_locale', $locale, 'give' );
499
+			$locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale();
500
+			$locale = apply_filters('plugin_locale', $locale, 'give');
501 501
 
502
-			unload_textdomain( 'give' );
503
-			load_textdomain( 'give', WP_LANG_DIR . '/give/give-' . $locale . '.mo' );
504
-			load_plugin_textdomain( 'give', false, $give_lang_dir );
502
+			unload_textdomain('give');
503
+			load_textdomain('give', WP_LANG_DIR.'/give/give-'.$locale.'.mo');
504
+			load_plugin_textdomain('give', false, $give_lang_dir);
505 505
 
506 506
 		}
507 507
 
Please login to merge, or discard this patch.
includes/actions.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -25,14 +25,14 @@  discard block
 block discarded – undo
25 25
  */
26 26
 function give_get_actions() {
27 27
 
28
-	$_get_action = ! empty( $_GET['give_action'] ) ? $_GET['give_action'] : null;
28
+	$_get_action = ! empty($_GET['give_action']) ? $_GET['give_action'] : null;
29 29
 
30 30
 	// Add backward compatibility to give-action param ( $_GET )
31
-	if(  empty( $_get_action ) ) {
32
-		$_get_action = ! empty( $_GET['give-action'] ) ? $_GET['give-action'] : null;
31
+	if (empty($_get_action)) {
32
+		$_get_action = ! empty($_GET['give-action']) ? $_GET['give-action'] : null;
33 33
 	}
34 34
 
35
-	if ( isset( $_get_action ) ) {
35
+	if (isset($_get_action)) {
36 36
 		/**
37 37
 		 * Fires in WordPress init or admin init, when give_action is present in $_GET.
38 38
 		 *
@@ -40,12 +40,12 @@  discard block
 block discarded – undo
40 40
 		 *
41 41
 		 * @param array $_GET Array of HTTP GET variables.
42 42
 		 */
43
-		do_action( "give_{$_get_action}", $_GET );
43
+		do_action("give_{$_get_action}", $_GET);
44 44
 	}
45 45
 
46 46
 }
47 47
 
48
-add_action( 'init', 'give_get_actions' );
48
+add_action('init', 'give_get_actions');
49 49
 
50 50
 /**
51 51
  * Hooks Give actions, when present in the $_POST super global. Every give_action
@@ -58,15 +58,15 @@  discard block
 block discarded – undo
58 58
  */
59 59
 function give_post_actions() {
60 60
 
61
-	$_post_action = ! empty( $_POST['give_action'] ) ? $_POST['give_action'] : null;
61
+	$_post_action = ! empty($_POST['give_action']) ? $_POST['give_action'] : null;
62 62
 
63 63
 
64 64
 	// Add backward compatibility to give-action param ( $_POST ).
65
-	if(  empty( $_post_action ) ) {
66
-		$_post_action = ! empty( $_POST['give-action'] ) ? $_POST['give-action'] : null;
65
+	if (empty($_post_action)) {
66
+		$_post_action = ! empty($_POST['give-action']) ? $_POST['give-action'] : null;
67 67
 	}
68 68
 
69
-	if ( isset( $_post_action ) ) {
69
+	if (isset($_post_action)) {
70 70
 		/**
71 71
 		 * Fires in WordPress init or admin init, when give_action is present in $_POST.
72 72
 		 *
@@ -74,12 +74,12 @@  discard block
 block discarded – undo
74 74
 		 *
75 75
 		 * @param array $_POST Array of HTTP POST variables.
76 76
 		 */
77
-		do_action( "give_{$_post_action}", $_POST );
77
+		do_action("give_{$_post_action}", $_POST);
78 78
 	}
79 79
 
80 80
 }
81 81
 
82
-add_action( 'init', 'give_post_actions' );
82
+add_action('init', 'give_post_actions');
83 83
 
84 84
 /**
85 85
  * Connect WordPress user with Donor.
@@ -89,28 +89,28 @@  discard block
 block discarded – undo
89 89
  * @param  array $user_data User Data
90 90
  * @return void
91 91
  */
92
-function give_connect_donor_to_wpuser( $user_id, $user_data ){
92
+function give_connect_donor_to_wpuser($user_id, $user_data) {
93 93
 	/* @var Give_Donor $donor */
94
-	$donor = new Give_Donor( $user_data['user_email'] );
94
+	$donor = new Give_Donor($user_data['user_email']);
95 95
 
96 96
 	// Validate donor id and check if do nor is already connect to wp user or not.
97
-	if( $donor->id && ! $donor->user_id ) {
97
+	if ($donor->id && ! $donor->user_id) {
98 98
 
99 99
 		// Update donor user_id.
100
-		if( $donor->update( array( 'user_id' => $user_id ) ) ) {
101
-			$donor_note = sprintf( esc_html__( 'WordPress user #%d is connected to #%d', 'give' ), $user_id, $donor->id );
102
-			$donor->add_note( $donor_note );
100
+		if ($donor->update(array('user_id' => $user_id))) {
101
+			$donor_note = sprintf(esc_html__('WordPress user #%d is connected to #%d', 'give'), $user_id, $donor->id);
102
+			$donor->add_note($donor_note);
103 103
 
104 104
 			// Update user_id meta in payments.
105
-			if( ! empty( $donor->payment_ids ) && ( $donations = explode( ',', $donor->payment_ids ) ) ) {
106
-				foreach ( $donations as $donation  ) {
107
-					give_update_meta( $donation, '_give_payment_user_id', $user_id );
105
+			if ( ! empty($donor->payment_ids) && ($donations = explode(',', $donor->payment_ids))) {
106
+				foreach ($donations as $donation) {
107
+					give_update_meta($donation, '_give_payment_user_id', $user_id);
108 108
 				}
109 109
 			}
110 110
 		}
111 111
 	}
112 112
 }
113
-add_action( 'give_insert_user', 'give_connect_donor_to_wpuser', 10, 2 );
113
+add_action('give_insert_user', 'give_connect_donor_to_wpuser', 10, 2);
114 114
 
115 115
 
116 116
 /**
@@ -124,24 +124,24 @@  discard block
 block discarded – undo
124 124
 function give_validate_license_when_site_migrated() {
125 125
 	// Store current site address if not already stored.
126 126
 	$homeurl = home_url();
127
-	if( ! get_option( 'give_site_address_before_migrate' ) ) {
127
+	if ( ! get_option('give_site_address_before_migrate')) {
128 128
 		// Update site address.
129
-		update_option( 'give_site_address_before_migrate', $homeurl );
129
+		update_option('give_site_address_before_migrate', $homeurl);
130 130
 
131 131
 		return;
132 132
 	}
133 133
 
134
-	if( $homeurl !== get_option( 'give_site_address_before_migrate' ) ) {
134
+	if ($homeurl !== get_option('give_site_address_before_migrate')) {
135 135
 		// Immediately run cron.
136
-		wp_schedule_single_event( time() , 'give_validate_license_when_site_migrated' );
136
+		wp_schedule_single_event(time(), 'give_validate_license_when_site_migrated');
137 137
 
138 138
 		// Update site address.
139
-		update_option( 'give_site_address_before_migrate', home_url() );
139
+		update_option('give_site_address_before_migrate', home_url());
140 140
 	}
141 141
 
142 142
 }
143
-add_action( 'init', 'give_validate_license_when_site_migrated' );
144
-add_action( 'admin_init', 'give_validate_license_when_site_migrated' );
143
+add_action('init', 'give_validate_license_when_site_migrated');
144
+add_action('admin_init', 'give_validate_license_when_site_migrated');
145 145
 
146 146
 
147 147
 /**
@@ -150,18 +150,18 @@  discard block
 block discarded – undo
150 150
  * @since 1.8
151 151
  * @param $data
152 152
  */
153
-function give_donor_batch_export_complete( $data ) {
153
+function give_donor_batch_export_complete($data) {
154 154
 	// Remove donor ids cache.
155
-	if(
156
-		isset( $data['class'] )
155
+	if (
156
+		isset($data['class'])
157 157
 		&& 'Give_Batch_Donors_Export' === $data['class']
158
-		&& ! empty( $data['forms'] )
159
-		&& isset( $data['give_export_option']['query_id'] )
158
+		&& ! empty($data['forms'])
159
+		&& isset($data['give_export_option']['query_id'])
160 160
 	) {
161
-		Give_Cache::delete( Give_Cache::get_key( $data['give_export_option']['query_id'] ) );
161
+		Give_Cache::delete(Give_Cache::get_key($data['give_export_option']['query_id']));
162 162
 	}
163 163
 }
164
-add_action('give_file_export_complete', 'give_donor_batch_export_complete' );
164
+add_action('give_file_export_complete', 'give_donor_batch_export_complete');
165 165
 
166 166
 /**
167 167
  * Print css for wordpress setting pages.
@@ -172,12 +172,12 @@  discard block
 block discarded – undo
172 172
 	/* @var WP_Screen $screen */
173 173
 	$screen = get_current_screen();
174 174
 
175
-	if( ! ( $screen instanceof WP_Screen ) ) {
175
+	if ( ! ($screen instanceof WP_Screen)) {
176 176
 		return false;
177 177
 	}
178 178
 
179
-	switch ( true ) {
180
-		case ( 'plugins' === $screen->base ):
179
+	switch (true) {
180
+		case ('plugins' === $screen->base):
181 181
 			?>
182 182
 			<style>
183 183
 				tr.active.update + tr.give-addon-notice-tr td{
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 			<?php
211 211
 	}
212 212
 }
213
-add_action( 'admin_head', 'give_admin_quick_css' );
213
+add_action('admin_head', 'give_admin_quick_css');
214 214
 
215 215
 
216 216
 /**
@@ -223,25 +223,25 @@  discard block
 block discarded – undo
223 223
  *
224 224
  * @return void
225 225
  */
226
-function give_set_donation_levels_max_min_amount( $form_id ) {
226
+function give_set_donation_levels_max_min_amount($form_id) {
227 227
 	if (
228
-		( 'set' === $_POST['_give_price_option'] ) ||
229
-		( in_array( '_give_donation_levels', $_POST ) && count( $_POST['_give_donation_levels'] ) <= 0 ) ||
230
-		! ( $donation_levels_amounts = wp_list_pluck( $_POST['_give_donation_levels'], '_give_amount' ) )
228
+		('set' === $_POST['_give_price_option']) ||
229
+		(in_array('_give_donation_levels', $_POST) && count($_POST['_give_donation_levels']) <= 0) ||
230
+		! ($donation_levels_amounts = wp_list_pluck($_POST['_give_donation_levels'], '_give_amount'))
231 231
 	) {
232 232
 		// Delete old meta.
233
-		give_delete_meta( $form_id, '_give_levels_minimum_amount' );
234
-		give_delete_meta( $form_id, '_give_levels_maximum_amount' );
233
+		give_delete_meta($form_id, '_give_levels_minimum_amount');
234
+		give_delete_meta($form_id, '_give_levels_maximum_amount');
235 235
 
236 236
 		return;
237 237
 	}
238 238
 
239
-	$min_amount = min( $donation_levels_amounts );
240
-	$max_amount = max( $donation_levels_amounts );
239
+	$min_amount = min($donation_levels_amounts);
240
+	$max_amount = max($donation_levels_amounts);
241 241
 
242 242
 	// Set Minimum and Maximum amount for Multi Level Donation Forms
243
-	give_update_meta( $form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount( $min_amount ) : 0 );
244
-	give_update_meta( $form_id, '_give_levels_maximum_amount', $max_amount? give_sanitize_amount( $max_amount ) : 0 );
243
+	give_update_meta($form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount($min_amount) : 0);
244
+	give_update_meta($form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount($max_amount) : 0);
245 245
 }
246 246
 
247
-add_action( 'give_pre_process_give_forms_meta', 'give_set_donation_levels_max_min_amount', 30 );
248 247
\ No newline at end of file
248
+add_action('give_pre_process_give_forms_meta', 'give_set_donation_levels_max_min_amount', 30);
249 249
\ No newline at end of file
Please login to merge, or discard this patch.
includes/api/class-give-api.php 1 patch
Spacing   +512 added lines, -512 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
 
@@ -141,27 +141,27 @@  discard block
 block discarded – undo
141 141
 			'v1' => 'GIVE_API_V1',
142 142
 		);
143 143
 
144
-		foreach ( $this->get_versions() as $version => $class ) {
145
-			require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api-' . $version . '.php';
144
+		foreach ($this->get_versions() as $version => $class) {
145
+			require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api-'.$version.'.php';
146 146
 		}
147 147
 
148
-		add_action( 'init', array( $this, 'add_endpoint' ) );
149
-		add_action( 'wp', array( $this, 'process_query' ), - 1 );
150
-		add_filter( 'query_vars', array( $this, 'query_vars' ) );
151
-		add_action( 'show_user_profile', array( $this, 'user_key_field' ) );
152
-		add_action( 'edit_user_profile', array( $this, 'user_key_field' ) );
153
-		add_action( 'personal_options_update', array( $this, 'update_key' ) );
154
-		add_action( 'edit_user_profile_update', array( $this, 'update_key' ) );
155
-		add_action( 'give_process_api_key', array( $this, 'process_api_key' ) );
148
+		add_action('init', array($this, 'add_endpoint'));
149
+		add_action('wp', array($this, 'process_query'), - 1);
150
+		add_filter('query_vars', array($this, 'query_vars'));
151
+		add_action('show_user_profile', array($this, 'user_key_field'));
152
+		add_action('edit_user_profile', array($this, 'user_key_field'));
153
+		add_action('personal_options_update', array($this, 'update_key'));
154
+		add_action('edit_user_profile_update', array($this, 'update_key'));
155
+		add_action('give_process_api_key', array($this, 'process_api_key'));
156 156
 
157 157
 		// Setup a backwards compatibility check for user API Keys
158
-		add_filter( 'get_user_metadata', array( $this, 'api_key_backwards_compat' ), 10, 4 );
158
+		add_filter('get_user_metadata', array($this, 'api_key_backwards_compat'), 10, 4);
159 159
 
160 160
 		// Determine if JSON_PRETTY_PRINT is available
161
-		$this->pretty_print = defined( 'JSON_PRETTY_PRINT' ) ? JSON_PRETTY_PRINT : null;
161
+		$this->pretty_print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : null;
162 162
 
163 163
 		// Allow API request logging to be turned off
164
-		$this->log_requests = apply_filters( 'give_api_log_requests', $this->log_requests );
164
+		$this->log_requests = apply_filters('give_api_log_requests', $this->log_requests);
165 165
 
166 166
 		// Setup Give_Payment_Stats instance
167 167
 		$this->stats = new Give_Payment_Stats();
@@ -177,8 +177,8 @@  discard block
 block discarded – undo
177 177
 	 *
178 178
 	 * @since  1.1
179 179
 	 */
180
-	public function add_endpoint( $rewrite_rules ) {
181
-		add_rewrite_endpoint( 'give-api', EP_ALL );
180
+	public function add_endpoint($rewrite_rules) {
181
+		add_rewrite_endpoint('give-api', EP_ALL);
182 182
 	}
183 183
 
184 184
 	/**
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 	 *
192 192
 	 * @return string[] $vars New query vars
193 193
 	 */
194
-	public function query_vars( $vars ) {
194
+	public function query_vars($vars) {
195 195
 
196 196
 		$vars[] = 'token';
197 197
 		$vars[] = 'key';
@@ -242,11 +242,11 @@  discard block
 block discarded – undo
242 242
 	 */
243 243
 	public function get_default_version() {
244 244
 
245
-		$version = get_option( 'give_default_api_version' );
245
+		$version = get_option('give_default_api_version');
246 246
 
247
-		if ( defined( 'GIVE_API_VERSION' ) ) {
247
+		if (defined('GIVE_API_VERSION')) {
248 248
 			$version = GIVE_API_VERSION;
249
-		} elseif ( ! $version ) {
249
+		} elseif ( ! $version) {
250 250
 			$version = 'v1';
251 251
 		}
252 252
 
@@ -267,14 +267,14 @@  discard block
 block discarded – undo
267 267
 
268 268
 		$version = $wp_query->query_vars['give-api'];
269 269
 
270
-		if ( strpos( $version, '/' ) ) {
270
+		if (strpos($version, '/')) {
271 271
 
272
-			$version = explode( '/', $version );
273
-			$version = strtolower( $version[0] );
272
+			$version = explode('/', $version);
273
+			$version = strtolower($version[0]);
274 274
 
275
-			$wp_query->query_vars['give-api'] = str_replace( $version . '/', '', $wp_query->query_vars['give-api'] );
275
+			$wp_query->query_vars['give-api'] = str_replace($version.'/', '', $wp_query->query_vars['give-api']);
276 276
 
277
-			if ( array_key_exists( $version, $this->versions ) ) {
277
+			if (array_key_exists($version, $this->versions)) {
278 278
 
279 279
 				$this->queried_version = $version;
280 280
 
@@ -310,26 +310,26 @@  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
 				return false;
318 318
 			}
319 319
 
320 320
 			// Retrieve the user by public API key and ensure they exist
321
-			if ( ! ( $user = $this->get_user( $wp_query->query_vars['key'] ) ) ) {
321
+			if ( ! ($user = $this->get_user($wp_query->query_vars['key']))) {
322 322
 
323 323
 				$this->invalid_key();
324 324
 				return false;
325 325
 
326 326
 			} else {
327 327
 
328
-				$token  = urldecode( $wp_query->query_vars['token'] );
329
-				$secret = $this->get_user_secret_key( $user );
330
-				$public = urldecode( $wp_query->query_vars['key'] );
328
+				$token  = urldecode($wp_query->query_vars['token']);
329
+				$secret = $this->get_user_secret_key($user);
330
+				$public = urldecode($wp_query->query_vars['key']);
331 331
 
332
-				if ( hash_equals( md5( $secret . $public ), $token ) ) {
332
+				if (hash_equals(md5($secret.$public), $token)) {
333 333
 					$this->is_valid_request = true;
334 334
 				} else {
335 335
 					$this->invalid_auth();
@@ -337,9 +337,9 @@  discard block
 block discarded – undo
337 337
 				}
338 338
 
339 339
 			}
340
-		} elseif ( ! empty( $wp_query->query_vars['give-api'] ) && $wp_query->query_vars['give-api'] === 'forms' ) {
340
+		} elseif ( ! empty($wp_query->query_vars['give-api']) && $wp_query->query_vars['give-api'] === 'forms') {
341 341
 			$this->is_valid_request = true;
342
-			$wp_query->set( 'key', 'public' );
342
+			$wp_query->set('key', 'public');
343 343
 		}
344 344
 	}
345 345
 
@@ -355,25 +355,25 @@  discard block
 block discarded – undo
355 355
 	 *
356 356
 	 * @return bool if user ID is found, false otherwise
357 357
 	 */
358
-	public function get_user( $key = '' ) {
358
+	public function get_user($key = '') {
359 359
 		global $wpdb, $wp_query;
360 360
 
361
-		if ( empty( $key ) ) {
362
-			$key = urldecode( $wp_query->query_vars['key'] );
361
+		if (empty($key)) {
362
+			$key = urldecode($wp_query->query_vars['key']);
363 363
 		}
364 364
 
365
-		if ( empty( $key ) ) {
365
+		if (empty($key)) {
366 366
 			return false;
367 367
 		}
368 368
 
369
-		$user = Give_Cache::get( md5( 'give_api_user_' . $key ), true );
369
+		$user = Give_Cache::get(md5('give_api_user_'.$key), true);
370 370
 
371
-		if ( false === $user ) {
372
-			$user = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key ) );
373
-			Give_Cache::set( md5( 'give_api_user_' . $key ), $user, DAY_IN_SECONDS, true );
371
+		if (false === $user) {
372
+			$user = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key));
373
+			Give_Cache::set(md5('give_api_user_'.$key), $user, DAY_IN_SECONDS, true);
374 374
 		}
375 375
 
376
-		if ( $user != null ) {
376
+		if ($user != null) {
377 377
 			$this->user_id = $user;
378 378
 
379 379
 			return $user;
@@ -389,19 +389,19 @@  discard block
 block discarded – undo
389 389
 	 *
390 390
 	 * @return mixed|null|string
391 391
 	 */
392
-	public function get_user_public_key( $user_id = 0 ) {
392
+	public function get_user_public_key($user_id = 0) {
393 393
 		global $wpdb;
394 394
 
395
-		if ( empty( $user_id ) ) {
395
+		if (empty($user_id)) {
396 396
 			return '';
397 397
 		}
398 398
 
399
-		$cache_key       = md5( 'give_api_user_public_key' . $user_id );
400
-		$user_public_key = Give_Cache::get( $cache_key, true );
399
+		$cache_key       = md5('give_api_user_public_key'.$user_id);
400
+		$user_public_key = Give_Cache::get($cache_key, true);
401 401
 
402
-		if ( empty( $user_public_key ) ) {
403
-			$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 ) );
404
-			Give_Cache::set( $cache_key, $user_public_key, HOUR_IN_SECONDS, true );
402
+		if (empty($user_public_key)) {
403
+			$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));
404
+			Give_Cache::set($cache_key, $user_public_key, HOUR_IN_SECONDS, true);
405 405
 		}
406 406
 
407 407
 		return $user_public_key;
@@ -414,19 +414,19 @@  discard block
 block discarded – undo
414 414
 	 *
415 415
 	 * @return mixed|null|string
416 416
 	 */
417
-	public function get_user_secret_key( $user_id = 0 ) {
417
+	public function get_user_secret_key($user_id = 0) {
418 418
 		global $wpdb;
419 419
 
420
-		if ( empty( $user_id ) ) {
420
+		if (empty($user_id)) {
421 421
 			return '';
422 422
 		}
423 423
 
424
-		$cache_key       = md5( 'give_api_user_secret_key' . $user_id );
425
-		$user_secret_key = Give_Cache::get( $cache_key, true );
424
+		$cache_key       = md5('give_api_user_secret_key'.$user_id);
425
+		$user_secret_key = Give_Cache::get($cache_key, true);
426 426
 
427
-		if ( empty( $user_secret_key ) ) {
428
-			$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 ) );
429
-			Give_Cache::set( $cache_key, $user_secret_key, HOUR_IN_SECONDS, true );
427
+		if (empty($user_secret_key)) {
428
+			$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));
429
+			Give_Cache::set($cache_key, $user_secret_key, HOUR_IN_SECONDS, true);
430 430
 		}
431 431
 
432 432
 		return $user_secret_key;
@@ -442,10 +442,10 @@  discard block
 block discarded – undo
442 442
 	 */
443 443
 	private function missing_auth() {
444 444
 		$error          = array();
445
-		$error['error'] = esc_html__( 'You must specify both a token and API key.', 'give' );
445
+		$error['error'] = esc_html__('You must specify both a token and API key.', 'give');
446 446
 
447 447
 		$this->data = $error;
448
-		$this->output( 401 );
448
+		$this->output(401);
449 449
 	}
450 450
 
451 451
 	/**
@@ -459,10 +459,10 @@  discard block
 block discarded – undo
459 459
 	 */
460 460
 	private function invalid_auth() {
461 461
 		$error          = array();
462
-		$error['error'] = esc_html__( 'Your request could not be authenticated.', 'give' );
462
+		$error['error'] = esc_html__('Your request could not be authenticated.', 'give');
463 463
 
464 464
 		$this->data = $error;
465
-		$this->output( 403 );
465
+		$this->output(403);
466 466
 	}
467 467
 
468 468
 	/**
@@ -476,10 +476,10 @@  discard block
 block discarded – undo
476 476
 	 */
477 477
 	private function invalid_key() {
478 478
 		$error          = array();
479
-		$error['error'] = esc_html__( 'Invalid API key.', 'give' );
479
+		$error['error'] = esc_html__('Invalid API key.', 'give');
480 480
 
481 481
 		$this->data = $error;
482
-		$this->output( 403 );
482
+		$this->output(403);
483 483
 	}
484 484
 
485 485
 	/**
@@ -492,10 +492,10 @@  discard block
 block discarded – undo
492 492
 	 */
493 493
 	private function invalid_version() {
494 494
 		$error          = array();
495
-		$error['error'] = esc_html__( 'Invalid API version.', 'give' );
495
+		$error['error'] = esc_html__('Invalid API version.', 'give');
496 496
 
497 497
 		$this->data = $error;
498
-		$this->output( 404 );
498
+		$this->output(404);
499 499
 	}
500 500
 
501 501
 	/**
@@ -511,10 +511,10 @@  discard block
 block discarded – undo
511 511
 		global $wp_query;
512 512
 
513 513
 		// Start logging how long the request takes for logging
514
-		$before = microtime( true );
514
+		$before = microtime(true);
515 515
 
516 516
 		// Check for give-api var. Get out if not present
517
-		if ( empty( $wp_query->query_vars['give-api'] ) ) {
517
+		if (empty($wp_query->query_vars['give-api'])) {
518 518
 			return;
519 519
 		}
520 520
 
@@ -528,45 +528,45 @@  discard block
 block discarded – undo
528 528
 		$this->validate_request();
529 529
 
530 530
 		// Only proceed if no errors have been noted
531
-		if ( ! $this->is_valid_request ) {
531
+		if ( ! $this->is_valid_request) {
532 532
 			return;
533 533
 		}
534 534
 
535
-		if ( ! defined( 'GIVE_DOING_API' ) ) {
536
-			define( 'GIVE_DOING_API', true );
535
+		if ( ! defined('GIVE_DOING_API')) {
536
+			define('GIVE_DOING_API', true);
537 537
 		}
538 538
 
539 539
 		$data         = array();
540 540
 		$this->routes = new $this->versions[$this->get_queried_version()];
541 541
 		$this->routes->validate_request();
542 542
 
543
-		switch ( $this->endpoint ) :
543
+		switch ($this->endpoint) :
544 544
 
545 545
 			case 'stats' :
546 546
 
547
-				$data = $this->routes->get_stats( array(
548
-					'type'      => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null,
549
-					'form'      => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null,
550
-					'date'      => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null,
551
-					'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null,
552
-					'enddate'   => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null,
553
-				) );
547
+				$data = $this->routes->get_stats(array(
548
+					'type'      => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null,
549
+					'form'      => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null,
550
+					'date'      => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null,
551
+					'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null,
552
+					'enddate'   => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null,
553
+				));
554 554
 
555 555
 				break;
556 556
 
557 557
 			case 'forms' :
558 558
 
559
-				$form = isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null;
559
+				$form = isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null;
560 560
 
561
-				$data = $this->routes->get_forms( $form );
561
+				$data = $this->routes->get_forms($form);
562 562
 
563 563
 				break;
564 564
 
565 565
 			case 'donors' :
566 566
 
567
-				$donor = isset( $wp_query->query_vars['donor'] ) ? $wp_query->query_vars['donor'] : null;
567
+				$donor = isset($wp_query->query_vars['donor']) ? $wp_query->query_vars['donor'] : null;
568 568
 
569
-				$data = $this->routes->get_donors( $donor );
569
+				$data = $this->routes->get_donors($donor);
570 570
 
571 571
 				break;
572 572
 
@@ -579,25 +579,25 @@  discard block
 block discarded – undo
579 579
 				 * @params date startdate | required when date = range and format to be YYYYMMDD (i.e. 20170524)
580 580
 				 * @params date enddate | required when date = range and format to be YYYYMMDD (i.e. 20170524)
581 581
 				 */
582
-				$data = $this->routes->get_recent_donations( array(
583
-					'date'      => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null,
584
-					'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null,
585
-					'enddate'   => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null,
586
-				) );
582
+				$data = $this->routes->get_recent_donations(array(
583
+					'date'      => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null,
584
+					'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null,
585
+					'enddate'   => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null,
586
+				));
587 587
 
588 588
 				break;
589 589
 
590 590
 		endswitch;
591 591
 
592 592
 		// Allow extensions to setup their own return data
593
-		$this->data = apply_filters( 'give_api_output_data', $data, $this->endpoint, $this );
593
+		$this->data = apply_filters('give_api_output_data', $data, $this->endpoint, $this);
594 594
 
595
-		$after                       = microtime( true );
596
-		$request_time                = ( $after - $before );
595
+		$after                       = microtime(true);
596
+		$request_time                = ($after - $before);
597 597
 		$this->data['request_speed'] = $request_time;
598 598
 
599 599
 		// Log this API request, if enabled. We log it here because we have access to errors.
600
-		$this->log_request( $this->data );
600
+		$this->log_request($this->data);
601 601
 
602 602
 		// Send out data to the output function
603 603
 		$this->output();
@@ -627,25 +627,25 @@  discard block
 block discarded – undo
627 627
 		global $wp_query;
628 628
 
629 629
 		// Whitelist our query options
630
-		$accepted = apply_filters( 'give_api_valid_query_modes', array(
630
+		$accepted = apply_filters('give_api_valid_query_modes', array(
631 631
 			'stats',
632 632
 			'forms',
633 633
 			'donors',
634 634
 			'donations',
635
-		) );
635
+		));
636 636
 
637
-		$query = isset( $wp_query->query_vars['give-api'] ) ? $wp_query->query_vars['give-api'] : null;
638
-		$query = str_replace( $this->queried_version . '/', '', $query );
637
+		$query = isset($wp_query->query_vars['give-api']) ? $wp_query->query_vars['give-api'] : null;
638
+		$query = str_replace($this->queried_version.'/', '', $query);
639 639
 
640 640
 		$error = array();
641 641
 
642 642
 		// Make sure our query is valid
643
-		if ( ! in_array( $query, $accepted ) ) {
644
-			$error['error'] = esc_html__( 'Invalid query.', 'give' );
643
+		if ( ! in_array($query, $accepted)) {
644
+			$error['error'] = esc_html__('Invalid query.', 'give');
645 645
 
646 646
 			$this->data = $error;
647 647
 			// 400 is Bad Request
648
-			$this->output( 400 );
648
+			$this->output(400);
649 649
 		}
650 650
 
651 651
 		$this->endpoint = $query;
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
 	public function get_paged() {
663 663
 		global $wp_query;
664 664
 
665
-		return isset( $wp_query->query_vars['page'] ) ? $wp_query->query_vars['page'] : 1;
665
+		return isset($wp_query->query_vars['page']) ? $wp_query->query_vars['page'] : 1;
666 666
 	}
667 667
 
668 668
 
@@ -677,13 +677,13 @@  discard block
 block discarded – undo
677 677
 	public function per_page() {
678 678
 		global $wp_query;
679 679
 
680
-		$per_page = isset( $wp_query->query_vars['number'] ) ? $wp_query->query_vars['number'] : 10;
680
+		$per_page = isset($wp_query->query_vars['number']) ? $wp_query->query_vars['number'] : 10;
681 681
 
682
-		if ( $per_page < 0 && $this->get_query_mode() == 'donors' ) {
682
+		if ($per_page < 0 && $this->get_query_mode() == 'donors') {
683 683
 			$per_page = 99999999;
684 684
 		} // End if().
685 685
 
686
-		return apply_filters( 'give_api_results_per_page', $per_page );
686
+		return apply_filters('give_api_results_per_page', $per_page);
687 687
 	}
688 688
 
689 689
 	/**
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
 	 *
697 697
 	 * @return array $dates
698 698
 	 */
699
-	public function get_dates( $args = array() ) {
699
+	public function get_dates($args = array()) {
700 700
 		$dates = array();
701 701
 
702 702
 		$defaults = array(
@@ -707,60 +707,60 @@  discard block
 block discarded – undo
707 707
 			'enddate'   => null,
708 708
 		);
709 709
 
710
-		$args = wp_parse_args( $args, $defaults );
710
+		$args = wp_parse_args($args, $defaults);
711 711
 
712
-		$current_time = current_time( 'timestamp' );
712
+		$current_time = current_time('timestamp');
713 713
 
714
-		if ( 'range' === $args['date'] ) {
715
-			$startdate          = strtotime( $args['startdate'] );
716
-			$enddate            = strtotime( $args['enddate'] );
717
-			$dates['day_start'] = date( 'd', $startdate );
718
-			$dates['day_end']   = date( 'd', $enddate );
719
-			$dates['m_start']   = date( 'n', $startdate );
720
-			$dates['m_end']     = date( 'n', $enddate );
721
-			$dates['year']      = date( 'Y', $startdate );
722
-			$dates['year_end']  = date( 'Y', $enddate );
714
+		if ('range' === $args['date']) {
715
+			$startdate          = strtotime($args['startdate']);
716
+			$enddate            = strtotime($args['enddate']);
717
+			$dates['day_start'] = date('d', $startdate);
718
+			$dates['day_end']   = date('d', $enddate);
719
+			$dates['m_start']   = date('n', $startdate);
720
+			$dates['m_end']     = date('n', $enddate);
721
+			$dates['year']      = date('Y', $startdate);
722
+			$dates['year_end']  = date('Y', $enddate);
723 723
 		} else {
724 724
 			// Modify dates based on predefined ranges
725
-			switch ( $args['date'] ) :
725
+			switch ($args['date']) :
726 726
 
727 727
 				case 'this_month' :
728 728
 					$dates['day']     = null;
729
-					$dates['m_start'] = date( 'n', $current_time );
730
-					$dates['m_end']   = date( 'n', $current_time );
731
-					$dates['year']    = date( 'Y', $current_time );
729
+					$dates['m_start'] = date('n', $current_time);
730
+					$dates['m_end']   = date('n', $current_time);
731
+					$dates['year']    = date('Y', $current_time);
732 732
 					break;
733 733
 
734 734
 				case 'last_month' :
735 735
 					$dates['day']     = null;
736
-					$dates['m_start'] = date( 'n', $current_time ) == 1 ? 12 : date( 'n', $current_time ) - 1;
736
+					$dates['m_start'] = date('n', $current_time) == 1 ? 12 : date('n', $current_time) - 1;
737 737
 					$dates['m_end']   = $dates['m_start'];
738
-					$dates['year']    = date( 'n', $current_time ) == 1 ? date( 'Y', $current_time ) - 1 : date( 'Y', $current_time );
738
+					$dates['year']    = date('n', $current_time) == 1 ? date('Y', $current_time) - 1 : date('Y', $current_time);
739 739
 					break;
740 740
 
741 741
 				case 'today' :
742
-					$dates['day']     = date( 'd', $current_time );
743
-					$dates['m_start'] = date( 'n', $current_time );
744
-					$dates['m_end']   = date( 'n', $current_time );
745
-					$dates['year']    = date( 'Y', $current_time );
742
+					$dates['day']     = date('d', $current_time);
743
+					$dates['m_start'] = date('n', $current_time);
744
+					$dates['m_end']   = date('n', $current_time);
745
+					$dates['year']    = date('Y', $current_time);
746 746
 					break;
747 747
 
748 748
 				case 'yesterday' :
749 749
 
750
-					$year  = date( 'Y', $current_time );
751
-					$month = date( 'n', $current_time );
752
-					$day   = date( 'd', $current_time );
750
+					$year  = date('Y', $current_time);
751
+					$month = date('n', $current_time);
752
+					$day   = date('d', $current_time);
753 753
 
754
-					if ( $month == 1 && $day == 1 ) {
754
+					if ($month == 1 && $day == 1) {
755 755
 
756
-						$year  -= 1;
756
+						$year -= 1;
757 757
 						$month = 12;
758
-						$day   = cal_days_in_month( CAL_GREGORIAN, $month, $year );
758
+						$day   = cal_days_in_month(CAL_GREGORIAN, $month, $year);
759 759
 
760
-					} elseif ( $month > 1 && $day == 1 ) {
760
+					} elseif ($month > 1 && $day == 1) {
761 761
 
762 762
 						$month -= 1;
763
-						$day   = cal_days_in_month( CAL_GREGORIAN, $month, $year );
763
+						$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
764 764
 
765 765
 					} else {
766 766
 
@@ -776,65 +776,65 @@  discard block
 block discarded – undo
776 776
 					break;
777 777
 
778 778
 				case 'this_quarter' :
779
-					$month_now = date( 'n', $current_time );
779
+					$month_now = date('n', $current_time);
780 780
 
781 781
 					$dates['day'] = null;
782 782
 
783
-					if ( $month_now <= 3 ) {
783
+					if ($month_now <= 3) {
784 784
 
785 785
 						$dates['m_start'] = 1;
786 786
 						$dates['m_end']   = 3;
787
-						$dates['year']    = date( 'Y', $current_time );
787
+						$dates['year']    = date('Y', $current_time);
788 788
 
789
-					} elseif ( $month_now <= 6 ) {
789
+					} elseif ($month_now <= 6) {
790 790
 
791 791
 						$dates['m_start'] = 4;
792 792
 						$dates['m_end']   = 6;
793
-						$dates['year']    = date( 'Y', $current_time );
793
+						$dates['year']    = date('Y', $current_time);
794 794
 
795
-					} elseif ( $month_now <= 9 ) {
795
+					} elseif ($month_now <= 9) {
796 796
 
797 797
 						$dates['m_start'] = 7;
798 798
 						$dates['m_end']   = 9;
799
-						$dates['year']    = date( 'Y', $current_time );
799
+						$dates['year']    = date('Y', $current_time);
800 800
 
801 801
 					} else {
802 802
 
803 803
 						$dates['m_start'] = 10;
804 804
 						$dates['m_end']   = 12;
805
-						$dates['year']    = date( 'Y', $current_time );
805
+						$dates['year']    = date('Y', $current_time);
806 806
 
807 807
 					}
808 808
 					break;
809 809
 
810 810
 				case 'last_quarter' :
811
-					$month_now = date( 'n', $current_time );
811
+					$month_now = date('n', $current_time);
812 812
 
813 813
 					$dates['day'] = null;
814 814
 
815
-					if ( $month_now <= 3 ) {
815
+					if ($month_now <= 3) {
816 816
 
817 817
 						$dates['m_start'] = 10;
818 818
 						$dates['m_end']   = 12;
819
-						$dates['year']    = date( 'Y', $current_time ) - 1; // Previous year
819
+						$dates['year']    = date('Y', $current_time) - 1; // Previous year
820 820
 
821
-					} elseif ( $month_now <= 6 ) {
821
+					} elseif ($month_now <= 6) {
822 822
 
823 823
 						$dates['m_start'] = 1;
824 824
 						$dates['m_end']   = 3;
825
-						$dates['year']    = date( 'Y', $current_time );
825
+						$dates['year']    = date('Y', $current_time);
826 826
 
827
-					} elseif ( $month_now <= 9 ) {
827
+					} elseif ($month_now <= 9) {
828 828
 
829 829
 						$dates['m_start'] = 4;
830 830
 						$dates['m_end']   = 6;
831
-						$dates['year']    = date( 'Y', $current_time );
831
+						$dates['year']    = date('Y', $current_time);
832 832
 
833 833
 					} else {
834 834
 
835 835
 						$dates['m_start'] = 7;
836 836
 						$dates['m_end']   = 9;
837
-						$dates['year']    = date( 'Y', $current_time );
837
+						$dates['year']    = date('Y', $current_time);
838 838
 
839 839
 					}
840 840
 					break;
@@ -843,14 +843,14 @@  discard block
 block discarded – undo
843 843
 					$dates['day']     = null;
844 844
 					$dates['m_start'] = null;
845 845
 					$dates['m_end']   = null;
846
-					$dates['year']    = date( 'Y', $current_time );
846
+					$dates['year']    = date('Y', $current_time);
847 847
 					break;
848 848
 
849 849
 				case 'last_year' :
850 850
 					$dates['day']     = null;
851 851
 					$dates['m_start'] = null;
852 852
 					$dates['m_end']   = null;
853
-					$dates['year']    = date( 'Y', $current_time ) - 1;
853
+					$dates['year']    = date('Y', $current_time) - 1;
854 854
 					break;
855 855
 
856 856
 			endswitch;
@@ -863,7 +863,7 @@  discard block
 block discarded – undo
863 863
 		 *
864 864
 		 * @param array $dates The dates used for retrieving earnings.
865 865
 		 */
866
-		return apply_filters( 'give_api_stat_dates', $dates );
866
+		return apply_filters('give_api_stat_dates', $dates);
867 867
 	}
868 868
 
869 869
 	/**
@@ -877,78 +877,78 @@  discard block
 block discarded – undo
877 877
 	 *
878 878
 	 * @return array $donors Multidimensional array of the donors.
879 879
 	 */
880
-	public function get_donors( $donor = null ) {
880
+	public function get_donors($donor = null) {
881 881
 
882 882
 		$donors = array();
883 883
 		$error  = array();
884
-		if ( ! user_can( $this->user_id, 'view_give_sensitive_data' ) && ! $this->override ) {
884
+		if ( ! user_can($this->user_id, 'view_give_sensitive_data') && ! $this->override) {
885 885
 			return $donors;
886 886
 		}
887 887
 
888 888
 		$paged    = $this->get_paged();
889 889
 		$per_page = $this->per_page();
890
-		$offset   = $per_page * ( $paged - 1 );
890
+		$offset   = $per_page * ($paged - 1);
891 891
 
892
-		if ( is_numeric( $donor ) ) {
892
+		if (is_numeric($donor)) {
893 893
 			$field = 'id';
894 894
 		} else {
895 895
 			$field = 'email';
896 896
 		}
897 897
 
898
-		$donor_query = Give()->donors->get_donors( array(
898
+		$donor_query = Give()->donors->get_donors(array(
899 899
 			'number' => $per_page,
900 900
 			'offset' => $offset,
901 901
 			$field   => $donor,
902
-		) );
902
+		));
903 903
 		$donor_count = 0;
904 904
 
905
-		if ( $donor_query ) {
905
+		if ($donor_query) {
906 906
 
907
-			foreach ( $donor_query as $donor_obj ) {
907
+			foreach ($donor_query as $donor_obj) {
908 908
 
909
-				$names      = explode( ' ', $donor_obj->name );
910
-				$first_name = ! empty( $names[0] ) ? $names[0] : '';
909
+				$names      = explode(' ', $donor_obj->name);
910
+				$first_name = ! empty($names[0]) ? $names[0] : '';
911 911
 				$last_name  = '';
912
-				if ( ! empty( $names[1] ) ) {
913
-					unset( $names[0] );
914
-					$last_name = implode( ' ', $names );
912
+				if ( ! empty($names[1])) {
913
+					unset($names[0]);
914
+					$last_name = implode(' ', $names);
915 915
 				}
916 916
 
917
-				$donors['donors'][ $donor_count ]['info']['user_id']      = '';
918
-				$donors['donors'][ $donor_count ]['info']['username']     = '';
919
-				$donors['donors'][ $donor_count ]['info']['display_name'] = '';
920
-				$donors['donors'][ $donor_count ]['info']['donor_id']     = $donor_obj->id;
921
-				$donors['donors'][ $donor_count ]['info']['first_name']   = $first_name;
922
-				$donors['donors'][ $donor_count ]['info']['last_name']    = $last_name;
923
-				$donors['donors'][ $donor_count ]['info']['email']        = $donor_obj->email;
917
+				$donors['donors'][$donor_count]['info']['user_id']      = '';
918
+				$donors['donors'][$donor_count]['info']['username']     = '';
919
+				$donors['donors'][$donor_count]['info']['display_name'] = '';
920
+				$donors['donors'][$donor_count]['info']['donor_id']     = $donor_obj->id;
921
+				$donors['donors'][$donor_count]['info']['first_name']   = $first_name;
922
+				$donors['donors'][$donor_count]['info']['last_name']    = $last_name;
923
+				$donors['donors'][$donor_count]['info']['email']        = $donor_obj->email;
924 924
 
925
-				if ( ! empty( $donor_obj->user_id ) ) {
925
+				if ( ! empty($donor_obj->user_id)) {
926 926
 
927
-					$user_data = get_userdata( $donor_obj->user_id );
927
+					$user_data = get_userdata($donor_obj->user_id);
928 928
 
929 929
 					// Donor with registered account.
930
-					$donors['donors'][ $donor_count ]['info']['user_id']      = $donor_obj->user_id;
931
-					$donors['donors'][ $donor_count ]['info']['username']     = $user_data->user_login;
932
-					$donors['donors'][ $donor_count ]['info']['display_name'] = $user_data->display_name;
930
+					$donors['donors'][$donor_count]['info']['user_id']      = $donor_obj->user_id;
931
+					$donors['donors'][$donor_count]['info']['username']     = $user_data->user_login;
932
+					$donors['donors'][$donor_count]['info']['display_name'] = $user_data->display_name;
933 933
 
934 934
 				}
935 935
 
936
-				$donors['donors'][ $donor_count ]['stats']['total_donations'] = $donor_obj->purchase_count;
937
-				$donors['donors'][ $donor_count ]['stats']['total_spent']     = $donor_obj->purchase_value;
936
+				$donors['donors'][$donor_count]['stats']['total_donations'] = $donor_obj->purchase_count;
937
+				$donors['donors'][$donor_count]['stats']['total_spent']     = $donor_obj->purchase_value;
938 938
 
939
-				$donor_count ++;
939
+				$donor_count++;
940 940
 
941 941
 			}
942
-		} elseif ( $donor ) {
942
+		} elseif ($donor) {
943 943
 
944 944
 			$error['error'] = sprintf( /* translators: %s: donor */
945
-				esc_html__( 'Donor %s not found.', 'give' ), $donor );
945
+				esc_html__('Donor %s not found.', 'give'), $donor );
946 946
 
947 947
 			return $error;
948 948
 
949 949
 		} else {
950 950
 
951
-			$error['error'] = esc_html__( 'No donors found.', 'give' );
951
+			$error['error'] = esc_html__('No donors found.', 'give');
952 952
 
953 953
 			return $error;
954 954
 
@@ -967,37 +967,37 @@  discard block
 block discarded – undo
967 967
 	 *
968 968
 	 * @return array $donors Multidimensional array of the forms.
969 969
 	 */
970
-	public function get_forms( $form = null ) {
970
+	public function get_forms($form = null) {
971 971
 
972 972
 		$forms = array();
973 973
 		$error = array();
974 974
 
975
-		if ( $form == null ) {
975
+		if ($form == null) {
976 976
 			$forms['forms'] = array();
977 977
 
978
-			$form_list = get_posts( array(
978
+			$form_list = get_posts(array(
979 979
 				'post_type'        => 'give_forms',
980 980
 				'posts_per_page'   => $this->per_page(),
981 981
 				'suppress_filters' => true,
982 982
 				'paged'            => $this->get_paged(),
983
-			) );
983
+			));
984 984
 
985
-			if ( $form_list ) {
985
+			if ($form_list) {
986 986
 				$i = 0;
987
-				foreach ( $form_list as $form_info ) {
988
-					$forms['forms'][ $i ] = $this->get_form_data( $form_info );
989
-					$i ++;
987
+				foreach ($form_list as $form_info) {
988
+					$forms['forms'][$i] = $this->get_form_data($form_info);
989
+					$i++;
990 990
 				}
991 991
 			}
992 992
 		} else {
993
-			if ( get_post_type( $form ) == 'give_forms' ) {
994
-				$form_info = get_post( $form );
993
+			if (get_post_type($form) == 'give_forms') {
994
+				$form_info = get_post($form);
995 995
 
996
-				$forms['forms'][0] = $this->get_form_data( $form_info );
996
+				$forms['forms'][0] = $this->get_form_data($form_info);
997 997
 
998 998
 			} else {
999 999
 				$error['error'] = sprintf( /* translators: %s: form */
1000
-					esc_html__( 'Form %s not found.', 'give' ), $form );
1000
+					esc_html__('Form %s not found.', 'give'), $form );
1001 1001
 
1002 1002
 				return $error;
1003 1003
 			}
@@ -1015,7 +1015,7 @@  discard block
 block discarded – undo
1015 1015
 	 *
1016 1016
 	 * @return array                Array of post data to return back in the API.
1017 1017
 	 */
1018
-	private function get_form_data( $form_info ) {
1018
+	private function get_form_data($form_info) {
1019 1019
 
1020 1020
 		$form = array();
1021 1021
 
@@ -1025,60 +1025,60 @@  discard block
 block discarded – undo
1025 1025
 		$form['info']['create_date']   = $form_info->post_date;
1026 1026
 		$form['info']['modified_date'] = $form_info->post_modified;
1027 1027
 		$form['info']['status']        = $form_info->post_status;
1028
-		$form['info']['link']          = html_entity_decode( $form_info->guid );
1029
-		$form['info']['content']       = give_get_meta( $form_info->ID, '_give_form_content', true );
1030
-		$form['info']['thumbnail']     = wp_get_attachment_url( get_post_thumbnail_id( $form_info->ID ) );
1028
+		$form['info']['link']          = html_entity_decode($form_info->guid);
1029
+		$form['info']['content']       = give_get_meta($form_info->ID, '_give_form_content', true);
1030
+		$form['info']['thumbnail']     = wp_get_attachment_url(get_post_thumbnail_id($form_info->ID));
1031 1031
 
1032
-		if ( give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ) ) {
1033
-			$form['info']['category'] = get_the_terms( $form_info, 'give_forms_category' );
1034
-			$form['info']['tags']     = get_the_terms( $form_info, 'give_forms_tag' );
1032
+		if (give_is_setting_enabled(give_get_option('categories', 'disabled'))) {
1033
+			$form['info']['category'] = get_the_terms($form_info, 'give_forms_category');
1034
+			$form['info']['tags']     = get_the_terms($form_info, 'give_forms_tag');
1035 1035
 		}
1036
-		if ( give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) ) ) {
1037
-			$form['info']['tags'] = get_the_terms( $form_info, 'give_forms_tag' );
1036
+		if (give_is_setting_enabled(give_get_option('tags', 'disabled'))) {
1037
+			$form['info']['tags'] = get_the_terms($form_info, 'give_forms_tag');
1038 1038
 		}
1039 1039
 
1040 1040
 		// Check whether any goal is to be achieved for the donation form.
1041
-		$goal_option = give_get_meta( $form_info->ID, '_give_goal_option', true );
1042
-		$goal_amount = give_get_meta( $form_info->ID, '_give_set_goal', true );
1043
-		if ( give_is_setting_enabled( $goal_option ) && $goal_amount ) {
1044
-			$total_income = give_get_form_earnings_stats( $form_info->ID );
1045
-			$goal_percentage_completed = ( $total_income < $goal_amount ) ? round( ( $total_income / $goal_amount ) * 100, 2 ) : 100;
1046
-			$form['goal']['amount']               = isset( $goal_amount ) ? $goal_amount : '';
1047
-			$form['goal']['percentage_completed'] = isset( $goal_percentage_completed ) ? $goal_percentage_completed : '';
1041
+		$goal_option = give_get_meta($form_info->ID, '_give_goal_option', true);
1042
+		$goal_amount = give_get_meta($form_info->ID, '_give_set_goal', true);
1043
+		if (give_is_setting_enabled($goal_option) && $goal_amount) {
1044
+			$total_income = give_get_form_earnings_stats($form_info->ID);
1045
+			$goal_percentage_completed = ($total_income < $goal_amount) ? round(($total_income / $goal_amount) * 100, 2) : 100;
1046
+			$form['goal']['amount']               = isset($goal_amount) ? $goal_amount : '';
1047
+			$form['goal']['percentage_completed'] = isset($goal_percentage_completed) ? $goal_percentage_completed : '';
1048 1048
 		}
1049 1049
 
1050
-		if ( user_can( $this->user_id, 'view_give_reports' ) || $this->override ) {
1051
-			$form['stats']['total']['donations']           = give_get_form_sales_stats( $form_info->ID );
1052
-			$form['stats']['total']['earnings']            = give_get_form_earnings_stats( $form_info->ID );
1053
-			$form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales( $form_info->ID );
1054
-			$form['stats']['monthly_average']['earnings']  = give_get_average_monthly_form_earnings( $form_info->ID );
1050
+		if (user_can($this->user_id, 'view_give_reports') || $this->override) {
1051
+			$form['stats']['total']['donations']           = give_get_form_sales_stats($form_info->ID);
1052
+			$form['stats']['total']['earnings']            = give_get_form_earnings_stats($form_info->ID);
1053
+			$form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales($form_info->ID);
1054
+			$form['stats']['monthly_average']['earnings']  = give_get_average_monthly_form_earnings($form_info->ID);
1055 1055
 		}
1056 1056
 
1057 1057
 		$counter = 0;
1058
-		if ( give_has_variable_prices( $form_info->ID ) ) {
1059
-			foreach ( give_get_variable_prices( $form_info->ID ) as $price ) {
1060
-				$counter ++;
1058
+		if (give_has_variable_prices($form_info->ID)) {
1059
+			foreach (give_get_variable_prices($form_info->ID) as $price) {
1060
+				$counter++;
1061 1061
 				// multi-level item
1062
-				$level                                     = isset( $price['_give_text'] ) ? $price['_give_text'] : 'level-' . $counter;
1063
-				$form['pricing'][ sanitize_key( $level ) ] = $price['_give_amount'];
1062
+				$level                                     = isset($price['_give_text']) ? $price['_give_text'] : 'level-'.$counter;
1063
+				$form['pricing'][sanitize_key($level)] = $price['_give_amount'];
1064 1064
 
1065 1065
 			}
1066 1066
 		} else {
1067
-			$form['pricing']['amount'] = give_get_form_price( $form_info->ID );
1067
+			$form['pricing']['amount'] = give_get_form_price($form_info->ID);
1068 1068
 		}
1069 1069
 
1070
-		if ( user_can( $this->user_id, 'view_give_sensitive_data' ) || $this->override ) {
1070
+		if (user_can($this->user_id, 'view_give_sensitive_data') || $this->override) {
1071 1071
 
1072 1072
 			/**
1073 1073
 			 * Fires when generating API sensitive data.
1074 1074
 			 *
1075 1075
 			 * @since 1.1
1076 1076
 			 */
1077
-			do_action( 'give_api_sensitive_data' );
1077
+			do_action('give_api_sensitive_data');
1078 1078
 
1079 1079
 		}
1080 1080
 
1081
-		return apply_filters( 'give_api_forms_form', $form );
1081
+		return apply_filters('give_api_forms_form', $form);
1082 1082
 
1083 1083
 	}
1084 1084
 
@@ -1093,7 +1093,7 @@  discard block
 block discarded – undo
1093 1093
 	 *
1094 1094
 	 * @return array
1095 1095
 	 */
1096
-	public function get_stats( $args = array() ) {
1096
+	public function get_stats($args = array()) {
1097 1097
 		$defaults = array(
1098 1098
 			'type'      => null,
1099 1099
 			'form'      => null,
@@ -1102,9 +1102,9 @@  discard block
 block discarded – undo
1102 1102
 			'enddate'   => null,
1103 1103
 		);
1104 1104
 
1105
-		$args = wp_parse_args( $args, $defaults );
1105
+		$args = wp_parse_args($args, $defaults);
1106 1106
 
1107
-		$dates = $this->get_dates( $args );
1107
+		$dates = $this->get_dates($args);
1108 1108
 
1109 1109
 		$stats    = array();
1110 1110
 		$earnings = array(
@@ -1115,40 +1115,40 @@  discard block
 block discarded – undo
1115 1115
 		);
1116 1116
 		$error    = array();
1117 1117
 
1118
-		if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) {
1118
+		if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) {
1119 1119
 			return $stats;
1120 1120
 		}
1121 1121
 
1122
-		if ( $args['type'] == 'donations' ) {
1122
+		if ($args['type'] == 'donations') {
1123 1123
 
1124
-			if ( $args['form'] == null ) {
1125
-				if ( $args['date'] == null ) {
1124
+			if ($args['form'] == null) {
1125
+				if ($args['date'] == null) {
1126 1126
 					$sales = $this->get_default_sales_stats();
1127
-				} elseif ( $args['date'] === 'range' ) {
1127
+				} elseif ($args['date'] === 'range') {
1128 1128
 					// Return donations for a date range.
1129 1129
 					// Ensure the end date is later than the start date.
1130
-					if ( $args['enddate'] < $args['startdate'] ) {
1131
-						$error['error'] = esc_html__( 'The end date must be later than the start date.', 'give' );
1130
+					if ($args['enddate'] < $args['startdate']) {
1131
+						$error['error'] = esc_html__('The end date must be later than the start date.', 'give');
1132 1132
 					}
1133 1133
 
1134 1134
 					// Ensure both the start and end date are specified
1135
-					if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) {
1136
-						$error['error'] = esc_html__( 'Invalid or no date range specified.', 'give' );
1135
+					if (empty($args['startdate']) || empty($args['enddate'])) {
1136
+						$error['error'] = esc_html__('Invalid or no date range specified.', 'give');
1137 1137
 					}
1138 1138
 
1139 1139
 					$total = 0;
1140 1140
 
1141 1141
 					// Loop through the years
1142 1142
 					$y = $dates['year'];
1143
-					while ( $y <= $dates['year_end'] ) :
1143
+					while ($y <= $dates['year_end']) :
1144 1144
 
1145
-						if ( $dates['year'] == $dates['year_end'] ) {
1145
+						if ($dates['year'] == $dates['year_end']) {
1146 1146
 							$month_start = $dates['m_start'];
1147 1147
 							$month_end   = $dates['m_end'];
1148
-						} elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) {
1148
+						} elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) {
1149 1149
 							$month_start = $dates['m_start'];
1150 1150
 							$month_end   = 12;
1151
-						} elseif ( $y == $dates['year_end'] ) {
1151
+						} elseif ($y == $dates['year_end']) {
1152 1152
 							$month_start = 1;
1153 1153
 							$month_end   = $dates['m_end'];
1154 1154
 						} else {
@@ -1157,116 +1157,116 @@  discard block
 block discarded – undo
1157 1157
 						}
1158 1158
 
1159 1159
 						$i = $month_start;
1160
-						while ( $i <= $month_end ) :
1160
+						while ($i <= $month_end) :
1161 1161
 
1162
-							if ( $i == $dates['m_start'] ) {
1162
+							if ($i == $dates['m_start']) {
1163 1163
 								$d = $dates['day_start'];
1164 1164
 							} else {
1165 1165
 								$d = 1;
1166 1166
 							}
1167 1167
 
1168
-							if ( $i == $dates['m_end'] ) {
1168
+							if ($i == $dates['m_end']) {
1169 1169
 								$num_of_days = $dates['day_end'];
1170 1170
 							} else {
1171
-								$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
1171
+								$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
1172 1172
 							}
1173 1173
 
1174
-							while ( $d <= $num_of_days ) :
1175
-								$sale_count = give_get_sales_by_date( $d, $i, $y );
1176
-								$date_key   = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) );
1177
-								if ( ! isset( $sales['sales'][ $date_key ] ) ) {
1178
-									$sales['sales'][ $date_key ] = 0;
1174
+							while ($d <= $num_of_days) :
1175
+								$sale_count = give_get_sales_by_date($d, $i, $y);
1176
+								$date_key   = date('Ymd', strtotime($y.'/'.$i.'/'.$d));
1177
+								if ( ! isset($sales['sales'][$date_key])) {
1178
+									$sales['sales'][$date_key] = 0;
1179 1179
 								}
1180
-								$sales['sales'][ $date_key ] += $sale_count;
1180
+								$sales['sales'][$date_key] += $sale_count;
1181 1181
 								$total                       += $sale_count;
1182
-								$d ++;
1182
+								$d++;
1183 1183
 							endwhile;
1184
-							$i ++;
1184
+							$i++;
1185 1185
 						endwhile;
1186 1186
 
1187
-						$y ++;
1187
+						$y++;
1188 1188
 					endwhile;
1189 1189
 
1190 1190
 					$sales['totals'] = $total;
1191 1191
 				} else {
1192
-					if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) {
1192
+					if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') {
1193 1193
 						$sales_count = 0;
1194 1194
 
1195 1195
 						// Loop through the months
1196 1196
 						$month = $dates['m_start'];
1197 1197
 
1198
-						while ( $month <= $dates['m_end'] ) :
1199
-							$sales_count += give_get_sales_by_date( null, $month, $dates['year'] );
1200
-							$month ++;
1198
+						while ($month <= $dates['m_end']) :
1199
+							$sales_count += give_get_sales_by_date(null, $month, $dates['year']);
1200
+							$month++;
1201 1201
 						endwhile;
1202 1202
 
1203
-						$sales['donations'][ $args['date'] ] = $sales_count;
1203
+						$sales['donations'][$args['date']] = $sales_count;
1204 1204
 					} else {
1205
-						$sales['donations'][ $args['date'] ] = give_get_sales_by_date( $dates['day'], $dates['m_start'], $dates['year'] );
1205
+						$sales['donations'][$args['date']] = give_get_sales_by_date($dates['day'], $dates['m_start'], $dates['year']);
1206 1206
 					}
1207 1207
 				}// End if().
1208
-			} elseif ( $args['form'] == 'all' ) {
1209
-				$forms = get_posts( array(
1208
+			} elseif ($args['form'] == 'all') {
1209
+				$forms = get_posts(array(
1210 1210
 					'post_type' => 'give_forms',
1211 1211
 					'nopaging'  => true,
1212
-				) );
1213
-				$i     = 0;
1214
-				foreach ( $forms as $form_info ) {
1215
-					$sales['donations'][ $i ] = array(
1216
-						$form_info->post_name => give_get_form_sales_stats( $form_info->ID ),
1212
+				));
1213
+				$i = 0;
1214
+				foreach ($forms as $form_info) {
1215
+					$sales['donations'][$i] = array(
1216
+						$form_info->post_name => give_get_form_sales_stats($form_info->ID),
1217 1217
 					);
1218
-					$i ++;
1218
+					$i++;
1219 1219
 				}
1220 1220
 			} else {
1221
-				if ( get_post_type( $args['form'] ) == 'give_forms' ) {
1222
-					$form_info             = get_post( $args['form'] );
1221
+				if (get_post_type($args['form']) == 'give_forms') {
1222
+					$form_info             = get_post($args['form']);
1223 1223
 					$sales['donations'][0] = array(
1224
-						$form_info->post_name => give_get_form_sales_stats( $args['form'] ),
1224
+						$form_info->post_name => give_get_form_sales_stats($args['form']),
1225 1225
 					);
1226 1226
 				} else {
1227 1227
 					$error['error'] = sprintf( /* translators: %s: form */
1228
-						esc_html__( 'Form %s not found.', 'give' ), $args['form'] );
1228
+						esc_html__('Form %s not found.', 'give'), $args['form'] );
1229 1229
 				}
1230 1230
 			}// End if().
1231 1231
 
1232
-			if ( ! empty( $error ) ) {
1232
+			if ( ! empty($error)) {
1233 1233
 				return $error;
1234 1234
 			}
1235 1235
 
1236 1236
 			return $sales;
1237 1237
 
1238
-		} elseif ( $args['type'] == 'earnings' ) {
1239
-			if ( $args['form'] == null ) {
1240
-				if ( $args['date'] == null ) {
1238
+		} elseif ($args['type'] == 'earnings') {
1239
+			if ($args['form'] == null) {
1240
+				if ($args['date'] == null) {
1241 1241
 					$earnings = $this->get_default_earnings_stats();
1242
-				} elseif ( $args['date'] === 'range' ) {
1242
+				} elseif ($args['date'] === 'range') {
1243 1243
 					// Return sales for a date range
1244 1244
 					// Ensure the end date is later than the start date
1245
-					if ( $args['enddate'] < $args['startdate'] ) {
1246
-						$error['error'] = esc_html__( 'The end date must be later than the start date.', 'give' );
1245
+					if ($args['enddate'] < $args['startdate']) {
1246
+						$error['error'] = esc_html__('The end date must be later than the start date.', 'give');
1247 1247
 					}
1248 1248
 
1249 1249
 					// Ensure both the start and end date are specified
1250
-					if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) {
1251
-						$error['error'] = esc_html__( 'Invalid or no date range specified.', 'give' );
1250
+					if (empty($args['startdate']) || empty($args['enddate'])) {
1251
+						$error['error'] = esc_html__('Invalid or no date range specified.', 'give');
1252 1252
 					}
1253 1253
 
1254 1254
 					$total = (float) 0.00;
1255 1255
 
1256 1256
 					// Loop through the years
1257 1257
 					$y = $dates['year'];
1258
-					if ( ! isset( $earnings['earnings'] ) ) {
1258
+					if ( ! isset($earnings['earnings'])) {
1259 1259
 						$earnings['earnings'] = array();
1260 1260
 					}
1261
-					while ( $y <= $dates['year_end'] ) :
1261
+					while ($y <= $dates['year_end']) :
1262 1262
 
1263
-						if ( $dates['year'] == $dates['year_end'] ) {
1263
+						if ($dates['year'] == $dates['year_end']) {
1264 1264
 							$month_start = $dates['m_start'];
1265 1265
 							$month_end   = $dates['m_end'];
1266
-						} elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) {
1266
+						} elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) {
1267 1267
 							$month_start = $dates['m_start'];
1268 1268
 							$month_end   = 12;
1269
-						} elseif ( $y == $dates['year_end'] ) {
1269
+						} elseif ($y == $dates['year_end']) {
1270 1270
 							$month_start = 1;
1271 1271
 							$month_end   = $dates['m_end'];
1272 1272
 						} else {
@@ -1275,94 +1275,94 @@  discard block
 block discarded – undo
1275 1275
 						}
1276 1276
 
1277 1277
 						$i = $month_start;
1278
-						while ( $i <= $month_end ) :
1278
+						while ($i <= $month_end) :
1279 1279
 
1280
-							if ( $i == $dates['m_start'] ) {
1280
+							if ($i == $dates['m_start']) {
1281 1281
 								$d = $dates['day_start'];
1282 1282
 							} else {
1283 1283
 								$d = 1;
1284 1284
 							}
1285 1285
 
1286
-							if ( $i == $dates['m_end'] ) {
1286
+							if ($i == $dates['m_end']) {
1287 1287
 								$num_of_days = $dates['day_end'];
1288 1288
 							} else {
1289
-								$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
1289
+								$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
1290 1290
 							}
1291 1291
 
1292
-							while ( $d <= $num_of_days ) :
1293
-								$earnings_stat = give_get_earnings_by_date( $d, $i, $y );
1294
-								$date_key      = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) );
1295
-								if ( ! isset( $earnings['earnings'][ $date_key ] ) ) {
1296
-									$earnings['earnings'][ $date_key ] = 0;
1292
+							while ($d <= $num_of_days) :
1293
+								$earnings_stat = give_get_earnings_by_date($d, $i, $y);
1294
+								$date_key      = date('Ymd', strtotime($y.'/'.$i.'/'.$d));
1295
+								if ( ! isset($earnings['earnings'][$date_key])) {
1296
+									$earnings['earnings'][$date_key] = 0;
1297 1297
 								}
1298
-								$earnings['earnings'][ $date_key ] += $earnings_stat;
1298
+								$earnings['earnings'][$date_key] += $earnings_stat;
1299 1299
 								$total                             += $earnings_stat;
1300
-								$d ++;
1300
+								$d++;
1301 1301
 							endwhile;
1302 1302
 
1303
-							$i ++;
1303
+							$i++;
1304 1304
 						endwhile;
1305 1305
 
1306
-						$y ++;
1306
+						$y++;
1307 1307
 					endwhile;
1308 1308
 
1309 1309
 					$earnings['totals'] = $total;
1310 1310
 				} else {
1311
-					if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) {
1311
+					if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') {
1312 1312
 						$earnings_count = (float) 0.00;
1313 1313
 
1314 1314
 						// Loop through the months
1315 1315
 						$month = $dates['m_start'];
1316 1316
 
1317
-						while ( $month <= $dates['m_end'] ) :
1318
-							$earnings_count += give_get_earnings_by_date( null, $month, $dates['year'] );
1319
-							$month ++;
1317
+						while ($month <= $dates['m_end']) :
1318
+							$earnings_count += give_get_earnings_by_date(null, $month, $dates['year']);
1319
+							$month++;
1320 1320
 						endwhile;
1321 1321
 
1322
-						$earnings['earnings'][ $args['date'] ] = $earnings_count;
1322
+						$earnings['earnings'][$args['date']] = $earnings_count;
1323 1323
 					} else {
1324
-						$earnings['earnings'][ $args['date'] ] = give_get_earnings_by_date( $dates['day'], $dates['m_start'], $dates['year'] );
1324
+						$earnings['earnings'][$args['date']] = give_get_earnings_by_date($dates['day'], $dates['m_start'], $dates['year']);
1325 1325
 					}
1326 1326
 				}// End if().
1327
-			} elseif ( $args['form'] == 'all' ) {
1328
-				$forms = get_posts( array(
1327
+			} elseif ($args['form'] == 'all') {
1328
+				$forms = get_posts(array(
1329 1329
 					'post_type' => 'give_forms',
1330 1330
 					'nopaging'  => true,
1331
-				) );
1331
+				));
1332 1332
 
1333 1333
 				$i = 0;
1334
-				foreach ( $forms as $form_info ) {
1335
-					$earnings['earnings'][ $i ] = array(
1336
-						$form_info->post_name => give_get_form_earnings_stats( $form_info->ID ),
1334
+				foreach ($forms as $form_info) {
1335
+					$earnings['earnings'][$i] = array(
1336
+						$form_info->post_name => give_get_form_earnings_stats($form_info->ID),
1337 1337
 					);
1338
-					$i ++;
1338
+					$i++;
1339 1339
 				}
1340 1340
 			} else {
1341
-				if ( get_post_type( $args['form'] ) == 'give_forms' ) {
1342
-					$form_info               = get_post( $args['form'] );
1341
+				if (get_post_type($args['form']) == 'give_forms') {
1342
+					$form_info               = get_post($args['form']);
1343 1343
 					$earnings['earnings'][0] = array(
1344
-						$form_info->post_name => give_get_form_earnings_stats( $args['form'] ),
1344
+						$form_info->post_name => give_get_form_earnings_stats($args['form']),
1345 1345
 					);
1346 1346
 				} else {
1347 1347
 					$error['error'] = sprintf( /* translators: %s: form */
1348
-						esc_html__( 'Form %s not found.', 'give' ), $args['form'] );
1348
+						esc_html__('Form %s not found.', 'give'), $args['form'] );
1349 1349
 				}
1350 1350
 			}// End if().
1351 1351
 
1352
-			if ( ! empty( $error ) ) {
1352
+			if ( ! empty($error)) {
1353 1353
 				return $error;
1354 1354
 			}
1355 1355
 
1356 1356
 			return $earnings;
1357
-		} elseif ( $args['type'] == 'donors' ) {
1357
+		} elseif ($args['type'] == 'donors') {
1358 1358
 			$donors                             = new Give_DB_Donors();
1359 1359
 			$stats['donations']['total_donors'] = $donors->count();
1360 1360
 
1361 1361
 			return $stats;
1362 1362
 
1363
-		} elseif ( empty( $args['type'] ) ) {
1364
-			$stats = array_merge( $stats, $this->get_default_sales_stats() );
1365
-			$stats = array_merge( $stats, $this->get_default_earnings_stats() );
1363
+		} elseif (empty($args['type'])) {
1364
+			$stats = array_merge($stats, $this->get_default_sales_stats());
1365
+			$stats = array_merge($stats, $this->get_default_earnings_stats());
1366 1366
 
1367 1367
 			return array(
1368 1368
 				'stats' => $stats,
@@ -1380,7 +1380,7 @@  discard block
 block discarded – undo
1380 1380
 	 *
1381 1381
 	 * @return array
1382 1382
 	 */
1383
-	public function get_recent_donations( $args = array() ) {
1383
+	public function get_recent_donations($args = array()) {
1384 1384
 		global $wp_query;
1385 1385
 
1386 1386
 		$defaults = array(
@@ -1389,22 +1389,22 @@  discard block
 block discarded – undo
1389 1389
 			'enddate'   => null,
1390 1390
 		);
1391 1391
 
1392
-		$args = wp_parse_args( $args, $defaults );
1392
+		$args = wp_parse_args($args, $defaults);
1393 1393
 
1394 1394
 		$sales = array();
1395 1395
 
1396
-		if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) {
1396
+		if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) {
1397 1397
 			return $sales;
1398 1398
 		}
1399 1399
 
1400
-		if ( isset( $wp_query->query_vars['id'] ) ) {
1400
+		if (isset($wp_query->query_vars['id'])) {
1401 1401
 			$query   = array();
1402
-			$query[] = new Give_Payment( $wp_query->query_vars['id'] );
1403
-		} elseif ( isset( $wp_query->query_vars['purchasekey'] ) ) {
1402
+			$query[] = new Give_Payment($wp_query->query_vars['id']);
1403
+		} elseif (isset($wp_query->query_vars['purchasekey'])) {
1404 1404
 			$query   = array();
1405
-			$query[] = give_get_payment_by( 'key', $wp_query->query_vars['purchasekey'] );
1406
-		} elseif ( isset( $wp_query->query_vars['email'] ) ) {
1407
-			$args  = array(
1405
+			$query[] = give_get_payment_by('key', $wp_query->query_vars['purchasekey']);
1406
+		} elseif (isset($wp_query->query_vars['email'])) {
1407
+			$args = array(
1408 1408
 				'fields'     => 'ids',
1409 1409
 				'meta_key'   => '_give_payment_user_email',
1410 1410
 				'meta_value' => $wp_query->query_vars['email'],
@@ -1412,11 +1412,11 @@  discard block
 block discarded – undo
1412 1412
 				'page'       => $this->get_paged(),
1413 1413
 				'status'     => 'publish',
1414 1414
 			);
1415
-			$query = give_get_payments( $args );
1416
-		} elseif ( isset( $wp_query->query_vars['date'] ) ) {
1415
+			$query = give_get_payments($args);
1416
+		} elseif (isset($wp_query->query_vars['date'])) {
1417 1417
 
1418
-			$current_time = current_time( 'timestamp' );
1419
-			$dates        = $this->get_dates( $args );
1418
+			$current_time = current_time('timestamp');
1419
+			$dates        = $this->get_dates($args);
1420 1420
 
1421 1421
 			/**
1422 1422
 			 *  Switch case for date query argument
@@ -1427,27 +1427,27 @@  discard block
 block discarded – undo
1427 1427
 			 * @params date startdate | required when date = range and format to be YYYYMMDD (i.e. 20170524)
1428 1428
 			 * @params date enddate | required when date = range and format to be YYYYMMDD (i.e. 20170524)
1429 1429
 			 */
1430
-			switch ( $wp_query->query_vars['date'] ) {
1430
+			switch ($wp_query->query_vars['date']) {
1431 1431
 
1432 1432
 				case 'today':
1433 1433
 
1434 1434
 					// Set and Format Start and End Date to be date of today.
1435
-					$start_date = $end_date = date( 'Y/m/d', $current_time );
1435
+					$start_date = $end_date = date('Y/m/d', $current_time);
1436 1436
 
1437 1437
 					break;
1438 1438
 
1439 1439
 				case 'yesterday':
1440 1440
 
1441 1441
 					// Set and Format Start and End Date to be date of yesterday.
1442
-					$start_date = $end_date = date( 'Y/m', $current_time ) . '/' . ( date( 'd', $current_time ) - 1 );
1442
+					$start_date = $end_date = date('Y/m', $current_time).'/'.(date('d', $current_time) - 1);
1443 1443
 
1444 1444
 					break;
1445 1445
 
1446 1446
 				case 'range':
1447 1447
 
1448 1448
 					// Format Start Date and End Date for filtering payment based on date range.
1449
-					$start_date = $dates['year'] . '/' . $dates['m_start'] . '/' . $dates['day_start'];
1450
-					$end_date   = $dates['year_end'] . '/' . $dates['m_end'] . '/' . $dates['day_end'];
1449
+					$start_date = $dates['year'].'/'.$dates['m_start'].'/'.$dates['day_start'];
1450
+					$end_date   = $dates['year_end'].'/'.$dates['m_end'].'/'.$dates['day_end'];
1451 1451
 
1452 1452
 					break;
1453 1453
 
@@ -1462,7 +1462,7 @@  discard block
 block discarded – undo
1462 1462
 				'status'     => 'publish',
1463 1463
 			);
1464 1464
 
1465
-			$query = give_get_payments( $args );
1465
+			$query = give_get_payments($args);
1466 1466
 		} else {
1467 1467
 			$args  = array(
1468 1468
 				'fields' => 'ids',
@@ -1470,14 +1470,14 @@  discard block
 block discarded – undo
1470 1470
 				'page'   => $this->get_paged(),
1471 1471
 				'status' => 'publish',
1472 1472
 			);
1473
-			$query = give_get_payments( $args );
1473
+			$query = give_get_payments($args);
1474 1474
 		}// End if().
1475
-		if ( $query ) {
1475
+		if ($query) {
1476 1476
 			$i = 0;
1477
-			foreach ( $query as $payment ) {
1477
+			foreach ($query as $payment) {
1478 1478
 
1479
-				if ( is_numeric( $payment ) ) {
1480
-					$payment      = new Give_Payment( $payment );
1479
+				if (is_numeric($payment)) {
1480
+					$payment      = new Give_Payment($payment);
1481 1481
 					$payment_meta = $payment->get_meta();
1482 1482
 					$user_info    = $payment->user_info;
1483 1483
 				} else {
@@ -1487,40 +1487,40 @@  discard block
 block discarded – undo
1487 1487
 				$payment_meta = $payment->get_meta();
1488 1488
 				$user_info    = $payment->user_info;
1489 1489
 
1490
-				$first_name = isset( $user_info['first_name'] ) ? $user_info['first_name'] : '';
1491
-				$last_name  = isset( $user_info['last_name'] ) ? $user_info['last_name'] : '';
1492
-
1493
-				$sales['donations'][ $i ]['ID']             = $payment->number;
1494
-				$sales['donations'][ $i ]['transaction_id'] = $payment->transaction_id;
1495
-				$sales['donations'][ $i ]['key']            = $payment->key;
1496
-				$sales['donations'][ $i ]['total']          = $payment->total;
1497
-				$sales['donations'][ $i ]['gateway']        = $payment->gateway;
1498
-				$sales['donations'][ $i ]['name']           = $first_name . ' ' . $last_name;
1499
-				$sales['donations'][ $i ]['fname']          = $first_name;
1500
-				$sales['donations'][ $i ]['lname']          = $last_name;
1501
-				$sales['donations'][ $i ]['email']          = $payment->email;
1502
-				$sales['donations'][ $i ]['date']           = $payment->date;
1503
-
1504
-				$form_id  = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : $payment_meta;
1505
-				$price    = isset( $payment_meta['form_id'] ) ? give_get_form_price( $payment_meta['form_id'] ) : false;
1506
-				$price_id = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null;
1507
-
1508
-				$sales['donations'][ $i ]['form']['id']    = $form_id;
1509
-				$sales['donations'][ $i ]['form']['name']  = get_the_title( $payment_meta['form_id'] );
1510
-				$sales['donations'][ $i ]['form']['price'] = $price;
1511
-
1512
-				if ( give_has_variable_prices( $form_id ) ) {
1513
-					if ( isset( $payment_meta['price_id'] ) ) {
1514
-						$price_name                                     = give_get_price_option_name( $form_id, $payment_meta['price_id'], $payment->ID );
1515
-						$sales['donations'][ $i ]['form']['price_name'] = $price_name;
1516
-						$sales['donations'][ $i ]['form']['price_id']   = $price_id;
1517
-						$sales['donations'][ $i ]['form']['price']      = give_get_price_option_amount( $form_id, $price_id );
1490
+				$first_name = isset($user_info['first_name']) ? $user_info['first_name'] : '';
1491
+				$last_name  = isset($user_info['last_name']) ? $user_info['last_name'] : '';
1492
+
1493
+				$sales['donations'][$i]['ID']             = $payment->number;
1494
+				$sales['donations'][$i]['transaction_id'] = $payment->transaction_id;
1495
+				$sales['donations'][$i]['key']            = $payment->key;
1496
+				$sales['donations'][$i]['total']          = $payment->total;
1497
+				$sales['donations'][$i]['gateway']        = $payment->gateway;
1498
+				$sales['donations'][$i]['name']           = $first_name.' '.$last_name;
1499
+				$sales['donations'][$i]['fname']          = $first_name;
1500
+				$sales['donations'][$i]['lname']          = $last_name;
1501
+				$sales['donations'][$i]['email']          = $payment->email;
1502
+				$sales['donations'][$i]['date']           = $payment->date;
1503
+
1504
+				$form_id  = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : $payment_meta;
1505
+				$price    = isset($payment_meta['form_id']) ? give_get_form_price($payment_meta['form_id']) : false;
1506
+				$price_id = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null;
1507
+
1508
+				$sales['donations'][$i]['form']['id']    = $form_id;
1509
+				$sales['donations'][$i]['form']['name']  = get_the_title($payment_meta['form_id']);
1510
+				$sales['donations'][$i]['form']['price'] = $price;
1511
+
1512
+				if (give_has_variable_prices($form_id)) {
1513
+					if (isset($payment_meta['price_id'])) {
1514
+						$price_name                                     = give_get_price_option_name($form_id, $payment_meta['price_id'], $payment->ID);
1515
+						$sales['donations'][$i]['form']['price_name'] = $price_name;
1516
+						$sales['donations'][$i]['form']['price_id']   = $price_id;
1517
+						$sales['donations'][$i]['form']['price']      = give_get_price_option_amount($form_id, $price_id);
1518 1518
 
1519 1519
 					}
1520 1520
 				}
1521 1521
 
1522 1522
 				// Add custom meta to API
1523
-				foreach ( $payment_meta as $meta_key => $meta_value ) {
1523
+				foreach ($payment_meta as $meta_key => $meta_value) {
1524 1524
 
1525 1525
 					$exceptions = array(
1526 1526
 						'form_title',
@@ -1533,19 +1533,19 @@  discard block
 block discarded – undo
1533 1533
 					);
1534 1534
 
1535 1535
 					// Don't clutter up results with dupes
1536
-					if ( in_array( $meta_key, $exceptions ) ) {
1536
+					if (in_array($meta_key, $exceptions)) {
1537 1537
 						continue;
1538 1538
 					}
1539 1539
 
1540
-					$sales['donations'][ $i ]['payment_meta'][ $meta_key ] = $meta_value;
1540
+					$sales['donations'][$i]['payment_meta'][$meta_key] = $meta_value;
1541 1541
 
1542 1542
 				}
1543 1543
 
1544
-				$i ++;
1544
+				$i++;
1545 1545
 			}// End foreach().
1546 1546
 		}// End if().
1547 1547
 
1548
-		return apply_filters( 'give_api_donations_endpoint', $sales );
1548
+		return apply_filters('give_api_donations_endpoint', $sales);
1549 1549
 	}
1550 1550
 
1551 1551
 	/**
@@ -1561,9 +1561,9 @@  discard block
 block discarded – undo
1561 1561
 	public function get_output_format() {
1562 1562
 		global $wp_query;
1563 1563
 
1564
-		$format = isset( $wp_query->query_vars['format'] ) ? $wp_query->query_vars['format'] : 'json';
1564
+		$format = isset($wp_query->query_vars['format']) ? $wp_query->query_vars['format'] : 'json';
1565 1565
 
1566
-		return apply_filters( 'give_api_output_format', $format );
1566
+		return apply_filters('give_api_output_format', $format);
1567 1567
 	}
1568 1568
 
1569 1569
 
@@ -1580,8 +1580,8 @@  discard block
 block discarded – undo
1580 1580
 	 *
1581 1581
 	 * @return void
1582 1582
 	 */
1583
-	private function log_request( $data = array() ) {
1584
-		if ( ! $this->log_requests ) {
1583
+	private function log_request($data = array()) {
1584
+		if ( ! $this->log_requests) {
1585 1585
 			return;
1586 1586
 		}
1587 1587
 
@@ -1597,36 +1597,36 @@  discard block
 block discarded – undo
1597 1597
 
1598 1598
 		$query = array(
1599 1599
 			'give-api'    => $wp_query->query_vars['give-api'],
1600
-			'key'         => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null,
1601
-			'token'       => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null,
1602
-			'query'       => isset( $wp_query->query_vars['query'] ) ? $wp_query->query_vars['query'] : null,
1603
-			'type'        => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null,
1604
-			'form'        => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null,
1605
-			'donor'       => isset( $wp_query->query_vars['donor'] ) ? $wp_query->query_vars['donor'] : null,
1606
-			'date'        => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null,
1607
-			'startdate'   => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null,
1608
-			'enddate'     => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null,
1609
-			'id'          => isset( $wp_query->query_vars['id'] ) ? $wp_query->query_vars['id'] : null,
1610
-			'purchasekey' => isset( $wp_query->query_vars['purchasekey'] ) ? $wp_query->query_vars['purchasekey'] : null,
1611
-			'email'       => isset( $wp_query->query_vars['email'] ) ? $wp_query->query_vars['email'] : null,
1600
+			'key'         => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null,
1601
+			'token'       => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null,
1602
+			'query'       => isset($wp_query->query_vars['query']) ? $wp_query->query_vars['query'] : null,
1603
+			'type'        => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null,
1604
+			'form'        => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null,
1605
+			'donor'       => isset($wp_query->query_vars['donor']) ? $wp_query->query_vars['donor'] : null,
1606
+			'date'        => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null,
1607
+			'startdate'   => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null,
1608
+			'enddate'     => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null,
1609
+			'id'          => isset($wp_query->query_vars['id']) ? $wp_query->query_vars['id'] : null,
1610
+			'purchasekey' => isset($wp_query->query_vars['purchasekey']) ? $wp_query->query_vars['purchasekey'] : null,
1611
+			'email'       => isset($wp_query->query_vars['email']) ? $wp_query->query_vars['email'] : null,
1612 1612
 		);
1613 1613
 
1614 1614
 		$log_data = array(
1615 1615
 			'log_type'     => 'api_request',
1616
-			'post_excerpt' => http_build_query( $query ),
1617
-			'post_content' => ! empty( $data['error'] ) ? $data['error'] : '',
1616
+			'post_excerpt' => http_build_query($query),
1617
+			'post_content' => ! empty($data['error']) ? $data['error'] : '',
1618 1618
 		);
1619 1619
 
1620 1620
 		$log_meta = array(
1621 1621
 			'request_ip' => give_get_ip(),
1622 1622
 			'user'       => $this->user_id,
1623
-			'key'        => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null,
1624
-			'token'      => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null,
1623
+			'key'        => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null,
1624
+			'token'      => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null,
1625 1625
 			'time'       => $data['request_speed'],
1626 1626
 			'version'    => $this->get_queried_version(),
1627 1627
 		);
1628 1628
 
1629
-		$give_logs->insert_log( $log_data, $log_meta );
1629
+		$give_logs->insert_log($log_data, $log_meta);
1630 1630
 	}
1631 1631
 
1632 1632
 
@@ -1650,11 +1650,11 @@  discard block
 block discarded – undo
1650 1650
 	 *
1651 1651
 	 * @param int       $status_code
1652 1652
 	 */
1653
-	public function output( $status_code = 200 ) {
1653
+	public function output($status_code = 200) {
1654 1654
 
1655 1655
 		$format = $this->get_output_format();
1656 1656
 
1657
-		status_header( $status_code );
1657
+		status_header($status_code);
1658 1658
 
1659 1659
 		/**
1660 1660
 		 * Fires before outputting the API.
@@ -1665,25 +1665,25 @@  discard block
 block discarded – undo
1665 1665
 		 * @param Give_API $this   The Give_API object.
1666 1666
 		 * @param string   $format Output format, XML or JSON. Default is JSON.
1667 1667
 		 */
1668
-		do_action( 'give_api_output_before', $this->data, $this, $format );
1668
+		do_action('give_api_output_before', $this->data, $this, $format);
1669 1669
 
1670
-		switch ( $format ) :
1670
+		switch ($format) :
1671 1671
 
1672 1672
 			case 'xml' :
1673 1673
 
1674
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/array2xml.php';
1675
-				$xml = Array2XML::createXML( 'give', $this->data );
1674
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/array2xml.php';
1675
+				$xml = Array2XML::createXML('give', $this->data);
1676 1676
 				echo $xml->saveXML();
1677 1677
 
1678 1678
 				break;
1679 1679
 
1680 1680
 			case 'json' :
1681 1681
 
1682
-				header( 'Content-Type: application/json' );
1683
-				if ( ! empty( $this->pretty_print ) ) {
1684
-					echo json_encode( $this->data, $this->pretty_print );
1682
+				header('Content-Type: application/json');
1683
+				if ( ! empty($this->pretty_print)) {
1684
+					echo json_encode($this->data, $this->pretty_print);
1685 1685
 				} else {
1686
-					echo json_encode( $this->data );
1686
+					echo json_encode($this->data);
1687 1687
 				}
1688 1688
 
1689 1689
 				break;
@@ -1698,7 +1698,7 @@  discard block
 block discarded – undo
1698 1698
 				 * @param array    $data Response data to return.
1699 1699
 				 * @param Give_API $this The Give_API object.
1700 1700
 				 */
1701
-				do_action( "give_api_output_{$format}", $this->data, $this );
1701
+				do_action("give_api_output_{$format}", $this->data, $this);
1702 1702
 
1703 1703
 				break;
1704 1704
 
@@ -1713,7 +1713,7 @@  discard block
 block discarded – undo
1713 1713
 		 * @param Give_API $this   The Give_API object.
1714 1714
 		 * @param string   $format Output format, XML or JSON. Default is JSON.
1715 1715
 		 */
1716
-		do_action( 'give_api_output_after', $this->data, $this, $format );
1716
+		do_action('give_api_output_after', $this->data, $this, $format);
1717 1717
 
1718 1718
 		give_die();
1719 1719
 	}
@@ -1730,40 +1730,40 @@  discard block
 block discarded – undo
1730 1730
 	 *
1731 1731
 	 * @return void
1732 1732
 	 */
1733
-	function user_key_field( $user ) {
1733
+	function user_key_field($user) {
1734 1734
 
1735
-		if ( ( give_get_option( 'api_allow_user_keys', false ) || current_user_can( 'manage_give_settings' ) ) && current_user_can( 'edit_user', $user->ID ) ) {
1736
-			$user = get_userdata( $user->ID );
1735
+		if ((give_get_option('api_allow_user_keys', false) || current_user_can('manage_give_settings')) && current_user_can('edit_user', $user->ID)) {
1736
+			$user = get_userdata($user->ID);
1737 1737
 			?>
1738 1738
 			<table class="form-table">
1739 1739
 				<tbody>
1740 1740
 				<tr>
1741 1741
 					<th>
1742
-						<?php esc_html_e( 'Give API Keys', 'give' ); ?>
1742
+						<?php esc_html_e('Give API Keys', 'give'); ?>
1743 1743
 					</th>
1744 1744
 					<td>
1745 1745
 						<?php
1746
-						$public_key = $this->get_user_public_key( $user->ID );
1747
-						$secret_key = $this->get_user_secret_key( $user->ID );
1746
+						$public_key = $this->get_user_public_key($user->ID);
1747
+						$secret_key = $this->get_user_secret_key($user->ID);
1748 1748
 						?>
1749
-						<?php if ( empty( $user->give_user_public_key ) ) { ?>
1749
+						<?php if (empty($user->give_user_public_key)) { ?>
1750 1750
 							<input name="give_set_api_key" type="checkbox" id="give_set_api_key" value="0"/>
1751
-							<span class="description"><?php esc_html_e( 'Generate API Key', 'give' ); ?></span>
1751
+							<span class="description"><?php esc_html_e('Generate API Key', 'give'); ?></span>
1752 1752
 						<?php } else { ?>
1753
-							<strong style="display:inline-block; width: 125px;"><?php esc_html_e( 'Public key:', 'give' ); ?>
1753
+							<strong style="display:inline-block; width: 125px;"><?php esc_html_e('Public key:', 'give'); ?>
1754 1754
 								&nbsp;</strong>
1755
-							<input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr( $public_key ); ?>"/>
1755
+							<input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr($public_key); ?>"/>
1756 1756
 							<br/>
1757
-							<strong style="display:inline-block; width: 125px;"><?php esc_html_e( 'Secret key:', 'give' ); ?>
1757
+							<strong style="display:inline-block; width: 125px;"><?php esc_html_e('Secret key:', 'give'); ?>
1758 1758
 								&nbsp;</strong>
1759
-							<input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr( $secret_key ); ?>"/>
1759
+							<input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr($secret_key); ?>"/>
1760 1760
 							<br/>
1761
-							<strong style="display:inline-block; width: 125px;"><?php esc_html_e( 'Token:', 'give' ); ?>
1761
+							<strong style="display:inline-block; width: 125px;"><?php esc_html_e('Token:', 'give'); ?>
1762 1762
 								&nbsp;</strong>
1763
-							<input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr( $this->get_token( $user->ID ) ); ?>"/>
1763
+							<input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr($this->get_token($user->ID)); ?>"/>
1764 1764
 							<br/>
1765 1765
 							<input name="give_set_api_key" type="checkbox" id="give_set_api_key" value="0"/>
1766
-							<span class="description"><label for="give_set_api_key"><?php esc_html_e( 'Revoke API Keys', 'give' ); ?></label></span>
1766
+							<span class="description"><label for="give_set_api_key"><?php esc_html_e('Revoke API Keys', 'give'); ?></label></span>
1767 1767
 						<?php } ?>
1768 1768
 					</td>
1769 1769
 				</tr>
@@ -1782,61 +1782,61 @@  discard block
 block discarded – undo
1782 1782
 	 *
1783 1783
 	 * @return void
1784 1784
 	 */
1785
-	public function process_api_key( $args ) {
1785
+	public function process_api_key($args) {
1786 1786
 
1787
-		if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'give-api-nonce' ) ) {
1788
-			wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ), array(
1787
+		if ( ! wp_verify_nonce($_REQUEST['_wpnonce'], 'give-api-nonce')) {
1788
+			wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'), array(
1789 1789
 				'response' => 403,
1790
-			) );
1790
+			));
1791 1791
 		}
1792 1792
 
1793
-		if ( empty( $args['user_id'] ) ) {
1794
-			wp_die( __( 'User ID Required.', 'give' ), __( 'Error', 'give' ), array(
1793
+		if (empty($args['user_id'])) {
1794
+			wp_die(__('User ID Required.', 'give'), __('Error', 'give'), array(
1795 1795
 				'response' => 401,
1796
-			) );
1796
+			));
1797 1797
 		}
1798 1798
 
1799
-		if ( is_numeric( $args['user_id'] ) ) {
1800
-			$user_id = isset( $args['user_id'] ) ? absint( $args['user_id'] ) : get_current_user_id();
1799
+		if (is_numeric($args['user_id'])) {
1800
+			$user_id = isset($args['user_id']) ? absint($args['user_id']) : get_current_user_id();
1801 1801
 		} else {
1802
-			$userdata = get_user_by( 'login', $args['user_id'] );
1802
+			$userdata = get_user_by('login', $args['user_id']);
1803 1803
 			$user_id  = $userdata->ID;
1804 1804
 		}
1805
-		$process = isset( $args['give_api_process'] ) ? strtolower( $args['give_api_process'] ) : false;
1805
+		$process = isset($args['give_api_process']) ? strtolower($args['give_api_process']) : false;
1806 1806
 
1807
-		if ( $user_id == get_current_user_id() && ! give_get_option( 'allow_user_api_keys' ) && ! current_user_can( 'manage_give_settings' ) ) {
1808
-			wp_die( sprintf( /* translators: %s: process */
1809
-				esc_html__( 'You do not have permission to %s API keys for this user.', 'give' ), $process ), esc_html__( 'Error', 'give' ), array(
1807
+		if ($user_id == get_current_user_id() && ! give_get_option('allow_user_api_keys') && ! current_user_can('manage_give_settings')) {
1808
+			wp_die(sprintf( /* translators: %s: process */
1809
+				esc_html__('You do not have permission to %s API keys for this user.', 'give'), $process ), esc_html__('Error', 'give'), array(
1810 1810
 				'response' => 403,
1811
-			) );
1812
-		} elseif ( ! current_user_can( 'manage_give_settings' ) ) {
1813
-			wp_die( sprintf( /* translators: %s: process */
1814
-				esc_html__( 'You do not have permission to %s API keys for this user.', 'give' ), $process ), esc_html__( 'Error', 'give' ), array(
1811
+			));
1812
+		} elseif ( ! current_user_can('manage_give_settings')) {
1813
+			wp_die(sprintf( /* translators: %s: process */
1814
+				esc_html__('You do not have permission to %s API keys for this user.', 'give'), $process ), esc_html__('Error', 'give'), array(
1815 1815
 				'response' => 403,
1816
-			) );
1816
+			));
1817 1817
 		}
1818 1818
 
1819
-		switch ( $process ) {
1819
+		switch ($process) {
1820 1820
 			case 'generate':
1821
-				if ( $this->generate_api_key( $user_id ) ) {
1822
-					Give_Cache::delete( Give_Cache::get_key( 'give_total_api_keys' ) );
1823
-					wp_redirect( add_query_arg( 'give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) );
1821
+				if ($this->generate_api_key($user_id)) {
1822
+					Give_Cache::delete(Give_Cache::get_key('give_total_api_keys'));
1823
+					wp_redirect(add_query_arg('give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-tools&tab=api'));
1824 1824
 					exit();
1825 1825
 				} else {
1826
-					wp_redirect( add_query_arg( 'give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) );
1826
+					wp_redirect(add_query_arg('give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-tools&tab=api'));
1827 1827
 					exit();
1828 1828
 				}
1829 1829
 				break;
1830 1830
 			case 'regenerate':
1831
-				$this->generate_api_key( $user_id, true );
1832
-				Give_Cache::delete( Give_Cache::get_key( 'give_total_api_keys' ) );
1833
-				wp_redirect( add_query_arg( 'give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) );
1831
+				$this->generate_api_key($user_id, true);
1832
+				Give_Cache::delete(Give_Cache::get_key('give_total_api_keys'));
1833
+				wp_redirect(add_query_arg('give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-tools&tab=api'));
1834 1834
 				exit();
1835 1835
 				break;
1836 1836
 			case 'revoke':
1837
-				$this->revoke_api_key( $user_id );
1838
-				Give_Cache::delete( Give_Cache::get_key( 'give_total_api_keys' ) );
1839
-				wp_redirect( add_query_arg( 'give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-tools&tab=api' ) );
1837
+				$this->revoke_api_key($user_id);
1838
+				Give_Cache::delete(Give_Cache::get_key('give_total_api_keys'));
1839
+				wp_redirect(add_query_arg('give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-tools&tab=api'));
1840 1840
 				exit();
1841 1841
 				break;
1842 1842
 			default;
@@ -1855,34 +1855,34 @@  discard block
 block discarded – undo
1855 1855
 	 *
1856 1856
 	 * @return boolean True if (re)generated succesfully, false otherwise.
1857 1857
 	 */
1858
-	public function generate_api_key( $user_id = 0, $regenerate = false ) {
1858
+	public function generate_api_key($user_id = 0, $regenerate = false) {
1859 1859
 
1860
-		if ( empty( $user_id ) ) {
1860
+		if (empty($user_id)) {
1861 1861
 			return false;
1862 1862
 		}
1863 1863
 
1864
-		$user = get_userdata( $user_id );
1864
+		$user = get_userdata($user_id);
1865 1865
 
1866
-		if ( ! $user ) {
1866
+		if ( ! $user) {
1867 1867
 			return false;
1868 1868
 		}
1869 1869
 
1870
-		$public_key = $this->get_user_public_key( $user_id );
1871
-		$secret_key = $this->get_user_secret_key( $user_id );
1870
+		$public_key = $this->get_user_public_key($user_id);
1871
+		$secret_key = $this->get_user_secret_key($user_id);
1872 1872
 
1873
-		if ( empty( $public_key ) || $regenerate == true ) {
1874
-			$new_public_key = $this->generate_public_key( $user->user_email );
1875
-			$new_secret_key = $this->generate_private_key( $user->ID );
1873
+		if (empty($public_key) || $regenerate == true) {
1874
+			$new_public_key = $this->generate_public_key($user->user_email);
1875
+			$new_secret_key = $this->generate_private_key($user->ID);
1876 1876
 		} else {
1877 1877
 			return false;
1878 1878
 		}
1879 1879
 
1880
-		if ( $regenerate == true ) {
1881
-			$this->revoke_api_key( $user->ID );
1880
+		if ($regenerate == true) {
1881
+			$this->revoke_api_key($user->ID);
1882 1882
 		}
1883 1883
 
1884
-		update_user_meta( $user_id, $new_public_key, 'give_user_public_key' );
1885
-		update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' );
1884
+		update_user_meta($user_id, $new_public_key, 'give_user_public_key');
1885
+		update_user_meta($user_id, $new_secret_key, 'give_user_secret_key');
1886 1886
 
1887 1887
 		return true;
1888 1888
 	}
@@ -1897,26 +1897,26 @@  discard block
 block discarded – undo
1897 1897
 	 *
1898 1898
 	 * @return bool
1899 1899
 	 */
1900
-	public function revoke_api_key( $user_id = 0 ) {
1900
+	public function revoke_api_key($user_id = 0) {
1901 1901
 
1902
-		if ( empty( $user_id ) ) {
1902
+		if (empty($user_id)) {
1903 1903
 			return false;
1904 1904
 		}
1905 1905
 
1906
-		$user = get_userdata( $user_id );
1906
+		$user = get_userdata($user_id);
1907 1907
 
1908
-		if ( ! $user ) {
1908
+		if ( ! $user) {
1909 1909
 			return false;
1910 1910
 		}
1911 1911
 
1912
-		$public_key = $this->get_user_public_key( $user_id );
1913
-		$secret_key = $this->get_user_secret_key( $user_id );
1914
-		if ( ! empty( $public_key ) ) {
1915
-			Give_Cache::delete( Give_Cache::get_key( md5( 'give_api_user_' . $public_key ) ) );
1916
-			Give_Cache::delete( Give_Cache::get_key( md5( 'give_api_user_public_key' . $user_id ) ) );
1917
-			Give_Cache::delete( Give_Cache::get_key( md5( 'give_api_user_secret_key' . $user_id ) ) );
1918
-			delete_user_meta( $user_id, $public_key );
1919
-			delete_user_meta( $user_id, $secret_key );
1912
+		$public_key = $this->get_user_public_key($user_id);
1913
+		$secret_key = $this->get_user_secret_key($user_id);
1914
+		if ( ! empty($public_key)) {
1915
+			Give_Cache::delete(Give_Cache::get_key(md5('give_api_user_'.$public_key)));
1916
+			Give_Cache::delete(Give_Cache::get_key(md5('give_api_user_public_key'.$user_id)));
1917
+			Give_Cache::delete(Give_Cache::get_key(md5('give_api_user_secret_key'.$user_id)));
1918
+			delete_user_meta($user_id, $public_key);
1919
+			delete_user_meta($user_id, $secret_key);
1920 1920
 		} else {
1921 1921
 			return false;
1922 1922
 		}
@@ -1941,22 +1941,22 @@  discard block
 block discarded – undo
1941 1941
 	 *
1942 1942
 	 * @return void
1943 1943
 	 */
1944
-	public function update_key( $user_id ) {
1945
-		if ( current_user_can( 'edit_user', $user_id ) && isset( $_POST['give_set_api_key'] ) ) {
1944
+	public function update_key($user_id) {
1945
+		if (current_user_can('edit_user', $user_id) && isset($_POST['give_set_api_key'])) {
1946 1946
 
1947
-			$user = get_userdata( $user_id );
1947
+			$user = get_userdata($user_id);
1948 1948
 
1949
-			$public_key = $this->get_user_public_key( $user_id );
1950
-			$secret_key = $this->get_user_secret_key( $user_id );
1949
+			$public_key = $this->get_user_public_key($user_id);
1950
+			$secret_key = $this->get_user_secret_key($user_id);
1951 1951
 
1952
-			if ( empty( $public_key ) ) {
1953
-				$new_public_key = $this->generate_public_key( $user->user_email );
1954
-				$new_secret_key = $this->generate_private_key( $user->ID );
1952
+			if (empty($public_key)) {
1953
+				$new_public_key = $this->generate_public_key($user->user_email);
1954
+				$new_secret_key = $this->generate_private_key($user->ID);
1955 1955
 
1956
-				update_user_meta( $user_id, $new_public_key, 'give_user_public_key' );
1957
-				update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' );
1956
+				update_user_meta($user_id, $new_public_key, 'give_user_public_key');
1957
+				update_user_meta($user_id, $new_secret_key, 'give_user_secret_key');
1958 1958
 			} else {
1959
-				$this->revoke_api_key( $user_id );
1959
+				$this->revoke_api_key($user_id);
1960 1960
 			}
1961 1961
 		}
1962 1962
 	}
@@ -1971,9 +1971,9 @@  discard block
 block discarded – undo
1971 1971
 	 *
1972 1972
 	 * @return string
1973 1973
 	 */
1974
-	private function generate_public_key( $user_email = '' ) {
1975
-		$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
1976
-		$public   = hash( 'md5', $user_email . $auth_key . date( 'U' ) );
1974
+	private function generate_public_key($user_email = '') {
1975
+		$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
1976
+		$public   = hash('md5', $user_email.$auth_key.date('U'));
1977 1977
 
1978 1978
 		return $public;
1979 1979
 	}
@@ -1988,9 +1988,9 @@  discard block
 block discarded – undo
1988 1988
 	 *
1989 1989
 	 * @return string
1990 1990
 	 */
1991
-	private function generate_private_key( $user_id = 0 ) {
1992
-		$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
1993
-		$secret   = hash( 'md5', $user_id . $auth_key . date( 'U' ) );
1991
+	private function generate_private_key($user_id = 0) {
1992
+		$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
1993
+		$secret   = hash('md5', $user_id.$auth_key.date('U'));
1994 1994
 
1995 1995
 		return $secret;
1996 1996
 	}
@@ -2005,8 +2005,8 @@  discard block
 block discarded – undo
2005 2005
 	 *
2006 2006
 	 * @return string
2007 2007
 	 */
2008
-	public function get_token( $user_id = 0 ) {
2009
-		return hash( 'md5', $this->get_user_secret_key( $user_id ) . $this->get_user_public_key( $user_id ) );
2008
+	public function get_token($user_id = 0) {
2009
+		return hash('md5', $this->get_user_secret_key($user_id).$this->get_user_public_key($user_id));
2010 2010
 	}
2011 2011
 
2012 2012
 	/**
@@ -2020,9 +2020,9 @@  discard block
 block discarded – undo
2020 2020
 
2021 2021
 		// Default sales return
2022 2022
 		$sales                               = array();
2023
-		$sales['donations']['today']         = $this->stats->get_sales( 0, 'today' );
2024
-		$sales['donations']['current_month'] = $this->stats->get_sales( 0, 'this_month' );
2025
-		$sales['donations']['last_month']    = $this->stats->get_sales( 0, 'last_month' );
2023
+		$sales['donations']['today']         = $this->stats->get_sales(0, 'today');
2024
+		$sales['donations']['current_month'] = $this->stats->get_sales(0, 'this_month');
2025
+		$sales['donations']['last_month']    = $this->stats->get_sales(0, 'last_month');
2026 2026
 		$sales['donations']['totals']        = give_get_total_donations();
2027 2027
 
2028 2028
 		return $sales;
@@ -2039,9 +2039,9 @@  discard block
 block discarded – undo
2039 2039
 
2040 2040
 		// Default earnings return
2041 2041
 		$earnings                              = array();
2042
-		$earnings['earnings']['today']         = $this->stats->get_earnings( 0, 'today' );
2043
-		$earnings['earnings']['current_month'] = $this->stats->get_earnings( 0, 'this_month' );
2044
-		$earnings['earnings']['last_month']    = $this->stats->get_earnings( 0, 'last_month' );
2042
+		$earnings['earnings']['today']         = $this->stats->get_earnings(0, 'today');
2043
+		$earnings['earnings']['current_month'] = $this->stats->get_earnings(0, 'this_month');
2044
+		$earnings['earnings']['last_month']    = $this->stats->get_earnings(0, 'last_month');
2045 2045
 		$earnings['earnings']['totals']        = give_get_total_earnings();
2046 2046
 
2047 2047
 		return $earnings;
@@ -2061,25 +2061,25 @@  discard block
 block discarded – undo
2061 2061
 	 *
2062 2062
 	 * @return string            The API key/secret for the user supplied
2063 2063
 	 */
2064
-	public function api_key_backwards_compat( $check, $object_id, $meta_key, $single ) {
2064
+	public function api_key_backwards_compat($check, $object_id, $meta_key, $single) {
2065 2065
 
2066
-		if ( $meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key' ) {
2066
+		if ($meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key') {
2067 2067
 			return $check;
2068 2068
 		}
2069 2069
 
2070 2070
 		$return = $check;
2071 2071
 
2072
-		switch ( $meta_key ) {
2072
+		switch ($meta_key) {
2073 2073
 			case 'give_user_public_key':
2074
-				$return = Give()->api->get_user_public_key( $object_id );
2074
+				$return = Give()->api->get_user_public_key($object_id);
2075 2075
 				break;
2076 2076
 			case 'give_user_secret_key':
2077
-				$return = Give()->api->get_user_secret_key( $object_id );
2077
+				$return = Give()->api->get_user_secret_key($object_id);
2078 2078
 				break;
2079 2079
 		}
2080 2080
 
2081
-		if ( ! $single ) {
2082
-			$return = array( $return );
2081
+		if ( ! $single) {
2082
+			$return = array($return);
2083 2083
 		}
2084 2084
 
2085 2085
 		return $return;
Please login to merge, or discard this patch.
includes/process-donation.php 1 patch
Spacing   +239 added lines, -239 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_donation' );
33
+	do_action('give_pre_process_donation');
34 34
 
35 35
 	// Validate the form $_POST data
36 36
 	$valid_data = give_donation_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_donation_form_user( $valid_data );
58
+	$user = give_get_donation_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_donation_errors' );
67
+			do_action('give_ajax_donation_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
 	$donation_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 ( ! $donation_data['price'] ) {
134
+	if ( ! $donation_data['price']) {
135 135
 		// Revert to manual
136 136
 		$donation_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
-	$donation_data = apply_filters( 'give_donation_data_before_gateway', $donation_data, $valid_data );
145
+	$donation_data = apply_filters('give_donation_data_before_gateway', $donation_data, $valid_data);
146 146
 
147 147
 	// Setup the data we're storing in the donation session
148 148
 	$session_data = $donation_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( $donation_data['gateway'], $donation_data );
158
+	give_send_to_gateway($donation_data['gateway'], $donation_data);
159 159
 	give_die();
160 160
 
161 161
 }
162 162
 
163
-add_action( 'give_purchase', 'give_process_donation_form' );
164
-add_action( 'wp_ajax_give_process_donation', 'give_process_donation_form' );
165
-add_action( 'wp_ajax_nopriv_give_process_donation', 'give_process_donation_form' );
163
+add_action('give_purchase', 'give_process_donation_form');
164
+add_action('wp_ajax_give_process_donation', 'give_process_donation_form');
165
+add_action('wp_ajax_nopriv_give_process_donation', 'give_process_donation_form');
166 166
 
167 167
 
168 168
 /**
@@ -175,29 +175,29 @@  discard block
 block discarded – undo
175 175
  *
176 176
  * @return void
177 177
  */
178
-function give_check_logged_in_user_for_existing_email( $valid_data, $post ) {
178
+function give_check_logged_in_user_for_existing_email($valid_data, $post) {
179 179
 
180 180
 	// Verify that the email address belongs to this customer.
181
-	if ( is_user_logged_in() ) {
181
+	if (is_user_logged_in()) {
182 182
 
183
-		$submitted_email    = $valid_data['logged_in_user']['user_email'];
184
-		$customer = new Give_Donor( get_current_user_id(), true );
183
+		$submitted_email = $valid_data['logged_in_user']['user_email'];
184
+		$customer = new Give_Donor(get_current_user_id(), true);
185 185
 
186 186
 		// If this email address is not registered with this customer, see if it belongs to any other customer
187 187
 		if (
188 188
 			$submitted_email !== $customer->email
189
-			&& ( is_array( $customer->emails ) && ! in_array( $submitted_email, $customer->emails ) )
189
+			&& (is_array($customer->emails) && ! in_array($submitted_email, $customer->emails))
190 190
 		) {
191
-			$found_customer = new Give_Donor( $submitted_email );
191
+			$found_customer = new Give_Donor($submitted_email);
192 192
 
193
-			if ( $found_customer->id > 0 ) {
194
-				give_set_error( 'give-customer-email-exists', sprintf( __( 'You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.' ,'give' ), $customer->email, $submitted_email ) );
193
+			if ($found_customer->id > 0) {
194
+				give_set_error('give-customer-email-exists', sprintf(__('You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.', 'give'), $customer->email, $submitted_email));
195 195
 			}
196 196
 		}
197 197
 	}
198 198
 }
199 199
 
200
-add_action( 'give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 2 );
200
+add_action('give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 2);
201 201
 
202 202
 /**
203 203
  * Process the checkout login form
@@ -208,37 +208,37 @@  discard block
 block discarded – undo
208 208
  */
209 209
 function give_process_form_login() {
210 210
 
211
-	$is_ajax = isset( $_POST['give_ajax'] );
211
+	$is_ajax = isset($_POST['give_ajax']);
212 212
 
213 213
 	$user_data = give_donation_form_validate_user_login();
214 214
 
215
-	if ( give_get_errors() || $user_data['user_id'] < 1 ) {
216
-		if ( $is_ajax ) {
215
+	if (give_get_errors() || $user_data['user_id'] < 1) {
216
+		if ($is_ajax) {
217 217
 			/**
218 218
 			 * Fires when AJAX sends back errors from the donation form.
219 219
 			 *
220 220
 			 * @since 1.0
221 221
 			 */
222
-			do_action( 'give_ajax_donation_errors' );
222
+			do_action('give_ajax_donation_errors');
223 223
 			give_die();
224 224
 		} else {
225
-			wp_redirect( $_SERVER['HTTP_REFERER'] );
225
+			wp_redirect($_SERVER['HTTP_REFERER']);
226 226
 			exit;
227 227
 		}
228 228
 	}
229 229
 
230
-	give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] );
230
+	give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']);
231 231
 
232
-	if ( $is_ajax ) {
232
+	if ($is_ajax) {
233 233
 		echo 'success';
234 234
 		give_die();
235 235
 	} else {
236
-		wp_redirect( $_SERVER['HTTP_REFERER'] );
236
+		wp_redirect($_SERVER['HTTP_REFERER']);
237 237
 	}
238 238
 }
239 239
 
240
-add_action( 'wp_ajax_give_process_donation_login', 'give_process_form_login' );
241
-add_action( 'wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login' );
240
+add_action('wp_ajax_give_process_donation_login', 'give_process_form_login');
241
+add_action('wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login');
242 242
 
243 243
 /**
244 244
  * Donation Form Validate Fields.
@@ -250,55 +250,55 @@  discard block
 block discarded – undo
250 250
 function give_donation_form_validate_fields() {
251 251
 
252 252
 	// Check if there is $_POST
253
-	if ( empty( $_POST ) ) {
253
+	if (empty($_POST)) {
254 254
 		return false;
255 255
 	}
256 256
 
257
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
257
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
258 258
 
259 259
 	// Start an array to collect valid data
260 260
 	$valid_data = array(
261 261
 		'gateway'          => give_donation_form_validate_gateway(), // Gateway fallback (amount is validated here)
262
-		'need_new_user'    => false,     // New user flag
263
-		'need_user_login'  => false,     // Login user flag
264
-		'logged_user_data' => array(),   // Logged user collected data
265
-		'new_user_data'    => array(),   // New user collected data
266
-		'login_user_data'  => array(),   // Login user collected data
267
-		'guest_user_data'  => array(),   // Guest user collected data
268
-		'cc_info'          => give_donation_form_validate_cc(),// Credit card info
262
+		'need_new_user'    => false, // New user flag
263
+		'need_user_login'  => false, // Login user flag
264
+		'logged_user_data' => array(), // Logged user collected data
265
+		'new_user_data'    => array(), // New user collected data
266
+		'login_user_data'  => array(), // Login user collected data
267
+		'guest_user_data'  => array(), // Guest user collected data
268
+		'cc_info'          => give_donation_form_validate_cc(), // Credit card info
269 269
 	);
270 270
 
271 271
 	// Validate Honeypot First
272
-	if ( ! empty( $_POST['give-honeypot'] ) ) {
273
-		give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) );
272
+	if ( ! empty($_POST['give-honeypot'])) {
273
+		give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give'));
274 274
 	}
275 275
 
276 276
 	// Validate agree to terms
277
-	if ( give_is_terms_enabled( $form_id ) ) {
277
+	if (give_is_terms_enabled($form_id)) {
278 278
 		give_donation_form_validate_agree_to_terms();
279 279
 	}
280 280
 
281 281
 	// Stop processing donor registration, if donor registration is optional and donor can do guest checkout.
282 282
 	// If registration form username field is empty that means donor do not want to registration instead want guest checkout.
283 283
 	if (
284
-		! give_logged_in_only( $form_id )
285
-		&& isset( $_POST['give-purchase-var'] )
284
+		! give_logged_in_only($form_id)
285
+		&& isset($_POST['give-purchase-var'])
286 286
 		&& $_POST['give-purchase-var'] == 'needs-to-register'
287
-		&& empty( $_POST['give_user_login'] )
287
+		&& empty($_POST['give_user_login'])
288 288
 	) {
289
-		unset( $_POST['give-purchase-var'] );
289
+		unset($_POST['give-purchase-var']);
290 290
 	}
291 291
 
292
-	if ( is_user_logged_in() ) {
292
+	if (is_user_logged_in()) {
293 293
 		// Collect logged in user data.
294 294
 		$valid_data['logged_in_user'] = give_donation_form_validate_logged_in_user();
295
-	} elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' ) {
295
+	} elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register') {
296 296
 		// Set new user registration as required.
297 297
 		$valid_data['need_new_user'] = true;
298 298
 		// Validate new user data.
299 299
 		$valid_data['new_user_data'] = give_donation_form_validate_new_user();
300 300
 		// Check if login validation is needed.
301
-	} elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) {
301
+	} elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') {
302 302
 		// Set user login as required.
303 303
 		$valid_data['need_user_login'] = true;
304 304
 		// Validate users login info.
@@ -323,41 +323,41 @@  discard block
 block discarded – undo
323 323
  */
324 324
 function give_donation_form_validate_gateway() {
325 325
 
326
-	$form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0;
327
-	$amount  = isset( $_REQUEST['give-amount'] ) ? give_sanitize_amount( $_REQUEST['give-amount'] ) : 0;
328
-	$gateway = give_get_default_gateway( $form_id );
326
+	$form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;
327
+	$amount  = isset($_REQUEST['give-amount']) ? give_sanitize_amount($_REQUEST['give-amount']) : 0;
328
+	$gateway = give_get_default_gateway($form_id);
329 329
 
330 330
 	// Check if a gateway value is present.
331
-	if ( ! empty( $_REQUEST['give-gateway'] ) ) {
331
+	if ( ! empty($_REQUEST['give-gateway'])) {
332 332
 
333
-		$gateway = sanitize_text_field( $_REQUEST['give-gateway'] );
333
+		$gateway = sanitize_text_field($_REQUEST['give-gateway']);
334 334
 
335 335
 		// Is amount being donated in LIVE mode 0.00? If so, error:
336
-		if ( $amount == 0 && ! give_is_test_mode() ) {
336
+		if ($amount == 0 && ! give_is_test_mode()) {
337 337
 
338
-			give_set_error( 'invalid_donation_amount', __( 'Please insert a valid donation amount.', 'give' ) );
338
+			give_set_error('invalid_donation_amount', __('Please insert a valid donation amount.', 'give'));
339 339
 
340 340
 		} // End if().
341
-		elseif ( ! give_verify_minimum_price() ) {
341
+		elseif ( ! give_verify_minimum_price()) {
342 342
 			// translators: %s: minimum donation amount.
343 343
 			give_set_error(
344 344
 				'invalid_donation_minimum',
345 345
 				sprintf(
346 346
 					/* translators: %s: minimum donation amount */
347
-					__( 'This form has a minimum donation amount of %s.', 'give' ),
348
-					give_currency_filter( give_format_amount( give_get_form_minimum_price( $form_id ) ) )
347
+					__('This form has a minimum donation amount of %s.', 'give'),
348
+					give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id)))
349 349
 				)
350 350
 			);
351 351
 
352 352
 		} //Is this test mode zero donation? Let it through but set to manual gateway.
353
-		elseif ( $amount == 0 && give_is_test_mode() ) {
353
+		elseif ($amount == 0 && give_is_test_mode()) {
354 354
 
355 355
 			$gateway = 'manual';
356 356
 
357 357
 		} //Check if this gateway is active.
358
-		elseif ( ! give_is_gateway_active( $gateway ) ) {
358
+		elseif ( ! give_is_gateway_active($gateway)) {
359 359
 
360
-			give_set_error( 'invalid_gateway', __( 'The selected payment gateway is not enabled.', 'give' ) );
360
+			give_set_error('invalid_gateway', __('The selected payment gateway is not enabled.', 'give'));
361 361
 
362 362
 		}
363 363
 	}
@@ -375,21 +375,21 @@  discard block
 block discarded – undo
375 375
  */
376 376
 function give_verify_minimum_price() {
377 377
 
378
-	$amount          = give_sanitize_amount( $_REQUEST['give-amount'] );
379
-	$form_id         = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0;
380
-	$price_id        = isset( $_REQUEST['give-price-id'] ) ? $_REQUEST['give-price-id'] : null;
381
-	$variable_prices = give_has_variable_prices( $form_id );
378
+	$amount          = give_sanitize_amount($_REQUEST['give-amount']);
379
+	$form_id         = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;
380
+	$price_id        = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : null;
381
+	$variable_prices = give_has_variable_prices($form_id);
382 382
 
383
-	if ( $variable_prices && in_array( $price_id, give_get_variable_price_ids( $form_id ) ) ) {
383
+	if ($variable_prices && in_array($price_id, give_get_variable_price_ids($form_id))) {
384 384
 
385
-		$price_level_amount = give_get_price_option_amount( $form_id, $price_id );
385
+		$price_level_amount = give_get_price_option_amount($form_id, $price_id);
386 386
 
387
-		if ( $price_level_amount == $amount ) {
387
+		if ($price_level_amount == $amount) {
388 388
 			return true;
389 389
 		}
390 390
 	}
391 391
 
392
-	if ( give_get_form_minimum_price( $form_id ) > $amount ) {
392
+	if (give_get_form_minimum_price($form_id) > $amount) {
393 393
 		return false;
394 394
 	}
395 395
 
@@ -405,9 +405,9 @@  discard block
 block discarded – undo
405 405
  */
406 406
 function give_donation_form_validate_agree_to_terms() {
407 407
 	// Validate agree to terms.
408
-	if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) {
408
+	if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) {
409 409
 		// User did not agree.
410
-		give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', __( 'You must agree to the terms and conditions.', 'give' ) ) );
410
+		give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', __('You must agree to the terms and conditions.', 'give')));
411 411
 	}
412 412
 }
413 413
 
@@ -421,43 +421,43 @@  discard block
 block discarded – undo
421 421
  *
422 422
  * @return      array
423 423
  */
424
-function give_get_required_fields( $form_id ) {
424
+function give_get_required_fields($form_id) {
425 425
 
426
-	$payment_mode = give_get_chosen_gateway( $form_id );
426
+	$payment_mode = give_get_chosen_gateway($form_id);
427 427
 
428 428
 	$required_fields = array(
429 429
 		'give_email' => array(
430 430
 			'error_id'      => 'invalid_email',
431
-			'error_message' => __( 'Please enter a valid email address.', 'give' ),
431
+			'error_message' => __('Please enter a valid email address.', 'give'),
432 432
 		),
433 433
 		'give_first' => array(
434 434
 			'error_id'      => 'invalid_first_name',
435
-			'error_message' => __( 'Please enter your first name.', 'give' ),
435
+			'error_message' => __('Please enter your first name.', 'give'),
436 436
 		),
437 437
 	);
438 438
 
439
-	$require_address = give_require_billing_address( $payment_mode );
439
+	$require_address = give_require_billing_address($payment_mode);
440 440
 
441
-	if ( $require_address ) {
442
-		$required_fields['card_address']    = array(
441
+	if ($require_address) {
442
+		$required_fields['card_address'] = array(
443 443
 			'error_id'      => 'invalid_card_address',
444
-			'error_message' => __( 'Please enter your primary billing address.', 'give' ),
444
+			'error_message' => __('Please enter your primary billing address.', 'give'),
445 445
 		);
446
-		$required_fields['card_zip']        = array(
446
+		$required_fields['card_zip'] = array(
447 447
 			'error_id'      => 'invalid_zip_code',
448
-			'error_message' => __( 'Please enter your zip / postal code.', 'give' ),
448
+			'error_message' => __('Please enter your zip / postal code.', 'give'),
449 449
 		);
450
-		$required_fields['card_city']       = array(
450
+		$required_fields['card_city'] = array(
451 451
 			'error_id'      => 'invalid_city',
452
-			'error_message' => __( 'Please enter your billing city.', 'give' ),
452
+			'error_message' => __('Please enter your billing city.', 'give'),
453 453
 		);
454 454
 		$required_fields['billing_country'] = array(
455 455
 			'error_id'      => 'invalid_country',
456
-			'error_message' => __( 'Please select your billing country.', 'give' ),
456
+			'error_message' => __('Please select your billing country.', 'give'),
457 457
 		);
458
-		$required_fields['card_state']      = array(
458
+		$required_fields['card_state'] = array(
459 459
 			'error_id'      => 'invalid_state',
460
-			'error_message' => __( 'Please enter billing state / province.', 'give' ),
460
+			'error_message' => __('Please enter billing state / province.', 'give'),
461 461
 		);
462 462
 	}
463 463
 
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
 	 *
467 467
 	 * @since 1.7
468 468
 	 */
469
-	$required_fields = apply_filters( 'give_donation_form_required_fields', $required_fields, $form_id );
469
+	$required_fields = apply_filters('give_donation_form_required_fields', $required_fields, $form_id);
470 470
 
471 471
 	return $required_fields;
472 472
 
@@ -481,16 +481,16 @@  discard block
 block discarded – undo
481 481
  *
482 482
  * @return bool
483 483
  */
484
-function give_require_billing_address( $payment_mode ) {
484
+function give_require_billing_address($payment_mode) {
485 485
 
486 486
 	$return = false;
487 487
 
488
-	if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) {
488
+	if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) {
489 489
 		$return = true;
490 490
 	}
491 491
 
492 492
 	// Let payment gateways and other extensions determine if address fields should be required.
493
-	return apply_filters( 'give_require_billing_address', $return );
493
+	return apply_filters('give_require_billing_address', $return);
494 494
 
495 495
 }
496 496
 
@@ -504,42 +504,42 @@  discard block
 block discarded – undo
504 504
 function give_donation_form_validate_logged_in_user() {
505 505
 	global $user_ID;
506 506
 
507
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
507
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
508 508
 
509 509
 	// Start empty array to collect valid user data.
510 510
 	$valid_user_data = array(
511 511
 		// Assume there will be errors.
512
-		'user_id' => - 1,
512
+		'user_id' => -1,
513 513
 	);
514 514
 
515 515
 	// Verify there is a user_ID.
516
-	if ( $user_ID > 0 ) {
516
+	if ($user_ID > 0) {
517 517
 		// Get the logged in user data.
518
-		$user_data = get_userdata( $user_ID );
518
+		$user_data = get_userdata($user_ID);
519 519
 
520 520
 		// Loop through required fields and show error messages.
521
-		foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) {
522
-			if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
523
-				give_set_error( $value['error_id'], $value['error_message'] );
521
+		foreach (give_get_required_fields($form_id) as $field_name => $value) {
522
+			if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) {
523
+				give_set_error($value['error_id'], $value['error_message']);
524 524
 			}
525 525
 		}
526 526
 
527 527
 		// Verify data.
528
-		if ( $user_data ) {
528
+		if ($user_data) {
529 529
 			// Collected logged in user data.
530 530
 			$valid_user_data = array(
531 531
 				'user_id'    => $user_ID,
532
-				'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email,
533
-				'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name,
534
-				'user_last'  => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name,
532
+				'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email,
533
+				'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name,
534
+				'user_last'  => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name,
535 535
 			);
536 536
 
537
-			if ( ! is_email( $valid_user_data['user_email'] ) ) {
538
-				give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
537
+			if ( ! is_email($valid_user_data['user_email'])) {
538
+				give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
539 539
 			}
540 540
 		} else {
541 541
 			// Set invalid user error.
542
-			give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) );
542
+			give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give'));
543 543
 		}
544 544
 	}
545 545
 
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
 	// Default user data.
559 559
 	$default_user_data = array(
560 560
 		'give-form-id'           => '',
561
-		'user_id'                => - 1, // Assume there will be errors.
561
+		'user_id'                => -1, // Assume there will be errors.
562 562
 		'user_first'             => '',
563 563
 		'user_last'              => '',
564 564
 		'give_user_login'        => false,
@@ -568,14 +568,14 @@  discard block
 block discarded – undo
568 568
 	);
569 569
 
570 570
 	// Get user data.
571
-	$user_data            = wp_parse_args( array_map( 'trim', give_clean( $_POST ) ), $default_user_data );
571
+	$user_data            = wp_parse_args(array_map('trim', give_clean($_POST)), $default_user_data);
572 572
 	$registering_new_user = false;
573
-	$form_id              = absint( $user_data['give-form-id'] );
573
+	$form_id              = absint($user_data['give-form-id']);
574 574
 
575 575
 	// Start an empty array to collect valid user data.
576 576
 	$valid_user_data = array(
577 577
 		// Assume there will be errors.
578
-		'user_id'    => - 1,
578
+		'user_id'    => -1,
579 579
 
580 580
 		// Get first name.
581 581
 		'user_first' => $user_data['give_first'],
@@ -585,25 +585,25 @@  discard block
 block discarded – undo
585 585
 	);
586 586
 
587 587
 	// Loop through required fields and show error messages.
588
-	foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) {
589
-		if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
590
-			give_set_error( $value['error_id'], $value['error_message'] );
588
+	foreach (give_get_required_fields($form_id) as $field_name => $value) {
589
+		if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) {
590
+			give_set_error($value['error_id'], $value['error_message']);
591 591
 		}
592 592
 	}
593 593
 
594 594
 	// Check if we have an username to register.
595
-	if ( give_validate_username( $user_data['give_user_login'] ) ) {
595
+	if (give_validate_username($user_data['give_user_login'])) {
596 596
 		$registering_new_user          = true;
597 597
 		$valid_user_data['user_login'] = $user_data['give_user_login'];
598 598
 	}
599 599
 
600 600
 	// Check if we have an email to verify.
601
-	if ( give_validate_user_email( $user_data['give_email'], $registering_new_user ) ) {
601
+	if (give_validate_user_email($user_data['give_email'], $registering_new_user)) {
602 602
 		$valid_user_data['user_email'] = $user_data['give_email'];
603 603
 	}
604 604
 
605 605
 	// Check password.
606
-	if ( give_validate_user_password( $user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user ) ) {
606
+	if (give_validate_user_password($user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user)) {
607 607
 		// All is good to go.
608 608
 		$valid_user_data['user_pass'] = $user_data['give_user_pass'];
609 609
 	}
@@ -623,36 +623,36 @@  discard block
 block discarded – undo
623 623
 	// Start an array to collect valid user data.
624 624
 	$valid_user_data = array(
625 625
 		// Assume there will be errors.
626
-		'user_id' => - 1,
626
+		'user_id' => -1,
627 627
 	);
628 628
 
629 629
 	// Username.
630
-	if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) {
631
-		give_set_error( 'must_log_in', __( 'You must register or login to complete your donation.', 'give' ) );
630
+	if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') {
631
+		give_set_error('must_log_in', __('You must register or login to complete your donation.', 'give'));
632 632
 
633 633
 		return $valid_user_data;
634 634
 	}
635 635
 
636 636
 	// Get the user by login.
637
-	$user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) );
637
+	$user_data = get_user_by('login', strip_tags($_POST['give_user_login']));
638 638
 
639 639
 	// Check if user exists.
640
-	if ( $user_data ) {
640
+	if ($user_data) {
641 641
 		// Get password.
642
-		$user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false;
642
+		$user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false;
643 643
 
644 644
 		// Check user_pass.
645
-		if ( $user_pass ) {
645
+		if ($user_pass) {
646 646
 			// Check if password is valid.
647
-			if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) {
647
+			if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) {
648 648
 				// Incorrect password.
649 649
 				give_set_error(
650 650
 					'password_incorrect',
651 651
 					sprintf(
652 652
 						'%1$s <a href="%2$s">%3$s</a>',
653
-						__( 'The password you entered is incorrect.', 'give' ),
654
-						wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ),
655
-						__( 'Reset Password', 'give' )
653
+						__('The password you entered is incorrect.', 'give'),
654
+						wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"),
655
+						__('Reset Password', 'give')
656 656
 					)
657 657
 				);
658 658
 				// All is correct.
@@ -669,11 +669,11 @@  discard block
 block discarded – undo
669 669
 			}
670 670
 		} else {
671 671
 			// Empty password.
672
-			give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) );
672
+			give_set_error('password_empty', __('Enter a password.', 'give'));
673 673
 		}
674 674
 	} else {
675 675
 		// No username.
676
-		give_set_error( 'username_incorrect', __( 'The username you entered does not exist.', 'give' ) );
676
+		give_set_error('username_incorrect', __('The username you entered does not exist.', 'give'));
677 677
 	}// End if().
678 678
 
679 679
 	return $valid_user_data;
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
  */
689 689
 function give_donation_form_validate_guest_user() {
690 690
 
691
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
691
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
692 692
 
693 693
 	// Start an array to collect valid user data.
694 694
 	$valid_user_data = array(
@@ -697,38 +697,38 @@  discard block
 block discarded – undo
697 697
 	);
698 698
 
699 699
 	// Show error message if user must be logged in.
700
-	if ( give_logged_in_only( $form_id ) ) {
701
-		give_set_error( 'logged_in_only', __( 'You must be logged in to donate.', 'give' ) );
700
+	if (give_logged_in_only($form_id)) {
701
+		give_set_error('logged_in_only', __('You must be logged in to donate.', 'give'));
702 702
 	}
703 703
 
704 704
 	// Get the guest email.
705
-	$guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false;
705
+	$guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false;
706 706
 
707 707
 	// Check email.
708
-	if ( $guest_email && strlen( $guest_email ) > 0 ) {
708
+	if ($guest_email && strlen($guest_email) > 0) {
709 709
 		// Validate email.
710
-		if ( ! is_email( $guest_email ) ) {
710
+		if ( ! is_email($guest_email)) {
711 711
 			// Invalid email.
712
-			give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) );
712
+			give_set_error('email_invalid', __('Invalid email.', 'give'));
713 713
 		} else {
714 714
 			// All is good to go.
715 715
 			$valid_user_data['user_email'] = $guest_email;
716 716
 
717 717
 			// Get user_id from donor if exist.
718
-			$donor = new Give_Donor( $guest_email );
719
-			if ( $donor->id && $donor->user_id ) {
718
+			$donor = new Give_Donor($guest_email);
719
+			if ($donor->id && $donor->user_id) {
720 720
 				$valid_user_data['user_id'] = $donor->user_id;
721 721
 			}
722 722
 		}
723 723
 	} else {
724 724
 		// No email.
725
-		give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) );
725
+		give_set_error('email_empty', __('Enter an email.', 'give'));
726 726
 	}
727 727
 
728 728
 	// Loop through required fields and show error messages.
729
-	foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) {
730
-		if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
731
-			give_set_error( $value['error_id'], $value['error_message'] );
729
+	foreach (give_get_required_fields($form_id) as $field_name => $value) {
730
+		if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) {
731
+			give_set_error($value['error_id'], $value['error_message']);
732 732
 		}
733 733
 	}
734 734
 
@@ -744,36 +744,36 @@  discard block
 block discarded – undo
744 744
  * @since   1.0
745 745
  * @return  integer
746 746
  */
747
-function give_register_and_login_new_user( $user_data = array() ) {
747
+function give_register_and_login_new_user($user_data = array()) {
748 748
 	// Verify the array.
749
-	if ( empty( $user_data ) ) {
750
-		return - 1;
749
+	if (empty($user_data)) {
750
+		return -1;
751 751
 	}
752 752
 
753
-	if ( give_get_errors() ) {
754
-		return - 1;
753
+	if (give_get_errors()) {
754
+		return -1;
755 755
 	}
756 756
 
757
-	$user_args = apply_filters( 'give_insert_user_args', array(
758
-		'user_login'      => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '',
759
-		'user_pass'       => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '',
760
-		'user_email'      => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '',
761
-		'first_name'      => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '',
762
-		'last_name'       => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '',
763
-		'user_registered' => date( 'Y-m-d H:i:s' ),
764
-		'role'            => get_option( 'default_role' ),
765
-	), $user_data );
757
+	$user_args = apply_filters('give_insert_user_args', array(
758
+		'user_login'      => isset($user_data['user_login']) ? $user_data['user_login'] : '',
759
+		'user_pass'       => isset($user_data['user_pass']) ? $user_data['user_pass'] : '',
760
+		'user_email'      => isset($user_data['user_email']) ? $user_data['user_email'] : '',
761
+		'first_name'      => isset($user_data['user_first']) ? $user_data['user_first'] : '',
762
+		'last_name'       => isset($user_data['user_last']) ? $user_data['user_last'] : '',
763
+		'user_registered' => date('Y-m-d H:i:s'),
764
+		'role'            => get_option('default_role'),
765
+	), $user_data);
766 766
 
767 767
 	// Insert new user.
768
-	$user_id = wp_insert_user( $user_args );
768
+	$user_id = wp_insert_user($user_args);
769 769
 
770 770
 	// Validate inserted user.
771
-	if ( is_wp_error( $user_id ) ) {
772
-		return - 1;
771
+	if (is_wp_error($user_id)) {
772
+		return -1;
773 773
 	}
774 774
 
775 775
 	// Allow themes and plugins to filter the user data.
776
-	$user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args );
776
+	$user_data = apply_filters('give_insert_user_data', $user_data, $user_args);
777 777
 
778 778
 	/**
779 779
 	 * Fires after inserting user.
@@ -783,10 +783,10 @@  discard block
 block discarded – undo
783 783
 	 * @param int $user_id User id.
784 784
 	 * @param array $user_data Array containing user data.
785 785
 	 */
786
-	do_action( 'give_insert_user', $user_id, $user_data );
786
+	do_action('give_insert_user', $user_id, $user_data);
787 787
 
788 788
 	// Login new user.
789
-	give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] );
789
+	give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']);
790 790
 
791 791
 	// Return user id.
792 792
 	return $user_id;
@@ -801,27 +801,27 @@  discard block
 block discarded – undo
801 801
  * @since   1.0
802 802
  * @return  array|bool
803 803
  */
804
-function give_get_donation_form_user( $valid_data = array() ) {
804
+function give_get_donation_form_user($valid_data = array()) {
805 805
 
806 806
 	// Initialize user.
807 807
 	$user    = false;
808
-	$is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
808
+	$is_ajax = defined('DOING_AJAX') && DOING_AJAX;
809 809
 
810
-	if ( $is_ajax ) {
810
+	if ($is_ajax) {
811 811
 		// Do not create or login the user during the ajax submission (check for errors only).
812 812
 		return true;
813
-	} elseif ( is_user_logged_in() ) {
813
+	} elseif (is_user_logged_in()) {
814 814
 		// Set the valid user as the logged in collected data.
815 815
 		$user = $valid_data['logged_in_user'];
816
-	} elseif ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) {
816
+	} elseif ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) {
817 817
 		// New user registration.
818
-		if ( $valid_data['need_new_user'] === true ) {
818
+		if ($valid_data['need_new_user'] === true) {
819 819
 			// Set user.
820 820
 			$user = $valid_data['new_user_data'];
821 821
 			// Register and login new user.
822
-			$user['user_id'] = give_register_and_login_new_user( $user );
822
+			$user['user_id'] = give_register_and_login_new_user($user);
823 823
 			// User login
824
-		} elseif ( $valid_data['need_user_login'] === true && ! $is_ajax ) {
824
+		} elseif ($valid_data['need_user_login'] === true && ! $is_ajax) {
825 825
 
826 826
 			/**
827 827
 			 * The login form is now processed in the give_process_donation_login() function.
@@ -833,48 +833,48 @@  discard block
 block discarded – undo
833 833
 			// Set user.
834 834
 			$user = $valid_data['login_user_data'];
835 835
 			// Login user.
836
-			give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] );
836
+			give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']);
837 837
 		}
838 838
 	}
839 839
 
840 840
 	// Check guest checkout.
841
-	if ( false === $user && false === give_logged_in_only( $_POST['give-form-id'] ) ) {
841
+	if (false === $user && false === give_logged_in_only($_POST['give-form-id'])) {
842 842
 		// Set user
843 843
 		$user = $valid_data['guest_user_data'];
844 844
 	}
845 845
 
846 846
 	// Verify we have an user.
847
-	if ( false === $user || empty( $user ) ) {
847
+	if (false === $user || empty($user)) {
848 848
 		// Return false.
849 849
 		return false;
850 850
 	}
851 851
 
852 852
 	// Get user first name.
853
-	if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) {
854
-		$user['user_first'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : '';
853
+	if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) {
854
+		$user['user_first'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : '';
855 855
 	}
856 856
 
857 857
 	// Get user last name.
858
-	if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) {
859
-		$user['user_last'] = isset( $_POST['give_last'] ) ? strip_tags( trim( $_POST['give_last'] ) ) : '';
858
+	if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) {
859
+		$user['user_last'] = isset($_POST['give_last']) ? strip_tags(trim($_POST['give_last'])) : '';
860 860
 	}
861 861
 
862 862
 	// Get the user's billing address details.
863 863
 	$user['address']            = array();
864
-	$user['address']['line1']   = ! empty( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : false;
865
-	$user['address']['line2']   = ! empty( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : false;
866
-	$user['address']['city']    = ! empty( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : false;
867
-	$user['address']['state']   = ! empty( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : false;
868
-	$user['address']['country'] = ! empty( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : false;
869
-	$user['address']['zip']     = ! empty( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : false;
870
-
871
-	if ( empty( $user['address']['country'] ) ) {
864
+	$user['address']['line1']   = ! empty($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : false;
865
+	$user['address']['line2']   = ! empty($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : false;
866
+	$user['address']['city']    = ! empty($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : false;
867
+	$user['address']['state']   = ! empty($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : false;
868
+	$user['address']['country'] = ! empty($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : false;
869
+	$user['address']['zip']     = ! empty($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : false;
870
+
871
+	if (empty($user['address']['country'])) {
872 872
 		$user['address'] = false;
873 873
 	} // End if().
874 874
 
875
-	if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) {
875
+	if ( ! empty($user['user_id']) && $user['user_id'] > 0 && ! empty($user['address'])) {
876 876
 		// Store the address in the user's meta so the donation form can be pre-populated with it on return donation.
877
-		update_user_meta( $user['user_id'], '_give_user_address', $user['address'] );
877
+		update_user_meta($user['user_id'], '_give_user_address', $user['address']);
878 878
 	}
879 879
 
880 880
 	// Return valid user.
@@ -893,16 +893,16 @@  discard block
 block discarded – undo
893 893
 	$card_data = give_get_donation_cc_info();
894 894
 
895 895
 	// Validate the card zip.
896
-	if ( ! empty( $card_data['card_zip'] ) ) {
897
-		if ( ! give_donation_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) {
898
-			give_set_error( 'invalid_cc_zip', __( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) );
896
+	if ( ! empty($card_data['card_zip'])) {
897
+		if ( ! give_donation_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) {
898
+			give_set_error('invalid_cc_zip', __('The zip / postal code you entered for your billing address is invalid.', 'give'));
899 899
 		}
900 900
 	}
901 901
 
902 902
 	// Ensure no spaces.
903
-	if ( ! empty( $card_data['card_number'] ) ) {
904
-		$card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); // no "+" signs
905
-		$card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces
903
+	if ( ! empty($card_data['card_number'])) {
904
+		$card_data['card_number'] = str_replace('+', '', $card_data['card_number']); // no "+" signs
905
+		$card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces
906 906
 	}
907 907
 
908 908
 	// This should validate card numbers at some point too.
@@ -919,17 +919,17 @@  discard block
 block discarded – undo
919 919
 function give_get_donation_cc_info() {
920 920
 
921 921
 	$cc_info                   = array();
922
-	$cc_info['card_name']      = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : '';
923
-	$cc_info['card_number']    = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : '';
924
-	$cc_info['card_cvc']       = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : '';
925
-	$cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : '';
926
-	$cc_info['card_exp_year']  = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : '';
927
-	$cc_info['card_address']   = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : '';
928
-	$cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : '';
929
-	$cc_info['card_city']      = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : '';
930
-	$cc_info['card_state']     = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : '';
931
-	$cc_info['card_country']   = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : '';
932
-	$cc_info['card_zip']       = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : '';
922
+	$cc_info['card_name']      = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : '';
923
+	$cc_info['card_number']    = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : '';
924
+	$cc_info['card_cvc']       = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : '';
925
+	$cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : '';
926
+	$cc_info['card_exp_year']  = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : '';
927
+	$cc_info['card_address']   = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : '';
928
+	$cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : '';
929
+	$cc_info['card_city']      = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : '';
930
+	$cc_info['card_state']     = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : '';
931
+	$cc_info['card_country']   = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : '';
932
+	$cc_info['card_zip']       = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : '';
933 933
 
934 934
 	// Return cc info.
935 935
 	return $cc_info;
@@ -945,14 +945,14 @@  discard block
 block discarded – undo
945 945
  *
946 946
  * @return bool|mixed
947 947
  */
948
-function give_donation_form_validate_cc_zip( $zip = 0, $country_code = '' ) {
948
+function give_donation_form_validate_cc_zip($zip = 0, $country_code = '') {
949 949
 	$ret = false;
950 950
 
951
-	if ( empty( $zip ) || empty( $country_code ) ) {
951
+	if (empty($zip) || empty($country_code)) {
952 952
 		return $ret;
953 953
 	}
954 954
 
955
-	$country_code = strtoupper( $country_code );
955
+	$country_code = strtoupper($country_code);
956 956
 
957 957
 	$zip_regex = array(
958 958
 		'AD' => 'AD\d{3}',
@@ -1112,11 +1112,11 @@  discard block
 block discarded – undo
1112 1112
 		'ZM' => '\d{5}',
1113 1113
 	);
1114 1114
 
1115
-	if ( ! isset( $zip_regex[ $country_code ] ) || preg_match( '/' . $zip_regex[ $country_code ] . '/i', $zip ) ) {
1115
+	if ( ! isset($zip_regex[$country_code]) || preg_match('/'.$zip_regex[$country_code].'/i', $zip)) {
1116 1116
 		$ret = true;
1117 1117
 	}
1118 1118
 
1119
-	return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code );
1119
+	return apply_filters('give_is_zip_valid', $ret, $zip, $country_code);
1120 1120
 }
1121 1121
 
1122 1122
 
@@ -1130,36 +1130,36 @@  discard block
 block discarded – undo
1130 1130
  *
1131 1131
  * @return bool
1132 1132
  */
1133
-function give_validate_multi_donation_form_level( $valid_data, $data ) {
1133
+function give_validate_multi_donation_form_level($valid_data, $data) {
1134 1134
 	/* @var Give_Donate_Form $form */
1135
-	$form = new Give_Donate_Form( $data['give-form-id'] );
1135
+	$form = new Give_Donate_Form($data['give-form-id']);
1136 1136
 
1137 1137
 	$donation_level_matched = false;
1138 1138
 
1139
-	if ( $form->is_multi_type_donation_form() ) {
1139
+	if ($form->is_multi_type_donation_form()) {
1140 1140
 
1141 1141
 		// Bailout.
1142
-		if ( ! ( $variable_prices = $form->get_prices() ) ) {
1142
+		if ( ! ($variable_prices = $form->get_prices())) {
1143 1143
 			return false;
1144 1144
 		}
1145 1145
 
1146 1146
 		// Sanitize donation amount.
1147
-		$data['give-amount'] = give_sanitize_amount( $data['give-amount'] );
1147
+		$data['give-amount'] = give_sanitize_amount($data['give-amount']);
1148 1148
 
1149 1149
 		// Get number of decimals.
1150 1150
 		$default_decimals = give_get_price_decimals();
1151 1151
 
1152
-		if ( $data['give-amount'] === give_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ), $default_decimals ) ) {
1152
+		if ($data['give-amount'] === give_sanitize_amount(give_get_price_option_amount($data['give-form-id'], $data['give-price-id']), $default_decimals)) {
1153 1153
 			return true;
1154 1154
 		}
1155 1155
 
1156 1156
 		// Find correct donation level from all donation levels.
1157
-		foreach ( $variable_prices as $variable_price ) {
1157
+		foreach ($variable_prices as $variable_price) {
1158 1158
 			// Sanitize level amount.
1159
-			$variable_price['_give_amount'] = give_sanitize_amount( $variable_price['_give_amount'], $default_decimals );
1159
+			$variable_price['_give_amount'] = give_sanitize_amount($variable_price['_give_amount'], $default_decimals);
1160 1160
 
1161 1161
 			// Set first match donation level ID.
1162
-			if ( $data['give-amount'] === $variable_price['_give_amount'] ) {
1162
+			if ($data['give-amount'] === $variable_price['_give_amount']) {
1163 1163
 				$_POST['give-price-id'] = $variable_price['_give_id']['level_id'];
1164 1164
 				$donation_level_matched = true;
1165 1165
 				break;
@@ -1170,19 +1170,19 @@  discard block
 block discarded – undo
1170 1170
 		// If yes then set price id to custom if amount is greater then custom minimum amount (if any).
1171 1171
 		if (
1172 1172
 			! $donation_level_matched
1173
-			&& ( give_is_setting_enabled( give_get_meta( $data['give-form-id'], '_give_custom_amount', true ) ) )
1173
+			&& (give_is_setting_enabled(give_get_meta($data['give-form-id'], '_give_custom_amount', true)))
1174 1174
 		) {
1175 1175
 			// Sanitize custom minimum amount.
1176
-			$custom_minimum_amount = give_sanitize_amount( give_get_meta( $data['give-form-id'], '_give_custom_amount_minimum', true ), $default_decimals );
1176
+			$custom_minimum_amount = give_sanitize_amount(give_get_meta($data['give-form-id'], '_give_custom_amount_minimum', true), $default_decimals);
1177 1177
 
1178
-			if ( $data['give-amount'] >= $custom_minimum_amount ) {
1178
+			if ($data['give-amount'] >= $custom_minimum_amount) {
1179 1179
 				$_POST['give-price-id'] = 'custom';
1180 1180
 				$donation_level_matched = true;
1181 1181
 			}
1182 1182
 		}
1183 1183
 	}// End if().
1184 1184
 
1185
-	return ( $donation_level_matched ? true : false );
1185
+	return ($donation_level_matched ? true : false);
1186 1186
 }
1187 1187
 
1188
-add_action( 'give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2 );
1188
+add_action('give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2);
Please login to merge, or discard this patch.
includes/class-give-cache.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	 * @return static
44 44
 	 */
45 45
 	public static function get_instance() {
46
-		if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Give_Cache ) ) {
46
+		if ( ! isset(self::$instance) && ! (self::$instance instanceof Give_Cache)) {
47 47
 			self::$instance = new Give_Cache();
48 48
 		}
49 49
 
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	 */
59 59
 	public function setup_hooks() {
60 60
 		// weekly delete all expired cache.
61
-		add_action( 'give_weekly_scheduled_events', array( $this, 'delete_all_expired' ) );
61
+		add_action('give_weekly_scheduled_events', array($this, 'delete_all_expired'));
62 62
 	}
63 63
 
64 64
 	/**
@@ -72,12 +72,12 @@  discard block
 block discarded – undo
72 72
 	 * @return string
73 73
 	 */
74 74
 
75
-	public static function get_key( $action, $query_args = null ) {
75
+	public static function get_key($action, $query_args = null) {
76 76
 		$cache_key = "give_cache_{$action}";
77 77
 
78 78
 		// Bailout.
79
-		if ( ! empty( $query_args ) ) {
80
-			$cache_key = "{$cache_key}_" . substr( md5( serialize( $query_args ) ), 0, 15 );
79
+		if ( ! empty($query_args)) {
80
+			$cache_key = "{$cache_key}_".substr(md5(serialize($query_args)), 0, 15);
81 81
 		}
82 82
 
83 83
 		return $cache_key;
@@ -95,26 +95,26 @@  discard block
 block discarded – undo
95 95
 	 * @return mixed
96 96
 	 */
97 97
 
98
-	public static function get( $cache_key, $custom_key = false, $query_args = array() ) {
99
-		if ( ! self::is_valid_cache_key( $cache_key ) ) {
100
-			if ( ! $custom_key ) {
101
-				return new WP_Error( 'give_invalid_cache_key', __( 'Cache key format should be give_cache_*', 'give' ) );
98
+	public static function get($cache_key, $custom_key = false, $query_args = array()) {
99
+		if ( ! self::is_valid_cache_key($cache_key)) {
100
+			if ( ! $custom_key) {
101
+				return new WP_Error('give_invalid_cache_key', __('Cache key format should be give_cache_*', 'give'));
102 102
 			}
103 103
 
104
-			$cache_key = self::get_key( $cache_key, $query_args );
104
+			$cache_key = self::get_key($cache_key, $query_args);
105 105
 		}
106 106
 
107
-		$option = get_option( $cache_key );
107
+		$option = get_option($cache_key);
108 108
 
109 109
 		// Backward compatibility (<1.8.7).
110
-		if ( ! is_array( $option ) || empty( $option ) || ! array_key_exists( 'expiration', $option ) ) {
110
+		if ( ! is_array($option) || empty($option) || ! array_key_exists('expiration', $option)) {
111 111
 			return $option;
112 112
 		}
113 113
 
114 114
 		// Get current time.
115
-		$current_time = current_time( 'timestamp', 1 );
115
+		$current_time = current_time('timestamp', 1);
116 116
 
117
-		if ( empty( $option['expiration'] ) || ( $current_time < $option['expiration'] ) ) {
117
+		if (empty($option['expiration']) || ($current_time < $option['expiration'])) {
118 118
 			$option = $option['data'];
119 119
 		} else {
120 120
 			$option = false;
@@ -137,23 +137,23 @@  discard block
 block discarded – undo
137 137
 	 * @return mixed
138 138
 	 */
139 139
 
140
-	public static function set( $cache_key, $data, $expiration = null, $custom_key = false, $query_args = array() ) {
141
-		if ( ! self::is_valid_cache_key( $cache_key ) ) {
142
-			if ( ! $custom_key ) {
143
-				return new WP_Error( 'give_invalid_cache_key', __( 'Cache key format should be give_cache_*', 'give' ) );
140
+	public static function set($cache_key, $data, $expiration = null, $custom_key = false, $query_args = array()) {
141
+		if ( ! self::is_valid_cache_key($cache_key)) {
142
+			if ( ! $custom_key) {
143
+				return new WP_Error('give_invalid_cache_key', __('Cache key format should be give_cache_*', 'give'));
144 144
 			}
145 145
 
146
-			$cache_key = self::get_key( $cache_key, $query_args );
146
+			$cache_key = self::get_key($cache_key, $query_args);
147 147
 		}
148 148
 
149 149
 		$option_value = array(
150 150
 			'data'       => $data,
151
-			'expiration' => ! is_null( $expiration )
152
-				? ( $expiration + current_time( 'timestamp', 1 ) )
151
+			'expiration' => ! is_null($expiration)
152
+				? ($expiration + current_time('timestamp', 1))
153 153
 				: null,
154 154
 		);
155 155
 
156
-		$result = update_option( $cache_key, $option_value, 'no' );
156
+		$result = update_option($cache_key, $option_value, 'no');
157 157
 
158 158
 		return $result;
159 159
 	}
@@ -168,27 +168,27 @@  discard block
 block discarded – undo
168 168
 	 * @return bool|WP_Error
169 169
 	 */
170 170
 
171
-	public static function delete( $cache_keys ) {
171
+	public static function delete($cache_keys) {
172 172
 		$result = true;
173 173
 		$invalid_keys = array();
174 174
 
175
-		if ( ! empty( $cache_keys ) ) {
176
-			$cache_keys = is_array( $cache_keys ) ? $cache_keys : array( $cache_keys );
175
+		if ( ! empty($cache_keys)) {
176
+			$cache_keys = is_array($cache_keys) ? $cache_keys : array($cache_keys);
177 177
 
178
-			foreach ( $cache_keys as $cache_key ) {
179
-				if ( ! self::is_valid_cache_key( $cache_key ) ) {
178
+			foreach ($cache_keys as $cache_key) {
179
+				if ( ! self::is_valid_cache_key($cache_key)) {
180 180
 					$invalid_keys[] = $cache_key;
181 181
 					$result = false;
182 182
 				}
183 183
 
184
-				delete_option( $cache_key );
184
+				delete_option($cache_key);
185 185
 			}
186 186
 		}
187 187
 
188
-		if( ! $result ) {
188
+		if ( ! $result) {
189 189
 			$result = new WP_Error(
190 190
 				'give_invalid_cache_key',
191
-					__( 'Cache key format should be give_cache_*', 'give' ),
191
+					__('Cache key format should be give_cache_*', 'give'),
192 192
 					$invalid_keys
193 193
 			);
194 194
 		}
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 	 *
208 208
 	 * @return bool
209 209
 	 */
210
-	public static function delete_all_expired( $force = false ) {
210
+	public static function delete_all_expired($force = false) {
211 211
 		global $wpdb;
212 212
 		$options = $wpdb->get_results(
213 213
 			$wpdb->prepare(
@@ -221,30 +221,30 @@  discard block
 block discarded – undo
221 221
 		);
222 222
 
223 223
 		// Bailout.
224
-		if ( empty( $options ) ) {
224
+		if (empty($options)) {
225 225
 			return false;
226 226
 		}
227 227
 
228
-		$current_time = current_time( 'timestamp', 1 );
228
+		$current_time = current_time('timestamp', 1);
229 229
 
230 230
 		// Delete log cache.
231
-		foreach ( $options as $option ) {
232
-			$option['option_value'] = maybe_unserialize( $option['option_value'] );
231
+		foreach ($options as $option) {
232
+			$option['option_value'] = maybe_unserialize($option['option_value']);
233 233
 
234 234
 			if (
235 235
 				(
236
-					! self::is_valid_cache_key( $option['option_name'] )
237
-					|| ! is_array( $option['option_value'] ) // Backward compatibility (<1.8.7).
238
-					|| ! array_key_exists( 'expiration', $option['option_value'] ) // Backward compatibility (<1.8.7).
239
-					|| empty( $option['option_value']['expiration'] )
240
-					|| ( $current_time < $option['option_value']['expiration'] )
236
+					! self::is_valid_cache_key($option['option_name'])
237
+					|| ! is_array($option['option_value']) // Backward compatibility (<1.8.7).
238
+					|| ! array_key_exists('expiration', $option['option_value']) // Backward compatibility (<1.8.7).
239
+					|| empty($option['option_value']['expiration'])
240
+					|| ($current_time < $option['option_value']['expiration'])
241 241
 				)
242 242
 				&& ! $force
243 243
 			) {
244 244
 				continue;
245 245
 			}
246 246
 
247
-			self::delete( $option['option_name'] );
247
+			self::delete($option['option_name']);
248 248
 		}
249 249
 	}
250 250
 
@@ -260,16 +260,16 @@  discard block
 block discarded – undo
260 260
 	 *
261 261
 	 * @return array
262 262
 	 */
263
-	public static function get_options_like( $option_name, $fields = false ) {
263
+	public static function get_options_like($option_name, $fields = false) {
264 264
 		global $wpdb;
265 265
 
266
-		if ( empty( $option_name ) ) {
266
+		if (empty($option_name)) {
267 267
 			return array();
268 268
 		}
269 269
 
270 270
 		$field_names = $fields ? 'option_name, option_value' : 'option_name';
271 271
 
272
-		if ( $fields ) {
272
+		if ($fields) {
273 273
 			$options = $wpdb->get_results(
274 274
 				$wpdb->prepare(
275 275
 					"SELECT {$field_names }
@@ -293,10 +293,10 @@  discard block
 block discarded – undo
293 293
 			);
294 294
 		}
295 295
 
296
-		if ( ! empty( $options ) && $fields ) {
297
-			foreach ( $options as $index => $option ) {
298
-				$option['option_value'] = maybe_unserialize( $option['option_value'] );
299
-				$options[ $index ]      = $option;
296
+		if ( ! empty($options) && $fields) {
297
+			foreach ($options as $index => $option) {
298
+				$option['option_value'] = maybe_unserialize($option['option_value']);
299
+				$options[$index]      = $option;
300 300
 			}
301 301
 		}
302 302
 
@@ -313,8 +313,8 @@  discard block
 block discarded – undo
313 313
 	 *
314 314
 	 * @return bool|int
315 315
 	 */
316
-	public static function is_valid_cache_key( $cache_key ) {
317
-		return ( false !== strpos( $cache_key, 'give_cache_' ) );
316
+	public static function is_valid_cache_key($cache_key) {
317
+		return (false !== strpos($cache_key, 'give_cache_'));
318 318
 	}
319 319
 }
320 320
 
Please login to merge, or discard this patch.
includes/class-give-db.php 1 patch
Spacing   +42 added lines, -42 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
 
@@ -98,11 +98,11 @@  discard block
 block discarded – undo
98 98
 	 *
99 99
 	 * @return object
100 100
 	 */
101
-	public function get( $row_id ) {
101
+	public function get($row_id) {
102 102
 		/* @var WPDB $wpdb */
103 103
 		global $wpdb;
104 104
 
105
-		return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) );
105
+		return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id));
106 106
 	}
107 107
 
108 108
 	/**
@@ -116,12 +116,12 @@  discard block
 block discarded – undo
116 116
      *
117 117
      * @return object
118 118
 	 */
119
-	public function get_by( $column, $row_id ) {
119
+	public function get_by($column, $row_id) {
120 120
         /* @var WPDB $wpdb */
121 121
         global $wpdb;
122 122
 
123
-		$column = esc_sql( $column );
124
-		return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) );
123
+		$column = esc_sql($column);
124
+		return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id));
125 125
 	}
126 126
 
127 127
 	/**
@@ -135,12 +135,12 @@  discard block
 block discarded – undo
135 135
      *
136 136
 	 * @return string      Column value.
137 137
 	 */
138
-	public function get_column( $column, $row_id ) {
138
+	public function get_column($column, $row_id) {
139 139
         /* @var WPDB $wpdb */
140 140
         global $wpdb;
141 141
 
142
-		$column = esc_sql( $column );
143
-		return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) );
142
+		$column = esc_sql($column);
143
+		return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id));
144 144
 	}
145 145
 
146 146
 	/**
@@ -155,13 +155,13 @@  discard block
 block discarded – undo
155 155
      *
156 156
 	 * @return string
157 157
 	 */
158
-	public function get_column_by( $column, $column_where, $column_value ) {
158
+	public function get_column_by($column, $column_where, $column_value) {
159 159
         /* @var WPDB $wpdb */
160 160
         global $wpdb;
161 161
 
162
-		$column_where = esc_sql( $column_where );
163
-		$column       = esc_sql( $column );
164
-		return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value ) );
162
+		$column_where = esc_sql($column_where);
163
+		$column       = esc_sql($column);
164
+		return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value));
165 165
 	}
166 166
 
167 167
 	/**
@@ -175,12 +175,12 @@  discard block
 block discarded – undo
175 175
      *
176 176
 	 * @return int
177 177
 	 */
178
-	public function insert( $data, $type = '' ) {
178
+	public function insert($data, $type = '') {
179 179
         /* @var WPDB $wpdb */
180 180
         global $wpdb;
181 181
 
182 182
 		// Set default values.
183
-		$data = wp_parse_args( $data, $this->get_column_defaults() );
183
+		$data = wp_parse_args($data, $this->get_column_defaults());
184 184
 
185 185
 		/**
186 186
 		 * Fires before inserting data to the database.
@@ -189,22 +189,22 @@  discard block
 block discarded – undo
189 189
 		 *
190 190
 		 * @param array $data
191 191
 		 */
192
-		do_action( "give_pre_insert_{$type}", $data );
192
+		do_action("give_pre_insert_{$type}", $data);
193 193
 
194 194
 		// Initialise column format array
195 195
 		$column_formats = $this->get_columns();
196 196
 
197 197
 		// Force fields to lower case
198
-		$data = array_change_key_case( $data );
198
+		$data = array_change_key_case($data);
199 199
 
200 200
 		// White list columns
201
-		$data = array_intersect_key( $data, $column_formats );
201
+		$data = array_intersect_key($data, $column_formats);
202 202
 
203 203
 		// Reorder $column_formats to match the order of columns given in $data
204
-		$data_keys      = array_keys( $data );
205
-		$column_formats = array_merge( array_flip( $data_keys ), $column_formats );
204
+		$data_keys      = array_keys($data);
205
+		$column_formats = array_merge(array_flip($data_keys), $column_formats);
206 206
 
207
-		$wpdb->insert( $this->table_name, $data, $column_formats );
207
+		$wpdb->insert($this->table_name, $data, $column_formats);
208 208
 
209 209
 		/**
210 210
 		 * Fires after inserting data to the database.
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 		 * @param int   $insert_id
215 215
 		 * @param array $data
216 216
 		 */
217
-		do_action( "give_post_insert_{$type}", $wpdb->insert_id, $data );
217
+		do_action("give_post_insert_{$type}", $wpdb->insert_id, $data);
218 218
 
219 219
 		return $wpdb->insert_id;
220 220
 	}
@@ -231,18 +231,18 @@  discard block
 block discarded – undo
231 231
      *
232 232
 	 * @return bool
233 233
 	 */
234
-	public function update( $row_id, $data = array(), $where = '' ) {
234
+	public function update($row_id, $data = array(), $where = '') {
235 235
         /* @var WPDB $wpdb */
236 236
         global $wpdb;
237 237
 
238 238
 		// Row ID must be positive integer
239
-		$row_id = absint( $row_id );
239
+		$row_id = absint($row_id);
240 240
 
241
-		if ( empty( $row_id ) ) {
241
+		if (empty($row_id)) {
242 242
 			return false;
243 243
 		}
244 244
 
245
-		if ( empty( $where ) ) {
245
+		if (empty($where)) {
246 246
 			$where = $this->primary_key;
247 247
 		}
248 248
 
@@ -250,16 +250,16 @@  discard block
 block discarded – undo
250 250
 		$column_formats = $this->get_columns();
251 251
 
252 252
 		// Force fields to lower case
253
-		$data = array_change_key_case( $data );
253
+		$data = array_change_key_case($data);
254 254
 
255 255
 		// White list columns
256
-		$data = array_intersect_key( $data, $column_formats );
256
+		$data = array_intersect_key($data, $column_formats);
257 257
 
258 258
 		// Reorder $column_formats to match the order of columns given in $data
259
-		$data_keys      = array_keys( $data );
260
-		$column_formats = array_merge( array_flip( $data_keys ), $column_formats );
259
+		$data_keys      = array_keys($data);
260
+		$column_formats = array_merge(array_flip($data_keys), $column_formats);
261 261
 
262
-		if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) {
262
+		if (false === $wpdb->update($this->table_name, $data, array($where => $row_id), $column_formats)) {
263 263
 			return false;
264 264
 		}
265 265
 
@@ -276,18 +276,18 @@  discard block
 block discarded – undo
276 276
      *
277 277
 	 * @return bool
278 278
 	 */
279
-	public function delete( $row_id = 0 ) {
279
+	public function delete($row_id = 0) {
280 280
         /* @var WPDB $wpdb */
281 281
         global $wpdb;
282 282
 
283 283
 		// Row ID must be positive integer
284
-		$row_id = absint( $row_id );
284
+		$row_id = absint($row_id);
285 285
 
286
-		if ( empty( $row_id ) ) {
286
+		if (empty($row_id)) {
287 287
 			return false;
288 288
 		}
289 289
 
290
-		if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id ) ) ) {
290
+		if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id))) {
291 291
 			return false;
292 292
 		}
293 293
 
@@ -304,13 +304,13 @@  discard block
 block discarded – undo
304 304
      *
305 305
 	 * @return bool          If the table name exists.
306 306
 	 */
307
-	public function table_exists( $table ) {
307
+	public function table_exists($table) {
308 308
         /* @var WPDB $wpdb */
309 309
 		global $wpdb;
310 310
 
311
-		$table = sanitize_text_field( $table );
311
+		$table = sanitize_text_field($table);
312 312
 
313
-		return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table;
313
+		return $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE '%s'", $table)) === $table;
314 314
 	}
315 315
 
316 316
 	/**
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 	 * @return bool Returns if the customers table was installed and upgrade routine run.
323 323
 	 */
324 324
 	public function installed() {
325
-		return $this->table_exists( $this->table_name );
325
+		return $this->table_exists($this->table_name);
326 326
 	}
327 327
 
328 328
 	/**
@@ -332,8 +332,8 @@  discard block
 block discarded – undo
332 332
 	 * @access public
333 333
 	 */
334 334
 	public function register_table() {
335
-		$current_version = get_option( $this->table_name . '_db_version' );
336
-		if ( ! $current_version || version_compare( $current_version, $this->version, '<' ) ) {
335
+		$current_version = get_option($this->table_name.'_db_version');
336
+		if ( ! $current_version || version_compare($current_version, $this->version, '<')) {
337 337
 			$this->create_table();
338 338
 		}
339 339
 	}
@@ -344,5 +344,5 @@  discard block
 block discarded – undo
344 344
 	 * @since  1.8.9
345 345
 	 * @access public
346 346
 	 */
347
-	public function create_table(){}
347
+	public function create_table() {}
348 348
 }
Please login to merge, or discard this patch.
includes/install.php 1 patch
Spacing   +56 added lines, -56 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
 
@@ -26,15 +26,15 @@  discard block
 block discarded – undo
26 26
  * @global     $wpdb
27 27
  * @return void
28 28
  */
29
-function give_install( $network_wide = false ) {
29
+function give_install($network_wide = false) {
30 30
 
31 31
 	global $wpdb;
32 32
 
33
-	if ( is_multisite() && $network_wide ) {
33
+	if (is_multisite() && $network_wide) {
34 34
 
35
-		foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs LIMIT 100" ) as $blog_id ) {
35
+		foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs LIMIT 100") as $blog_id) {
36 36
 
37
-			switch_to_blog( $blog_id );
37
+			switch_to_blog($blog_id);
38 38
 			give_run_install();
39 39
 			restore_current_blog();
40 40
 
@@ -62,24 +62,24 @@  discard block
 block discarded – undo
62 62
 	give_setup_post_types();
63 63
 
64 64
 	// Clear the permalinks.
65
-	flush_rewrite_rules( false );
65
+	flush_rewrite_rules(false);
66 66
 
67 67
 	// Add Upgraded From Option.
68
-	$current_version = get_option( 'give_version' );
69
-	if ( $current_version ) {
70
-		update_option( 'give_version_upgraded_from', $current_version );
68
+	$current_version = get_option('give_version');
69
+	if ($current_version) {
70
+		update_option('give_version_upgraded_from', $current_version);
71 71
 	}
72 72
 
73 73
 	// Setup some default options.
74 74
 	$options = array();
75 75
 
76 76
 	// Checks if the Success Page option exists AND that the page exists.
77
-	if ( ! get_post( give_get_option( 'success_page' ) ) ) {
77
+	if ( ! get_post(give_get_option('success_page'))) {
78 78
 
79 79
 		// Donation Confirmation (Success) Page
80 80
 		$success = wp_insert_post(
81 81
 			array(
82
-				'post_title'     => esc_html__( 'Donation Confirmation', 'give' ),
82
+				'post_title'     => esc_html__('Donation Confirmation', 'give'),
83 83
 				'post_content'   => '[give_receipt]',
84 84
 				'post_status'    => 'publish',
85 85
 				'post_author'    => 1,
@@ -93,13 +93,13 @@  discard block
 block discarded – undo
93 93
 	}
94 94
 
95 95
 	// Checks if the Failure Page option exists AND that the page exists.
96
-	if ( ! get_post( give_get_option( 'failure_page' ) ) ) {
96
+	if ( ! get_post(give_get_option('failure_page'))) {
97 97
 
98 98
 		// Failed Donation Page
99 99
 		$failed = wp_insert_post(
100 100
 			array(
101
-				'post_title'     => esc_html__( 'Donation Failed', 'give' ),
102
-				'post_content'   => esc_html__( 'We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give' ),
101
+				'post_title'     => esc_html__('Donation Failed', 'give'),
102
+				'post_content'   => esc_html__('We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give'),
103 103
 				'post_status'    => 'publish',
104 104
 				'post_author'    => 1,
105 105
 				'post_type'      => 'page',
@@ -111,11 +111,11 @@  discard block
 block discarded – undo
111 111
 	}
112 112
 
113 113
 	// Checks if the History Page option exists AND that the page exists.
114
-	if ( ! get_post( give_get_option( 'history_page' ) ) ) {
114
+	if ( ! get_post(give_get_option('history_page'))) {
115 115
 		// Donation History Page
116 116
 		$history = wp_insert_post(
117 117
 			array(
118
-				'post_title'     => esc_html__( 'Donation History', 'give' ),
118
+				'post_title'     => esc_html__('Donation History', 'give'),
119 119
 				'post_content'   => '[donation_history]',
120 120
 				'post_status'    => 'publish',
121 121
 				'post_author'    => 1,
@@ -128,22 +128,22 @@  discard block
 block discarded – undo
128 128
 	}
129 129
 
130 130
 	//Fresh Install? Setup Test Mode, Base Country (US), Test Gateway, Currency.
131
-	if ( empty( $current_version ) ) {
132
-		$options = array_merge( $options, give_get_default_settings() );
131
+	if (empty($current_version)) {
132
+		$options = array_merge($options, give_get_default_settings());
133 133
 	}
134 134
 
135 135
 	// Populate the default values.
136
-	update_option( 'give_settings', array_merge( $give_options, $options ) );
136
+	update_option('give_settings', array_merge($give_options, $options));
137 137
 
138 138
 	/**
139 139
 	 * Run plugin upgrades.
140 140
 	 *
141 141
 	 * @since 1.8
142 142
 	 */
143
-	do_action( 'give_upgrades' );
143
+	do_action('give_upgrades');
144 144
 
145
-	if ( GIVE_VERSION !== get_option( 'give_version' ) ) {
146
-		update_option( 'give_version', GIVE_VERSION );
145
+	if (GIVE_VERSION !== get_option('give_version')) {
146
+		update_option('give_version', GIVE_VERSION);
147 147
 	}
148 148
 
149 149
 	// Create Give roles.
@@ -152,18 +152,18 @@  discard block
 block discarded – undo
152 152
 	$roles->add_caps();
153 153
 
154 154
 	$api = new Give_API();
155
-	update_option( 'give_default_api_version', 'v' . $api->get_version() );
155
+	update_option('give_default_api_version', 'v'.$api->get_version());
156 156
 
157 157
 	// Check for PHP Session support, and enable if available.
158 158
 	$give_sessions = new Give_Session();
159 159
 	$give_sessions->use_php_sessions();
160 160
 
161 161
 	// Add a temporary option to note that Give pages have been created.
162
-	Give_Cache::set( '_give_installed', $options, 30, true );
162
+	Give_Cache::set('_give_installed', $options, 30, true);
163 163
 
164
-	if ( ! $current_version ) {
164
+	if ( ! $current_version) {
165 165
 
166
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php';
166
+		require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php';
167 167
 
168 168
 		// When new upgrade routines are added, mark them as complete on fresh install.
169 169
 		$upgrade_routines = array(
@@ -175,18 +175,18 @@  discard block
 block discarded – undo
175 175
 			'v189_upgrades_levels_post_meta'
176 176
 		);
177 177
 
178
-		foreach ( $upgrade_routines as $upgrade ) {
179
-			give_set_upgrade_complete( $upgrade );
178
+		foreach ($upgrade_routines as $upgrade) {
179
+			give_set_upgrade_complete($upgrade);
180 180
 		}
181 181
 	}
182 182
 
183 183
 	// Bail if activating from network, or bulk.
184
-	if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
184
+	if (is_network_admin() || isset($_GET['activate-multi'])) {
185 185
 		return;
186 186
 	}
187 187
 
188 188
 	// Add the transient to redirect.
189
-	Give_Cache::set( '_give_activation_redirect', true, 30, true );
189
+	Give_Cache::set('_give_activation_redirect', true, 30, true);
190 190
 
191 191
 	// Set 'Donation Form' meta box enabled by default.
192 192
 	give_nav_donation_metabox_enabled();
@@ -206,11 +206,11 @@  discard block
 block discarded – undo
206 206
  * @param  int $site_id The Site ID.
207 207
  * @param  array $meta Blog Meta.
208 208
  */
209
-function give_on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
209
+function give_on_create_blog($blog_id, $user_id, $domain, $path, $site_id, $meta) {
210 210
 
211
-	if ( is_plugin_active_for_network( GIVE_PLUGIN_BASENAME ) ) {
211
+	if (is_plugin_active_for_network(GIVE_PLUGIN_BASENAME)) {
212 212
 
213
-		switch_to_blog( $blog_id );
213
+		switch_to_blog($blog_id);
214 214
 		give_install();
215 215
 		restore_current_blog();
216 216
 
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 
219 219
 }
220 220
 
221
-add_action( 'wpmu_new_blog', 'give_on_create_blog', 10, 6 );
221
+add_action('wpmu_new_blog', 'give_on_create_blog', 10, 6);
222 222
 
223 223
 
224 224
 /**
@@ -231,13 +231,13 @@  discard block
 block discarded – undo
231 231
  *
232 232
  * @return array          The tables to drop.
233 233
  */
234
-function give_wpmu_drop_tables( $tables, $blog_id ) {
234
+function give_wpmu_drop_tables($tables, $blog_id) {
235 235
 
236
-	switch_to_blog( $blog_id );
236
+	switch_to_blog($blog_id);
237 237
 	$donors_db     = new Give_DB_Donors();
238 238
 	$donor_meta_db = new Give_DB_Donor_Meta();
239 239
 
240
-	if ( $donors_db->installed() ) {
240
+	if ($donors_db->installed()) {
241 241
 		$tables[] = $donors_db->table_name;
242 242
 		$tables[] = $donor_meta_db->table_name;
243 243
 	}
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 
248 248
 }
249 249
 
250
-add_filter( 'wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2 );
250
+add_filter('wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2);
251 251
 
252 252
 /**
253 253
  * Post-installation
@@ -259,16 +259,16 @@  discard block
 block discarded – undo
259 259
  */
260 260
 function give_after_install() {
261 261
 
262
-	if ( ! is_admin() ) {
262
+	if ( ! is_admin()) {
263 263
 		return;
264 264
 	}
265 265
 
266
-	$give_options     = Give_Cache::get( '_give_installed', true );
267
-	$give_table_check = get_option( '_give_table_check', false );
266
+	$give_options     = Give_Cache::get('_give_installed', true);
267
+	$give_table_check = get_option('_give_table_check', false);
268 268
 
269
-	if ( false === $give_table_check || current_time( 'timestamp' ) > $give_table_check ) {
269
+	if (false === $give_table_check || current_time('timestamp') > $give_table_check) {
270 270
 
271
-		if ( ! @Give()->donor_meta->installed() ) {
271
+		if ( ! @Give()->donor_meta->installed()) {
272 272
 
273 273
 			// Create the donor meta database.
274 274
 			// (this ensures it creates it on multisite instances where it is network activated).
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 
277 277
 		}
278 278
 
279
-		if ( ! @Give()->donors->installed() ) {
279
+		if ( ! @Give()->donors->installed()) {
280 280
 			// Create the donor database.
281 281
 			// (this ensures it creates it on multisite instances where it is network activated).
282 282
 			@Give()->donors->create_table();
@@ -288,22 +288,22 @@  discard block
 block discarded – undo
288 288
 			 *
289 289
 			 * @param array $give_options Give plugin options.
290 290
 			 */
291
-			do_action( 'give_after_install', $give_options );
291
+			do_action('give_after_install', $give_options);
292 292
 		}
293 293
 
294
-		update_option( '_give_table_check', ( current_time( 'timestamp' ) + WEEK_IN_SECONDS ) );
294
+		update_option('_give_table_check', (current_time('timestamp') + WEEK_IN_SECONDS));
295 295
 
296 296
 	}
297 297
 
298 298
 	// Delete the transient
299
-	if ( false !== $give_options ) {
300
-		Give_Cache::delete( Give_Cache::get_key( '_give_installed' ) );
299
+	if (false !== $give_options) {
300
+		Give_Cache::delete(Give_Cache::get_key('_give_installed'));
301 301
 	}
302 302
 
303 303
 
304 304
 }
305 305
 
306
-add_action( 'admin_init', 'give_after_install' );
306
+add_action('admin_init', 'give_after_install');
307 307
 
308 308
 
309 309
 /**
@@ -318,11 +318,11 @@  discard block
 block discarded – undo
318 318
 
319 319
 	global $wp_roles;
320 320
 
321
-	if ( ! is_object( $wp_roles ) ) {
321
+	if ( ! is_object($wp_roles)) {
322 322
 		return;
323 323
 	}
324 324
 
325
-	if ( ! array_key_exists( 'give_manager', $wp_roles->roles ) ) {
325
+	if ( ! array_key_exists('give_manager', $wp_roles->roles)) {
326 326
 
327 327
 		// Create Give plugin roles
328 328
 		$roles = new Give_Roles();
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 
334 334
 }
335 335
 
336
-add_action( 'admin_init', 'give_install_roles_on_network' );
336
+add_action('admin_init', 'give_install_roles_on_network');
337 337
 
338 338
 /**
339 339
  * Default core setting values.
@@ -369,14 +369,14 @@  discard block
 block discarded – undo
369 369
 		'uninstall_on_delete'                         => 'disabled',
370 370
 		'the_content_filter'                          => 'enabled',
371 371
 		'scripts_footer'                              => 'disabled',
372
-		'agree_to_terms_label'                        => __( 'Agree to Terms?', 'give' ),
372
+		'agree_to_terms_label'                        => __('Agree to Terms?', 'give'),
373 373
 		'agreement_text'                              => give_get_default_agreement_text(),
374 374
 
375 375
 		// Paypal IPN verification.
376 376
 		'paypal_verification'                         => 'enabled',
377 377
 
378 378
 		// Default is manual gateway.
379
-		'gateways'                                    => array( 'manual' => 1, 'offline' => 1 ),
379
+		'gateways'                                    => array('manual' => 1, 'offline' => 1),
380 380
 		'default_gateway'                             => 'manual',
381 381
 
382 382
 		// Offline gateway setup.
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
  */
402 402
 function give_get_default_agreement_text() {
403 403
 
404
-	$org_name = get_bloginfo( 'name' );
404
+	$org_name = get_bloginfo('name');
405 405
 
406 406
 	$agreement = sprintf(
407 407
 		'<p>Acceptance of any contribution, gift or grant is at the discretion of the %1$s. The  %1$s will not accept any gift unless it can be used or expended consistently with the purpose and mission of the  %1$s.</p>
@@ -415,5 +415,5 @@  discard block
 block discarded – undo
415 415
 		$org_name
416 416
 	);
417 417
 
418
-	return apply_filters( 'give_get_default_agreement_text', $agreement, $org_name );
418
+	return apply_filters('give_get_default_agreement_text', $agreement, $org_name);
419 419
 }
Please login to merge, or discard this patch.
includes/shortcodes.php 1 patch
Spacing   +100 added lines, -100 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
 
@@ -26,15 +26,15 @@  discard block
 block discarded – undo
26 26
 function give_donation_history() {
27 27
 
28 28
 	// If payment_key query arg exists, return receipt instead of donation history.
29
-	if ( isset( $_GET['payment_key'] ) ) {
29
+	if (isset($_GET['payment_key'])) {
30 30
 		ob_start();
31
-		echo give_receipt_shortcode( array() );
32
-		echo '<a href="' . esc_url( give_get_history_page_uri() ) . '">&laquo; ' . __( 'Return to All Donations', 'give' ) . '</a>';
31
+		echo give_receipt_shortcode(array());
32
+		echo '<a href="'.esc_url(give_get_history_page_uri()).'">&laquo; '.__('Return to All Donations', 'give').'</a>';
33 33
 
34 34
 		return ob_get_clean();
35 35
 	}
36 36
 
37
-	$email_access = give_get_option( 'email_access' );
37
+	$email_access = give_get_option('email_access');
38 38
 
39 39
 	/**
40 40
 	 * Determine access
@@ -44,30 +44,30 @@  discard block
 block discarded – undo
44 44
 	 */
45 45
 	if (
46 46
 		is_user_logged_in() || false !== Give()->session->get_session_expiration()
47
-		|| ( give_is_setting_enabled( $email_access ) && Give()->email_access->token_exists )
47
+		|| (give_is_setting_enabled($email_access) && Give()->email_access->token_exists)
48 48
 	) {
49 49
 		ob_start();
50
-		give_get_template_part( 'history', 'donations' );
50
+		give_get_template_part('history', 'donations');
51 51
 
52 52
 		return ob_get_clean();
53 53
 
54
-	} elseif ( give_is_setting_enabled( $email_access ) ) {
54
+	} elseif (give_is_setting_enabled($email_access)) {
55 55
 		// Is Email-based access enabled?
56 56
 		ob_start();
57
-		give_get_template_part( 'email', 'login-form' );
57
+		give_get_template_part('email', 'login-form');
58 58
 
59 59
 		return ob_get_clean();
60 60
 
61 61
 	} else {
62 62
 
63
-		$output = apply_filters( 'give_donation_history_nonuser_message', Give()->notices->print_frontend_notice( __( 'You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give' ), false ) );
64
-		$output .= do_shortcode( '[give_login]' );
63
+		$output = apply_filters('give_donation_history_nonuser_message', Give()->notices->print_frontend_notice(__('You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give'), false));
64
+		$output .= do_shortcode('[give_login]');
65 65
 
66 66
 		return $output;
67 67
 	}
68 68
 }
69 69
 
70
-add_shortcode( 'donation_history', 'give_donation_history' );
70
+add_shortcode('donation_history', 'give_donation_history');
71 71
 
72 72
 /**
73 73
  * Donation Form Shortcode
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
  *
81 81
  * @return string
82 82
  */
83
-function give_form_shortcode( $atts ) {
84
-	$atts = shortcode_atts( array(
83
+function give_form_shortcode($atts) {
84
+	$atts = shortcode_atts(array(
85 85
 		'id'                    => '',
86 86
 		'show_title'            => true,
87 87
 		'show_goal'             => true,
@@ -89,21 +89,21 @@  discard block
 block discarded – undo
89 89
 		'float_labels'          => '',
90 90
 		'display_style'         => '',
91 91
 		'continue_button_title' => '',
92
-	), $atts, 'give_form' );
92
+	), $atts, 'give_form');
93 93
 
94 94
 	// Convert string to bool.
95
-	$atts['show_title'] = filter_var( $atts['show_title'], FILTER_VALIDATE_BOOLEAN );
96
-	$atts['show_goal']  = filter_var( $atts['show_goal'], FILTER_VALIDATE_BOOLEAN );
95
+	$atts['show_title'] = filter_var($atts['show_title'], FILTER_VALIDATE_BOOLEAN);
96
+	$atts['show_goal']  = filter_var($atts['show_goal'], FILTER_VALIDATE_BOOLEAN);
97 97
 
98 98
 	//get the Give Form
99 99
 	ob_start();
100
-	give_get_donation_form( $atts );
100
+	give_get_donation_form($atts);
101 101
 	$final_output = ob_get_clean();
102 102
 
103
-	return apply_filters( 'give_donate_form', $final_output, $atts );
103
+	return apply_filters('give_donate_form', $final_output, $atts);
104 104
 }
105 105
 
106
-add_shortcode( 'give_form', 'give_form_shortcode' );
106
+add_shortcode('give_form', 'give_form_shortcode');
107 107
 
108 108
 /**
109 109
  * Donation Form Goal Shortcode.
@@ -116,37 +116,37 @@  discard block
 block discarded – undo
116 116
  *
117 117
  * @return string
118 118
  */
119
-function give_goal_shortcode( $atts ) {
120
-	$atts = shortcode_atts( array(
119
+function give_goal_shortcode($atts) {
120
+	$atts = shortcode_atts(array(
121 121
 		'id'        => '',
122 122
 		'show_text' => true,
123 123
 		'show_bar'  => true,
124
-	), $atts, 'give_goal' );
124
+	), $atts, 'give_goal');
125 125
 
126 126
 
127 127
 	//get the Give Form.
128 128
 	ob_start();
129 129
 
130 130
 	//Sanity check 1: ensure there is an ID Provided.
131
-	if ( empty( $atts['id'] ) ) {
132
-		Give()->notices->print_frontend_notice( __( 'The shortcode is missing Donation Form ID attribute.', 'give' ), true );
131
+	if (empty($atts['id'])) {
132
+		Give()->notices->print_frontend_notice(__('The shortcode is missing Donation Form ID attribute.', 'give'), true);
133 133
 	}
134 134
 
135 135
 	//Sanity check 2: Check the form even has Goals enabled.
136
-	if ( ! give_is_setting_enabled( give_get_meta( $atts['id'], '_give_goal_option', true ) ) ) {
136
+	if ( ! give_is_setting_enabled(give_get_meta($atts['id'], '_give_goal_option', true))) {
137 137
 
138
-		Give()->notices->print_frontend_notice( __( 'The form does not have Goals enabled.', 'give' ), true );
138
+		Give()->notices->print_frontend_notice(__('The form does not have Goals enabled.', 'give'), true);
139 139
 	} else {
140 140
 		//Passed all sanity checks: output Goal.
141
-		give_show_goal_progress( $atts['id'], $atts );
141
+		give_show_goal_progress($atts['id'], $atts);
142 142
 	}
143 143
 
144 144
 	$final_output = ob_get_clean();
145 145
 
146
-	return apply_filters( 'give_goal_shortcode_output', $final_output, $atts );
146
+	return apply_filters('give_goal_shortcode_output', $final_output, $atts);
147 147
 }
148 148
 
149
-add_shortcode( 'give_goal', 'give_goal_shortcode' );
149
+add_shortcode('give_goal', 'give_goal_shortcode');
150 150
 
151 151
 
152 152
 /**
@@ -163,22 +163,22 @@  discard block
 block discarded – undo
163 163
  *
164 164
  * @return string
165 165
  */
166
-function give_login_form_shortcode( $atts ) {
167
-	$atts = shortcode_atts( array(
166
+function give_login_form_shortcode($atts) {
167
+	$atts = shortcode_atts(array(
168 168
 		// Add backward compatibility for redirect attribute.
169 169
 		'redirect' => '',
170 170
 
171 171
 		'login-redirect'  => '',
172 172
 		'logout-redirect' => '',
173
-	), $atts, 'give_login' );
173
+	), $atts, 'give_login');
174 174
 
175 175
 	// Check login-redirect attribute first, if it empty or not found then check for redirect attribute and add value of this to login-redirect attribute.
176
-	$atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect'] ) ? $atts['redirect'] : '' );
176
+	$atts['login-redirect'] = ! empty($atts['login-redirect']) ? $atts['login-redirect'] : ( ! empty($atts['redirect']) ? $atts['redirect'] : '');
177 177
 
178
-	return give_login_form( $atts['login-redirect'], $atts['logout-redirect'] );
178
+	return give_login_form($atts['login-redirect'], $atts['logout-redirect']);
179 179
 }
180 180
 
181
-add_shortcode( 'give_login', 'give_login_form_shortcode' );
181
+add_shortcode('give_login', 'give_login_form_shortcode');
182 182
 
183 183
 /**
184 184
  * Register Shortcode.
@@ -193,15 +193,15 @@  discard block
 block discarded – undo
193 193
  *
194 194
  * @return string
195 195
  */
196
-function give_register_form_shortcode( $atts ) {
197
-	$atts = shortcode_atts( array(
196
+function give_register_form_shortcode($atts) {
197
+	$atts = shortcode_atts(array(
198 198
 		'redirect' => '',
199
-	), $atts, 'give_register' );
199
+	), $atts, 'give_register');
200 200
 
201
-	return give_register_form( $atts['redirect'] );
201
+	return give_register_form($atts['redirect']);
202 202
 }
203 203
 
204
-add_shortcode( 'give_register', 'give_register_form_shortcode' );
204
+add_shortcode('give_register', 'give_register_form_shortcode');
205 205
 
206 206
 /**
207 207
  * Receipt Shortcode.
@@ -214,12 +214,12 @@  discard block
 block discarded – undo
214 214
  *
215 215
  * @return string
216 216
  */
217
-function give_receipt_shortcode( $atts ) {
217
+function give_receipt_shortcode($atts) {
218 218
 
219 219
 	global $give_receipt_args, $payment;
220 220
 
221
-	$give_receipt_args = shortcode_atts( array(
222
-		'error'          => __( 'You are missing the payment key to view this donation receipt.', 'give' ),
221
+	$give_receipt_args = shortcode_atts(array(
222
+		'error'          => __('You are missing the payment key to view this donation receipt.', 'give'),
223 223
 		'price'          => true,
224 224
 		'donor'          => true,
225 225
 		'date'           => true,
@@ -228,50 +228,50 @@  discard block
 block discarded – undo
228 228
 		'payment_id'     => true,
229 229
 		'payment_status' => false,
230 230
 		'status_notice'  => true,
231
-	), $atts, 'give_receipt' );
231
+	), $atts, 'give_receipt');
232 232
 
233 233
 	//set $session var
234 234
 	$session = give_get_purchase_session();
235 235
 
236 236
 	//set payment key var
237
-	if ( isset( $_GET['payment_key'] ) ) {
238
-		$payment_key = urldecode( $_GET['payment_key'] );
239
-	} elseif ( $session ) {
237
+	if (isset($_GET['payment_key'])) {
238
+		$payment_key = urldecode($_GET['payment_key']);
239
+	} elseif ($session) {
240 240
 		$payment_key = $session['purchase_key'];
241
-	} elseif ( $give_receipt_args['payment_key'] ) {
241
+	} elseif ($give_receipt_args['payment_key']) {
242 242
 		$payment_key = $give_receipt_args['payment_key'];
243 243
 	}
244 244
 
245
-	$email_access = give_get_option( 'email_access' );
245
+	$email_access = give_get_option('email_access');
246 246
 
247 247
 	// No payment_key found & Email Access is Turned on:
248
-	if ( ! isset( $payment_key ) && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) {
248
+	if ( ! isset($payment_key) && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) {
249 249
 
250 250
 		ob_start();
251 251
 
252
-		give_get_template_part( 'email-login-form' );
252
+		give_get_template_part('email-login-form');
253 253
 
254 254
 		return ob_get_clean();
255 255
 
256
-	} elseif ( ! isset( $payment_key ) ) {
256
+	} elseif ( ! isset($payment_key)) {
257 257
 
258
-		return Give()->notices->print_frontend_notice( $give_receipt_args['error'], false, 'error' );
258
+		return Give()->notices->print_frontend_notice($give_receipt_args['error'], false, 'error');
259 259
 
260 260
 	}
261 261
 
262
-	$payment_id    = give_get_purchase_id_by_key( $payment_key );
263
-	$user_can_view = give_can_view_receipt( $payment_key );
262
+	$payment_id    = give_get_purchase_id_by_key($payment_key);
263
+	$user_can_view = give_can_view_receipt($payment_key);
264 264
 
265 265
 	// Key was provided, but user is logged out. Offer them the ability to login and view the receipt.
266
-	if ( ! $user_can_view && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) {
266
+	if ( ! $user_can_view && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) {
267 267
 
268 268
 		ob_start();
269 269
 
270
-		give_get_template_part( 'email-login-form' );
270
+		give_get_template_part('email-login-form');
271 271
 
272 272
 		return ob_get_clean();
273 273
 
274
-	} elseif ( ! $user_can_view ) {
274
+	} elseif ( ! $user_can_view) {
275 275
 
276 276
 		global $give_login_redirect;
277 277
 
@@ -279,9 +279,9 @@  discard block
 block discarded – undo
279 279
 
280 280
 		ob_start();
281 281
 
282
-		Give()->notices->print_frontend_notice( apply_filters( 'give_must_be_logged_in_error_message', __( 'You must be logged in to view this donation receipt.', 'give' ) ) );
282
+		Give()->notices->print_frontend_notice(apply_filters('give_must_be_logged_in_error_message', __('You must be logged in to view this donation receipt.', 'give')));
283 283
 
284
-		give_get_template_part( 'shortcode', 'login' );
284
+		give_get_template_part('shortcode', 'login');
285 285
 
286 286
 		$login_form = ob_get_clean();
287 287
 
@@ -296,20 +296,20 @@  discard block
 block discarded – undo
296 296
 	 * or if user is logged in and the user can view sensitive shop data.
297 297
 	 *
298 298
 	 */
299
-	if ( ! apply_filters( 'give_user_can_view_receipt', $user_can_view, $give_receipt_args ) ) {
300
-		return Give()->notices->print_frontend_notice( $give_receipt_args['error'], false, 'error' );
299
+	if ( ! apply_filters('give_user_can_view_receipt', $user_can_view, $give_receipt_args)) {
300
+		return Give()->notices->print_frontend_notice($give_receipt_args['error'], false, 'error');
301 301
 	}
302 302
 
303 303
 	ob_start();
304 304
 
305
-	give_get_template_part( 'shortcode', 'receipt' );
305
+	give_get_template_part('shortcode', 'receipt');
306 306
 
307 307
 	$display = ob_get_clean();
308 308
 
309 309
 	return $display;
310 310
 }
311 311
 
312
-add_shortcode( 'give_receipt', 'give_receipt_shortcode' );
312
+add_shortcode('give_receipt', 'give_receipt_shortcode');
313 313
 
314 314
 /**
315 315
  * Profile Editor Shortcode.
@@ -328,18 +328,18 @@  discard block
 block discarded – undo
328 328
  *
329 329
  * @return string Output generated from the profile editor
330 330
  */
331
-function give_profile_editor_shortcode( $atts ) {
331
+function give_profile_editor_shortcode($atts) {
332 332
 
333 333
 	ob_start();
334 334
 
335
-	give_get_template_part( 'shortcode', 'profile-editor' );
335
+	give_get_template_part('shortcode', 'profile-editor');
336 336
 
337 337
 	$display = ob_get_clean();
338 338
 
339 339
 	return $display;
340 340
 }
341 341
 
342
-add_shortcode( 'give_profile_editor', 'give_profile_editor_shortcode' );
342
+add_shortcode('give_profile_editor', 'give_profile_editor_shortcode');
343 343
 
344 344
 /**
345 345
  * Process Profile Updater Form.
@@ -352,30 +352,30 @@  discard block
 block discarded – undo
352 352
  *
353 353
  * @return bool
354 354
  */
355
-function give_process_profile_editor_updates( $data ) {
355
+function give_process_profile_editor_updates($data) {
356 356
 	// Profile field change request
357
-	if ( empty( $_POST['give_profile_editor_submit'] ) && ! is_user_logged_in() ) {
357
+	if (empty($_POST['give_profile_editor_submit']) && ! is_user_logged_in()) {
358 358
 		return false;
359 359
 	}
360 360
 
361 361
 	// Nonce security
362
-	if ( ! wp_verify_nonce( $data['give_profile_editor_nonce'], 'give-profile-editor-nonce' ) ) {
362
+	if ( ! wp_verify_nonce($data['give_profile_editor_nonce'], 'give-profile-editor-nonce')) {
363 363
 		return false;
364 364
 	}
365 365
 
366 366
 	$user_id       = get_current_user_id();
367
-	$old_user_data = get_userdata( $user_id );
368
-
369
-	$display_name = isset( $data['give_display_name'] ) ? sanitize_text_field( $data['give_display_name'] ) : $old_user_data->display_name;
370
-	$first_name   = isset( $data['give_first_name'] ) ? sanitize_text_field( $data['give_first_name'] ) : $old_user_data->first_name;
371
-	$last_name    = isset( $data['give_last_name'] ) ? sanitize_text_field( $data['give_last_name'] ) : $old_user_data->last_name;
372
-	$email        = isset( $data['give_email'] ) ? sanitize_email( $data['give_email'] ) : $old_user_data->user_email;
373
-	$line1        = ( isset( $data['give_address_line1'] ) ? sanitize_text_field( $data['give_address_line1'] ) : '' );
374
-	$line2        = ( isset( $data['give_address_line2'] ) ? sanitize_text_field( $data['give_address_line2'] ) : '' );
375
-	$city         = ( isset( $data['give_address_city'] ) ? sanitize_text_field( $data['give_address_city'] ) : '' );
376
-	$state        = ( isset( $data['give_address_state'] ) ? sanitize_text_field( $data['give_address_state'] ) : '' );
377
-	$zip          = ( isset( $data['give_address_zip'] ) ? sanitize_text_field( $data['give_address_zip'] ) : '' );
378
-	$country      = ( isset( $data['give_address_country'] ) ? sanitize_text_field( $data['give_address_country'] ) : '' );
367
+	$old_user_data = get_userdata($user_id);
368
+
369
+	$display_name = isset($data['give_display_name']) ? sanitize_text_field($data['give_display_name']) : $old_user_data->display_name;
370
+	$first_name   = isset($data['give_first_name']) ? sanitize_text_field($data['give_first_name']) : $old_user_data->first_name;
371
+	$last_name    = isset($data['give_last_name']) ? sanitize_text_field($data['give_last_name']) : $old_user_data->last_name;
372
+	$email        = isset($data['give_email']) ? sanitize_email($data['give_email']) : $old_user_data->user_email;
373
+	$line1        = (isset($data['give_address_line1']) ? sanitize_text_field($data['give_address_line1']) : '');
374
+	$line2        = (isset($data['give_address_line2']) ? sanitize_text_field($data['give_address_line2']) : '');
375
+	$city         = (isset($data['give_address_city']) ? sanitize_text_field($data['give_address_city']) : '');
376
+	$state        = (isset($data['give_address_state']) ? sanitize_text_field($data['give_address_state']) : '');
377
+	$zip          = (isset($data['give_address_zip']) ? sanitize_text_field($data['give_address_zip']) : '');
378
+	$country      = (isset($data['give_address_country']) ? sanitize_text_field($data['give_address_country']) : '');
379 379
 
380 380
 	$userdata = array(
381 381
 		'ID'           => $user_id,
@@ -403,40 +403,40 @@  discard block
 block discarded – undo
403 403
 	 * @param int $user_id The ID of the user.
404 404
 	 * @param array $userdata User info, including ID, first name, last name, display name and email.
405 405
 	 */
406
-	do_action( 'give_pre_update_user_profile', $user_id, $userdata );
406
+	do_action('give_pre_update_user_profile', $user_id, $userdata);
407 407
 
408 408
 	// Make sure to validate passwords for existing Donors
409
-	give_validate_user_password( $data['give_new_user_pass1'], $data['give_new_user_pass2'] );
409
+	give_validate_user_password($data['give_new_user_pass1'], $data['give_new_user_pass2']);
410 410
 
411
-	if ( empty( $email ) ) {
411
+	if (empty($email)) {
412 412
 		// Make sure email should not be empty.
413
-		give_set_error( 'email_empty', __( 'The email you entered is empty.', 'give' ) );
413
+		give_set_error('email_empty', __('The email you entered is empty.', 'give'));
414 414
 
415
-	} else if ( ! is_email( $email ) ) {
415
+	} else if ( ! is_email($email)) {
416 416
 		// Make sure email should be valid.
417
-		give_set_error( 'email_not_valid', __( 'The email you entered is not valid. Please use another', 'give' ) );
417
+		give_set_error('email_not_valid', __('The email you entered is not valid. Please use another', 'give'));
418 418
 
419
-	} else if ( $email != $old_user_data->user_email ) {
419
+	} else if ($email != $old_user_data->user_email) {
420 420
 		// Make sure the new email doesn't belong to another user
421
-		if ( email_exists( $email ) ) {
422
-			give_set_error( 'email_exists', __( 'The email you entered belongs to another user. Please use another.', 'give' ) );
421
+		if (email_exists($email)) {
422
+			give_set_error('email_exists', __('The email you entered belongs to another user. Please use another.', 'give'));
423 423
 		}
424 424
 	}
425 425
 
426 426
 	// Check for errors
427 427
 	$errors = give_get_errors();
428 428
 
429
-	if ( $errors ) {
429
+	if ($errors) {
430 430
 		// Send back to the profile editor if there are errors
431
-		wp_redirect( $data['give_redirect'] );
431
+		wp_redirect($data['give_redirect']);
432 432
 		give_die();
433 433
 	}
434 434
 
435 435
 	// Update the user
436
-	$meta    = update_user_meta( $user_id, '_give_user_address', $address );
437
-	$updated = wp_update_user( $userdata );
436
+	$meta    = update_user_meta($user_id, '_give_user_address', $address);
437
+	$updated = wp_update_user($userdata);
438 438
 
439
-	if ( $updated ) {
439
+	if ($updated) {
440 440
 
441 441
 		/**
442 442
 		 * Fires after updating user profile.
@@ -446,12 +446,12 @@  discard block
 block discarded – undo
446 446
 		 * @param int $user_id The ID of the user.
447 447
 		 * @param array $userdata User info, including ID, first name, last name, display name and email.
448 448
 		 */
449
-		do_action( 'give_user_profile_updated', $user_id, $userdata );
450
-		wp_redirect( add_query_arg( 'updated', 'true', $data['give_redirect'] ) );
449
+		do_action('give_user_profile_updated', $user_id, $userdata);
450
+		wp_redirect(add_query_arg('updated', 'true', $data['give_redirect']));
451 451
 		give_die();
452 452
 	}
453 453
 
454 454
 	return false;
455 455
 }
456 456
 
457
-add_action( 'give_edit_user_profile', 'give_process_profile_editor_updates' );
457
+add_action('give_edit_user_profile', 'give_process_profile_editor_updates');
Please login to merge, or discard this patch.
includes/user-functions.php 1 patch
Spacing   +143 added lines, -143 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
 
@@ -30,54 +30,54 @@  discard block
 block discarded – undo
30 30
  *
31 31
  * @return bool|array List of all user donations.
32 32
  */
33
-function give_get_users_donations( $user = 0, $number = 20, $pagination = false, $status = 'complete' ) {
33
+function give_get_users_donations($user = 0, $number = 20, $pagination = false, $status = 'complete') {
34 34
 
35
-	if ( empty( $user ) ) {
35
+	if (empty($user)) {
36 36
 		$user = get_current_user_id();
37 37
 	}
38 38
 
39
-	if ( 0 === $user && ! Give()->email_access->token_exists ) {
39
+	if (0 === $user && ! Give()->email_access->token_exists) {
40 40
 		return false;
41 41
 	}
42 42
 
43 43
 	$status = $status === 'complete' ? 'publish' : $status;
44 44
 	$paged = 1;
45 45
 
46
-	if ( $pagination ) {
47
-		if ( get_query_var( 'paged' ) ) {
48
-			$paged = get_query_var( 'paged' );
49
-		} elseif ( get_query_var( 'page' ) ) {
50
-			$paged = get_query_var( 'page' );
46
+	if ($pagination) {
47
+		if (get_query_var('paged')) {
48
+			$paged = get_query_var('paged');
49
+		} elseif (get_query_var('page')) {
50
+			$paged = get_query_var('page');
51 51
 		}
52 52
 	}
53 53
 
54
-	$args = apply_filters( 'give_get_users_donations_args', array(
54
+	$args = apply_filters('give_get_users_donations_args', array(
55 55
 		'user'    => $user,
56 56
 		'number'  => $number,
57 57
 		'status'  => $status,
58 58
 		'orderby' => 'date',
59
-	) );
59
+	));
60 60
 
61
-	if ( $pagination ) {
61
+	if ($pagination) {
62 62
 		$args['page'] = $paged;
63 63
 	} else {
64 64
 		$args['nopaging'] = true;
65 65
 	}
66 66
 
67
-	$by_user_id = is_numeric( $user ) ? true : false;
68
-	$donor   = new Give_Donor( $user, $by_user_id );
67
+	$by_user_id = is_numeric($user) ? true : false;
68
+	$donor = new Give_Donor($user, $by_user_id);
69 69
 
70
-	if ( ! empty( $donor->payment_ids ) ) {
70
+	if ( ! empty($donor->payment_ids)) {
71 71
 
72
-		unset( $args['user'] );
73
-		$args['post__in'] = array_map( 'absint', explode( ',', $donor->payment_ids ) );
72
+		unset($args['user']);
73
+		$args['post__in'] = array_map('absint', explode(',', $donor->payment_ids));
74 74
 
75 75
 	}
76 76
 
77
-	$donations = give_get_payments( apply_filters( 'give_get_users_donations_args', $args ) );
77
+	$donations = give_get_payments(apply_filters('give_get_users_donations_args', $args));
78 78
 
79 79
 	// No donations
80
-	if ( ! $donations ) {
80
+	if ( ! $donations) {
81 81
 		return false;
82 82
 	}
83 83
 
@@ -96,65 +96,65 @@  discard block
 block discarded – undo
96 96
  *
97 97
  * @return bool|object List of unique forms donated by user
98 98
  */
99
-function give_get_users_completed_donations( $user = 0, $status = 'complete' ) {
100
-	if ( empty( $user ) ) {
99
+function give_get_users_completed_donations($user = 0, $status = 'complete') {
100
+	if (empty($user)) {
101 101
 		$user = get_current_user_id();
102 102
 	}
103 103
 
104
-	if ( empty( $user ) ) {
104
+	if (empty($user)) {
105 105
 		return false;
106 106
 	}
107 107
 
108
-	$by_user_id = is_numeric( $user ) ? true : false;
108
+	$by_user_id = is_numeric($user) ? true : false;
109 109
 
110
-	$donor = new Give_Donor( $user, $by_user_id );
110
+	$donor = new Give_Donor($user, $by_user_id);
111 111
 
112
-	if ( empty( $donor->payment_ids ) ) {
112
+	if (empty($donor->payment_ids)) {
113 113
 		return false;
114 114
 	}
115 115
 
116 116
 	// Get all the items donated.
117
-	$payment_ids    = array_reverse( explode( ',', $donor->payment_ids ) );
118
-	$limit_payments = apply_filters( 'give_users_completed_donations_payments', 50 );
119
-	if ( ! empty( $limit_payments ) ) {
120
-		$payment_ids = array_slice( $payment_ids, 0, $limit_payments );
117
+	$payment_ids    = array_reverse(explode(',', $donor->payment_ids));
118
+	$limit_payments = apply_filters('give_users_completed_donations_payments', 50);
119
+	if ( ! empty($limit_payments)) {
120
+		$payment_ids = array_slice($payment_ids, 0, $limit_payments);
121 121
 	}
122 122
 	$donation_data = array();
123
-	foreach ( $payment_ids as $payment_id ) {
124
-		$donation_data[] = give_get_payment_meta( $payment_id );
123
+	foreach ($payment_ids as $payment_id) {
124
+		$donation_data[] = give_get_payment_meta($payment_id);
125 125
 	}
126 126
 
127
-	if ( empty( $donation_data ) ) {
127
+	if (empty($donation_data)) {
128 128
 		return false;
129 129
 	}
130 130
 
131 131
 	// Grab only the post ids "form_id" of the forms donated on this order
132 132
 	$completed_donations_ids = array();
133
-	foreach ( $donation_data as $donation_meta ) {
134
-		$completed_donations_ids[] = isset( $donation_meta['form_id'] ) ? $donation_meta['form_id'] : '';
133
+	foreach ($donation_data as $donation_meta) {
134
+		$completed_donations_ids[] = isset($donation_meta['form_id']) ? $donation_meta['form_id'] : '';
135 135
 	}
136 136
 
137
-	if ( empty( $completed_donations_ids ) ) {
137
+	if (empty($completed_donations_ids)) {
138 138
 		return false;
139 139
 	}
140 140
 
141 141
 	// Only include each donation once
142
-	$form_ids = array_unique( $completed_donations_ids );
142
+	$form_ids = array_unique($completed_donations_ids);
143 143
 
144 144
 	// Make sure we still have some products and a first item
145
-	if ( empty( $form_ids ) || ! isset( $form_ids[0] ) ) {
145
+	if (empty($form_ids) || ! isset($form_ids[0])) {
146 146
 		return false;
147 147
 	}
148 148
 
149
-	$post_type = get_post_type( $form_ids[0] );
149
+	$post_type = get_post_type($form_ids[0]);
150 150
 
151
-	$args = apply_filters( 'give_get_users_completed_donations_args', array(
151
+	$args = apply_filters('give_get_users_completed_donations_args', array(
152 152
 		'include'        => $form_ids,
153 153
 		'post_type'      => $post_type,
154
-		'posts_per_page' => - 1,
155
-	) );
154
+		'posts_per_page' => -1,
155
+	));
156 156
 
157
-	return apply_filters( 'give_users_completed_donations_list', get_posts( $args ) );
157
+	return apply_filters('give_users_completed_donations_list', get_posts($args));
158 158
 }
159 159
 
160 160
 
@@ -170,12 +170,12 @@  discard block
 block discarded – undo
170 170
  *
171 171
  * @return      bool True if has donated, false other wise.
172 172
  */
173
-function give_has_donations( $user_id = null ) {
174
-	if ( empty( $user_id ) ) {
173
+function give_has_donations($user_id = null) {
174
+	if (empty($user_id)) {
175 175
 		$user_id = get_current_user_id();
176 176
 	}
177 177
 
178
-	if ( give_get_users_donations( $user_id, 1 ) ) {
178
+	if (give_get_users_donations($user_id, 1)) {
179 179
 		return true; // User has at least one donation.
180 180
 	}
181 181
 
@@ -196,23 +196,23 @@  discard block
 block discarded – undo
196 196
  *
197 197
  * @return      array
198 198
  */
199
-function give_get_donation_stats_by_user( $user = '' ) {
199
+function give_get_donation_stats_by_user($user = '') {
200 200
 
201 201
 	$field = '';
202 202
 
203
-	if ( is_email( $user ) ) {
203
+	if (is_email($user)) {
204 204
 		$field = 'email';
205
-	} elseif ( is_numeric( $user ) ) {
205
+	} elseif (is_numeric($user)) {
206 206
 		$field = 'user_id';
207 207
 	}
208 208
 
209
-	$stats    = array();
210
-	$donor = Give()->donors->get_donor_by( $field, $user );
209
+	$stats = array();
210
+	$donor = Give()->donors->get_donor_by($field, $user);
211 211
 
212
-	if ( $donor ) {
213
-		$donor = new Give_Donor( $donor->id );
214
-		$stats['purchases']   = absint( $donor->purchase_count );
215
-		$stats['total_spent'] = give_sanitize_amount( $donor->purchase_value );
212
+	if ($donor) {
213
+		$donor = new Give_Donor($donor->id);
214
+		$stats['purchases']   = absint($donor->purchase_count);
215
+		$stats['total_spent'] = give_sanitize_amount($donor->purchase_value);
216 216
 	}
217 217
 
218 218
 	/**
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 	 *
221 221
 	 * @since 1.7
222 222
 	 */
223
-	$stats = (array) apply_filters( 'give_donation_stats_by_user', $stats, $user );
223
+	$stats = (array) apply_filters('give_donation_stats_by_user', $stats, $user);
224 224
 
225 225
 	return $stats;
226 226
 }
@@ -238,21 +238,21 @@  discard block
 block discarded – undo
238 238
  *
239 239
  * @return      int The total number of donations.
240 240
  */
241
-function give_count_donations_of_donor( $user = null ) {
241
+function give_count_donations_of_donor($user = null) {
242 242
 
243 243
 	// Logged in?
244
-	if ( empty( $user ) ) {
244
+	if (empty($user)) {
245 245
 		$user = get_current_user_id();
246 246
 	}
247 247
 
248 248
 	// Email access?
249
-	if ( empty( $user ) && Give()->email_access->token_email ) {
249
+	if (empty($user) && Give()->email_access->token_email) {
250 250
 		$user = Give()->email_access->token_email;
251 251
 	}
252 252
 
253
-	$stats = ! empty( $user ) ? give_get_donation_stats_by_user( $user ) : false;
253
+	$stats = ! empty($user) ? give_get_donation_stats_by_user($user) : false;
254 254
 
255
-	return isset( $stats['purchases'] ) ? $stats['purchases'] : 0;
255
+	return isset($stats['purchases']) ? $stats['purchases'] : 0;
256 256
 }
257 257
 
258 258
 /**
@@ -265,9 +265,9 @@  discard block
 block discarded – undo
265 265
  *
266 266
  * @return      float The total amount the user has spent
267 267
  */
268
-function give_donation_total_of_user( $user = null ) {
268
+function give_donation_total_of_user($user = null) {
269 269
 
270
-	$stats = give_get_donation_stats_by_user( $user );
270
+	$stats = give_get_donation_stats_by_user($user);
271 271
 
272 272
 	return $stats['total_spent'];
273 273
 }
@@ -283,40 +283,40 @@  discard block
 block discarded – undo
283 283
  *
284 284
  * @return bool
285 285
  */
286
-function give_validate_username( $username, $form_id = 0 ) {
286
+function give_validate_username($username, $form_id = 0) {
287 287
 	$valid = true;
288 288
 
289 289
 	// Validate username.
290
-	if ( ! empty( $username ) ) {
290
+	if ( ! empty($username)) {
291 291
 
292 292
 		// Sanitize username.
293
-		$sanitized_user_name = sanitize_user( $username, false );
293
+		$sanitized_user_name = sanitize_user($username, false);
294 294
 
295 295
 		// We have an user name, check if it already exists.
296
-		if ( username_exists( $username ) ) {
296
+		if (username_exists($username)) {
297 297
 			// Username already registered.
298
-			give_set_error( 'username_unavailable', __( 'Username already taken.', 'give' ) );
298
+			give_set_error('username_unavailable', __('Username already taken.', 'give'));
299 299
 			$valid = false;
300 300
 
301 301
 			// Check if it's valid.
302
-		} elseif ( $sanitized_user_name !== $username ) {
302
+		} elseif ($sanitized_user_name !== $username) {
303 303
 			// Invalid username.
304
-			if ( is_multisite() ) {
305
-				give_set_error( 'username_invalid', __( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ) );
304
+			if (is_multisite()) {
305
+				give_set_error('username_invalid', __('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give'));
306 306
 				$valid = false;
307 307
 			} else {
308
-				give_set_error( 'username_invalid', __( 'Invalid username.', 'give' ) );
308
+				give_set_error('username_invalid', __('Invalid username.', 'give'));
309 309
 				$valid = false;
310 310
 			}
311 311
 		}
312 312
 	} else {
313 313
 		// Username is empty.
314
-		give_set_error( 'username_empty', __( 'Enter a username.', 'give' ) );
314
+		give_set_error('username_empty', __('Enter a username.', 'give'));
315 315
 		$valid = false;
316 316
 
317 317
 		// Check if guest checkout is disable for form.
318
-		if ( $form_id && give_logged_in_only( $form_id ) ) {
319
-			give_set_error( 'registration_required', __( 'You must register or login to complete your donation.', 'give' ) );
318
+		if ($form_id && give_logged_in_only($form_id)) {
319
+			give_set_error('registration_required', __('You must register or login to complete your donation.', 'give'));
320 320
 			$valid = false;
321 321
 		}
322 322
 	}
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 	 * @param string $username
331 331
 	 * @param bool   $form_id
332 332
 	 */
333
-	$valid = (bool) apply_filters( 'give_validate_username', $valid, $username, $form_id );
333
+	$valid = (bool) apply_filters('give_validate_username', $valid, $username, $form_id);
334 334
 
335 335
 	return $valid;
336 336
 }
@@ -346,22 +346,22 @@  discard block
 block discarded – undo
346 346
  *
347 347
  * @return bool
348 348
  */
349
-function give_validate_user_email( $email, $registering_new_user = false ) {
349
+function give_validate_user_email($email, $registering_new_user = false) {
350 350
 	$valid = true;
351 351
 
352
-	if ( empty( $email ) ) {
352
+	if (empty($email)) {
353 353
 		// No email.
354
-		give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) );
354
+		give_set_error('email_empty', __('Enter an email.', 'give'));
355 355
 		$valid = false;
356 356
 
357
-	} elseif ( ! is_email( $email ) ) {
357
+	} elseif ( ! is_email($email)) {
358 358
 		// Validate email.
359
-		give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) );
359
+		give_set_error('email_invalid', __('Invalid email.', 'give'));
360 360
 		$valid = false;
361 361
 
362
-	} elseif ( $registering_new_user && ( give_donor_email_exists( $email ) || email_exists( $email ) ) ) {
362
+	} elseif ($registering_new_user && (give_donor_email_exists($email) || email_exists($email))) {
363 363
 		// Check if email exists.
364
-		give_set_error( 'email_used', __( 'The email address provided is already active for another user.', 'give' ) );
364
+		give_set_error('email_used', __('The email address provided is already active for another user.', 'give'));
365 365
 		$valid = false;
366 366
 	}
367 367
 
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 	 * @param string $email
375 375
 	 * @param bool   $registering_new_user
376 376
 	 */
377
-	$valid = (bool) apply_filters( 'give_validate_user_email', $valid, $email, $registering_new_user );
377
+	$valid = (bool) apply_filters('give_validate_user_email', $valid, $email, $registering_new_user);
378 378
 
379 379
 	return $valid;
380 380
 }
@@ -390,34 +390,34 @@  discard block
 block discarded – undo
390 390
  *
391 391
  * @return bool
392 392
  */
393
-function give_validate_user_password( $password = '', $confirm_password = '', $registering_new_user = false ) {
393
+function give_validate_user_password($password = '', $confirm_password = '', $registering_new_user = false) {
394 394
 	$valid = true;
395 395
 
396 396
 	// Passwords Validation For New Donors Only
397
-	if ( $registering_new_user ) {
397
+	if ($registering_new_user) {
398 398
 		// Password or confirmation missing.
399
-		if ( ! $password ) {
399
+		if ( ! $password) {
400 400
 			// The password is invalid.
401
-			give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) );
401
+			give_set_error('password_empty', __('Enter a password.', 'give'));
402 402
 			$valid = false;
403
-		} elseif ( ! $confirm_password ) {
403
+		} elseif ( ! $confirm_password) {
404 404
 			// Confirmation password is invalid.
405
-			give_set_error( 'confirmation_empty', __( 'Enter the password confirmation.', 'give' ) );
405
+			give_set_error('confirmation_empty', __('Enter the password confirmation.', 'give'));
406 406
 			$valid = false;
407 407
 		}
408 408
 	}
409 409
 	// Passwords Validation For New Donors as well as Existing Donors
410
-	if( $password || $confirm_password ) {
411
-		if ( strlen( $password ) < 6 || strlen( $confirm_password ) < 6 ) {
410
+	if ($password || $confirm_password) {
411
+		if (strlen($password) < 6 || strlen($confirm_password) < 6) {
412 412
 			// Seems Weak Password
413
-			give_set_error( 'password_weak', __( 'Passwords should have atleast 6 characters.', 'give' ) );
413
+			give_set_error('password_weak', __('Passwords should have atleast 6 characters.', 'give'));
414 414
 			$valid = false;
415 415
 		}
416
-		if ( $password && $confirm_password ) {
416
+		if ($password && $confirm_password) {
417 417
 			// Verify confirmation matches.
418
-			if ( $password != $confirm_password ) {
418
+			if ($password != $confirm_password) {
419 419
 				// Passwords do not match
420
-				give_set_error( 'password_mismatch', __( 'Passwords you entered do not match. Please try again.', 'give' ) );
420
+				give_set_error('password_mismatch', __('Passwords you entered do not match. Please try again.', 'give'));
421 421
 				$valid = false;
422 422
 			}
423 423
 		}
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 	 * @param string $confirm_password
434 434
 	 * @param bool   $registering_new_user
435 435
 	 */
436
-	$valid = (bool) apply_filters( 'give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user );
436
+	$valid = (bool) apply_filters('give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user);
437 437
 
438 438
 	return $valid;
439 439
 }
@@ -451,33 +451,33 @@  discard block
 block discarded – undo
451 451
  *
452 452
  * @return      void
453 453
  */
454
-function give_add_past_donations_to_new_user( $user_id ) {
454
+function give_add_past_donations_to_new_user($user_id) {
455 455
 
456
-	$email = get_the_author_meta( 'user_email', $user_id );
456
+	$email = get_the_author_meta('user_email', $user_id);
457 457
 
458
-	$payments = give_get_payments( array(
458
+	$payments = give_get_payments(array(
459 459
 		's' => $email,
460
-	) );
460
+	));
461 461
 
462
-	if ( $payments ) {
463
-		foreach ( $payments as $payment ) {
464
-			if ( intval( give_get_payment_user_id( $payment->ID ) ) > 0 ) {
462
+	if ($payments) {
463
+		foreach ($payments as $payment) {
464
+			if (intval(give_get_payment_user_id($payment->ID)) > 0) {
465 465
 				continue;
466 466
 			} // End if().
467 467
 
468
-			$meta                    = give_get_payment_meta( $payment->ID );
469
-			$meta['user_info']       = maybe_unserialize( $meta['user_info'] );
468
+			$meta                    = give_get_payment_meta($payment->ID);
469
+			$meta['user_info']       = maybe_unserialize($meta['user_info']);
470 470
 			$meta['user_info']['id'] = $user_id;
471 471
 
472 472
 			// Store the updated user ID in the payment meta.
473
-			give_update_payment_meta( $payment->ID, '_give_payment_meta', $meta );
474
-			give_update_payment_meta( $payment->ID, '_give_payment_user_id', $user_id );
473
+			give_update_payment_meta($payment->ID, '_give_payment_meta', $meta);
474
+			give_update_payment_meta($payment->ID, '_give_payment_user_id', $user_id);
475 475
 		}
476 476
 	}
477 477
 
478 478
 }
479 479
 
480
-add_action( 'user_register', 'give_add_past_donations_to_new_user' );
480
+add_action('user_register', 'give_add_past_donations_to_new_user');
481 481
 
482 482
 
483 483
 /**
@@ -503,34 +503,34 @@  discard block
 block discarded – undo
503 503
  *
504 504
  * @return        array The donor's address, if any
505 505
  */
506
-function give_get_donor_address( $user_id = 0 ) {
507
-	if ( empty( $user_id ) ) {
506
+function give_get_donor_address($user_id = 0) {
507
+	if (empty($user_id)) {
508 508
 		$user_id = get_current_user_id();
509 509
 	}
510 510
 
511
-	$address = get_user_meta( $user_id, '_give_user_address', true );
511
+	$address = get_user_meta($user_id, '_give_user_address', true);
512 512
 
513
-	if ( ! isset( $address['line1'] ) ) {
513
+	if ( ! isset($address['line1'])) {
514 514
 		$address['line1'] = '';
515 515
 	}
516 516
 
517
-	if ( ! isset( $address['line2'] ) ) {
517
+	if ( ! isset($address['line2'])) {
518 518
 		$address['line2'] = '';
519 519
 	}
520 520
 
521
-	if ( ! isset( $address['city'] ) ) {
521
+	if ( ! isset($address['city'])) {
522 522
 		$address['city'] = '';
523 523
 	}
524 524
 
525
-	if ( ! isset( $address['zip'] ) ) {
525
+	if ( ! isset($address['zip'])) {
526 526
 		$address['zip'] = '';
527 527
 	}
528 528
 
529
-	if ( ! isset( $address['country'] ) ) {
529
+	if ( ! isset($address['country'])) {
530 530
 		$address['country'] = '';
531 531
 	}
532 532
 
533
-	if ( ! isset( $address['state'] ) ) {
533
+	if ( ! isset($address['state'])) {
534 534
 		$address['state'] = '';
535 535
 	}
536 536
 
@@ -550,32 +550,32 @@  discard block
 block discarded – undo
550 550
  *
551 551
  * @return        void
552 552
  */
553
-function give_new_user_notification( $user_id = 0, $user_data = array() ) {
553
+function give_new_user_notification($user_id = 0, $user_data = array()) {
554 554
 
555
-	if ( empty( $user_id ) || empty( $user_data ) ) {
555
+	if (empty($user_id) || empty($user_data)) {
556 556
 		return;
557 557
 	}
558
-	$blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
558
+	$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
559 559
 
560 560
 
561 561
 	// New User Registration: Email sends to the site admin.
562 562
 	$emails = Give()->emails;
563
-	$emails->__set( 'heading', esc_html__( 'New User Registration', 'give' ) );
563
+	$emails->__set('heading', esc_html__('New User Registration', 'give'));
564 564
 
565 565
 	/* translators: %s: site name */
566
-	$message = sprintf( esc_attr__( 'A new user has registered on %s:', 'give' ), $blogname ) . "\r\n\r\n";
566
+	$message = sprintf(esc_attr__('A new user has registered on %s:', 'give'), $blogname)."\r\n\r\n";
567 567
 	/* translators: %s: user login */
568
-	$message .= '<strong>' . esc_attr__( 'Username:', 'give' ) . '</strong> ' . $user_data['user_login'] . "\r\n";
568
+	$message .= '<strong>'.esc_attr__('Username:', 'give').'</strong> '.$user_data['user_login']."\r\n";
569 569
 	/* translators: %s: user email */
570
-	$message .= '<strong>' . esc_attr__( 'E-mail:', 'give' ) . '</strong> ' . $user_data['user_email']  . "\r\n\r\n";
570
+	$message .= '<strong>'.esc_attr__('E-mail:', 'give').'</strong> '.$user_data['user_email']."\r\n\r\n";
571 571
 
572
-	$message .= '<a href="' . admin_url('user-edit.php?user_id=' . $user_id) . '" target="_blank"> ' . esc_attr__( 'Click here to view &raquo;', 'give' ) . '</a>' . "\r\n";
572
+	$message .= '<a href="'.admin_url('user-edit.php?user_id='.$user_id).'" target="_blank"> '.esc_attr__('Click here to view &raquo;', 'give').'</a>'."\r\n";
573 573
 
574 574
 	$emails->send(
575
-		get_option( 'admin_email' ),
575
+		get_option('admin_email'),
576 576
 		sprintf(
577 577
 			/* translators: %s: site name */
578
-			esc_attr__( '[%s] New User Registration', 'give' ),
578
+			esc_attr__('[%s] New User Registration', 'give'),
579 579
 			$blogname
580 580
 		),
581 581
 		$message
@@ -583,22 +583,22 @@  discard block
 block discarded – undo
583 583
 
584 584
 
585 585
 	// Account Information: Email sends to donor who registered.
586
-	$emails->__set( 'heading', esc_html__( 'Account Information', 'give' ) );
586
+	$emails->__set('heading', esc_html__('Account Information', 'give'));
587 587
 
588
-	$message = sprintf( esc_attr__( 'The following email contains your account information for %s:', 'give' ), $blogname ) . "\r\n\r\n";
588
+	$message = sprintf(esc_attr__('The following email contains your account information for %s:', 'give'), $blogname)."\r\n\r\n";
589 589
 
590 590
 	/* translators: %s: user login */
591
-	$message .=  '<strong>' . esc_attr__( 'Username:', 'give' ) . '</strong> ' .  $user_data['user_login'] . "\r\n";
591
+	$message .= '<strong>'.esc_attr__('Username:', 'give').'</strong> '.$user_data['user_login']."\r\n";
592 592
 	/* translators: %s: password */
593
-	$message .=  '<strong>' . esc_attr__( 'Password:', 'give' ) . '</strong> ' . esc_attr__( '[Password entered during donation]', 'give' ) . "\r\n\r\n";
593
+	$message .= '<strong>'.esc_attr__('Password:', 'give').'</strong> '.esc_attr__('[Password entered during donation]', 'give')."\r\n\r\n";
594 594
 
595
-	$message .= '<a href="' . wp_login_url() . '" target="_blank"> ' . esc_attr__( 'Click here to login &raquo;', 'give' ) . '</a>' . "\r\n";
595
+	$message .= '<a href="'.wp_login_url().'" target="_blank"> '.esc_attr__('Click here to login &raquo;', 'give').'</a>'."\r\n";
596 596
 
597 597
 	$emails->send(
598 598
 		$user_data['user_email'],
599 599
 		sprintf(
600 600
 			/* translators: %s: site name */
601
-			esc_attr__( '[%s] Your username and password', 'give' ),
601
+			esc_attr__('[%s] Your username and password', 'give'),
602 602
 			$blogname
603 603
 		),
604 604
 		$message
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
 
607 607
 }
608 608
 
609
-add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 );
609
+add_action('give_insert_user', 'give_new_user_notification', 10, 2);
610 610
 
611 611
 
612 612
 /**
@@ -622,34 +622,34 @@  discard block
 block discarded – undo
622 622
  *
623 623
  * @return      string
624 624
  */
625
-function give_get_donor_name_by( $id = 0, $from = 'donation' ) {
625
+function give_get_donor_name_by($id = 0, $from = 'donation') {
626 626
 
627 627
 	// ID shouldn't be empty
628
-	if ( empty( $id ) ) {
628
+	if (empty($id)) {
629 629
 		return;
630 630
 	}
631 631
 
632 632
 	$name = '';
633 633
 
634
-	switch ( $from ) {
634
+	switch ($from) {
635 635
 
636 636
 		case 'donation':
637 637
 
638
-			$user_info = give_get_payment_meta_user_info( $id );
639
-			$name = $user_info['first_name'] . ' ' . $user_info['last_name'];
638
+			$user_info = give_get_payment_meta_user_info($id);
639
+			$name = $user_info['first_name'].' '.$user_info['last_name'];
640 640
 
641 641
 		break;
642 642
 
643 643
 		case 'donor':
644 644
 
645
-			$donor = new Give_Donor( $id );
645
+			$donor = new Give_Donor($id);
646 646
 			$name = $donor->name;
647 647
 
648 648
 		break;
649 649
 
650 650
 	}
651 651
 
652
-	return trim( $name );
652
+	return trim($name);
653 653
 
654 654
 }
655 655
 
@@ -661,8 +661,8 @@  discard block
 block discarded – undo
661 661
  * @param  string   $email Donor Email.
662 662
  * @return boolean  The user's ID on success, and false on failure.
663 663
  */
664
-function give_donor_email_exists( $email ) {
665
-	if ( Give()->donors->get_donor_by( 'email', $email ) ) {
664
+function give_donor_email_exists($email) {
665
+	if (Give()->donors->get_donor_by('email', $email)) {
666 666
 		return true;
667 667
 	}
668 668
 	return false;
Please login to merge, or discard this patch.