Test Failed
Pull Request — master (#2225)
by Devin
04:31
created
includes/class-give-license-handler.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
 		 * @access private
704 704
 		 * @since  1.7
705 705
 		 *
706
-		 * @return bool
706
+		 * @return false|null
707 707
 		 */
708 708
 		private function __remove_license_key_from_subscriptions() {
709 709
 			$subscriptions = get_option( 'give_subscriptions', array() );
@@ -736,7 +736,7 @@  discard block
 block discarded – undo
736 736
 		 * @param $plugin_data
737 737
 		 * @param $status
738 738
 		 *
739
-		 * @return bool
739
+		 * @return false|null
740 740
 		 */
741 741
 		public function plugin_page_notices( $plugin_file, $plugin_data, $status ) {
742 742
 			// Bailout.
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
 		 *
759 759
 		 * @since  1.8.7
760 760
 		 * @access public
761
-		 * @return array
761
+		 * @return string
762 762
 		 */
763 763
 		public function license_state_message() {
764 764
 			$message_data = array();
Please login to merge, or discard this patch.
Spacing   +151 added lines, -151 removed lines patch added patch discarded remove patch
@@ -10,11 +10,11 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
17
-if ( ! class_exists( 'Give_License' ) ) :
17
+if ( ! class_exists('Give_License')) :
18 18
 
19 19
 	/**
20 20
 	 * Give_License Class
@@ -143,27 +143,27 @@  discard block
 block discarded – undo
143 143
 		 * @param string $_checkout_url
144 144
 		 * @param string $_account_url
145 145
 		 */
146
-		public function __construct( $_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null ) {
146
+		public function __construct($_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null) {
147 147
 
148 148
 			$give_options = give_get_settings();
149 149
 
150 150
 			$this->file             = $_file;
151 151
 			$this->item_name        = $_item_name;
152
-			$this->item_shortname   = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $this->item_name ) ) );
152
+			$this->item_shortname   = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($this->item_name)));
153 153
 			$this->version          = $_version;
154
-			$this->license          = isset( $give_options[ $this->item_shortname . '_license_key' ] ) ? trim( $give_options[ $this->item_shortname . '_license_key' ] ) : '';
155
-			$this->license_data     = get_option( $this->item_shortname . '_license_active' );
154
+			$this->license          = isset($give_options[$this->item_shortname.'_license_key']) ? trim($give_options[$this->item_shortname.'_license_key']) : '';
155
+			$this->license_data     = get_option($this->item_shortname.'_license_active');
156 156
 			$this->author           = $_author;
157
-			$this->api_url          = is_null( $_api_url ) ? $this->api_url : $_api_url;
158
-			$this->checkout_url     = is_null( $_checkout_url ) ? $this->checkout_url : $_checkout_url;
159
-			$this->account_url      = is_null( $_account_url ) ? $this->account_url : $_account_url;
157
+			$this->api_url          = is_null($_api_url) ? $this->api_url : $_api_url;
158
+			$this->checkout_url     = is_null($_checkout_url) ? $this->checkout_url : $_checkout_url;
159
+			$this->account_url      = is_null($_account_url) ? $this->account_url : $_account_url;
160 160
 			$this->auto_updater_obj = null;
161 161
 
162 162
 			// Add Setting for Give Add-on activation status.
163
-			$is_addon_activated = get_option( 'give_is_addon_activated' );
164
-			if ( ! $is_addon_activated && is_object( $this ) && sizeof( $this ) > 0 ) {
165
-				update_option( 'give_is_addon_activated', true );
166
-				Give_Cache::set( 'give_cache_hide_license_notice_after_activation', true, DAY_IN_SECONDS );
163
+			$is_addon_activated = get_option('give_is_addon_activated');
164
+			if ( ! $is_addon_activated && is_object($this) && sizeof($this) > 0) {
165
+				update_option('give_is_addon_activated', true);
166
+				Give_Cache::set('give_cache_hide_license_notice_after_activation', true, DAY_IN_SECONDS);
167 167
 			}
168 168
 
169 169
 			// Setup hooks
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 		 */
185 185
 		private function includes() {
186 186
 
187
-			if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) {
187
+			if ( ! class_exists('EDD_SL_Plugin_Updater')) {
188 188
 				require_once 'admin/EDD_SL_Plugin_Updater.php';
189 189
 			}
190 190
 		}
@@ -202,30 +202,30 @@  discard block
 block discarded – undo
202 202
 		private function hooks() {
203 203
 
204 204
 			// Register settings.
205
-			add_filter( 'give_settings_licenses', array( $this, 'settings' ), 1 );
205
+			add_filter('give_settings_licenses', array($this, 'settings'), 1);
206 206
 
207 207
 			// Activate license key on settings save.
208
-			add_action( 'admin_init', array( $this, 'activate_license' ) );
208
+			add_action('admin_init', array($this, 'activate_license'));
209 209
 
210 210
 			// Deactivate license key.
211
-			add_action( 'admin_init', array( $this, 'deactivate_license' ) );
211
+			add_action('admin_init', array($this, 'deactivate_license'));
212 212
 
213 213
 			// Updater.
214
-			add_action( 'admin_init', array( $this, 'auto_updater' ), 0 );
215
-			add_action( 'admin_notices', array( $this, 'notices' ) );
214
+			add_action('admin_init', array($this, 'auto_updater'), 0);
215
+			add_action('admin_notices', array($this, 'notices'));
216 216
 
217 217
 			// Check license weekly.
218
-			Give_Cron::add_weekly_event( array( $this, 'weekly_license_check' ) );
219
-			add_action( 'give_validate_license_when_site_migrated', array( $this, 'weekly_license_check' ) );
218
+			Give_Cron::add_weekly_event(array($this, 'weekly_license_check'));
219
+			add_action('give_validate_license_when_site_migrated', array($this, 'weekly_license_check'));
220 220
 
221 221
 			// Check subscription weekly.
222
-			Give_Cron::add_weekly_event( array( $this, 'weekly_subscription_check' ) );
223
-			add_action( 'give_validate_license_when_site_migrated', array( $this, 'weekly_subscription_check' ) );
222
+			Give_Cron::add_weekly_event(array($this, 'weekly_subscription_check'));
223
+			add_action('give_validate_license_when_site_migrated', array($this, 'weekly_subscription_check'));
224 224
 
225 225
 			// Show addon notice on plugin page.
226
-			$plugin_name = explode( 'plugins/', $this->file );
227
-			$plugin_name = end( $plugin_name );
228
-			add_action( "after_plugin_row_{$plugin_name}", array( $this, 'plugin_page_notices' ), 10, 3 );
226
+			$plugin_name = explode('plugins/', $this->file);
227
+			$plugin_name = end($plugin_name);
228
+			add_action("after_plugin_row_{$plugin_name}", array($this, 'plugin_page_notices'), 10, 3);
229 229
 
230 230
 		}
231 231
 
@@ -265,16 +265,16 @@  discard block
 block discarded – undo
265 265
 		 *
266 266
 		 * @return array           License settings.
267 267
 		 */
268
-		public function settings( $settings ) {
268
+		public function settings($settings) {
269 269
 
270 270
 			$give_license_settings = array(
271 271
 				array(
272 272
 					'name'    => $this->item_name,
273
-					'id'      => $this->item_shortname . '_license_key',
273
+					'id'      => $this->item_shortname.'_license_key',
274 274
 					'desc'    => '',
275 275
 					'type'    => 'license_key',
276 276
 					'options' => array(
277
-						'license'      => get_option( $this->item_shortname . '_license_active' ),
277
+						'license'      => get_option($this->item_shortname.'_license_active'),
278 278
 						'shortname'    => $this->item_shortname,
279 279
 						'item_name'    => $this->item_name,
280 280
 						'api_url'      => $this->api_url,
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 				),
286 286
 			);
287 287
 
288
-			return array_merge( $settings, $give_license_settings );
288
+			return array_merge($settings, $give_license_settings);
289 289
 		}
290 290
 
291 291
 		/**
@@ -300,18 +300,18 @@  discard block
 block discarded – undo
300 300
 		 *
301 301
 		 * @return array           License settings content.
302 302
 		 */
303
-		public function license_settings_content( $settings ) {
303
+		public function license_settings_content($settings) {
304 304
 
305 305
 			$give_license_settings = array(
306 306
 				array(
307
-					'name' => __( 'Add-on Licenses', 'give' ),
307
+					'name' => __('Add-on Licenses', 'give'),
308 308
 					'desc' => '<hr>',
309 309
 					'type' => 'give_title',
310 310
 					'id'   => 'give_title',
311 311
 				),
312 312
 			);
313 313
 
314
-			return array_merge( $settings, $give_license_settings );
314
+			return array_merge($settings, $give_license_settings);
315 315
 		}
316 316
 
317 317
 		/**
@@ -326,65 +326,65 @@  discard block
 block discarded – undo
326 326
 		 */
327 327
 		public function activate_license() {
328 328
 			// Bailout.
329
-			if ( ! $this->__is_user_can_edit_license() ) {
329
+			if ( ! $this->__is_user_can_edit_license()) {
330 330
 				return;
331 331
 			}
332 332
 
333 333
 			// Allow third party addon developers to handle license activation.
334
-			if ( $this->__is_third_party_addon() ) {
335
-				do_action( 'give_activate_license', $this );
334
+			if ($this->__is_third_party_addon()) {
335
+				do_action('give_activate_license', $this);
336 336
 
337 337
 				return;
338 338
 			}
339 339
 
340 340
 			// Do not simultaneously activate add-ons if the user want to deactivate a specific add-on.
341
-			foreach ( $_POST as $key => $value ) {
342
-				if ( false !== strpos( $key, 'license_key_deactivate' ) ) {
341
+			foreach ($_POST as $key => $value) {
342
+				if (false !== strpos($key, 'license_key_deactivate')) {
343 343
 					// Don't activate a key when deactivating a different key
344 344
 					return;
345 345
 				}
346 346
 			}
347 347
 
348 348
 			// Delete previous license setting if a empty license key submitted.
349
-			if ( empty( $_POST["{$this->item_shortname}_license_key"] ) ) {
349
+			if (empty($_POST["{$this->item_shortname}_license_key"])) {
350 350
 				$this->unset_license();
351 351
 
352 352
 				return;
353 353
 			}
354 354
 
355 355
 			// Check if plugin previously installed.
356
-			if ( $this->is_valid_license() ) {
356
+			if ($this->is_valid_license()) {
357 357
 				return;
358 358
 			}
359 359
 
360 360
 			// Get license key.
361
-			$this->license = sanitize_text_field( $_POST[ $this->item_shortname . '_license_key' ] );
361
+			$this->license = sanitize_text_field($_POST[$this->item_shortname.'_license_key']);
362 362
 
363 363
 			// Delete previous license key from subscription if previously added.
364 364
 			$this->__remove_license_key_from_subscriptions();
365 365
 
366 366
 			// Make sure there are no api errors.
367
-			if ( ! ( $license_data = $this->get_license_info( 'activate_license' ) ) ) {
367
+			if ( ! ($license_data = $this->get_license_info('activate_license'))) {
368 368
 				return;
369 369
 			}
370 370
 
371 371
 			// Make sure license is valid.
372 372
 			// return because admin will want to activate license again.
373
-			if ( ! $this->is_license( $license_data ) ) {
373
+			if ( ! $this->is_license($license_data)) {
374 374
 				// Add license key.
375
-				give_update_option( "{$this->item_shortname}_license_key", $this->license );
375
+				give_update_option("{$this->item_shortname}_license_key", $this->license);
376 376
 
377 377
 				return;
378 378
 			}
379 379
 
380 380
 			// Tell WordPress to look for updates.
381
-			set_site_transient( 'update_plugins', null );
381
+			set_site_transient('update_plugins', null);
382 382
 
383 383
 			// Add license data.
384
-			update_option( "{$this->item_shortname}_license_active", $license_data );
384
+			update_option("{$this->item_shortname}_license_active", $license_data);
385 385
 
386 386
 			// Add license key.
387
-			give_update_option( "{$this->item_shortname}_license_key", $this->license );
387
+			give_update_option("{$this->item_shortname}_license_key", $this->license);
388 388
 
389 389
 			// Check subscription for license key and store this to db (if any).
390 390
 			$this->__single_subscription_check();
@@ -402,27 +402,27 @@  discard block
 block discarded – undo
402 402
 		 */
403 403
 		public function deactivate_license() {
404 404
 			// Bailout.
405
-			if ( ! $this->__is_user_can_edit_license() ) {
405
+			if ( ! $this->__is_user_can_edit_license()) {
406 406
 				return;
407 407
 			}
408 408
 
409 409
 			// Allow third party add-on developers to handle license deactivation.
410
-			if ( $this->__is_third_party_addon() ) {
411
-				do_action( 'give_deactivate_license', $this );
410
+			if ($this->__is_third_party_addon()) {
411
+				do_action('give_deactivate_license', $this);
412 412
 
413 413
 				return;
414 414
 			}
415 415
 
416 416
 			// Run on deactivate button press.
417
-			if ( isset( $_POST[ $this->item_shortname . '_license_key_deactivate' ] ) ) {
417
+			if (isset($_POST[$this->item_shortname.'_license_key_deactivate'])) {
418 418
 
419 419
 				// Make sure there are no api errors.
420
-				if ( ! ( $license_data = $this->get_license_info( 'deactivate_license' ) ) ) {
420
+				if ( ! ($license_data = $this->get_license_info('deactivate_license'))) {
421 421
 					return;
422 422
 				}
423 423
 
424 424
 				// Ensure deactivated successfully.
425
-				if ( isset( $license_data->success ) ) {
425
+				if (isset($license_data->success)) {
426 426
 					$this->unset_license();
427 427
 				}
428 428
 			}// End if().
@@ -439,30 +439,30 @@  discard block
 block discarded – undo
439 439
 		public function weekly_license_check() {
440 440
 
441 441
 			if (
442
-				! empty( $_POST['give_settings'] ) ||
443
-				empty( $this->license )
442
+				! empty($_POST['give_settings']) ||
443
+				empty($this->license)
444 444
 			) {
445 445
 				return;
446 446
 			}
447 447
 
448 448
 			// Allow third party add-on developers to handle their license check.
449
-			if ( $this->__is_third_party_addon() ) {
450
-				do_action( 'give_weekly_license_check', $this );
449
+			if ($this->__is_third_party_addon()) {
450
+				do_action('give_weekly_license_check', $this);
451 451
 
452 452
 				return;
453 453
 			}
454 454
 
455 455
 			// Make sure there are no api errors.
456
-			if ( ! ( $license_data = $this->get_license_info( 'check_license' ) ) ) {
456
+			if ( ! ($license_data = $this->get_license_info('check_license'))) {
457 457
 				return;
458 458
 			}
459 459
 
460 460
 			// Bailout.
461
-			if ( ! $this->is_license( $license_data ) ) {
461
+			if ( ! $this->is_license($license_data)) {
462 462
 				return;
463 463
 			}
464 464
 
465
-			update_option( $this->item_shortname . '_license_active', $license_data );
465
+			update_option($this->item_shortname.'_license_active', $license_data);
466 466
 
467 467
 			return;
468 468
 		}
@@ -478,21 +478,21 @@  discard block
 block discarded – undo
478 478
 		public function weekly_subscription_check() {
479 479
 			// Bailout.
480 480
 			if (
481
-				! empty( $_POST['give_settings'] ) ||
482
-				empty( $this->license )
481
+				! empty($_POST['give_settings']) ||
482
+				empty($this->license)
483 483
 			) {
484 484
 				return;
485 485
 			}
486 486
 
487 487
 			// Remove old subscription data.
488
-			if ( absint( get_option( '_give_subscriptions_edit_last', true ) ) < current_time( 'timestamp', 1 ) ) {
489
-				delete_option( 'give_subscriptions' );
490
-				update_option( '_give_subscriptions_edit_last', strtotime( '+ 1 day', current_time( 'timestamp', 1 ) ) );
488
+			if (absint(get_option('_give_subscriptions_edit_last', true)) < current_time('timestamp', 1)) {
489
+				delete_option('give_subscriptions');
490
+				update_option('_give_subscriptions_edit_last', strtotime('+ 1 day', current_time('timestamp', 1)));
491 491
 			}
492 492
 
493 493
 			// Allow third party add-on developers to handle their subscription check.
494
-			if ( $this->__is_third_party_addon() ) {
495
-				do_action( 'give_weekly_subscription_check', $this );
494
+			if ($this->__is_third_party_addon()) {
495
+				do_action('give_weekly_subscription_check', $this);
496 496
 
497 497
 				return;
498 498
 			}
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
 		 * @return void
510 510
 		 */
511 511
 		private function __single_subscription_check() {
512
-			if ( empty( $this->license ) ) {
512
+			if (empty($this->license)) {
513 513
 				return;
514 514
 			}
515 515
 
@@ -520,29 +520,29 @@  discard block
 block discarded – undo
520 520
 			 * By default edd software licensing api does not have api to check subscription.
521 521
 			 * This is a custom feature to check subscriptions.
522 522
 			 */
523
-			if ( ! ( $subscription_data = $this->get_license_info( 'check_subscription', true ) ) ) {
523
+			if ( ! ($subscription_data = $this->get_license_info('check_subscription', true))) {
524 524
 				return;
525 525
 			}
526 526
 
527 527
 
528
-			if ( ! empty( $subscription_data['success'] ) && absint( $subscription_data['success'] ) ) {
529
-				$subscriptions = get_option( 'give_subscriptions', array() );
528
+			if ( ! empty($subscription_data['success']) && absint($subscription_data['success'])) {
529
+				$subscriptions = get_option('give_subscriptions', array());
530 530
 
531 531
 				// Update subscription data only if subscription does not exist already.
532
-				$subscriptions[ $subscription_data['id'] ] = $subscription_data;
532
+				$subscriptions[$subscription_data['id']] = $subscription_data;
533 533
 
534 534
 
535 535
 				// Initiate default set of license for subscription.
536
-				if ( ! isset( $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) {
537
-					$subscriptions[ $subscription_data['id'] ]['licenses'] = array();
536
+				if ( ! isset($subscriptions[$subscription_data['id']]['licenses'])) {
537
+					$subscriptions[$subscription_data['id']]['licenses'] = array();
538 538
 				}
539 539
 
540 540
 				// Store licenses for subscription.
541
-				if ( ! in_array( $this->license, $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) {
542
-					$subscriptions[ $subscription_data['id'] ]['licenses'][] = $this->license;
541
+				if ( ! in_array($this->license, $subscriptions[$subscription_data['id']]['licenses'])) {
542
+					$subscriptions[$subscription_data['id']]['licenses'][] = $this->license;
543 543
 				}
544 544
 
545
-				update_option( 'give_subscriptions', $subscriptions );
545
+				update_option('give_subscriptions', $subscriptions);
546 546
 			}
547 547
 		}
548 548
 
@@ -556,12 +556,12 @@  discard block
 block discarded – undo
556 556
 		 */
557 557
 		public function notices() {
558 558
 
559
-			if ( ! current_user_can( 'manage_give_settings' ) ) {
559
+			if ( ! current_user_can('manage_give_settings')) {
560 560
 				return;
561 561
 			}
562 562
 
563 563
 			// Do not show licenses notices on license tab.
564
-			if ( 'licenses' === give_get_current_setting_tab() ) {
564
+			if ('licenses' === give_get_current_setting_tab()) {
565 565
 				return;
566 566
 			}
567 567
 
@@ -570,118 +570,118 @@  discard block
 block discarded – undo
570 570
 			static $addon_license_key_in_subscriptions;
571 571
 
572 572
 			// Set default value.
573
-			$addon_license_key_in_subscriptions = ! empty( $addon_license_key_in_subscriptions ) ? $addon_license_key_in_subscriptions : array();
573
+			$addon_license_key_in_subscriptions = ! empty($addon_license_key_in_subscriptions) ? $addon_license_key_in_subscriptions : array();
574 574
 			$messages                           = array();
575 575
 
576 576
 			// Check whether admin has Give Add-on activated since 24 hours?
577
-			$is_license_notice_hidden = Give_Cache::get( 'give_cache_hide_license_notice_after_activation' );
577
+			$is_license_notice_hidden = Give_Cache::get('give_cache_hide_license_notice_after_activation');
578 578
 
579 579
 			// Display Invalid License notice, if its more than 24 hours since first Give Add-on activation.
580 580
 			if (
581
-				empty( $this->license )
582
-				&& empty( $showed_invalid_message )
583
-				&& ( false === $is_license_notice_hidden )
581
+				empty($this->license)
582
+				&& empty($showed_invalid_message)
583
+				&& (false === $is_license_notice_hidden)
584 584
 			) {
585 585
 
586
-				Give()->notices->register_notice( array(
586
+				Give()->notices->register_notice(array(
587 587
 					'id'               => 'give-invalid-license',
588 588
 					'type'             => 'error',
589 589
 					'description'      => sprintf(
590
-						__( 'You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give' ),
591
-						admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' )
590
+						__('You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give'),
591
+						admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses')
592 592
 					),
593 593
 					'dismissible_type' => 'user',
594 594
 					'dismiss_interval' => 'shortly',
595
-				) );
595
+				));
596 596
 
597 597
 				$showed_invalid_message = true;
598 598
 
599 599
 			}
600 600
 
601 601
 			// Get subscriptions.
602
-			$subscriptions = get_option( 'give_subscriptions' );
602
+			$subscriptions = get_option('give_subscriptions');
603 603
 
604 604
 			// Show subscription messages.
605
-			if ( ! empty( $subscriptions ) && ! $showed_subscriptions_message ) {
605
+			if ( ! empty($subscriptions) && ! $showed_subscriptions_message) {
606 606
 
607
-				foreach ( $subscriptions as $subscription ) {
607
+				foreach ($subscriptions as $subscription) {
608 608
 					// Subscription expires timestamp.
609
-					$subscription_expires = strtotime( $subscription['expires'] );
609
+					$subscription_expires = strtotime($subscription['expires']);
610 610
 
611 611
 					// Start showing subscriptions message before one week of renewal date.
612
-					if ( strtotime( '- 7 days', $subscription_expires ) > current_time( 'timestamp', 1 ) ) {
612
+					if (strtotime('- 7 days', $subscription_expires) > current_time('timestamp', 1)) {
613 613
 						continue;
614 614
 					}
615 615
 
616 616
 					// Check if subscription message already exist in messages.
617
-					if ( array_key_exists( $subscription['id'], $messages ) ) {
617
+					if (array_key_exists($subscription['id'], $messages)) {
618 618
 						continue;
619 619
 					}
620 620
 
621 621
 					// Check if license already expired.
622
-					if ( strtotime( $subscription['expires'] ) < current_time( 'timestamp', 1 ) ) {
623
-						Give()->notices->register_notice( array(
622
+					if (strtotime($subscription['expires']) < current_time('timestamp', 1)) {
623
+						Give()->notices->register_notice(array(
624 624
 							'id'               => "give-expired-subscription-{$subscription['id']}",
625 625
 							'type'             => 'error',
626 626
 							'description'      => sprintf(
627
-								__( 'Your Give add-on license expired for payment <a href="%1$s" target="_blank">#%2$d</a>. <a href="%3$s" target="_blank">Click to renew an existing license</a> or %4$s.', 'give' ),
628
-								urldecode( $subscription['invoice_url'] ),
627
+								__('Your Give add-on license expired for payment <a href="%1$s" target="_blank">#%2$d</a>. <a href="%3$s" target="_blank">Click to renew an existing license</a> or %4$s.', 'give'),
628
+								urldecode($subscription['invoice_url']),
629 629
 								$subscription['payment_id'],
630 630
 								"{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired",
631
-								Give()->notices->get_dismiss_link( array(
632
-									'title'            => __( 'Click here if already renewed', 'give' ),
631
+								Give()->notices->get_dismiss_link(array(
632
+									'title'            => __('Click here if already renewed', 'give'),
633 633
 									'dismissible_type' => 'user',
634 634
 									'dismiss_interval' => 'permanent',
635
-								) )
635
+								))
636 636
 							),
637 637
 							'dismissible_type' => 'user',
638 638
 							'dismiss_interval' => 'shortly',
639
-						) );
639
+						));
640 640
 					} else {
641
-						Give()->notices->register_notice( array(
641
+						Give()->notices->register_notice(array(
642 642
 							'id'               => "give-expires-subscription-{$subscription['id']}",
643 643
 							'type'             => 'error',
644 644
 							'description'      => sprintf(
645
-								__( 'Your Give add-on license will expire in %1$s for payment <a href="%2$s" target="_blank">#%3$d</a>. <a href="%4$s" target="_blank">Click to renew an existing license</a> or %5$s.', 'give' ),
646
-								human_time_diff( current_time( 'timestamp', 1 ), strtotime( $subscription['expires'] ) ),
647
-								urldecode( $subscription['invoice_url'] ),
645
+								__('Your Give add-on license will expire in %1$s for payment <a href="%2$s" target="_blank">#%3$d</a>. <a href="%4$s" target="_blank">Click to renew an existing license</a> or %5$s.', 'give'),
646
+								human_time_diff(current_time('timestamp', 1), strtotime($subscription['expires'])),
647
+								urldecode($subscription['invoice_url']),
648 648
 								$subscription['payment_id'],
649 649
 								"{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired",
650
-								Give()->notices->get_dismiss_link( array(
651
-									'title'            => __( 'Click here if already renewed', 'give' ),
650
+								Give()->notices->get_dismiss_link(array(
651
+									'title'            => __('Click here if already renewed', 'give'),
652 652
 									'dismissible_type' => 'user',
653 653
 									'dismiss_interval' => 'permanent',
654
-								) )
654
+								))
655 655
 							),
656 656
 							'dismissible_type' => 'user',
657 657
 							'dismiss_interval' => 'shortly',
658
-						) );
658
+						));
659 659
 					}
660 660
 
661 661
 					// Stop validation for these license keys.
662
-					$addon_license_key_in_subscriptions = array_merge( $addon_license_key_in_subscriptions, $subscription['licenses'] );
662
+					$addon_license_key_in_subscriptions = array_merge($addon_license_key_in_subscriptions, $subscription['licenses']);
663 663
 				}// End foreach().
664 664
 				$showed_subscriptions_message = true;
665 665
 			}// End if().
666 666
 
667 667
 			// Show Non Subscription Give Add-on messages.
668 668
 			if (
669
-				! in_array( $this->license, $addon_license_key_in_subscriptions )
670
-				&& ! empty( $this->license )
671
-				&& empty( $showed_invalid_message )
669
+				! in_array($this->license, $addon_license_key_in_subscriptions)
670
+				&& ! empty($this->license)
671
+				&& empty($showed_invalid_message)
672 672
 				&& ! $this->is_valid_license()
673 673
 			) {
674 674
 
675
-				Give()->notices->register_notice( array(
675
+				Give()->notices->register_notice(array(
676 676
 					'id'               => 'give-invalid-license',
677 677
 					'type'             => 'error',
678 678
 					'description'      => sprintf(
679
-						__( 'You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give' ),
680
-						admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' )
679
+						__('You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give'),
680
+						admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses')
681 681
 					),
682 682
 					'dismissible_type' => 'user',
683 683
 					'dismiss_interval' => 'shortly',
684
-				) );
684
+				));
685 685
 
686 686
 				$showed_invalid_message = true;
687 687
 
@@ -698,10 +698,10 @@  discard block
 block discarded – undo
698 698
 		 *
699 699
 		 * @return bool
700 700
 		 */
701
-		public function is_valid_license( $licence_data = null ) {
702
-			$license_data = empty( $licence_data ) ? $this->license_data : $licence_data;
701
+		public function is_valid_license($licence_data = null) {
702
+			$license_data = empty($licence_data) ? $this->license_data : $licence_data;
703 703
 
704
-			if ( apply_filters( 'give_is_valid_license', ( $this->is_license( $license_data ) && 'valid' === $license_data->license ) ) ) {
704
+			if (apply_filters('give_is_valid_license', ($this->is_license($license_data) && 'valid' === $license_data->license))) {
705 705
 				return true;
706 706
 			}
707 707
 
@@ -719,10 +719,10 @@  discard block
 block discarded – undo
719 719
 		 *
720 720
 		 * @return bool
721 721
 		 */
722
-		public function is_license( $licence_data = null ) {
723
-			$license_data = empty( $licence_data ) ? $this->license_data : $licence_data;
722
+		public function is_license($licence_data = null) {
723
+			$license_data = empty($licence_data) ? $this->license_data : $licence_data;
724 724
 
725
-			if ( apply_filters( 'give_is_license', ( is_object( $license_data ) && ! empty( $license_data ) && property_exists( $license_data, 'license' ) ) ) ) {
725
+			if (apply_filters('give_is_license', (is_object($license_data) && ! empty($license_data) && property_exists($license_data, 'license')))) {
726 726
 				return true;
727 727
 			}
728 728
 
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
 		 * @return bool
739 739
 		 */
740 740
 		private function __is_third_party_addon() {
741
-			return ( false === strpos( $this->api_url, 'givewp.com/' ) );
741
+			return (false === strpos($this->api_url, 'givewp.com/'));
742 742
 		}
743 743
 
744 744
 		/**
@@ -753,25 +753,25 @@  discard block
 block discarded – undo
753 753
 		 * @return bool
754 754
 		 */
755 755
 		private function __remove_license_key_from_subscriptions() {
756
-			$subscriptions = get_option( 'give_subscriptions', array() );
756
+			$subscriptions = get_option('give_subscriptions', array());
757 757
 
758 758
 			// Bailout.
759
-			if ( empty( $this->license ) ) {
759
+			if (empty($this->license)) {
760 760
 				return false;
761 761
 			}
762 762
 
763
-			if ( ! empty( $subscriptions ) ) {
764
-				foreach ( $subscriptions as $subscription_id => $subscription ) {
765
-					$license_index = array_search( $this->license, $subscription['licenses'] );
766
-					if ( false !== $license_index ) {
763
+			if ( ! empty($subscriptions)) {
764
+				foreach ($subscriptions as $subscription_id => $subscription) {
765
+					$license_index = array_search($this->license, $subscription['licenses']);
766
+					if (false !== $license_index) {
767 767
 						// Remove license key.
768
-						unset( $subscriptions[ $subscription_id ]['licenses'][ $license_index ] );
768
+						unset($subscriptions[$subscription_id]['licenses'][$license_index]);
769 769
 
770 770
 						// Rearrange license keys.
771
-						$subscriptions[ $subscription_id ]['licenses'] = array_values( $subscriptions[ $subscription_id ]['licenses'] );
771
+						$subscriptions[$subscription_id]['licenses'] = array_values($subscriptions[$subscription_id]['licenses']);
772 772
 
773 773
 						// Update subscription information.
774
-						update_option( 'give_subscriptions', $subscriptions );
774
+						update_option('give_subscriptions', $subscriptions);
775 775
 						break;
776 776
 					}
777 777
 				}
@@ -785,17 +785,17 @@  discard block
 block discarded – undo
785 785
 		 *
786 786
 		 * @return bool
787 787
 		 */
788
-		public function plugin_page_notices( $plugin_file, $plugin_data, $status ) {
788
+		public function plugin_page_notices($plugin_file, $plugin_data, $status) {
789 789
 			// Bailout.
790
-			if ( $this->is_valid_license() ) {
790
+			if ($this->is_valid_license()) {
791 791
 				return false;
792 792
 			}
793 793
 
794 794
 			$update_notice_wrap = '<tr class="give-addon-notice-tr active"><td colspan="3" class="colspanchange"><div class="notice inline notice-warning notice-alt give-invalid-license"><p><span class="dashicons dashicons-info"></span> %s</p></div></td></tr>';
795 795
 			$message            = $this->license_state_message();
796 796
 
797
-			if ( ! empty( $message['message'] ) ) {
798
-				echo sprintf( $update_notice_wrap, $message['message'] );
797
+			if ( ! empty($message['message'])) {
798
+				echo sprintf($update_notice_wrap, $message['message']);
799 799
 			}
800 800
 		}
801 801
 
@@ -810,11 +810,11 @@  discard block
 block discarded – undo
810 810
 		public function license_state_message() {
811 811
 			$message_data = array();
812 812
 
813
-			if ( ! $this->is_valid_license() ) {
813
+			if ( ! $this->is_valid_license()) {
814 814
 
815 815
 				$message_data['message'] = sprintf(
816 816
 					'Please <a href="%1$s">activate your license</a> to receive updates and support for the %2$s add-on.',
817
-					esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' ) ),
817
+					esc_url(admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses')),
818 818
 					$this->item_name
819 819
 				);
820 820
 			}
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
 			// Bailout.
834 834
 			if (
835 835
 				! Give_Admin_Settings::verify_nonce() ||
836
-				! current_user_can( 'manage_give_settings' ) ||
836
+				! current_user_can('manage_give_settings') ||
837 837
 				'licenses' !== give_get_current_setting_tab()
838 838
 			) {
839 839
 				return false;
@@ -841,10 +841,10 @@  discard block
 block discarded – undo
841 841
 
842 842
 			// Security check.
843 843
 			if (
844
-				isset( $_POST[ $this->item_shortname . '_license_key-nonce' ] ) &&
845
-				! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' )
844
+				isset($_POST[$this->item_shortname.'_license_key-nonce']) &&
845
+				! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')
846 846
 			) {
847
-				wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
847
+				wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'), array('response' => 403));
848 848
 			}
849 849
 
850 850
 			return true;
@@ -862,8 +862,8 @@  discard block
 block discarded – undo
862 862
 		 *
863 863
 		 * @return mixed
864 864
 		 */
865
-		public function get_license_info( $edd_action = '', $response_in_array = false ) {
866
-			if ( empty( $edd_action ) ) {
865
+		public function get_license_info($edd_action = '', $response_in_array = false) {
866
+			if (empty($edd_action)) {
867 867
 				return false;
868 868
 			}
869 869
 
@@ -871,7 +871,7 @@  discard block
 block discarded – undo
871 871
 			$api_params = array(
872 872
 				'edd_action' => $edd_action, // never change from "edd_" to "give_"!
873 873
 				'license'    => $this->license,
874
-				'item_name'  => urlencode( $this->item_name ),
874
+				'item_name'  => urlencode($this->item_name),
875 875
 				'url'        => home_url(),
876 876
 			);
877 877
 
@@ -886,11 +886,11 @@  discard block
 block discarded – undo
886 886
 			);
887 887
 
888 888
 			// Make sure there are no errors.
889
-			if ( is_wp_error( $response ) ) {
889
+			if (is_wp_error($response)) {
890 890
 				return false;
891 891
 			}
892 892
 
893
-			return json_decode( wp_remote_retrieve_body( $response ), $response_in_array );
893
+			return json_decode(wp_remote_retrieve_body($response), $response_in_array);
894 894
 		}
895 895
 
896 896
 
@@ -905,8 +905,8 @@  discard block
 block discarded – undo
905 905
 			$this->__remove_license_key_from_subscriptions();
906 906
 
907 907
 			// Remove license from database.
908
-			delete_option( "{$this->item_shortname}_license_active" );
909
-			give_delete_option( "{$this->item_shortname}_license_key" );
908
+			delete_option("{$this->item_shortname}_license_active");
909
+			give_delete_option("{$this->item_shortname}_license_key");
910 910
 
911 911
 			// Unset license param.
912 912
 			$this->license = '';
Please login to merge, or discard this patch.
includes/login-register.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
  * @param string $user_login Username
175 175
  * @param string $user_pass  Password
176 176
  *
177
- * @return bool
177
+ * @return false|null
178 178
  */
179 179
 function give_log_user_in( $user_id, $user_login, $user_pass ) {
180 180
 
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
  *
216 216
  * @param array $data Data sent from the register form
217 217
  *
218
- * @return bool
218
+ * @return false|null
219 219
  */
220 220
 function give_process_register_form( $data ) {
221 221
 
Please login to merge, or discard this patch.
Spacing   +70 added lines, -70 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,23 +26,23 @@  discard block
 block discarded – undo
26 26
  *
27 27
  * @return string Login form
28 28
  */
29
-function give_login_form( $login_redirect = '', $logout_redirect = '' ) {
30
-	if ( empty( $login_redirect ) ) {
31
-		$login_redirect = add_query_arg( 'give-login-success', 'true', give_get_current_page_url() );
29
+function give_login_form($login_redirect = '', $logout_redirect = '') {
30
+	if (empty($login_redirect)) {
31
+		$login_redirect = add_query_arg('give-login-success', 'true', give_get_current_page_url());
32 32
 	}
33 33
 
34
-	if ( empty( $logout_redirect ) ) {
35
-		$logout_redirect = add_query_arg( 'give-logout-success', 'true', give_get_current_page_url() );
34
+	if (empty($logout_redirect)) {
35
+		$logout_redirect = add_query_arg('give-logout-success', 'true', give_get_current_page_url());
36 36
 	}
37 37
 
38 38
 	// Add user_logout action to logout url.
39 39
 	$logout_redirect = add_query_arg(
40 40
 		array(
41 41
 			'give_action'          => 'user_logout',
42
-			'give_logout_nonce'    => wp_create_nonce( 'give-logout-nonce' ),
43
-			'give_logout_redirect' => urlencode( $logout_redirect ),
42
+			'give_logout_nonce'    => wp_create_nonce('give-logout-nonce'),
43
+			'give_logout_redirect' => urlencode($logout_redirect),
44 44
 		),
45
-		home_url( '/' )
45
+		home_url('/')
46 46
 	);
47 47
 
48 48
 	ob_start();
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 		)
56 56
 	);
57 57
 
58
-	return apply_filters( 'give_login_form', ob_get_clean() );
58
+	return apply_filters('give_login_form', ob_get_clean());
59 59
 }
60 60
 
61 61
 /**
@@ -68,14 +68,14 @@  discard block
 block discarded – undo
68 68
  *
69 69
  * @return string Register form
70 70
  */
71
-function give_register_form( $redirect = '' ) {
72
-	if ( empty( $redirect ) ) {
71
+function give_register_form($redirect = '') {
72
+	if (empty($redirect)) {
73 73
 		$redirect = give_get_current_page_url();
74 74
 	}
75 75
 
76 76
 	ob_start();
77 77
 
78
-	if ( ! is_user_logged_in() ) {
78
+	if ( ! is_user_logged_in()) {
79 79
 		give_get_template(
80 80
 			'shortcode-register',
81 81
 			array(
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 		);
85 85
 	}
86 86
 
87
-	return apply_filters( 'give_register_form', ob_get_clean() );
87
+	return apply_filters('give_register_form', ob_get_clean());
88 88
 }
89 89
 
90 90
 /**
@@ -96,34 +96,34 @@  discard block
 block discarded – undo
96 96
  *
97 97
  * @return void
98 98
  */
99
-function give_process_login_form( $data ) {
100
-	if ( wp_verify_nonce( $data['give_login_nonce'], 'give-login-nonce' ) ) {
101
-		$user_data = get_user_by( 'login', $data['give_user_login'] );
102
-		if ( ! $user_data ) {
103
-			$user_data = get_user_by( 'email', $data['give_user_login'] );
99
+function give_process_login_form($data) {
100
+	if (wp_verify_nonce($data['give_login_nonce'], 'give-login-nonce')) {
101
+		$user_data = get_user_by('login', $data['give_user_login']);
102
+		if ( ! $user_data) {
103
+			$user_data = get_user_by('email', $data['give_user_login']);
104 104
 		}
105
-		if ( $user_data ) {
105
+		if ($user_data) {
106 106
 			$user_ID    = $user_data->ID;
107 107
 			$user_email = $user_data->user_email;
108
-			if ( wp_check_password( $data['give_user_pass'], $user_data->user_pass, $user_ID ) ) {
109
-				give_log_user_in( $user_data->ID, $data['give_user_login'], $data['give_user_pass'] );
108
+			if (wp_check_password($data['give_user_pass'], $user_data->user_pass, $user_ID)) {
109
+				give_log_user_in($user_data->ID, $data['give_user_login'], $data['give_user_pass']);
110 110
 			} else {
111
-				give_set_error( 'password_incorrect', __( 'The password you entered is incorrect.', 'give' ) );
111
+				give_set_error('password_incorrect', __('The password you entered is incorrect.', 'give'));
112 112
 			}
113 113
 		} else {
114
-			give_set_error( 'username_incorrect', __( 'The username you entered does not exist.', 'give' ) );
114
+			give_set_error('username_incorrect', __('The username you entered does not exist.', 'give'));
115 115
 		}
116 116
 		// Check for errors and redirect if none present
117 117
 		$errors = give_get_errors();
118
-		if ( ! $errors ) {
119
-			$redirect = apply_filters( 'give_login_redirect', $data['give_login_redirect'], $user_ID );
120
-			wp_redirect( $redirect );
118
+		if ( ! $errors) {
119
+			$redirect = apply_filters('give_login_redirect', $data['give_login_redirect'], $user_ID);
120
+			wp_redirect($redirect);
121 121
 			give_die();
122 122
 		}
123 123
 	}
124 124
 }
125 125
 
126
-add_action( 'give_user_login', 'give_process_login_form' );
126
+add_action('give_user_login', 'give_process_login_form');
127 127
 
128 128
 
129 129
 /**
@@ -135,18 +135,18 @@  discard block
 block discarded – undo
135 135
  *
136 136
  * @return void
137 137
  */
138
-function give_process_user_logout( $data ) {
139
-	if ( wp_verify_nonce( $data['give_logout_nonce'], 'give-logout-nonce' ) && is_user_logged_in() ) {
138
+function give_process_user_logout($data) {
139
+	if (wp_verify_nonce($data['give_logout_nonce'], 'give-logout-nonce') && is_user_logged_in()) {
140 140
 
141 141
 		// Prevent occurring of any custom action on wp_logout.
142
-		remove_all_actions( 'wp_logout' );
142
+		remove_all_actions('wp_logout');
143 143
 
144 144
 		/**
145 145
 		 * Fires before processing user logout.
146 146
 		 *
147 147
 		 * @since 1.0
148 148
 		 */
149
-		do_action( 'give_before_user_logout' );
149
+		do_action('give_before_user_logout');
150 150
 
151 151
 		// Logout user.
152 152
 		wp_logout();
@@ -156,14 +156,14 @@  discard block
 block discarded – undo
156 156
 		 *
157 157
 		 * @since 1.0
158 158
 		 */
159
-		do_action( 'give_after_user_logout' );
159
+		do_action('give_after_user_logout');
160 160
 
161
-		wp_redirect( $data['give_logout_redirect'] );
161
+		wp_redirect($data['give_logout_redirect']);
162 162
 		give_die();
163 163
 	}
164 164
 }
165 165
 
166
-add_action( 'give_user_logout', 'give_process_user_logout' );
166
+add_action('give_user_logout', 'give_process_user_logout');
167 167
 
168 168
 /**
169 169
  * Log User In
@@ -176,14 +176,14 @@  discard block
 block discarded – undo
176 176
  *
177 177
  * @return bool
178 178
  */
179
-function give_log_user_in( $user_id, $user_login, $user_pass ) {
179
+function give_log_user_in($user_id, $user_login, $user_pass) {
180 180
 
181
-	if ( $user_id < 1 ) {
181
+	if ($user_id < 1) {
182 182
 		return false;
183 183
 	}
184 184
 
185
-	wp_set_auth_cookie( $user_id );
186
-	wp_set_current_user( $user_id, $user_login );
185
+	wp_set_auth_cookie($user_id);
186
+	wp_set_current_user($user_id, $user_login);
187 187
 
188 188
 	/**
189 189
 	 * Fires after the user has successfully logged in.
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 	 * @param string  $user_login Username.
194 194
 	 * @param WP_User $$user      WP_User object of the logged-in user.
195 195
 	 */
196
-	do_action( 'wp_login', $user_login, get_userdata( $user_id ) );
196
+	do_action('wp_login', $user_login, get_userdata($user_id));
197 197
 
198 198
 	/**
199 199
 	 * Fires after give user has successfully logged in.
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 	 * @param string $user_login Username.
205 205
 	 * @param string $user_pass  User password.
206 206
 	 */
207
-	do_action( 'give_log_user_in', $user_id, $user_login, $user_pass );
207
+	do_action('give_log_user_in', $user_id, $user_login, $user_pass);
208 208
 }
209 209
 
210 210
 
@@ -217,13 +217,13 @@  discard block
 block discarded – undo
217 217
  *
218 218
  * @return bool
219 219
  */
220
-function give_process_register_form( $data ) {
220
+function give_process_register_form($data) {
221 221
 
222
-	if ( is_user_logged_in() ) {
222
+	if (is_user_logged_in()) {
223 223
 		return false;
224 224
 	}
225 225
 
226
-	if ( empty( $_POST['give_register_submit'] ) ) {
226
+	if (empty($_POST['give_register_submit'])) {
227 227
 		return false;
228 228
 	}
229 229
 
@@ -232,38 +232,38 @@  discard block
 block discarded – undo
232 232
 	 *
233 233
 	 * @since 1.0
234 234
 	 */
235
-	do_action( 'give_pre_process_register_form' );
235
+	do_action('give_pre_process_register_form');
236 236
 
237
-	if ( empty( $data['give_user_login'] ) ) {
238
-		give_set_error( 'empty_username', esc_html__( 'Invalid username.', 'give' ) );
237
+	if (empty($data['give_user_login'])) {
238
+		give_set_error('empty_username', esc_html__('Invalid username.', 'give'));
239 239
 	}
240 240
 
241
-	if ( username_exists( $data['give_user_login'] ) ) {
242
-		give_set_error( 'username_unavailable', esc_html__( 'Username already taken.', 'give' ) );
241
+	if (username_exists($data['give_user_login'])) {
242
+		give_set_error('username_unavailable', esc_html__('Username already taken.', 'give'));
243 243
 	}
244 244
 
245
-	if ( ! validate_username( $data['give_user_login'] ) ) {
246
-		give_set_error( 'username_invalid', esc_html__( 'Invalid username.', 'give' ) );
245
+	if ( ! validate_username($data['give_user_login'])) {
246
+		give_set_error('username_invalid', esc_html__('Invalid username.', 'give'));
247 247
 	}
248 248
 
249
-	if ( email_exists( $data['give_user_email'] ) ) {
250
-		give_set_error( 'email_unavailable', esc_html__( 'Email address already taken.', 'give' ) );
249
+	if (email_exists($data['give_user_email'])) {
250
+		give_set_error('email_unavailable', esc_html__('Email address already taken.', 'give'));
251 251
 	}
252 252
 
253
-	if ( empty( $data['give_user_email'] ) || ! is_email( $data['give_user_email'] ) ) {
254
-		give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
253
+	if (empty($data['give_user_email']) || ! is_email($data['give_user_email'])) {
254
+		give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
255 255
 	}
256 256
 
257
-	if ( ! empty( $data['give_payment_email'] ) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email( $data['give_payment_email'] ) ) {
258
-		give_set_error( 'payment_email_invalid', esc_html__( 'Invalid payment email.', 'give' ) );
257
+	if ( ! empty($data['give_payment_email']) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email($data['give_payment_email'])) {
258
+		give_set_error('payment_email_invalid', esc_html__('Invalid payment email.', 'give'));
259 259
 	}
260 260
 
261
-	if ( empty( $_POST['give_user_pass'] ) ) {
262
-		give_set_error( 'empty_password', esc_html__( 'Please enter a password.', 'give' ) );
261
+	if (empty($_POST['give_user_pass'])) {
262
+		give_set_error('empty_password', esc_html__('Please enter a password.', 'give'));
263 263
 	}
264 264
 
265
-	if ( ( ! empty( $_POST['give_user_pass'] ) && empty( $_POST['give_user_pass2'] ) ) || ( $_POST['give_user_pass'] !== $_POST['give_user_pass2'] ) ) {
266
-		give_set_error( 'password_mismatch', esc_html__( 'Passwords don\'t match.', 'give' ) );
265
+	if (( ! empty($_POST['give_user_pass']) && empty($_POST['give_user_pass2'])) || ($_POST['give_user_pass'] !== $_POST['give_user_pass2'])) {
266
+		give_set_error('password_mismatch', esc_html__('Passwords don\'t match.', 'give'));
267 267
 	}
268 268
 
269 269
 	/**
@@ -271,26 +271,26 @@  discard block
 block discarded – undo
271 271
 	 *
272 272
 	 * @since 1.0
273 273
 	 */
274
-	do_action( 'give_process_register_form' );
274
+	do_action('give_process_register_form');
275 275
 
276 276
 	// Check for errors and redirect if none present
277 277
 	$errors = give_get_errors();
278 278
 
279
-	if ( empty( $errors ) ) {
279
+	if (empty($errors)) {
280 280
 
281
-		$redirect = apply_filters( 'give_register_redirect', $data['give_redirect'] );
281
+		$redirect = apply_filters('give_register_redirect', $data['give_redirect']);
282 282
 
283
-		give_register_and_login_new_user( array(
283
+		give_register_and_login_new_user(array(
284 284
 			'user_login'      => $data['give_user_login'],
285 285
 			'user_pass'       => $data['give_user_pass'],
286 286
 			'user_email'      => $data['give_user_email'],
287
-			'user_registered' => date( 'Y-m-d H:i:s' ),
288
-			'role'            => get_option( 'default_role' ),
289
-		) );
287
+			'user_registered' => date('Y-m-d H:i:s'),
288
+			'role'            => get_option('default_role'),
289
+		));
290 290
 
291
-		wp_redirect( $redirect );
291
+		wp_redirect($redirect);
292 292
 		give_die();
293 293
 	}
294 294
 }
295 295
 
296
-add_action( 'give_user_register', 'give_process_register_form' );
296
+add_action('give_user_register', 'give_process_register_form');
Please login to merge, or discard this patch.
includes/payments/class-payment-stats.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	 * @param  $end_date   string|bool  The end date for which we'd like to filter our sale stats. If false, we'll use the default end date of `this_month`
37 37
 	 * @param  $status     string|array The sale status(es) to count. Only valid when retrieving global stats
38 38
 	 *
39
-	 * @return float|int                Total amount of donations based on the passed arguments.
39
+	 * @return string                Total amount of donations based on the passed arguments.
40 40
 	 */
41 41
 	public function get_sales( $form_id = 0, $start_date = false, $end_date = false, $status = 'publish' ) {
42 42
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	 * @param  $end_date    string|bool The end date for which we'd like to filter the donations stats. If false, method will use the default end date of `this_month`.
84 84
 	 * @param  $gateway_id  string|bool The gateway to get earnings for such as 'paypal' or 'stripe'.
85 85
 	 *
86
-	 * @return float|int                Total amount of donations based on the passed arguments.
86
+	 * @return string                Total amount of donations based on the passed arguments.
87 87
 	 */
88 88
 	public function get_earnings( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) {
89 89
 		$this->setup_dates( $start_date, $end_date );
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 	 * @param  $end_date    string|bool The end date for which we'd like to filter our sale stats. If false, we'll use the default end date of `this_month`
169 169
 	 * @param  $gateway_id  string|bool The gateway to get earnings for such as 'paypal' or 'stripe'
170 170
 	 *
171
-	 * @return float|int                Total amount of donations based on the passed arguments.
171
+	 * @return string                Total amount of donations based on the passed arguments.
172 172
 	 */
173 173
 	public function get_earnings_cache_key( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) {
174 174
 
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 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
 
@@ -38,17 +38,17 @@  discard block
 block discarded – undo
38 38
 	 *
39 39
 	 * @return float|int                Total amount of donations based on the passed arguments.
40 40
 	 */
41
-	public function get_sales( $form_id = 0, $start_date = false, $end_date = false, $status = 'publish' ) {
41
+	public function get_sales($form_id = 0, $start_date = false, $end_date = false, $status = 'publish') {
42 42
 
43
-		$this->setup_dates( $start_date, $end_date );
43
+		$this->setup_dates($start_date, $end_date);
44 44
 
45 45
 		// Make sure start date is valid
46
-		if ( is_wp_error( $this->start_date ) ) {
46
+		if (is_wp_error($this->start_date)) {
47 47
 			return $this->start_date;
48 48
 		}
49 49
 
50 50
 		// Make sure end date is valid
51
-		if ( is_wp_error( $this->end_date ) ) {
51
+		if (is_wp_error($this->end_date)) {
52 52
 			return $this->end_date;
53 53
 		}
54 54
 
@@ -57,18 +57,18 @@  discard block
 block discarded – undo
57 57
 			'start_date' => $this->start_date,
58 58
 			'end_date'   => $this->end_date,
59 59
 			'fields'     => 'ids',
60
-			'number'     => - 1,
60
+			'number'     => -1,
61 61
 		);
62 62
 
63
-		if ( ! empty( $form_id ) ) {
63
+		if ( ! empty($form_id)) {
64 64
 			$args['give_forms'] = $form_id;
65 65
 		}
66 66
 
67 67
 		/* @var Give_Payments_Query $payments */
68
-		$payments = new Give_Payments_Query( $args );
68
+		$payments = new Give_Payments_Query($args);
69 69
 		$payments = $payments->get_payments();
70 70
 
71
-		return count( $payments );
71
+		return count($payments);
72 72
 	}
73 73
 
74 74
 
@@ -85,16 +85,16 @@  discard block
 block discarded – undo
85 85
 	 *
86 86
 	 * @return float|int                Total amount of donations based on the passed arguments.
87 87
 	 */
88
-	public function get_earnings( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) {
89
-		$this->setup_dates( $start_date, $end_date );
88
+	public function get_earnings($form_id = 0, $start_date = false, $end_date = false, $gateway_id = false) {
89
+		$this->setup_dates($start_date, $end_date);
90 90
 
91 91
 		// Make sure start date is valid
92
-		if ( is_wp_error( $this->start_date ) ) {
92
+		if (is_wp_error($this->start_date)) {
93 93
 			return $this->start_date;
94 94
 		}
95 95
 
96 96
 		// Make sure end date is valid
97
-		if ( is_wp_error( $this->end_date ) ) {
97
+		if (is_wp_error($this->end_date)) {
98 98
 			return $this->end_date;
99 99
 		}
100 100
 
@@ -104,12 +104,12 @@  discard block
 block discarded – undo
104 104
 			'start_date' => $this->start_date,
105 105
 			'end_date'   => $this->end_date,
106 106
 			'fields'     => 'ids',
107
-			'number'     => - 1,
107
+			'number'     => -1,
108 108
 		);
109 109
 
110 110
 
111 111
 		// Filter by Gateway ID meta_key
112
-		if ( $gateway_id ) {
112
+		if ($gateway_id) {
113 113
 			$args['meta_query'][] = array(
114 114
 				'key'   => '_give_payment_gateway',
115 115
 				'value' => $gateway_id,
@@ -117,43 +117,43 @@  discard block
 block discarded – undo
117 117
 		}
118 118
 
119 119
 		// Filter by Gateway ID meta_key
120
-		if ( $form_id ) {
120
+		if ($form_id) {
121 121
 			$args['meta_query'][] = array(
122 122
 				'key'   => '_give_payment_form_id',
123 123
 				'value' => $form_id,
124 124
 			);
125 125
 		}
126 126
 
127
-		if ( ! empty( $args['meta_query'] ) && 1 < count( $args['meta_query'] ) ) {
127
+		if ( ! empty($args['meta_query']) && 1 < count($args['meta_query'])) {
128 128
 			$args['meta_query']['relation'] = 'AND';
129 129
 		}
130 130
 
131
-		$args = apply_filters( 'give_stats_earnings_args', $args );
132
-		$key  = Give_Cache::get_key( 'give_stats', $args );
131
+		$args = apply_filters('give_stats_earnings_args', $args);
132
+		$key  = Give_Cache::get_key('give_stats', $args);
133 133
 
134 134
 		//Set transient for faster stats
135
-		$earnings = Give_Cache::get( $key );
135
+		$earnings = Give_Cache::get($key);
136 136
 
137
-		if ( false === $earnings ) {
137
+		if (false === $earnings) {
138 138
 
139 139
 			$this->timestamp = false;
140
-			$payments        = new Give_Payments_Query( $args );
140
+			$payments        = new Give_Payments_Query($args);
141 141
 			$payments        = $payments->get_payments();
142 142
 			$earnings        = 0;
143 143
 
144
-			if ( ! empty( $payments ) ) {
145
-				foreach ( $payments as $payment ) {
146
-					$earnings += give_get_payment_amount( $payment->ID );
144
+			if ( ! empty($payments)) {
145
+				foreach ($payments as $payment) {
146
+					$earnings += give_get_payment_amount($payment->ID);
147 147
 				}
148 148
 
149 149
 			}
150 150
 
151 151
 			// Cache the results for one hour
152
-			Give_Cache::set( $key, give_sanitize_amount_for_db( $earnings ), 60 * 60 );
152
+			Give_Cache::set($key, give_sanitize_amount_for_db($earnings), 60 * 60);
153 153
 		}
154 154
 
155 155
 		//return earnings
156
-		return round( $earnings, give_get_price_decimals( $form_id ) );
156
+		return round($earnings, give_get_price_decimals($form_id));
157 157
 
158 158
 	}
159 159
 
@@ -170,17 +170,17 @@  discard block
 block discarded – undo
170 170
 	 *
171 171
 	 * @return float|int                Total amount of donations based on the passed arguments.
172 172
 	 */
173
-	public function get_earnings_cache_key( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) {
173
+	public function get_earnings_cache_key($form_id = 0, $start_date = false, $end_date = false, $gateway_id = false) {
174 174
 
175
-		$this->setup_dates( $start_date, $end_date );
175
+		$this->setup_dates($start_date, $end_date);
176 176
 
177 177
 		// Make sure start date is valid
178
-		if ( is_wp_error( $this->start_date ) ) {
178
+		if (is_wp_error($this->start_date)) {
179 179
 			return $this->start_date;
180 180
 		}
181 181
 
182 182
 		// Make sure end date is valid
183
-		if ( is_wp_error( $this->end_date ) ) {
183
+		if (is_wp_error($this->end_date)) {
184 184
 			return $this->end_date;
185 185
 		}
186 186
 
@@ -190,12 +190,12 @@  discard block
 block discarded – undo
190 190
 			'start_date' => $this->start_date,
191 191
 			'end_date'   => $this->end_date,
192 192
 			'fields'     => 'ids',
193
-			'number'     => - 1,
193
+			'number'     => -1,
194 194
 		);
195 195
 
196 196
 
197 197
 		// Filter by Gateway ID meta_key
198
-		if ( $gateway_id ) {
198
+		if ($gateway_id) {
199 199
 			$args['meta_query'][] = array(
200 200
 				'key'   => '_give_payment_gateway',
201 201
 				'value' => $gateway_id,
@@ -203,19 +203,19 @@  discard block
 block discarded – undo
203 203
 		}
204 204
 
205 205
 		// Filter by Gateway ID meta_key
206
-		if ( $form_id ) {
206
+		if ($form_id) {
207 207
 			$args['meta_query'][] = array(
208 208
 				'key'   => '_give_payment_form_id',
209 209
 				'value' => $form_id,
210 210
 			);
211 211
 		}
212 212
 
213
-		if ( ! empty( $args['meta_query'] ) && 1 < count( $args['meta_query'] ) ) {
213
+		if ( ! empty($args['meta_query']) && 1 < count($args['meta_query'])) {
214 214
 			$args['meta_query']['relation'] = 'AND';
215 215
 		}
216 216
 
217
-		$args = apply_filters( 'give_stats_earnings_args', $args );
218
-		$key  = Give_Cache::get_key( 'give_stats', $args );
217
+		$args = apply_filters('give_stats_earnings_args', $args);
218
+		$key  = Give_Cache::get_key('give_stats', $args);
219 219
 
220 220
 		//return earnings
221 221
 		return $key;
@@ -232,16 +232,16 @@  discard block
 block discarded – undo
232 232
 	 *
233 233
 	 * @return array       Best selling forms
234 234
 	 */
235
-	public function get_best_selling( $number = 10 ) {
235
+	public function get_best_selling($number = 10) {
236 236
 
237 237
 		global $wpdb;
238 238
 
239
-		$give_forms = $wpdb->get_results( $wpdb->prepare(
239
+		$give_forms = $wpdb->get_results($wpdb->prepare(
240 240
 			"SELECT post_id as form_id, max(meta_value) as sales
241 241
 				FROM $wpdb->postmeta WHERE meta_key='_give_form_sales' AND meta_value > 0
242 242
 				GROUP BY meta_value+0
243 243
 				DESC LIMIT %d;", $number
244
-		) );
244
+		));
245 245
 
246 246
 		return $give_forms;
247 247
 	}
Please login to merge, or discard this patch.
includes/gateways/offline-donations.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -249,10 +249,10 @@
 block discarded – undo
249 249
 	$admin_message .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n\n";
250 250
 
251 251
 	$admin_message .= sprintf(
252
-		                  '<a href="%1$s">%2$s</a>',
253
-		                  admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $payment_id ),
254
-		                  __( 'View Donation Details &raquo;', 'give' )
255
-	                  ) . "\n\n";
252
+						  '<a href="%1$s">%2$s</a>',
253
+						  admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $payment_id ),
254
+						  __( 'View Donation Details &raquo;', 'give' )
255
+					  ) . "\n\n";
256 256
 
257 257
 	$admin_message = apply_filters( 'give_offline_admin_donation_notification', $admin_message, $payment_id );
258 258
 	$admin_message = give_do_email_tags( $admin_message, $payment_id );
Please login to merge, or discard this patch.
Spacing   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -18,17 +18,17 @@  discard block
 block discarded – undo
18 18
  *
19 19
  * @return array
20 20
  */
21
-function give_offline_register_gateway( $gateways ) {
21
+function give_offline_register_gateway($gateways) {
22 22
 	// Format: ID => Name
23 23
 	$gateways['offline'] = array(
24
-		'admin_label'    => esc_attr__( 'Offline Donation', 'give' ),
25
-		'checkout_label' => esc_attr__( 'Offline Donation', 'give' )
24
+		'admin_label'    => esc_attr__('Offline Donation', 'give'),
25
+		'checkout_label' => esc_attr__('Offline Donation', 'give')
26 26
 	);
27 27
 
28 28
 	return $gateways;
29 29
 }
30 30
 
31
-add_filter( 'give_payment_gateways', 'give_offline_register_gateway', 1 );
31
+add_filter('give_payment_gateways', 'give_offline_register_gateway', 1);
32 32
 
33 33
 
34 34
 /**
@@ -40,9 +40,9 @@  discard block
 block discarded – undo
40 40
  *
41 41
  * @return void
42 42
  */
43
-function give_offline_payment_cc_form( $form_id ) {
43
+function give_offline_payment_cc_form($form_id) {
44 44
 	// Get offline payment instruction.
45
-	$offline_instructions = give_get_offline_payment_instruction( $form_id, true );
45
+	$offline_instructions = give_get_offline_payment_instruction($form_id, true);
46 46
 
47 47
 	ob_start();
48 48
 
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
 	 *
54 54
 	 * @param int $form_id Give form id.
55 55
 	 */
56
-	do_action( 'give_before_offline_info_fields', $form_id );
56
+	do_action('give_before_offline_info_fields', $form_id);
57 57
 	?>
58 58
     <fieldset id="give_offline_payment_info">
59
-		<?php echo stripslashes( $offline_instructions ); ?>
59
+		<?php echo stripslashes($offline_instructions); ?>
60 60
     </fieldset>
61 61
 	<?php
62 62
 	/**
@@ -66,35 +66,35 @@  discard block
 block discarded – undo
66 66
 	 *
67 67
 	 * @param int $form_id Give form id.
68 68
 	 */
69
-	do_action( 'give_after_offline_info_fields', $form_id );
69
+	do_action('give_after_offline_info_fields', $form_id);
70 70
 
71 71
 	echo ob_get_clean();
72 72
 }
73 73
 
74
-add_action( 'give_offline_cc_form', 'give_offline_payment_cc_form' );
74
+add_action('give_offline_cc_form', 'give_offline_payment_cc_form');
75 75
 
76 76
 /**
77 77
  * Give Offline Billing Field
78 78
  *
79 79
  * @param $form_id
80 80
  */
81
-function give_offline_billing_fields( $form_id ) {
81
+function give_offline_billing_fields($form_id) {
82 82
 	//Enable Default CC fields (billing info)
83
-	$post_offline_cc_fields        = give_get_meta( $form_id, '_give_offline_donation_enable_billing_fields_single', true );
84
-	$post_offline_customize_option = give_get_meta( $form_id, '_give_customize_offline_donations', true );
83
+	$post_offline_cc_fields        = give_get_meta($form_id, '_give_offline_donation_enable_billing_fields_single', true);
84
+	$post_offline_customize_option = give_get_meta($form_id, '_give_customize_offline_donations', true);
85 85
 
86
-	$global_offline_cc_fields = give_get_option( 'give_offline_donation_enable_billing_fields' );
86
+	$global_offline_cc_fields = give_get_option('give_offline_donation_enable_billing_fields');
87 87
 
88 88
 	//Output CC Address fields if global option is on and user hasn't elected to customize this form's offline donation options
89 89
 	if (
90
-		( give_is_setting_enabled( $post_offline_customize_option, 'global' ) && give_is_setting_enabled( $global_offline_cc_fields ) )
91
-		|| ( give_is_setting_enabled( $post_offline_customize_option, 'enabled' ) && give_is_setting_enabled( $post_offline_cc_fields ) )
90
+		(give_is_setting_enabled($post_offline_customize_option, 'global') && give_is_setting_enabled($global_offline_cc_fields))
91
+		|| (give_is_setting_enabled($post_offline_customize_option, 'enabled') && give_is_setting_enabled($post_offline_cc_fields))
92 92
 	) {
93
-		give_default_cc_address_fields( $form_id );
93
+		give_default_cc_address_fields($form_id);
94 94
 	}
95 95
 }
96 96
 
97
-add_action( 'give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1 );
97
+add_action('give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1);
98 98
 
99 99
 /**
100 100
  * Process the payment
@@ -105,18 +105,18 @@  discard block
 block discarded – undo
105 105
  *
106 106
  * @return void
107 107
  */
108
-function give_offline_process_payment( $purchase_data ) {
108
+function give_offline_process_payment($purchase_data) {
109 109
 
110 110
 	// Setup the payment details.
111 111
 	$payment_data = array(
112 112
 		'price'           => $purchase_data['price'],
113 113
 		'give_form_title' => $purchase_data['post_data']['give-form-title'],
114
-		'give_form_id'    => intval( $purchase_data['post_data']['give-form-id'] ),
115
-		'give_price_id'   => isset( $purchase_data['post_data']['give-price-id'] ) ? $purchase_data['post_data']['give-price-id'] : '',
114
+		'give_form_id'    => intval($purchase_data['post_data']['give-form-id']),
115
+		'give_price_id'   => isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : '',
116 116
 		'date'            => $purchase_data['date'],
117 117
 		'user_email'      => $purchase_data['user_email'],
118 118
 		'purchase_key'    => $purchase_data['purchase_key'],
119
-		'currency'        => give_get_currency( $purchase_data['post_data']['give-form-id'], $purchase_data ),
119
+		'currency'        => give_get_currency($purchase_data['post_data']['give-form-id'], $purchase_data),
120 120
 		'user_info'       => $purchase_data['user_info'],
121 121
 		'status'          => 'pending',
122 122
 		'gateway'         => 'offline'
@@ -124,20 +124,20 @@  discard block
 block discarded – undo
124 124
 
125 125
 
126 126
 	// record the pending payment
127
-	$payment = give_insert_payment( $payment_data );
127
+	$payment = give_insert_payment($payment_data);
128 128
 
129
-	if ( $payment ) {
130
-		give_offline_send_admin_notice( $payment );
131
-		give_offline_send_donor_instructions( $payment );
129
+	if ($payment) {
130
+		give_offline_send_admin_notice($payment);
131
+		give_offline_send_donor_instructions($payment);
132 132
 		give_send_to_success_page();
133 133
 	} else {
134 134
 		// if errors are present, send the user back to the donation form so they can be corrected
135
-		give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] );
135
+		give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']);
136 136
 	}
137 137
 
138 138
 }
139 139
 
140
-add_action( 'give_gateway_offline', 'give_offline_process_payment' );
140
+add_action('give_gateway_offline', 'give_offline_process_payment');
141 141
 
142 142
 
143 143
 /**
@@ -150,59 +150,59 @@  discard block
 block discarded – undo
150 150
  * @since       1.0
151 151
  * @return void
152 152
  */
153
-function give_offline_send_donor_instructions( $payment_id = 0 ) {
153
+function give_offline_send_donor_instructions($payment_id = 0) {
154 154
 
155
-	$payment_data                      = give_get_payment_meta( $payment_id );
156
-	$post_offline_customization_option = give_get_meta( $payment_data['form_id'], '_give_customize_offline_donations', true );
155
+	$payment_data                      = give_get_payment_meta($payment_id);
156
+	$post_offline_customization_option = give_get_meta($payment_data['form_id'], '_give_customize_offline_donations', true);
157 157
 
158 158
 	//Customize email content depending on whether the single form has been customized
159
-	$email_content = give_get_option( 'global_offline_donation_email' );
159
+	$email_content = give_get_option('global_offline_donation_email');
160 160
 
161
-	if ( give_is_setting_enabled( $post_offline_customization_option, 'enabled' ) ) {
162
-		$email_content = give_get_meta( $payment_data['form_id'], '_give_offline_donation_email', true );
161
+	if (give_is_setting_enabled($post_offline_customization_option, 'enabled')) {
162
+		$email_content = give_get_meta($payment_data['form_id'], '_give_offline_donation_email', true);
163 163
 	}
164 164
 
165
-	$from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) );
165
+	$from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES));
166 166
 
167 167
 	/**
168 168
 	 * Filters the from name.
169 169
 	 *
170 170
 	 * @since 1.7
171 171
 	 */
172
-	$from_name = apply_filters( 'give_donation_from_name', $from_name, $payment_id, $payment_data );
172
+	$from_name = apply_filters('give_donation_from_name', $from_name, $payment_id, $payment_data);
173 173
 
174
-	$from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) );
174
+	$from_email = give_get_option('from_email', get_bloginfo('admin_email'));
175 175
 
176 176
 	/**
177 177
 	 * Filters the from email.
178 178
 	 *
179 179
 	 * @since 1.7
180 180
 	 */
181
-	$from_email = apply_filters( 'give_donation_from_address', $from_email, $payment_id, $payment_data );
181
+	$from_email = apply_filters('give_donation_from_address', $from_email, $payment_id, $payment_data);
182 182
 
183
-	$to_email = give_get_payment_user_email( $payment_id );
183
+	$to_email = give_get_payment_user_email($payment_id);
184 184
 
185
-	$subject = give_get_option( 'offline_donation_subject', __( 'Offline Donation Instructions', 'give' ) );
186
-	if ( give_is_setting_enabled( $post_offline_customization_option, 'enabled' ) ) {
187
-		$subject = give_get_meta( $payment_data['form_id'], '_give_offline_donation_subject', true );
185
+	$subject = give_get_option('offline_donation_subject', __('Offline Donation Instructions', 'give'));
186
+	if (give_is_setting_enabled($post_offline_customization_option, 'enabled')) {
187
+		$subject = give_get_meta($payment_data['form_id'], '_give_offline_donation_subject', true);
188 188
 	}
189 189
 
190
-	$subject = apply_filters( 'give_offline_donation_subject', wp_strip_all_tags( $subject ), $payment_id );
191
-	$subject = give_do_email_tags( $subject, $payment_id );
190
+	$subject = apply_filters('give_offline_donation_subject', wp_strip_all_tags($subject), $payment_id);
191
+	$subject = give_do_email_tags($subject, $payment_id);
192 192
 
193
-	$attachments = apply_filters( 'give_offline_donation_attachments', array(), $payment_id, $payment_data );
194
-	$message     = give_do_email_tags( $email_content, $payment_id );
193
+	$attachments = apply_filters('give_offline_donation_attachments', array(), $payment_id, $payment_data);
194
+	$message     = give_do_email_tags($email_content, $payment_id);
195 195
 
196 196
 	$emails = Give()->emails;
197 197
 
198
-	$emails->__set( 'from_name', $from_name );
199
-	$emails->__set( 'from_email', $from_email );
200
-	$emails->__set( 'heading', __( 'Offline Donation Instructions', 'give' ) );
198
+	$emails->__set('from_name', $from_name);
199
+	$emails->__set('from_email', $from_email);
200
+	$emails->__set('heading', __('Offline Donation Instructions', 'give'));
201 201
 
202
-	$headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data );
203
-	$emails->__set( 'headers', $headers );
202
+	$headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data);
203
+	$emails->__set('headers', $headers);
204 204
 
205
-	$emails->send( $to_email, $subject, $message, $attachments );
205
+	$emails->send($to_email, $subject, $message, $attachments);
206 206
 
207 207
 }
208 208
 
@@ -219,54 +219,54 @@  discard block
 block discarded – undo
219 219
  * @return void
220 220
  *
221 221
  */
222
-function give_offline_send_admin_notice( $payment_id = 0 ) {
222
+function give_offline_send_admin_notice($payment_id = 0) {
223 223
 
224 224
 	/* Send an email notification to the admin */
225 225
 	$admin_email = give_get_admin_notice_emails();
226
-	$user_info   = give_get_payment_meta_user_info( $payment_id );
226
+	$user_info   = give_get_payment_meta_user_info($payment_id);
227 227
 
228
-	if ( isset( $user_info['id'] ) && $user_info['id'] > 0 ) {
229
-		$user_data = get_userdata( $user_info['id'] );
228
+	if (isset($user_info['id']) && $user_info['id'] > 0) {
229
+		$user_data = get_userdata($user_info['id']);
230 230
 		$name      = $user_data->display_name;
231
-	} elseif ( isset( $user_info['first_name'] ) && isset( $user_info['last_name'] ) ) {
232
-		$name = $user_info['first_name'] . ' ' . $user_info['last_name'];
231
+	} elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) {
232
+		$name = $user_info['first_name'].' '.$user_info['last_name'];
233 233
 	} else {
234 234
 		$name = $user_info['email'];
235 235
 	}
236 236
 
237
-	$amount = give_currency_filter( give_format_amount( give_get_payment_amount( $payment_id ), array( 'sanitize' => false ) ) );
237
+	$amount = give_currency_filter(give_format_amount(give_get_payment_amount($payment_id), array('sanitize' => false)));
238 238
 
239
-	$admin_subject = apply_filters( 'give_offline_admin_donation_notification_subject', __( 'New Pending Donation', 'give' ), $payment_id );
239
+	$admin_subject = apply_filters('give_offline_admin_donation_notification_subject', __('New Pending Donation', 'give'), $payment_id);
240 240
 
241
-	$admin_message = __( 'Dear Admin,', 'give' ) . "\n\n";
242
-	$admin_message .= sprintf(__( 'A new offline donation has been made on your website for %s.', 'give' ), $amount) . "\n\n";
243
-	$admin_message .= __( 'The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give' ) . "\n\n";
241
+	$admin_message = __('Dear Admin,', 'give')."\n\n";
242
+	$admin_message .= sprintf(__('A new offline donation has been made on your website for %s.', 'give'), $amount)."\n\n";
243
+	$admin_message .= __('The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give')."\n\n";
244 244
 
245 245
 
246
-	$admin_message .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n";
247
-	$admin_message .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n\n";
246
+	$admin_message .= '<strong>'.__('Donor:', 'give').'</strong> {fullname}'."\n";
247
+	$admin_message .= '<strong>'.__('Amount:', 'give').'</strong> {amount}'."\n\n";
248 248
 
249 249
 	$admin_message .= sprintf(
250 250
 		                  '<a href="%1$s">%2$s</a>',
251
-		                  admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $payment_id ),
252
-		                  __( 'View Donation Details &raquo;', 'give' )
253
-	                  ) . "\n\n";
251
+		                  admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id='.$payment_id),
252
+		                  __('View Donation Details &raquo;', 'give')
253
+	                  )."\n\n";
254 254
 
255
-	$admin_message = apply_filters( 'give_offline_admin_donation_notification', $admin_message, $payment_id );
256
-	$admin_message = give_do_email_tags( $admin_message, $payment_id );
255
+	$admin_message = apply_filters('give_offline_admin_donation_notification', $admin_message, $payment_id);
256
+	$admin_message = give_do_email_tags($admin_message, $payment_id);
257 257
 
258
-	$attachments   = apply_filters( 'give_offline_admin_donation_notification_attachments', array(), $payment_id );
259
-	$admin_headers = apply_filters( 'give_offline_admin_donation_notification_headers', array(), $payment_id );
258
+	$attachments   = apply_filters('give_offline_admin_donation_notification_attachments', array(), $payment_id);
259
+	$admin_headers = apply_filters('give_offline_admin_donation_notification_headers', array(), $payment_id);
260 260
 
261 261
 	//Send Email
262 262
 	$emails = Give()->emails;
263
-	$emails->__set( 'heading', __( 'New Offline Donation', 'give' ) );
263
+	$emails->__set('heading', __('New Offline Donation', 'give'));
264 264
 
265
-	if ( ! empty( $admin_headers ) ) {
266
-		$emails->__set( 'headers', $admin_headers );
265
+	if ( ! empty($admin_headers)) {
266
+		$emails->__set('headers', $admin_headers);
267 267
 	}
268 268
 
269
-	$emails->send( $admin_email, $admin_subject, $admin_message, $attachments );
269
+	$emails->send($admin_email, $admin_subject, $admin_message, $attachments);
270 270
 
271 271
 }
272 272
 
@@ -278,20 +278,20 @@  discard block
 block discarded – undo
278 278
  *
279 279
  * @return array
280 280
  */
281
-function give_offline_add_settings( $settings ) {
281
+function give_offline_add_settings($settings) {
282 282
 
283 283
 	// Bailout: Do not show offline gateways setting in to metabox if its disabled globally.
284
-	if ( in_array( 'offline', give_get_option( 'gateways' ) ) ) {
284
+	if (in_array('offline', give_get_option('gateways'))) {
285 285
 		return $settings;
286 286
 	}
287 287
 
288 288
 	//Vars
289 289
 	$prefix = '_give_';
290 290
 
291
-	$is_gateway_active = give_is_gateway_active( 'offline' );
291
+	$is_gateway_active = give_is_gateway_active('offline');
292 292
 
293 293
 	//this gateway isn't active
294
-	if ( ! $is_gateway_active ) {
294
+	if ( ! $is_gateway_active) {
295 295
 		//return settings and bounce
296 296
 		return $settings;
297 297
 	}
@@ -300,34 +300,34 @@  discard block
 block discarded – undo
300 300
 	$check_settings = array(
301 301
 
302 302
 		array(
303
-			'name'    => __( 'Offline Donations', 'give' ),
304
-			'desc'    => __( 'Do you want to customize the donation instructions for this form?', 'give' ),
305
-			'id'      => $prefix . 'customize_offline_donations',
303
+			'name'    => __('Offline Donations', 'give'),
304
+			'desc'    => __('Do you want to customize the donation instructions for this form?', 'give'),
305
+			'id'      => $prefix.'customize_offline_donations',
306 306
 			'type'    => 'radio_inline',
307 307
 			'default' => 'global',
308
-			'options' => apply_filters( 'give_forms_content_options_select', array(
309
-					'global'   => __( 'Global Option', 'give' ),
310
-					'enabled'  => __( 'Customize', 'give' ),
311
-					'disabled' => __( 'Disable', 'give' ),
308
+			'options' => apply_filters('give_forms_content_options_select', array(
309
+					'global'   => __('Global Option', 'give'),
310
+					'enabled'  => __('Customize', 'give'),
311
+					'disabled' => __('Disable', 'give'),
312 312
 				)
313 313
 			),
314 314
 		),
315 315
 		array(
316
-			'name'        => __( 'Billing Fields', 'give' ),
317
-			'desc'        => __( 'This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give' ),
318
-			'id'          => $prefix . 'offline_donation_enable_billing_fields_single',
316
+			'name'        => __('Billing Fields', 'give'),
317
+			'desc'        => __('This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give'),
318
+			'id'          => $prefix.'offline_donation_enable_billing_fields_single',
319 319
 			'row_classes' => 'give-subfield give-hidden',
320 320
 			'type'        => 'radio_inline',
321 321
 			'default'     => 'disabled',
322 322
 			'options'     => array(
323
-				'enabled'  => __( 'Enabled', 'give' ),
324
-				'disabled' => __( 'Disabled', 'give' ),
323
+				'enabled'  => __('Enabled', 'give'),
324
+				'disabled' => __('Disabled', 'give'),
325 325
 			),
326 326
 		),
327 327
 		array(
328
-			'id'          => $prefix . 'offline_checkout_notes',
329
-			'name'        => __( 'Donation Instructions', 'give' ),
330
-			'desc'        => __( 'Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ),
328
+			'id'          => $prefix.'offline_checkout_notes',
329
+			'name'        => __('Donation Instructions', 'give'),
330
+			'desc'        => __('Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give'),
331 331
 			'default'     => give_get_default_offline_donation_content(),
332 332
 			'type'        => 'wysiwyg',
333 333
 			'row_classes' => 'give-subfield give-hidden',
@@ -336,17 +336,17 @@  discard block
 block discarded – undo
336 336
 			),
337 337
 		),
338 338
 		array(
339
-			'id'          => $prefix . 'offline_donation_subject',
340
-			'name'        => __( 'Email Subject', 'give' ),
341
-			'desc'        => __( 'Enter the subject line for the donation receipt email.', 'give' ),
342
-			'default'     => __( '{form_title} - Offline Donation Instructions', 'give' ),
339
+			'id'          => $prefix.'offline_donation_subject',
340
+			'name'        => __('Email Subject', 'give'),
341
+			'desc'        => __('Enter the subject line for the donation receipt email.', 'give'),
342
+			'default'     => __('{form_title} - Offline Donation Instructions', 'give'),
343 343
 			'row_classes' => 'give-subfield give-hidden',
344 344
 			'type'        => 'text',
345 345
 		),
346 346
 		array(
347
-			'id'          => $prefix . 'offline_donation_email',
348
-			'name'        => __( 'Email Instructions', 'give' ),
349
-			'desc'        => __( 'Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ) . ' ' . __( 'Available template tags:', 'give' ) . give_get_emails_tags_list(),
347
+			'id'          => $prefix.'offline_donation_email',
348
+			'name'        => __('Email Instructions', 'give'),
349
+			'desc'        => __('Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give').' '.__('Available template tags:', 'give').give_get_emails_tags_list(),
350 350
 			'default'     => give_get_default_offline_donation_email_content(),
351 351
 			'type'        => 'wysiwyg',
352 352
 			'row_classes' => 'give-subfield give-hidden',
@@ -358,14 +358,14 @@  discard block
 block discarded – undo
358 358
 			'name'  => 'offline_docs',
359 359
 			'type'  => 'docs_link',
360 360
 			'url'   => 'http://docs.givewp.com/settings-gateway-offline-donations',
361
-			'title' => __( 'Offline Donations', 'give' ),
361
+			'title' => __('Offline Donations', 'give'),
362 362
 		),
363 363
 	);
364 364
 
365
-	return array_merge( $settings, $check_settings );
365
+	return array_merge($settings, $check_settings);
366 366
 }
367 367
 
368
-add_filter( 'give_forms_offline_donations_metabox_fields', 'give_offline_add_settings' );
368
+add_filter('give_forms_offline_donations_metabox_fields', 'give_offline_add_settings');
369 369
 
370 370
 
371 371
 /**
@@ -377,32 +377,32 @@  discard block
 block discarded – undo
377 377
  */
378 378
 function give_get_default_offline_donation_content() {
379 379
 
380
-	$sitename = get_bloginfo( 'sitename' );
380
+	$sitename = get_bloginfo('sitename');
381 381
 
382
-	$default_text = '<p>' . __( 'In order to make an offline donation we ask that you please follow these instructions', 'give' ) . ': </p>';
382
+	$default_text = '<p>'.__('In order to make an offline donation we ask that you please follow these instructions', 'give').': </p>';
383 383
 	$default_text .= '<ol>';
384 384
 	$default_text .= '<li>';
385 385
 	$default_text .= sprintf(
386 386
 	/* translators: %s: site name */
387
-		__( 'Make a check payable to "%s"', 'give' ),
387
+		__('Make a check payable to "%s"', 'give'),
388 388
 		$sitename
389 389
 	);
390 390
 	$default_text .= '</li>';
391 391
 	$default_text .= '<li>';
392 392
 	$default_text .= sprintf(
393 393
 	/* translators: %s: site name */
394
-		__( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ),
394
+		__('On the memo line of the check, please indicate that the donation is for "%s"', 'give'),
395 395
 		$sitename
396 396
 	);
397 397
 	$default_text .= '</li>';
398
-	$default_text .= '<li>' . __( 'Please mail your check to:', 'give' ) . '</li>';
398
+	$default_text .= '<li>'.__('Please mail your check to:', 'give').'</li>';
399 399
 	$default_text .= '</ol>';
400
-	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>' . $sitename . '</em><br>';
400
+	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>'.$sitename.'</em><br>';
401 401
 	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>111 Not A Real St.</em><br>';
402 402
 	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>Anytown, CA 12345 </em><br>';
403
-	$default_text .= '<p>' . __( 'All contributions will be gratefully acknowledged and are tax deductible.', 'give' ) . '</p>';
403
+	$default_text .= '<p>'.__('All contributions will be gratefully acknowledged and are tax deductible.', 'give').'</p>';
404 404
 
405
-	return apply_filters( 'give_default_offline_donation_content', $default_text );
405
+	return apply_filters('give_default_offline_donation_content', $default_text);
406 406
 
407 407
 }
408 408
 
@@ -415,34 +415,34 @@  discard block
 block discarded – undo
415 415
  */
416 416
 function give_get_default_offline_donation_email_content() {
417 417
 
418
-	$sitename     = get_bloginfo( 'sitename' );
419
-	$default_text = '<p>' . __( 'Dear {name},', 'give' ) . '</p>';
420
-	$default_text .= '<p>' . __( 'Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions:', 'give' ) . '</p>';
418
+	$sitename     = get_bloginfo('sitename');
419
+	$default_text = '<p>'.__('Dear {name},', 'give').'</p>';
420
+	$default_text .= '<p>'.__('Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions:', 'give').'</p>';
421 421
 	$default_text .= '<ol>';
422 422
 	$default_text .= '<li>';
423 423
 	$default_text .= sprintf(
424 424
 	/* translators: %s: site name */
425
-		__( 'Make a check payable to "%s"', 'give' ),
425
+		__('Make a check payable to "%s"', 'give'),
426 426
 		$sitename
427 427
 	);
428 428
 	$default_text .= '</li>';
429 429
 	$default_text .= '<li>';
430 430
 	$default_text .= sprintf(
431 431
 	/* translators: %s: site name */
432
-		__( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ),
432
+		__('On the memo line of the check, please indicate that the donation is for "%s"', 'give'),
433 433
 		$sitename
434 434
 	);
435 435
 	$default_text .= '</li>';
436
-	$default_text .= '<li>' . __( 'Please mail your check to:', 'give' ) . '</li>';
436
+	$default_text .= '<li>'.__('Please mail your check to:', 'give').'</li>';
437 437
 	$default_text .= '</ol>';
438
-	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>' . $sitename . '</em><br>';
438
+	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>'.$sitename.'</em><br>';
439 439
 	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>111 Not A Real St.</em><br>';
440 440
 	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>Anytown, CA 12345 </em><br>';
441
-	$default_text .= '<p>' . __( 'Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give' ) . '</p>';
442
-	$default_text .= '<p>' . __( 'Sincerely,', 'give' ) . '</p>';
443
-	$default_text .= '<p>' . $sitename . '</p>';
441
+	$default_text .= '<p>'.__('Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give').'</p>';
442
+	$default_text .= '<p>'.__('Sincerely,', 'give').'</p>';
443
+	$default_text .= '<p>'.$sitename.'</p>';
444 444
 
445
-	return apply_filters( 'give_default_offline_donation_content', $default_text );
445
+	return apply_filters('give_default_offline_donation_content', $default_text);
446 446
 
447 447
 }
448 448
 
@@ -456,17 +456,17 @@  discard block
 block discarded – undo
456 456
  *
457 457
  * @return string
458 458
  */
459
-function give_offline_donation_receipt_status_notice( $notice, $id ) {
460
-	$payment = new Give_Payment( $id );
459
+function give_offline_donation_receipt_status_notice($notice, $id) {
460
+	$payment = new Give_Payment($id);
461 461
 
462
-	if ( 'offline' !== $payment->gateway || $payment->is_completed() ) {
462
+	if ('offline' !== $payment->gateway || $payment->is_completed()) {
463 463
 		return $notice;
464 464
 	}
465 465
 
466
-	return Give()->notices->print_frontend_notice( __( 'Payment Pending: Please follow the instructions below to complete your donation.', 'give' ), false, 'warning' );
466
+	return Give()->notices->print_frontend_notice(__('Payment Pending: Please follow the instructions below to complete your donation.', 'give'), false, 'warning');
467 467
 }
468 468
 
469
-add_filter( 'give_receipt_status_notice', 'give_offline_donation_receipt_status_notice', 10, 2 );
469
+add_filter('give_receipt_status_notice', 'give_offline_donation_receipt_status_notice', 10, 2);
470 470
 
471 471
 /**
472 472
  * Get offline payment instructions.
@@ -478,27 +478,27 @@  discard block
 block discarded – undo
478 478
  *
479 479
  * @return string
480 480
  */
481
-function give_get_offline_payment_instruction( $form_id, $wpautop = false ) {
481
+function give_get_offline_payment_instruction($form_id, $wpautop = false) {
482 482
 	// Bailout.
483
-	if ( ! $form_id ) {
483
+	if ( ! $form_id) {
484 484
 		return '';
485 485
 	}
486 486
 
487
-	$post_offline_customization_option = give_get_meta( $form_id, '_give_customize_offline_donations', true );
488
-	$post_offline_instructions         = give_get_meta( $form_id, '_give_offline_checkout_notes', true );
489
-	$global_offline_instruction        = give_get_option( 'global_offline_donation_content' );
487
+	$post_offline_customization_option = give_get_meta($form_id, '_give_customize_offline_donations', true);
488
+	$post_offline_instructions         = give_get_meta($form_id, '_give_offline_checkout_notes', true);
489
+	$global_offline_instruction        = give_get_option('global_offline_donation_content');
490 490
 	$offline_instructions              = $global_offline_instruction;
491 491
 
492
-	if ( give_is_setting_enabled( $post_offline_customization_option ) ) {
492
+	if (give_is_setting_enabled($post_offline_customization_option)) {
493 493
 		$offline_instructions = $post_offline_instructions;
494 494
 	}
495 495
 
496
-	$settings_url = admin_url( 'post.php?post=' . $form_id . '&action=edit&message=1' );
496
+	$settings_url = admin_url('post.php?post='.$form_id.'&action=edit&message=1');
497 497
 
498 498
 	/* translators: %s: form settings url */
499
-	$offline_instructions = ! empty( $offline_instructions ) ? $offline_instructions : sprintf( __( 'Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give' ), $settings_url );
499
+	$offline_instructions = ! empty($offline_instructions) ? $offline_instructions : sprintf(__('Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give'), $settings_url);
500 500
 
501
-	return ( $wpautop ? wpautop( $offline_instructions ) : $offline_instructions );
501
+	return ($wpautop ? wpautop($offline_instructions) : $offline_instructions);
502 502
 }
503 503
 
504 504
 
@@ -512,24 +512,24 @@  discard block
 block discarded – undo
512 512
  *
513 513
  * @return array
514 514
  */
515
-function give_filter_offline_gateway( $gateway_list, $form_id ) {
515
+function give_filter_offline_gateway($gateway_list, $form_id) {
516 516
 	if (
517 517
 		// Show offline payment gateway if enable for new donation form.
518
-		( false === strpos( $_SERVER['REQUEST_URI'], '/wp-admin/post-new.php?post_type=give_forms' ) )
518
+		(false === strpos($_SERVER['REQUEST_URI'], '/wp-admin/post-new.php?post_type=give_forms'))
519 519
 		&& $form_id
520
-		&& ! give_is_setting_enabled( give_get_meta( $form_id, '_give_customize_offline_donations', true ), array(
520
+		&& ! give_is_setting_enabled(give_get_meta($form_id, '_give_customize_offline_donations', true), array(
521 521
 			'enabled',
522 522
 			'global',
523
-		) )
523
+		))
524 524
 	) {
525
-		unset( $gateway_list['offline'] );
525
+		unset($gateway_list['offline']);
526 526
 	}
527 527
 
528 528
 	// Output.
529 529
 	return $gateway_list;
530 530
 }
531 531
 
532
-add_filter( 'give_enabled_payment_gateways', 'give_filter_offline_gateway', 10, 2 );
532
+add_filter('give_enabled_payment_gateways', 'give_filter_offline_gateway', 10, 2);
533 533
 
534 534
 /**
535 535
  * Set default gateway to global default payment gateway
@@ -543,10 +543,10 @@  discard block
 block discarded – undo
543 543
  *
544 544
  * @return void
545 545
  */
546
-function _give_customize_offline_donations_on_save_callback( $meta_key, $meta_value, $postid ) {
547
-	if ( ! give_is_setting_enabled( $meta_value ) && ( 'offline' === give_get_meta( $postid, '_give_default_gateway', true ) ) ) {
548
-		give_update_meta( $postid, '_give_default_gateway', 'global' );
546
+function _give_customize_offline_donations_on_save_callback($meta_key, $meta_value, $postid) {
547
+	if ( ! give_is_setting_enabled($meta_value) && ('offline' === give_get_meta($postid, '_give_default_gateway', true))) {
548
+		give_update_meta($postid, '_give_default_gateway', 'global');
549 549
 	}
550 550
 }
551 551
 
552
-add_filter( 'give_save__give_customize_offline_donations', '_give_customize_offline_donations_on_save_callback', 10, 3 );
552
+add_filter('give_save__give_customize_offline_donations', '_give_customize_offline_donations_on_save_callback', 10, 3);
Please login to merge, or discard this patch.
includes/admin/tools/export/export-actions.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  * @license     https://opensource.org/licenses/gpl-license GNU Public License
11 11
  */
12 12
 
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -22,13 +22,13 @@  discard block
 block discarded – undo
22 22
  */
23 23
 function give_process_batch_export_form() {
24 24
 
25
-	if ( ! wp_verify_nonce( $_REQUEST['nonce'], 'give-batch-export' ) ) {
26
-		wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array(
25
+	if ( ! wp_verify_nonce($_REQUEST['nonce'], 'give-batch-export')) {
26
+		wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array(
27 27
 			'response' => 403,
28
-		) );
28
+		));
29 29
 	}
30 30
 
31
-	require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/class-batch-export.php';
31
+	require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/class-batch-export.php';
32 32
 
33 33
 	/**
34 34
 	 * Fires before batch export.
@@ -37,14 +37,14 @@  discard block
 block discarded – undo
37 37
 	 *
38 38
 	 * @param string $class Export class.
39 39
 	 */
40
-	do_action( 'give_batch_export_class_include', $_REQUEST['class'] );
40
+	do_action('give_batch_export_class_include', $_REQUEST['class']);
41 41
 
42 42
 	$export = new $_REQUEST['class'];
43 43
 	$export->export();
44 44
 
45 45
 }
46 46
 
47
-add_action( 'give_form_batch_export', 'give_process_batch_export_form' );
47
+add_action('give_form_batch_export', 'give_process_batch_export_form');
48 48
 
49 49
 /**
50 50
  * Exports earnings for a specified time period.
@@ -55,14 +55,14 @@  discard block
 block discarded – undo
55 55
  * @return void
56 56
  */
57 57
 function give_export_earnings() {
58
-	require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/class-export-earnings.php';
58
+	require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/class-export-earnings.php';
59 59
 
60 60
 	$earnings_export = new Give_Earnings_Export();
61 61
 
62 62
 	$earnings_export->export();
63 63
 }
64 64
 
65
-add_action( 'give_earnings_export', 'give_export_earnings' );
65
+add_action('give_earnings_export', 'give_export_earnings');
66 66
 
67 67
 
68 68
 /**
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
  * @return void
73 73
  */
74 74
 function give_register_batch_exporters() {
75
-	if ( is_admin() ) {
75
+	if (is_admin()) {
76 76
 		/**
77 77
 		 * Fires in the admin, while plugins loaded.
78 78
 		 *
@@ -82,11 +82,11 @@  discard block
 block discarded – undo
82 82
 		 *
83 83
 		 * @param string $class Export class.
84 84
 		 */
85
-		do_action( 'give_register_batch_exporter' );
85
+		do_action('give_register_batch_exporter');
86 86
 	}
87 87
 }
88 88
 
89
-add_action( 'plugins_loaded', 'give_register_batch_exporters' );
89
+add_action('plugins_loaded', 'give_register_batch_exporters');
90 90
 
91 91
 /**
92 92
  * Register the payments batch exporter
@@ -94,10 +94,10 @@  discard block
 block discarded – undo
94 94
  * @since  1.5
95 95
  */
96 96
 function give_register_payments_batch_export() {
97
-	add_action( 'give_batch_export_class_include', 'give_include_payments_batch_processor', 10, 1 );
97
+	add_action('give_batch_export_class_include', 'give_include_payments_batch_processor', 10, 1);
98 98
 }
99 99
 
100
-add_action( 'give_register_batch_exporter', 'give_register_payments_batch_export', 10 );
100
+add_action('give_register_batch_exporter', 'give_register_payments_batch_export', 10);
101 101
 
102 102
 /**
103 103
  * Loads the payments batch process if needed
@@ -108,10 +108,10 @@  discard block
 block discarded – undo
108 108
  *
109 109
  * @return void
110 110
  */
111
-function give_include_payments_batch_processor( $class ) {
111
+function give_include_payments_batch_processor($class) {
112 112
 
113
-	if ( 'Give_Batch_Payments_Export' === $class ) {
114
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/class-batch-export-payments.php';
113
+	if ('Give_Batch_Payments_Export' === $class) {
114
+		require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/class-batch-export-payments.php';
115 115
 	}
116 116
 
117 117
 }
@@ -122,10 +122,10 @@  discard block
 block discarded – undo
122 122
  * @since  1.5.2
123 123
  */
124 124
 function give_register_donors_batch_export() {
125
-	add_action( 'give_batch_export_class_include', 'give_include_donors_batch_processor', 10, 1 );
125
+	add_action('give_batch_export_class_include', 'give_include_donors_batch_processor', 10, 1);
126 126
 }
127 127
 
128
-add_action( 'give_register_batch_exporter', 'give_register_donors_batch_export', 10 );
128
+add_action('give_register_batch_exporter', 'give_register_donors_batch_export', 10);
129 129
 
130 130
 /**
131 131
  * Loads the donors batch process if needed.
@@ -136,10 +136,10 @@  discard block
 block discarded – undo
136 136
  *
137 137
  * @return void
138 138
  */
139
-function give_include_donors_batch_processor( $class ) {
139
+function give_include_donors_batch_processor($class) {
140 140
 
141
-	if ( 'Give_Batch_Donors_Export' === $class ) {
142
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/class-batch-export-donors.php';
141
+	if ('Give_Batch_Donors_Export' === $class) {
142
+		require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/class-batch-export-donors.php';
143 143
 	}
144 144
 
145 145
 }
@@ -150,10 +150,10 @@  discard block
 block discarded – undo
150 150
  * @since  1.5
151 151
  */
152 152
 function give_register_forms_batch_export() {
153
-	add_action( 'give_batch_export_class_include', 'give_include_forms_batch_processor', 10, 1 );
153
+	add_action('give_batch_export_class_include', 'give_include_forms_batch_processor', 10, 1);
154 154
 }
155 155
 
156
-add_action( 'give_register_batch_exporter', 'give_register_forms_batch_export', 10 );
156
+add_action('give_register_batch_exporter', 'give_register_forms_batch_export', 10);
157 157
 
158 158
 /**
159 159
  * Loads the file downloads batch process if needed
@@ -164,10 +164,10 @@  discard block
 block discarded – undo
164 164
  *
165 165
  * @return void
166 166
  */
167
-function give_include_forms_batch_processor( $class ) {
167
+function give_include_forms_batch_processor($class) {
168 168
 
169
-	if ( 'Give_Batch_Forms_Export' === $class ) {
170
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/class-batch-export-forms.php';
169
+	if ('Give_Batch_Forms_Export' === $class) {
170
+		require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/class-batch-export-forms.php';
171 171
 	}
172 172
 
173 173
 }
Please login to merge, or discard this patch.
includes/admin/tools/export/export-functions.php 1 patch
Spacing   +27 added lines, -28 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
 
@@ -25,14 +25,14 @@  discard block
 block discarded – undo
25 25
  */
26 26
 function give_do_ajax_export() {
27 27
 
28
-	require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/class-batch-export.php';
28
+	require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/class-batch-export.php';
29 29
 
30
-	parse_str( $_POST['form'], $form );
30
+	parse_str($_POST['form'], $form);
31 31
 
32 32
 	$_REQUEST = $form = (array) $form;
33 33
 
34
-	if ( ! wp_verify_nonce( $_REQUEST['give_ajax_export'], 'give_ajax_export' ) ) {
35
-		die( '-2' );
34
+	if ( ! wp_verify_nonce($_REQUEST['give_ajax_export'], 'give_ajax_export')) {
35
+		die('-2');
36 36
 	}
37 37
 
38 38
 	/**
@@ -42,28 +42,28 @@  discard block
 block discarded – undo
42 42
 	 *
43 43
 	 * @param string $class Export class.
44 44
 	 */
45
-	do_action( 'give_batch_export_class_include', $form['give-export-class'] );
45
+	do_action('give_batch_export_class_include', $form['give-export-class']);
46 46
 
47
-	$step   = absint( $_POST['step'] );
48
-	$class  = sanitize_text_field( $form['give-export-class'] );
47
+	$step   = absint($_POST['step']);
48
+	$class  = sanitize_text_field($form['give-export-class']);
49 49
 
50 50
 	/* @var Give_Batch_Export $export */
51
-	$export = new $class( $step );
51
+	$export = new $class($step);
52 52
 
53
-	if ( ! $export->can_export() ) {
54
-		die( '-1' );
53
+	if ( ! $export->can_export()) {
54
+		die('-1');
55 55
 	}
56 56
 
57
-	if ( ! $export->is_writable ) {
57
+	if ( ! $export->is_writable) {
58 58
 		$json_args = array(
59 59
 			'error'   => true,
60
-			'message' => esc_html__( 'Export location or file not writable.', 'give' )
60
+			'message' => esc_html__('Export location or file not writable.', 'give')
61 61
 		);
62 62
 		echo json_encode($json_args);
63 63
 		exit;
64 64
 	}
65 65
 
66
-	$export->set_properties( give_clean( $_REQUEST ) );
66
+	$export->set_properties(give_clean($_REQUEST));
67 67
 
68 68
 	$export->pre_fetch();
69 69
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 
72 72
 	$percentage = $export->get_percentage_complete();
73 73
 
74
-	if ( $ret ) {
74
+	if ($ret) {
75 75
 
76 76
 		$step += 1;
77 77
 		$json_data = array(
@@ -79,18 +79,17 @@  discard block
 block discarded – undo
79 79
 			'percentage' => $percentage
80 80
 		);
81 81
 
82
-	} elseif ( true === $export->is_empty ) {
82
+	} elseif (true === $export->is_empty) {
83 83
 
84 84
 		$json_data = array(
85 85
 			'error'   => true,
86
-			'message' => esc_html__( 'No data found for export parameters.', 'give' )
86
+			'message' => esc_html__('No data found for export parameters.', 'give')
87 87
 		);
88 88
 
89
-	} elseif ( true === $export->done && true === $export->is_void ) {
89
+	} elseif (true === $export->done && true === $export->is_void) {
90 90
 
91
-		$message = ! empty( $export->message ) ?
92
-			$export->message :
93
-			esc_html__( 'Batch Processing Complete', 'give' );
91
+		$message = ! empty($export->message) ?
92
+			$export->message : esc_html__('Batch Processing Complete', 'give');
94 93
 
95 94
 		$json_data = array(
96 95
 			'success' => true,
@@ -99,23 +98,23 @@  discard block
 block discarded – undo
99 98
 
100 99
 	} else {
101 100
 		
102
-		$args = array_merge( $_REQUEST, array(
101
+		$args = array_merge($_REQUEST, array(
103 102
 			'step'        => $step,
104 103
 			'class'       => $class,
105
-			'nonce'       => wp_create_nonce( 'give-batch-export' ),
104
+			'nonce'       => wp_create_nonce('give-batch-export'),
106 105
 			'give_action' => 'form_batch_export',
107
-		) );
106
+		));
108 107
 
109 108
 		$json_data = array(
110 109
 			'step' => 'done',
111
-			'url' => add_query_arg( $args, admin_url() )
110
+			'url' => add_query_arg($args, admin_url())
112 111
 		);
113 112
 
114 113
 	}
115 114
 
116
-	$export->unset_properties( give_clean( $_REQUEST ), $export );
117
-	echo json_encode( $json_data );
115
+	$export->unset_properties(give_clean($_REQUEST), $export);
116
+	echo json_encode($json_data);
118 117
 	exit;
119 118
 }
120 119
 
121
-add_action( 'wp_ajax_give_do_ajax_export', 'give_do_ajax_export' );
120
+add_action('wp_ajax_give_do_ajax_export', 'give_do_ajax_export');
Please login to merge, or discard this patch.
includes/admin/tools/export/class-batch-export-donors.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -245,7 +245,7 @@
 block discarded – undo
245 245
 
246 246
 					// Continue if donor already included.
247 247
 					if ( empty( $payment->customer_id ) ||
248
-					     in_array( $payment->customer_id, $cached_donor_ids )
248
+						 in_array( $payment->customer_id, $cached_donor_ids )
249 249
 					) {
250 250
 						continue;
251 251
 					}
Please login to merge, or discard this patch.
Spacing   +103 added lines, -105 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
 
@@ -70,23 +70,23 @@  discard block
 block discarded – undo
70 70
 	 *
71 71
 	 * @param array $request The Form Data passed into the batch processing
72 72
 	 */
73
-	public function set_properties( $request ) {
73
+	public function set_properties($request) {
74 74
 
75 75
 		// Set data from form submission
76
-		if ( isset( $_POST['form'] ) ) {
77
-			parse_str( $_POST['form'], $this->data );
76
+		if (isset($_POST['form'])) {
77
+			parse_str($_POST['form'], $this->data);
78 78
 		}
79 79
 
80 80
 		$this->form = $this->data['forms'];
81 81
 
82 82
 		// Setup donor ids cache.
83
-		if ( ! empty( $this->form ) ) {
83
+		if ( ! empty($this->form)) {
84 84
 			// Cache donor ids to output unique list of donor.
85
-			$this->query_id = give_clean( $_REQUEST['give_export_option']['query_id'] );
85
+			$this->query_id = give_clean($_REQUEST['give_export_option']['query_id']);
86 86
 			$this->cache_donor_ids();
87 87
 		}
88 88
 
89
-		$this->price_id = ! empty( $request['give_price_option'] ) && 'all' !== $request['give_price_option'] ? absint( $request['give_price_option'] ) : null;
89
+		$this->price_id = ! empty($request['give_price_option']) && 'all' !== $request['give_price_option'] ? absint($request['give_price_option']) : null;
90 90
 
91 91
 	}
92 92
 
@@ -101,12 +101,12 @@  discard block
 block discarded – undo
101 101
 		// Fetch already cached donor ids.
102 102
 		$donor_ids = $this->donor_ids;
103 103
 
104
-		if ( $cached_donor_ids = Give_Cache::get( $this->query_id, true ) ) {
105
-			$donor_ids = array_unique( array_merge( $cached_donor_ids, $this->donor_ids ) );
104
+		if ($cached_donor_ids = Give_Cache::get($this->query_id, true)) {
105
+			$donor_ids = array_unique(array_merge($cached_donor_ids, $this->donor_ids));
106 106
 		}
107 107
 
108
-		$donor_ids = array_values( $donor_ids );
109
-		Give_Cache::set( $this->query_id, $donor_ids, HOUR_IN_SECONDS, true );
108
+		$donor_ids = array_values($donor_ids);
109
+		Give_Cache::set($this->query_id, $donor_ids, HOUR_IN_SECONDS, true);
110 110
 	}
111 111
 
112 112
 	/**
@@ -118,14 +118,14 @@  discard block
 block discarded – undo
118 118
 	 */
119 119
 	public function csv_cols() {
120 120
 
121
-		$columns = isset( $this->data['give_export_option'] ) ? $this->data['give_export_option'] : array();
121
+		$columns = isset($this->data['give_export_option']) ? $this->data['give_export_option'] : array();
122 122
 
123 123
 		// We need columns.
124
-		if ( empty( $columns ) ) {
124
+		if (empty($columns)) {
125 125
 			return false;
126 126
 		}
127 127
 
128
-		$cols = $this->get_cols( $columns );
128
+		$cols = $this->get_cols($columns);
129 129
 
130 130
 		return $cols;
131 131
 	}
@@ -137,41 +137,41 @@  discard block
 block discarded – undo
137 137
 	 *
138 138
 	 * @return array
139 139
 	 */
140
-	private function get_cols( $columns ) {
140
+	private function get_cols($columns) {
141 141
 
142 142
 		$cols = array();
143 143
 
144
-		foreach ( $columns as $key => $value ) {
144
+		foreach ($columns as $key => $value) {
145 145
 
146
-			switch ( $key ) {
146
+			switch ($key) {
147 147
 				case 'full_name' :
148
-					$cols['full_name'] = esc_html__( 'Full Name', 'give' );
148
+					$cols['full_name'] = esc_html__('Full Name', 'give');
149 149
 					break;
150 150
 				case 'email' :
151
-					$cols['email'] = esc_html__( 'Email Address', 'give' );
151
+					$cols['email'] = esc_html__('Email Address', 'give');
152 152
 					break;
153 153
 				case 'address' :
154
-					$cols['address_line1']   = esc_html__( 'Address', 'give' );
155
-					$cols['address_line2']   = esc_html__( 'Address 2', 'give' );
156
-					$cols['address_city']    = esc_html__( 'City', 'give' );
157
-					$cols['address_state']   = esc_html__( 'State', 'give' );
158
-					$cols['address_zip']     = esc_html__( 'Zip', 'give' );
159
-					$cols['address_country'] = esc_html__( 'Country', 'give' );
154
+					$cols['address_line1']   = esc_html__('Address', 'give');
155
+					$cols['address_line2']   = esc_html__('Address 2', 'give');
156
+					$cols['address_city']    = esc_html__('City', 'give');
157
+					$cols['address_state']   = esc_html__('State', 'give');
158
+					$cols['address_zip']     = esc_html__('Zip', 'give');
159
+					$cols['address_country'] = esc_html__('Country', 'give');
160 160
 					break;
161 161
 				case 'userid' :
162
-					$cols['userid'] = esc_html__( 'User ID', 'give' );
162
+					$cols['userid'] = esc_html__('User ID', 'give');
163 163
 					break;
164 164
 				case 'donation_form' :
165
-					$cols['donation_form'] = esc_html__( 'Donation Form', 'give' );
165
+					$cols['donation_form'] = esc_html__('Donation Form', 'give');
166 166
 					break;
167 167
 				case 'date_first_donated' :
168
-					$cols['date_first_donated'] = esc_html__( 'First Donation Date', 'give' );
168
+					$cols['date_first_donated'] = esc_html__('First Donation Date', 'give');
169 169
 					break;
170 170
 				case 'donations' :
171
-					$cols['donations'] = esc_html__( 'Number of Donations', 'give' );
171
+					$cols['donations'] = esc_html__('Number of Donations', 'give');
172 172
 					break;
173 173
 				case 'donation_sum' :
174
-					$cols['donation_sum'] = esc_html__( 'Sum of Donations', 'give' );
174
+					$cols['donation_sum'] = esc_html__('Sum of Donations', 'give');
175 175
 					break;
176 176
 			}
177 177
 		}
@@ -192,29 +192,29 @@  discard block
 block discarded – undo
192 192
 		$i = 0;
193 193
 
194 194
 		$data             = array();
195
-		$cached_donor_ids = Give_Cache::get( $this->query_id, true );
195
+		$cached_donor_ids = Give_Cache::get($this->query_id, true);
196 196
 
197
-		if ( ! empty( $this->form ) ) {
197
+		if ( ! empty($this->form)) {
198 198
 
199 199
 			// Export donors for a specific donation form and also within specified timeframe
200 200
 			$args = array(
201 201
 				'output'     => 'payments', // Use 'posts' to get standard post objects
202
-				'post_type'  => array( 'give_payment' ),
202
+				'post_type'  => array('give_payment'),
203 203
 				'number'     => 30,
204 204
 				'paged'      => $this->step,
205 205
 				'status'     => 'publish',
206 206
 				'meta_key'   => '_give_payment_form_id',
207
-				'meta_value' => absint( $this->form ),
207
+				'meta_value' => absint($this->form),
208 208
 			);
209 209
 
210 210
 			// Check for date option filter
211
-			if ( ! empty( $this->data['donor_export_start_date'] ) || ! empty( $this->data['donor_export_end_date'] ) ) {
212
-				$args['start_date'] = ! empty( $this->data['donor_export_start_date'] ) ? date( 'Y-n-d 00:00:00', strtotime( $this->data['donor_export_start_date'] ) ) : date( 'Y-n-d 23:59:59', '1970-1-01 00:00:00' );
213
-				$args['end_date']   = ! empty( $this->data['donor_export_end_date'] ) ? date( 'Y-n-d 23:59:59', strtotime( $this->data['donor_export_end_date'] ) ) : date( 'Y-n-d 23:59:59', current_time( 'timestamp' ) );
211
+			if ( ! empty($this->data['donor_export_start_date']) || ! empty($this->data['donor_export_end_date'])) {
212
+				$args['start_date'] = ! empty($this->data['donor_export_start_date']) ? date('Y-n-d 00:00:00', strtotime($this->data['donor_export_start_date'])) : date('Y-n-d 23:59:59', '1970-1-01 00:00:00');
213
+				$args['end_date']   = ! empty($this->data['donor_export_end_date']) ? date('Y-n-d 23:59:59', strtotime($this->data['donor_export_end_date'])) : date('Y-n-d 23:59:59', current_time('timestamp'));
214 214
 			}
215 215
 
216 216
 			// Check for price option.
217
-			if ( null !== $this->price_id ) {
217
+			if (null !== $this->price_id) {
218 218
 				$args['meta_query'] = array(
219 219
 					array(
220 220
 						'key'   => '_give_payment_price_id',
@@ -223,45 +223,43 @@  discard block
 block discarded – undo
223 223
 				);
224 224
 			}
225 225
 
226
-			$payments_query = new Give_Payments_Query( $args );
226
+			$payments_query = new Give_Payments_Query($args);
227 227
 			$payments       = $payments_query->get_payments();
228 228
 
229
-			if ( $payments ) {
229
+			if ($payments) {
230 230
 				/* @var Give_Payment $payment */
231
-				foreach ( $payments as $payment ) {
231
+				foreach ($payments as $payment) {
232 232
 					// Set donation sum.
233
-					$this->payment_stats[ $payment->customer_id ]['donation_sum'] = isset( $this->payment_stats[ $payment->customer_id ]['donation_sum'] ) ?
234
-						$this->payment_stats[ $payment->customer_id ]['donation_sum'] :
235
-						0;
236
-					$this->payment_stats[ $payment->customer_id ]['donation_sum'] += $payment->total;
233
+					$this->payment_stats[$payment->customer_id]['donation_sum'] = isset($this->payment_stats[$payment->customer_id]['donation_sum']) ?
234
+						$this->payment_stats[$payment->customer_id]['donation_sum'] : 0;
235
+					$this->payment_stats[$payment->customer_id]['donation_sum'] += $payment->total;
237 236
 
238 237
 					// Set donation count.
239
-					$this->payment_stats[ $payment->customer_id ]['donations'] = isset( $this->payment_stats[ $payment->customer_id ]['donations'] ) ?
240
-						++ $this->payment_stats[ $payment->customer_id ]['donations'] :
241
-						1;
238
+					$this->payment_stats[$payment->customer_id]['donations'] = isset($this->payment_stats[$payment->customer_id]['donations']) ?
239
+						++$this->payment_stats[$payment->customer_id]['donations'] : 1;
242 240
 
243 241
 					// Set donation form name.
244
-					$this->payment_stats[ $payment->customer_id ]['form_title'] = $payment->form_title;
242
+					$this->payment_stats[$payment->customer_id]['form_title'] = $payment->form_title;
245 243
 
246 244
 					// Continue if donor already included.
247
-					if ( empty( $payment->customer_id ) ||
248
-					     in_array( $payment->customer_id, $cached_donor_ids )
245
+					if (empty($payment->customer_id) ||
246
+					     in_array($payment->customer_id, $cached_donor_ids)
249 247
 					) {
250 248
 						continue;
251 249
 					}
252 250
 
253 251
 					$this->donor_ids[] = $cached_donor_ids[] = $payment->customer_id;
254 252
 
255
-					$i ++;
253
+					$i++;
256 254
 				}
257 255
 
258
-				if ( ! empty( $this->donor_ids ) ) {
259
-					foreach ( $this->donor_ids as $donor_id ) {
260
-						$donor                      = Give()->donors->get_donor_by( 'id', $donor_id );
261
-						$donor->donation_form_title = $this->payment_stats[ $donor_id ]['form_title'];
262
-						$donor->purchase_count      = $this->payment_stats[ $donor_id ]['donations'];
263
-						$donor->purchase_value      = $this->payment_stats[ $donor_id ]['donation_sum'];
264
-						$data[]                     = $this->set_donor_data( $i, $data, $donor );
256
+				if ( ! empty($this->donor_ids)) {
257
+					foreach ($this->donor_ids as $donor_id) {
258
+						$donor                      = Give()->donors->get_donor_by('id', $donor_id);
259
+						$donor->donation_form_title = $this->payment_stats[$donor_id]['form_title'];
260
+						$donor->purchase_count      = $this->payment_stats[$donor_id]['donations'];
261
+						$donor->purchase_value      = $this->payment_stats[$donor_id]['donation_sum'];
262
+						$data[]                     = $this->set_donor_data($i, $data, $donor);
265 263
 					}
266 264
 
267 265
 					// Cache donor ids only if admin export donor for specific form.
@@ -271,7 +269,7 @@  discard block
 block discarded – undo
271 269
 		} else {
272 270
 
273 271
 			// Export all donors.
274
-			$offset = 30 * ( $this->step - 1 );
272
+			$offset = 30 * ($this->step - 1);
275 273
 
276 274
 			$args = array(
277 275
 				'number' => 30,
@@ -279,31 +277,31 @@  discard block
 block discarded – undo
279 277
 			);
280 278
 
281 279
 			// Check for date option filter
282
-			if ( ! empty( $this->data['donor_export_start_date'] ) || ! empty( $this->data['donor_export_end_date'] ) ) {
280
+			if ( ! empty($this->data['donor_export_start_date']) || ! empty($this->data['donor_export_end_date'])) {
283 281
 				$args['date'] = array(
284
-					'start' => ! empty( $this->data['donor_export_start_date'] ) ? date( 'Y-n-d 00:00:00', strtotime( $this->data['donor_export_start_date'] ) ) : date( 'Y-n-d 23:59:59', '1970-1-01 00:00:00' ),
285
-					'end'   => ! empty( $this->data['donor_export_end_date'] ) ? date( 'Y-n-d 23:59:59', strtotime( $this->data['donor_export_end_date'] ) ) : date( 'Y-n-d 23:59:59', current_time( 'timestamp' ) ),
282
+					'start' => ! empty($this->data['donor_export_start_date']) ? date('Y-n-d 00:00:00', strtotime($this->data['donor_export_start_date'])) : date('Y-n-d 23:59:59', '1970-1-01 00:00:00'),
283
+					'end'   => ! empty($this->data['donor_export_end_date']) ? date('Y-n-d 23:59:59', strtotime($this->data['donor_export_end_date'])) : date('Y-n-d 23:59:59', current_time('timestamp')),
286 284
 				);
287 285
 			}
288 286
 
289
-			$donors = Give()->donors->get_donors( $args );
287
+			$donors = Give()->donors->get_donors($args);
290 288
 
291
-			foreach ( $donors as $donor ) {
289
+			foreach ($donors as $donor) {
292 290
 
293 291
 				// Continue if donor already included.
294
-				if ( empty( $donor->id ) || empty( $donor->payment_ids ) ) {
292
+				if (empty($donor->id) || empty($donor->payment_ids)) {
295 293
 					continue;
296 294
 				}
297 295
 
298
-				$payment                    = new Give_Payment( $donor->payment_ids );
296
+				$payment                    = new Give_Payment($donor->payment_ids);
299 297
 				$donor->donation_form_title = $payment->form_title;
300
-				$data[]                     = $this->set_donor_data( $i, $data, $donor );
301
-				$i ++;
298
+				$data[]                     = $this->set_donor_data($i, $data, $donor);
299
+				$i++;
302 300
 			}
303 301
 		}// End if().
304 302
 
305
-		$data = apply_filters( 'give_export_get_data', $data );
306
-		$data = apply_filters( "give_export_get_data_{$this->export_type}", $data );
303
+		$data = apply_filters('give_export_get_data', $data);
304
+		$data = apply_filters("give_export_get_data_{$this->export_type}", $data);
307 305
 
308 306
 		return $data;
309 307
 	}
@@ -319,18 +317,18 @@  discard block
 block discarded – undo
319 317
 		$percentage = 0;
320 318
 
321 319
 		// We can't count the number when getting them for a specific form.
322
-		if ( empty( $this->form ) ) {
320
+		if (empty($this->form)) {
323 321
 
324 322
 			$total = Give()->donors->count();
325 323
 
326
-			if ( $total > 0 ) {
324
+			if ($total > 0) {
327 325
 
328
-				$percentage = ( ( 30 * $this->step ) / $total ) * 100;
326
+				$percentage = ((30 * $this->step) / $total) * 100;
329 327
 
330 328
 			}
331 329
 		}
332 330
 
333
-		if ( $percentage > 100 ) {
331
+		if ($percentage > 100) {
334 332
 			$percentage = 100;
335 333
 		}
336 334
 
@@ -346,51 +344,51 @@  discard block
 block discarded – undo
346 344
 	 *
347 345
 	 * @return mixed
348 346
 	 */
349
-	private function set_donor_data( $i, $data, $donor ) {
347
+	private function set_donor_data($i, $data, $donor) {
350 348
 
351 349
 		$columns = $this->csv_cols();
352 350
 
353 351
 		// Set address variable
354 352
 		$address = '';
355
-		if ( isset( $donor->user_id ) && $donor->user_id > 0 ) {
356
-			$address = give_get_donor_address( $donor->user_id );
353
+		if (isset($donor->user_id) && $donor->user_id > 0) {
354
+			$address = give_get_donor_address($donor->user_id);
357 355
 		}
358 356
 
359 357
 		// Set columns
360
-		if ( ! empty( $columns['full_name'] ) ) {
361
-			$data[ $i ]['full_name'] = $donor->name;
358
+		if ( ! empty($columns['full_name'])) {
359
+			$data[$i]['full_name'] = $donor->name;
362 360
 		}
363
-		if ( ! empty( $columns['email'] ) ) {
364
-			$data[ $i ]['email'] = $donor->email;
361
+		if ( ! empty($columns['email'])) {
362
+			$data[$i]['email'] = $donor->email;
365 363
 		}
366
-		if ( ! empty( $columns['address_line1'] ) ) {
367
-
368
-			$data[ $i ]['address_line1']   = isset( $address['line1'] ) ? $address['line1'] : '';
369
-			$data[ $i ]['address_line2']   = isset( $address['line2'] ) ? $address['line2'] : '';
370
-			$data[ $i ]['address_city']    = isset( $address['city'] ) ? $address['city'] : '';
371
-			$data[ $i ]['address_state']   = isset( $address['state'] ) ? $address['state'] : '';
372
-			$data[ $i ]['address_zip']     = isset( $address['zip'] ) ? $address['zip'] : '';
373
-			$data[ $i ]['address_country'] = isset( $address['country'] ) ? $address['country'] : '';
364
+		if ( ! empty($columns['address_line1'])) {
365
+
366
+			$data[$i]['address_line1']   = isset($address['line1']) ? $address['line1'] : '';
367
+			$data[$i]['address_line2']   = isset($address['line2']) ? $address['line2'] : '';
368
+			$data[$i]['address_city']    = isset($address['city']) ? $address['city'] : '';
369
+			$data[$i]['address_state']   = isset($address['state']) ? $address['state'] : '';
370
+			$data[$i]['address_zip']     = isset($address['zip']) ? $address['zip'] : '';
371
+			$data[$i]['address_country'] = isset($address['country']) ? $address['country'] : '';
374 372
 		}
375
-		if ( ! empty( $columns['userid'] ) ) {
376
-			$data[ $i ]['userid'] = ! empty( $donor->user_id ) ? $donor->user_id : '';
373
+		if ( ! empty($columns['userid'])) {
374
+			$data[$i]['userid'] = ! empty($donor->user_id) ? $donor->user_id : '';
377 375
 		}
378
-		if ( ! empty( $columns['donation_form'] ) ) {
379
-			$data[ $i ]['donation_form'] = ! empty( $donor->donation_form_title ) ? $donor->donation_form_title : '';
376
+		if ( ! empty($columns['donation_form'])) {
377
+			$data[$i]['donation_form'] = ! empty($donor->donation_form_title) ? $donor->donation_form_title : '';
380 378
 		}
381
-		if ( ! empty( $columns['date_first_donated'] ) ) {
382
-			$data[ $i ]['date_first_donated'] = date_i18n( give_date_format(), strtotime( $donor->date_created ) );
379
+		if ( ! empty($columns['date_first_donated'])) {
380
+			$data[$i]['date_first_donated'] = date_i18n(give_date_format(), strtotime($donor->date_created));
383 381
 		}
384
-		if ( ! empty( $columns['donations'] ) ) {
385
-			$data[ $i ]['donations'] = $donor->purchase_count;
382
+		if ( ! empty($columns['donations'])) {
383
+			$data[$i]['donations'] = $donor->purchase_count;
386 384
 		}
387
-		if ( ! empty( $columns['donation_sum'] ) ) {
388
-			$data[ $i ]['donation_sum'] = give_format_amount( $donor->purchase_value, array( 'sanitize' => false ) );
385
+		if ( ! empty($columns['donation_sum'])) {
386
+			$data[$i]['donation_sum'] = give_format_amount($donor->purchase_value, array('sanitize' => false));
389 387
 		}
390 388
 
391
-		$data[ $i ] = apply_filters( 'give_export_set_donor_data', $data[ $i ], $donor );
389
+		$data[$i] = apply_filters('give_export_set_donor_data', $data[$i], $donor);
392 390
 
393
-		return $data[ $i ];
391
+		return $data[$i];
394 392
 
395 393
 	}
396 394
 
@@ -400,9 +398,9 @@  discard block
 block discarded – undo
400 398
 	 * @param array             $request
401 399
 	 * @param Give_Batch_Export $export
402 400
 	 */
403
-	public function unset_properties( $request, $export ) {
404
-		if ( $export->done ) {
405
-			Give_Cache::delete( "give_cache_{$this->query_id}" );
401
+	public function unset_properties($request, $export) {
402
+		if ($export->done) {
403
+			Give_Cache::delete("give_cache_{$this->query_id}");
406 404
 		}
407 405
 	}
408 406
 }
409 407
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/tools/export/class-batch-export.php 1 patch
Spacing   +38 added lines, -38 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
 
@@ -118,14 +118,14 @@  discard block
 block discarded – undo
118 118
 	 *
119 119
 	 * @param int $_step
120 120
 	 */
121
-	public function __construct( $_step = 1 ) {
121
+	public function __construct($_step = 1) {
122 122
 
123 123
 		$upload_dir     = wp_upload_dir();
124 124
 		$this->filetype = '.csv';
125
-		$this->filename = 'give-' . $this->export_type . $this->filetype;
126
-		$this->file     = trailingslashit( $upload_dir['basedir'] ) . $this->filename;
125
+		$this->filename = 'give-'.$this->export_type.$this->filetype;
126
+		$this->file     = trailingslashit($upload_dir['basedir']).$this->filename;
127 127
 
128
-		if ( ! is_writeable( $upload_dir['basedir'] ) ) {
128
+		if ( ! is_writeable($upload_dir['basedir'])) {
129 129
 			$this->is_writable = false;
130 130
 		}
131 131
 
@@ -141,22 +141,22 @@  discard block
 block discarded – undo
141 141
 	 */
142 142
 	public function process_step() {
143 143
 
144
-		if ( ! $this->can_export() ) {
145
-			wp_die( esc_html__( 'You do not have permission to export data.', 'give' ), esc_html__( 'Error', 'give' ), array(
144
+		if ( ! $this->can_export()) {
145
+			wp_die(esc_html__('You do not have permission to export data.', 'give'), esc_html__('Error', 'give'), array(
146 146
 				'response' => 403,
147
-			) );
147
+			));
148 148
 		}
149 149
 
150
-		if ( $this->step < 2 ) {
150
+		if ($this->step < 2) {
151 151
 
152 152
 			// Make sure we start with a fresh file on step 1.
153
-			@unlink( $this->file );
153
+			@unlink($this->file);
154 154
 			$this->print_csv_cols();
155 155
 		}
156 156
 
157 157
 		$rows = $this->print_csv_rows();
158 158
 
159
-		if ( $rows ) {
159
+		if ($rows) {
160 160
 			return true;
161 161
 		} else {
162 162
 			return false;
@@ -176,14 +176,14 @@  discard block
 block discarded – undo
176 176
 		$col_data = '';
177 177
 		$cols     = $this->get_csv_cols();
178 178
 		$i        = 1;
179
-		foreach ( $cols as $col_id => $column ) {
180
-			$col_data .= '"' . addslashes( $column ) . '"';
181
-			$col_data .= $i == count( $cols ) ? '' : ',';
182
-			$i ++;
179
+		foreach ($cols as $col_id => $column) {
180
+			$col_data .= '"'.addslashes($column).'"';
181
+			$col_data .= $i == count($cols) ? '' : ',';
182
+			$i++;
183 183
 		}
184 184
 		$col_data .= "\r\n";
185 185
 
186
-		$this->stash_step_data( $col_data );
186
+		$this->stash_step_data($col_data);
187 187
 
188 188
 		return $col_data;
189 189
 
@@ -202,23 +202,23 @@  discard block
 block discarded – undo
202 202
 		$data     = $this->get_data();
203 203
 		$cols     = $this->get_csv_cols();
204 204
 
205
-		if ( $data ) {
205
+		if ($data) {
206 206
 
207 207
 			// Output each row
208
-			foreach ( $data as $row ) {
208
+			foreach ($data as $row) {
209 209
 				$i = 1;
210
-				foreach ( $row as $col_id => $column ) {
210
+				foreach ($row as $col_id => $column) {
211 211
 					// Make sure the column is valid
212
-					if ( array_key_exists( $col_id, $cols ) ) {
213
-						$row_data .= '"' . addslashes( preg_replace( '/"/', "'", $column ) ) . '"';
214
-						$row_data .= $i == count( $cols ) ? '' : ',';
215
-						$i ++;
212
+					if (array_key_exists($col_id, $cols)) {
213
+						$row_data .= '"'.addslashes(preg_replace('/"/', "'", $column)).'"';
214
+						$row_data .= $i == count($cols) ? '' : ',';
215
+						$i++;
216 216
 					}
217 217
 				}
218 218
 				$row_data .= "\r\n";
219 219
 			}
220 220
 
221
-			$this->stash_step_data( $row_data );
221
+			$this->stash_step_data($row_data);
222 222
 
223 223
 			return $row_data;
224 224
 		}
@@ -246,18 +246,18 @@  discard block
 block discarded – undo
246 246
 
247 247
 		$file = '';
248 248
 
249
-		if ( @file_exists( $this->file ) ) {
249
+		if (@file_exists($this->file)) {
250 250
 
251
-			if ( ! is_writeable( $this->file ) ) {
251
+			if ( ! is_writeable($this->file)) {
252 252
 				$this->is_writable = false;
253 253
 			}
254 254
 
255
-			$file = @file_get_contents( $this->file );
255
+			$file = @file_get_contents($this->file);
256 256
 
257 257
 		} else {
258 258
 
259
-			@file_put_contents( $this->file, '' );
260
-			@chmod( $this->file, 0664 );
259
+			@file_put_contents($this->file, '');
260
+			@chmod($this->file, 0664);
261 261
 
262 262
 		}
263 263
 
@@ -273,18 +273,18 @@  discard block
 block discarded – undo
273 273
 	 *
274 274
 	 * @return void
275 275
 	 */
276
-	protected function stash_step_data( $data = '' ) {
276
+	protected function stash_step_data($data = '') {
277 277
 
278 278
 		$file = $this->get_file();
279 279
 		$file .= $data;
280
-		@file_put_contents( $this->file, $file );
280
+		@file_put_contents($this->file, $file);
281 281
 
282 282
 		// If we have no rows after this step, mark it as an empty export.
283
-		$file_rows    = file( $this->file, FILE_SKIP_EMPTY_LINES );
283
+		$file_rows    = file($this->file, FILE_SKIP_EMPTY_LINES);
284 284
 		$default_cols = $this->get_csv_cols();
285
-		$default_cols = empty( $default_cols ) ? 0 : 1;
285
+		$default_cols = empty($default_cols) ? 0 : 1;
286 286
 
287
-		$this->is_empty = count( $file_rows ) == $default_cols ? true : false;
287
+		$this->is_empty = count($file_rows) == $default_cols ? true : false;
288 288
 
289 289
 	}
290 290
 
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 
303 303
 		$file = $this->get_file();
304 304
 
305
-		@unlink( $this->file );
305
+		@unlink($this->file);
306 306
 
307 307
 		echo $file;
308 308
 
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 		 *
312 312
 		 * @since 1.8
313 313
 		 */
314
-		do_action( 'give_file_export_complete', $_REQUEST );
314
+		do_action('give_file_export_complete', $_REQUEST);
315 315
 
316 316
 		give_die();
317 317
 	}
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 	 *
324 324
 	 * @param array $request The Form Data passed into the batch processing.
325 325
 	 */
326
-	public function set_properties( $request ) {
326
+	public function set_properties($request) {
327 327
 	}
328 328
 
329 329
 	/**
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
 	 * @param array             $request The Form Data passed into the batch processing.
335 335
 	 * @param Give_Batch_Export $export
336 336
 	 */
337
-	public function unset_properties( $request, $export ) {
337
+	public function unset_properties($request, $export) {
338 338
 	}
339 339
 
340 340
 	/**
Please login to merge, or discard this patch.
includes/admin/tools/views/html-admin-page-exports.php 1 patch
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Admin View: Exports
4 4
  */
5 5
 
6
-if ( ! defined( 'ABSPATH' ) ) {
6
+if ( ! defined('ABSPATH')) {
7 7
 	exit;
8 8
 } ?>
9 9
 
@@ -18,14 +18,14 @@  discard block
 block discarded – undo
18 18
 				 *
19 19
 				 * @since 1.0
20 20
 				 */
21
-				do_action( 'give_tools_tab_export_content_top' );
21
+				do_action('give_tools_tab_export_content_top');
22 22
 				?>
23 23
 
24 24
 				<table class="widefat export-options-table give-table">
25 25
 					<thead>
26 26
 					<tr>
27
-						<th scope="col"><?php esc_html_e( 'Export Type', 'give' ); ?></th>
28
-						<th scope="col"><?php esc_html_e( 'Export Options', 'give' ); ?></th>
27
+						<th scope="col"><?php esc_html_e('Export Type', 'give'); ?></th>
28
+						<th scope="col"><?php esc_html_e('Export Options', 'give'); ?></th>
29 29
 					</tr>
30 30
 					</thead>
31 31
 					<tbody>
@@ -38,42 +38,42 @@  discard block
 block discarded – undo
38 38
 					 *
39 39
 					 * @since 1.0
40 40
 					 */
41
-					do_action( 'give_tools_tab_export_table_top' );
41
+					do_action('give_tools_tab_export_table_top');
42 42
 					?>
43 43
 					<tr class="give-export-pdf-sales-earnings">
44 44
 						<td scope="row" class="row-title">
45 45
 							<h3>
46
-								<span><?php esc_html_e( 'Export PDF of Donations and Income', 'give' ); ?></span>
46
+								<span><?php esc_html_e('Export PDF of Donations and Income', 'give'); ?></span>
47 47
 							</h3>
48
-							<p><?php esc_html_e( 'Download a PDF of Donations and Income reports for all forms for the current year.', 'give' ); ?></p>
48
+							<p><?php esc_html_e('Download a PDF of Donations and Income reports for all forms for the current year.', 'give'); ?></p>
49 49
 						</td>
50 50
 						<td>
51
-							<a class="button" href="<?php echo wp_nonce_url( add_query_arg( array( 'give-action' => 'generate_pdf' ) ), 'give_generate_pdf' ); ?>">
52
-								<?php esc_html_e( 'Generate PDF', 'give' ); ?>
51
+							<a class="button" href="<?php echo wp_nonce_url(add_query_arg(array('give-action' => 'generate_pdf')), 'give_generate_pdf'); ?>">
52
+								<?php esc_html_e('Generate PDF', 'give'); ?>
53 53
 							</a>
54 54
 						</td>
55 55
 					</tr>
56 56
 					<tr class="alternate give-export-sales-earnings">
57 57
 						<td scope="row" class="row-title">
58 58
 							<h3>
59
-								<span><?php esc_html_e( 'Export Income and Donation Stats', 'give' ); ?></span>
59
+								<span><?php esc_html_e('Export Income and Donation Stats', 'give'); ?></span>
60 60
 							</h3>
61
-							<p><?php esc_html_e( 'Download a CSV of income and donations over time.', 'give' ); ?></p>
61
+							<p><?php esc_html_e('Download a CSV of income and donations over time.', 'give'); ?></p>
62 62
 						</td>
63 63
 						<td>
64 64
 							<form method="post">
65 65
 								<?php
66 66
 								printf(
67 67
 								/* translators: 1: start date dropdown 2: end date dropdown */
68
-									esc_html__( '%1$s to %2$s', 'give' ),
69
-									Give()->html->year_dropdown( 'start_year' ) . ' ' . Give()->html->month_dropdown( 'start_month' ),
70
-									Give()->html->year_dropdown( 'end_year' ) . ' ' . Give()->html->month_dropdown( 'end_month' )
68
+									esc_html__('%1$s to %2$s', 'give'),
69
+									Give()->html->year_dropdown('start_year').' '.Give()->html->month_dropdown('start_month'),
70
+									Give()->html->year_dropdown('end_year').' '.Give()->html->month_dropdown('end_month')
71 71
 								);
72 72
 								?>
73 73
 								<input type="hidden" name="give-action"
74 74
 								       value="earnings_export"/>
75 75
 								<input type="submit"
76
-								       value="<?php esc_attr_e( 'Generate CSV', 'give' ); ?>"
76
+								       value="<?php esc_attr_e('Generate CSV', 'give'); ?>"
77 77
 								       class="button-secondary"/>
78 78
 							</form>
79 79
 						</td>
@@ -81,37 +81,37 @@  discard block
 block discarded – undo
81 81
 					<tr class="give-export-payment-history">
82 82
 						<td scope="row" class="row-title">
83 83
 							<h3>
84
-								<span><?php esc_html_e( 'Export Donation History', 'give' ); ?></span>
84
+								<span><?php esc_html_e('Export Donation History', 'give'); ?></span>
85 85
 							</h3>
86
-							<p><?php esc_html_e( 'Download a CSV of all donations recorded.', 'give' ); ?></p>
86
+							<p><?php esc_html_e('Download a CSV of all donations recorded.', 'give'); ?></p>
87 87
 						</td>
88 88
 						<td>
89 89
 							<form id="give-export-payments"
90 90
 							      class="give-export-form" method="post">
91 91
 								<?php
92
-								echo Give()->html->date_field( array(
92
+								echo Give()->html->date_field(array(
93 93
 									'id'          => 'give-payment-export-start',
94 94
 									'name'        => 'start',
95
-									'placeholder' => esc_attr__( 'Start date', 'give' ),
96
-								) );
95
+									'placeholder' => esc_attr__('Start date', 'give'),
96
+								));
97 97
 
98
-								echo Give()->html->date_field( array(
98
+								echo Give()->html->date_field(array(
99 99
 									'id'          => 'give-payment-export-end',
100 100
 									'name'        => 'end',
101
-									'placeholder' => esc_attr__( 'End date', 'give' ),
102
-								) );
101
+									'placeholder' => esc_attr__('End date', 'give'),
102
+								));
103 103
 								?>
104 104
 								<select name="status">
105
-									<option value="any"><?php esc_html_e( 'All Statuses', 'give' ); ?></option>
105
+									<option value="any"><?php esc_html_e('All Statuses', 'give'); ?></option>
106 106
 									<?php
107 107
 									$statuses = give_get_payment_statuses();
108
-									foreach ( $statuses as $status => $label ) {
109
-										echo '<option value="' . $status . '">' . $label . '</option>';
108
+									foreach ($statuses as $status => $label) {
109
+										echo '<option value="'.$status.'">'.$label.'</option>';
110 110
 									}
111 111
 									?>
112 112
 								</select>
113 113
 								<?php
114
-								if ( give_is_setting_enabled( give_get_option( 'categories' ) ) ) {
114
+								if (give_is_setting_enabled(give_get_option('categories'))) {
115 115
 									echo Give()->html->category_dropdown(
116 116
 										'give_forms_categories[]',
117 117
 										0,
@@ -121,12 +121,12 @@  discard block
 block discarded – undo
121 121
 											'multiple'        => true,
122 122
 											'selected'        => array(),
123 123
 											'show_option_all' => false,
124
-											'placeholder'     => __( 'Choose one or more from categories', 'give' ),
124
+											'placeholder'     => __('Choose one or more from categories', 'give'),
125 125
 										)
126 126
 									);
127 127
 								}
128 128
 
129
-								if ( give_is_setting_enabled( give_get_option( 'tags' ) ) ) {
129
+								if (give_is_setting_enabled(give_get_option('tags'))) {
130 130
 									echo Give()->html->tags_dropdown(
131 131
 										'give_forms_tags[]',
132 132
 										0,
@@ -136,18 +136,18 @@  discard block
 block discarded – undo
136 136
 											'multiple'        => true,
137 137
 											'selected'        => array(),
138 138
 											'show_option_all' => false,
139
-											'placeholder'     => __( 'Choose one or more from tags', 'give' ),
139
+											'placeholder'     => __('Choose one or more from tags', 'give'),
140 140
 										)
141 141
 									);
142 142
 								}
143 143
 
144
-								wp_nonce_field( 'give_ajax_export', 'give_ajax_export' );
144
+								wp_nonce_field('give_ajax_export', 'give_ajax_export');
145 145
 								?>
146 146
 								<input type="hidden" name="give-export-class"
147 147
 								       value="Give_Batch_Payments_Export"/>
148 148
 								<span>
149 149
 									<input type="submit"
150
-									       value="<?php esc_attr_e( 'Generate CSV', 'give' ); ?>"
150
+									       value="<?php esc_attr_e('Generate CSV', 'give'); ?>"
151 151
 									       class="button-secondary"/>
152 152
 									<span class="spinner"></span>
153 153
 								</span>
@@ -157,9 +157,9 @@  discard block
 block discarded – undo
157 157
 					<tr class="alternate give-export-donors">
158 158
 						<td scope="row" class="row-title">
159 159
 							<h3>
160
-								<span><?php esc_html_e( 'Export Donors in CSV', 'give' ); ?></span>
160
+								<span><?php esc_html_e('Export Donors in CSV', 'give'); ?></span>
161 161
 							</h3>
162
-							<p><?php esc_html_e( 'Download an export of donors for all donation forms or only those who have given to a particular form.', 'give' ); ?></p>
162
+							<p><?php esc_html_e('Download an export of donors for all donation forms or only those who have given to a particular form.', 'give'); ?></p>
163 163
 						</td>
164 164
 						<td>
165 165
 							<form method="post" id="give_donor_export"
@@ -167,99 +167,99 @@  discard block
 block discarded – undo
167 167
 
168 168
 								<?php
169 169
 								// Start Date form field for donors
170
-								echo Give()->html->date_field( array(
170
+								echo Give()->html->date_field(array(
171 171
 									'id'          => 'give_donor_export_start_date',
172 172
 									'name'        => 'donor_export_start_date',
173
-									'placeholder' => esc_attr__( 'Start date', 'give' ),
174
-								) );
173
+									'placeholder' => esc_attr__('Start date', 'give'),
174
+								));
175 175
 
176 176
 								// End Date form field for donors
177
-								echo Give()->html->date_field( array(
177
+								echo Give()->html->date_field(array(
178 178
 									'id'          => 'give_donor_export_end_date',
179 179
 									'name'        => 'donor_export_end_date',
180
-									'placeholder' => esc_attr__( 'End date', 'give' ),
181
-								) );
180
+									'placeholder' => esc_attr__('End date', 'give'),
181
+								));
182 182
 
183 183
 								// Donation forms dropdown for donors export
184
-								echo Give()->html->forms_dropdown( array(
184
+								echo Give()->html->forms_dropdown(array(
185 185
 									'name'   => 'forms',
186 186
 									'id'     => 'give_donor_export_form',
187 187
 									'chosen' => true,
188
-								) );
188
+								));
189 189
 								?>
190 190
 
191 191
 								<input type="submit"
192
-								       value="<?php esc_attr_e( 'Generate CSV', 'give' ); ?>"
192
+								       value="<?php esc_attr_e('Generate CSV', 'give'); ?>"
193 193
 								       class="button-secondary"/>
194 194
 
195 195
 								<div id="export-donor-options-wrap"
196 196
 								     class="give-clearfix">
197
-									<p><?php esc_html_e( 'Export Columns:', 'give' ); ?></p>
197
+									<p><?php esc_html_e('Export Columns:', 'give'); ?></p>
198 198
 									<ul id="give-export-option-ul">
199 199
 										<li>
200 200
 											<label for="give-export-fullname">
201 201
 												<input type="checkbox" checked
202 202
 												       name="give_export_option[full_name]"
203
-												       id="give-export-fullname"><?php esc_html_e( 'Name', 'give' ); ?>
203
+												       id="give-export-fullname"><?php esc_html_e('Name', 'give'); ?>
204 204
 											</label>
205 205
 										</li>
206 206
 										<li>
207 207
 											<label for="give-export-email">
208 208
 												<input type="checkbox" checked
209 209
 												       name="give_export_option[email]"
210
-												       id="give-export-email"><?php esc_html_e( 'Email', 'give' ); ?>
210
+												       id="give-export-email"><?php esc_html_e('Email', 'give'); ?>
211 211
 											</label>
212 212
 										</li>
213 213
 										<li>
214 214
 											<label for="give-export-address">
215 215
 												<input type="checkbox" checked
216 216
 												       name="give_export_option[address]"
217
-												       id="give-export-address"><?php esc_html_e( 'Address', 'give' ); ?>
217
+												       id="give-export-address"><?php esc_html_e('Address', 'give'); ?>
218 218
 											</label>
219 219
 										</li>
220 220
 										<li>
221 221
 											<label for="give-export-userid">
222 222
 												<input type="checkbox" checked
223 223
 												       name="give_export_option[userid]"
224
-												       id="give-export-userid"><?php esc_html_e( 'User ID', 'give' ); ?>
224
+												       id="give-export-userid"><?php esc_html_e('User ID', 'give'); ?>
225 225
 											</label>
226 226
 										</li>
227 227
 										<li>
228 228
 											<label for="give-export-donation-form">
229 229
 												<input type="checkbox" checked
230 230
 												       name="give_export_option[donation_form]"
231
-												       id="give-export-donation-form"><?php esc_html_e( 'Donation Form', 'give' ); ?>
231
+												       id="give-export-donation-form"><?php esc_html_e('Donation Form', 'give'); ?>
232 232
 											</label>
233 233
 										</li>
234 234
 										<li>
235 235
 											<label for="give-export-first-donation-date">
236 236
 												<input type="checkbox" checked
237 237
 												       name="give_export_option[date_first_donated]"
238
-												       id="give-export-first-donation-date"><?php esc_html_e( 'First Donation Date', 'give' ); ?>
238
+												       id="give-export-first-donation-date"><?php esc_html_e('First Donation Date', 'give'); ?>
239 239
 											</label>
240 240
 										</li>
241 241
 										<li>
242 242
 											<label for="give-export-donation-number">
243 243
 												<input type="checkbox" checked
244 244
 												       name="give_export_option[donations]"
245
-												       id="give-export-donation-number"><?php esc_html_e( 'Number of Donations', 'give' ); ?>
245
+												       id="give-export-donation-number"><?php esc_html_e('Number of Donations', 'give'); ?>
246 246
 											</label>
247 247
 										</li>
248 248
 										<li>
249 249
 											<label for="give-export-donation-sum">
250 250
 												<input type="checkbox" checked
251 251
 												       name="give_export_option[donation_sum]"
252
-												       id="give-export-donation-sum"><?php esc_html_e( 'Total Donated', 'give' ); ?>
252
+												       id="give-export-donation-sum"><?php esc_html_e('Total Donated', 'give'); ?>
253 253
 											</label>
254 254
 										</li>
255 255
 									</ul>
256 256
 								</div>
257
-								<?php wp_nonce_field( 'give_ajax_export', 'give_ajax_export' ); ?>
257
+								<?php wp_nonce_field('give_ajax_export', 'give_ajax_export'); ?>
258 258
 								<input type="hidden" name="give-export-class"
259 259
 								       value="Give_Batch_Donors_Export"/>
260 260
 								<input type="hidden"
261 261
 								       name="give_export_option[query_id]"
262
-								       value="<?php echo uniqid( 'give_' ); ?>"/>
262
+								       value="<?php echo uniqid('give_'); ?>"/>
263 263
 							</form>
264 264
 						</td>
265 265
 					</tr>
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 					 *
273 273
 					 * @since 1.0
274 274
 					 */
275
-					do_action( 'give_tools_tab_export_table_bottom' );
275
+					do_action('give_tools_tab_export_table_bottom');
276 276
 					?>
277 277
 					</tbody>
278 278
 				</table>
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 				 *
284 284
 				 * @since 1.0
285 285
 				 */
286
-				do_action( 'give_tools_tab_export_content_bottom' );
286
+				do_action('give_tools_tab_export_content_bottom');
287 287
 				?>
288 288
 
289 289
 			</div>
Please login to merge, or discard this patch.