Test Setup Failed
Pull Request — master (#2014)
by Rami
05:17
created
give.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -521,7 +521,7 @@
 block discarded – undo
521 521
  * Example: <?php $give = Give(); ?>
522 522
  *
523 523
  * @since 1.0
524
- * @return object|Give
524
+ * @return Give
525 525
  */
526 526
 function Give() {
527 527
 	return Give::instance();
Please login to merge, or discard this 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
 
@@ -214,13 +214,13 @@  discard block
 block discarded – undo
214 214
 		 */
215 215
 		public function __construct() {
216 216
 			// PHP version
217
-			if ( ! defined( 'GIVE_REQUIRED_PHP_VERSION' ) ) {
218
-				define( 'GIVE_REQUIRED_PHP_VERSION', '5.3' );
217
+			if ( ! defined('GIVE_REQUIRED_PHP_VERSION')) {
218
+				define('GIVE_REQUIRED_PHP_VERSION', '5.3');
219 219
 			}
220 220
 
221 221
 			// Bailout: Need minimum php version to load plugin.
222
-			if ( function_exists( 'phpversion' ) && version_compare( GIVE_REQUIRED_PHP_VERSION, phpversion(), '>' ) ) {
223
-				add_action( 'admin_notices', array( $this, 'minmum_phpversion_notice' ) );
222
+			if (function_exists('phpversion') && version_compare(GIVE_REQUIRED_PHP_VERSION, phpversion(), '>')) {
223
+				add_action('admin_notices', array($this, 'minmum_phpversion_notice'));
224 224
 
225 225
 				return;
226 226
 			}
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 			$this->includes();
231 231
 			$this->init_hooks();
232 232
 
233
-			do_action( 'give_loaded' );
233
+			do_action('give_loaded');
234 234
 		}
235 235
 
236 236
 		/**
@@ -239,8 +239,8 @@  discard block
 block discarded – undo
239 239
 		 * @since  1.8.9
240 240
 		 */
241 241
 		private function init_hooks() {
242
-			register_activation_hook( __FILE__, 'give_install' );
243
-			add_action( 'plugins_loaded', array( $this, 'init' ), 0 );
242
+			register_activation_hook(__FILE__, 'give_install');
243
+			add_action('plugins_loaded', array($this, 'init'), 0);
244 244
 		}
245 245
 		/**
246 246
 		 * Init Give when WordPress Initializes.
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 			 *
255 255
 			 * @since 1.8.9
256 256
 			 */
257
-			do_action( 'before_give_init' );
257
+			do_action('before_give_init');
258 258
 
259 259
 			// Set up localization.
260 260
 			$this->load_textdomain();
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 			 *
280 280
 			 * @since 1.8.7
281 281
 			 */
282
-			do_action( 'give_init', $this );
282
+			do_action('give_init', $this);
283 283
 
284 284
 		}
285 285
 
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 		 */
297 297
 		public function __clone() {
298 298
 			// Cloning instances of the class is forbidden.
299
-			_doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'give' ), '1.0' );
299
+			_doing_it_wrong(__FUNCTION__, __('Cheatin&#8217; huh?', 'give'), '1.0');
300 300
 		}
301 301
 
302 302
 		/**
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 		 */
310 310
 		public function __wakeup() {
311 311
 			// Unserializing instances of the class is forbidden.
312
-			_doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'give' ), '1.0' );
312
+			_doing_it_wrong(__FUNCTION__, __('Cheatin&#8217; huh?', 'give'), '1.0');
313 313
 		}
314 314
 
315 315
 		/**
@@ -323,33 +323,33 @@  discard block
 block discarded – undo
323 323
 		private function setup_constants() {
324 324
 
325 325
 			// Plugin version
326
-			if ( ! defined( 'GIVE_VERSION' ) ) {
327
-				define( 'GIVE_VERSION', '1.8.12' );
326
+			if ( ! defined('GIVE_VERSION')) {
327
+				define('GIVE_VERSION', '1.8.12');
328 328
 			}
329 329
 
330 330
 			// Plugin Folder Path
331
-			if ( ! defined( 'GIVE_PLUGIN_DIR' ) ) {
332
-				define( 'GIVE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
331
+			if ( ! defined('GIVE_PLUGIN_DIR')) {
332
+				define('GIVE_PLUGIN_DIR', plugin_dir_path(__FILE__));
333 333
 			}
334 334
 
335 335
 			// Plugin Folder URL
336
-			if ( ! defined( 'GIVE_PLUGIN_URL' ) ) {
337
-				define( 'GIVE_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
336
+			if ( ! defined('GIVE_PLUGIN_URL')) {
337
+				define('GIVE_PLUGIN_URL', plugin_dir_url(__FILE__));
338 338
 			}
339 339
 
340 340
 			// Plugin Basename aka: "give/give.php"
341
-			if ( ! defined( 'GIVE_PLUGIN_BASENAME' ) ) {
342
-				define( 'GIVE_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
341
+			if ( ! defined('GIVE_PLUGIN_BASENAME')) {
342
+				define('GIVE_PLUGIN_BASENAME', plugin_basename(__FILE__));
343 343
 			}
344 344
 
345 345
 			// Plugin Root File
346
-			if ( ! defined( 'GIVE_PLUGIN_FILE' ) ) {
347
-				define( 'GIVE_PLUGIN_FILE', __FILE__ );
346
+			if ( ! defined('GIVE_PLUGIN_FILE')) {
347
+				define('GIVE_PLUGIN_FILE', __FILE__);
348 348
 			}
349 349
 
350 350
 			// Make sure CAL_GREGORIAN is defined
351
-			if ( ! defined( 'CAL_GREGORIAN' ) ) {
352
-				define( 'CAL_GREGORIAN', 1 );
351
+			if ( ! defined('CAL_GREGORIAN')) {
352
+				define('CAL_GREGORIAN', 1);
353 353
 			}
354 354
 		}
355 355
 
@@ -364,128 +364,128 @@  discard block
 block discarded – undo
364 364
 		private function includes() {
365 365
 			global $give_options;
366 366
 
367
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/class-admin-settings.php';
368
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/class-give-settings.php';
367
+			require_once GIVE_PLUGIN_DIR.'includes/admin/class-admin-settings.php';
368
+			require_once GIVE_PLUGIN_DIR.'includes/admin/class-give-settings.php';
369 369
 			$give_options = give_get_settings();
370 370
 
371
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/give-metabox-functions.php';
372
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-cache.php';
373
-			require_once GIVE_PLUGIN_DIR . 'includes/post-types.php';
374
-			require_once GIVE_PLUGIN_DIR . 'includes/scripts.php';
375
-			require_once GIVE_PLUGIN_DIR . 'includes/ajax-functions.php';
376
-			require_once GIVE_PLUGIN_DIR . 'includes/actions.php';
377
-			require_once GIVE_PLUGIN_DIR . 'includes/filters.php';
378
-			require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api.php';
379
-			require_once GIVE_PLUGIN_DIR . 'includes/class-notices.php';
380
-
381
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-roles.php';
382
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-template-loader.php';
383
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-donate-form.php';
384
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-db.php';
385
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-donors.php';
386
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-db-donor-meta.php';
387
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-donor.php';
388
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-stats.php';
389
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-session.php';
390
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-html-elements.php';
391
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-logging.php';
392
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-license-handler.php';
393
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-cron.php';
394
-			require_once GIVE_PLUGIN_DIR . 'includes/class-give-email-access.php';
395
-
396
-			require_once GIVE_PLUGIN_DIR . 'includes/country-functions.php';
397
-			require_once GIVE_PLUGIN_DIR . 'includes/template-functions.php';
398
-			require_once GIVE_PLUGIN_DIR . 'includes/misc-functions.php';
399
-			require_once GIVE_PLUGIN_DIR . 'includes/forms/functions.php';
400
-			require_once GIVE_PLUGIN_DIR . 'includes/forms/template.php';
401
-			require_once GIVE_PLUGIN_DIR . 'includes/forms/widget.php';
402
-			require_once GIVE_PLUGIN_DIR . 'includes/shortcodes.php';
403
-			require_once GIVE_PLUGIN_DIR . 'includes/formatting.php';
404
-			require_once GIVE_PLUGIN_DIR . 'includes/price-functions.php';
405
-			require_once GIVE_PLUGIN_DIR . 'includes/error-tracking.php';
406
-			require_once GIVE_PLUGIN_DIR . 'includes/process-donation.php';
407
-			require_once GIVE_PLUGIN_DIR . 'includes/login-register.php';
408
-			require_once GIVE_PLUGIN_DIR . 'includes/user-functions.php';
409
-			require_once GIVE_PLUGIN_DIR . 'includes/plugin-compatibility.php';
410
-			require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-classes.php';
411
-			require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-functions.php';
412
-			require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-actions.php';
413
-			require_once GIVE_PLUGIN_DIR . 'includes/deprecated/deprecated-filters.php';
414
-
415
-			require_once GIVE_PLUGIN_DIR . 'includes/payments/functions.php';
416
-			require_once GIVE_PLUGIN_DIR . 'includes/payments/actions.php';
417
-			require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payment-stats.php';
418
-			require_once GIVE_PLUGIN_DIR . 'includes/payments/class-payments-query.php';
419
-			require_once GIVE_PLUGIN_DIR . 'includes/payments/class-give-payment.php';
420
-
421
-			require_once GIVE_PLUGIN_DIR . 'includes/gateways/functions.php';
422
-			require_once GIVE_PLUGIN_DIR . 'includes/gateways/actions.php';
423
-			require_once GIVE_PLUGIN_DIR . 'includes/gateways/paypal-standard.php';
424
-			require_once GIVE_PLUGIN_DIR . 'includes/gateways/offline-donations.php';
425
-			require_once GIVE_PLUGIN_DIR . 'includes/gateways/manual.php';
426
-
427
-			require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-emails.php';
428
-			require_once GIVE_PLUGIN_DIR . 'includes/emails/class-give-email-tags.php';
429
-			require_once GIVE_PLUGIN_DIR . 'includes/emails/functions.php';
430
-			require_once GIVE_PLUGIN_DIR . 'includes/emails/template.php';
431
-			require_once GIVE_PLUGIN_DIR . 'includes/emails/actions.php';
432
-
433
-			if ( defined( 'WP_CLI' ) && WP_CLI ) {
434
-				require_once GIVE_PLUGIN_DIR . 'includes/class-give-cli-commands.php';
371
+			require_once GIVE_PLUGIN_DIR.'includes/admin/give-metabox-functions.php';
372
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-cache.php';
373
+			require_once GIVE_PLUGIN_DIR.'includes/post-types.php';
374
+			require_once GIVE_PLUGIN_DIR.'includes/scripts.php';
375
+			require_once GIVE_PLUGIN_DIR.'includes/ajax-functions.php';
376
+			require_once GIVE_PLUGIN_DIR.'includes/actions.php';
377
+			require_once GIVE_PLUGIN_DIR.'includes/filters.php';
378
+			require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api.php';
379
+			require_once GIVE_PLUGIN_DIR.'includes/class-notices.php';
380
+
381
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-roles.php';
382
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-template-loader.php';
383
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-donate-form.php';
384
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-db.php';
385
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-db-donors.php';
386
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-db-donor-meta.php';
387
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-donor.php';
388
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-stats.php';
389
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-session.php';
390
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-html-elements.php';
391
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-logging.php';
392
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-license-handler.php';
393
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-cron.php';
394
+			require_once GIVE_PLUGIN_DIR.'includes/class-give-email-access.php';
395
+
396
+			require_once GIVE_PLUGIN_DIR.'includes/country-functions.php';
397
+			require_once GIVE_PLUGIN_DIR.'includes/template-functions.php';
398
+			require_once GIVE_PLUGIN_DIR.'includes/misc-functions.php';
399
+			require_once GIVE_PLUGIN_DIR.'includes/forms/functions.php';
400
+			require_once GIVE_PLUGIN_DIR.'includes/forms/template.php';
401
+			require_once GIVE_PLUGIN_DIR.'includes/forms/widget.php';
402
+			require_once GIVE_PLUGIN_DIR.'includes/shortcodes.php';
403
+			require_once GIVE_PLUGIN_DIR.'includes/formatting.php';
404
+			require_once GIVE_PLUGIN_DIR.'includes/price-functions.php';
405
+			require_once GIVE_PLUGIN_DIR.'includes/error-tracking.php';
406
+			require_once GIVE_PLUGIN_DIR.'includes/process-donation.php';
407
+			require_once GIVE_PLUGIN_DIR.'includes/login-register.php';
408
+			require_once GIVE_PLUGIN_DIR.'includes/user-functions.php';
409
+			require_once GIVE_PLUGIN_DIR.'includes/plugin-compatibility.php';
410
+			require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-classes.php';
411
+			require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-functions.php';
412
+			require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-actions.php';
413
+			require_once GIVE_PLUGIN_DIR.'includes/deprecated/deprecated-filters.php';
414
+
415
+			require_once GIVE_PLUGIN_DIR.'includes/payments/functions.php';
416
+			require_once GIVE_PLUGIN_DIR.'includes/payments/actions.php';
417
+			require_once GIVE_PLUGIN_DIR.'includes/payments/class-payment-stats.php';
418
+			require_once GIVE_PLUGIN_DIR.'includes/payments/class-payments-query.php';
419
+			require_once GIVE_PLUGIN_DIR.'includes/payments/class-give-payment.php';
420
+
421
+			require_once GIVE_PLUGIN_DIR.'includes/gateways/functions.php';
422
+			require_once GIVE_PLUGIN_DIR.'includes/gateways/actions.php';
423
+			require_once GIVE_PLUGIN_DIR.'includes/gateways/paypal-standard.php';
424
+			require_once GIVE_PLUGIN_DIR.'includes/gateways/offline-donations.php';
425
+			require_once GIVE_PLUGIN_DIR.'includes/gateways/manual.php';
426
+
427
+			require_once GIVE_PLUGIN_DIR.'includes/emails/class-give-emails.php';
428
+			require_once GIVE_PLUGIN_DIR.'includes/emails/class-give-email-tags.php';
429
+			require_once GIVE_PLUGIN_DIR.'includes/emails/functions.php';
430
+			require_once GIVE_PLUGIN_DIR.'includes/emails/template.php';
431
+			require_once GIVE_PLUGIN_DIR.'includes/emails/actions.php';
432
+
433
+			if (defined('WP_CLI') && WP_CLI) {
434
+				require_once GIVE_PLUGIN_DIR.'includes/class-give-cli-commands.php';
435 435
 			}
436 436
 
437
-			if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
437
+			if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
438 438
 
439
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-footer.php';
440
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/welcome.php';
441
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-pages.php';
442
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/class-api-keys-table.php';
443
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/class-i18n-module.php';
444
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-actions.php';
445
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/admin-filters.php';
446
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/add-ons.php';
447
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/plugins.php';
448
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/dashboard-widgets.php';
439
+				require_once GIVE_PLUGIN_DIR.'includes/admin/admin-footer.php';
440
+				require_once GIVE_PLUGIN_DIR.'includes/admin/welcome.php';
441
+				require_once GIVE_PLUGIN_DIR.'includes/admin/admin-pages.php';
442
+				require_once GIVE_PLUGIN_DIR.'includes/admin/class-api-keys-table.php';
443
+				require_once GIVE_PLUGIN_DIR.'includes/admin/class-i18n-module.php';
444
+				require_once GIVE_PLUGIN_DIR.'includes/admin/admin-actions.php';
445
+				require_once GIVE_PLUGIN_DIR.'includes/admin/admin-filters.php';
446
+				require_once GIVE_PLUGIN_DIR.'includes/admin/add-ons.php';
447
+				require_once GIVE_PLUGIN_DIR.'includes/admin/plugins.php';
448
+				require_once GIVE_PLUGIN_DIR.'includes/admin/dashboard-widgets.php';
449 449
 
450
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/actions.php';
451
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/payments-history.php';
450
+				require_once GIVE_PLUGIN_DIR.'includes/admin/payments/actions.php';
451
+				require_once GIVE_PLUGIN_DIR.'includes/admin/payments/payments-history.php';
452 452
 
453
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/donors/donors.php';
454
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/donors/donor-functions.php';
455
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/donors/donor-actions.php';
453
+				require_once GIVE_PLUGIN_DIR.'includes/admin/donors/donors.php';
454
+				require_once GIVE_PLUGIN_DIR.'includes/admin/donors/donor-functions.php';
455
+				require_once GIVE_PLUGIN_DIR.'includes/admin/donors/donor-actions.php';
456 456
 
457
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/metabox.php';
458
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/class-metabox-form-data.php';
459
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/forms/dashboard-columns.php';
457
+				require_once GIVE_PLUGIN_DIR.'includes/admin/forms/metabox.php';
458
+				require_once GIVE_PLUGIN_DIR.'includes/admin/forms/class-metabox-form-data.php';
459
+				require_once GIVE_PLUGIN_DIR.'includes/admin/forms/dashboard-columns.php';
460 460
 
461
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/export-functions.php';
462
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/class-export.php';
463
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/export-actions.php';
464
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/pdf-reports.php';
461
+				require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/export-functions.php';
462
+				require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/class-export.php';
463
+				require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/export-actions.php';
464
+				require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/pdf-reports.php';
465 465
 
466
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/reports/reports.php';
467
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/reports/class-give-graph.php';
468
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/reports/graphing.php';
466
+				require_once GIVE_PLUGIN_DIR.'includes/admin/reports/reports.php';
467
+				require_once GIVE_PLUGIN_DIR.'includes/admin/reports/class-give-graph.php';
468
+				require_once GIVE_PLUGIN_DIR.'includes/admin/reports/graphing.php';
469 469
 
470
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/logs/logs.php';
470
+				require_once GIVE_PLUGIN_DIR.'includes/admin/tools/logs/logs.php';
471 471
 
472
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/tools-actions.php';
472
+				require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/tools-actions.php';
473 473
 
474
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/abstract-shortcode-generator.php';
475
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/class-shortcode-button.php';
476
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-form.php';
477
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-goal.php';
478
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-login.php';
479
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-register.php';
480
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-profile-editor.php';
481
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-donation-history.php';
482
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/shortcode-give-receipt.php';
474
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/abstract-shortcode-generator.php';
475
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/class-shortcode-button.php';
476
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-form.php';
477
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-goal.php';
478
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-login.php';
479
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-register.php';
480
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-profile-editor.php';
481
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-donation-history.php';
482
+				require_once GIVE_PLUGIN_DIR.'includes/admin/shortcodes/shortcode-give-receipt.php';
483 483
 
484
-				require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/class-give-updates.php';
484
+				require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/class-give-updates.php';
485 485
 
486 486
 			}// End if().
487 487
 
488
-			require_once GIVE_PLUGIN_DIR . 'includes/install.php';
488
+			require_once GIVE_PLUGIN_DIR.'includes/install.php';
489 489
 
490 490
 		}
491 491
 
@@ -500,16 +500,16 @@  discard block
 block discarded – undo
500 500
 		public function load_textdomain() {
501 501
 
502 502
 			// Set filter for Give's languages directory
503
-			$give_lang_dir = dirname( plugin_basename( GIVE_PLUGIN_FILE ) ) . '/languages/';
504
-			$give_lang_dir = apply_filters( 'give_languages_directory', $give_lang_dir );
503
+			$give_lang_dir = dirname(plugin_basename(GIVE_PLUGIN_FILE)).'/languages/';
504
+			$give_lang_dir = apply_filters('give_languages_directory', $give_lang_dir);
505 505
 
506 506
 			// Traditional WordPress plugin locale filter.
507
-			$locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
508
-			$locale = apply_filters( 'plugin_locale', $locale, 'give' );
507
+			$locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale();
508
+			$locale = apply_filters('plugin_locale', $locale, 'give');
509 509
 
510
-			unload_textdomain( 'give' );
511
-			load_textdomain( 'give', WP_LANG_DIR . '/give/give-' . $locale . '.mo' );
512
-			load_plugin_textdomain( 'give', false, $give_lang_dir );
510
+			unload_textdomain('give');
511
+			load_textdomain('give', WP_LANG_DIR.'/give/give-'.$locale.'.mo');
512
+			load_plugin_textdomain('give', false, $give_lang_dir);
513 513
 
514 514
 		}
515 515
 
@@ -522,17 +522,17 @@  discard block
 block discarded – undo
522 522
 		 */
523 523
 		public function minmum_phpversion_notice() {
524 524
 			// Bailout.
525
-			if ( ! is_admin() ) {
525
+			if ( ! is_admin()) {
526 526
 				return;
527 527
 			}
528 528
 
529
-			$notice_desc = '<p><strong>' . __( 'Your site could be faster and more secure with a newer PHP version.', 'give' ) . '</strong></p>';
530
-			$notice_desc .= '<p>' . __( 'Hey, we\'ve noticed that you\'re running an outdated version of PHP. PHP is the programming language that WordPress and Give are built on. The version that is currently used for your site is no longer supported. Newer versions of PHP are both faster and more secure. In fact, your version of PHP no longer receives security updates, which is why we\'re sending you this notice.', 'give' ) . '</p>';
531
-			$notice_desc .= '<p>' . __( 'Hosts have the ability to update your PHP version, but sometimes they don\'t dare to do that because they\'re afraid they\'ll break your site.', 'give' ) . '</p>';
532
-			$notice_desc .= '<p><strong>' . __( 'To which version should I update?', 'give' ) . '</strong></p>';
533
-			$notice_desc .= '<p>' . __( 'You should update your PHP version to either 5.6 or to 7.0 or 7.1. On a normal WordPress site, switching to PHP 5.6 should never cause issues. We would however actually recommend you switch to PHP7. There are some plugins that are not ready for PHP7 though, so do some testing first. PHP7 is much faster than PHP 5.6. It\'s also the only PHP version still in active development and therefore the better option for your site in the long run.', 'give' ) . '</p>';
534
-			$notice_desc .= '<p><strong>' . __( 'Can\'t update? Ask your host!', 'give' ) . '</strong></p>';
535
-			$notice_desc .= '<p>' . sprintf( __( 'If you cannot upgrade your PHP version yourself, you can send an email to your host. If they don\'t want to upgrade your PHP version, we would suggest you switch hosts. Have a look at one of the recommended %1$sWordPress hosting partners%2$s.', 'give' ), sprintf( '<a href="%1$s" target="_blank">', esc_url( 'https://wordpress.org/hosting/' ) ), '</a>' ) . '</p>';
529
+			$notice_desc = '<p><strong>'.__('Your site could be faster and more secure with a newer PHP version.', 'give').'</strong></p>';
530
+			$notice_desc .= '<p>'.__('Hey, we\'ve noticed that you\'re running an outdated version of PHP. PHP is the programming language that WordPress and Give are built on. The version that is currently used for your site is no longer supported. Newer versions of PHP are both faster and more secure. In fact, your version of PHP no longer receives security updates, which is why we\'re sending you this notice.', 'give').'</p>';
531
+			$notice_desc .= '<p>'.__('Hosts have the ability to update your PHP version, but sometimes they don\'t dare to do that because they\'re afraid they\'ll break your site.', 'give').'</p>';
532
+			$notice_desc .= '<p><strong>'.__('To which version should I update?', 'give').'</strong></p>';
533
+			$notice_desc .= '<p>'.__('You should update your PHP version to either 5.6 or to 7.0 or 7.1. On a normal WordPress site, switching to PHP 5.6 should never cause issues. We would however actually recommend you switch to PHP7. There are some plugins that are not ready for PHP7 though, so do some testing first. PHP7 is much faster than PHP 5.6. It\'s also the only PHP version still in active development and therefore the better option for your site in the long run.', 'give').'</p>';
534
+			$notice_desc .= '<p><strong>'.__('Can\'t update? Ask your host!', 'give').'</strong></p>';
535
+			$notice_desc .= '<p>'.sprintf(__('If you cannot upgrade your PHP version yourself, you can send an email to your host. If they don\'t want to upgrade your PHP version, we would suggest you switch hosts. Have a look at one of the recommended %1$sWordPress hosting partners%2$s.', 'give'), sprintf('<a href="%1$s" target="_blank">', esc_url('https://wordpress.org/hosting/')), '</a>').'</p>';
536 536
 
537 537
 			echo sprintf(
538 538
 				'<div class="notice notice-error">%1$s</div>',
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-delete-test-donors.php 2 patches
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 	 * Return the calculated completion percentage.
217 217
 	 *
218 218
 	 * @since 1.8.12
219
-	 * @return int
219
+	 * @return double
220 220
 	 */
221 221
 	public function get_percentage_complete() {
222 222
 		return ceil( ( 100 * $this->step_completed ) / $this->total_step );
@@ -353,6 +353,9 @@  discard block
 block discarded – undo
353 353
 		return true;
354 354
 	}
355 355
 
356
+	/**
357
+	 * @param integer $page
358
+	 */
356 359
 	public function get_delete_ids( $donation_ids, $page ) {
357 360
 		$index            = $page --;
358 361
 		$count            = count( $donation_ids );
Please login to merge, or discard this patch.
Spacing   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly.
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -109,32 +109,32 @@  discard block
 block discarded – undo
109 109
 		$donor_ids    = array();
110 110
 
111 111
 		// Check if the ajax request if running for the first time.
112
-		if ( 1 === (int) $this->step ) {
112
+		if (1 === (int) $this->step) {
113 113
 			// Delete all the donation ids.
114
-			$this->delete_option( $this->donation_key );
114
+			$this->delete_option($this->donation_key);
115 115
 			// Delete all the donor ids.
116
-			$this->delete_option( $this->donor_key );
116
+			$this->delete_option($this->donor_key);
117 117
 
118 118
 			// Delete all the step and set to 'count' which if the first step in the process of deleting the donors.
119
-			$this->update_option( $this->step_key, 'count' );
119
+			$this->update_option($this->step_key, 'count');
120 120
 
121 121
 			// Delete tha page count of the step.
122
-			$this->update_option( $this->step_on_key, '0' );
122
+			$this->update_option($this->step_on_key, '0');
123 123
 		} else {
124 124
 			// Get the old donors list.
125
-			$donor_ids = $this->get_option( $this->donor_key );
125
+			$donor_ids = $this->get_option($this->donor_key);
126 126
 
127 127
 			// Get the old donation list.
128
-			$donation_ids = $this->get_option( $this->donation_key );
128
+			$donation_ids = $this->get_option($this->donation_key);
129 129
 		}
130 130
 
131 131
 		// Get the step and check for it if it's on the first step( 'count' ) or not.
132 132
 		$step = (int) $this->get_step();
133
-		if ( 1 === $step ) {
133
+		if (1 === $step) {
134 134
 			/**
135 135
 			 * Will add or update the donation and donor data by running wp query.
136 136
 			 */
137
-			$this->count( $step, $donation_ids, $donor_ids );
137
+			$this->count($step, $donation_ids, $donor_ids);
138 138
 		}
139 139
 	}
140 140
 
@@ -145,17 +145,17 @@  discard block
 block discarded – undo
145 145
 	 * @param array $donation_ids Contain the list of all the donation id's that has being add before this
146 146
 	 * @param array $donor_ids Contain the list of all the donors id's that has being add before this
147 147
 	 */
148
-	private function count( $step, $donation_ids = array(), $donor_ids = array() ) {
148
+	private function count($step, $donation_ids = array(), $donor_ids = array()) {
149 149
 
150 150
 		// Get the Page count by default it's zero.
151 151
 		$paged = (int) $this->get_step_page();
152 152
 		// Incresed the page count by one.
153
-		++ $paged;
153
+		++$paged;
154 154
 
155 155
 		/**
156 156
 		 * Filter add to alter the argument before the wp quest run
157 157
 		 */
158
-		$args = apply_filters( 'give_tools_reset_stats_total_args', array(
158
+		$args = apply_filters('give_tools_reset_stats_total_args', array(
159 159
 			'post_type'      => 'give_payment',
160 160
 			'post_status'    => 'any',
161 161
 			'posts_per_page' => $this->per_step,
@@ -163,16 +163,16 @@  discard block
 block discarded – undo
163 163
 			// ONLY TEST MODE TRANSACTIONS!!!
164 164
 			'meta_key'       => '_give_payment_mode',
165 165
 			'meta_value'     => 'test'
166
-		) );
166
+		));
167 167
 
168 168
 		// Reset the post data.
169 169
 		wp_reset_postdata();
170 170
 		// Getting the new donation.
171
-		$donation_posts = new WP_Query( $args );
171
+		$donation_posts = new WP_Query($args);
172 172
 
173 173
 		// The Loop.
174
-		if ( $donation_posts->have_posts() ) {
175
-			while ( $donation_posts->have_posts() ) {
174
+		if ($donation_posts->have_posts()) {
175
+			while ($donation_posts->have_posts()) {
176 176
 				$donation_posts->the_post();
177 177
 				global $post;
178 178
 				// Add the donation id in side the array.
@@ -191,23 +191,23 @@  discard block
 block discarded – undo
191 191
 		$max_num_pages = (int) $donation_posts->max_num_pages;
192 192
 
193 193
 		// Check current page is less then max number of page or not
194
-		if ( $paged < $max_num_pages ) {
194
+		if ($paged < $max_num_pages) {
195 195
 			// Update the curretn page virable for the next step
196
-			$this->update_option( $this->step_on_key, $paged );
196
+			$this->update_option($this->step_on_key, $paged);
197 197
 
198 198
 			// Calculating percentage.
199 199
 			$page_remain          = $max_num_pages - $paged;
200
-			$this->total_step     = (int) $max_num_pages + ( $total_donation / $this->per_step ) + ( ( $page_remain * 2 ) * count( $donor_ids ) );
200
+			$this->total_step     = (int) $max_num_pages + ($total_donation / $this->per_step) + (($page_remain * 2) * count($donor_ids));
201 201
 			$this->step_completed = $paged;
202 202
 		} else {
203
-			$donation_ids_count = count( $donor_ids );
204
-			$this->update_option( $this->step_key, 'donation' );
205
-			$this->update_option( $this->step_on_key, '0' );
203
+			$donation_ids_count = count($donor_ids);
204
+			$this->update_option($this->step_key, 'donation');
205
+			$this->update_option($this->step_on_key, '0');
206 206
 		}
207 207
 
208
-		$donor_ids = array_unique( $donor_ids );
209
-		$this->update_option( $this->donor_key, $donor_ids );
210
-		$this->update_option( $this->donation_key, $donation_ids );
208
+		$donor_ids = array_unique($donor_ids);
209
+		$this->update_option($this->donor_key, $donor_ids);
210
+		$this->update_option($this->donation_key, $donation_ids);
211 211
 
212 212
 		wp_reset_postdata();
213 213
 	}
@@ -219,34 +219,34 @@  discard block
 block discarded – undo
219 219
 	 * @return int
220 220
 	 */
221 221
 	public function get_percentage_complete() {
222
-		return ceil( ( 100 * $this->step_completed ) / $this->total_step );
222
+		return ceil((100 * $this->step_completed) / $this->total_step);
223 223
 	}
224 224
 
225 225
 	public function process_step() {
226 226
 
227
-		if ( ! $this->can_export() ) {
228
-			wp_die( __( 'You do not have permission to delete test transactions.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
227
+		if ( ! $this->can_export()) {
228
+			wp_die(__('You do not have permission to delete test transactions.', 'give'), __('Error', 'give'), array('response' => 403));
229 229
 		}
230 230
 
231 231
 		$had_data = $this->get_data();
232 232
 
233
-		if ( $had_data ) {
233
+		if ($had_data) {
234 234
 			$this->done = false;
235 235
 
236 236
 			return true;
237 237
 		} else {
238
-			update_option( 'give_earnings_total', give_get_total_earnings( true ) );
239
-			Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) );
238
+			update_option('give_earnings_total', give_get_total_earnings(true));
239
+			Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats'));
240 240
 
241
-			$this->delete_option( $this->donation_key );
241
+			$this->delete_option($this->donation_key);
242 242
 
243 243
 			// Reset the sequential order numbers
244
-			if ( give_get_option( 'enable_sequential' ) ) {
245
-				delete_option( 'give_last_payment_number' );
244
+			if (give_get_option('enable_sequential')) {
245
+				delete_option('give_last_payment_number');
246 246
 			}
247 247
 
248 248
 			$this->done    = true;
249
-			$this->message = __( 'Test donor and transactions successfully deleted.', 'give' );
249
+			$this->message = __('Test donor and transactions successfully deleted.', 'give');
250 250
 
251 251
 			return false;
252 252
 		}
@@ -264,12 +264,12 @@  discard block
 block discarded – undo
264 264
 	public function get_data() {
265 265
 
266 266
 		// Get the donation id's.
267
-		$donation_ids = $this->get_option( $this->donation_key );
267
+		$donation_ids = $this->get_option($this->donation_key);
268 268
 
269 269
 		/**
270 270
 		 * Return false id not test donation is found.
271 271
 		 */
272
-		if ( empty( $donation_ids ) ) {
272
+		if (empty($donation_ids)) {
273 273
 			$this->is_empty   = true;
274 274
 			$this->total_step = 1;
275 275
 
@@ -280,68 +280,68 @@  discard block
 block discarded – undo
280 280
 		$step = (int) $this->get_step();
281 281
 
282 282
 		// get teh donor ids.
283
-		$donor_ids = $this->get_option( $this->donor_key );
283
+		$donor_ids = $this->get_option($this->donor_key);
284 284
 
285 285
 		// In step to we delete all the donation in loop.
286
-		if ( 2 === $step ) {
286
+		if (2 === $step) {
287 287
 			$pass_to_donor = false;
288 288
 			$page          = (int) $this->get_step_page();
289
-			$page ++;
290
-			$count = count( $donation_ids );
289
+			$page++;
290
+			$count = count($donation_ids);
291 291
 
292
-			$this->total_step     = ( ( count( $donation_ids ) / $this->per_step ) * 2 ) + count( $donor_ids );
292
+			$this->total_step     = ((count($donation_ids) / $this->per_step) * 2) + count($donor_ids);
293 293
 			$this->step_completed = $page;
294 294
 
295 295
 
296
-			if ( $count > $this->per_step ) {
296
+			if ($count > $this->per_step) {
297 297
 
298
-				$this->update_option( $this->step_on_key, $page );
299
-				$donation_ids = $this->get_delete_ids( $donation_ids, $page );
300
-				$current_page = (int) ceil( $count / $this->per_step );
298
+				$this->update_option($this->step_on_key, $page);
299
+				$donation_ids = $this->get_delete_ids($donation_ids, $page);
300
+				$current_page = (int) ceil($count / $this->per_step);
301 301
 
302
-				if ( $page === $current_page ) {
302
+				if ($page === $current_page) {
303 303
 					$pass_to_donor = true;
304 304
 				}
305 305
 			} else {
306 306
 				$pass_to_donor = true;
307 307
 			}
308 308
 
309
-			if ( true === $pass_to_donor ) {
310
-				$this->update_option( $this->step_key, 'donor' );
311
-				$this->update_option( $this->step_on_key, '0' );
309
+			if (true === $pass_to_donor) {
310
+				$this->update_option($this->step_key, 'donor');
311
+				$this->update_option($this->step_on_key, '0');
312 312
 			}
313 313
 
314
-			foreach ( $donation_ids as $item ) {
315
-				wp_delete_post( $item, true );
314
+			foreach ($donation_ids as $item) {
315
+				wp_delete_post($item, true);
316 316
 			}
317 317
 		}
318 318
 
319 319
 
320 320
 		// Here we delete all the donor
321
-		if ( 3 === $step ) {
321
+		if (3 === $step) {
322 322
 			$page  = (int) $this->get_step_page();
323
-			$count = count( $donor_ids );
323
+			$count = count($donor_ids);
324 324
 
325
-			$this->total_step     = ( ( count( $donation_ids ) / $this->per_step ) * 2 ) + count( $donor_ids );
326
-			$this->step_completed = $page + ( count( $donation_ids ) / $this->per_step );
325
+			$this->total_step     = ((count($donation_ids) / $this->per_step) * 2) + count($donor_ids);
326
+			$this->step_completed = $page + (count($donation_ids) / $this->per_step);
327 327
 
328
-			$args = apply_filters( 'give_tools_reset_stats_total_args', array(
328
+			$args = apply_filters('give_tools_reset_stats_total_args', array(
329 329
 				'post_type'      => 'give_payment',
330 330
 				'post_status'    => 'any',
331 331
 				'posts_per_page' => 1,
332 332
 				'meta_key'       => '_give_payment_mode',
333 333
 				'meta_value'     => 'live',
334
-				'author'         => $donor_ids[ $page ]
335
-			) );
334
+				'author'         => $donor_ids[$page]
335
+			));
336 336
 
337
-			$donation_posts = get_posts( $args );
338
-			if ( empty( $donation_posts ) ) {
339
-				Give()->donors->delete_by_user_id( $donor_ids[ $page ] );
337
+			$donation_posts = get_posts($args);
338
+			if (empty($donation_posts)) {
339
+				Give()->donors->delete_by_user_id($donor_ids[$page]);
340 340
 			}
341 341
 
342
-			$page ++;
343
-			$this->update_option( $this->step_on_key, $page );
344
-			if ( $count === $page ) {
342
+			$page++;
343
+			$this->update_option($this->step_on_key, $page);
344
+			if ($count === $page) {
345 345
 				$this->is_empty = false;
346 346
 
347 347
 				return false;
@@ -353,24 +353,24 @@  discard block
 block discarded – undo
353 353
 		return true;
354 354
 	}
355 355
 
356
-	public function get_delete_ids( $donation_ids, $page ) {
357
-		$index            = $page --;
358
-		$count            = count( $donation_ids );
356
+	public function get_delete_ids($donation_ids, $page) {
357
+		$index            = $page--;
358
+		$count            = count($donation_ids);
359 359
 		$temp             = 0;
360 360
 		$current_page     = 0;
361 361
 		$post_delete      = $this->per_step;
362 362
 		$page_donation_id = array();
363 363
 
364
-		foreach ( $donation_ids as $item ) {
365
-			$temp ++;
366
-			$page_donation_id[ $current_page ][] = $item;
367
-			if ( $temp === $post_delete ) {
368
-				$current_page ++;
364
+		foreach ($donation_ids as $item) {
365
+			$temp++;
366
+			$page_donation_id[$current_page][] = $item;
367
+			if ($temp === $post_delete) {
368
+				$current_page++;
369 369
 				$temp = 0;
370 370
 			}
371 371
 		}
372 372
 
373
-		return $page_donation_id[ $page ];
373
+		return $page_donation_id[$page];
374 374
 	}
375 375
 
376 376
 	/**
@@ -382,8 +382,8 @@  discard block
 block discarded – undo
382 382
 	 *
383 383
 	 * @return mixed       Returns the data from the database
384 384
 	 */
385
-	public function get_option( $key, $defalut_value = false ) {
386
-		return get_option( $key, $defalut_value );
385
+	public function get_option($key, $defalut_value = false) {
386
+		return get_option($key, $defalut_value);
387 387
 	}
388 388
 
389 389
 	/**
@@ -396,8 +396,8 @@  discard block
 block discarded – undo
396 396
 	 *
397 397
 	 * @return void
398 398
 	 */
399
-	public function update_option( $key, $value ) {
400
-		update_option( $key, $value, false );
399
+	public function update_option($key, $value) {
400
+		update_option($key, $value, false);
401 401
 	}
402 402
 
403 403
 	/**
@@ -409,8 +409,8 @@  discard block
 block discarded – undo
409 409
 	 *
410 410
 	 * @return void
411 411
 	 */
412
-	public function delete_option( $key ) {
413
-		delete_option( $key );
412
+	public function delete_option($key) {
413
+		delete_option($key);
414 414
 	}
415 415
 
416 416
 	/**
@@ -421,12 +421,12 @@  discard block
 block discarded – undo
421 421
 	 * @return int|string
422 422
 	 */
423 423
 	private function get_step() {
424
-		$step_key = (string) $this->get_option( $this->step_key, false );
425
-		if ( 'count' === $step_key ) {
424
+		$step_key = (string) $this->get_option($this->step_key, false);
425
+		if ('count' === $step_key) {
426 426
 			return 1;
427
-		} elseif ( 'donation' === $step_key ) {
427
+		} elseif ('donation' === $step_key) {
428 428
 			return 2;
429
-		} elseif ( 'donor' === $step_key ) {
429
+		} elseif ('donor' === $step_key) {
430 430
 			return 3;
431 431
 		} else {
432 432
 			return $step_key;
@@ -437,6 +437,6 @@  discard block
 block discarded – undo
437 437
 	 * Get the current $page value in the ajax.
438 438
 	 */
439 439
 	private function get_step_page() {
440
-		return $this->get_option( $this->step_on_key, false );
440
+		return $this->get_option($this->step_on_key, false);
441 441
 	}
442 442
 }
Please login to merge, or discard this patch.
includes/formatting.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -340,7 +340,7 @@
 block discarded – undo
340 340
  * @since 1.0
341 341
  *
342 342
  * @param int|float|string $amount   Formatted or sanitized price
343
- * @param int|bool         $dp       number of decimals
343
+ * @param boolean         $dp       number of decimals
344 344
  * @param bool             $sanitize Whether or not sanitize number
345 345
  *
346 346
  * @return string $amount Newly formatted amount or Price Not Available
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@
 block discarded – undo
96 96
 	// Bailout.
97 97
 	if( empty( $number ) || ( ! is_numeric( $number ) && ! is_string( $number ) ) ) {
98 98
 		return $number;
99
-	}elseif (
99
+	} elseif (
100 100
 		( false == strpos( $number, $thousand_separator ) ) &&
101 101
 		( false === strpos( $number, $decimal_separator ) )
102 102
 	) {
Please login to merge, or discard this patch.
Spacing   +146 added lines, -149 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  * @return mixed
24 24
  */
25 25
 function give_get_price_decimals() {
26
-	return apply_filters( 'give_sanitize_amount_decimals', give_get_option( 'number_decimals', 0 ) );
26
+	return apply_filters('give_sanitize_amount_decimals', give_get_option('number_decimals', 0));
27 27
 }
28 28
 
29 29
 /**
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
  */
36 36
 function give_get_price_thousand_separator() {
37 37
 	$give_options       = give_get_settings();
38
-	$thousand_separator = isset( $give_options['thousands_separator'] ) ? $give_options['thousands_separator'] : ',';
39
-	$thousand_separator = empty( $thousand_separator ) ? ' ' : $thousand_separator;
38
+	$thousand_separator = isset($give_options['thousands_separator']) ? $give_options['thousands_separator'] : ',';
39
+	$thousand_separator = empty($thousand_separator) ? ' ' : $thousand_separator;
40 40
 
41 41
 	return $thousand_separator;
42 42
 }
@@ -55,11 +55,10 @@  discard block
 block discarded – undo
55 55
 	);
56 56
 
57 57
 	$thousand_separator = give_get_price_thousand_separator();
58
-	$default_decimal_separator = in_array( $thousand_separator, $default_decimal_separators ) ?
59
-		$default_decimal_separators[$thousand_separator] :
60
-		'.';
58
+	$default_decimal_separator = in_array($thousand_separator, $default_decimal_separators) ?
59
+		$default_decimal_separators[$thousand_separator] : '.';
61 60
 
62
-	$decimal_separator = give_get_option( 'decimal_separator', $default_decimal_separator );
61
+	$decimal_separator = give_get_option('decimal_separator', $default_decimal_separator);
63 62
 
64 63
 	return $decimal_separator;
65 64
 }
@@ -74,8 +73,8 @@  discard block
 block discarded – undo
74 73
  *
75 74
  * @return string $amount Newly sanitized amount
76 75
  */
77
-function give_sanitize_amount_for_db( $number ) {
78
-	return give_sanitize_amount( $number, 6 );
76
+function give_sanitize_amount_for_db($number) {
77
+	return give_sanitize_amount($number, 6);
79 78
 }
80 79
 
81 80
 /**
@@ -89,40 +88,40 @@  discard block
 block discarded – undo
89 88
  *
90 89
  * @return string $amount Newly sanitized amount
91 90
  */
92
-function give_maybe_sanitize_amount( $number, $dp = false, $trim_zeros = false ) {
91
+function give_maybe_sanitize_amount($number, $dp = false, $trim_zeros = false) {
93 92
 	$thousand_separator = give_get_price_thousand_separator();
94 93
 	$decimal_separator  = give_get_price_decimal_separator();
95 94
 
96 95
 	// Bailout.
97
-	if( empty( $number ) || ( ! is_numeric( $number ) && ! is_string( $number ) ) ) {
96
+	if (empty($number) || ( ! is_numeric($number) && ! is_string($number))) {
98 97
 		return $number;
99 98
 	}elseif (
100
-		( false == strpos( $number, $thousand_separator ) ) &&
101
-		( false === strpos( $number, $decimal_separator ) )
99
+		(false == strpos($number, $thousand_separator)) &&
100
+		(false === strpos($number, $decimal_separator))
102 101
 	) {
103
-		return number_format( $number, ( is_bool( $dp ) ? give_get_price_decimals() : $dp ), '.', '' );
102
+		return number_format($number, (is_bool($dp) ? give_get_price_decimals() : $dp), '.', '');
104 103
 	}
105 104
 
106 105
 	// Handle thousand separator as '.'
107 106
 	// Handle sanitize database values.
108
-	$number_parts = explode( '.', $number );
109
-	$is_db_sanitize_val = ( 2 === count( $number_parts ) && ( 6 === strlen( $number_parts[1] ) ) );
107
+	$number_parts = explode('.', $number);
108
+	$is_db_sanitize_val = (2 === count($number_parts) && (6 === strlen($number_parts[1])));
110 109
 
111
-	if( $is_db_sanitize_val ) {
110
+	if ($is_db_sanitize_val) {
112 111
 		// Sanitize database value.
113
-		return number_format( $number, ( is_bool( $dp ) ? give_get_price_decimals() : $dp ), '.', '' );
112
+		return number_format($number, (is_bool($dp) ? give_get_price_decimals() : $dp), '.', '');
114 113
 
115 114
 	} elseif (
116 115
 		'.' === $thousand_separator &&
117
-		false !== strpos( $number, $thousand_separator )
118
-	){
116
+		false !== strpos($number, $thousand_separator)
117
+	) {
119 118
 		// Fix point thousand separator value.
120
-		if( ! $is_db_sanitize_val ) {
121
-			$number = str_replace( '.', '', $number );
119
+		if ( ! $is_db_sanitize_val) {
120
+			$number = str_replace('.', '', $number);
122 121
 		}
123 122
 	}
124 123
 
125
-	return give_sanitize_amount( $number, $dp, $trim_zeros );
124
+	return give_sanitize_amount($number, $dp, $trim_zeros);
126 125
 }
127 126
 
128 127
 /**
@@ -138,67 +137,67 @@  discard block
 block discarded – undo
138 137
  *
139 138
  * @return string $amount Newly sanitized amount
140 139
  */
141
-function give_sanitize_amount( $number, $dp = false, $trim_zeros = false ) {
140
+function give_sanitize_amount($number, $dp = false, $trim_zeros = false) {
142 141
 
143 142
 	// Bailout.
144
-	if ( empty( $number ) || ( ! is_numeric( $number ) && ! is_string( $number ) ) ) {
143
+	if (empty($number) || ( ! is_numeric($number) && ! is_string($number))) {
145 144
 		return $number;
146 145
 	}
147 146
 
148 147
 	// Remove slash from amount.
149 148
 	// If thousand or decimal separator is set to ' then in $_POST or $_GET param we will get an escaped number.
150 149
 	// To prevent notices and warning remove slash from amount/number.
151
-	$number = wp_unslash( $number );
150
+	$number = wp_unslash($number);
152 151
 
153 152
 	$thousand_separator = give_get_price_thousand_separator();
154 153
 
155 154
 	$locale   = localeconv();
156
-	$decimals = array( give_get_price_decimal_separator(), $locale['decimal_point'], $locale['mon_decimal_point'] );
155
+	$decimals = array(give_get_price_decimal_separator(), $locale['decimal_point'], $locale['mon_decimal_point']);
157 156
 
158 157
 	// Remove locale from string
159
-	if ( ! is_float( $number ) ) {
160
-		$number = str_replace( $decimals, '.', $number );
158
+	if ( ! is_float($number)) {
159
+		$number = str_replace($decimals, '.', $number);
161 160
 	}
162 161
 
163 162
 	// Remove thousand amount formatting if amount has.
164 163
 	// This condition use to add backward compatibility to version before 1.6, because before version 1.6 we were saving formatted amount to db.
165 164
 	// Do not replace thousand separator from price if it is same as decimal separator, because it will be already replace by above code.
166
-	if ( ! in_array( $thousand_separator, $decimals ) && ( false !== strpos( $number, $thousand_separator ) ) ) {
167
-		$number = str_replace( $thousand_separator, '', $number );
168
-	} elseif ( in_array( $thousand_separator, $decimals ) ) {
169
-		$number = preg_replace( '/\.(?=.*\.)/', '', $number );
165
+	if ( ! in_array($thousand_separator, $decimals) && (false !== strpos($number, $thousand_separator))) {
166
+		$number = str_replace($thousand_separator, '', $number);
167
+	} elseif (in_array($thousand_separator, $decimals)) {
168
+		$number = preg_replace('/\.(?=.*\.)/', '', $number);
170 169
 	}
171 170
 
172 171
 	// Remove non numeric entity before decimal separator.
173
-	$number     = preg_replace( '/[^0-9\.]/', '', $number );
172
+	$number     = preg_replace('/[^0-9\.]/', '', $number);
174 173
 	$default_dp = give_get_price_decimals();
175 174
 
176 175
 	// Reset negative amount to zero.
177
-	if ( 0 > $number ) {
178
-		$number = number_format( 0, $default_dp, '.' );
176
+	if (0 > $number) {
177
+		$number = number_format(0, $default_dp, '.');
179 178
 	}
180 179
 
181 180
 	// If number does not have decimal then add number of decimals to it.
182 181
 	if (
183
-		false === strpos( $number, '.' )
184
-		|| ( $default_dp > strlen( substr( $number, strpos( $number, '.' ) + 1 ) ) )
182
+		false === strpos($number, '.')
183
+		|| ($default_dp > strlen(substr($number, strpos($number, '.') + 1)))
185 184
 	) {
186
-		$number = number_format( $number, $default_dp, '.', '' );
185
+		$number = number_format($number, $default_dp, '.', '');
187 186
 	}
188 187
 
189 188
 	// Format number by custom number of decimals.
190
-	if ( false !== $dp ) {
191
-		$dp     = intval( is_bool( $dp ) ? $default_dp : $dp );
192
-		$dp     = apply_filters( 'give_sanitize_amount_decimals', $dp, $number );
193
-		$number = number_format( floatval( $number ), $dp, '.', '' );
189
+	if (false !== $dp) {
190
+		$dp     = intval(is_bool($dp) ? $default_dp : $dp);
191
+		$dp     = apply_filters('give_sanitize_amount_decimals', $dp, $number);
192
+		$number = number_format(floatval($number), $dp, '.', '');
194 193
 	}
195 194
 
196 195
 	// Trim zeros.
197
-	if ( $trim_zeros && strstr( $number, '.' ) ) {
198
-		$number = rtrim( rtrim( $number, '0' ), '.' );
196
+	if ($trim_zeros && strstr($number, '.')) {
197
+		$number = rtrim(rtrim($number, '0'), '.');
199 198
 	}
200 199
 
201
-	return apply_filters( 'give_sanitize_amount', $number );
200
+	return apply_filters('give_sanitize_amount', $number);
202 201
 }
203 202
 
204 203
 /**
@@ -211,10 +210,10 @@  discard block
 block discarded – undo
211 210
  *
212 211
  * @return string $amount   Newly formatted amount or Price Not Available
213 212
  */
214
-function give_format_amount( $amount, $args = array() ) {
213
+function give_format_amount($amount, $args = array()) {
215 214
 	// Backward compatibility.
216
-	if( is_bool( $args ) ) {
217
-		$args = array( 'decimal' => $args );
215
+	if (is_bool($args)) {
216
+		$args = array('decimal' => $args);
218 217
 	}
219 218
 
220 219
 	$default_args = array(
@@ -223,60 +222,59 @@  discard block
 block discarded – undo
223 222
 		'currency' => give_get_currency(),
224 223
 	);
225 224
 
226
-	$args = wp_parse_args( $args, $default_args );
225
+	$args = wp_parse_args($args, $default_args);
227 226
 
228 227
 	$formatted     = 0;
229 228
 	$thousands_sep = give_get_price_thousand_separator();
230 229
 	$decimal_sep   = give_get_price_decimal_separator();
231
-	$decimals      = ! empty( $args['decimal'] ) ? give_get_price_decimals() : 0;
230
+	$decimals      = ! empty($args['decimal']) ? give_get_price_decimals() : 0;
232 231
 	$currency      = $args['currency'];
233 232
 
234
-	if ( ! empty( $amount ) ) {
233
+	if ( ! empty($amount)) {
235 234
 		// Sanitize amount before formatting.
236
-		$amount = ! empty( $args['sanitize'] ) ?
237
-			give_maybe_sanitize_amount( $amount, $decimals ) :
238
-			number_format( $amount, $decimals, '.', '' );
235
+		$amount = ! empty($args['sanitize']) ?
236
+			give_maybe_sanitize_amount($amount, $decimals) : number_format($amount, $decimals, '.', '');
239 237
 
240
-		switch ( $currency ) {
238
+		switch ($currency) {
241 239
 			case 'INR':
242 240
 				$decimal_amount = '';
243 241
 
244 242
 				// Extract decimals from amount
245
-				if ( ( $pos = strpos( $amount, '.' ) ) !== false ) {
246
-					if ( ! empty( $decimals ) ) {
247
-						$decimal_amount = substr( round( substr( $amount, $pos ), $decimals ), 1 );
248
-						$amount         = substr( $amount, 0, $pos );
249
-
250
-						if ( ! $decimal_amount ) {
251
-							$decimal_amount = substr( '.0000000000', 0, ( $decimals + 1 ) );
252
-						} elseif ( ( $decimals + 1 ) > strlen( $decimal_amount ) ) {
253
-							$decimal_amount = substr( "{$decimal_amount}000000000", 0, ( $decimals + 1 ) );
243
+				if (($pos = strpos($amount, '.')) !== false) {
244
+					if ( ! empty($decimals)) {
245
+						$decimal_amount = substr(round(substr($amount, $pos), $decimals), 1);
246
+						$amount         = substr($amount, 0, $pos);
247
+
248
+						if ( ! $decimal_amount) {
249
+							$decimal_amount = substr('.0000000000', 0, ($decimals + 1));
250
+						} elseif (($decimals + 1) > strlen($decimal_amount)) {
251
+							$decimal_amount = substr("{$decimal_amount}000000000", 0, ($decimals + 1));
254 252
 						}
255 253
 
256 254
 					} else {
257
-						$amount = number_format( $amount, $decimals, $decimal_sep, '' );
255
+						$amount = number_format($amount, $decimals, $decimal_sep, '');
258 256
 					}
259 257
 				}
260 258
 
261 259
 				// Extract last 3 from amount
262
-				$result = substr( $amount, - 3 );
263
-				$amount = substr( $amount, 0, - 3 );
260
+				$result = substr($amount, - 3);
261
+				$amount = substr($amount, 0, - 3);
264 262
 
265 263
 				// Apply digits 2 by 2
266
-				while ( strlen( $amount ) > 0 ) {
267
-					$result = substr( $amount, - 2 ) . $thousands_sep . $result;
268
-					$amount = substr( $amount, 0, - 2 );
264
+				while (strlen($amount) > 0) {
265
+					$result = substr($amount, - 2).$thousands_sep.$result;
266
+					$amount = substr($amount, 0, - 2);
269 267
 				}
270 268
 
271
-				$formatted = $result . $decimal_amount;
269
+				$formatted = $result.$decimal_amount;
272 270
 				break;
273 271
 
274 272
 			default:
275
-				$formatted = number_format( $amount, $decimals, $decimal_sep, $thousands_sep );
273
+				$formatted = number_format($amount, $decimals, $decimal_sep, $thousands_sep);
276 274
 		}
277 275
 	}
278 276
 
279
-	return apply_filters( 'give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $currency, $args );
277
+	return apply_filters('give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $currency, $args);
280 278
 }
281 279
 
282 280
 
@@ -294,51 +292,51 @@  discard block
 block discarded – undo
294 292
  *
295 293
  * @return float|string  formatted amount number with large number names.
296 294
  */
297
-function give_human_format_large_amount( $amount, $args = array() ) {
295
+function give_human_format_large_amount($amount, $args = array()) {
298 296
 	$default_args = array(
299 297
 		'currency' => give_get_currency(),
300 298
 	);
301 299
 
302
-	$args = wp_parse_args( $args, $default_args );
300
+	$args = wp_parse_args($args, $default_args);
303 301
 
304 302
 	// Get thousand separator.
305 303
 	$thousands_sep = give_get_price_thousand_separator();
306 304
 
307 305
 	// Sanitize amount.
308
-	$sanitize_amount = give_maybe_sanitize_amount( $amount );
306
+	$sanitize_amount = give_maybe_sanitize_amount($amount);
309 307
 
310 308
 	// Explode amount to calculate name of large numbers.
311
-	$amount_array = explode( $thousands_sep, $amount );
309
+	$amount_array = explode($thousands_sep, $amount);
312 310
 
313 311
 	// Calculate amount parts count.
314
-	$amount_count_parts = count( $amount_array );
312
+	$amount_count_parts = count($amount_array);
315 313
 
316 314
 	// Human format amount (default).
317 315
 	$human_format_amount = $amount;
318 316
 
319
-	switch ( $args['currency'] ) {
317
+	switch ($args['currency']) {
320 318
 		case 'INR':
321 319
 			// Calculate large number formatted amount.
322
-			if ( 4 < $amount_count_parts ) {
323
-				$human_format_amount = sprintf( esc_html__( '%s arab', 'give' ), round( ( $sanitize_amount / 1000000000 ), 2 ) );
324
-			} elseif ( 3 < $amount_count_parts ) {
325
-				$human_format_amount = sprintf( esc_html__( '%s crore', 'give' ), round( ( $sanitize_amount / 10000000 ), 2 ) );
326
-			} elseif ( 2 < $amount_count_parts ) {
327
-				$human_format_amount = sprintf( esc_html__( '%s lakh', 'give' ), round( ( $sanitize_amount / 100000 ), 2 ) );
320
+			if (4 < $amount_count_parts) {
321
+				$human_format_amount = sprintf(esc_html__('%s arab', 'give'), round(($sanitize_amount / 1000000000), 2));
322
+			} elseif (3 < $amount_count_parts) {
323
+				$human_format_amount = sprintf(esc_html__('%s crore', 'give'), round(($sanitize_amount / 10000000), 2));
324
+			} elseif (2 < $amount_count_parts) {
325
+				$human_format_amount = sprintf(esc_html__('%s lakh', 'give'), round(($sanitize_amount / 100000), 2));
328 326
 			}
329 327
 			break;
330 328
 		default:
331 329
 			// Calculate large number formatted amount.
332
-			if ( 4 < $amount_count_parts ) {
333
-				$human_format_amount = sprintf( esc_html__( '%s trillion', 'give' ), round( ( $sanitize_amount / 1000000000000 ), 2 ) );
334
-			} elseif ( 3 < $amount_count_parts ) {
335
-				$human_format_amount = sprintf( esc_html__( '%s billion', 'give' ), round( ( $sanitize_amount / 1000000000 ), 2 ) );
336
-			} elseif ( 2 < $amount_count_parts ) {
337
-				$human_format_amount = sprintf( esc_html__( '%s million', 'give' ), round( ( $sanitize_amount / 1000000 ), 2 ) );
330
+			if (4 < $amount_count_parts) {
331
+				$human_format_amount = sprintf(esc_html__('%s trillion', 'give'), round(($sanitize_amount / 1000000000000), 2));
332
+			} elseif (3 < $amount_count_parts) {
333
+				$human_format_amount = sprintf(esc_html__('%s billion', 'give'), round(($sanitize_amount / 1000000000), 2));
334
+			} elseif (2 < $amount_count_parts) {
335
+				$human_format_amount = sprintf(esc_html__('%s million', 'give'), round(($sanitize_amount / 1000000), 2));
338 336
 			}
339 337
 	}
340 338
 
341
-	return apply_filters( 'give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount );
339
+	return apply_filters('give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount);
342 340
 }
343 341
 
344 342
 /**
@@ -352,17 +350,16 @@  discard block
 block discarded – undo
352 350
  *
353 351
  * @return string $amount Newly formatted amount or Price Not Available
354 352
  */
355
-function give_format_decimal( $amount, $dp = false, $sanitize = true ) {
353
+function give_format_decimal($amount, $dp = false, $sanitize = true) {
356 354
 	$decimal_separator = give_get_price_decimal_separator();
357 355
 	$formatted_amount  = $sanitize ?
358
-		give_maybe_sanitize_amount( $amount, $dp ) :
359
-		number_format( $amount, ( is_bool( $dp ) ? give_get_price_decimals() : $dp ), '.', '' );
356
+		give_maybe_sanitize_amount($amount, $dp) : number_format($amount, (is_bool($dp) ? give_get_price_decimals() : $dp), '.', '');
360 357
 
361
-	if ( false !== strpos( $formatted_amount, '.' ) ) {
362
-		$formatted_amount = str_replace( '.', $decimal_separator, $formatted_amount );
358
+	if (false !== strpos($formatted_amount, '.')) {
359
+		$formatted_amount = str_replace('.', $decimal_separator, $formatted_amount);
363 360
 	}
364 361
 
365
-	return apply_filters( 'give_format_decimal', $formatted_amount, $amount, $decimal_separator );
362
+	return apply_filters('give_format_decimal', $formatted_amount, $amount, $decimal_separator);
366 363
 }
367 364
 
368 365
 /**
@@ -376,24 +373,24 @@  discard block
 block discarded – undo
376 373
  *
377 374
  * @return mixed|string
378 375
  */
379
-function give_currency_filter( $price = '', $currency = '', $decode_currency = false ) {
376
+function give_currency_filter($price = '', $currency = '', $decode_currency = false) {
380 377
 
381
-	if ( empty( $currency ) || ! array_key_exists( (string) $currency, give_get_currencies() ) ) {
378
+	if (empty($currency) || ! array_key_exists((string) $currency, give_get_currencies())) {
382 379
 		$currency = give_get_currency();
383 380
 	}
384 381
 
385
-	$position = give_get_option( 'currency_position', 'before' );
382
+	$position = give_get_option('currency_position', 'before');
386 383
 
387 384
 	$negative = $price < 0;
388 385
 
389
-	if ( $negative ) {
386
+	if ($negative) {
390 387
 		// Remove proceeding "-".
391
-		$price = substr( $price, 1 );
388
+		$price = substr($price, 1);
392 389
 	}
393 390
 
394
-	$symbol = give_currency_symbol( $currency, $decode_currency );
391
+	$symbol = give_currency_symbol($currency, $decode_currency);
395 392
 
396
-	switch ( $currency ) :
393
+	switch ($currency) :
397 394
 		case 'GBP' :
398 395
 		case 'BRL' :
399 396
 		case 'EUR' :
@@ -422,13 +419,13 @@  discard block
 block discarded – undo
422 419
 		case 'MAD' :
423 420
 		case 'KRW' :
424 421
 		case 'ZAR' :
425
-			$formatted = ( 'before' === $position ? $symbol . $price : $price . $symbol );
422
+			$formatted = ('before' === $position ? $symbol.$price : $price.$symbol);
426 423
 			break;
427 424
 		case 'NOK' :
428
-			$formatted = ( 'before' === $position ? $symbol . ' ' . $price : $price . ' ' . $symbol );
425
+			$formatted = ('before' === $position ? $symbol.' '.$price : $price.' '.$symbol);
429 426
 			break;
430 427
 		default :
431
-			$formatted = ( 'before' === $position ? $currency . ' ' . $price : $price . ' ' . $currency );
428
+			$formatted = ('before' === $position ? $currency.' '.$price : $price.' '.$currency);
432 429
 			break;
433 430
 	endswitch;
434 431
 
@@ -443,11 +440,11 @@  discard block
 block discarded – undo
443 440
 	 *           and if currency is USD and currency position is after then
444 441
 	 *           filter name will be give_usd_currency_filter_after
445 442
 	 */
446
-	$formatted = apply_filters( 'give_' . strtolower( $currency ) . "_currency_filter_{$position}", $formatted, $currency, $price );
443
+	$formatted = apply_filters('give_'.strtolower($currency)."_currency_filter_{$position}", $formatted, $currency, $price);
447 444
 
448
-	if ( $negative ) {
445
+	if ($negative) {
449 446
 		// Prepend the minus sign before the currency sign.
450
-		$formatted = '-' . $formatted;
447
+		$formatted = '-'.$formatted;
451 448
 	}
452 449
 
453 450
 	return $formatted;
@@ -463,21 +460,21 @@  discard block
 block discarded – undo
463 460
  */
464 461
 function give_currency_decimal_filter() {
465 462
 
466
-	remove_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' );
463
+	remove_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter');
467 464
 
468 465
 	// Set default number of decimals.
469 466
 	$decimals = give_get_price_decimals();
470 467
 
471
-	add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' );
468
+	add_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter');
472 469
 
473 470
 	// Get number of decimals with backward compatibility ( version < 1.6 )
474
-	if ( 1 <= func_num_args() ) {
475
-		$decimals = ( false === func_get_arg( 0 ) ? $decimals : absint( func_get_arg( 0 ) ) );
471
+	if (1 <= func_num_args()) {
472
+		$decimals = (false === func_get_arg(0) ? $decimals : absint(func_get_arg(0)));
476 473
 	}
477 474
 
478 475
 	$currency = give_get_currency();
479 476
 
480
-	switch ( $currency ) {
477
+	switch ($currency) {
481 478
 		case 'RIAL' :
482 479
 		case 'JPY' :
483 480
 		case 'TWD' :
@@ -487,11 +484,11 @@  discard block
 block discarded – undo
487 484
 			break;
488 485
 	}
489 486
 
490
-	return apply_filters( 'give_currency_decimal_count', $decimals, $currency );
487
+	return apply_filters('give_currency_decimal_count', $decimals, $currency);
491 488
 }
492 489
 
493
-add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' );
494
-add_filter( 'give_format_amount_decimals', 'give_currency_decimal_filter' );
490
+add_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter');
491
+add_filter('give_format_amount_decimals', 'give_currency_decimal_filter');
495 492
 
496 493
 
497 494
 /**
@@ -503,7 +500,7 @@  discard block
 block discarded – undo
503 500
  *
504 501
  * @return string                  Date format string
505 502
  */
506
-function give_date_format( $date_context = '' ) {
503
+function give_date_format($date_context = '') {
507 504
 	/**
508 505
 	 * Filter the date context
509 506
 	 *
@@ -524,19 +521,19 @@  discard block
 block discarded – undo
524 521
 	 *
525 522
 	 *    }
526 523
 	 */
527
-	$date_format_contexts = apply_filters( 'give_date_format_contexts', array() );
524
+	$date_format_contexts = apply_filters('give_date_format_contexts', array());
528 525
 
529 526
 	// Set date format to default date format.
530
-	$date_format = get_option( 'date_format' );
527
+	$date_format = get_option('date_format');
531 528
 
532 529
 	// Update date format if we have non empty date format context array and non empty date format string for that context.
533
-	if ( $date_context && ! empty( $date_format_contexts ) && array_key_exists( $date_context, $date_format_contexts ) ) {
534
-		$date_format = ! empty( $date_format_contexts[ $date_context ] )
535
-			? $date_format_contexts[ $date_context ]
530
+	if ($date_context && ! empty($date_format_contexts) && array_key_exists($date_context, $date_format_contexts)) {
531
+		$date_format = ! empty($date_format_contexts[$date_context])
532
+			? $date_format_contexts[$date_context]
536 533
 			: $date_format;
537 534
 	}
538 535
 
539
-	return apply_filters( 'give_date_format', $date_format );
536
+	return apply_filters('give_date_format', $date_format);
540 537
 }
541 538
 
542 539
 /**
@@ -550,8 +547,8 @@  discard block
 block discarded – undo
550 547
  *
551 548
  * @return string
552 549
  */
553
-function give_get_cache_key( $action, $query_args ) {
554
-	return Give_Cache::get_key( $action, $query_args );
550
+function give_get_cache_key($action, $query_args) {
551
+	return Give_Cache::get_key($action, $query_args);
555 552
 }
556 553
 
557 554
 /**
@@ -564,11 +561,11 @@  discard block
 block discarded – undo
564 561
  *
565 562
  * @return string|array
566 563
  */
567
-function give_clean( $var ) {
568
-	if ( is_array( $var ) ) {
569
-		return array_map( 'give_clean', $var );
564
+function give_clean($var) {
565
+	if (is_array($var)) {
566
+		return array_map('give_clean', $var);
570 567
 	} else {
571
-		return is_scalar( $var ) ? sanitize_text_field( $var ) : $var;
568
+		return is_scalar($var) ? sanitize_text_field($var) : $var;
572 569
 	}
573 570
 }
574 571
 
@@ -581,10 +578,10 @@  discard block
 block discarded – undo
581 578
  *
582 579
  * @return int
583 580
  */
584
-function give_let_to_num( $size ) {
585
-	$l   = substr( $size, - 1 );
586
-	$ret = substr( $size, 0, - 1 );
587
-	switch ( strtoupper( $l ) ) {
581
+function give_let_to_num($size) {
582
+	$l   = substr($size, - 1);
583
+	$ret = substr($size, 0, - 1);
584
+	switch (strtoupper($l)) {
588 585
 		case 'P':
589 586
 			$ret *= 1024;
590 587
 		case 'T':
@@ -609,19 +606,19 @@  discard block
 block discarded – undo
609 606
  * @param int   $action
610 607
  * @param array $wp_die_args
611 608
  */
612
-function give_validate_nonce( $nonce, $action = - 1, $wp_die_args = array() ) {
609
+function give_validate_nonce($nonce, $action = - 1, $wp_die_args = array()) {
613 610
 
614 611
 	$default_wp_die_args = array(
615
-		'message' => esc_html__( 'Nonce verification has failed.', 'give' ),
616
-		'title'   => esc_html__( 'Error', 'give' ),
612
+		'message' => esc_html__('Nonce verification has failed.', 'give'),
613
+		'title'   => esc_html__('Error', 'give'),
617 614
 		'args'    => array(
618 615
 			'response' => 403,
619 616
 		),
620 617
 	);
621 618
 
622
-	$wp_die_args = wp_parse_args( $wp_die_args, $default_wp_die_args );
619
+	$wp_die_args = wp_parse_args($wp_die_args, $default_wp_die_args);
623 620
 
624
-	if ( ! wp_verify_nonce( $nonce, $action ) ) {
621
+	if ( ! wp_verify_nonce($nonce, $action)) {
625 622
 		wp_die(
626 623
 			$wp_die_args['message'],
627 624
 			$wp_die_args['title'],
@@ -643,23 +640,23 @@  discard block
 block discarded – undo
643 640
  *
644 641
  * @return mixed
645 642
  */
646
-function give_check_variable( $variable, $conditional = '', $default = false ) {
643
+function give_check_variable($variable, $conditional = '', $default = false) {
647 644
 
648
-	switch ( $conditional ) {
645
+	switch ($conditional) {
649 646
 		case 'isset_empty':
650
-			$variable = ( isset( $variable ) && ! empty( $variable ) ) ? $variable : $default;
647
+			$variable = (isset($variable) && ! empty($variable)) ? $variable : $default;
651 648
 			break;
652 649
 
653 650
 		case 'empty':
654
-			$variable = ! empty( $variable ) ? $variable : $default;
651
+			$variable = ! empty($variable) ? $variable : $default;
655 652
 			break;
656 653
 
657 654
 		case 'null':
658
-			$variable = ! is_null( $variable ) ? $variable : $default;
655
+			$variable = ! is_null($variable) ? $variable : $default;
659 656
 			break;
660 657
 
661 658
 		default:
662
-			$variable = isset( $variable ) ? $variable : $default;
659
+			$variable = isset($variable) ? $variable : $default;
663 660
 
664 661
 	}
665 662
 
Please login to merge, or discard this patch.
includes/forms/functions.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
  *
156 156
  * Used to redirect a user back to the donation form if there are errors present.
157 157
  *
158
- * @param array $args
158
+ * @param string $args
159 159
  *
160 160
  * @access public
161 161
  * @since  1.0
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
  *
442 442
  * @param int $form_id Give Form ID
443 443
  *
444
- * @return int $earnings Earnings for a certain form
444
+ * @return double $earnings Earnings for a certain form
445 445
  */
446 446
 function give_get_form_earnings_stats( $form_id = 0 ) {
447 447
 	$give_form = new Give_Donate_Form( $form_id );
@@ -708,7 +708,7 @@  discard block
 block discarded – undo
708 708
  *
709 709
  * @param int $form_id ID number of the form to retrieve the minimum price for
710 710
  *
711
- * @return mixed string|int Minimum price of the form
711
+ * @return string string|int Minimum price of the form
712 712
  */
713 713
 function give_get_form_minimum_price( $form_id = 0 ) {
714 714
 
Please login to merge, or discard this patch.
Spacing   +203 added lines, -203 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -23,14 +23,14 @@  discard block
 block discarded – undo
23 23
 
24 24
 	global $typenow;
25 25
 
26
-	if ( $typenow != 'give_forms' ) {
26
+	if ($typenow != 'give_forms') {
27 27
 		return true;
28 28
 	}
29 29
 
30 30
 	return false;
31 31
 }
32 32
 
33
-add_filter( 'give_shortcode_button_condition', 'give_shortcode_button_condition' );
33
+add_filter('give_shortcode_button_condition', 'give_shortcode_button_condition');
34 34
 
35 35
 
36 36
 /**
@@ -40,11 +40,11 @@  discard block
 block discarded – undo
40 40
  *
41 41
  * @return int|false
42 42
  */
43
-function get_form_id_from_args( $args ) {
43
+function get_form_id_from_args($args) {
44 44
 
45
-	if ( isset( $args['form_id'] ) && $args['form_id'] != 0 ) {
45
+	if (isset($args['form_id']) && $args['form_id'] != 0) {
46 46
 
47
-		return intval( $args['form_id'] );
47
+		return intval($args['form_id']);
48 48
 	}
49 49
 
50 50
 	return false;
@@ -59,23 +59,23 @@  discard block
 block discarded – undo
59 59
  *
60 60
  * @return bool
61 61
  */
62
-function give_is_float_labels_enabled( $args ) {
62
+function give_is_float_labels_enabled($args) {
63 63
 
64 64
 	$float_labels = '';
65 65
 
66
-	if ( ! empty( $args['float_labels'] ) ) {
66
+	if ( ! empty($args['float_labels'])) {
67 67
 		$float_labels = $args['float_labels'];
68 68
 	}
69 69
 
70
-	if ( empty( $float_labels ) ) {
71
-		$float_labels = give_get_meta( $args['form_id'], '_give_form_floating_labels', true );
70
+	if (empty($float_labels)) {
71
+		$float_labels = give_get_meta($args['form_id'], '_give_form_floating_labels', true);
72 72
 	}
73 73
 
74
-	if ( empty( $float_labels ) || ( 'global' === $float_labels ) ) {
75
-		$float_labels = give_get_option( 'floatlabels', 'disabled' );
74
+	if (empty($float_labels) || ('global' === $float_labels)) {
75
+		$float_labels = give_get_option('floatlabels', 'disabled');
76 76
 	}
77 77
 
78
-	return give_is_setting_enabled( $float_labels );
78
+	return give_is_setting_enabled($float_labels);
79 79
 }
80 80
 
81 81
 /**
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 
92 92
 	$can_checkout = true;
93 93
 
94
-	return (bool) apply_filters( 'give_can_checkout', $can_checkout );
94
+	return (bool) apply_filters('give_can_checkout', $can_checkout);
95 95
 }
96 96
 
97 97
 /**
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
 function give_get_success_page_uri() {
106 106
 	$give_options = give_get_settings();
107 107
 
108
-	$success_page = isset( $give_options['success_page'] ) ? get_permalink( absint( $give_options['success_page'] ) ) : get_bloginfo( 'url' );
108
+	$success_page = isset($give_options['success_page']) ? get_permalink(absint($give_options['success_page'])) : get_bloginfo('url');
109 109
 
110
-	return apply_filters( 'give_get_success_page_uri', $success_page );
110
+	return apply_filters('give_get_success_page_uri', $success_page);
111 111
 }
112 112
 
113 113
 /**
@@ -119,9 +119,9 @@  discard block
 block discarded – undo
119 119
  */
120 120
 function give_is_success_page() {
121 121
 	$give_options    = give_get_settings();
122
-	$is_success_page = isset( $give_options['success_page'] ) ? is_page( $give_options['success_page'] ) : false;
122
+	$is_success_page = isset($give_options['success_page']) ? is_page($give_options['success_page']) : false;
123 123
 
124
-	return apply_filters( 'give_is_success_page', $is_success_page );
124
+	return apply_filters('give_is_success_page', $is_success_page);
125 125
 }
126 126
 
127 127
 /**
@@ -135,17 +135,17 @@  discard block
 block discarded – undo
135 135
  * @since       1.0
136 136
  * @return      void
137 137
  */
138
-function give_send_to_success_page( $query_string = null ) {
138
+function give_send_to_success_page($query_string = null) {
139 139
 
140 140
 	$redirect = give_get_success_page_uri();
141 141
 
142
-	if ( $query_string ) {
142
+	if ($query_string) {
143 143
 		$redirect .= $query_string;
144 144
 	}
145 145
 
146
-	$gateway = isset( $_REQUEST['give-gateway'] ) ? $_REQUEST['give-gateway'] : '';
146
+	$gateway = isset($_REQUEST['give-gateway']) ? $_REQUEST['give-gateway'] : '';
147 147
 
148
-	wp_redirect( apply_filters( 'give_success_page_redirect', $redirect, $gateway, $query_string ) );
148
+	wp_redirect(apply_filters('give_success_page_redirect', $redirect, $gateway, $query_string));
149 149
 	give_die();
150 150
 }
151 151
 
@@ -161,19 +161,19 @@  discard block
 block discarded – undo
161 161
  * @since  1.0
162 162
  * @return Void
163 163
  */
164
-function give_send_back_to_checkout( $args = array() ) {
164
+function give_send_back_to_checkout($args = array()) {
165 165
 
166
-	$url     = isset( $_POST['give-current-url'] ) ? sanitize_text_field( $_POST['give-current-url'] ) : '';
166
+	$url     = isset($_POST['give-current-url']) ? sanitize_text_field($_POST['give-current-url']) : '';
167 167
 	$form_id = 0;
168 168
 
169 169
 	// Set the form_id.
170
-	if ( isset( $_POST['give-form-id'] ) ) {
171
-		$form_id = sanitize_text_field( $_POST['give-form-id'] );
170
+	if (isset($_POST['give-form-id'])) {
171
+		$form_id = sanitize_text_field($_POST['give-form-id']);
172 172
 	}
173 173
 
174 174
 	// Need a URL to continue. If none, redirect back to single form.
175
-	if ( empty( $url ) ) {
176
-		wp_safe_redirect( get_permalink( $form_id ) );
175
+	if (empty($url)) {
176
+		wp_safe_redirect(get_permalink($form_id));
177 177
 		give_die();
178 178
 	}
179 179
 
@@ -182,41 +182,41 @@  discard block
 block discarded – undo
182 182
 	);
183 183
 
184 184
 	// Set the $level_id.
185
-	if ( isset( $_POST['give-price-id'] ) ) {
186
-		$defaults['level-id'] = sanitize_text_field( $_POST['give-price-id'] );
185
+	if (isset($_POST['give-price-id'])) {
186
+		$defaults['level-id'] = sanitize_text_field($_POST['give-price-id']);
187 187
 	}
188 188
 
189 189
 	// Check for backward compatibility.
190
-	if ( is_string( $args ) ) {
191
-		$args = str_replace( '?', '', $args );
190
+	if (is_string($args)) {
191
+		$args = str_replace('?', '', $args);
192 192
 	}
193 193
 
194
-	$args = wp_parse_args( $args, $defaults );
194
+	$args = wp_parse_args($args, $defaults);
195 195
 
196 196
 	// Merge URL query with $args to maintain third-party URL parameters after redirect.
197
-	$url_data = wp_parse_url( $url );
197
+	$url_data = wp_parse_url($url);
198 198
 
199 199
 	// Check if an array to prevent notices before parsing.
200
-	if ( isset( $url_data['query'] ) && ! empty( $url_data['query'] ) ) {
201
-		parse_str( $url_data['query'], $query );
200
+	if (isset($url_data['query']) && ! empty($url_data['query'])) {
201
+		parse_str($url_data['query'], $query);
202 202
 
203 203
 		// Precaution: don't allow any CC info.
204
-		unset( $query['card_number'] );
205
-		unset( $query['card_cvc'] );
204
+		unset($query['card_number']);
205
+		unset($query['card_cvc']);
206 206
 
207 207
 	} else {
208 208
 		// No $url_data so pass empty array.
209 209
 		$query = array();
210 210
 	}
211 211
 
212
-	$new_query        = array_merge( $args, $query );
213
-	$new_query_string = http_build_query( $new_query );
212
+	$new_query        = array_merge($args, $query);
213
+	$new_query_string = http_build_query($new_query);
214 214
 
215 215
 	// Assemble URL parts.
216
-	$redirect = home_url( '/' . $url_data['path'] . '?' . $new_query_string . '#give-form-' . $form_id . '-wrap' );
216
+	$redirect = home_url('/'.$url_data['path'].'?'.$new_query_string.'#give-form-'.$form_id.'-wrap');
217 217
 
218 218
 	// Redirect them.
219
-	wp_safe_redirect( apply_filters( 'give_send_back_to_checkout', $redirect, $args ) );
219
+	wp_safe_redirect(apply_filters('give_send_back_to_checkout', $redirect, $args));
220 220
 	give_die();
221 221
 
222 222
 }
@@ -232,16 +232,16 @@  discard block
 block discarded – undo
232 232
  * @since       1.0
233 233
  * @return      string
234 234
  */
235
-function give_get_success_page_url( $query_string = null ) {
235
+function give_get_success_page_url($query_string = null) {
236 236
 
237
-	$success_page = give_get_option( 'success_page', 0 );
238
-	$success_page = get_permalink( $success_page );
237
+	$success_page = give_get_option('success_page', 0);
238
+	$success_page = get_permalink($success_page);
239 239
 
240
-	if ( $query_string ) {
240
+	if ($query_string) {
241 241
 		$success_page .= $query_string;
242 242
 	}
243 243
 
244
-	return apply_filters( 'give_success_page_url', $success_page );
244
+	return apply_filters('give_success_page_url', $success_page);
245 245
 
246 246
 }
247 247
 
@@ -254,15 +254,15 @@  discard block
 block discarded – undo
254 254
  *
255 255
  * @return mixed Full URL to the Failed Donation Page, if present, home page if it doesn't exist.
256 256
  */
257
-function give_get_failed_transaction_uri( $extras = false ) {
257
+function give_get_failed_transaction_uri($extras = false) {
258 258
 	$give_options = give_get_settings();
259 259
 
260
-	$uri = ! empty( $give_options['failure_page'] ) ? trailingslashit( get_permalink( $give_options['failure_page'] ) ) : home_url();
261
-	if ( $extras ) {
260
+	$uri = ! empty($give_options['failure_page']) ? trailingslashit(get_permalink($give_options['failure_page'])) : home_url();
261
+	if ($extras) {
262 262
 		$uri .= $extras;
263 263
 	}
264 264
 
265
-	return apply_filters( 'give_get_failed_transaction_uri', $uri );
265
+	return apply_filters('give_get_failed_transaction_uri', $uri);
266 266
 }
267 267
 
268 268
 /**
@@ -273,9 +273,9 @@  discard block
 block discarded – undo
273 273
  */
274 274
 function give_is_failed_transaction_page() {
275 275
 	$give_options = give_get_settings();
276
-	$ret          = isset( $give_options['failure_page'] ) ? is_page( $give_options['failure_page'] ) : false;
276
+	$ret          = isset($give_options['failure_page']) ? is_page($give_options['failure_page']) : false;
277 277
 
278
-	return apply_filters( 'give_is_failure_page', $ret );
278
+	return apply_filters('give_is_failure_page', $ret);
279 279
 }
280 280
 
281 281
 /**
@@ -287,18 +287,18 @@  discard block
 block discarded – undo
287 287
  */
288 288
 function give_listen_for_failed_payments() {
289 289
 
290
-	$failed_page = give_get_option( 'failure_page', 0 );
290
+	$failed_page = give_get_option('failure_page', 0);
291 291
 
292
-	if ( ! empty( $failed_page ) && is_page( $failed_page ) && ! empty( $_GET['payment-id'] ) ) {
292
+	if ( ! empty($failed_page) && is_page($failed_page) && ! empty($_GET['payment-id'])) {
293 293
 
294
-		$payment_id = absint( $_GET['payment-id'] );
295
-		give_update_payment_status( $payment_id, 'failed' );
294
+		$payment_id = absint($_GET['payment-id']);
295
+		give_update_payment_status($payment_id, 'failed');
296 296
 
297 297
 	}
298 298
 
299 299
 }
300 300
 
301
-add_action( 'template_redirect', 'give_listen_for_failed_payments' );
301
+add_action('template_redirect', 'give_listen_for_failed_payments');
302 302
 
303 303
 /**
304 304
  * Retrieve the Donation History page URI
@@ -311,9 +311,9 @@  discard block
 block discarded – undo
311 311
 function give_get_history_page_uri() {
312 312
 	$give_options = give_get_settings();
313 313
 
314
-	$history_page = isset( $give_options['history_page'] ) ? get_permalink( absint( $give_options['history_page'] ) ) : get_bloginfo( 'url' );
314
+	$history_page = isset($give_options['history_page']) ? get_permalink(absint($give_options['history_page'])) : get_bloginfo('url');
315 315
 
316
-	return apply_filters( 'give_get_history_page_uri', $history_page );
316
+	return apply_filters('give_get_history_page_uri', $history_page);
317 317
 }
318 318
 
319 319
 /**
@@ -326,11 +326,11 @@  discard block
 block discarded – undo
326 326
  * @since       1.0
327 327
  * @return      bool
328 328
  */
329
-function give_field_is_required( $field = '', $form_id ) {
329
+function give_field_is_required($field = '', $form_id) {
330 330
 
331
-	$required_fields = give_get_required_fields( $form_id );
331
+	$required_fields = give_get_required_fields($form_id);
332 332
 
333
-	return array_key_exists( $field, $required_fields );
333
+	return array_key_exists($field, $required_fields);
334 334
 }
335 335
 
336 336
 /**
@@ -348,14 +348,14 @@  discard block
 block discarded – undo
348 348
  *
349 349
  * @return void
350 350
  */
351
-function give_record_donation_in_log( $give_form_id = 0, $payment_id, $price_id = false, $donation_date = null ) {
351
+function give_record_donation_in_log($give_form_id = 0, $payment_id, $price_id = false, $donation_date = null) {
352 352
 	global $give_logs;
353 353
 
354 354
 	$log_data = array(
355 355
 		'post_parent'   => $give_form_id,
356 356
 		'log_type'      => 'sale',
357
-		'post_date'     => isset( $donation_date ) ? $donation_date : null,
358
-		'post_date_gmt' => isset( $donation_date ) ? $donation_date : null,
357
+		'post_date'     => isset($donation_date) ? $donation_date : null,
358
+		'post_date_gmt' => isset($donation_date) ? $donation_date : null,
359 359
 	);
360 360
 
361 361
 	$log_meta = array(
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 		'price_id'   => (int) $price_id,
364 364
 	);
365 365
 
366
-	$give_logs->insert_log( $log_data, $log_meta );
366
+	$give_logs->insert_log($log_data, $log_meta);
367 367
 }
368 368
 
369 369
 
@@ -377,11 +377,11 @@  discard block
 block discarded – undo
377 377
  *
378 378
  * @return bool|int
379 379
  */
380
-function give_increase_donation_count( $form_id = 0, $quantity = 1 ) {
380
+function give_increase_donation_count($form_id = 0, $quantity = 1) {
381 381
 	$quantity = (int) $quantity;
382
-	$form     = new Give_Donate_Form( $form_id );
382
+	$form     = new Give_Donate_Form($form_id);
383 383
 
384
-	return $form->increase_sales( $quantity );
384
+	return $form->increase_sales($quantity);
385 385
 }
386 386
 
387 387
 /**
@@ -394,11 +394,11 @@  discard block
 block discarded – undo
394 394
  *
395 395
  * @return bool|int
396 396
  */
397
-function give_decrease_donation_count( $form_id = 0, $quantity = 1 ) {
397
+function give_decrease_donation_count($form_id = 0, $quantity = 1) {
398 398
 	$quantity = (int) $quantity;
399
-	$form     = new Give_Donate_Form( $form_id );
399
+	$form     = new Give_Donate_Form($form_id);
400 400
 
401
-	return $form->decrease_sales( $quantity );
401
+	return $form->decrease_sales($quantity);
402 402
 }
403 403
 
404 404
 /**
@@ -411,10 +411,10 @@  discard block
 block discarded – undo
411 411
  *
412 412
  * @return bool|int
413 413
  */
414
-function give_increase_earnings( $give_form_id = 0, $amount ) {
415
-	$form = new Give_Donate_Form( $give_form_id );
414
+function give_increase_earnings($give_form_id = 0, $amount) {
415
+	$form = new Give_Donate_Form($give_form_id);
416 416
 
417
-	return $form->increase_earnings( $amount );
417
+	return $form->increase_earnings($amount);
418 418
 }
419 419
 
420 420
 /**
@@ -427,10 +427,10 @@  discard block
 block discarded – undo
427 427
  *
428 428
  * @return bool|int
429 429
  */
430
-function give_decrease_earnings( $form_id = 0, $amount ) {
431
-	$form = new Give_Donate_Form( $form_id );
430
+function give_decrease_earnings($form_id = 0, $amount) {
431
+	$form = new Give_Donate_Form($form_id);
432 432
 
433
-	return $form->decrease_earnings( $amount );
433
+	return $form->decrease_earnings($amount);
434 434
 }
435 435
 
436 436
 
@@ -443,8 +443,8 @@  discard block
 block discarded – undo
443 443
  *
444 444
  * @return int $earnings Earnings for a certain form
445 445
  */
446
-function give_get_form_earnings_stats( $form_id = 0 ) {
447
-	$give_form = new Give_Donate_Form( $form_id );
446
+function give_get_form_earnings_stats($form_id = 0) {
447
+	$give_form = new Give_Donate_Form($form_id);
448 448
 
449 449
 	return $give_form->earnings;
450 450
 }
@@ -459,8 +459,8 @@  discard block
 block discarded – undo
459 459
  *
460 460
  * @return int $sales Amount of sales for a certain form
461 461
  */
462
-function give_get_form_sales_stats( $give_form_id = 0 ) {
463
-	$give_form = new Give_Donate_Form( $give_form_id );
462
+function give_get_form_sales_stats($give_form_id = 0) {
463
+	$give_form = new Give_Donate_Form($give_form_id);
464 464
 
465 465
 	return $give_form->sales;
466 466
 }
@@ -475,16 +475,16 @@  discard block
 block discarded – undo
475 475
  *
476 476
  * @return float $sales Average monthly sales
477 477
  */
478
-function give_get_average_monthly_form_sales( $form_id = 0 ) {
479
-	$sales        = give_get_form_sales_stats( $form_id );
480
-	$release_date = get_post_field( 'post_date', $form_id );
478
+function give_get_average_monthly_form_sales($form_id = 0) {
479
+	$sales        = give_get_form_sales_stats($form_id);
480
+	$release_date = get_post_field('post_date', $form_id);
481 481
 
482
-	$diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) );
482
+	$diff = abs(current_time('timestamp') - strtotime($release_date));
483 483
 
484
-	$months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication
484
+	$months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication
485 485
 
486
-	if ( $months > 0 ) {
487
-		$sales = ( $sales / $months );
486
+	if ($months > 0) {
487
+		$sales = ($sales / $months);
488 488
 	}
489 489
 
490 490
 	return $sales;
@@ -500,16 +500,16 @@  discard block
 block discarded – undo
500 500
  *
501 501
  * @return float $earnings Average monthly earnings
502 502
  */
503
-function give_get_average_monthly_form_earnings( $form_id = 0 ) {
504
-	$earnings     = give_get_form_earnings_stats( $form_id );
505
-	$release_date = get_post_field( 'post_date', $form_id );
503
+function give_get_average_monthly_form_earnings($form_id = 0) {
504
+	$earnings     = give_get_form_earnings_stats($form_id);
505
+	$release_date = get_post_field('post_date', $form_id);
506 506
 
507
-	$diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) );
507
+	$diff = abs(current_time('timestamp') - strtotime($release_date));
508 508
 
509
-	$months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication
509
+	$months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication
510 510
 
511
-	if ( $months > 0 ) {
512
-		$earnings = ( $earnings / $months );
511
+	if ($months > 0) {
512
+		$earnings = ($earnings / $months);
513 513
 	}
514 514
 
515 515
 	return $earnings < 0 ? 0 : $earnings;
@@ -529,23 +529,23 @@  discard block
 block discarded – undo
529 529
  *
530 530
  * @return string $price_name Name of the price option
531 531
  */
532
-function give_get_price_option_name( $form_id = 0, $price_id = 0, $payment_id = 0 ) {
532
+function give_get_price_option_name($form_id = 0, $price_id = 0, $payment_id = 0) {
533 533
 
534
-	$prices     = give_get_variable_prices( $form_id );
534
+	$prices     = give_get_variable_prices($form_id);
535 535
 	$price_name = '';
536 536
 
537
-	foreach ( $prices as $price ) {
537
+	foreach ($prices as $price) {
538 538
 
539
-		if ( intval( $price['_give_id']['level_id'] ) == intval( $price_id ) ) {
539
+		if (intval($price['_give_id']['level_id']) == intval($price_id)) {
540 540
 
541
-			$price_text     = isset( $price['_give_text'] ) ? $price['_give_text'] : '';
542
-			$price_fallback = give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ), '', true );
543
-			$price_name     = ! empty( $price_text ) ? $price_text : $price_fallback;
541
+			$price_text     = isset($price['_give_text']) ? $price['_give_text'] : '';
542
+			$price_fallback = give_currency_filter(give_format_amount($price['_give_amount'], array('sanitize' => false)), '', true);
543
+			$price_name     = ! empty($price_text) ? $price_text : $price_fallback;
544 544
 
545 545
 		}
546 546
 	}
547 547
 
548
-	return apply_filters( 'give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id );
548
+	return apply_filters('give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id);
549 549
 }
550 550
 
551 551
 
@@ -558,23 +558,23 @@  discard block
 block discarded – undo
558 558
  *
559 559
  * @return string $range A fully formatted price range
560 560
  */
561
-function give_price_range( $form_id = 0 ) {
562
-	$low        = give_get_lowest_price_option( $form_id );
563
-	$high       = give_get_highest_price_option( $form_id );
564
-	$order_type = ! empty( $_REQUEST['order'] ) ? $_REQUEST['order'] : 'asc';
561
+function give_price_range($form_id = 0) {
562
+	$low        = give_get_lowest_price_option($form_id);
563
+	$high       = give_get_highest_price_option($form_id);
564
+	$order_type = ! empty($_REQUEST['order']) ? $_REQUEST['order'] : 'asc';
565 565
 
566 566
 	$range = sprintf(
567 567
 		'<span class="give_price_range_%1$s">%2$s</span>
568 568
 				<span class="give_price_range_sep">&nbsp;&ndash;&nbsp;</span>
569 569
 				<span class="give_price_range_%3$s">%4$s</span>',
570 570
 		'asc' === $order_type ? 'low' : 'high',
571
-		'asc' === $order_type ? give_currency_filter( give_format_amount( $low, array( 'sanitize' => false ) ) ) : give_currency_filter( give_format_amount( $high, array( 'sanitize' => false ) ) ),
571
+		'asc' === $order_type ? give_currency_filter(give_format_amount($low, array('sanitize' => false))) : give_currency_filter(give_format_amount($high, array('sanitize' => false))),
572 572
 		'asc' === $order_type ? 'high' : 'low',
573
-		'asc' === $order_type ? give_currency_filter( give_format_amount( $high, array( 'sanitize' => false ) ) ) : give_currency_filter( give_format_amount( $low, array( 'sanitize' => false ) ) )
573
+		'asc' === $order_type ? give_currency_filter(give_format_amount($high, array('sanitize' => false))) : give_currency_filter(give_format_amount($low, array('sanitize' => false)))
574 574
 
575 575
 	);
576 576
 
577
-	return apply_filters( 'give_price_range', $range, $form_id, $low, $high );
577
+	return apply_filters('give_price_range', $range, $form_id, $low, $high);
578 578
 }
579 579
 
580 580
 
@@ -589,35 +589,35 @@  discard block
 block discarded – undo
589 589
  *
590 590
  * @return int ID of the lowest price
591 591
  */
592
-function give_get_lowest_price_id( $form_id = 0 ) {
592
+function give_get_lowest_price_id($form_id = 0) {
593 593
 
594
-	if ( empty( $form_id ) ) {
594
+	if (empty($form_id)) {
595 595
 		$form_id = get_the_ID();
596 596
 	}
597 597
 
598
-	if ( ! give_has_variable_prices( $form_id ) ) {
599
-		return give_get_form_price( $form_id );
598
+	if ( ! give_has_variable_prices($form_id)) {
599
+		return give_get_form_price($form_id);
600 600
 	}
601 601
 
602
-	$prices = give_get_variable_prices( $form_id );
602
+	$prices = give_get_variable_prices($form_id);
603 603
 
604 604
 	$min = $min_id = 0;
605 605
 
606
-	if ( ! empty( $prices ) ) {
606
+	if ( ! empty($prices)) {
607 607
 
608
-		foreach ( $prices as $key => $price ) {
608
+		foreach ($prices as $key => $price) {
609 609
 
610
-			if ( empty( $price['_give_amount'] ) ) {
610
+			if (empty($price['_give_amount'])) {
611 611
 				continue;
612 612
 			}
613 613
 
614
-			if ( ! isset( $min ) ) {
614
+			if ( ! isset($min)) {
615 615
 				$min = $price['_give_amount'];
616 616
 			} else {
617
-				$min = min( $min, $price['_give_amount'] );
617
+				$min = min($min, $price['_give_amount']);
618 618
 			}
619 619
 
620
-			if ( $price['_give_amount'] == $min ) {
620
+			if ($price['_give_amount'] == $min) {
621 621
 				$min_id = $price['_give_id']['level_id'];
622 622
 			}
623 623
 		}
@@ -635,22 +635,22 @@  discard block
 block discarded – undo
635 635
  *
636 636
  * @return float Amount of the lowest price
637 637
  */
638
-function give_get_lowest_price_option( $form_id = 0 ) {
639
-	if ( empty( $form_id ) ) {
638
+function give_get_lowest_price_option($form_id = 0) {
639
+	if (empty($form_id)) {
640 640
 		$form_id = get_the_ID();
641 641
 	}
642 642
 
643
-	if ( ! give_has_variable_prices( $form_id ) ) {
644
-		return give_get_form_price( $form_id );
643
+	if ( ! give_has_variable_prices($form_id)) {
644
+		return give_get_form_price($form_id);
645 645
 	}
646 646
 
647
-	if ( ! ( $low = get_post_meta( $form_id, '_give_levels_minimum_amount', true ) ) ) {
647
+	if ( ! ($low = get_post_meta($form_id, '_give_levels_minimum_amount', true))) {
648 648
 		// Backward compatibility.
649
-		$prices = wp_list_pluck( give_get_variable_prices( $form_id ), '_give_amount' );
650
-		$low    = ! empty( $prices ) ? min( $prices ) : 0;
649
+		$prices = wp_list_pluck(give_get_variable_prices($form_id), '_give_amount');
650
+		$low    = ! empty($prices) ? min($prices) : 0;
651 651
 	}
652 652
 
653
-	return give_maybe_sanitize_amount( $low );
653
+	return give_maybe_sanitize_amount($low);
654 654
 }
655 655
 
656 656
 /**
@@ -662,23 +662,23 @@  discard block
 block discarded – undo
662 662
  *
663 663
  * @return float Amount of the highest price
664 664
  */
665
-function give_get_highest_price_option( $form_id = 0 ) {
665
+function give_get_highest_price_option($form_id = 0) {
666 666
 
667
-	if ( empty( $form_id ) ) {
667
+	if (empty($form_id)) {
668 668
 		$form_id = get_the_ID();
669 669
 	}
670 670
 
671
-	if ( ! give_has_variable_prices( $form_id ) ) {
672
-		return give_get_form_price( $form_id );
671
+	if ( ! give_has_variable_prices($form_id)) {
672
+		return give_get_form_price($form_id);
673 673
 	}
674 674
 
675
-	if ( ! ( $high = get_post_meta( $form_id, '_give_levels_maximum_amount', true ) ) ) {
675
+	if ( ! ($high = get_post_meta($form_id, '_give_levels_maximum_amount', true))) {
676 676
 		// Backward compatibility.
677
-		$prices = wp_list_pluck( give_get_variable_prices( $form_id ), '_give_amount' );
678
-		$high   = ! empty( $prices ) ? max( $prices ) : 0;
677
+		$prices = wp_list_pluck(give_get_variable_prices($form_id), '_give_amount');
678
+		$high   = ! empty($prices) ? max($prices) : 0;
679 679
 	}
680 680
 
681
-	return give_maybe_sanitize_amount( $high );
681
+	return give_maybe_sanitize_amount($high);
682 682
 }
683 683
 
684 684
 /**
@@ -690,15 +690,15 @@  discard block
 block discarded – undo
690 690
  *
691 691
  * @return mixed string|int Price of the form
692 692
  */
693
-function give_get_form_price( $form_id = 0 ) {
693
+function give_get_form_price($form_id = 0) {
694 694
 
695
-	if ( empty( $form_id ) ) {
695
+	if (empty($form_id)) {
696 696
 		return false;
697 697
 	}
698 698
 
699
-	$form = new Give_Donate_Form( $form_id );
699
+	$form = new Give_Donate_Form($form_id);
700 700
 
701
-	return $form->__get( 'price' );
701
+	return $form->__get('price');
702 702
 }
703 703
 
704 704
 /**
@@ -710,15 +710,15 @@  discard block
 block discarded – undo
710 710
  *
711 711
  * @return mixed string|int Minimum price of the form
712 712
  */
713
-function give_get_form_minimum_price( $form_id = 0 ) {
713
+function give_get_form_minimum_price($form_id = 0) {
714 714
 
715
-	if ( empty( $form_id ) ) {
715
+	if (empty($form_id)) {
716 716
 		return false;
717 717
 	}
718 718
 
719
-	$form = new Give_Donate_Form( $form_id );
719
+	$form = new Give_Donate_Form($form_id);
720 720
 
721
-	return $form->__get( 'minimum_price' );
721
+	return $form->__get('minimum_price');
722 722
 
723 723
 }
724 724
 
@@ -733,48 +733,48 @@  discard block
 block discarded – undo
733 733
  *
734 734
  * @return int $formatted_price
735 735
  */
736
-function give_price( $form_id = 0, $echo = true, $price_id = false ) {
736
+function give_price($form_id = 0, $echo = true, $price_id = false) {
737 737
 	$price = 0;
738 738
 
739
-	if ( empty( $form_id ) ) {
739
+	if (empty($form_id)) {
740 740
 		$form_id = get_the_ID();
741 741
 	}
742 742
 
743
-	if ( give_has_variable_prices( $form_id ) ) {
743
+	if (give_has_variable_prices($form_id)) {
744 744
 
745
-		$prices = give_get_variable_prices( $form_id );
745
+		$prices = give_get_variable_prices($form_id);
746 746
 
747
-		if ( false !== $price_id ) {
747
+		if (false !== $price_id) {
748 748
 
749 749
 			// loop through multi-prices to see which is default
750
-			foreach ( $prices as $price ) {
750
+			foreach ($prices as $price) {
751 751
 				// this is the default price
752
-				if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) {
752
+				if (isset($price['_give_default']) && $price['_give_default'] === 'default') {
753 753
 					$price = (float) $price['_give_amount'];
754 754
 				};
755 755
 			}
756 756
 		} else {
757 757
 
758
-			$price = give_get_lowest_price_option( $form_id );
758
+			$price = give_get_lowest_price_option($form_id);
759 759
 		}
760 760
 	} else {
761 761
 
762
-		$price = give_get_form_price( $form_id );
762
+		$price = give_get_form_price($form_id);
763 763
 	}
764 764
 
765
-	$price           = apply_filters( 'give_form_price', give_maybe_sanitize_amount( $price ), $form_id );
766
-	$formatted_price = '<span class="give_price" id="give_price_' . $form_id . '">' . $price . '</span>';
767
-	$formatted_price = apply_filters( 'give_form_price_after_html', $formatted_price, $form_id, $price );
765
+	$price           = apply_filters('give_form_price', give_maybe_sanitize_amount($price), $form_id);
766
+	$formatted_price = '<span class="give_price" id="give_price_'.$form_id.'">'.$price.'</span>';
767
+	$formatted_price = apply_filters('give_form_price_after_html', $formatted_price, $form_id, $price);
768 768
 
769
-	if ( $echo ) {
769
+	if ($echo) {
770 770
 		echo $formatted_price;
771 771
 	} else {
772 772
 		return $formatted_price;
773 773
 	}
774 774
 }
775 775
 
776
-add_filter( 'give_form_price', 'give_format_amount', 10 );
777
-add_filter( 'give_form_price', 'give_currency_filter', 20 );
776
+add_filter('give_form_price', 'give_format_amount', 10);
777
+add_filter('give_form_price', 'give_currency_filter', 20);
778 778
 
779 779
 
780 780
 /**
@@ -787,19 +787,19 @@  discard block
 block discarded – undo
787 787
  *
788 788
  * @return float $amount Amount of the price option
789 789
  */
790
-function give_get_price_option_amount( $form_id = 0, $price_id = 0 ) {
791
-	$prices = give_get_variable_prices( $form_id );
790
+function give_get_price_option_amount($form_id = 0, $price_id = 0) {
791
+	$prices = give_get_variable_prices($form_id);
792 792
 
793 793
 	$amount = 0.00;
794 794
 
795
-	foreach ( $prices as $price ) {
796
-		if ( isset( $price['_give_id']['level_id'] ) && $price['_give_id']['level_id'] == $price_id ) {
797
-			$amount = isset( $price['_give_amount'] ) ? $price['_give_amount'] : 0.00;
795
+	foreach ($prices as $price) {
796
+		if (isset($price['_give_id']['level_id']) && $price['_give_id']['level_id'] == $price_id) {
797
+			$amount = isset($price['_give_amount']) ? $price['_give_amount'] : 0.00;
798 798
 			break;
799 799
 		};
800 800
 	}
801 801
 
802
-	return apply_filters( 'give_get_price_option_amount', give_maybe_sanitize_amount( $amount ), $form_id, $price_id );
802
+	return apply_filters('give_get_price_option_amount', give_maybe_sanitize_amount($amount), $form_id, $price_id);
803 803
 }
804 804
 
805 805
 /**
@@ -811,13 +811,13 @@  discard block
 block discarded – undo
811 811
  *
812 812
  * @return mixed string|int Goal of the form
813 813
  */
814
-function give_get_form_goal( $form_id = 0 ) {
814
+function give_get_form_goal($form_id = 0) {
815 815
 
816
-	if ( empty( $form_id ) ) {
816
+	if (empty($form_id)) {
817 817
 		return false;
818 818
 	}
819 819
 
820
-	$form = new Give_Donate_Form( $form_id );
820
+	$form = new Give_Donate_Form($form_id);
821 821
 
822 822
 	return $form->goal;
823 823
 
@@ -833,27 +833,27 @@  discard block
 block discarded – undo
833 833
  *
834 834
  * @return string $formatted_goal
835 835
  */
836
-function give_goal( $form_id = 0, $echo = true ) {
836
+function give_goal($form_id = 0, $echo = true) {
837 837
 
838
-	if ( empty( $form_id ) ) {
838
+	if (empty($form_id)) {
839 839
 		$form_id = get_the_ID();
840 840
 	}
841 841
 
842
-	$goal = give_get_form_goal( $form_id );
842
+	$goal = give_get_form_goal($form_id);
843 843
 
844
-	$goal           = apply_filters( 'give_form_goal', give_maybe_sanitize_amount( $goal ), $form_id );
845
-	$formatted_goal = '<span class="give_price" id="give_price_' . $form_id . '">' . $goal . '</span>';
846
-	$formatted_goal = apply_filters( 'give_form_price_after_html', $formatted_goal, $form_id, $goal );
844
+	$goal           = apply_filters('give_form_goal', give_maybe_sanitize_amount($goal), $form_id);
845
+	$formatted_goal = '<span class="give_price" id="give_price_'.$form_id.'">'.$goal.'</span>';
846
+	$formatted_goal = apply_filters('give_form_price_after_html', $formatted_goal, $form_id, $goal);
847 847
 
848
-	if ( $echo ) {
848
+	if ($echo) {
849 849
 		echo $formatted_goal;
850 850
 	} else {
851 851
 		return $formatted_goal;
852 852
 	}
853 853
 }
854 854
 
855
-add_filter( 'give_form_goal', 'give_format_amount', 10 );
856
-add_filter( 'give_form_goal', 'give_currency_filter', 20 );
855
+add_filter('give_form_goal', 'give_format_amount', 10);
856
+add_filter('give_form_goal', 'give_currency_filter', 20);
857 857
 
858 858
 
859 859
 /**
@@ -865,15 +865,15 @@  discard block
 block discarded – undo
865 865
  *
866 866
  * @return bool  $ret Whether or not the logged_in_only setting is set
867 867
  */
868
-function give_logged_in_only( $form_id ) {
868
+function give_logged_in_only($form_id) {
869 869
 	// If _give_logged_in_only is set to enable then guest can donate from that specific form.
870 870
 	// Otherwise it is member only donation form.
871
-	$val = give_get_meta( $form_id, '_give_logged_in_only', true );
872
-	$val = ! empty( $val ) ? $val : 'enabled';
871
+	$val = give_get_meta($form_id, '_give_logged_in_only', true);
872
+	$val = ! empty($val) ? $val : 'enabled';
873 873
 
874
-	$ret = ! give_is_setting_enabled( $val );
874
+	$ret = ! give_is_setting_enabled($val);
875 875
 
876
-	return (bool) apply_filters( 'give_logged_in_only', $ret, $form_id );
876
+	return (bool) apply_filters('give_logged_in_only', $ret, $form_id);
877 877
 }
878 878
 
879 879
 
@@ -886,11 +886,11 @@  discard block
 block discarded – undo
886 886
  *
887 887
  * @return string
888 888
  */
889
-function give_show_login_register_option( $form_id ) {
889
+function give_show_login_register_option($form_id) {
890 890
 
891
-	$show_register_form = give_get_meta( $form_id, '_give_show_register_form', true );
891
+	$show_register_form = give_get_meta($form_id, '_give_show_register_form', true);
892 892
 
893
-	return apply_filters( 'give_show_register_form', $show_register_form, $form_id );
893
+	return apply_filters('give_show_register_form', $show_register_form, $form_id);
894 894
 
895 895
 }
896 896
 
@@ -906,12 +906,12 @@  discard block
 block discarded – undo
906 906
  *
907 907
  * @return array
908 908
  */
909
-function _give_get_prefill_form_field_values( $form_id ) {
909
+function _give_get_prefill_form_field_values($form_id) {
910 910
 	$logged_in_donor_info = array();
911 911
 
912
-	if ( is_user_logged_in() ) :
913
-		$donor_data    = get_userdata( get_current_user_id() );
914
-		$donor_address = get_user_meta( get_current_user_id(), '_give_user_address', true );
912
+	if (is_user_logged_in()) :
913
+		$donor_data    = get_userdata(get_current_user_id());
914
+		$donor_address = get_user_meta(get_current_user_id(), '_give_user_address', true);
915 915
 
916 916
 		$logged_in_donor_info = array(
917 917
 			// First name.
@@ -924,42 +924,42 @@  discard block
 block discarded – undo
924 924
 			'give_email'      => $donor_data->user_email,
925 925
 
926 926
 			// Street address 1.
927
-			'card_address'    => ( ! empty( $donor_address['line1'] ) ? $donor_address['line1'] : '' ),
927
+			'card_address'    => ( ! empty($donor_address['line1']) ? $donor_address['line1'] : ''),
928 928
 
929 929
 			// Street address 2.
930
-			'card_address_2'  => ( ! empty( $donor_address['line2'] ) ? $donor_address['line2'] : '' ),
930
+			'card_address_2'  => ( ! empty($donor_address['line2']) ? $donor_address['line2'] : ''),
931 931
 
932 932
 			// Country.
933
-			'billing_country' => ( ! empty( $donor_address['country'] ) ? $donor_address['country'] : '' ),
933
+			'billing_country' => ( ! empty($donor_address['country']) ? $donor_address['country'] : ''),
934 934
 
935 935
 			// State.
936
-			'card_state'      => ( ! empty( $donor_address['state'] ) ? $donor_address['state'] : '' ),
936
+			'card_state'      => ( ! empty($donor_address['state']) ? $donor_address['state'] : ''),
937 937
 
938 938
 			// City.
939
-			'card_city'       => ( ! empty( $donor_address['city'] ) ? $donor_address['city'] : '' ),
939
+			'card_city'       => ( ! empty($donor_address['city']) ? $donor_address['city'] : ''),
940 940
 
941 941
 			// Zipcode
942
-			'card_zip'        => ( ! empty( $donor_address['zip'] ) ? $donor_address['zip'] : '' ),
942
+			'card_zip'        => ( ! empty($donor_address['zip']) ? $donor_address['zip'] : ''),
943 943
 		);
944 944
 	endif;
945 945
 
946 946
 	// Bailout: Auto fill form field values only form form which donor is donating.
947 947
 	if (
948
-		empty( $_GET['form-id'] )
948
+		empty($_GET['form-id'])
949 949
 		|| ! $form_id
950
-		|| ( $form_id !== absint( $_GET['form-id'] ) )
950
+		|| ($form_id !== absint($_GET['form-id']))
951 951
 	) {
952 952
 		return $logged_in_donor_info;
953 953
 	}
954 954
 
955 955
 	// Get purchase data.
956
-	$give_purchase_data = Give()->session->get( 'give_purchase' );
956
+	$give_purchase_data = Give()->session->get('give_purchase');
957 957
 
958 958
 	// Get donor info from form data.
959
-	$give_donor_info_in_session = empty( $give_purchase_data['post_data'] )
959
+	$give_donor_info_in_session = empty($give_purchase_data['post_data'])
960 960
 		? array()
961 961
 		: $give_purchase_data['post_data'];
962 962
 
963 963
 	// Output.
964
-	return wp_parse_args( $give_donor_info_in_session, $logged_in_donor_info );
964
+	return wp_parse_args($give_donor_info_in_session, $logged_in_donor_info);
965 965
 }
Please login to merge, or discard this patch.
includes/scripts.php 1 patch
Spacing   +165 added lines, -165 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,26 +25,26 @@  discard block
 block discarded – undo
25 25
  */
26 26
 function give_load_scripts() {
27 27
 
28
-	$js_dir         = GIVE_PLUGIN_URL . 'assets/js/frontend/';
29
-	$js_plugins     = GIVE_PLUGIN_URL . 'assets/js/plugins/';
30
-	$scripts_footer = ( give_is_setting_enabled( give_get_option( 'scripts_footer' ) ) ) ? true : false;
28
+	$js_dir         = GIVE_PLUGIN_URL.'assets/js/frontend/';
29
+	$js_plugins     = GIVE_PLUGIN_URL.'assets/js/plugins/';
30
+	$scripts_footer = (give_is_setting_enabled(give_get_option('scripts_footer'))) ? true : false;
31 31
 
32 32
 	// Use minified libraries if SCRIPT_DEBUG is turned off.
33
-	$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
33
+	$suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
34 34
 
35 35
 	// Localize / PHP to AJAX vars.
36
-	$localize_give_vars = apply_filters( 'give_global_script_vars', array(
36
+	$localize_give_vars = apply_filters('give_global_script_vars', array(
37 37
 		'ajaxurl'             => give_get_ajax_url(),
38
-		'checkout_nonce'      => wp_create_nonce( 'give_checkout_nonce' ),
38
+		'checkout_nonce'      => wp_create_nonce('give_checkout_nonce'),
39 39
 		'currency'            => give_get_currency(),
40
-		'currency_sign'       => give_currency_filter( '' ),
40
+		'currency_sign'       => give_currency_filter(''),
41 41
 		'currency_pos'        => give_get_currency_position(),
42 42
 		'thousands_separator' => give_get_price_thousand_separator(),
43 43
 		'decimal_separator'   => give_get_price_decimal_separator(),
44
-		'no_gateway'          => __( 'Please select a payment method.', 'give' ),
45
-		'bad_minimum'         => __( 'The minimum custom donation amount for this form is', 'give' ),
46
-		'general_loading'     => __( 'Loading...', 'give' ),
47
-		'purchase_loading'    => __( 'Please Wait...', 'give' ),
44
+		'no_gateway'          => __('Please select a payment method.', 'give'),
45
+		'bad_minimum'         => __('The minimum custom donation amount for this form is', 'give'),
46
+		'general_loading'     => __('Loading...', 'give'),
47
+		'purchase_loading'    => __('Please Wait...', 'give'),
48 48
 		'number_decimals'     => give_get_price_decimals(),
49 49
 		'give_version'        => GIVE_VERSION,
50 50
 		'magnific_options'    => apply_filters(
@@ -58,81 +58,81 @@  discard block
 block discarded – undo
58 58
 			'give_form_translation_js',
59 59
 			array(
60 60
 				// Field name               Validation message.
61
-				'payment-mode'           => __( 'Please select payment mode.', 'give' ),
62
-				'give_first'             => __( 'Please enter your first name.', 'give' ),
63
-				'give_email'             => __( 'Please enter a valid email address.', 'give' ),
64
-				'give_user_login'        => __( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ),
65
-				'give_user_pass'         => __( 'Enter a password.', 'give' ),
66
-				'give_user_pass_confirm' => __( 'Enter the password confirmation.', 'give' ),
67
-				'give_agree_to_terms'    => __( 'You must agree to the terms and conditions.', 'give' ),
61
+				'payment-mode'           => __('Please select payment mode.', 'give'),
62
+				'give_first'             => __('Please enter your first name.', 'give'),
63
+				'give_email'             => __('Please enter a valid email address.', 'give'),
64
+				'give_user_login'        => __('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give'),
65
+				'give_user_pass'         => __('Enter a password.', 'give'),
66
+				'give_user_pass_confirm' => __('Enter the password confirmation.', 'give'),
67
+				'give_agree_to_terms'    => __('You must agree to the terms and conditions.', 'give'),
68 68
 			)
69 69
 		),
70
-	) );
70
+	));
71 71
 
72
-	$localize_give_ajax = apply_filters( 'give_global_ajax_vars', array(
72
+	$localize_give_ajax = apply_filters('give_global_ajax_vars', array(
73 73
 		'ajaxurl'         => give_get_ajax_url(),
74
-		'loading'         => __( 'Loading', 'give' ),
74
+		'loading'         => __('Loading', 'give'),
75 75
 		// General loading message.
76
-		'select_option'   => __( 'Please select an option', 'give' ),
76
+		'select_option'   => __('Please select an option', 'give'),
77 77
 		// Variable pricing error with multi-donation option enabled.
78
-		'default_gateway' => give_get_default_gateway( null ),
79
-		'permalinks'      => get_option( 'permalink_structure' ) ? '1' : '0',
78
+		'default_gateway' => give_get_default_gateway(null),
79
+		'permalinks'      => get_option('permalink_structure') ? '1' : '0',
80 80
 		'number_decimals' => give_get_price_decimals(),
81
-	) );
81
+	));
82 82
 
83 83
 	// DEBUG is On.
84
-	if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
84
+	if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) {
85 85
 
86
-		if ( give_is_cc_verify_enabled() ) {
87
-			wp_register_script( 'give-cc-validator', $js_plugins . 'jquery.payment' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
88
-			wp_enqueue_script( 'give-cc-validator' );
86
+		if (give_is_cc_verify_enabled()) {
87
+			wp_register_script('give-cc-validator', $js_plugins.'jquery.payment'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
88
+			wp_enqueue_script('give-cc-validator');
89 89
 		}
90 90
 
91
-		wp_register_script( 'give-float-labels', $js_plugins . 'float-labels' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
92
-		wp_enqueue_script( 'give-float-labels' );
91
+		wp_register_script('give-float-labels', $js_plugins.'float-labels'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
92
+		wp_enqueue_script('give-float-labels');
93 93
 
94
-		wp_register_script( 'give-blockui', $js_plugins . 'jquery.blockUI' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
95
-		wp_enqueue_script( 'give-blockui' );
94
+		wp_register_script('give-blockui', $js_plugins.'jquery.blockUI'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
95
+		wp_enqueue_script('give-blockui');
96 96
 
97
-		wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
98
-		wp_enqueue_script( 'give-qtip' );
97
+		wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
98
+		wp_enqueue_script('give-qtip');
99 99
 
100
-		wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
101
-		wp_enqueue_script( 'give-accounting' );
100
+		wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
101
+		wp_enqueue_script('give-accounting');
102 102
 
103
-		wp_register_script( 'give-magnific', $js_plugins . 'jquery.magnific-popup' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
104
-		wp_enqueue_script( 'give-magnific' );
103
+		wp_register_script('give-magnific', $js_plugins.'jquery.magnific-popup'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
104
+		wp_enqueue_script('give-magnific');
105 105
 
106
-		wp_register_script( 'give-checkout-global', $js_dir . 'give-checkout-global' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
107
-		wp_enqueue_script( 'give-checkout-global' );
106
+		wp_register_script('give-checkout-global', $js_dir.'give-checkout-global'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
107
+		wp_enqueue_script('give-checkout-global');
108 108
 
109 109
 		// General scripts.
110
-		wp_register_script( 'give-scripts', $js_dir . 'give' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
111
-		wp_enqueue_script( 'give-scripts' );
110
+		wp_register_script('give-scripts', $js_dir.'give'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
111
+		wp_enqueue_script('give-scripts');
112 112
 
113 113
 		// Load AJAX scripts, if enabled.
114
-		wp_register_script( 'give-ajax', $js_dir . 'give-ajax' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
115
-		wp_enqueue_script( 'give-ajax' );
114
+		wp_register_script('give-ajax', $js_dir.'give-ajax'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
115
+		wp_enqueue_script('give-ajax');
116 116
 
117 117
 		// Localize / Pass AJAX vars from PHP,
118
-		wp_localize_script( 'give-checkout-global', 'give_global_vars', $localize_give_vars );
119
-		wp_localize_script( 'give-ajax', 'give_scripts', $localize_give_ajax );
118
+		wp_localize_script('give-checkout-global', 'give_global_vars', $localize_give_vars);
119
+		wp_localize_script('give-ajax', 'give_scripts', $localize_give_ajax);
120 120
 
121 121
 	} else {
122 122
 
123 123
 		// DEBUG is OFF (one JS file to rule them all!).
124
-		wp_register_script( 'give', $js_dir . 'give.all.min.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
125
-		wp_enqueue_script( 'give' );
124
+		wp_register_script('give', $js_dir.'give.all.min.js', array('jquery'), GIVE_VERSION, $scripts_footer);
125
+		wp_enqueue_script('give');
126 126
 
127 127
 		// Localize / Pass AJAX vars from PHP.
128
-		wp_localize_script( 'give', 'give_global_vars', $localize_give_vars );
129
-		wp_localize_script( 'give', 'give_scripts', $localize_give_ajax );
128
+		wp_localize_script('give', 'give_global_vars', $localize_give_vars);
129
+		wp_localize_script('give', 'give_scripts', $localize_give_ajax);
130 130
 
131 131
 	}
132 132
 
133 133
 }
134 134
 
135
-add_action( 'wp_enqueue_scripts', 'give_load_scripts' );
135
+add_action('wp_enqueue_scripts', 'give_load_scripts');
136 136
 
137 137
 /**
138 138
  * Register styles.
@@ -145,16 +145,16 @@  discard block
 block discarded – undo
145 145
  */
146 146
 function give_register_styles() {
147 147
 
148
-	if ( ! give_is_setting_enabled( give_get_option( 'css' ) ) ) {
148
+	if ( ! give_is_setting_enabled(give_get_option('css'))) {
149 149
 		return;
150 150
 	}
151 151
 
152
-	wp_register_style( 'give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all' );
153
-	wp_enqueue_style( 'give-styles' );
152
+	wp_register_style('give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all');
153
+	wp_enqueue_style('give-styles');
154 154
 
155 155
 }
156 156
 
157
-add_action( 'wp_enqueue_scripts', 'give_register_styles' );
157
+add_action('wp_enqueue_scripts', 'give_register_styles');
158 158
 
159 159
 
160 160
 /**
@@ -167,19 +167,19 @@  discard block
 block discarded – undo
167 167
 function give_get_stylesheet_uri() {
168 168
 
169 169
 	// Use minified libraries if SCRIPT_DEBUG is turned off.
170
-	$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
170
+	$suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
171 171
 
172 172
 	// LTR or RTL files.
173
-	$direction = ( is_rtl() ) ? '-rtl' : '';
173
+	$direction = (is_rtl()) ? '-rtl' : '';
174 174
 
175
-	$file          = 'give' . $direction . $suffix . '.css';
175
+	$file          = 'give'.$direction.$suffix.'.css';
176 176
 	$templates_dir = give_get_theme_template_dir_name();
177 177
 
178
-	$child_theme_style_sheet    = trailingslashit( get_stylesheet_directory() ) . $templates_dir . $file;
179
-	$child_theme_style_sheet_2  = trailingslashit( get_stylesheet_directory() ) . $templates_dir . 'give' . $direction . '.css';
180
-	$parent_theme_style_sheet   = trailingslashit( get_template_directory() ) . $templates_dir . $file;
181
-	$parent_theme_style_sheet_2 = trailingslashit( get_template_directory() ) . $templates_dir . 'give' . $direction . '.css';
182
-	$give_plugin_style_sheet    = trailingslashit( give_get_templates_dir() ) . $file;
178
+	$child_theme_style_sheet    = trailingslashit(get_stylesheet_directory()).$templates_dir.$file;
179
+	$child_theme_style_sheet_2  = trailingslashit(get_stylesheet_directory()).$templates_dir.'give'.$direction.'.css';
180
+	$parent_theme_style_sheet   = trailingslashit(get_template_directory()).$templates_dir.$file;
181
+	$parent_theme_style_sheet_2 = trailingslashit(get_template_directory()).$templates_dir.'give'.$direction.'.css';
182
+	$give_plugin_style_sheet    = trailingslashit(give_get_templates_dir()).$file;
183 183
 
184 184
 	$uri = false;
185 185
 
@@ -189,23 +189,23 @@  discard block
 block discarded – undo
189 189
 	 * followed by non minified version, even if SCRIPT_DEBUG is not enabled.
190 190
 	 * This allows users to copy just give.css to their theme.
191 191
 	 */
192
-	if ( file_exists( $child_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $child_theme_style_sheet_2 ) ) ) ) {
193
-		if ( ! empty( $nonmin ) ) {
194
-			$uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . 'give' . $direction . '.css';
192
+	if (file_exists($child_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($child_theme_style_sheet_2)))) {
193
+		if ( ! empty($nonmin)) {
194
+			$uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.'give'.$direction.'.css';
195 195
 		} else {
196
-			$uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . $file;
196
+			$uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.$file;
197 197
 		}
198
-	} elseif ( file_exists( $parent_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $parent_theme_style_sheet_2 ) ) ) ) {
199
-		if ( ! empty( $nonmin ) ) {
200
-			$uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . 'give' . $direction . '.css';
198
+	} elseif (file_exists($parent_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($parent_theme_style_sheet_2)))) {
199
+		if ( ! empty($nonmin)) {
200
+			$uri = trailingslashit(get_template_directory_uri()).$templates_dir.'give'.$direction.'.css';
201 201
 		} else {
202
-			$uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . $file;
202
+			$uri = trailingslashit(get_template_directory_uri()).$templates_dir.$file;
203 203
 		}
204
-	} elseif ( file_exists( $give_plugin_style_sheet ) || file_exists( $give_plugin_style_sheet ) ) {
205
-		$uri = trailingslashit( give_get_templates_url() ) . $file;
204
+	} elseif (file_exists($give_plugin_style_sheet) || file_exists($give_plugin_style_sheet)) {
205
+		$uri = trailingslashit(give_get_templates_url()).$file;
206 206
 	}
207 207
 
208
-	return apply_filters( 'give_get_stylesheet_uri', $uri );
208
+	return apply_filters('give_get_stylesheet_uri', $uri);
209 209
 
210 210
 }
211 211
 
@@ -222,79 +222,79 @@  discard block
 block discarded – undo
222 222
  *
223 223
  * @return void
224 224
  */
225
-function give_load_admin_scripts( $hook ) {
225
+function give_load_admin_scripts($hook) {
226 226
 
227 227
 	global $post, $post_type;
228 228
 
229 229
 	$give_options = give_get_settings();
230 230
 
231 231
 	// Directories of assets.
232
-	$js_dir     = GIVE_PLUGIN_URL . 'assets/js/admin/';
233
-	$js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/';
234
-	$css_dir    = GIVE_PLUGIN_URL . 'assets/css/';
232
+	$js_dir     = GIVE_PLUGIN_URL.'assets/js/admin/';
233
+	$js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/';
234
+	$css_dir    = GIVE_PLUGIN_URL.'assets/css/';
235 235
 
236 236
 	// Use minified libraries if SCRIPT_DEBUG is turned off.
237
-	$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
237
+	$suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
238 238
 
239 239
 	// LTR or RTL files.
240
-	$direction = ( is_rtl() ) ? '-rtl' : '';
240
+	$direction = (is_rtl()) ? '-rtl' : '';
241 241
 
242 242
 	// Global Admin.
243
-	wp_register_style( 'give-admin-bar-notification', $css_dir . 'adminbar-style.css' );
244
-	wp_enqueue_style( 'give-admin-bar-notification' );
243
+	wp_register_style('give-admin-bar-notification', $css_dir.'adminbar-style.css');
244
+	wp_enqueue_style('give-admin-bar-notification');
245 245
 
246 246
 	// Give Admin Only.
247
-	if ( ! apply_filters( 'give_load_admin_scripts', give_is_admin_page(), $hook ) ) {
247
+	if ( ! apply_filters('give_load_admin_scripts', give_is_admin_page(), $hook)) {
248 248
 		return;
249 249
 	}
250 250
 
251 251
 	// CSS.
252
-	wp_register_style( 'jquery-ui-css', $css_dir . 'jquery-ui-fresh' . $suffix . '.css' );
253
-	wp_enqueue_style( 'jquery-ui-css' );
254
-	wp_register_style( 'give-admin', $css_dir . 'give-admin' . $direction . $suffix . '.css', array(), GIVE_VERSION );
255
-	wp_enqueue_style( 'give-admin' );
256
-	wp_register_style( 'jquery-chosen', $css_dir . 'chosen' . $suffix . '.css', array(), GIVE_VERSION );
257
-	wp_enqueue_style( 'jquery-chosen' );
258
-	wp_enqueue_style( 'thickbox' );
259
-	wp_enqueue_style( 'wp-color-picker' );
252
+	wp_register_style('jquery-ui-css', $css_dir.'jquery-ui-fresh'.$suffix.'.css');
253
+	wp_enqueue_style('jquery-ui-css');
254
+	wp_register_style('give-admin', $css_dir.'give-admin'.$direction.$suffix.'.css', array(), GIVE_VERSION);
255
+	wp_enqueue_style('give-admin');
256
+	wp_register_style('jquery-chosen', $css_dir.'chosen'.$suffix.'.css', array(), GIVE_VERSION);
257
+	wp_enqueue_style('jquery-chosen');
258
+	wp_enqueue_style('thickbox');
259
+	wp_enqueue_style('wp-color-picker');
260 260
 
261 261
 
262 262
 	// JS.
263
-	wp_register_script( 'give-selector-cache', $js_plugins . 'selector-cache' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
264
-	wp_enqueue_script( 'give-selector-cache' );
263
+	wp_register_script('give-selector-cache', $js_plugins.'selector-cache'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
264
+	wp_enqueue_script('give-selector-cache');
265 265
 
266
-	wp_register_script( 'jquery-chosen', $js_plugins . 'chosen.jquery' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION );
267
-	wp_enqueue_script( 'jquery-chosen' );
266
+	wp_register_script('jquery-chosen', $js_plugins.'chosen.jquery'.$suffix.'.js', array('jquery'), GIVE_VERSION);
267
+	wp_enqueue_script('jquery-chosen');
268 268
 
269
-	wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
270
-	wp_enqueue_script( 'give-accounting' );
269
+	wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
270
+	wp_enqueue_script('give-accounting');
271 271
 
272
-	wp_enqueue_script( 'wp-color-picker' );
273
-	wp_enqueue_script( 'jquery-ui-datepicker' );
274
-	wp_enqueue_script( 'thickbox' );
272
+	wp_enqueue_script('wp-color-picker');
273
+	wp_enqueue_script('jquery-ui-datepicker');
274
+	wp_enqueue_script('thickbox');
275 275
 
276
-	wp_register_script( 'give-admin-scripts', $js_dir . 'admin-scripts' . $suffix . '.js', array( 'jquery', 'jquery-ui-datepicker', 'wp-color-picker' ), GIVE_VERSION, false );
277
-	wp_enqueue_script( 'give-admin-scripts' );
276
+	wp_register_script('give-admin-scripts', $js_dir.'admin-scripts'.$suffix.'.js', array('jquery', 'jquery-ui-datepicker', 'wp-color-picker'), GIVE_VERSION, false);
277
+	wp_enqueue_script('give-admin-scripts');
278 278
 
279
-	wp_register_script( 'jquery-flot', $js_plugins . 'jquery.flot' . $suffix . '.js' );
280
-	wp_enqueue_script( 'jquery-flot' );
279
+	wp_register_script('jquery-flot', $js_plugins.'jquery.flot'.$suffix.'.js');
280
+	wp_enqueue_script('jquery-flot');
281 281
 
282
-	wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
283
-	wp_enqueue_script( 'give-qtip' );
282
+	wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
283
+	wp_enqueue_script('give-qtip');
284 284
 
285
-	wp_register_script( 'give-repeatable-fields', $js_plugins . 'repeatable-fields' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
286
-	wp_enqueue_script( 'give-repeatable-fields' );
285
+	wp_register_script('give-repeatable-fields', $js_plugins.'repeatable-fields'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
286
+	wp_enqueue_script('give-repeatable-fields');
287 287
 
288 288
 	// Forms CPT Script.
289
-	if ( $post_type === 'give_forms' ) {
290
-		wp_register_script( 'give-admin-forms-scripts', $js_dir . 'admin-forms' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
291
-		wp_enqueue_script( 'give-admin-forms-scripts' );
289
+	if ($post_type === 'give_forms') {
290
+		wp_register_script('give-admin-forms-scripts', $js_dir.'admin-forms'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
291
+		wp_enqueue_script('give-admin-forms-scripts');
292 292
 	}
293 293
 
294 294
 	// Settings Scripts.
295
-	if ( isset( $_GET['page'] ) && $_GET['page'] == 'give-settings' ) {
296
-		wp_register_script( 'give-admin-settings-scripts', $js_dir . 'admin-settings' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
297
-		wp_enqueue_script( 'give-admin-settings-scripts' );
295
+	if (isset($_GET['page']) && $_GET['page'] == 'give-settings') {
296
+		wp_register_script('give-admin-settings-scripts', $js_dir.'admin-settings'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
297
+		wp_enqueue_script('give-admin-settings-scripts');
298 298
 	}
299 299
 
300 300
 	// Price Separators.
@@ -302,76 +302,76 @@  discard block
 block discarded – undo
302 302
 	$decimal_separator  = give_get_price_decimal_separator();
303 303
 
304 304
 	// Localize strings & variables for JS.
305
-	wp_localize_script( 'give-admin-scripts', 'give_vars', array(
306
-		'post_id'                        => isset( $post->ID ) ? $post->ID : null,
305
+	wp_localize_script('give-admin-scripts', 'give_vars', array(
306
+		'post_id'                        => isset($post->ID) ? $post->ID : null,
307 307
 		'give_version'                   => GIVE_VERSION,
308 308
 		'thousands_separator'            => $thousand_separator,
309 309
 		'decimal_separator'              => $decimal_separator,
310
-		'quick_edit_warning'             => __( 'Not available for variable priced forms.', 'give' ),
311
-		'delete_payment'                 => __( 'Are you sure you want to delete this payment?', 'give' ),
312
-		'delete_payment_note'            => __( 'Are you sure you want to delete this note?', 'give' ),
313
-		'revoke_api_key'                 => __( 'Are you sure you want to revoke this API key?', 'give' ),
314
-		'regenerate_api_key'             => __( 'Are you sure you want to regenerate this API key?', 'give' ),
315
-		'resend_receipt'                 => __( 'Are you sure you want to resend the donation receipt?', 'give' ),
316
-		'disconnect_user'                => __( 'Are you sure you want to disconnect the user from this donor?', 'give' ),
317
-		'one_option'                     => __( 'Choose a form', 'give' ),
318
-		'one_or_more_option'             => __( 'Choose one or more forms', 'give' ),
319
-		'currency_sign'                  => give_currency_filter( '' ),
320
-		'currency_pos'                   => isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before',
321
-		'currency_decimals'              => give_currency_decimal_filter( give_get_price_decimals() ),
322
-		'batch_export_no_class'          => __( 'You must choose a method.', 'give' ),
323
-		'batch_export_no_reqs'           => __( 'Required fields not completed.', 'give' ),
324
-		'reset_stats_warn'               => __( 'Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give' ),
325
-		'delete_test_donor'               => __( 'Are you sure you want to delete all the test donors? This process will also delete test donations as well.', 'give' ),
326
-		'price_format_guide'             => sprintf( __( 'Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give' ), $decimal_separator, $thousand_separator ),
310
+		'quick_edit_warning'             => __('Not available for variable priced forms.', 'give'),
311
+		'delete_payment'                 => __('Are you sure you want to delete this payment?', 'give'),
312
+		'delete_payment_note'            => __('Are you sure you want to delete this note?', 'give'),
313
+		'revoke_api_key'                 => __('Are you sure you want to revoke this API key?', 'give'),
314
+		'regenerate_api_key'             => __('Are you sure you want to regenerate this API key?', 'give'),
315
+		'resend_receipt'                 => __('Are you sure you want to resend the donation receipt?', 'give'),
316
+		'disconnect_user'                => __('Are you sure you want to disconnect the user from this donor?', 'give'),
317
+		'one_option'                     => __('Choose a form', 'give'),
318
+		'one_or_more_option'             => __('Choose one or more forms', 'give'),
319
+		'currency_sign'                  => give_currency_filter(''),
320
+		'currency_pos'                   => isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before',
321
+		'currency_decimals'              => give_currency_decimal_filter(give_get_price_decimals()),
322
+		'batch_export_no_class'          => __('You must choose a method.', 'give'),
323
+		'batch_export_no_reqs'           => __('Required fields not completed.', 'give'),
324
+		'reset_stats_warn'               => __('Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give'),
325
+		'delete_test_donor'               => __('Are you sure you want to delete all the test donors? This process will also delete test donations as well.', 'give'),
326
+		'price_format_guide'             => sprintf(__('Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give'), $decimal_separator, $thousand_separator),
327 327
 		/* translators : %s: Donation form options metabox */
328
-		'confirm_before_remove_row_text' => __( 'Do you want to delete this level?', 'give' ),
329
-		'matched_success_failure_page'   => __( 'You cannot set the success and failed pages to the same page', 'give' ),
330
-		'dismiss_notice_text'            => __( 'Dismiss this notice.', 'give' ),
331
-		'search_placeholder'             => __( 'Type to search all forms', 'give' ),
332
-		'search_placeholder_donor'       => __( 'Type to search all donors', 'give' ),
333
-		'search_placeholder_country'     => __( 'Type to search all countries', 'give' ),
334
-		'search_placeholder_state'       => __( 'Type to search all states/provinces', 'give' ),
328
+		'confirm_before_remove_row_text' => __('Do you want to delete this level?', 'give'),
329
+		'matched_success_failure_page'   => __('You cannot set the success and failed pages to the same page', 'give'),
330
+		'dismiss_notice_text'            => __('Dismiss this notice.', 'give'),
331
+		'search_placeholder'             => __('Type to search all forms', 'give'),
332
+		'search_placeholder_donor'       => __('Type to search all donors', 'give'),
333
+		'search_placeholder_country'     => __('Type to search all countries', 'give'),
334
+		'search_placeholder_state'       => __('Type to search all states/provinces', 'give'),
335 335
 		'bulk_action' => array(
336 336
 			'delete'    => array(
337
-				'zero'     => __( 'You must choose at least one or more payments to delete.', 'give' ),
338
-				'single'   => __( 'Are you sure you want to permanently delete this donation?', 'give' ),
339
-				'multiple' => __( 'Are you sure you want to permanently delete the selected {payment_count} donations?', 'give' ),
337
+				'zero'     => __('You must choose at least one or more payments to delete.', 'give'),
338
+				'single'   => __('Are you sure you want to permanently delete this donation?', 'give'),
339
+				'multiple' => __('Are you sure you want to permanently delete the selected {payment_count} donations?', 'give'),
340 340
 			),
341 341
 			'resend-receipt' => array(
342
-				'zero'     => __( 'You must choose at least one or more recipients to resend the email receipt.', 'give' ),
343
-				'single'   => __( 'Are you sure you want to resend the email receipt to this recipient?', 'give' ),
344
-				'multiple' => __( 'Are you sure you want to resend the emails receipt to {payment_count} recipients?', 'give' ),
342
+				'zero'     => __('You must choose at least one or more recipients to resend the email receipt.', 'give'),
343
+				'single'   => __('Are you sure you want to resend the email receipt to this recipient?', 'give'),
344
+				'multiple' => __('Are you sure you want to resend the emails receipt to {payment_count} recipients?', 'give'),
345 345
 			),
346 346
 			'set-to-status' => array(
347
-				'zero'      => __( 'You must choose at least one or more donations to set status to {status}.', 'give' ),
348
-				'single'    => __( 'Are you sure you want to set status of this donation to {status}?', 'give' ),
349
-				'multiple'  => __( 'Are you sure you want to set status of {payment_count} donations to {status}?', 'give' ),
347
+				'zero'      => __('You must choose at least one or more donations to set status to {status}.', 'give'),
348
+				'single'    => __('Are you sure you want to set status of this donation to {status}?', 'give'),
349
+				'multiple'  => __('Are you sure you want to set status of {payment_count} donations to {status}?', 'give'),
350 350
 			),
351 351
 		),
352 352
 		'metabox_fields' => array(
353 353
 			'media' => array(
354
-				'button_title' => __( 'Choose Image', 'give' ),
354
+				'button_title' => __('Choose Image', 'give'),
355 355
 			),
356 356
 			'file' => array(
357
-				'button_title' => __( 'Choose File', 'give' ),
357
+				'button_title' => __('Choose File', 'give'),
358 358
 			)
359 359
 		),
360 360
 		'chosen' => array(
361
-			'no_results_msg'  => __( 'No results match {search_term}', 'give' ),
362
-			'ajax_search_msg' => __( 'Searching results for match {search_term}', 'give' ),
361
+			'no_results_msg'  => __('No results match {search_term}', 'give'),
362
+			'ajax_search_msg' => __('Searching results for match {search_term}', 'give'),
363 363
 		),
364
-		'db_update_confirmation_msg' => __( 'The following process will make updates to your site\'s database. Please create a database backup before proceeding with updates.', 'give' )
365
-	) );
364
+		'db_update_confirmation_msg' => __('The following process will make updates to your site\'s database. Please create a database backup before proceeding with updates.', 'give')
365
+	));
366 366
 
367
-	if ( function_exists( 'wp_enqueue_media' ) && version_compare( get_bloginfo( 'version' ), '3.5', '>=' ) ) {
367
+	if (function_exists('wp_enqueue_media') && version_compare(get_bloginfo('version'), '3.5', '>=')) {
368 368
 		// call for new media manager.
369 369
 		wp_enqueue_media();
370 370
 	}
371 371
 
372 372
 }
373 373
 
374
-add_action( 'admin_enqueue_scripts', 'give_load_admin_scripts', 100 );
374
+add_action('admin_enqueue_scripts', 'give_load_admin_scripts', 100);
375 375
 
376 376
 /**
377 377
  * Admin Give Icon
@@ -386,13 +386,13 @@  discard block
 block discarded – undo
386 386
 	?>
387 387
 	<style type="text/css" media="screen">
388 388
 
389
-		<?php if ( version_compare( get_bloginfo( 'version' ), '3.8-RC', '>=' ) || version_compare( get_bloginfo( 'version' ), '3.8', '>=' ) ) { ?>
389
+		<?php if (version_compare(get_bloginfo('version'), '3.8-RC', '>=') || version_compare(get_bloginfo('version'), '3.8', '>=')) { ?>
390 390
 		@font-face {
391 391
 			font-family: 'give-icomoon';
392
-			src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?ngjl88'; ?>');
393
-			src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?#iefixngjl88'?>') format('embedded-opentype'),
394
-			url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.woff?ngjl88'; ?>') format('woff'),
395
-			url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.svg?ngjl88#icomoon'; ?>') format('svg');
392
+			src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?ngjl88'; ?>');
393
+			src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?#iefixngjl88'?>') format('embedded-opentype'),
394
+			url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.woff?ngjl88'; ?>') format('woff'),
395
+			url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.svg?ngjl88#icomoon'; ?>') format('svg');
396 396
 			font-weight: normal;
397 397
 			font-style: normal;
398 398
 		}
@@ -411,4 +411,4 @@  discard block
 block discarded – undo
411 411
 	<?php
412 412
 }
413 413
 
414
-add_action( 'admin_head', 'give_admin_icon' );
414
+add_action('admin_head', 'give_admin_icon');
Please login to merge, or discard this patch.
includes/ajax-functions.php 1 patch
Spacing   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly.
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -26,26 +26,26 @@  discard block
 block discarded – undo
26 26
 function give_test_ajax_works() {
27 27
 
28 28
 	// Check if the Airplane Mode plugin is installed.
29
-	if ( class_exists( 'Airplane_Mode_Core' ) ) {
29
+	if (class_exists('Airplane_Mode_Core')) {
30 30
 
31 31
 		$airplane = Airplane_Mode_Core::getInstance();
32 32
 
33
-		if ( method_exists( $airplane, 'enabled' ) ) {
33
+		if (method_exists($airplane, 'enabled')) {
34 34
 
35
-			if ( $airplane->enabled() ) {
35
+			if ($airplane->enabled()) {
36 36
 				return true;
37 37
 			}
38 38
 		} else {
39 39
 
40
-			if ( 'on' === $airplane->check_status()  ) {
40
+			if ('on' === $airplane->check_status()) {
41 41
 				return true;
42 42
 			}
43 43
 		}
44 44
 	}
45 45
 
46
-	add_filter( 'block_local_requests', '__return_false' );
46
+	add_filter('block_local_requests', '__return_false');
47 47
 
48
-	if ( Give_Cache::get( '_give_ajax_works', true ) ) {
48
+	if (Give_Cache::get('_give_ajax_works', true)) {
49 49
 		return true;
50 50
 	}
51 51
 
@@ -57,35 +57,35 @@  discard block
 block discarded – undo
57 57
 		),
58 58
 	);
59 59
 
60
-	$ajax = wp_remote_post( give_get_ajax_url(), $params );
60
+	$ajax = wp_remote_post(give_get_ajax_url(), $params);
61 61
 
62 62
 	$works = true;
63 63
 
64
-	if ( is_wp_error( $ajax ) ) {
64
+	if (is_wp_error($ajax)) {
65 65
 
66 66
 		$works = false;
67 67
 
68 68
 	} else {
69 69
 
70
-		if ( empty( $ajax['response'] ) ) {
70
+		if (empty($ajax['response'])) {
71 71
 			$works = false;
72 72
 		}
73 73
 
74
-		if ( empty( $ajax['response']['code'] ) || 200 !== (int) $ajax['response']['code'] ) {
74
+		if (empty($ajax['response']['code']) || 200 !== (int) $ajax['response']['code']) {
75 75
 			$works = false;
76 76
 		}
77 77
 
78
-		if ( empty( $ajax['response']['message'] ) || 'OK' !== $ajax['response']['message'] ) {
78
+		if (empty($ajax['response']['message']) || 'OK' !== $ajax['response']['message']) {
79 79
 			$works = false;
80 80
 		}
81 81
 
82
-		if ( ! isset( $ajax['body'] ) || 0 !== (int) $ajax['body'] ) {
82
+		if ( ! isset($ajax['body']) || 0 !== (int) $ajax['body']) {
83 83
 			$works = false;
84 84
 		}
85 85
 	}
86 86
 
87
-	if ( $works ) {
88
-		Give_Cache::set( '_give_ajax_works', '1', DAY_IN_SECONDS, true );
87
+	if ($works) {
88
+		Give_Cache::set('_give_ajax_works', '1', DAY_IN_SECONDS, true);
89 89
 	}
90 90
 
91 91
 	return $works;
@@ -100,16 +100,16 @@  discard block
 block discarded – undo
100 100
  * @return string
101 101
  */
102 102
 function give_get_ajax_url() {
103
-	$scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin';
103
+	$scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin';
104 104
 
105 105
 	$current_url = give_get_current_page_url();
106
-	$ajax_url    = admin_url( 'admin-ajax.php', $scheme );
106
+	$ajax_url    = admin_url('admin-ajax.php', $scheme);
107 107
 
108
-	if ( preg_match( '/^https/', $current_url ) && ! preg_match( '/^https/', $ajax_url ) ) {
109
-		$ajax_url = preg_replace( '/^http/', 'https', $ajax_url );
108
+	if (preg_match('/^https/', $current_url) && ! preg_match('/^https/', $ajax_url)) {
109
+		$ajax_url = preg_replace('/^http/', 'https', $ajax_url);
110 110
 	}
111 111
 
112
-	return apply_filters( 'give_ajax_url', $ajax_url );
112
+	return apply_filters('give_ajax_url', $ajax_url);
113 113
 }
114 114
 
115 115
 /**
@@ -125,12 +125,12 @@  discard block
 block discarded – undo
125 125
 	 *
126 126
 	 * @since 1.7
127 127
 	 */
128
-	do_action( 'give_donation_form_login_fields' );
128
+	do_action('give_donation_form_login_fields');
129 129
 
130 130
 	give_die();
131 131
 }
132 132
 
133
-add_action( 'wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields' );
133
+add_action('wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields');
134 134
 
135 135
 /**
136 136
  * Load Checkout Fields
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
  * @return void
141 141
  */
142 142
 function give_load_checkout_fields() {
143
-	$form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : '';
143
+	$form_id = isset($_POST['form_id']) ? $_POST['form_id'] : '';
144 144
 
145 145
 	ob_start();
146 146
 
@@ -149,18 +149,18 @@  discard block
 block discarded – undo
149 149
 	 *
150 150
 	 * @since 1.7
151 151
 	 */
152
-	do_action( 'give_donation_form_register_login_fields', $form_id );
152
+	do_action('give_donation_form_register_login_fields', $form_id);
153 153
 
154 154
 	$fields = ob_get_clean();
155 155
 
156
-	wp_send_json( array(
157
-		'fields' => wp_json_encode( $fields ),
158
-		'submit' => wp_json_encode( give_get_donation_form_submit_button( $form_id ) ),
159
-	) );
156
+	wp_send_json(array(
157
+		'fields' => wp_json_encode($fields),
158
+		'submit' => wp_json_encode(give_get_donation_form_submit_button($form_id)),
159
+	));
160 160
 }
161 161
 
162
-add_action( 'wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields' );
163
-add_action( 'wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields' );
162
+add_action('wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields');
163
+add_action('wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields');
164 164
 
165 165
 /**
166 166
  * Get Form Title via AJAX (used only in WordPress Admin)
@@ -170,9 +170,9 @@  discard block
 block discarded – undo
170 170
  * @return void
171 171
  */
172 172
 function give_ajax_get_form_title() {
173
-	if ( isset( $_POST['form_id'] ) ) {
174
-		$title = get_the_title( $_POST['form_id'] );
175
-		if ( $title ) {
173
+	if (isset($_POST['form_id'])) {
174
+		$title = get_the_title($_POST['form_id']);
175
+		if ($title) {
176 176
 			echo $title;
177 177
 		} else {
178 178
 			echo 'fail';
@@ -181,8 +181,8 @@  discard block
 block discarded – undo
181 181
 	give_die();
182 182
 }
183 183
 
184
-add_action( 'wp_ajax_give_get_form_title', 'give_ajax_get_form_title' );
185
-add_action( 'wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title' );
184
+add_action('wp_ajax_give_get_form_title', 'give_ajax_get_form_title');
185
+add_action('wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title');
186 186
 
187 187
 /**
188 188
  * Retrieve a states drop down
@@ -196,35 +196,35 @@  discard block
 block discarded – undo
196 196
 	$show_field = true;
197 197
 	$states_require = true;
198 198
 	// Get the Country code from the $_POST.
199
-	$country = sanitize_text_field( $_POST['country'] );
199
+	$country = sanitize_text_field($_POST['country']);
200 200
 
201 201
 	// Get the field name from the $_POST.
202
-	$field_name = sanitize_text_field( $_POST['field_name'] );
202
+	$field_name = sanitize_text_field($_POST['field_name']);
203 203
 
204
-	$label = __( 'State', 'give' );
204
+	$label = __('State', 'give');
205 205
 	$states_label = give_get_states_label();
206 206
 
207 207
 	// Check if $country code exists in the array key for states label.
208
-	if ( array_key_exists( $country, $states_label ) ) {
209
-		$label = $states_label[ $country ];
208
+	if (array_key_exists($country, $states_label)) {
209
+		$label = $states_label[$country];
210 210
 	}
211 211
 
212
-	if ( empty( $country ) ) {
212
+	if (empty($country)) {
213 213
 		$country = give_get_country();
214 214
 	}
215 215
 
216
-	$states = give_get_states( $country );
217
-	if ( ! empty( $states ) ) {
216
+	$states = give_get_states($country);
217
+	if ( ! empty($states)) {
218 218
 		$args = array(
219 219
 			'name'             => $field_name,
220 220
 			'id'               => $field_name,
221
-			'class'            => $field_name . '  give-select',
221
+			'class'            => $field_name.'  give-select',
222 222
 			'options'          => $states,
223 223
 			'show_option_all'  => false,
224 224
 			'show_option_none' => false,
225 225
 			'placeholder' => $label,
226 226
 		);
227
-		$data = Give()->html->select( $args );
227
+		$data = Give()->html->select($args);
228 228
 		$states_found = true;
229 229
 	} else {
230 230
 		$data = 'nostates';
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 		$no_states_country = give_no_states_country_list();
234 234
 
235 235
 		// Check if $country code exists in the array key.
236
-		if ( array_key_exists( $country, $no_states_country ) ) {
236
+		if (array_key_exists($country, $no_states_country)) {
237 237
 			$show_field = false;
238 238
 		}
239 239
 
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 		$states_not_required_country_list = give_states_not_required_country_list();
242 242
 
243 243
 		// Check if $country code exists in the array key.
244
-		if ( array_key_exists( $country, $states_not_required_country_list ) ) {
244
+		if (array_key_exists($country, $states_not_required_country_list)) {
245 245
 			$states_require = false;
246 246
 		}
247 247
 	}
@@ -253,10 +253,10 @@  discard block
 block discarded – undo
253 253
 		'states_require' => $states_require,
254 254
 		'data' => $data,
255 255
 	);
256
-	wp_send_json( $response );
256
+	wp_send_json($response);
257 257
 }
258
-add_action( 'wp_ajax_give_get_states', 'give_ajax_get_states_field' );
259
-add_action( 'wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field' );
258
+add_action('wp_ajax_give_get_states', 'give_ajax_get_states_field');
259
+add_action('wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field');
260 260
 
261 261
 /**
262 262
  * Retrieve donation forms via AJAX for chosen dropdown search field.
@@ -268,19 +268,19 @@  discard block
 block discarded – undo
268 268
 function give_ajax_form_search() {
269 269
 	global $wpdb;
270 270
 
271
-	$search   = esc_sql( sanitize_text_field( $_GET['s'] ) );
272
-	$excludes = ( isset( $_GET['current_id'] ) ? (array) $_GET['current_id'] : array() );
271
+	$search   = esc_sql(sanitize_text_field($_GET['s']));
272
+	$excludes = (isset($_GET['current_id']) ? (array) $_GET['current_id'] : array());
273 273
 
274 274
 	$results = array();
275
-	if ( current_user_can( 'edit_give_forms' ) ) {
276
-		$items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50" );
275
+	if (current_user_can('edit_give_forms')) {
276
+		$items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50");
277 277
 	} else {
278
-		$items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50" );
278
+		$items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50");
279 279
 	}
280 280
 
281
-	if ( $items ) {
281
+	if ($items) {
282 282
 
283
-		foreach ( $items as $item ) {
283
+		foreach ($items as $item) {
284 284
 
285 285
 			$results[] = array(
286 286
 				'id'   => $item->ID,
@@ -291,18 +291,18 @@  discard block
 block discarded – undo
291 291
 
292 292
 		$items[] = array(
293 293
 			'id'   => 0,
294
-			'name' => __( 'No forms found.', 'give' ),
294
+			'name' => __('No forms found.', 'give'),
295 295
 		);
296 296
 
297 297
 	}
298 298
 
299
-	echo json_encode( $results );
299
+	echo json_encode($results);
300 300
 
301 301
 	give_die();
302 302
 }
303 303
 
304
-add_action( 'wp_ajax_give_form_search', 'give_ajax_form_search' );
305
-add_action( 'wp_ajax_nopriv_give_form_search', 'give_ajax_form_search' );
304
+add_action('wp_ajax_give_form_search', 'give_ajax_form_search');
305
+add_action('wp_ajax_nopriv_give_form_search', 'give_ajax_form_search');
306 306
 
307 307
 /**
308 308
  * Search the donors database via Ajax
@@ -314,38 +314,38 @@  discard block
 block discarded – undo
314 314
 function give_ajax_donor_search() {
315 315
 	global $wpdb;
316 316
 
317
-	$search  = esc_sql( sanitize_text_field( $_GET['s'] ) );
317
+	$search  = esc_sql(sanitize_text_field($_GET['s']));
318 318
 	$results = array();
319
-	if ( ! current_user_can( 'view_give_reports' ) ) {
319
+	if ( ! current_user_can('view_give_reports')) {
320 320
 		$donors = array();
321 321
 	} else {
322
-		$donors = $wpdb->get_results( "SELECT id,name,email FROM {$wpdb->prefix}give_customers WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50" );
322
+		$donors = $wpdb->get_results("SELECT id,name,email FROM {$wpdb->prefix}give_customers WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50");
323 323
 	}
324 324
 
325
-	if ( $donors ) {
325
+	if ($donors) {
326 326
 
327
-		foreach ( $donors as $donor ) {
327
+		foreach ($donors as $donor) {
328 328
 
329 329
 			$results[] = array(
330 330
 				'id'   => $donor->id,
331
-				'name' => $donor->name . ' (' . $donor->email . ')',
331
+				'name' => $donor->name.' ('.$donor->email.')',
332 332
 			);
333 333
 		}
334 334
 	} else {
335 335
 
336 336
 		$donors[] = array(
337 337
 			'id'   => 0,
338
-			'name' => __( 'No donors found.', 'give' ),
338
+			'name' => __('No donors found.', 'give'),
339 339
 		);
340 340
 
341 341
 	}
342 342
 
343
-	echo json_encode( $results );
343
+	echo json_encode($results);
344 344
 
345 345
 	give_die();
346 346
 }
347 347
 
348
-add_action( 'wp_ajax_give_donor_search', 'give_ajax_donor_search' );
348
+add_action('wp_ajax_give_donor_search', 'give_ajax_donor_search');
349 349
 
350 350
 
351 351
 /**
@@ -357,39 +357,39 @@  discard block
 block discarded – undo
357 357
  */
358 358
 function give_ajax_search_users() {
359 359
 
360
-	if ( current_user_can( 'manage_give_settings' ) ) {
360
+	if (current_user_can('manage_give_settings')) {
361 361
 
362
-		$search   = esc_sql( sanitize_text_field( $_GET['s'] ) );
362
+		$search = esc_sql(sanitize_text_field($_GET['s']));
363 363
 
364 364
 		$get_users_args = array(
365 365
 			'number' => 9999,
366
-			'search' => $search . '*',
366
+			'search' => $search.'*',
367 367
 		);
368 368
 
369
-		$get_users_args = apply_filters( 'give_search_users_args', $get_users_args );
369
+		$get_users_args = apply_filters('give_search_users_args', $get_users_args);
370 370
 
371
-		$found_users = apply_filters( 'give_ajax_found_users', get_users( $get_users_args ), $search );
371
+		$found_users = apply_filters('give_ajax_found_users', get_users($get_users_args), $search);
372 372
 		$results     = array();
373 373
 
374
-		if ( $found_users ) {
374
+		if ($found_users) {
375 375
 
376
-			foreach ( $found_users as $user ) {
376
+			foreach ($found_users as $user) {
377 377
 
378 378
 				$results[] = array(
379 379
 					'id'   => $user->ID,
380
-					'name' => esc_html( $user->user_login . ' (' . $user->user_email . ')' ),
380
+					'name' => esc_html($user->user_login.' ('.$user->user_email.')'),
381 381
 				);
382 382
 			}
383 383
 		} else {
384 384
 
385 385
 			$results[] = array(
386 386
 				'id'   => 0,
387
-				'name' => __( 'No users found.', 'give' ),
387
+				'name' => __('No users found.', 'give'),
388 388
 			);
389 389
 
390 390
 		}
391 391
 
392
-		echo json_encode( $results );
392
+		echo json_encode($results);
393 393
 
394 394
 	}// End if().
395 395
 
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
 
398 398
 }
399 399
 
400
-add_action( 'wp_ajax_give_user_search', 'give_ajax_search_users' );
400
+add_action('wp_ajax_give_user_search', 'give_ajax_search_users');
401 401
 
402 402
 
403 403
 /**
@@ -409,32 +409,32 @@  discard block
 block discarded – undo
409 409
  */
410 410
 function give_check_for_form_price_variations() {
411 411
 
412
-	if ( ! current_user_can( 'edit_give_forms', get_current_user_id() ) ) {
413
-		die( '-1' );
412
+	if ( ! current_user_can('edit_give_forms', get_current_user_id())) {
413
+		die('-1');
414 414
 	}
415 415
 
416
-	$form_id = intval( $_POST['form_id'] );
417
-	$form    = get_post( $form_id );
416
+	$form_id = intval($_POST['form_id']);
417
+	$form    = get_post($form_id);
418 418
 
419
-	if ( 'give_forms' != $form->post_type ) {
420
-		die( '-2' );
419
+	if ('give_forms' != $form->post_type) {
420
+		die('-2');
421 421
 	}
422 422
 
423
-	if ( give_has_variable_prices( $form_id ) ) {
424
-		$variable_prices = give_get_variable_prices( $form_id );
423
+	if (give_has_variable_prices($form_id)) {
424
+		$variable_prices = give_get_variable_prices($form_id);
425 425
 
426
-		if ( $variable_prices ) {
426
+		if ($variable_prices) {
427 427
 			$ajax_response = '<select class="give_price_options_select give-select give-select" name="give_price_option">';
428 428
 
429
-			if ( isset( $_POST['all_prices'] ) ) {
430
-				$ajax_response .= '<option value="all">' . esc_html__( 'All Levels', 'give' ) . '</option>';
429
+			if (isset($_POST['all_prices'])) {
430
+				$ajax_response .= '<option value="all">'.esc_html__('All Levels', 'give').'</option>';
431 431
 			}
432 432
 
433
-			foreach ( $variable_prices as $key => $price ) {
433
+			foreach ($variable_prices as $key => $price) {
434 434
 
435
-				$level_text = ! empty( $price['_give_text'] ) ? esc_html( $price['_give_text'] ) : give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) );
435
+				$level_text = ! empty($price['_give_text']) ? esc_html($price['_give_text']) : give_currency_filter(give_format_amount($price['_give_amount'], array('sanitize' => false)));
436 436
 
437
-				$ajax_response .= '<option value="' . esc_attr( $price['_give_id']['level_id'] ) . '">' . $level_text . '</option>';
437
+				$ajax_response .= '<option value="'.esc_attr($price['_give_id']['level_id']).'">'.$level_text.'</option>';
438 438
 			}
439 439
 			$ajax_response .= '</select>';
440 440
 			echo $ajax_response;
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 	give_die();
445 445
 }
446 446
 
447
-add_action( 'wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations' );
447
+add_action('wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations');
448 448
 
449 449
 
450 450
 /**
@@ -455,25 +455,25 @@  discard block
 block discarded – undo
455 455
  * @return void
456 456
  */
457 457
 function give_check_for_form_price_variations_html() {
458
-	if ( ! current_user_can( 'edit_give_payments', get_current_user_id() ) ) {
458
+	if ( ! current_user_can('edit_give_payments', get_current_user_id())) {
459 459
 		wp_die();
460 460
 	}
461 461
 
462
-	$form_id    = ! empty( $_POST['form_id'] ) ? intval( $_POST['form_id'] ) : 0;
463
-	$payment_id = ! empty( $_POST['payment_id'] ) ? intval( $_POST['payment_id'] ) : 0;
464
-	$form       = get_post( $form_id );
462
+	$form_id    = ! empty($_POST['form_id']) ? intval($_POST['form_id']) : 0;
463
+	$payment_id = ! empty($_POST['payment_id']) ? intval($_POST['payment_id']) : 0;
464
+	$form       = get_post($form_id);
465 465
 
466
-	if ( 'give_forms' != $form->post_type ) {
466
+	if ('give_forms' != $form->post_type) {
467 467
 		wp_die();
468 468
 	}
469 469
 
470
-	if ( ! give_has_variable_prices( $form_id ) || ! $form_id ) {
471
-		esc_html_e( 'n/a', 'give' );
470
+	if ( ! give_has_variable_prices($form_id) || ! $form_id) {
471
+		esc_html_e('n/a', 'give');
472 472
 	} else {
473 473
 		$prices_atts = '';
474
-		if ( $variable_prices = give_get_variable_prices( $form_id ) ) {
475
-			foreach ( $variable_prices as $variable_price ) {
476
-				$prices_atts[ $variable_price['_give_id']['level_id'] ] = give_format_amount( $variable_price['_give_amount'], array( 'sanitize' => false ) );
474
+		if ($variable_prices = give_get_variable_prices($form_id)) {
475
+			foreach ($variable_prices as $variable_price) {
476
+				$prices_atts[$variable_price['_give_id']['level_id']] = give_format_amount($variable_price['_give_amount'], array('sanitize' => false));
477 477
 			}
478 478
 		}
479 479
 
@@ -484,12 +484,12 @@  discard block
 block discarded – undo
484 484
 			'chosen'           => true,
485 485
 			'show_option_all'  => '',
486 486
 			'show_option_none' => '',
487
-			'select_atts'      => 'data-prices=' . esc_attr( json_encode( $prices_atts ) ),
487
+			'select_atts'      => 'data-prices='.esc_attr(json_encode($prices_atts)),
488 488
 		);
489 489
 
490
-		if ( $payment_id ) {
490
+		if ($payment_id) {
491 491
 			// Payment object.
492
-			$payment = new Give_Payment( $payment_id );
492
+			$payment = new Give_Payment($payment_id);
493 493
 
494 494
 			// Payment meta.
495 495
 			$payment_meta                               = $payment->get_meta();
@@ -497,10 +497,10 @@  discard block
 block discarded – undo
497 497
 		}
498 498
 
499 499
 		// Render variable prices select tag html.
500
-		give_get_form_variable_price_dropdown( $variable_price_dropdown_option, true );
500
+		give_get_form_variable_price_dropdown($variable_price_dropdown_option, true);
501 501
 	}
502 502
 
503 503
 	give_die();
504 504
 }
505 505
 
506
-add_action( 'wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html' );
506
+add_action('wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html');
Please login to merge, or discard this patch.
includes/class-give-donate-form.php 1 patch
Spacing   +115 added lines, -115 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
 
@@ -337,11 +337,11 @@  discard block
 block discarded – undo
337 337
 	 * @param  bool  $_id   Post id. Default is false.
338 338
 	 * @param  array $_args Arguments passed.
339 339
 	 */
340
-	public function __construct( $_id = false, $_args = array() ) {
340
+	public function __construct($_id = false, $_args = array()) {
341 341
 
342
-		$donation_form = WP_Post::get_instance( $_id );
342
+		$donation_form = WP_Post::get_instance($_id);
343 343
 
344
-		return $this->setup_donation_form( $donation_form );
344
+		return $this->setup_donation_form($donation_form);
345 345
 	}
346 346
 
347 347
 	/**
@@ -354,23 +354,23 @@  discard block
 block discarded – undo
354 354
 	 *
355 355
 	 * @return bool                   If the setup was successful or not.
356 356
 	 */
357
-	private function setup_donation_form( $donation_form ) {
357
+	private function setup_donation_form($donation_form) {
358 358
 
359
-		if ( ! is_object( $donation_form ) ) {
359
+		if ( ! is_object($donation_form)) {
360 360
 			return false;
361 361
 		}
362 362
 
363
-		if ( ! is_a( $donation_form, 'WP_Post' ) ) {
363
+		if ( ! is_a($donation_form, 'WP_Post')) {
364 364
 			return false;
365 365
 		}
366 366
 
367
-		if ( 'give_forms' !== $donation_form->post_type ) {
367
+		if ('give_forms' !== $donation_form->post_type) {
368 368
 			return false;
369 369
 		}
370 370
 
371
-		foreach ( $donation_form as $key => $value ) {
371
+		foreach ($donation_form as $key => $value) {
372 372
 
373
-			switch ( $key ) {
373
+			switch ($key) {
374 374
 
375 375
 				default:
376 376
 					$this->$key = $value;
@@ -394,16 +394,16 @@  discard block
 block discarded – undo
394 394
 	 *
395 395
 	 * @return mixed
396 396
 	 */
397
-	public function __get( $key ) {
397
+	public function __get($key) {
398 398
 
399
-		if ( method_exists( $this, 'get_' . $key ) ) {
399
+		if (method_exists($this, 'get_'.$key)) {
400 400
 
401
-			return call_user_func( array( $this, 'get_' . $key ) );
401
+			return call_user_func(array($this, 'get_'.$key));
402 402
 
403 403
 		} else {
404 404
 
405 405
 			/* translators: %s: property key */
406
-			return new WP_Error( 'give-form-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) );
406
+			return new WP_Error('give-form-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key));
407 407
 
408 408
 		}
409 409
 
@@ -419,30 +419,30 @@  discard block
 block discarded – undo
419 419
 	 *
420 420
 	 * @return bool|int    False if data isn't passed and class not instantiated for creation, or New Form ID.
421 421
 	 */
422
-	public function create( $data = array() ) {
422
+	public function create($data = array()) {
423 423
 
424
-		if ( $this->id != 0 ) {
424
+		if ($this->id != 0) {
425 425
 			return false;
426 426
 		}
427 427
 
428 428
 		$defaults = array(
429 429
 			'post_type'   => 'give_forms',
430 430
 			'post_status' => 'draft',
431
-			'post_title'  => __( 'New Donation Form', 'give' ),
431
+			'post_title'  => __('New Donation Form', 'give'),
432 432
 		);
433 433
 
434
-		$args = wp_parse_args( $data, $defaults );
434
+		$args = wp_parse_args($data, $defaults);
435 435
 
436 436
 		/**
437 437
 		 * Fired before a donation form is created
438 438
 		 *
439 439
 		 * @param array $args The post object arguments used for creation.
440 440
 		 */
441
-		do_action( 'give_form_pre_create', $args );
441
+		do_action('give_form_pre_create', $args);
442 442
 
443
-		$id = wp_insert_post( $args, true );
443
+		$id = wp_insert_post($args, true);
444 444
 
445
-		$donation_form = WP_Post::get_instance( $id );
445
+		$donation_form = WP_Post::get_instance($id);
446 446
 
447 447
 		/**
448 448
 		 * Fired after a donation form is created
@@ -450,9 +450,9 @@  discard block
 block discarded – undo
450 450
 		 * @param int   $id   The post ID of the created item.
451 451
 		 * @param array $args The post object arguments used for creation.
452 452
 		 */
453
-		do_action( 'give_form_post_create', $id, $args );
453
+		do_action('give_form_post_create', $id, $args);
454 454
 
455
-		return $this->setup_donation_form( $donation_form );
455
+		return $this->setup_donation_form($donation_form);
456 456
 
457 457
 	}
458 458
 
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
 	 * @return string Donation form name.
478 478
 	 */
479 479
 	public function get_name() {
480
-		return get_the_title( $this->ID );
480
+		return get_the_title($this->ID);
481 481
 	}
482 482
 
483 483
 	/**
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
 	 */
491 491
 	public function get_price() {
492 492
 
493
-		if ( ! isset( $this->price ) ) {
493
+		if ( ! isset($this->price)) {
494 494
 
495 495
 			$this->price = give_maybe_sanitize_amount(
496 496
 				give_get_meta(
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
 				)
501 501
 			);
502 502
 
503
-			if ( ! $this->price ) {
503
+			if ( ! $this->price) {
504 504
 				$this->price = 0;
505 505
 			}
506 506
 
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
 		 * @param string     $price The donation form price.
515 515
 		 * @param string|int $id    The form ID.
516 516
 		 */
517
-		return apply_filters( 'give_get_set_price', $this->price, $this->ID );
517
+		return apply_filters('give_get_set_price', $this->price, $this->ID);
518 518
 	}
519 519
 
520 520
 	/**
@@ -527,18 +527,18 @@  discard block
 block discarded – undo
527 527
 	 */
528 528
 	public function get_minimum_price() {
529 529
 
530
-		if ( ! isset( $this->minimum_price ) ) {
530
+		if ( ! isset($this->minimum_price)) {
531 531
 
532
-			$allow_custom_amount = give_get_meta( $this->ID, '_give_custom_amount', true );
533
-			$this->minimum_price = give_get_meta( $this->ID, '_give_custom_amount_minimum', true );
532
+			$allow_custom_amount = give_get_meta($this->ID, '_give_custom_amount', true);
533
+			$this->minimum_price = give_get_meta($this->ID, '_give_custom_amount_minimum', true);
534 534
 
535
-			if ( ! give_is_setting_enabled( $allow_custom_amount ) ) {
535
+			if ( ! give_is_setting_enabled($allow_custom_amount)) {
536 536
 				$this->minimum_price = 0;
537 537
 			}
538 538
 
539 539
 		}
540 540
 
541
-		return apply_filters( 'give_get_set_minimum_price', $this->minimum_price, $this->ID );
541
+		return apply_filters('give_get_set_minimum_price', $this->minimum_price, $this->ID);
542 542
 	}
543 543
 
544 544
 	/**
@@ -551,9 +551,9 @@  discard block
 block discarded – undo
551 551
 	 */
552 552
 	public function get_prices() {
553 553
 
554
-		if ( ! isset( $this->prices ) ) {
554
+		if ( ! isset($this->prices)) {
555 555
 
556
-			$this->prices = give_get_meta( $this->ID, '_give_donation_levels', true );
556
+			$this->prices = give_get_meta($this->ID, '_give_donation_levels', true);
557 557
 
558 558
 		}
559 559
 
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
 		 * @param array      $prices The array of mulit-level prices.
566 566
 		 * @param int|string $ID     The ID of the form.
567 567
 		 */
568
-		return apply_filters( 'give_get_donation_levels', $this->prices, $this->ID );
568
+		return apply_filters('give_get_donation_levels', $this->prices, $this->ID);
569 569
 
570 570
 	}
571 571
 
@@ -579,17 +579,17 @@  discard block
 block discarded – undo
579 579
 	 */
580 580
 	public function get_goal() {
581 581
 
582
-		if ( ! isset( $this->goal ) ) {
582
+		if ( ! isset($this->goal)) {
583 583
 
584
-			$this->goal = give_get_meta( $this->ID, '_give_set_goal', true );
584
+			$this->goal = give_get_meta($this->ID, '_give_set_goal', true);
585 585
 
586
-			if ( ! $this->goal ) {
586
+			if ( ! $this->goal) {
587 587
 				$this->goal = 0;
588 588
 			}
589 589
 
590 590
 		}
591 591
 
592
-		return apply_filters( 'give_get_set_goal', $this->goal, $this->ID );
592
+		return apply_filters('give_get_set_goal', $this->goal, $this->ID);
593 593
 
594 594
 	}
595 595
 
@@ -603,10 +603,10 @@  discard block
 block discarded – undo
603 603
 	 */
604 604
 	public function is_single_price_mode() {
605 605
 
606
-		$option = give_get_meta( $this->ID, '_give_price_option', true );
606
+		$option = give_get_meta($this->ID, '_give_price_option', true);
607 607
 		$ret    = 0;
608 608
 
609
-		if ( empty( $option ) || $option === 'set' ) {
609
+		if (empty($option) || $option === 'set') {
610 610
 			$ret = 1;
611 611
 		}
612 612
 
@@ -618,7 +618,7 @@  discard block
 block discarded – undo
618 618
 		 * @param bool       $ret Is donation form in single price mode?
619 619
 		 * @param int|string $ID The ID of the donation form.
620 620
 		 */
621
-		return (bool) apply_filters( 'give_single_price_option_mode', $ret, $this->ID );
621
+		return (bool) apply_filters('give_single_price_option_mode', $ret, $this->ID);
622 622
 
623 623
 	}
624 624
 
@@ -632,10 +632,10 @@  discard block
 block discarded – undo
632 632
 	 */
633 633
 	public function is_custom_price_mode() {
634 634
 
635
-		$option = give_get_meta( $this->ID, '_give_custom_amount', true );
635
+		$option = give_get_meta($this->ID, '_give_custom_amount', true);
636 636
 		$ret    = 0;
637 637
 
638
-		if ( give_is_setting_enabled( $option ) ) {
638
+		if (give_is_setting_enabled($option)) {
639 639
 			$ret = 1;
640 640
 		}
641 641
 
@@ -647,7 +647,7 @@  discard block
 block discarded – undo
647 647
 		 * @param bool       $ret Is donation form in custom price mode?
648 648
 		 * @param int|string $ID  The ID of the donation form.
649 649
 		 */
650
-		return (bool) apply_filters( 'give_custom_price_option_mode', $ret, $this->ID );
650
+		return (bool) apply_filters('give_custom_price_option_mode', $ret, $this->ID);
651 651
 
652 652
 	}
653 653
 
@@ -663,10 +663,10 @@  discard block
 block discarded – undo
663 663
 	 */
664 664
 	public function has_variable_prices() {
665 665
 
666
-		$option = give_get_meta( $this->ID, '_give_price_option', true );
666
+		$option = give_get_meta($this->ID, '_give_price_option', true);
667 667
 		$ret    = 0;
668 668
 
669
-		if ( $option === 'multi' ) {
669
+		if ($option === 'multi') {
670 670
 			$ret = 1;
671 671
 		}
672 672
 
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
 		 * @param bool       $ret Does donation form have variable prices?
677 677
 		 * @param int|string $ID  The ID of the donation form.
678 678
 		 */
679
-		return (bool) apply_filters( 'give_has_variable_prices', $ret, $this->ID );
679
+		return (bool) apply_filters('give_has_variable_prices', $ret, $this->ID);
680 680
 
681 681
 	}
682 682
 
@@ -690,17 +690,17 @@  discard block
 block discarded – undo
690 690
 	 */
691 691
 	public function get_type() {
692 692
 
693
-		if ( ! isset( $this->type ) ) {
693
+		if ( ! isset($this->type)) {
694 694
 
695
-			$this->type = give_get_meta( $this->ID, '_give_price_option', true );
695
+			$this->type = give_get_meta($this->ID, '_give_price_option', true);
696 696
 
697
-			if ( empty( $this->type ) ) {
697
+			if (empty($this->type)) {
698 698
 				$this->type = 'set';
699 699
 			}
700 700
 
701 701
 		}
702 702
 
703
-		return apply_filters( 'give_get_form_type', $this->type, $this->ID );
703
+		return apply_filters('give_get_form_type', $this->type, $this->ID);
704 704
 
705 705
 	}
706 706
 
@@ -716,23 +716,23 @@  discard block
 block discarded – undo
716 716
 	 *
717 717
 	 * @return string
718 718
 	 */
719
-	public function get_form_classes( $args ) {
719
+	public function get_form_classes($args) {
720 720
 
721
-		$float_labels_option = give_is_float_labels_enabled( $args )
721
+		$float_labels_option = give_is_float_labels_enabled($args)
722 722
 			? 'float-labels-enabled'
723 723
 			: '';
724 724
 
725
-		$form_classes_array = apply_filters( 'give_form_classes', array(
725
+		$form_classes_array = apply_filters('give_form_classes', array(
726 726
 			'give-form',
727
-			'give-form-' . $this->ID,
728
-			'give-form-type-' . $this->get_type(),
727
+			'give-form-'.$this->ID,
728
+			'give-form-type-'.$this->get_type(),
729 729
 			$float_labels_option,
730
-		), $this->ID, $args );
730
+		), $this->ID, $args);
731 731
 
732 732
 		// Remove empty class names.
733
-		$form_classes_array = array_filter( $form_classes_array );
733
+		$form_classes_array = array_filter($form_classes_array);
734 734
 
735
-		return implode( ' ', $form_classes_array );
735
+		return implode(' ', $form_classes_array);
736 736
 
737 737
 	}
738 738
 
@@ -747,24 +747,24 @@  discard block
 block discarded – undo
747 747
 	 *
748 748
 	 * @return string
749 749
 	 */
750
-	public function get_form_wrap_classes( $args ) {
750
+	public function get_form_wrap_classes($args) {
751 751
 
752
-		$display_option = ( isset( $args['display_style'] ) && ! empty( $args['display_style'] ) )
752
+		$display_option = (isset($args['display_style']) && ! empty($args['display_style']))
753 753
 			? $args['display_style']
754
-			: give_get_meta( $this->ID, '_give_payment_display', true );
754
+			: give_get_meta($this->ID, '_give_payment_display', true);
755 755
 
756 756
 		// If admin want to show only button for form then user inbuilt modal functionality.
757
-		if( 'button' === $display_option ) {
757
+		if ('button' === $display_option) {
758 758
 			$display_option = 'modal give-display-button-only';
759 759
 		}
760 760
 
761
-		$form_wrap_classes_array = apply_filters( 'give_form_wrap_classes', array(
761
+		$form_wrap_classes_array = apply_filters('give_form_wrap_classes', array(
762 762
 			'give-form-wrap',
763
-			'give-display-' . $display_option,
764
-		), $this->ID, $args );
763
+			'give-display-'.$display_option,
764
+		), $this->ID, $args);
765 765
 
766 766
 
767
-		return implode( ' ', $form_wrap_classes_array );
767
+		return implode(' ', $form_wrap_classes_array);
768 768
 
769 769
 	}
770 770
 
@@ -779,7 +779,7 @@  discard block
 block discarded – undo
779 779
 	public function is_set_type_donation_form() {
780 780
 		$form_type = $this->get_type();
781 781
 
782
-		return ( 'set' === $form_type ? true : false );
782
+		return ('set' === $form_type ? true : false);
783 783
 	}
784 784
 
785 785
 	/**
@@ -793,7 +793,7 @@  discard block
 block discarded – undo
793 793
 	public function is_multi_type_donation_form() {
794 794
 		$form_type = $this->get_type();
795 795
 
796
-		return ( 'multi' === $form_type ? true : false );
796
+		return ('multi' === $form_type ? true : false);
797 797
 
798 798
 	}
799 799
 
@@ -807,15 +807,15 @@  discard block
 block discarded – undo
807 807
 	 */
808 808
 	public function get_sales() {
809 809
 
810
-		if ( ! isset( $this->sales ) ) {
810
+		if ( ! isset($this->sales)) {
811 811
 
812
-			if ( '' == give_get_meta( $this->ID, '_give_form_sales', true ) ) {
813
-				add_post_meta( $this->ID, '_give_form_sales', 0 );
812
+			if ('' == give_get_meta($this->ID, '_give_form_sales', true)) {
813
+				add_post_meta($this->ID, '_give_form_sales', 0);
814 814
 			} // End if
815 815
 
816
-			$this->sales = give_get_meta( $this->ID, '_give_form_sales', true );
816
+			$this->sales = give_get_meta($this->ID, '_give_form_sales', true);
817 817
 
818
-			if ( $this->sales < 0 ) {
818
+			if ($this->sales < 0) {
819 819
 				// Never let sales be less than zero
820 820
 				$this->sales = 0;
821 821
 			}
@@ -836,13 +836,13 @@  discard block
 block discarded – undo
836 836
 	 *
837 837
 	 * @return int|false     New number of total sales.
838 838
 	 */
839
-	public function increase_sales( $quantity = 1 ) {
839
+	public function increase_sales($quantity = 1) {
840 840
 
841
-		$sales       = give_get_form_sales_stats( $this->ID );
842
-		$quantity    = absint( $quantity );
841
+		$sales       = give_get_form_sales_stats($this->ID);
842
+		$quantity    = absint($quantity);
843 843
 		$total_sales = $sales + $quantity;
844 844
 
845
-		if ( $this->update_meta( '_give_form_sales', $total_sales ) ) {
845
+		if ($this->update_meta('_give_form_sales', $total_sales)) {
846 846
 
847 847
 			$this->sales = $total_sales;
848 848
 
@@ -863,17 +863,17 @@  discard block
 block discarded – undo
863 863
 	 *
864 864
 	 * @return int|false     New number of total sales.
865 865
 	 */
866
-	public function decrease_sales( $quantity = 1 ) {
866
+	public function decrease_sales($quantity = 1) {
867 867
 
868
-		$sales = give_get_form_sales_stats( $this->ID );
868
+		$sales = give_get_form_sales_stats($this->ID);
869 869
 
870 870
 		// Only decrease if not already zero
871
-		if ( $sales > 0 ) {
871
+		if ($sales > 0) {
872 872
 
873
-			$quantity    = absint( $quantity );
873
+			$quantity    = absint($quantity);
874 874
 			$total_sales = $sales - $quantity;
875 875
 
876
-			if ( $this->update_meta( '_give_form_sales', $total_sales ) ) {
876
+			if ($this->update_meta('_give_form_sales', $total_sales)) {
877 877
 
878 878
 				$this->sales = $sales;
879 879
 
@@ -897,15 +897,15 @@  discard block
 block discarded – undo
897 897
 	 */
898 898
 	public function get_earnings() {
899 899
 
900
-		if ( ! isset( $this->earnings ) ) {
900
+		if ( ! isset($this->earnings)) {
901 901
 
902
-			if ( '' == give_get_meta( $this->ID, '_give_form_earnings', true ) ) {
903
-				add_post_meta( $this->ID, '_give_form_earnings', 0 );
902
+			if ('' == give_get_meta($this->ID, '_give_form_earnings', true)) {
903
+				add_post_meta($this->ID, '_give_form_earnings', 0);
904 904
 			}
905 905
 
906
-			$this->earnings = give_get_meta( $this->ID, '_give_form_earnings', true );
906
+			$this->earnings = give_get_meta($this->ID, '_give_form_earnings', true);
907 907
 
908
-			if ( $this->earnings < 0 ) {
908
+			if ($this->earnings < 0) {
909 909
 				// Never let earnings be less than zero
910 910
 				$this->earnings = 0;
911 911
 			}
@@ -926,12 +926,12 @@  discard block
 block discarded – undo
926 926
 	 *
927 927
 	 * @return float|false
928 928
 	 */
929
-	public function increase_earnings( $amount = 0 ) {
929
+	public function increase_earnings($amount = 0) {
930 930
 
931
-		$earnings   = give_get_form_earnings_stats( $this->ID );
931
+		$earnings   = give_get_form_earnings_stats($this->ID);
932 932
 		$new_amount = $earnings + (float) $amount;
933 933
 
934
-		if ( $this->update_meta( '_give_form_earnings', $new_amount ) ) {
934
+		if ($this->update_meta('_give_form_earnings', $new_amount)) {
935 935
 
936 936
 			$this->earnings = $new_amount;
937 937
 
@@ -953,16 +953,16 @@  discard block
 block discarded – undo
953 953
 	 *
954 954
 	 * @return float|false
955 955
 	 */
956
-	public function decrease_earnings( $amount ) {
956
+	public function decrease_earnings($amount) {
957 957
 
958
-		$earnings = give_get_form_earnings_stats( $this->ID );
958
+		$earnings = give_get_form_earnings_stats($this->ID);
959 959
 
960
-		if ( $earnings > 0 ) {
960
+		if ($earnings > 0) {
961 961
 			// Only decrease if greater than zero
962 962
 			$new_amount = $earnings - (float) $amount;
963 963
 
964 964
 
965
-			if ( $this->update_meta( '_give_form_earnings', $new_amount ) ) {
965
+			if ($this->update_meta('_give_form_earnings', $new_amount)) {
966 966
 
967 967
 				$this->earnings = $new_amount;
968 968
 
@@ -986,22 +986,22 @@  discard block
 block discarded – undo
986 986
 	 *
987 987
 	 * @return bool
988 988
 	 */
989
-	public function is_free( $price_id = false ) {
989
+	public function is_free($price_id = false) {
990 990
 
991 991
 		$is_free          = false;
992
-		$variable_pricing = give_has_variable_prices( $this->ID );
992
+		$variable_pricing = give_has_variable_prices($this->ID);
993 993
 
994
-		if ( $variable_pricing && ! is_null( $price_id ) && $price_id !== false ) {
995
-			$price = give_get_price_option_amount( $this->ID, $price_id );
996
-		} elseif ( ! $variable_pricing ) {
997
-			$price = give_get_meta( $this->ID, '_give_set_price', true );
994
+		if ($variable_pricing && ! is_null($price_id) && $price_id !== false) {
995
+			$price = give_get_price_option_amount($this->ID, $price_id);
996
+		} elseif ( ! $variable_pricing) {
997
+			$price = give_get_meta($this->ID, '_give_set_price', true);
998 998
 		}
999 999
 
1000
-		if ( isset( $price ) && (float) $price == 0 ) {
1000
+		if (isset($price) && (float) $price == 0) {
1001 1001
 			$is_free = true;
1002 1002
 		}
1003 1003
 
1004
-		return (bool) apply_filters( 'give_is_free_donation', $is_free, $this->ID, $price_id );
1004
+		return (bool) apply_filters('give_is_free_donation', $is_free, $this->ID, $price_id);
1005 1005
 
1006 1006
 	}
1007 1007
 
@@ -1028,9 +1028,9 @@  discard block
 block discarded – undo
1028 1028
 		$is_close_form = apply_filters(
1029 1029
 			'give_is_close_donation_form',
1030 1030
 			(
1031
-			give_is_setting_enabled( give_get_meta( $this->ID, '_give_goal_option', true ) ) )
1032
-			&& give_is_setting_enabled( give_get_meta( $this->ID, '_give_close_form_when_goal_achieved', true ) )
1033
-			&& ( $this->get_goal() <= $this->get_earnings()
1031
+			give_is_setting_enabled(give_get_meta($this->ID, '_give_goal_option', true)) )
1032
+			&& give_is_setting_enabled(give_get_meta($this->ID, '_give_close_form_when_goal_achieved', true))
1033
+			&& ($this->get_goal() <= $this->get_earnings()
1034 1034
 			),
1035 1035
 			$this->ID
1036 1036
 		);
@@ -1049,29 +1049,29 @@  discard block
 block discarded – undo
1049 1049
 	 *
1050 1050
 	 * @return bool                            The result of the update query.
1051 1051
 	 */
1052
-	private function update_meta( $meta_key = '', $meta_value = '' ) {
1052
+	private function update_meta($meta_key = '', $meta_value = '') {
1053 1053
 
1054 1054
 		/* @var WPDB $wpdb */
1055 1055
 		global $wpdb;
1056 1056
 
1057
-		if ( empty( $meta_key ) ) {
1057
+		if (empty($meta_key)) {
1058 1058
 			return false;
1059 1059
 		}
1060 1060
 
1061 1061
 		// Make sure if it needs to be serialized, we do
1062
-		$meta_value = maybe_serialize( $meta_value );
1062
+		$meta_value = maybe_serialize($meta_value);
1063 1063
 
1064
-		if ( is_numeric( $meta_value ) ) {
1065
-			$value_type = is_float( $meta_value ) ? '%f' : '%d';
1064
+		if (is_numeric($meta_value)) {
1065
+			$value_type = is_float($meta_value) ? '%f' : '%d';
1066 1066
 		} else {
1067 1067
 			$value_type = "'%s'";
1068 1068
 		}
1069 1069
 
1070
-		$sql = $wpdb->prepare( "UPDATE $wpdb->postmeta SET meta_value = $value_type WHERE post_id = $this->ID AND meta_key = '%s'", $meta_value, $meta_key );
1070
+		$sql = $wpdb->prepare("UPDATE $wpdb->postmeta SET meta_value = $value_type WHERE post_id = $this->ID AND meta_key = '%s'", $meta_value, $meta_key);
1071 1071
 
1072
-		if ( $wpdb->query( $sql ) ) {
1072
+		if ($wpdb->query($sql)) {
1073 1073
 
1074
-			clean_post_cache( $this->ID );
1074
+			clean_post_cache($this->ID);
1075 1075
 
1076 1076
 			return true;
1077 1077
 
Please login to merge, or discard this patch.
includes/install.php 1 patch
Spacing   +62 added lines, -62 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,34 +62,34 @@  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
 	//Fresh Install? Setup Test Mode, Base Country (US), Test Gateway, Currency.
77
-	if ( empty( $current_version ) ) {
78
-		$options = array_merge( $options, give_get_default_settings() );
77
+	if (empty($current_version)) {
78
+		$options = array_merge($options, give_get_default_settings());
79 79
 	}
80 80
 
81 81
 	// Populate the default values.
82
-	update_option( 'give_settings', array_merge( $give_options, $options ) );
82
+	update_option('give_settings', array_merge($give_options, $options));
83 83
 
84 84
 	/**
85 85
 	 * Run plugin upgrades.
86 86
 	 *
87 87
 	 * @since 1.8
88 88
 	 */
89
-	do_action( 'give_upgrades' );
89
+	do_action('give_upgrades');
90 90
 
91
-	if ( GIVE_VERSION !== get_option( 'give_version' ) ) {
92
-		update_option( 'give_version', GIVE_VERSION );
91
+	if (GIVE_VERSION !== get_option('give_version')) {
92
+		update_option('give_version', GIVE_VERSION);
93 93
 	}
94 94
 
95 95
 	// Create Give roles.
@@ -98,18 +98,18 @@  discard block
 block discarded – undo
98 98
 	$roles->add_caps();
99 99
 
100 100
 	$api = new Give_API();
101
-	update_option( 'give_default_api_version', 'v' . $api->get_version() );
101
+	update_option('give_default_api_version', 'v'.$api->get_version());
102 102
 
103 103
 	// Check for PHP Session support, and enable if available.
104 104
 	$give_sessions = new Give_Session();
105 105
 	$give_sessions->use_php_sessions();
106 106
 
107 107
 	// Add a temporary option to note that Give pages have been created.
108
-	Give_Cache::set( '_give_installed', $options, 30, true );
108
+	Give_Cache::set('_give_installed', $options, 30, true);
109 109
 
110
-	if ( ! $current_version ) {
110
+	if ( ! $current_version) {
111 111
 
112
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php';
112
+		require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php';
113 113
 
114 114
 		// When new upgrade routines are added, mark them as complete on fresh install.
115 115
 		$upgrade_routines = array(
@@ -123,18 +123,18 @@  discard block
 block discarded – undo
123 123
 			'v1812_update_donor_purchase_values'
124 124
 		);
125 125
 
126
-		foreach ( $upgrade_routines as $upgrade ) {
127
-			give_set_upgrade_complete( $upgrade );
126
+		foreach ($upgrade_routines as $upgrade) {
127
+			give_set_upgrade_complete($upgrade);
128 128
 		}
129 129
 	}
130 130
 
131 131
 	// Bail if activating from network, or bulk.
132
-	if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
132
+	if (is_network_admin() || isset($_GET['activate-multi'])) {
133 133
 		return;
134 134
 	}
135 135
 
136 136
 	// Add the transient to redirect.
137
-	Give_Cache::set( '_give_activation_redirect', true, 30, true );
137
+	Give_Cache::set('_give_activation_redirect', true, 30, true);
138 138
 
139 139
 	// Set 'Donation Form' meta box enabled by default.
140 140
 	give_nav_donation_metabox_enabled();
@@ -154,11 +154,11 @@  discard block
 block discarded – undo
154 154
  * @param  int $site_id The Site ID.
155 155
  * @param  array $meta Blog Meta.
156 156
  */
157
-function give_on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
157
+function give_on_create_blog($blog_id, $user_id, $domain, $path, $site_id, $meta) {
158 158
 
159
-	if ( is_plugin_active_for_network( GIVE_PLUGIN_BASENAME ) ) {
159
+	if (is_plugin_active_for_network(GIVE_PLUGIN_BASENAME)) {
160 160
 
161
-		switch_to_blog( $blog_id );
161
+		switch_to_blog($blog_id);
162 162
 		give_install();
163 163
 		restore_current_blog();
164 164
 
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 
167 167
 }
168 168
 
169
-add_action( 'wpmu_new_blog', 'give_on_create_blog', 10, 6 );
169
+add_action('wpmu_new_blog', 'give_on_create_blog', 10, 6);
170 170
 
171 171
 
172 172
 /**
@@ -179,13 +179,13 @@  discard block
 block discarded – undo
179 179
  *
180 180
  * @return array          The tables to drop.
181 181
  */
182
-function give_wpmu_drop_tables( $tables, $blog_id ) {
182
+function give_wpmu_drop_tables($tables, $blog_id) {
183 183
 
184
-	switch_to_blog( $blog_id );
184
+	switch_to_blog($blog_id);
185 185
 	$donors_db     = new Give_DB_Donors();
186 186
 	$donor_meta_db = new Give_DB_Donor_Meta();
187 187
 
188
-	if ( $donors_db->installed() ) {
188
+	if ($donors_db->installed()) {
189 189
 		$tables[] = $donors_db->table_name;
190 190
 		$tables[] = $donor_meta_db->table_name;
191 191
 	}
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 
196 196
 }
197 197
 
198
-add_filter( 'wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2 );
198
+add_filter('wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2);
199 199
 
200 200
 /**
201 201
  * Post-installation
@@ -207,16 +207,16 @@  discard block
 block discarded – undo
207 207
  */
208 208
 function give_after_install() {
209 209
 
210
-	if ( ! is_admin() ) {
210
+	if ( ! is_admin()) {
211 211
 		return;
212 212
 	}
213 213
 
214
-	$give_options     = Give_Cache::get( '_give_installed', true );
215
-	$give_table_check = get_option( '_give_table_check', false );
214
+	$give_options     = Give_Cache::get('_give_installed', true);
215
+	$give_table_check = get_option('_give_table_check', false);
216 216
 
217
-	if ( false === $give_table_check || current_time( 'timestamp' ) > $give_table_check ) {
217
+	if (false === $give_table_check || current_time('timestamp') > $give_table_check) {
218 218
 
219
-		if ( ! @Give()->donor_meta->installed() ) {
219
+		if ( ! @Give()->donor_meta->installed()) {
220 220
 
221 221
 			// Create the donor meta database.
222 222
 			// (this ensures it creates it on multisite instances where it is network activated).
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 
225 225
 		}
226 226
 
227
-		if ( ! @Give()->donors->installed() ) {
227
+		if ( ! @Give()->donors->installed()) {
228 228
 			// Create the donor database.
229 229
 			// (this ensures it creates it on multisite instances where it is network activated).
230 230
 			@Give()->donors->create_table();
@@ -236,22 +236,22 @@  discard block
 block discarded – undo
236 236
 			 *
237 237
 			 * @param array $give_options Give plugin options.
238 238
 			 */
239
-			do_action( 'give_after_install', $give_options );
239
+			do_action('give_after_install', $give_options);
240 240
 		}
241 241
 
242
-		update_option( '_give_table_check', ( current_time( 'timestamp' ) + WEEK_IN_SECONDS ) );
242
+		update_option('_give_table_check', (current_time('timestamp') + WEEK_IN_SECONDS));
243 243
 
244 244
 	}
245 245
 
246 246
 	// Delete the transient
247
-	if ( false !== $give_options ) {
248
-		Give_Cache::delete( Give_Cache::get_key( '_give_installed' ) );
247
+	if (false !== $give_options) {
248
+		Give_Cache::delete(Give_Cache::get_key('_give_installed'));
249 249
 	}
250 250
 
251 251
 
252 252
 }
253 253
 
254
-add_action( 'admin_init', 'give_after_install' );
254
+add_action('admin_init', 'give_after_install');
255 255
 
256 256
 
257 257
 /**
@@ -266,11 +266,11 @@  discard block
 block discarded – undo
266 266
 
267 267
 	global $wp_roles;
268 268
 
269
-	if ( ! is_object( $wp_roles ) ) {
269
+	if ( ! is_object($wp_roles)) {
270 270
 		return;
271 271
 	}
272 272
 
273
-	if ( ! array_key_exists( 'give_manager', $wp_roles->roles ) ) {
273
+	if ( ! array_key_exists('give_manager', $wp_roles->roles)) {
274 274
 
275 275
 		// Create Give plugin roles
276 276
 		$roles = new Give_Roles();
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 
282 282
 }
283 283
 
284
-add_action( 'admin_init', 'give_install_roles_on_network' );
284
+add_action('admin_init', 'give_install_roles_on_network');
285 285
 
286 286
 /**
287 287
  * Default core setting values.
@@ -317,14 +317,14 @@  discard block
 block discarded – undo
317 317
 		'uninstall_on_delete'                         => 'disabled',
318 318
 		'the_content_filter'                          => 'enabled',
319 319
 		'scripts_footer'                              => 'disabled',
320
-		'agree_to_terms_label'                        => __( 'Agree to Terms?', 'give' ),
320
+		'agree_to_terms_label'                        => __('Agree to Terms?', 'give'),
321 321
 		'agreement_text'                              => give_get_default_agreement_text(),
322 322
 
323 323
 		// Paypal IPN verification.
324 324
 		'paypal_verification'                         => 'enabled',
325 325
 
326 326
 		// Default is manual gateway.
327
-		'gateways'                                    => array( 'manual' => 1, 'offline' => 1 ),
327
+		'gateways'                                    => array('manual' => 1, 'offline' => 1),
328 328
 		'default_gateway'                             => 'manual',
329 329
 
330 330
 		// Offline gateway setup.
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
  */
350 350
 function give_get_default_agreement_text() {
351 351
 
352
-	$org_name = get_bloginfo( 'name' );
352
+	$org_name = get_bloginfo('name');
353 353
 
354 354
 	$agreement = sprintf(
355 355
 		'<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>
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 		$org_name
364 364
 	);
365 365
 
366
-	return apply_filters( 'give_get_default_agreement_text', $agreement, $org_name );
366
+	return apply_filters('give_get_default_agreement_text', $agreement, $org_name);
367 367
 }
368 368
 
369 369
 
@@ -372,22 +372,22 @@  discard block
 block discarded – undo
372 372
  *
373 373
  * @since 1.8.11
374 374
  */
375
-function give_create_pages(){
375
+function give_create_pages() {
376 376
 
377 377
 	// Bailout if pages already created.
378
-	if( get_option( 'give_install_pages_created') ) {
378
+	if (get_option('give_install_pages_created')) {
379 379
 		return false;
380 380
 	}
381 381
 
382 382
 	$options = array();
383 383
 
384 384
 	// Checks if the Success Page option exists AND that the page exists.
385
-	if ( ! get_post( give_get_option( 'success_page' ) ) ) {
385
+	if ( ! get_post(give_get_option('success_page'))) {
386 386
 
387 387
 		// Donation Confirmation (Success) Page
388 388
 		$success = wp_insert_post(
389 389
 			array(
390
-				'post_title'     => esc_html__( 'Donation Confirmation', 'give' ),
390
+				'post_title'     => esc_html__('Donation Confirmation', 'give'),
391 391
 				'post_content'   => '[give_receipt]',
392 392
 				'post_status'    => 'publish',
393 393
 				'post_author'    => 1,
@@ -401,13 +401,13 @@  discard block
 block discarded – undo
401 401
 	}
402 402
 
403 403
 	// Checks if the Failure Page option exists AND that the page exists.
404
-	if ( ! get_post( give_get_option( 'failure_page' ) ) ) {
404
+	if ( ! get_post(give_get_option('failure_page'))) {
405 405
 
406 406
 		// Failed Donation Page
407 407
 		$failed = wp_insert_post(
408 408
 			array(
409
-				'post_title'     => esc_html__( 'Donation Failed', 'give' ),
410
-				'post_content'   => esc_html__( 'We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give' ),
409
+				'post_title'     => esc_html__('Donation Failed', 'give'),
410
+				'post_content'   => esc_html__('We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give'),
411 411
 				'post_status'    => 'publish',
412 412
 				'post_author'    => 1,
413 413
 				'post_type'      => 'page',
@@ -419,11 +419,11 @@  discard block
 block discarded – undo
419 419
 	}
420 420
 
421 421
 	// Checks if the History Page option exists AND that the page exists.
422
-	if ( ! get_post( give_get_option( 'history_page' ) ) ) {
422
+	if ( ! get_post(give_get_option('history_page'))) {
423 423
 		// Donation History Page
424 424
 		$history = wp_insert_post(
425 425
 			array(
426
-				'post_title'     => esc_html__( 'Donation History', 'give' ),
426
+				'post_title'     => esc_html__('Donation History', 'give'),
427 427
 				'post_content'   => '[donation_history]',
428 428
 				'post_status'    => 'publish',
429 429
 				'post_author'    => 1,
@@ -435,10 +435,10 @@  discard block
 block discarded – undo
435 435
 		$options['history_page'] = $history;
436 436
 	}
437 437
 
438
-	if( ! empty( $options ) ) {
439
-		update_option( 'give_settings', array_merge( give_get_settings(), $options ) );
438
+	if ( ! empty($options)) {
439
+		update_option('give_settings', array_merge(give_get_settings(), $options));
440 440
 	}
441 441
 
442
-	add_option( 'give_install_pages_created', 1, '', 'no' );
442
+	add_option('give_install_pages_created', 1, '', 'no');
443 443
 }
444
-add_action( 'admin_init', 'give_create_pages', -1 );
444
+add_action('admin_init', 'give_create_pages', -1);
Please login to merge, or discard this patch.
includes/process-donation.php 1 patch
Spacing   +248 added lines, -249 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,20 +97,19 @@  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'] ) ?
103
-		(float) apply_filters( 'give_donation_total', give_maybe_sanitize_amount( $_POST['give-amount'] ) ) :
104
-		'0.00';
105
-	$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']) ?
103
+		(float) apply_filters('give_donation_total', give_maybe_sanitize_amount($_POST['give-amount'])) : '0.00';
104
+	$purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true)));
106 105
 
107 106
 	// Setup donation information
108 107
 	$donation_data = array(
109 108
 		'price'        => $price,
110 109
 		'purchase_key' => $purchase_key,
111 110
 		'user_email'   => $user['user_email'],
112
-		'date'         => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ),
113
-		'user_info'    => stripslashes_deep( $user_info ),
111
+		'date'         => date('Y-m-d H:i:s', current_time('timestamp')),
112
+		'user_info'    => stripslashes_deep($user_info),
114 113
 		'post_data'    => $_POST,
115 114
 		'gateway'      => $valid_data['gateway'],
116 115
 		'card_info'    => $valid_data['cc_info'],
@@ -130,10 +129,10 @@  discard block
 block discarded – undo
130 129
 	 * @param array $user_info Array containing basic user information.
131 130
 	 * @param bool|array $valid_data Validate fields.
132 131
 	 */
133
-	do_action( 'give_checkout_before_gateway', $_POST, $user_info, $valid_data );
132
+	do_action('give_checkout_before_gateway', $_POST, $user_info, $valid_data);
134 133
 
135 134
 	// Sanity check for price
136
-	if ( ! $donation_data['price'] ) {
135
+	if ( ! $donation_data['price']) {
137 136
 		// Revert to manual
138 137
 		$donation_data['gateway'] = 'manual';
139 138
 		$_POST['give-gateway']    = 'manual';
@@ -144,27 +143,27 @@  discard block
 block discarded – undo
144 143
 	 *
145 144
 	 * @since 1.7
146 145
 	 */
147
-	$donation_data = apply_filters( 'give_donation_data_before_gateway', $donation_data, $valid_data );
146
+	$donation_data = apply_filters('give_donation_data_before_gateway', $donation_data, $valid_data);
148 147
 
149 148
 	// Setup the data we're storing in the donation session
150 149
 	$session_data = $donation_data;
151 150
 
152 151
 	// Make sure credit card numbers are never stored in sessions
153
-	unset( $session_data['card_info']['card_number'] );
154
-	unset( $session_data['post_data']['card_number'] );
152
+	unset($session_data['card_info']['card_number']);
153
+	unset($session_data['post_data']['card_number']);
155 154
 
156 155
 	// Used for showing data to non logged-in users after donation, and for other plugins needing donation data.
157
-	give_set_purchase_session( $session_data );
156
+	give_set_purchase_session($session_data);
158 157
 
159 158
 	// Send info to the gateway for payment processing
160
-	give_send_to_gateway( $donation_data['gateway'], $donation_data );
159
+	give_send_to_gateway($donation_data['gateway'], $donation_data);
161 160
 	give_die();
162 161
 
163 162
 }
164 163
 
165
-add_action( 'give_purchase', 'give_process_donation_form' );
166
-add_action( 'wp_ajax_give_process_donation', 'give_process_donation_form' );
167
-add_action( 'wp_ajax_nopriv_give_process_donation', 'give_process_donation_form' );
164
+add_action('give_purchase', 'give_process_donation_form');
165
+add_action('wp_ajax_give_process_donation', 'give_process_donation_form');
166
+add_action('wp_ajax_nopriv_give_process_donation', 'give_process_donation_form');
168 167
 
169 168
 
170 169
 /**
@@ -177,29 +176,29 @@  discard block
 block discarded – undo
177 176
  *
178 177
  * @return void
179 178
  */
180
-function give_check_logged_in_user_for_existing_email( $valid_data, $post ) {
179
+function give_check_logged_in_user_for_existing_email($valid_data, $post) {
181 180
 
182 181
 	// Verify that the email address belongs to this customer.
183
-	if ( is_user_logged_in() ) {
182
+	if (is_user_logged_in()) {
184 183
 
185
-		$submitted_email    = $valid_data['logged_in_user']['user_email'];
186
-		$customer = new Give_Donor( get_current_user_id(), true );
184
+		$submitted_email = $valid_data['logged_in_user']['user_email'];
185
+		$customer = new Give_Donor(get_current_user_id(), true);
187 186
 
188 187
 		// If this email address is not registered with this customer, see if it belongs to any other customer
189 188
 		if (
190 189
 			$submitted_email !== $customer->email
191
-			&& ( is_array( $customer->emails ) && ! in_array( $submitted_email, $customer->emails ) )
190
+			&& (is_array($customer->emails) && ! in_array($submitted_email, $customer->emails))
192 191
 		) {
193
-			$found_customer = new Give_Donor( $submitted_email );
192
+			$found_customer = new Give_Donor($submitted_email);
194 193
 
195
-			if ( $found_customer->id > 0 ) {
196
-				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 ) );
194
+			if ($found_customer->id > 0) {
195
+				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));
197 196
 			}
198 197
 		}
199 198
 	}
200 199
 }
201 200
 
202
-add_action( 'give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 2 );
201
+add_action('give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 2);
203 202
 
204 203
 /**
205 204
  * Process the checkout login form
@@ -209,49 +208,49 @@  discard block
 block discarded – undo
209 208
  * @return      void
210 209
  */
211 210
 function give_process_form_login() {
212
-	$is_ajax = isset( $_POST['give_ajax'] );
211
+	$is_ajax = isset($_POST['give_ajax']);
213 212
 
214 213
 	$user_data = give_donation_form_validate_user_login();
215 214
 
216
-	if ( give_get_errors() || $user_data['user_id'] < 1 ) {
217
-		if ( $is_ajax ) {
215
+	if (give_get_errors() || $user_data['user_id'] < 1) {
216
+		if ($is_ajax) {
218 217
 			/**
219 218
 			 * Fires when AJAX sends back errors from the donation form.
220 219
 			 *
221 220
 			 * @since 1.0
222 221
 			 */
223 222
 			ob_start();
224
-				do_action( 'give_ajax_donation_errors' );
223
+				do_action('give_ajax_donation_errors');
225 224
 				$message = ob_get_contents();
226 225
 			ob_end_clean();
227
-			wp_send_json_error( $message );
226
+			wp_send_json_error($message);
228 227
 		} else {
229
-			wp_redirect( $_SERVER['HTTP_REFERER'] );
228
+			wp_redirect($_SERVER['HTTP_REFERER']);
230 229
 			exit;
231 230
 		}
232 231
 	}
233 232
 
234
-	give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] );
233
+	give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']);
235 234
 
236
-	if ( $is_ajax ) {
235
+	if ($is_ajax) {
237 236
 		$message = Give()->notices->print_frontend_notice(
238 237
 			sprintf(
239 238
 				/* translators: %s: user first name */
240
-				esc_html__( 'Welcome %s! You have successfully logged into your account.', 'give' ),
241
-				( ! empty( $user_data['user_first'] ) ) ? $user_data['user_first'] : $user_data['user_login']
239
+				esc_html__('Welcome %s! You have successfully logged into your account.', 'give'),
240
+				( ! empty($user_data['user_first'])) ? $user_data['user_first'] : $user_data['user_login']
242 241
 			),
243 242
 			false,
244 243
 			'success'
245 244
 		);
246 245
 
247
-		wp_send_json_success( $message );
246
+		wp_send_json_success($message);
248 247
 	} else {
249
-		wp_redirect( $_SERVER['HTTP_REFERER'] );
248
+		wp_redirect($_SERVER['HTTP_REFERER']);
250 249
 	}
251 250
 }
252 251
 
253
-add_action( 'wp_ajax_give_process_donation_login', 'give_process_form_login' );
254
-add_action( 'wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login' );
252
+add_action('wp_ajax_give_process_donation_login', 'give_process_form_login');
253
+add_action('wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login');
255 254
 
256 255
 /**
257 256
  * Donation Form Validate Fields.
@@ -263,55 +262,55 @@  discard block
 block discarded – undo
263 262
 function give_donation_form_validate_fields() {
264 263
 
265 264
 	// Check if there is $_POST
266
-	if ( empty( $_POST ) ) {
265
+	if (empty($_POST)) {
267 266
 		return false;
268 267
 	}
269 268
 
270
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
269
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
271 270
 
272 271
 	// Start an array to collect valid data
273 272
 	$valid_data = array(
274 273
 		'gateway'          => give_donation_form_validate_gateway(), // Gateway fallback (amount is validated here)
275
-		'need_new_user'    => false,     // New user flag
276
-		'need_user_login'  => false,     // Login user flag
277
-		'logged_user_data' => array(),   // Logged user collected data
278
-		'new_user_data'    => array(),   // New user collected data
279
-		'login_user_data'  => array(),   // Login user collected data
280
-		'guest_user_data'  => array(),   // Guest user collected data
281
-		'cc_info'          => give_donation_form_validate_cc(),// Credit card info
274
+		'need_new_user'    => false, // New user flag
275
+		'need_user_login'  => false, // Login user flag
276
+		'logged_user_data' => array(), // Logged user collected data
277
+		'new_user_data'    => array(), // New user collected data
278
+		'login_user_data'  => array(), // Login user collected data
279
+		'guest_user_data'  => array(), // Guest user collected data
280
+		'cc_info'          => give_donation_form_validate_cc(), // Credit card info
282 281
 	);
283 282
 
284 283
 	// Validate Honeypot First
285
-	if ( ! empty( $_POST['give-honeypot'] ) ) {
286
-		give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) );
284
+	if ( ! empty($_POST['give-honeypot'])) {
285
+		give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give'));
287 286
 	}
288 287
 
289 288
 	// Validate agree to terms
290
-	if ( give_is_terms_enabled( $form_id ) ) {
289
+	if (give_is_terms_enabled($form_id)) {
291 290
 		give_donation_form_validate_agree_to_terms();
292 291
 	}
293 292
 
294 293
 	// Stop processing donor registration, if donor registration is optional and donor can do guest checkout.
295 294
 	// If registration form username field is empty that means donor do not want to registration instead want guest checkout.
296 295
 	if (
297
-		! give_logged_in_only( $form_id )
298
-		&& isset( $_POST['give-purchase-var'] )
296
+		! give_logged_in_only($form_id)
297
+		&& isset($_POST['give-purchase-var'])
299 298
 		&& $_POST['give-purchase-var'] == 'needs-to-register'
300
-		&& empty( $_POST['give_user_login'] )
299
+		&& empty($_POST['give_user_login'])
301 300
 	) {
302
-		unset( $_POST['give-purchase-var'] );
301
+		unset($_POST['give-purchase-var']);
303 302
 	}
304 303
 
305
-	if ( is_user_logged_in() ) {
304
+	if (is_user_logged_in()) {
306 305
 		// Collect logged in user data.
307 306
 		$valid_data['logged_in_user'] = give_donation_form_validate_logged_in_user();
308
-	} elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' ) {
307
+	} elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register') {
309 308
 		// Set new user registration as required.
310 309
 		$valid_data['need_new_user'] = true;
311 310
 		// Validate new user data.
312 311
 		$valid_data['new_user_data'] = give_donation_form_validate_new_user();
313 312
 		// Check if login validation is needed.
314
-	} elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) {
313
+	} elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') {
315 314
 		// Set user login as required.
316 315
 		$valid_data['need_user_login'] = true;
317 316
 		// Validate users login info.
@@ -336,41 +335,41 @@  discard block
 block discarded – undo
336 335
  */
337 336
 function give_donation_form_validate_gateway() {
338 337
 
339
-	$form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0;
340
-	$amount  = isset( $_REQUEST['give-amount'] ) ? give_maybe_sanitize_amount( $_REQUEST['give-amount'] ) : 0;
341
-	$gateway = give_get_default_gateway( $form_id );
338
+	$form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;
339
+	$amount  = isset($_REQUEST['give-amount']) ? give_maybe_sanitize_amount($_REQUEST['give-amount']) : 0;
340
+	$gateway = give_get_default_gateway($form_id);
342 341
 
343 342
 	// Check if a gateway value is present.
344
-	if ( ! empty( $_REQUEST['give-gateway'] ) ) {
343
+	if ( ! empty($_REQUEST['give-gateway'])) {
345 344
 
346
-		$gateway = sanitize_text_field( $_REQUEST['give-gateway'] );
345
+		$gateway = sanitize_text_field($_REQUEST['give-gateway']);
347 346
 
348 347
 		// Is amount being donated in LIVE mode 0.00? If so, error:
349
-		if ( $amount == 0 && ! give_is_test_mode() ) {
348
+		if ($amount == 0 && ! give_is_test_mode()) {
350 349
 
351
-			give_set_error( 'invalid_donation_amount', __( 'Please insert a valid donation amount.', 'give' ) );
350
+			give_set_error('invalid_donation_amount', __('Please insert a valid donation amount.', 'give'));
352 351
 
353 352
 		} // End if().
354
-		elseif ( ! give_verify_minimum_price() ) {
353
+		elseif ( ! give_verify_minimum_price()) {
355 354
 			// translators: %s: minimum donation amount.
356 355
 			give_set_error(
357 356
 				'invalid_donation_minimum',
358 357
 				sprintf(
359 358
 					/* translators: %s: minimum donation amount */
360
-					__( 'This form has a minimum donation amount of %s.', 'give' ),
361
-					give_currency_filter( give_format_amount( give_get_form_minimum_price( $form_id ), array( 'sanitize' => false ) ) )
359
+					__('This form has a minimum donation amount of %s.', 'give'),
360
+					give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id), array('sanitize' => false)))
362 361
 				)
363 362
 			);
364 363
 
365 364
 		} //Is this test mode zero donation? Let it through but set to manual gateway.
366
-		elseif ( $amount == 0 && give_is_test_mode() ) {
365
+		elseif ($amount == 0 && give_is_test_mode()) {
367 366
 
368 367
 			$gateway = 'manual';
369 368
 
370 369
 		} //Check if this gateway is active.
371
-		elseif ( ! give_is_gateway_active( $gateway ) ) {
370
+		elseif ( ! give_is_gateway_active($gateway)) {
372 371
 
373
-			give_set_error( 'invalid_gateway', __( 'The selected payment gateway is not enabled.', 'give' ) );
372
+			give_set_error('invalid_gateway', __('The selected payment gateway is not enabled.', 'give'));
374 373
 
375 374
 		}
376 375
 	}
@@ -388,21 +387,21 @@  discard block
 block discarded – undo
388 387
  */
389 388
 function give_verify_minimum_price() {
390 389
 
391
-	$amount          = give_maybe_sanitize_amount( $_REQUEST['give-amount'] );
392
-	$form_id         = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0;
393
-	$price_id        = isset( $_REQUEST['give-price-id'] ) ? $_REQUEST['give-price-id'] : null;
394
-	$variable_prices = give_has_variable_prices( $form_id );
390
+	$amount          = give_maybe_sanitize_amount($_REQUEST['give-amount']);
391
+	$form_id         = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;
392
+	$price_id        = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : null;
393
+	$variable_prices = give_has_variable_prices($form_id);
395 394
 
396
-	if ( $variable_prices && in_array( $price_id, give_get_variable_price_ids( $form_id ) ) ) {
395
+	if ($variable_prices && in_array($price_id, give_get_variable_price_ids($form_id))) {
397 396
 
398
-		$price_level_amount = give_get_price_option_amount( $form_id, $price_id );
397
+		$price_level_amount = give_get_price_option_amount($form_id, $price_id);
399 398
 
400
-		if ( $price_level_amount == $amount ) {
399
+		if ($price_level_amount == $amount) {
401 400
 			return true;
402 401
 		}
403 402
 	}
404 403
 
405
-	if ( give_get_form_minimum_price( $form_id ) > $amount ) {
404
+	if (give_get_form_minimum_price($form_id) > $amount) {
406 405
 		return false;
407 406
 	}
408 407
 
@@ -418,9 +417,9 @@  discard block
 block discarded – undo
418 417
  */
419 418
 function give_donation_form_validate_agree_to_terms() {
420 419
 	// Validate agree to terms.
421
-	if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) {
420
+	if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) {
422 421
 		// User did not agree.
423
-		give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', __( 'You must agree to the terms and conditions.', 'give' ) ) );
422
+		give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', __('You must agree to the terms and conditions.', 'give')));
424 423
 	}
425 424
 }
426 425
 
@@ -434,59 +433,59 @@  discard block
 block discarded – undo
434 433
  *
435 434
  * @return      array
436 435
  */
437
-function give_get_required_fields( $form_id ) {
436
+function give_get_required_fields($form_id) {
438 437
 
439
-	$payment_mode = give_get_chosen_gateway( $form_id );
438
+	$payment_mode = give_get_chosen_gateway($form_id);
440 439
 
441 440
 	$required_fields = array(
442 441
 		'give_email' => array(
443 442
 			'error_id'      => 'invalid_email',
444
-			'error_message' => __( 'Please enter a valid email address.', 'give' ),
443
+			'error_message' => __('Please enter a valid email address.', 'give'),
445 444
 		),
446 445
 		'give_first' => array(
447 446
 			'error_id'      => 'invalid_first_name',
448
-			'error_message' => __( 'Please enter your first name.', 'give' ),
447
+			'error_message' => __('Please enter your first name.', 'give'),
449 448
 		),
450 449
 	);
451 450
 
452
-	$require_address = give_require_billing_address( $payment_mode );
451
+	$require_address = give_require_billing_address($payment_mode);
453 452
 
454
-	if ( $require_address ) {
455
-		$required_fields['card_address']    = array(
453
+	if ($require_address) {
454
+		$required_fields['card_address'] = array(
456 455
 			'error_id'      => 'invalid_card_address',
457
-			'error_message' => __( 'Please enter your primary billing address.', 'give' ),
456
+			'error_message' => __('Please enter your primary billing address.', 'give'),
458 457
 		);
459
-		$required_fields['card_zip']        = array(
458
+		$required_fields['card_zip'] = array(
460 459
 			'error_id'      => 'invalid_zip_code',
461
-			'error_message' => __( 'Please enter your zip / postal code.', 'give' ),
460
+			'error_message' => __('Please enter your zip / postal code.', 'give'),
462 461
 		);
463
-		$required_fields['card_city']       = array(
462
+		$required_fields['card_city'] = array(
464 463
 			'error_id'      => 'invalid_city',
465
-			'error_message' => __( 'Please enter your billing city.', 'give' ),
464
+			'error_message' => __('Please enter your billing city.', 'give'),
466 465
 		);
467 466
 		$required_fields['billing_country'] = array(
468 467
 			'error_id'      => 'invalid_country',
469
-			'error_message' => __( 'Please select your billing country.', 'give' ),
468
+			'error_message' => __('Please select your billing country.', 'give'),
470 469
 		);
471 470
 
472 471
 
473
-		$required_fields['card_state']      = array(
472
+		$required_fields['card_state'] = array(
474 473
 			'error_id'      => 'invalid_state',
475
-			'error_message' => __( 'Please enter billing state / province / County.', 'give' ),
474
+			'error_message' => __('Please enter billing state / province / County.', 'give'),
476 475
 		);
477 476
 
478 477
 		// Check if billing country alredy exists.
479
-		if ( ! empty( $_POST['billing_country'] ) ) {
478
+		if ( ! empty($_POST['billing_country'])) {
480 479
 			// Get the value from $_POST.
481
-			$country = sanitize_text_field( $_POST['billing_country'] );
480
+			$country = sanitize_text_field($_POST['billing_country']);
482 481
 
483 482
 			// Get the country list that does not required any states init.
484 483
 			$states_country = give_states_not_required_country_list();
485 484
 
486 485
 			// Check if states is empty or not.
487
-			if ( array_key_exists( $country, $states_country ) ) {
486
+			if (array_key_exists($country, $states_country)) {
488 487
 				// If states is empty remove the required feilds of state in billing cart.
489
-				unset( $required_fields['card_state'] );
488
+				unset($required_fields['card_state']);
490 489
 			}
491 490
 		}
492 491
 	}
@@ -496,7 +495,7 @@  discard block
 block discarded – undo
496 495
 	 *
497 496
 	 * @since 1.7
498 497
 	 */
499
-	$required_fields = apply_filters( 'give_donation_form_required_fields', $required_fields, $form_id );
498
+	$required_fields = apply_filters('give_donation_form_required_fields', $required_fields, $form_id);
500 499
 
501 500
 	return $required_fields;
502 501
 
@@ -511,16 +510,16 @@  discard block
 block discarded – undo
511 510
  *
512 511
  * @return bool
513 512
  */
514
-function give_require_billing_address( $payment_mode ) {
513
+function give_require_billing_address($payment_mode) {
515 514
 
516 515
 	$return = false;
517 516
 
518
-	if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) {
517
+	if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) {
519 518
 		$return = true;
520 519
 	}
521 520
 
522 521
 	// Let payment gateways and other extensions determine if address fields should be required.
523
-	return apply_filters( 'give_require_billing_address', $return );
522
+	return apply_filters('give_require_billing_address', $return);
524 523
 
525 524
 }
526 525
 
@@ -534,42 +533,42 @@  discard block
 block discarded – undo
534 533
 function give_donation_form_validate_logged_in_user() {
535 534
 	global $user_ID;
536 535
 
537
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
536
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
538 537
 
539 538
 	// Start empty array to collect valid user data.
540 539
 	$valid_user_data = array(
541 540
 		// Assume there will be errors.
542
-		'user_id' => - 1,
541
+		'user_id' => -1,
543 542
 	);
544 543
 
545 544
 	// Verify there is a user_ID.
546
-	if ( $user_ID > 0 ) {
545
+	if ($user_ID > 0) {
547 546
 		// Get the logged in user data.
548
-		$user_data = get_userdata( $user_ID );
547
+		$user_data = get_userdata($user_ID);
549 548
 
550 549
 		// Loop through required fields and show error messages.
551
-		foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) {
552
-			if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
553
-				give_set_error( $value['error_id'], $value['error_message'] );
550
+		foreach (give_get_required_fields($form_id) as $field_name => $value) {
551
+			if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) {
552
+				give_set_error($value['error_id'], $value['error_message']);
554 553
 			}
555 554
 		}
556 555
 
557 556
 		// Verify data.
558
-		if ( $user_data ) {
557
+		if ($user_data) {
559 558
 			// Collected logged in user data.
560 559
 			$valid_user_data = array(
561 560
 				'user_id'    => $user_ID,
562
-				'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email,
563
-				'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name,
564
-				'user_last'  => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name,
561
+				'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email,
562
+				'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name,
563
+				'user_last'  => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name,
565 564
 			);
566 565
 
567
-			if ( ! is_email( $valid_user_data['user_email'] ) ) {
568
-				give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
566
+			if ( ! is_email($valid_user_data['user_email'])) {
567
+				give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
569 568
 			}
570 569
 		} else {
571 570
 			// Set invalid user error.
572
-			give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) );
571
+			give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give'));
573 572
 		}
574 573
 	}
575 574
 
@@ -588,7 +587,7 @@  discard block
 block discarded – undo
588 587
 	// Default user data.
589 588
 	$default_user_data = array(
590 589
 		'give-form-id'           => '',
591
-		'user_id'                => - 1, // Assume there will be errors.
590
+		'user_id'                => -1, // Assume there will be errors.
592 591
 		'user_first'             => '',
593 592
 		'user_last'              => '',
594 593
 		'give_user_login'        => false,
@@ -598,14 +597,14 @@  discard block
 block discarded – undo
598 597
 	);
599 598
 
600 599
 	// Get user data.
601
-	$user_data            = wp_parse_args( array_map( 'trim', give_clean( $_POST ) ), $default_user_data );
600
+	$user_data            = wp_parse_args(array_map('trim', give_clean($_POST)), $default_user_data);
602 601
 	$registering_new_user = false;
603
-	$form_id              = absint( $user_data['give-form-id'] );
602
+	$form_id              = absint($user_data['give-form-id']);
604 603
 
605 604
 	// Start an empty array to collect valid user data.
606 605
 	$valid_user_data = array(
607 606
 		// Assume there will be errors.
608
-		'user_id'    => - 1,
607
+		'user_id'    => -1,
609 608
 
610 609
 		// Get first name.
611 610
 		'user_first' => $user_data['give_first'],
@@ -615,25 +614,25 @@  discard block
 block discarded – undo
615 614
 	);
616 615
 
617 616
 	// Loop through required fields and show error messages.
618
-	foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) {
619
-		if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
620
-			give_set_error( $value['error_id'], $value['error_message'] );
617
+	foreach (give_get_required_fields($form_id) as $field_name => $value) {
618
+		if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) {
619
+			give_set_error($value['error_id'], $value['error_message']);
621 620
 		}
622 621
 	}
623 622
 
624 623
 	// Check if we have an username to register.
625
-	if ( give_validate_username( $user_data['give_user_login'] ) ) {
624
+	if (give_validate_username($user_data['give_user_login'])) {
626 625
 		$registering_new_user          = true;
627 626
 		$valid_user_data['user_login'] = $user_data['give_user_login'];
628 627
 	}
629 628
 
630 629
 	// Check if we have an email to verify.
631
-	if ( give_validate_user_email( $user_data['give_email'], $registering_new_user ) ) {
630
+	if (give_validate_user_email($user_data['give_email'], $registering_new_user)) {
632 631
 		$valid_user_data['user_email'] = $user_data['give_email'];
633 632
 	}
634 633
 
635 634
 	// Check password.
636
-	if ( give_validate_user_password( $user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user ) ) {
635
+	if (give_validate_user_password($user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user)) {
637 636
 		// All is good to go.
638 637
 		$valid_user_data['user_pass'] = $user_data['give_user_pass'];
639 638
 	}
@@ -653,36 +652,36 @@  discard block
 block discarded – undo
653 652
 	// Start an array to collect valid user data.
654 653
 	$valid_user_data = array(
655 654
 		// Assume there will be errors.
656
-		'user_id' => - 1,
655
+		'user_id' => -1,
657 656
 	);
658 657
 
659 658
 	// Username.
660
-	if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) {
661
-		give_set_error( 'must_log_in', __( 'You must register or login to complete your donation.', 'give' ) );
659
+	if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') {
660
+		give_set_error('must_log_in', __('You must register or login to complete your donation.', 'give'));
662 661
 
663 662
 		return $valid_user_data;
664 663
 	}
665 664
 
666 665
 	// Get the user by login.
667
-	$user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) );
666
+	$user_data = get_user_by('login', strip_tags($_POST['give_user_login']));
668 667
 
669 668
 	// Check if user exists.
670
-	if ( $user_data ) {
669
+	if ($user_data) {
671 670
 		// Get password.
672
-		$user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false;
671
+		$user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false;
673 672
 
674 673
 		// Check user_pass.
675
-		if ( $user_pass ) {
674
+		if ($user_pass) {
676 675
 			// Check if password is valid.
677
-			if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) {
676
+			if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) {
678 677
 				// Incorrect password.
679 678
 				give_set_error(
680 679
 					'password_incorrect',
681 680
 					sprintf(
682 681
 						'%1$s <a href="%2$s">%3$s</a>',
683
-						__( 'The password you entered is incorrect.', 'give' ),
684
-						wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ),
685
-						__( 'Reset Password', 'give' )
682
+						__('The password you entered is incorrect.', 'give'),
683
+						wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"),
684
+						__('Reset Password', 'give')
686 685
 					)
687 686
 				);
688 687
 				// All is correct.
@@ -699,11 +698,11 @@  discard block
 block discarded – undo
699 698
 			}
700 699
 		} else {
701 700
 			// Empty password.
702
-			give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) );
701
+			give_set_error('password_empty', __('Enter a password.', 'give'));
703 702
 		}
704 703
 	} else {
705 704
 		// No username.
706
-		give_set_error( 'username_incorrect', __( 'The username you entered does not exist.', 'give' ) );
705
+		give_set_error('username_incorrect', __('The username you entered does not exist.', 'give'));
707 706
 	}// End if().
708 707
 
709 708
 	return $valid_user_data;
@@ -718,7 +717,7 @@  discard block
 block discarded – undo
718 717
  */
719 718
 function give_donation_form_validate_guest_user() {
720 719
 
721
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
720
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
722 721
 
723 722
 	// Start an array to collect valid user data.
724 723
 	$valid_user_data = array(
@@ -727,38 +726,38 @@  discard block
 block discarded – undo
727 726
 	);
728 727
 
729 728
 	// Show error message if user must be logged in.
730
-	if ( give_logged_in_only( $form_id ) ) {
731
-		give_set_error( 'logged_in_only', __( 'You must be logged in to donate.', 'give' ) );
729
+	if (give_logged_in_only($form_id)) {
730
+		give_set_error('logged_in_only', __('You must be logged in to donate.', 'give'));
732 731
 	}
733 732
 
734 733
 	// Get the guest email.
735
-	$guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false;
734
+	$guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false;
736 735
 
737 736
 	// Check email.
738
-	if ( $guest_email && strlen( $guest_email ) > 0 ) {
737
+	if ($guest_email && strlen($guest_email) > 0) {
739 738
 		// Validate email.
740
-		if ( ! is_email( $guest_email ) ) {
739
+		if ( ! is_email($guest_email)) {
741 740
 			// Invalid email.
742
-			give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) );
741
+			give_set_error('email_invalid', __('Invalid email.', 'give'));
743 742
 		} else {
744 743
 			// All is good to go.
745 744
 			$valid_user_data['user_email'] = $guest_email;
746 745
 
747 746
 			// Get user_id from donor if exist.
748
-			$donor = new Give_Donor( $guest_email );
749
-			if ( $donor->id && $donor->user_id ) {
747
+			$donor = new Give_Donor($guest_email);
748
+			if ($donor->id && $donor->user_id) {
750 749
 				$valid_user_data['user_id'] = $donor->user_id;
751 750
 			}
752 751
 		}
753 752
 	} else {
754 753
 		// No email.
755
-		give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) );
754
+		give_set_error('email_empty', __('Enter an email.', 'give'));
756 755
 	}
757 756
 
758 757
 	// Loop through required fields and show error messages.
759
-	foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) {
760
-		if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
761
-			give_set_error( $value['error_id'], $value['error_message'] );
758
+	foreach (give_get_required_fields($form_id) as $field_name => $value) {
759
+		if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) {
760
+			give_set_error($value['error_id'], $value['error_message']);
762 761
 		}
763 762
 	}
764 763
 
@@ -774,36 +773,36 @@  discard block
 block discarded – undo
774 773
  * @since   1.0
775 774
  * @return  integer
776 775
  */
777
-function give_register_and_login_new_user( $user_data = array() ) {
776
+function give_register_and_login_new_user($user_data = array()) {
778 777
 	// Verify the array.
779
-	if ( empty( $user_data ) ) {
780
-		return - 1;
778
+	if (empty($user_data)) {
779
+		return -1;
781 780
 	}
782 781
 
783
-	if ( give_get_errors() ) {
784
-		return - 1;
782
+	if (give_get_errors()) {
783
+		return -1;
785 784
 	}
786 785
 
787
-	$user_args = apply_filters( 'give_insert_user_args', array(
788
-		'user_login'      => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '',
789
-		'user_pass'       => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '',
790
-		'user_email'      => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '',
791
-		'first_name'      => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '',
792
-		'last_name'       => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '',
793
-		'user_registered' => date( 'Y-m-d H:i:s' ),
794
-		'role'            => get_option( 'default_role' ),
795
-	), $user_data );
786
+	$user_args = apply_filters('give_insert_user_args', array(
787
+		'user_login'      => isset($user_data['user_login']) ? $user_data['user_login'] : '',
788
+		'user_pass'       => isset($user_data['user_pass']) ? $user_data['user_pass'] : '',
789
+		'user_email'      => isset($user_data['user_email']) ? $user_data['user_email'] : '',
790
+		'first_name'      => isset($user_data['user_first']) ? $user_data['user_first'] : '',
791
+		'last_name'       => isset($user_data['user_last']) ? $user_data['user_last'] : '',
792
+		'user_registered' => date('Y-m-d H:i:s'),
793
+		'role'            => get_option('default_role'),
794
+	), $user_data);
796 795
 
797 796
 	// Insert new user.
798
-	$user_id = wp_insert_user( $user_args );
797
+	$user_id = wp_insert_user($user_args);
799 798
 
800 799
 	// Validate inserted user.
801
-	if ( is_wp_error( $user_id ) ) {
802
-		return - 1;
800
+	if (is_wp_error($user_id)) {
801
+		return -1;
803 802
 	}
804 803
 
805 804
 	// Allow themes and plugins to filter the user data.
806
-	$user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args );
805
+	$user_data = apply_filters('give_insert_user_data', $user_data, $user_args);
807 806
 
808 807
 	/**
809 808
 	 * Fires after inserting user.
@@ -813,10 +812,10 @@  discard block
 block discarded – undo
813 812
 	 * @param int $user_id User id.
814 813
 	 * @param array $user_data Array containing user data.
815 814
 	 */
816
-	do_action( 'give_insert_user', $user_id, $user_data );
815
+	do_action('give_insert_user', $user_id, $user_data);
817 816
 
818 817
 	// Login new user.
819
-	give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] );
818
+	give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']);
820 819
 
821 820
 	// Return user id.
822 821
 	return $user_id;
@@ -831,27 +830,27 @@  discard block
 block discarded – undo
831 830
  * @since   1.0
832 831
  * @return  array|bool
833 832
  */
834
-function give_get_donation_form_user( $valid_data = array() ) {
833
+function give_get_donation_form_user($valid_data = array()) {
835 834
 
836 835
 	// Initialize user.
837 836
 	$user    = false;
838
-	$is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
837
+	$is_ajax = defined('DOING_AJAX') && DOING_AJAX;
839 838
 
840
-	if ( $is_ajax ) {
839
+	if ($is_ajax) {
841 840
 		// Do not create or login the user during the ajax submission (check for errors only).
842 841
 		return true;
843
-	} elseif ( is_user_logged_in() ) {
842
+	} elseif (is_user_logged_in()) {
844 843
 		// Set the valid user as the logged in collected data.
845 844
 		$user = $valid_data['logged_in_user'];
846
-	} elseif ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) {
845
+	} elseif ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) {
847 846
 		// New user registration.
848
-		if ( $valid_data['need_new_user'] === true ) {
847
+		if ($valid_data['need_new_user'] === true) {
849 848
 			// Set user.
850 849
 			$user = $valid_data['new_user_data'];
851 850
 			// Register and login new user.
852
-			$user['user_id'] = give_register_and_login_new_user( $user );
851
+			$user['user_id'] = give_register_and_login_new_user($user);
853 852
 			// User login
854
-		} elseif ( $valid_data['need_user_login'] === true && ! $is_ajax ) {
853
+		} elseif ($valid_data['need_user_login'] === true && ! $is_ajax) {
855 854
 
856 855
 			/**
857 856
 			 * The login form is now processed in the give_process_donation_login() function.
@@ -863,48 +862,48 @@  discard block
 block discarded – undo
863 862
 			// Set user.
864 863
 			$user = $valid_data['login_user_data'];
865 864
 			// Login user.
866
-			give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] );
865
+			give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']);
867 866
 		}
868 867
 	}
869 868
 
870 869
 	// Check guest checkout.
871
-	if ( false === $user && false === give_logged_in_only( $_POST['give-form-id'] ) ) {
870
+	if (false === $user && false === give_logged_in_only($_POST['give-form-id'])) {
872 871
 		// Set user
873 872
 		$user = $valid_data['guest_user_data'];
874 873
 	}
875 874
 
876 875
 	// Verify we have an user.
877
-	if ( false === $user || empty( $user ) ) {
876
+	if (false === $user || empty($user)) {
878 877
 		// Return false.
879 878
 		return false;
880 879
 	}
881 880
 
882 881
 	// Get user first name.
883
-	if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) {
884
-		$user['user_first'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : '';
882
+	if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) {
883
+		$user['user_first'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : '';
885 884
 	}
886 885
 
887 886
 	// Get user last name.
888
-	if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) {
889
-		$user['user_last'] = isset( $_POST['give_last'] ) ? strip_tags( trim( $_POST['give_last'] ) ) : '';
887
+	if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) {
888
+		$user['user_last'] = isset($_POST['give_last']) ? strip_tags(trim($_POST['give_last'])) : '';
890 889
 	}
891 890
 
892 891
 	// Get the user's billing address details.
893 892
 	$user['address']            = array();
894
-	$user['address']['line1']   = ! empty( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : false;
895
-	$user['address']['line2']   = ! empty( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : false;
896
-	$user['address']['city']    = ! empty( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : false;
897
-	$user['address']['state']   = ! empty( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : false;
898
-	$user['address']['country'] = ! empty( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : false;
899
-	$user['address']['zip']     = ! empty( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : false;
900
-
901
-	if ( empty( $user['address']['country'] ) ) {
893
+	$user['address']['line1']   = ! empty($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : false;
894
+	$user['address']['line2']   = ! empty($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : false;
895
+	$user['address']['city']    = ! empty($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : false;
896
+	$user['address']['state']   = ! empty($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : false;
897
+	$user['address']['country'] = ! empty($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : false;
898
+	$user['address']['zip']     = ! empty($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : false;
899
+
900
+	if (empty($user['address']['country'])) {
902 901
 		$user['address'] = false;
903 902
 	} // End if().
904 903
 
905
-	if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) {
904
+	if ( ! empty($user['user_id']) && $user['user_id'] > 0 && ! empty($user['address'])) {
906 905
 		// Store the address in the user's meta so the donation form can be pre-populated with it on return donation.
907
-		update_user_meta( $user['user_id'], '_give_user_address', $user['address'] );
906
+		update_user_meta($user['user_id'], '_give_user_address', $user['address']);
908 907
 	}
909 908
 
910 909
 	// Return valid user.
@@ -923,16 +922,16 @@  discard block
 block discarded – undo
923 922
 	$card_data = give_get_donation_cc_info();
924 923
 
925 924
 	// Validate the card zip.
926
-	if ( ! empty( $card_data['card_zip'] ) ) {
927
-		if ( ! give_donation_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) {
928
-			give_set_error( 'invalid_cc_zip', __( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) );
925
+	if ( ! empty($card_data['card_zip'])) {
926
+		if ( ! give_donation_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) {
927
+			give_set_error('invalid_cc_zip', __('The zip / postal code you entered for your billing address is invalid.', 'give'));
929 928
 		}
930 929
 	}
931 930
 
932 931
 	// Ensure no spaces.
933
-	if ( ! empty( $card_data['card_number'] ) ) {
934
-		$card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); // no "+" signs
935
-		$card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces
932
+	if ( ! empty($card_data['card_number'])) {
933
+		$card_data['card_number'] = str_replace('+', '', $card_data['card_number']); // no "+" signs
934
+		$card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces
936 935
 	}
937 936
 
938 937
 	// This should validate card numbers at some point too.
@@ -949,17 +948,17 @@  discard block
 block discarded – undo
949 948
 function give_get_donation_cc_info() {
950 949
 
951 950
 	$cc_info                   = array();
952
-	$cc_info['card_name']      = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : '';
953
-	$cc_info['card_number']    = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : '';
954
-	$cc_info['card_cvc']       = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : '';
955
-	$cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : '';
956
-	$cc_info['card_exp_year']  = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : '';
957
-	$cc_info['card_address']   = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : '';
958
-	$cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : '';
959
-	$cc_info['card_city']      = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : '';
960
-	$cc_info['card_state']     = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : '';
961
-	$cc_info['card_country']   = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : '';
962
-	$cc_info['card_zip']       = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : '';
951
+	$cc_info['card_name']      = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : '';
952
+	$cc_info['card_number']    = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : '';
953
+	$cc_info['card_cvc']       = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : '';
954
+	$cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : '';
955
+	$cc_info['card_exp_year']  = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : '';
956
+	$cc_info['card_address']   = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : '';
957
+	$cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : '';
958
+	$cc_info['card_city']      = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : '';
959
+	$cc_info['card_state']     = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : '';
960
+	$cc_info['card_country']   = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : '';
961
+	$cc_info['card_zip']       = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : '';
963 962
 
964 963
 	// Return cc info.
965 964
 	return $cc_info;
@@ -975,14 +974,14 @@  discard block
 block discarded – undo
975 974
  *
976 975
  * @return bool|mixed
977 976
  */
978
-function give_donation_form_validate_cc_zip( $zip = 0, $country_code = '' ) {
977
+function give_donation_form_validate_cc_zip($zip = 0, $country_code = '') {
979 978
 	$ret = false;
980 979
 
981
-	if ( empty( $zip ) || empty( $country_code ) ) {
980
+	if (empty($zip) || empty($country_code)) {
982 981
 		return $ret;
983 982
 	}
984 983
 
985
-	$country_code = strtoupper( $country_code );
984
+	$country_code = strtoupper($country_code);
986 985
 
987 986
 	$zip_regex = array(
988 987
 		'AD' => 'AD\d{3}',
@@ -1142,11 +1141,11 @@  discard block
 block discarded – undo
1142 1141
 		'ZM' => '\d{5}',
1143 1142
 	);
1144 1143
 
1145
-	if ( ! isset( $zip_regex[ $country_code ] ) || preg_match( '/' . $zip_regex[ $country_code ] . '/i', $zip ) ) {
1144
+	if ( ! isset($zip_regex[$country_code]) || preg_match('/'.$zip_regex[$country_code].'/i', $zip)) {
1146 1145
 		$ret = true;
1147 1146
 	}
1148 1147
 
1149
-	return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code );
1148
+	return apply_filters('give_is_zip_valid', $ret, $zip, $country_code);
1150 1149
 }
1151 1150
 
1152 1151
 
@@ -1160,33 +1159,33 @@  discard block
 block discarded – undo
1160 1159
  *
1161 1160
  * @return bool
1162 1161
  */
1163
-function give_validate_multi_donation_form_level( $valid_data, $data ) {
1162
+function give_validate_multi_donation_form_level($valid_data, $data) {
1164 1163
 	/* @var Give_Donate_Form $form */
1165
-	$form = new Give_Donate_Form( $data['give-form-id'] );
1164
+	$form = new Give_Donate_Form($data['give-form-id']);
1166 1165
 
1167 1166
 	$donation_level_matched = false;
1168 1167
 
1169
-	if ( $form->is_multi_type_donation_form() ) {
1168
+	if ($form->is_multi_type_donation_form()) {
1170 1169
 
1171 1170
 		// Bailout.
1172
-		if ( ! ( $variable_prices = $form->get_prices() ) ) {
1171
+		if ( ! ($variable_prices = $form->get_prices())) {
1173 1172
 			return false;
1174 1173
 		}
1175 1174
 
1176 1175
 		// Sanitize donation amount.
1177
-		$data['give-amount'] = give_maybe_sanitize_amount( $data['give-amount'] );
1176
+		$data['give-amount'] = give_maybe_sanitize_amount($data['give-amount']);
1178 1177
 
1179
-		if ( $data['give-amount'] === give_maybe_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ) ) ) {
1178
+		if ($data['give-amount'] === give_maybe_sanitize_amount(give_get_price_option_amount($data['give-form-id'], $data['give-price-id']))) {
1180 1179
 			return true;
1181 1180
 		}
1182 1181
 
1183 1182
 		// Find correct donation level from all donation levels.
1184
-		foreach ( $variable_prices as $variable_price ) {
1183
+		foreach ($variable_prices as $variable_price) {
1185 1184
 			// Sanitize level amount.
1186
-			$variable_price['_give_amount'] = give_maybe_sanitize_amount( $variable_price['_give_amount'] );
1185
+			$variable_price['_give_amount'] = give_maybe_sanitize_amount($variable_price['_give_amount']);
1187 1186
 
1188 1187
 			// Set first match donation level ID.
1189
-			if ( $data['give-amount'] === $variable_price['_give_amount'] ) {
1188
+			if ($data['give-amount'] === $variable_price['_give_amount']) {
1190 1189
 				$_POST['give-price-id'] = $variable_price['_give_id']['level_id'];
1191 1190
 				$donation_level_matched = true;
1192 1191
 				break;
@@ -1197,19 +1196,19 @@  discard block
 block discarded – undo
1197 1196
 		// If yes then set price id to custom if amount is greater then custom minimum amount (if any).
1198 1197
 		if (
1199 1198
 			! $donation_level_matched
1200
-			&& ( give_is_setting_enabled( give_get_meta( $data['give-form-id'], '_give_custom_amount', true ) ) )
1199
+			&& (give_is_setting_enabled(give_get_meta($data['give-form-id'], '_give_custom_amount', true)))
1201 1200
 		) {
1202 1201
 			// Sanitize custom minimum amount.
1203
-			$custom_minimum_amount = give_maybe_sanitize_amount( give_get_meta( $data['give-form-id'], '_give_custom_amount_minimum', true ) );
1202
+			$custom_minimum_amount = give_maybe_sanitize_amount(give_get_meta($data['give-form-id'], '_give_custom_amount_minimum', true));
1204 1203
 
1205
-			if ( $data['give-amount'] >= $custom_minimum_amount ) {
1204
+			if ($data['give-amount'] >= $custom_minimum_amount) {
1206 1205
 				$_POST['give-price-id'] = 'custom';
1207 1206
 				$donation_level_matched = true;
1208 1207
 			}
1209 1208
 		}
1210 1209
 	}// End if().
1211 1210
 
1212
-	return ( $donation_level_matched ? true : false );
1211
+	return ($donation_level_matched ? true : false);
1213 1212
 }
1214 1213
 
1215
-add_action( 'give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2 );
1214
+add_action('give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2);
Please login to merge, or discard this patch.