Test Failed
Pull Request — master (#2482)
by Devin
05:37
created
includes/class-give-license-handler.php 1 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' ), 10 );
208
+			add_action('admin_init', array($this, 'activate_license'), 10);
209 209
 
210 210
 			// Deactivate license key.
211
-			add_action( 'admin_init', array( $this, 'deactivate_license' ), 11 );
211
+			add_action('admin_init', array($this, 'deactivate_license'), 11);
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,62 +326,62 @@  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
 			// Delete previous license setting if a empty license key submitted.
341
-			if ( empty( $_POST["{$this->item_shortname}_license_key"] ) ) {
341
+			if (empty($_POST["{$this->item_shortname}_license_key"])) {
342 342
 				$this->unset_license();
343 343
 
344 344
 				return;
345 345
 			}
346 346
 
347 347
 			// Do not simultaneously activate add-ons if the user want to deactivate a specific add-on.
348
-			if( $this->is_deactivating_license() ) {
348
+			if ($this->is_deactivating_license()) {
349 349
 				return;
350 350
 			}
351 351
 
352 352
 			// Check if plugin previously installed.
353
-			if ( $this->is_valid_license() ) {
353
+			if ($this->is_valid_license()) {
354 354
 				return;
355 355
 			}
356 356
 
357 357
 			// Get license key.
358
-			$this->license = sanitize_text_field( $_POST[ $this->item_shortname . '_license_key' ] );
358
+			$this->license = sanitize_text_field($_POST[$this->item_shortname.'_license_key']);
359 359
 
360 360
 			// Delete previous license key from subscription if previously added.
361 361
 			$this->__remove_license_key_from_subscriptions();
362 362
 
363 363
 			// Make sure there are no api errors.
364
-			if ( ! ( $license_data = $this->get_license_info( 'activate_license' ) ) ) {
364
+			if ( ! ($license_data = $this->get_license_info('activate_license'))) {
365 365
 				return;
366 366
 			}
367 367
 
368 368
 			// Make sure license is valid.
369 369
 			// return because admin will want to activate license again.
370
-			if ( ! $this->is_license( $license_data ) ) {
370
+			if ( ! $this->is_license($license_data)) {
371 371
 				// Add license key.
372
-				give_update_option( "{$this->item_shortname}_license_key", $this->license );
372
+				give_update_option("{$this->item_shortname}_license_key", $this->license);
373 373
 
374 374
 				return;
375 375
 			}
376 376
 
377 377
 			// Tell WordPress to look for updates.
378
-			set_site_transient( 'update_plugins', null );
378
+			set_site_transient('update_plugins', null);
379 379
 
380 380
 			// Add license data.
381
-			update_option( "{$this->item_shortname}_license_active", $license_data );
381
+			update_option("{$this->item_shortname}_license_active", $license_data);
382 382
 
383 383
 			// Add license key.
384
-			give_update_option( "{$this->item_shortname}_license_key", $this->license );
384
+			give_update_option("{$this->item_shortname}_license_key", $this->license);
385 385
 
386 386
 			// Check subscription for license key and store this to db (if any).
387 387
 			$this->__single_subscription_check();
@@ -399,19 +399,19 @@  discard block
 block discarded – undo
399 399
 		 */
400 400
 		public function deactivate_license() {
401 401
 			// Bailout.
402
-			if ( ! $this->__is_user_can_edit_license() ) {
402
+			if ( ! $this->__is_user_can_edit_license()) {
403 403
 				return;
404 404
 			}
405 405
 
406 406
 			// Allow third party add-on developers to handle license deactivation.
407
-			if ( $this->__is_third_party_addon() ) {
408
-				do_action( 'give_deactivate_license', $this );
407
+			if ($this->__is_third_party_addon()) {
408
+				do_action('give_deactivate_license', $this);
409 409
 
410 410
 				return;
411 411
 			}
412 412
 
413 413
 			// Run on deactivate button press.
414
-			if ( isset( $_POST[ $this->item_shortname . '_license_key_deactivate' ] ) ) {
414
+			if (isset($_POST[$this->item_shortname.'_license_key_deactivate'])) {
415 415
 				$this->unset_license();
416 416
 			}
417 417
 		}
@@ -427,30 +427,30 @@  discard block
 block discarded – undo
427 427
 		public function weekly_license_check() {
428 428
 
429 429
 			if (
430
-				! empty( $_POST['give_settings'] ) ||
431
-				empty( $this->license )
430
+				! empty($_POST['give_settings']) ||
431
+				empty($this->license)
432 432
 			) {
433 433
 				return;
434 434
 			}
435 435
 
436 436
 			// Allow third party add-on developers to handle their license check.
437
-			if ( $this->__is_third_party_addon() ) {
438
-				do_action( 'give_weekly_license_check', $this );
437
+			if ($this->__is_third_party_addon()) {
438
+				do_action('give_weekly_license_check', $this);
439 439
 
440 440
 				return;
441 441
 			}
442 442
 
443 443
 			// Make sure there are no api errors.
444
-			if ( ! ( $license_data = $this->get_license_info( 'check_license' ) ) ) {
444
+			if ( ! ($license_data = $this->get_license_info('check_license'))) {
445 445
 				return;
446 446
 			}
447 447
 
448 448
 			// Bailout.
449
-			if ( ! $this->is_license( $license_data ) ) {
449
+			if ( ! $this->is_license($license_data)) {
450 450
 				return;
451 451
 			}
452 452
 
453
-			update_option( $this->item_shortname . '_license_active', $license_data );
453
+			update_option($this->item_shortname.'_license_active', $license_data);
454 454
 
455 455
 			return;
456 456
 		}
@@ -466,21 +466,21 @@  discard block
 block discarded – undo
466 466
 		public function weekly_subscription_check() {
467 467
 			// Bailout.
468 468
 			if (
469
-				! empty( $_POST['give_settings'] ) ||
470
-				empty( $this->license )
469
+				! empty($_POST['give_settings']) ||
470
+				empty($this->license)
471 471
 			) {
472 472
 				return;
473 473
 			}
474 474
 
475 475
 			// Remove old subscription data.
476
-			if ( absint( get_option( '_give_subscriptions_edit_last', true ) ) < current_time( 'timestamp', 1 ) ) {
477
-				delete_option( 'give_subscriptions' );
478
-				update_option( '_give_subscriptions_edit_last', strtotime( '+ 1 day', current_time( 'timestamp', 1 ) ) );
476
+			if (absint(get_option('_give_subscriptions_edit_last', true)) < current_time('timestamp', 1)) {
477
+				delete_option('give_subscriptions');
478
+				update_option('_give_subscriptions_edit_last', strtotime('+ 1 day', current_time('timestamp', 1)));
479 479
 			}
480 480
 
481 481
 			// Allow third party add-on developers to handle their subscription check.
482
-			if ( $this->__is_third_party_addon() ) {
483
-				do_action( 'give_weekly_subscription_check', $this );
482
+			if ($this->__is_third_party_addon()) {
483
+				do_action('give_weekly_subscription_check', $this);
484 484
 
485 485
 				return;
486 486
 			}
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
 		 * @return void
498 498
 		 */
499 499
 		private function __single_subscription_check() {
500
-			if ( empty( $this->license ) ) {
500
+			if (empty($this->license)) {
501 501
 				return;
502 502
 			}
503 503
 
@@ -508,26 +508,26 @@  discard block
 block discarded – undo
508 508
 			 * By default edd software licensing api does not have api to check subscription.
509 509
 			 * This is a custom feature to check subscriptions.
510 510
 			 */
511
-			$subscription_data = $this->get_license_info( 'check_subscription', true );
511
+			$subscription_data = $this->get_license_info('check_subscription', true);
512 512
 
513
-			if ( ! empty( $subscription_data['success'] ) && absint( $subscription_data['success'] ) ) {
513
+			if ( ! empty($subscription_data['success']) && absint($subscription_data['success'])) {
514 514
 
515
-				$subscriptions = get_option( 'give_subscriptions', array() );
515
+				$subscriptions = get_option('give_subscriptions', array());
516 516
 
517 517
 				// Update subscription data only if subscription does not exist already.
518
-				$subscriptions[ $subscription_data['id'] ] = $subscription_data;
518
+				$subscriptions[$subscription_data['id']] = $subscription_data;
519 519
 
520 520
 				// Initiate default set of license for subscription.
521
-				if ( ! isset( $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) {
522
-					$subscriptions[ $subscription_data['id'] ]['licenses'] = array();
521
+				if ( ! isset($subscriptions[$subscription_data['id']]['licenses'])) {
522
+					$subscriptions[$subscription_data['id']]['licenses'] = array();
523 523
 				}
524 524
 
525 525
 				// Store licenses for subscription.
526
-				if ( ! in_array( $this->license, $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) {
527
-					$subscriptions[ $subscription_data['id'] ]['licenses'][] = $this->license;
526
+				if ( ! in_array($this->license, $subscriptions[$subscription_data['id']]['licenses'])) {
527
+					$subscriptions[$subscription_data['id']]['licenses'][] = $this->license;
528 528
 				}
529 529
 
530
-				update_option( 'give_subscriptions', $subscriptions );
530
+				update_option('give_subscriptions', $subscriptions);
531 531
 			}
532 532
 		}
533 533
 
@@ -541,12 +541,12 @@  discard block
 block discarded – undo
541 541
 		 */
542 542
 		public function notices() {
543 543
 
544
-			if ( ! current_user_can( 'manage_give_settings' ) ) {
544
+			if ( ! current_user_can('manage_give_settings')) {
545 545
 				return;
546 546
 			}
547 547
 
548 548
 			// Do not show licenses notices on license tab.
549
-			if ( 'licenses' === give_get_current_setting_tab() ) {
549
+			if ('licenses' === give_get_current_setting_tab()) {
550 550
 				return;
551 551
 			}
552 552
 
@@ -555,118 +555,118 @@  discard block
 block discarded – undo
555 555
 			static $addon_license_key_in_subscriptions;
556 556
 
557 557
 			// Set default value.
558
-			$addon_license_key_in_subscriptions = ! empty( $addon_license_key_in_subscriptions ) ? $addon_license_key_in_subscriptions : array();
558
+			$addon_license_key_in_subscriptions = ! empty($addon_license_key_in_subscriptions) ? $addon_license_key_in_subscriptions : array();
559 559
 			$messages                           = array();
560 560
 
561 561
 			// Check whether admin has Give Add-on activated since 24 hours?
562
-			$is_license_notice_hidden = Give_Cache::get( 'give_cache_hide_license_notice_after_activation' );
562
+			$is_license_notice_hidden = Give_Cache::get('give_cache_hide_license_notice_after_activation');
563 563
 
564 564
 			// Display Invalid License notice, if its more than 24 hours since first Give Add-on activation.
565 565
 			if (
566
-				empty( $this->license )
567
-				&& empty( $showed_invalid_message )
568
-				&& ( false === $is_license_notice_hidden )
566
+				empty($this->license)
567
+				&& empty($showed_invalid_message)
568
+				&& (false === $is_license_notice_hidden)
569 569
 			) {
570 570
 
571
-				Give()->notices->register_notice( array(
571
+				Give()->notices->register_notice(array(
572 572
 					'id'               => 'give-invalid-license',
573 573
 					'type'             => 'error',
574 574
 					'description'      => sprintf(
575
-						__( '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' ),
576
-						admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' )
575
+						__('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'),
576
+						admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses')
577 577
 					),
578 578
 					'dismissible_type' => 'user',
579 579
 					'dismiss_interval' => 'shortly',
580
-				) );
580
+				));
581 581
 
582 582
 				$showed_invalid_message = true;
583 583
 
584 584
 			}
585 585
 
586 586
 			// Get subscriptions.
587
-			$subscriptions = get_option( 'give_subscriptions' );
587
+			$subscriptions = get_option('give_subscriptions');
588 588
 
589 589
 			// Show subscription messages.
590
-			if ( ! empty( $subscriptions ) && ! $showed_subscriptions_message ) {
590
+			if ( ! empty($subscriptions) && ! $showed_subscriptions_message) {
591 591
 
592
-				foreach ( $subscriptions as $subscription ) {
592
+				foreach ($subscriptions as $subscription) {
593 593
 					// Subscription expires timestamp.
594
-					$subscription_expires = strtotime( $subscription['expires'] );
594
+					$subscription_expires = strtotime($subscription['expires']);
595 595
 
596 596
 					// Start showing subscriptions message before one week of renewal date.
597
-					if ( strtotime( '- 7 days', $subscription_expires ) > current_time( 'timestamp', 1 ) ) {
597
+					if (strtotime('- 7 days', $subscription_expires) > current_time('timestamp', 1)) {
598 598
 						continue;
599 599
 					}
600 600
 
601 601
 					// Check if subscription message already exist in messages.
602
-					if ( array_key_exists( $subscription['id'], $messages ) ) {
602
+					if (array_key_exists($subscription['id'], $messages)) {
603 603
 						continue;
604 604
 					}
605 605
 
606 606
 					// Check if license already expired.
607
-					if ( strtotime( $subscription['expires'] ) < current_time( 'timestamp', 1 ) ) {
608
-						Give()->notices->register_notice( array(
607
+					if (strtotime($subscription['expires']) < current_time('timestamp', 1)) {
608
+						Give()->notices->register_notice(array(
609 609
 							'id'               => "give-expired-subscription-{$subscription['id']}",
610 610
 							'type'             => 'error',
611 611
 							'description'      => sprintf(
612
-								__( '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' ),
613
-								urldecode( $subscription['invoice_url'] ),
612
+								__('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'),
613
+								urldecode($subscription['invoice_url']),
614 614
 								$subscription['payment_id'],
615 615
 								"{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired",
616
-								Give()->notices->get_dismiss_link( array(
617
-									'title'            => __( 'Click here if already renewed', 'give' ),
616
+								Give()->notices->get_dismiss_link(array(
617
+									'title'            => __('Click here if already renewed', 'give'),
618 618
 									'dismissible_type' => 'user',
619 619
 									'dismiss_interval' => 'permanent',
620
-								) )
620
+								))
621 621
 							),
622 622
 							'dismissible_type' => 'user',
623 623
 							'dismiss_interval' => 'shortly',
624
-						) );
624
+						));
625 625
 					} else {
626
-						Give()->notices->register_notice( array(
626
+						Give()->notices->register_notice(array(
627 627
 							'id'               => "give-expires-subscription-{$subscription['id']}",
628 628
 							'type'             => 'error',
629 629
 							'description'      => sprintf(
630
-								__( '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' ),
631
-								human_time_diff( current_time( 'timestamp', 1 ), strtotime( $subscription['expires'] ) ),
632
-								urldecode( $subscription['invoice_url'] ),
630
+								__('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'),
631
+								human_time_diff(current_time('timestamp', 1), strtotime($subscription['expires'])),
632
+								urldecode($subscription['invoice_url']),
633 633
 								$subscription['payment_id'],
634 634
 								"{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired",
635
-								Give()->notices->get_dismiss_link( array(
636
-									'title'            => __( 'Click here if already renewed', 'give' ),
635
+								Give()->notices->get_dismiss_link(array(
636
+									'title'            => __('Click here if already renewed', 'give'),
637 637
 									'dismissible_type' => 'user',
638 638
 									'dismiss_interval' => 'permanent',
639
-								) )
639
+								))
640 640
 							),
641 641
 							'dismissible_type' => 'user',
642 642
 							'dismiss_interval' => 'shortly',
643
-						) );
643
+						));
644 644
 					}
645 645
 
646 646
 					// Stop validation for these license keys.
647
-					$addon_license_key_in_subscriptions = array_merge( $addon_license_key_in_subscriptions, $subscription['licenses'] );
647
+					$addon_license_key_in_subscriptions = array_merge($addon_license_key_in_subscriptions, $subscription['licenses']);
648 648
 				}// End foreach().
649 649
 				$showed_subscriptions_message = true;
650 650
 			}// End if().
651 651
 
652 652
 			// Show Non Subscription Give Add-on messages.
653 653
 			if (
654
-				! in_array( $this->license, $addon_license_key_in_subscriptions )
655
-				&& ! empty( $this->license )
656
-				&& empty( $showed_invalid_message )
654
+				! in_array($this->license, $addon_license_key_in_subscriptions)
655
+				&& ! empty($this->license)
656
+				&& empty($showed_invalid_message)
657 657
 				&& ! $this->is_valid_license()
658 658
 			) {
659 659
 
660
-				Give()->notices->register_notice( array(
660
+				Give()->notices->register_notice(array(
661 661
 					'id'               => 'give-invalid-license',
662 662
 					'type'             => 'error',
663 663
 					'description'      => sprintf(
664
-						__( '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' ),
665
-						admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' )
664
+						__('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'),
665
+						admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses')
666 666
 					),
667 667
 					'dismissible_type' => 'user',
668 668
 					'dismiss_interval' => 'shortly',
669
-				) );
669
+				));
670 670
 
671 671
 				$showed_invalid_message = true;
672 672
 
@@ -683,10 +683,10 @@  discard block
 block discarded – undo
683 683
 		 *
684 684
 		 * @return bool
685 685
 		 */
686
-		public function is_valid_license( $licence_data = null ) {
687
-			$license_data = empty( $licence_data ) ? $this->license_data : $licence_data;
686
+		public function is_valid_license($licence_data = null) {
687
+			$license_data = empty($licence_data) ? $this->license_data : $licence_data;
688 688
 
689
-			if ( apply_filters( 'give_is_valid_license', ( $this->is_license( $license_data ) && 'valid' === $license_data->license ) ) ) {
689
+			if (apply_filters('give_is_valid_license', ($this->is_license($license_data) && 'valid' === $license_data->license))) {
690 690
 				return true;
691 691
 			}
692 692
 
@@ -704,10 +704,10 @@  discard block
 block discarded – undo
704 704
 		 *
705 705
 		 * @return bool
706 706
 		 */
707
-		public function is_license( $licence_data = null ) {
708
-			$license_data = empty( $licence_data ) ? $this->license_data : $licence_data;
707
+		public function is_license($licence_data = null) {
708
+			$license_data = empty($licence_data) ? $this->license_data : $licence_data;
709 709
 
710
-			if ( apply_filters( 'give_is_license', ( is_object( $license_data ) && ! empty( $license_data ) && property_exists( $license_data, 'license' ) ) ) ) {
710
+			if (apply_filters('give_is_license', (is_object($license_data) && ! empty($license_data) && property_exists($license_data, 'license')))) {
711 711
 				return true;
712 712
 			}
713 713
 
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
 		 * @return bool
724 724
 		 */
725 725
 		private function __is_third_party_addon() {
726
-			return ( false === strpos( $this->api_url, 'givewp.com/' ) );
726
+			return (false === strpos($this->api_url, 'givewp.com/'));
727 727
 		}
728 728
 
729 729
 		/**
@@ -738,25 +738,25 @@  discard block
 block discarded – undo
738 738
 		 * @return bool
739 739
 		 */
740 740
 		private function __remove_license_key_from_subscriptions() {
741
-			$subscriptions = get_option( 'give_subscriptions', array() );
741
+			$subscriptions = get_option('give_subscriptions', array());
742 742
 
743 743
 			// Bailout.
744
-			if ( empty( $this->license ) ) {
744
+			if (empty($this->license)) {
745 745
 				return false;
746 746
 			}
747 747
 
748
-			if ( ! empty( $subscriptions ) ) {
749
-				foreach ( $subscriptions as $subscription_id => $subscription ) {
750
-					$license_index = array_search( $this->license, $subscription['licenses'] );
751
-					if ( false !== $license_index ) {
748
+			if ( ! empty($subscriptions)) {
749
+				foreach ($subscriptions as $subscription_id => $subscription) {
750
+					$license_index = array_search($this->license, $subscription['licenses']);
751
+					if (false !== $license_index) {
752 752
 						// Remove license key.
753
-						unset( $subscriptions[ $subscription_id ]['licenses'][ $license_index ] );
753
+						unset($subscriptions[$subscription_id]['licenses'][$license_index]);
754 754
 
755 755
 						// Rearrange license keys.
756
-						$subscriptions[ $subscription_id ]['licenses'] = array_values( $subscriptions[ $subscription_id ]['licenses'] );
756
+						$subscriptions[$subscription_id]['licenses'] = array_values($subscriptions[$subscription_id]['licenses']);
757 757
 
758 758
 						// Update subscription information.
759
-						update_option( 'give_subscriptions', $subscriptions );
759
+						update_option('give_subscriptions', $subscriptions);
760 760
 						break;
761 761
 					}
762 762
 				}
@@ -770,17 +770,17 @@  discard block
 block discarded – undo
770 770
 		 *
771 771
 		 * @return bool
772 772
 		 */
773
-		public function plugin_page_notices( $plugin_file, $plugin_data, $status ) {
773
+		public function plugin_page_notices($plugin_file, $plugin_data, $status) {
774 774
 			// Bailout.
775
-			if ( $this->is_valid_license() ) {
775
+			if ($this->is_valid_license()) {
776 776
 				return false;
777 777
 			}
778 778
 
779 779
 			$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>';
780 780
 			$message            = $this->license_state_message();
781 781
 
782
-			if ( ! empty( $message['message'] ) ) {
783
-				echo sprintf( $update_notice_wrap, $message['message'] );
782
+			if ( ! empty($message['message'])) {
783
+				echo sprintf($update_notice_wrap, $message['message']);
784 784
 			}
785 785
 		}
786 786
 
@@ -795,11 +795,11 @@  discard block
 block discarded – undo
795 795
 		public function license_state_message() {
796 796
 			$message_data = array();
797 797
 
798
-			if ( ! $this->is_valid_license() ) {
798
+			if ( ! $this->is_valid_license()) {
799 799
 
800 800
 				$message_data['message'] = sprintf(
801 801
 					'Please <a href="%1$s">activate your license</a> to receive updates and support for the %2$s add-on.',
802
-					esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' ) ),
802
+					esc_url(admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses')),
803 803
 					$this->item_name
804 804
 				);
805 805
 			}
@@ -818,7 +818,7 @@  discard block
 block discarded – undo
818 818
 			// Bailout.
819 819
 			if (
820 820
 				! Give_Admin_Settings::verify_nonce() ||
821
-				! current_user_can( 'manage_give_settings' ) ||
821
+				! current_user_can('manage_give_settings') ||
822 822
 				'licenses' !== give_get_current_setting_tab()
823 823
 			) {
824 824
 				return false;
@@ -826,10 +826,10 @@  discard block
 block discarded – undo
826 826
 
827 827
 			// Security check.
828 828
 			if (
829
-				isset( $_POST[ $this->item_shortname . '_license_key-nonce' ] ) &&
830
-				! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' )
829
+				isset($_POST[$this->item_shortname.'_license_key-nonce']) &&
830
+				! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')
831 831
 			) {
832
-				wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
832
+				wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'), array('response' => 403));
833 833
 			}
834 834
 
835 835
 			return true;
@@ -847,9 +847,9 @@  discard block
 block discarded – undo
847 847
 		 *
848 848
 		 * @return mixed
849 849
 		 */
850
-		public function get_license_info( $edd_action = '', $response_in_array = false ) {
850
+		public function get_license_info($edd_action = '', $response_in_array = false) {
851 851
 
852
-			if ( empty( $edd_action ) ) {
852
+			if (empty($edd_action)) {
853 853
 				return false;
854 854
 			}
855 855
 
@@ -857,7 +857,7 @@  discard block
 block discarded – undo
857 857
 			$api_params = array(
858 858
 				'edd_action' => $edd_action, // never change from "edd_" to "give_"!
859 859
 				'license'    => $this->license,
860
-				'item_name'  => urlencode( $this->item_name ),
860
+				'item_name'  => urlencode($this->item_name),
861 861
 				'url'        => home_url(),
862 862
 			);
863 863
 
@@ -872,11 +872,11 @@  discard block
 block discarded – undo
872 872
 			);
873 873
 
874 874
 			// Make sure there are no errors.
875
-			if ( is_wp_error( $response ) ) {
875
+			if (is_wp_error($response)) {
876 876
 				return false;
877 877
 			}
878 878
 
879
-			return json_decode( wp_remote_retrieve_body( $response ), $response_in_array );
879
+			return json_decode(wp_remote_retrieve_body($response), $response_in_array);
880 880
 		}
881 881
 
882 882
 
@@ -892,9 +892,9 @@  discard block
 block discarded – undo
892 892
 			$this->__remove_license_key_from_subscriptions();
893 893
 
894 894
 			// Remove license from database.
895
-			delete_option( "{$this->item_shortname}_license_active" );
896
-			give_delete_option( "{$this->item_shortname}_license_key" );
897
-			unset( $_POST["{$this->item_shortname}_license_key"] );
895
+			delete_option("{$this->item_shortname}_license_active");
896
+			give_delete_option("{$this->item_shortname}_license_key");
897
+			unset($_POST["{$this->item_shortname}_license_key"]);
898 898
 
899 899
 			// Unset license param.
900 900
 			$this->license = '';
@@ -912,8 +912,8 @@  discard block
 block discarded – undo
912 912
 		private function is_deactivating_license() {
913 913
 			$status = false;
914 914
 
915
-			foreach ( $_POST as $key => $value ) {
916
-				if ( false !== strpos( $key, 'license_key_deactivate' ) ) {
915
+			foreach ($_POST as $key => $value) {
916
+				if (false !== strpos($key, 'license_key_deactivate')) {
917 917
 					$status = true;
918 918
 					break;
919 919
 				}
Please login to merge, or discard this patch.
includes/install.php 1 patch
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -26,15 +26,15 @@  discard block
 block discarded – undo
26 26
  * @global     $wpdb
27 27
  * @return void
28 28
  */
29
-function give_install( $network_wide = false ) {
29
+function give_install($network_wide = false) {
30 30
 
31 31
 	global $wpdb;
32 32
 
33
-	if ( is_multisite() && $network_wide ) {
33
+	if (is_multisite() && $network_wide) {
34 34
 
35
-		foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs LIMIT 100" ) as $blog_id ) {
35
+		foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs LIMIT 100") as $blog_id) {
36 36
 
37
-			switch_to_blog( $blog_id );
37
+			switch_to_blog($blog_id);
38 38
 			give_run_install();
39 39
 			restore_current_blog();
40 40
 
@@ -61,31 +61,31 @@  discard block
 block discarded – undo
61 61
 	give_setup_post_types();
62 62
 
63 63
 	// Add Upgraded From Option.
64
-	$current_version = get_option( 'give_version' );
65
-	if ( $current_version ) {
66
-		update_option( 'give_version_upgraded_from', $current_version );
64
+	$current_version = get_option('give_version');
65
+	if ($current_version) {
66
+		update_option('give_version_upgraded_from', $current_version);
67 67
 	}
68 68
 
69 69
 	// Setup some default options.
70 70
 	$options = array();
71 71
 
72 72
 	//Fresh Install? Setup Test Mode, Base Country (US), Test Gateway, Currency.
73
-	if ( empty( $current_version ) ) {
74
-		$options = array_merge( $options, give_get_default_settings() );
73
+	if (empty($current_version)) {
74
+		$options = array_merge($options, give_get_default_settings());
75 75
 	}
76 76
 
77 77
 	// Populate the default values.
78
-	update_option( 'give_settings', array_merge( $give_options, $options ) );
78
+	update_option('give_settings', array_merge($give_options, $options));
79 79
 
80 80
 	/**
81 81
 	 * Run plugin upgrades.
82 82
 	 *
83 83
 	 * @since 1.8
84 84
 	 */
85
-	do_action( 'give_upgrades' );
85
+	do_action('give_upgrades');
86 86
 
87
-	if ( GIVE_VERSION !== get_option( 'give_version' ) ) {
88
-		update_option( 'give_version', GIVE_VERSION );
87
+	if (GIVE_VERSION !== get_option('give_version')) {
88
+		update_option('give_version', GIVE_VERSION);
89 89
 	}
90 90
 
91 91
 	// Create Give roles.
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	// Set api version, end point and refresh permalink.
97 97
 	$api = new Give_API();
98 98
 	$api->add_endpoint();
99
-	update_option( 'give_default_api_version', 'v' . $api->get_version() );
99
+	update_option('give_default_api_version', 'v'.$api->get_version());
100 100
 
101 101
 	flush_rewrite_rules();
102 102
 
@@ -105,11 +105,11 @@  discard block
 block discarded – undo
105 105
 	$give_sessions->use_php_sessions();
106 106
 
107 107
 	// Add a temporary option to note that Give pages have been created.
108
-	Give_Cache::set( '_give_installed', $options, 30, true );
108
+	Give_Cache::set('_give_installed', $options, 30, true);
109 109
 
110
-	if ( ! $current_version ) {
110
+	if ( ! $current_version) {
111 111
 
112
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php';
112
+		require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php';
113 113
 
114 114
 		// When new upgrade routines are added, mark them as complete on fresh install.
115 115
 		$upgrade_routines = array(
@@ -127,18 +127,18 @@  discard block
 block discarded – undo
127 127
 			'v1817_cleanup_user_roles'
128 128
 		);
129 129
 
130
-		foreach ( $upgrade_routines as $upgrade ) {
131
-			give_set_upgrade_complete( $upgrade );
130
+		foreach ($upgrade_routines as $upgrade) {
131
+			give_set_upgrade_complete($upgrade);
132 132
 		}
133 133
 	}
134 134
 
135 135
 	// Bail if activating from network, or bulk.
136
-	if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
136
+	if (is_network_admin() || isset($_GET['activate-multi'])) {
137 137
 		return;
138 138
 	}
139 139
 
140 140
 	// Add the transient to redirect.
141
-	Give_Cache::set( '_give_activation_redirect', true, 30, true );
141
+	Give_Cache::set('_give_activation_redirect', true, 30, true);
142 142
 }
143 143
 
144 144
 /**
@@ -155,11 +155,11 @@  discard block
 block discarded – undo
155 155
  * @param  int $site_id The Site ID.
156 156
  * @param  array $meta Blog Meta.
157 157
  */
158
-function give_on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
158
+function give_on_create_blog($blog_id, $user_id, $domain, $path, $site_id, $meta) {
159 159
 
160
-	if ( is_plugin_active_for_network( GIVE_PLUGIN_BASENAME ) ) {
160
+	if (is_plugin_active_for_network(GIVE_PLUGIN_BASENAME)) {
161 161
 
162
-		switch_to_blog( $blog_id );
162
+		switch_to_blog($blog_id);
163 163
 		give_install();
164 164
 		restore_current_blog();
165 165
 
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 
168 168
 }
169 169
 
170
-add_action( 'wpmu_new_blog', 'give_on_create_blog', 10, 6 );
170
+add_action('wpmu_new_blog', 'give_on_create_blog', 10, 6);
171 171
 
172 172
 
173 173
 /**
@@ -180,13 +180,13 @@  discard block
 block discarded – undo
180 180
  *
181 181
  * @return array          The tables to drop.
182 182
  */
183
-function give_wpmu_drop_tables( $tables, $blog_id ) {
183
+function give_wpmu_drop_tables($tables, $blog_id) {
184 184
 
185
-	switch_to_blog( $blog_id );
185
+	switch_to_blog($blog_id);
186 186
 	$donors_db     = new Give_DB_Donors();
187 187
 	$donor_meta_db = new Give_DB_Donor_Meta();
188 188
 
189
-	if ( $donors_db->installed() ) {
189
+	if ($donors_db->installed()) {
190 190
 		$tables[] = $donors_db->table_name;
191 191
 		$tables[] = $donor_meta_db->table_name;
192 192
 	}
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 
197 197
 }
198 198
 
199
-add_filter( 'wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2 );
199
+add_filter('wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2);
200 200
 
201 201
 /**
202 202
  * Post-installation
@@ -208,16 +208,16 @@  discard block
 block discarded – undo
208 208
  */
209 209
 function give_after_install() {
210 210
 
211
-	if ( ! is_admin() ) {
211
+	if ( ! is_admin()) {
212 212
 		return;
213 213
 	}
214 214
 
215
-	$give_options     = Give_Cache::get( '_give_installed', true );
216
-	$give_table_check = get_option( '_give_table_check', false );
215
+	$give_options     = Give_Cache::get('_give_installed', true);
216
+	$give_table_check = get_option('_give_table_check', false);
217 217
 
218
-	if ( false === $give_table_check || current_time( 'timestamp' ) > $give_table_check ) {
218
+	if (false === $give_table_check || current_time('timestamp') > $give_table_check) {
219 219
 
220
-		if ( ! @Give()->donor_meta->installed() ) {
220
+		if ( ! @Give()->donor_meta->installed()) {
221 221
 
222 222
 			// Create the donor meta database.
223 223
 			// (this ensures it creates it on multisite instances where it is network activated).
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 
226 226
 		}
227 227
 
228
-		if ( ! @Give()->donors->installed() ) {
228
+		if ( ! @Give()->donors->installed()) {
229 229
 			// Create the donor database.
230 230
 			// (this ensures it creates it on multisite instances where it is network activated).
231 231
 			@Give()->donors->create_table();
@@ -237,22 +237,22 @@  discard block
 block discarded – undo
237 237
 			 *
238 238
 			 * @param array $give_options Give plugin options.
239 239
 			 */
240
-			do_action( 'give_after_install', $give_options );
240
+			do_action('give_after_install', $give_options);
241 241
 		}
242 242
 
243
-		update_option( '_give_table_check', ( current_time( 'timestamp' ) + WEEK_IN_SECONDS ) );
243
+		update_option('_give_table_check', (current_time('timestamp') + WEEK_IN_SECONDS));
244 244
 
245 245
 	}
246 246
 
247 247
 	// Delete the transient
248
-	if ( false !== $give_options ) {
249
-		Give_Cache::delete( Give_Cache::get_key( '_give_installed' ) );
248
+	if (false !== $give_options) {
249
+		Give_Cache::delete(Give_Cache::get_key('_give_installed'));
250 250
 	}
251 251
 
252 252
 
253 253
 }
254 254
 
255
-add_action( 'admin_init', 'give_after_install' );
255
+add_action('admin_init', 'give_after_install');
256 256
 
257 257
 
258 258
 /**
@@ -267,11 +267,11 @@  discard block
 block discarded – undo
267 267
 
268 268
 	global $wp_roles;
269 269
 
270
-	if ( ! is_object( $wp_roles ) ) {
270
+	if ( ! is_object($wp_roles)) {
271 271
 		return;
272 272
 	}
273 273
 
274
-	if ( ! array_key_exists( 'give_manager', $wp_roles->roles ) ) {
274
+	if ( ! array_key_exists('give_manager', $wp_roles->roles)) {
275 275
 
276 276
 		// Create Give plugin roles
277 277
 		$roles = new Give_Roles();
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 
283 283
 }
284 284
 
285
-add_action( 'admin_init', 'give_install_roles_on_network' );
285
+add_action('admin_init', 'give_install_roles_on_network');
286 286
 
287 287
 /**
288 288
  * Default core setting values.
@@ -320,14 +320,14 @@  discard block
 block discarded – undo
320 320
 		'uninstall_on_delete'                         => 'disabled',
321 321
 		'the_content_filter'                          => 'enabled',
322 322
 		'scripts_footer'                              => 'disabled',
323
-		'agree_to_terms_label'                        => __( 'Agree to Terms?', 'give' ),
323
+		'agree_to_terms_label'                        => __('Agree to Terms?', 'give'),
324 324
 		'agreement_text'                              => give_get_default_agreement_text(),
325 325
 
326 326
 		// Paypal IPN verification.
327 327
 		'paypal_verification'                         => 'enabled',
328 328
 
329 329
 		// Default is manual gateway.
330
-		'gateways'                                    => array( 'manual' => 1, 'offline' => 1 ),
330
+		'gateways'                                    => array('manual' => 1, 'offline' => 1),
331 331
 		'default_gateway'                             => 'manual',
332 332
 
333 333
 		// Offline gateway setup.
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
  */
356 356
 function give_get_default_agreement_text() {
357 357
 
358
-	$org_name = get_bloginfo( 'name' );
358
+	$org_name = get_bloginfo('name');
359 359
 
360 360
 	$agreement = sprintf(
361 361
 		'<p>Acceptance of any contribution, gift or grant is at the discretion of the %1$s. The  %1$s will not accept any gift unless it can be used or expended consistently with the purpose and mission of the  %1$s.</p>
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 		$org_name
370 370
 	);
371 371
 
372
-	return apply_filters( 'give_get_default_agreement_text', $agreement, $org_name );
372
+	return apply_filters('give_get_default_agreement_text', $agreement, $org_name);
373 373
 }
374 374
 
375 375
 
@@ -378,22 +378,22 @@  discard block
 block discarded – undo
378 378
  *
379 379
  * @since 1.8.11
380 380
  */
381
-function give_create_pages(){
381
+function give_create_pages() {
382 382
 
383 383
 	// Bailout if pages already created.
384
-	if( get_option( 'give_install_pages_created') ) {
384
+	if (get_option('give_install_pages_created')) {
385 385
 		return false;
386 386
 	}
387 387
 
388 388
 	$options = array();
389 389
 
390 390
 	// Checks if the Success Page option exists AND that the page exists.
391
-	if ( ! get_post( give_get_option( 'success_page' ) ) ) {
391
+	if ( ! get_post(give_get_option('success_page'))) {
392 392
 
393 393
 		// Donation Confirmation (Success) Page
394 394
 		$success = wp_insert_post(
395 395
 			array(
396
-				'post_title'     => esc_html__( 'Donation Confirmation', 'give' ),
396
+				'post_title'     => esc_html__('Donation Confirmation', 'give'),
397 397
 				'post_content'   => '[give_receipt]',
398 398
 				'post_status'    => 'publish',
399 399
 				'post_author'    => 1,
@@ -407,13 +407,13 @@  discard block
 block discarded – undo
407 407
 	}
408 408
 
409 409
 	// Checks if the Failure Page option exists AND that the page exists.
410
-	if ( ! get_post( give_get_option( 'failure_page' ) ) ) {
410
+	if ( ! get_post(give_get_option('failure_page'))) {
411 411
 
412 412
 		// Failed Donation Page
413 413
 		$failed = wp_insert_post(
414 414
 			array(
415
-				'post_title'     => esc_html__( 'Donation Failed', 'give' ),
416
-				'post_content'   => esc_html__( 'We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give' ),
415
+				'post_title'     => esc_html__('Donation Failed', 'give'),
416
+				'post_content'   => esc_html__('We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give'),
417 417
 				'post_status'    => 'publish',
418 418
 				'post_author'    => 1,
419 419
 				'post_type'      => 'page',
@@ -425,11 +425,11 @@  discard block
 block discarded – undo
425 425
 	}
426 426
 
427 427
 	// Checks if the History Page option exists AND that the page exists.
428
-	if ( ! get_post( give_get_option( 'history_page' ) ) ) {
428
+	if ( ! get_post(give_get_option('history_page'))) {
429 429
 		// Donation History Page
430 430
 		$history = wp_insert_post(
431 431
 			array(
432
-				'post_title'     => esc_html__( 'Donation History', 'give' ),
432
+				'post_title'     => esc_html__('Donation History', 'give'),
433 433
 				'post_content'   => '[donation_history]',
434 434
 				'post_status'    => 'publish',
435 435
 				'post_author'    => 1,
@@ -441,10 +441,10 @@  discard block
 block discarded – undo
441 441
 		$options['history_page'] = $history;
442 442
 	}
443 443
 
444
-	if( ! empty( $options ) ) {
445
-		update_option( 'give_settings', array_merge( give_get_settings(), $options ) );
444
+	if ( ! empty($options)) {
445
+		update_option('give_settings', array_merge(give_get_settings(), $options));
446 446
 	}
447 447
 
448
-	add_option( 'give_install_pages_created', 1, '', 'no' );
448
+	add_option('give_install_pages_created', 1, '', 'no');
449 449
 }
450
-add_action( 'admin_init', 'give_create_pages', -1 );
450
+add_action('admin_init', 'give_create_pages', -1);
Please login to merge, or discard this patch.
includes/admin/reports/class-earnings-report.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -9,11 +9,11 @@  discard block
 block discarded – undo
9 9
  * @since       1.8
10 10
  */
11 11
 
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit; // Exit if accessed directly
14 14
 }
15 15
 
16
-if ( ! class_exists( 'Give_Earnings_Report' ) ) :
16
+if ( ! class_exists('Give_Earnings_Report')) :
17 17
 
18 18
 	/**
19 19
 	 * Give_Earnings_Report.
@@ -35,16 +35,16 @@  discard block
 block discarded – undo
35 35
 		 */
36 36
 		public function __construct() {
37 37
 			$this->id    = 'earnings';
38
-			$this->label = esc_html__( 'Income', 'give' );
38
+			$this->label = esc_html__('Income', 'give');
39 39
 
40 40
 			parent::__construct();
41 41
 
42
-			add_action( 'give_admin_field_report_earnings', array( $this, 'render_report_earnings_field' ), 10, 2 );
42
+			add_action('give_admin_field_report_earnings', array($this, 'render_report_earnings_field'), 10, 2);
43 43
 
44 44
 			// Do not use main form for this tab.
45
-			if ( give_get_current_setting_tab() === $this->id ) {
46
-				add_action( 'give-reports_open_form', '__return_empty_string' );
47
-				add_action( 'give-reports_close_form', '__return_empty_string' );
45
+			if (give_get_current_setting_tab() === $this->id) {
46
+				add_action('give-reports_open_form', '__return_empty_string');
47
+				add_action('give-reports_close_form', '__return_empty_string');
48 48
 			}
49 49
 		}
50 50
 
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 			 * @param  array $settings
65 65
 			 */
66 66
 			$settings = apply_filters(
67
-				'give_get_settings_' . $this->id,
67
+				'give_get_settings_'.$this->id,
68 68
 				array(
69 69
 					array(
70 70
 						'id'         => 'give_tools_earnings',
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 					),
74 74
 					array(
75 75
 						'id'   => 'earnings',
76
-						'name' => esc_html__( 'Income', 'give' ),
76
+						'name' => esc_html__('Income', 'give'),
77 77
 						'type' => 'report_earnings',
78 78
 					),
79 79
 					array(
@@ -97,8 +97,8 @@  discard block
 block discarded – undo
97 97
 		 * @param $field
98 98
 		 * @param $option_value
99 99
 		 */
100
-		public function render_report_earnings_field( $field, $option_value ) {
101
-			do_action( 'give_reports_view_earnings' );
100
+		public function render_report_earnings_field($field, $option_value) {
101
+			do_action('give_reports_view_earnings');
102 102
 		}
103 103
 	}
104 104
 
Please login to merge, or discard this patch.
includes/admin/reports/class-forms-report.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -9,11 +9,11 @@  discard block
 block discarded – undo
9 9
  * @since       1.8
10 10
  */
11 11
 
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit; // Exit if accessed directly
14 14
 }
15 15
 
16
-if ( ! class_exists( 'Give_Forms_Report' ) ) :
16
+if ( ! class_exists('Give_Forms_Report')) :
17 17
 
18 18
 	/**
19 19
 	 * Give_Forms_Report.
@@ -34,16 +34,16 @@  discard block
 block discarded – undo
34 34
 		 */
35 35
 		public function __construct() {
36 36
 			$this->id    = 'forms';
37
-			$this->label = esc_html__( 'Forms', 'give' );
37
+			$this->label = esc_html__('Forms', 'give');
38 38
 
39 39
 			parent::__construct();
40 40
 
41
-			add_action( 'give_admin_field_report_forms', array( $this, 'render_report_forms_field' ), 10, 2 );
41
+			add_action('give_admin_field_report_forms', array($this, 'render_report_forms_field'), 10, 2);
42 42
 
43 43
 			// Do not use main form for this tab.
44
-			if ( give_get_current_setting_tab() === $this->id ) {
45
-				add_action( 'give-reports_open_form', '__return_empty_string' );
46
-				add_action( 'give-reports_close_form', '__return_empty_string' );
44
+			if (give_get_current_setting_tab() === $this->id) {
45
+				add_action('give-reports_open_form', '__return_empty_string');
46
+				add_action('give-reports_close_form', '__return_empty_string');
47 47
 			}
48 48
 		}
49 49
 
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 			 * @param  array $settings
64 64
 			 */
65 65
 			$settings = apply_filters(
66
-				'give_get_settings_' . $this->id,
66
+				'give_get_settings_'.$this->id,
67 67
 				array(
68 68
 					array(
69 69
 						'id'         => 'give_reports_forms',
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 					),
73 73
 					array(
74 74
 						'id'   => 'forms',
75
-						'name' => esc_html__( 'Forms', 'give' ),
75
+						'name' => esc_html__('Forms', 'give'),
76 76
 						'type' => 'report_forms',
77 77
 					),
78 78
 					array(
@@ -96,8 +96,8 @@  discard block
 block discarded – undo
96 96
 		 * @param $field
97 97
 		 * @param $option_value
98 98
 		 */
99
-		public function render_report_forms_field( $field, $option_value ) {
100
-			do_action( 'give_reports_view_forms' );
99
+		public function render_report_forms_field($field, $option_value) {
100
+			do_action('give_reports_view_forms');
101 101
 		}
102 102
 	}
103 103
 
Please login to merge, or discard this patch.
includes/admin/reports/reports.php 1 patch
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  */
17 17
 
18 18
 // Exit if accessed directly.
19
-if ( ! defined( 'ABSPATH' ) ) {
19
+if ( ! defined('ABSPATH')) {
20 20
 	exit;
21 21
 }
22 22
 
@@ -29,8 +29,8 @@  discard block
 block discarded – undo
29 29
  * @return void
30 30
  */
31 31
 function give_reports_page() {
32
-	$current_page = admin_url( 'edit.php?post_type=give_forms&page=give-reports' );
33
-	$active_tab   = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'earnings';
32
+	$current_page = admin_url('edit.php?post_type=give_forms&page=give-reports');
33
+	$active_tab   = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'earnings';
34 34
 	$views        = give_reports_default_views();
35 35
 	?>
36 36
 	<div class="wrap give-settings-page">
@@ -38,17 +38,17 @@  discard block
 block discarded – undo
38 38
 		<h1 class="screen-reader-text"><?php echo get_admin_page_title(); ?></h1>
39 39
 
40 40
 		<h2 class="nav-tab-wrapper">
41
-			<?php foreach ( $views as $tab => $label ) { ?>
42
-				<a href="<?php echo esc_url( add_query_arg( array(
41
+			<?php foreach ($views as $tab => $label) { ?>
42
+				<a href="<?php echo esc_url(add_query_arg(array(
43 43
 					'tab'              => $tab,
44 44
 					'settings-updated' => false,
45
-				), $current_page ) ); ?>" class="nav-tab <?php echo $tab === $active_tab ? esc_attr( 'nav-tab-active' ) : ''; ?>"><?php echo esc_html( $label ); ?></a>
45
+				), $current_page)); ?>" class="nav-tab <?php echo $tab === $active_tab ? esc_attr('nav-tab-active') : ''; ?>"><?php echo esc_html($label); ?></a>
46 46
 			<?php } ?>
47
-			<?php if ( current_user_can( 'export_give_reports' ) ) { ?>
48
-				<a href="<?php echo esc_url( add_query_arg( array(
47
+			<?php if (current_user_can('export_give_reports')) { ?>
48
+				<a href="<?php echo esc_url(add_query_arg(array(
49 49
 					'tab'              => 'export',
50 50
 					'settings-updated' => false,
51
-				), $current_page ) ); ?>" class="nav-tab <?php echo 'export' === $active_tab ? esc_attr( 'nav-tab-active' ) : ''; ?>"><?php esc_html_e( 'Export', 'give' ); ?></a>
51
+				), $current_page)); ?>" class="nav-tab <?php echo 'export' === $active_tab ? esc_attr('nav-tab-active') : ''; ?>"><?php esc_html_e('Export', 'give'); ?></a>
52 52
 			<?php }
53 53
 			/**
54 54
 			 * Fires in the report tabs.
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 			 *
58 58
 			 * @since 1.0
59 59
 			 */
60
-			do_action( 'give_reports_tabs' );
60
+			do_action('give_reports_tabs');
61 61
 			?>
62 62
 		</h2>
63 63
 
@@ -67,10 +67,10 @@  discard block
 block discarded – undo
67 67
 		 *
68 68
 		 * @since 1.0
69 69
 		 */
70
-		do_action( 'give_reports_page_top' );
70
+		do_action('give_reports_page_top');
71 71
 
72 72
 		// Set $active_tab prior to hook firing.
73
-		if ( in_array( $active_tab, array_keys( $views ) ) ) {
73
+		if (in_array($active_tab, array_keys($views))) {
74 74
 			$active_tab = 'reports';
75 75
 		}
76 76
 
@@ -79,14 +79,14 @@  discard block
 block discarded – undo
79 79
 		 *
80 80
 		 * @since 1.0
81 81
 		 */
82
-		do_action( "give_reports_tab_{$active_tab}" );
82
+		do_action("give_reports_tab_{$active_tab}");
83 83
 
84 84
 		/**
85 85
 		 * Fires after the report page.
86 86
 		 *
87 87
 		 * @since 1.0
88 88
 		 */
89
-		do_action( 'give_reports_page_bottom' );
89
+		do_action('give_reports_page_bottom');
90 90
 		?>
91 91
 	</div><!-- .wrap -->
92 92
 	<?php
@@ -100,12 +100,12 @@  discard block
 block discarded – undo
100 100
  */
101 101
 function give_reports_default_views() {
102 102
 	$views = array(
103
-		'earnings' => esc_html__( 'Income', 'give' ),
104
-		'forms'    => esc_html__( 'Forms', 'give' ),
105
-		'gateways' => esc_html__( 'Donation Methods', 'give' ),
103
+		'earnings' => esc_html__('Income', 'give'),
104
+		'forms'    => esc_html__('Forms', 'give'),
105
+		'gateways' => esc_html__('Donation Methods', 'give'),
106 106
 	);
107 107
 
108
-	$views = apply_filters( 'give_report_views', $views );
108
+	$views = apply_filters('give_report_views', $views);
109 109
 
110 110
 	return $views;
111 111
 }
@@ -120,15 +120,15 @@  discard block
 block discarded – undo
120 120
  * @since 1.0
121 121
  * @return string $view Report View
122 122
  */
123
-function give_get_reporting_view( $default = 'earnings' ) {
123
+function give_get_reporting_view($default = 'earnings') {
124 124
 
125
-	if ( ! isset( $_GET['view'] ) || ! in_array( $_GET['view'], array_keys( give_reports_default_views() ) ) ) {
125
+	if ( ! isset($_GET['view']) || ! in_array($_GET['view'], array_keys(give_reports_default_views()))) {
126 126
 		$view = $default;
127 127
 	} else {
128 128
 		$view = $_GET['view'];
129 129
 	}
130 130
 
131
-	return apply_filters( 'give_get_reporting_view', $view );
131
+	return apply_filters('give_get_reporting_view', $view);
132 132
 }
133 133
 
134 134
 /**
@@ -139,14 +139,14 @@  discard block
 block discarded – undo
139 139
  */
140 140
 function give_reports_tab_reports() {
141 141
 
142
-	if( ! current_user_can( 'view_give_reports' ) ) {
143
-		wp_die( __( 'You do not have permission to access this report', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
142
+	if ( ! current_user_can('view_give_reports')) {
143
+		wp_die(__('You do not have permission to access this report', 'give'), __('Error', 'give'), array('response' => 403));
144 144
 	}
145 145
 
146 146
 	$current_view = 'earnings';
147 147
 	$views        = give_reports_default_views();
148 148
 
149
-	if ( isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $views ) ) {
149
+	if (isset($_GET['tab']) && array_key_exists($_GET['tab'], $views)) {
150 150
 		$current_view = $_GET['tab'];
151 151
 	}
152 152
 
@@ -155,10 +155,10 @@  discard block
 block discarded – undo
155 155
 	 *
156 156
 	 * @since 1.0
157 157
 	 */
158
-	do_action( "give_reports_view_{$current_view}" );
158
+	do_action("give_reports_view_{$current_view}");
159 159
 }
160 160
 
161
-add_action( 'give_reports_tab_reports', 'give_reports_tab_reports' );
161
+add_action('give_reports_tab_reports', 'give_reports_tab_reports');
162 162
 
163 163
 /**
164 164
  * Renders the Reports Page Views Drop Downs
@@ -168,19 +168,19 @@  discard block
 block discarded – undo
168 168
  */
169 169
 function give_report_views() {
170 170
 	$views        = give_reports_default_views();
171
-	$current_view = isset( $_GET['view'] ) ? $_GET['view'] : 'earnings';
171
+	$current_view = isset($_GET['view']) ? $_GET['view'] : 'earnings';
172 172
 	/**
173 173
 	 * Fires before the report page actions form.
174 174
 	 *
175 175
 	 * @since 1.0
176 176
 	 */
177
-	do_action( 'give_report_view_actions_before' );
177
+	do_action('give_report_view_actions_before');
178 178
 	?>
179 179
 	<form id="give-reports-filter" method="get">
180 180
 		<select id="give-reports-view" name="view">
181
-			<option value="-1"><?php esc_html_e( 'Report Type', 'give' ); ?></option>
182
-			<?php foreach ( $views as $view_id => $label ) : ?>
183
-				<option value="<?php echo esc_attr( $view_id ); ?>" <?php selected( $view_id, $current_view ); ?>><?php echo $label; ?></option>
181
+			<option value="-1"><?php esc_html_e('Report Type', 'give'); ?></option>
182
+			<?php foreach ($views as $view_id => $label) : ?>
183
+				<option value="<?php echo esc_attr($view_id); ?>" <?php selected($view_id, $current_view); ?>><?php echo $label; ?></option>
184 184
 			<?php endforeach; ?>
185 185
 		</select>
186 186
 
@@ -192,12 +192,12 @@  discard block
 block discarded – undo
192 192
 		 *
193 193
 		 * @since 1.0
194 194
 		 */
195
-		do_action( 'give_report_view_actions' );
195
+		do_action('give_report_view_actions');
196 196
 		?>
197 197
 
198 198
 		<input type="hidden" name="post_type" value="give_forms"/>
199 199
 		<input type="hidden" name="page" value="give-reports"/>
200
-		<?php submit_button( esc_html__( 'Show', 'give' ), 'secondary', 'submit', false ); ?>
200
+		<?php submit_button(esc_html__('Show', 'give'), 'secondary', 'submit', false); ?>
201 201
 	</form>
202 202
 	<?php
203 203
 	/**
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 	 *
206 206
 	 * @since 1.0
207 207
 	 */
208
-	do_action( 'give_report_view_actions_after' );
208
+	do_action('give_report_view_actions_after');
209 209
 }
210 210
 
211 211
 /**
@@ -218,11 +218,11 @@  discard block
 block discarded – undo
218 218
  */
219 219
 function give_reports_forms_table() {
220 220
 
221
-	if ( isset( $_GET['form-id'] ) ) {
221
+	if (isset($_GET['form-id'])) {
222 222
 		return;
223 223
 	}
224 224
 
225
-	include( dirname( __FILE__ ) . '/class-form-reports-table.php' );
225
+	include(dirname(__FILE__).'/class-form-reports-table.php');
226 226
 
227 227
 	$give_table = new Give_Form_Reports_Table();
228 228
 	$give_table->prepare_items();
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 	<?php
235 235
 }
236 236
 
237
-add_action( 'give_reports_view_forms', 'give_reports_forms_table' );
237
+add_action('give_reports_view_forms', 'give_reports_forms_table');
238 238
 
239 239
 /**
240 240
  * Renders the detailed report for a specific give form.
@@ -243,20 +243,20 @@  discard block
 block discarded – undo
243 243
  * @return void
244 244
  */
245 245
 function give_reports_form_details() {
246
-	if ( ! isset( $_GET['form-id'] ) ) {
246
+	if ( ! isset($_GET['form-id'])) {
247 247
 		return;
248 248
 	}
249 249
 	?>
250 250
 	<div class="tablenav top reports-forms-details-wrap">
251 251
 		<div class="actions bulkactions">
252
-			<button onclick="history.go(-1);" class="button-secondary"><?php esc_html_e( 'Go Back', 'give' ); ?></button>
252
+			<button onclick="history.go(-1);" class="button-secondary"><?php esc_html_e('Go Back', 'give'); ?></button>
253 253
 		</div>
254 254
 	</div>
255 255
 	<?php
256
-	give_reports_graph_of_form( absint( $_GET['form-id'] ) );
256
+	give_reports_graph_of_form(absint($_GET['form-id']));
257 257
 }
258 258
 
259
-add_action( 'give_reports_view_forms', 'give_reports_form_details' );
259
+add_action('give_reports_view_forms', 'give_reports_form_details');
260 260
 
261 261
 /**
262 262
  * Renders the Gateways Table
@@ -267,14 +267,14 @@  discard block
 block discarded – undo
267 267
  * @return void
268 268
  */
269 269
 function give_reports_gateways_table() {
270
-	include( dirname( __FILE__ ) . '/class-gateways-reports-table.php' );
270
+	include(dirname(__FILE__).'/class-gateways-reports-table.php');
271 271
 
272 272
 	$give_table = new Give_Gateway_Reports_Table();
273 273
 	$give_table->prepare_items();
274 274
 	$give_table->display();
275 275
 }
276 276
 
277
-add_action( 'give_reports_view_gateways', 'give_reports_gateways_table' );
277
+add_action('give_reports_view_gateways', 'give_reports_gateways_table');
278 278
 
279 279
 /**
280 280
  * Renders the Reports Earnings Graphs
@@ -285,13 +285,13 @@  discard block
 block discarded – undo
285 285
 function give_reports_earnings() {
286 286
 	?>
287 287
 	<div class="tablenav top reports-table-nav">
288
-		<h2 class="reports-earnings-title screen-reader-text"><?php _e( 'Income Report', 'give' ); ?></h2>
288
+		<h2 class="reports-earnings-title screen-reader-text"><?php _e('Income Report', 'give'); ?></h2>
289 289
 	</div>
290 290
 	<?php
291 291
 	give_reports_graph();
292 292
 }
293 293
 
294
-add_action( 'give_reports_view_earnings', 'give_reports_earnings' );
294
+add_action('give_reports_view_earnings', 'give_reports_earnings');
295 295
 
296 296
 
297 297
 /**
@@ -302,9 +302,9 @@  discard block
 block discarded – undo
302 302
  */
303 303
 function give_estimated_monthly_stats() {
304 304
 
305
-	$estimated = Give_Cache::get( 'give_estimated_monthly_stats', true );
305
+	$estimated = Give_Cache::get('give_estimated_monthly_stats', true);
306 306
 
307
-	if ( false === $estimated ) {
307
+	if (false === $estimated) {
308 308
 
309 309
 		$estimated = array(
310 310
 			'earnings' => 0,
@@ -313,22 +313,22 @@  discard block
 block discarded – undo
313 313
 
314 314
 		$stats = new Give_Payment_Stats;
315 315
 
316
-		$to_date_earnings = $stats->get_earnings( 0, 'this_month' );
317
-		$to_date_sales    = $stats->get_sales( 0, 'this_month' );
316
+		$to_date_earnings = $stats->get_earnings(0, 'this_month');
317
+		$to_date_sales    = $stats->get_sales(0, 'this_month');
318 318
 
319
-		$current_day   = date( 'd', current_time( 'timestamp' ) );
320
-		$current_month = date( 'n', current_time( 'timestamp' ) );
321
-		$current_year  = date( 'Y', current_time( 'timestamp' ) );
322
-		$days_in_month = cal_days_in_month( CAL_GREGORIAN, $current_month, $current_year );
319
+		$current_day   = date('d', current_time('timestamp'));
320
+		$current_month = date('n', current_time('timestamp'));
321
+		$current_year  = date('Y', current_time('timestamp'));
322
+		$days_in_month = cal_days_in_month(CAL_GREGORIAN, $current_month, $current_year);
323 323
 
324
-		$estimated['earnings'] = ( $to_date_earnings / $current_day ) * $days_in_month;
325
-		$estimated['sales']    = ( $to_date_sales / $current_day ) * $days_in_month;
324
+		$estimated['earnings'] = ($to_date_earnings / $current_day) * $days_in_month;
325
+		$estimated['sales']    = ($to_date_sales / $current_day) * $days_in_month;
326 326
 
327 327
 		// Cache for one day
328
-		Give_Cache::set( 'give_estimated_monthly_stats', $estimated, DAY_IN_SECONDS, true );
328
+		Give_Cache::set('give_estimated_monthly_stats', $estimated, DAY_IN_SECONDS, true);
329 329
 	}
330 330
 
331
-	return maybe_unserialize( $estimated );
331
+	return maybe_unserialize($estimated);
332 332
 }
333 333
 
334 334
 /**
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
 function give_reports_set_form_method() {
342 342
 	return 'get';
343 343
 }
344
-add_filter( 'give-reports_form_method_tab_forms', 'give_reports_set_form_method', 10 );
345
-add_filter( 'give-reports_form_method_tab_donors', 'give_reports_set_form_method', 10 );
344
+add_filter('give-reports_form_method_tab_forms', 'give_reports_set_form_method', 10);
345
+add_filter('give-reports_form_method_tab_donors', 'give_reports_set_form_method', 10);
346 346
 
347 347
 // @TODO: After release 1.8 Donations -> Reports generates with new setting api, so we can remove some old code from this file.
Please login to merge, or discard this patch.
includes/admin/reports/class-gateways-report.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -9,11 +9,11 @@  discard block
 block discarded – undo
9 9
  * @since       1.8
10 10
  */
11 11
 
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit; // Exit if accessed directly
14 14
 }
15 15
 
16
-if ( ! class_exists( 'Give_Gateways_Report' ) ) :
16
+if ( ! class_exists('Give_Gateways_Report')) :
17 17
 
18 18
 	/**
19 19
 	 * Give_Gateways_Report.
@@ -34,16 +34,16 @@  discard block
 block discarded – undo
34 34
 		 */
35 35
 		public function __construct() {
36 36
 			$this->id    = 'gateways';
37
-			$this->label = esc_html__( 'Donation Methods', 'give' );
37
+			$this->label = esc_html__('Donation Methods', 'give');
38 38
 
39 39
 			parent::__construct();
40 40
 
41
-			add_action( 'give_admin_field_report_gateways', array( $this, 'render_report_gateways_field' ), 10, 2 );
41
+			add_action('give_admin_field_report_gateways', array($this, 'render_report_gateways_field'), 10, 2);
42 42
 
43 43
 			// Do not use main form for this tab.
44
-			if ( give_get_current_setting_tab() === $this->id ) {
45
-				add_action( 'give-reports_open_form', '__return_empty_string' );
46
-				add_action( 'give-reports_close_form', '__return_empty_string' );
44
+			if (give_get_current_setting_tab() === $this->id) {
45
+				add_action('give-reports_open_form', '__return_empty_string');
46
+				add_action('give-reports_close_form', '__return_empty_string');
47 47
 			}
48 48
 		}
49 49
 
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 			 * @param  array $settings
76 76
 			 */
77 77
 			$settings = apply_filters(
78
-				'give_get_settings_' . $this->id,
78
+				'give_get_settings_'.$this->id,
79 79
 				array(
80 80
 					array(
81 81
 						'id'         => 'give_reports_gateways',
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 					),
85 85
 					array(
86 86
 						'id'   => 'gateways',
87
-						'name' => esc_html__( 'Gateways', 'give' ),
87
+						'name' => esc_html__('Gateways', 'give'),
88 88
 						'type' => 'report_gateways',
89 89
 					),
90 90
 					array(
@@ -108,8 +108,8 @@  discard block
 block discarded – undo
108 108
 		 * @param $field
109 109
 		 * @param $option_value
110 110
 		 */
111
-		public function render_report_gateways_field( $field, $option_value ) {
112
-			do_action( 'give_reports_view_gateways' );
111
+		public function render_report_gateways_field($field, $option_value) {
112
+			do_action('give_reports_view_gateways');
113 113
 		}
114 114
 	}
115 115
 
Please login to merge, or discard this patch.
includes/admin/reports/class-form-reports-table.php 1 patch
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -10,13 +10,13 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
17 17
 // Load WP_List_Table if not loaded
18
-if ( ! class_exists( 'WP_List_Table' ) ) {
19
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
18
+if ( ! class_exists('WP_List_Table')) {
19
+	require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
20 20
 }
21 21
 
22 22
 /**
@@ -56,13 +56,13 @@  discard block
 block discarded – undo
56 56
 		global $status, $page;
57 57
 
58 58
 		// Set parent defaults
59
-		parent::__construct( array(
60
-			'singular' => give_get_forms_label_singular(),    // Singular name of the listed records.
61
-			'plural'   => give_get_forms_label_plural(),        // Plural name of the listed records.
59
+		parent::__construct(array(
60
+			'singular' => give_get_forms_label_singular(), // Singular name of the listed records.
61
+			'plural'   => give_get_forms_label_plural(), // Plural name of the listed records.
62 62
 			'ajax'     => false                        // Does this table support ajax?
63
-		) );
63
+		));
64 64
 
65
-		add_action( 'give_report_view_actions', array( $this, 'category_filter' ) );
65
+		add_action('give_report_view_actions', array($this, 'category_filter'));
66 66
 		$this->query();
67 67
 
68 68
 	}
@@ -78,32 +78,32 @@  discard block
 block discarded – undo
78 78
 	 *
79 79
 	 * @return string Column Name
80 80
 	 */
81
-	public function column_default( $item, $column_name ) {
82
-		switch ( $column_name ) {
81
+	public function column_default($item, $column_name) {
82
+		switch ($column_name) {
83 83
 			case 'title':
84
-				$title = empty( $item['title'] ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $item['ID'] ) : $item['title'];
84
+				$title = empty($item['title']) ? sprintf(__('Untitled (#%s)', 'give'), $item['ID']) : $item['title'];
85 85
 
86 86
 				return sprintf(
87 87
 					'<a href="%s">%s</a>',
88
-					get_edit_post_link( $item['ID'] ),
88
+					get_edit_post_link($item['ID']),
89 89
 					$title
90 90
 				);
91 91
 			case 'sales':
92 92
 				return sprintf(
93 93
 					'<a href="%s">%s</a>',
94
-					admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&form_id=' . urlencode( $item['ID'] ) ),
94
+					admin_url('edit.php?post_type=give_forms&page=give-payment-history&form_id='.urlencode($item['ID'])),
95 95
 					$item['sales']
96 96
 				);
97 97
 			case 'earnings' :
98
-				return give_currency_filter( give_format_amount( $item[ $column_name ], array( 'sanitize' => false ) ) );
98
+				return give_currency_filter(give_format_amount($item[$column_name], array('sanitize' => false)));
99 99
 			case 'average_sales' :
100
-				return round( $item[ $column_name ] );
100
+				return round($item[$column_name]);
101 101
 			case 'average_earnings' :
102
-				return give_currency_filter( give_format_amount( $item[ $column_name ], array( 'sanitize' => false ) ) );
102
+				return give_currency_filter(give_format_amount($item[$column_name], array('sanitize' => false)));
103 103
 			case 'details' :
104
-				return '<a href="' . admin_url( 'edit.php?post_type=give_forms&page=give-reports&tab=forms&form-id=' . $item['ID'] ) . '">' . esc_html__( 'View Detailed Report', 'give' ) . '</a>';
104
+				return '<a href="'.admin_url('edit.php?post_type=give_forms&page=give-reports&tab=forms&form-id='.$item['ID']).'">'.esc_html__('View Detailed Report', 'give').'</a>';
105 105
 			default:
106
-				return $item[ $column_name ];
106
+				return $item[$column_name];
107 107
 		}
108 108
 	}
109 109
 
@@ -117,12 +117,12 @@  discard block
 block discarded – undo
117 117
 	 */
118 118
 	public function get_columns() {
119 119
 		$columns = array(
120
-			'title'            => esc_html__( 'Form', 'give' ),
121
-			'sales'            => esc_html__( 'Donations', 'give' ),
122
-			'earnings'         => esc_html__( 'Income', 'give' ),
123
-			'average_sales'    => esc_html__( 'Monthly Average Donations', 'give' ),
124
-			'average_earnings' => esc_html__( 'Monthly Average Income', 'give' ),
125
-			'details'          => esc_html__( 'Detailed Report', 'give' )
120
+			'title'            => esc_html__('Form', 'give'),
121
+			'sales'            => esc_html__('Donations', 'give'),
122
+			'earnings'         => esc_html__('Income', 'give'),
123
+			'average_sales'    => esc_html__('Monthly Average Donations', 'give'),
124
+			'average_earnings' => esc_html__('Monthly Average Income', 'give'),
125
+			'details'          => esc_html__('Detailed Report', 'give')
126 126
 		);
127 127
 
128 128
 		return $columns;
@@ -138,9 +138,9 @@  discard block
 block discarded – undo
138 138
 	 */
139 139
 	public function get_sortable_columns() {
140 140
 		return array(
141
-			'title'    => array( 'title', true ),
142
-			'sales'    => array( 'sales', false ),
143
-			'earnings' => array( 'earnings', false ),
141
+			'title'    => array('title', true),
142
+			'sales'    => array('sales', false),
143
+			'earnings' => array('earnings', false),
144 144
 		);
145 145
 	}
146 146
 
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	 * @return int Current page number
154 154
 	 */
155 155
 	public function get_paged() {
156
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
156
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
157 157
 	}
158 158
 
159 159
 	/**
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	 * @return int Category ID
166 166
 	 */
167 167
 	public function get_category() {
168
-		return isset( $_GET['category'] ) ? absint( $_GET['category'] ) : 0;
168
+		return isset($_GET['category']) ? absint($_GET['category']) : 0;
169 169
 	}
170 170
 
171 171
 	/**
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 	 *
177 177
 	 * @return void
178 178
 	 */
179
-	public function bulk_actions( $which = '' ) {
179
+	public function bulk_actions($which = '') {
180 180
 
181 181
 	}
182 182
 
@@ -188,27 +188,27 @@  discard block
 block discarded – undo
188 188
 	 *
189 189
 	 * @param string $which
190 190
 	 */
191
-	protected function display_tablenav( $which ) {
191
+	protected function display_tablenav($which) {
192 192
 
193
-		if ( 'top' === $which ) {
194
-			wp_nonce_field( 'bulk-' . $this->_args['plural'] );
193
+		if ('top' === $which) {
194
+			wp_nonce_field('bulk-'.$this->_args['plural']);
195 195
 		}
196 196
 		?>
197
-		<div class="tablenav give-clearfix <?php echo esc_attr( $which ); ?>">
197
+		<div class="tablenav give-clearfix <?php echo esc_attr($which); ?>">
198 198
 
199
-			<?php if ( 'top' === $which ) { ?>
199
+			<?php if ('top' === $which) { ?>
200 200
 				<h2 class="alignleft reports-earnings-title screen-reader-text">
201
-					<?php _e( 'Donation Forms Report', 'give' ); ?>
201
+					<?php _e('Donation Forms Report', 'give'); ?>
202 202
 				</h2>
203 203
 			<?php } ?>
204 204
 
205 205
 			<div class="alignright tablenav-right">
206 206
 				<div class="actions bulkactions">
207
-					<?php $this->bulk_actions( $which ); ?>
207
+					<?php $this->bulk_actions($which); ?>
208 208
 				</div>
209 209
 				<?php
210
-				$this->extra_tablenav( $which );
211
-				$this->pagination( $which );
210
+				$this->extra_tablenav($which);
211
+				$this->pagination($which);
212 212
 				?>
213 213
 			</div>
214 214
 
@@ -228,9 +228,9 @@  discard block
 block discarded – undo
228 228
 	 */
229 229
 	public function category_filter() {
230 230
 
231
-		$categories = get_terms( 'form_category' );
232
-		if ( $categories && ! is_wp_error( $categories ) ) {
233
-			echo Give()->html->category_dropdown( 'category', $this->get_category() );
231
+		$categories = get_terms('form_category');
232
+		if ($categories && ! is_wp_error($categories)) {
233
+			echo Give()->html->category_dropdown('category', $this->get_category());
234 234
 		}
235 235
 	}
236 236
 
@@ -244,8 +244,8 @@  discard block
 block discarded – undo
244 244
 	 */
245 245
 	public function query() {
246 246
 
247
-		$orderby  = isset( $_GET['orderby'] ) ? $_GET['orderby'] : 'title';
248
-		$order    = isset( $_GET['order'] ) ? $_GET['order'] : 'DESC';
247
+		$orderby  = isset($_GET['orderby']) ? $_GET['orderby'] : 'title';
248
+		$order    = isset($_GET['order']) ? $_GET['order'] : 'DESC';
249 249
 		$category = $this->get_category();
250 250
 
251 251
 		$args = array(
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 			'suppress_filters' => true
259 259
 		);
260 260
 
261
-		if ( ! empty( $category ) ) {
261
+		if ( ! empty($category)) {
262 262
 			$args['tax_query'] = array(
263 263
 				array(
264 264
 					'taxonomy' => 'form_category',
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 			);
268 268
 		}
269 269
 
270
-		switch ( $orderby ) :
270
+		switch ($orderby) :
271 271
 			case 'title' :
272 272
 				$args['orderby'] = 'title';
273 273
 				break;
@@ -283,9 +283,9 @@  discard block
 block discarded – undo
283 283
 				break;
284 284
 		endswitch;
285 285
 
286
-		$args = apply_filters( 'give_form_reports_prepare_items_args', $args, $this );
286
+		$args = apply_filters('give_form_reports_prepare_items_args', $args, $this);
287 287
 
288
-		$this->donation_forms = new WP_Query( $args );
288
+		$this->donation_forms = new WP_Query($args);
289 289
 
290 290
 		// Store total number of donation forms count.
291 291
 		$this->count = $this->donation_forms->found_posts;
@@ -305,15 +305,15 @@  discard block
 block discarded – undo
305 305
 
306 306
 		$give_forms = $this->donation_forms->posts;
307 307
 
308
-		if ( $give_forms ) {
309
-			foreach ( $give_forms as $form ) {
308
+		if ($give_forms) {
309
+			foreach ($give_forms as $form) {
310 310
 				$reports_data[] = array(
311 311
 					'ID'               => $form,
312
-					'title'            => get_the_title( $form ),
313
-					'sales'            => give_get_form_sales_stats( $form ),
314
-					'earnings'         => give_get_form_earnings_stats( $form ),
315
-					'average_sales'    => give_get_average_monthly_form_sales( $form ),
316
-					'average_earnings' => give_get_average_monthly_form_earnings( $form )
312
+					'title'            => get_the_title($form),
313
+					'sales'            => give_get_form_sales_stats($form),
314
+					'earnings'         => give_get_form_earnings_stats($form),
315
+					'average_sales'    => give_get_average_monthly_form_sales($form),
316
+					'average_earnings' => give_get_average_monthly_form_earnings($form)
317 317
 				);
318 318
 			}
319 319
 		}
@@ -338,14 +338,14 @@  discard block
 block discarded – undo
338 338
 		$columns = $this->get_columns();
339 339
 		$hidden = array(); // No hidden columns
340 340
 		$sortable = $this->get_sortable_columns();
341
-		$this->_column_headers = array( $columns, $hidden, $sortable );
341
+		$this->_column_headers = array($columns, $hidden, $sortable);
342 342
 		$this->items = $this->reports_data();
343 343
 		$total_items = $this->count;
344 344
 
345
-		$this->set_pagination_args( array(
345
+		$this->set_pagination_args(array(
346 346
 				'total_items' => $total_items,
347 347
 				'per_page'    => $this->per_page,
348
-				'total_pages' => ceil( $total_items / $this->per_page )
348
+				'total_pages' => ceil($total_items / $this->per_page)
349 349
 			)
350 350
 		);
351 351
 	}
Please login to merge, or discard this patch.
includes/admin/reports/class-gateways-reports-table.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -10,13 +10,13 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
17 17
 // Load WP_List_Table if not loaded
18
-if ( ! class_exists( 'WP_List_Table' ) ) {
19
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
18
+if ( ! class_exists('WP_List_Table')) {
19
+	require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
20 20
 }
21 21
 
22 22
 /**
@@ -45,11 +45,11 @@  discard block
 block discarded – undo
45 45
 		global $status, $page;
46 46
 
47 47
 		// Set parent defaults
48
-		parent::__construct( array(
49
-			'singular' => give_get_forms_label_singular(),    // Singular name of the listed records
50
-			'plural'   => give_get_forms_label_plural(),        // Plural name of the listed records
48
+		parent::__construct(array(
49
+			'singular' => give_get_forms_label_singular(), // Singular name of the listed records
50
+			'plural'   => give_get_forms_label_plural(), // Plural name of the listed records
51 51
 			'ajax'     => false                        // Does this table support ajax?
52
-		) );
52
+		));
53 53
 
54 54
 	}
55 55
 
@@ -64,15 +64,15 @@  discard block
 block discarded – undo
64 64
 	 *
65 65
 	 * @return string Column Name
66 66
 	 */
67
-	public function column_default( $item, $column_name ) {
68
-		switch ( $column_name ) {
67
+	public function column_default($item, $column_name) {
68
+		switch ($column_name) {
69 69
 			case 'complete_sales':
70
-				$value = $item[ $column_name ];
70
+				$value = $item[$column_name];
71 71
 
72 72
 				break;
73 73
 
74 74
 			default:
75
-				$value = $item[ $column_name ];
75
+				$value = $item[$column_name];
76 76
 		}
77 77
 
78 78
 		return $value;
@@ -87,11 +87,11 @@  discard block
 block discarded – undo
87 87
 	 */
88 88
 	public function get_columns() {
89 89
 		$columns = array(
90
-			'label'           => esc_attr__( 'Gateway', 'give' ),
91
-			'complete_sales'  => esc_attr__( 'Complete Payments', 'give' ),
92
-			'pending_sales'   => esc_attr__( 'Pending / Failed Payments', 'give' ),
93
-			'total_sales'     => esc_attr__( 'Total Payments', 'give' ),
94
-			'total_donations' => esc_attr__( 'Total Donated', 'give' )
90
+			'label'           => esc_attr__('Gateway', 'give'),
91
+			'complete_sales'  => esc_attr__('Complete Payments', 'give'),
92
+			'pending_sales'   => esc_attr__('Pending / Failed Payments', 'give'),
93
+			'total_sales'     => esc_attr__('Total Payments', 'give'),
94
+			'total_donations' => esc_attr__('Total Donated', 'give')
95 95
 		);
96 96
 
97 97
 		return $columns;
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	 */
107 107
 	public function get_sortable_columns() {
108 108
 		return array(
109
-			'total_donations' => array( 'total_donations', false )
109
+			'total_donations' => array('total_donations', false)
110 110
 		);
111 111
 	}
112 112
 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	 * @return int Current page number
120 120
 	 */
121 121
 	public function get_paged() {
122
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
122
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
123 123
 	}
124 124
 
125 125
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	 * @since  1.0
131 131
 	 * @return void
132 132
 	 */
133
-	public function bulk_actions( $which = '' ) {
133
+	public function bulk_actions($which = '') {
134 134
 
135 135
 	}
136 136
 
@@ -142,27 +142,27 @@  discard block
 block discarded – undo
142 142
 	 *
143 143
 	 * @param string $which
144 144
 	 */
145
-	protected function display_tablenav( $which ) {
145
+	protected function display_tablenav($which) {
146 146
 
147
-		if ( 'top' === $which ) {
148
-			wp_nonce_field( 'bulk-' . $this->_args['plural'] );
147
+		if ('top' === $which) {
148
+			wp_nonce_field('bulk-'.$this->_args['plural']);
149 149
 		}
150 150
 		?>
151
-		<div class="tablenav gateways-report-tablenav give-clearfix <?php echo esc_attr( $which ); ?>">
151
+		<div class="tablenav gateways-report-tablenav give-clearfix <?php echo esc_attr($which); ?>">
152 152
 
153
-			<?php if ( 'top' === $which ) { ?>
153
+			<?php if ('top' === $which) { ?>
154 154
 				<h2 class="alignleft reports-earnings-title screen-reader-text">
155
-					<?php _e( 'Donation Methods Report', 'give' ); ?>
155
+					<?php _e('Donation Methods Report', 'give'); ?>
156 156
 				</h2>
157 157
 			<?php } ?>
158 158
 
159 159
 			<div class="alignright tablenav-right">
160 160
 				<div class="actions bulkactions">
161
-					<?php $this->bulk_actions( $which ); ?>
161
+					<?php $this->bulk_actions($which); ?>
162 162
 				</div>
163 163
 				<?php
164
-				$this->extra_tablenav( $which );
165
-				$this->pagination( $which );
164
+				$this->extra_tablenav($which);
165
+				$this->pagination($which);
166 166
 				?>
167 167
 			</div>
168 168
 
@@ -184,17 +184,17 @@  discard block
 block discarded – undo
184 184
 	 *
185 185
 	 * @return int
186 186
 	 */
187
-	public function give_sort_total_donations( $old_value, $new_value ) {
187
+	public function give_sort_total_donations($old_value, $new_value) {
188 188
 		// If no sort, default to label.
189
-		$orderby = ( ! empty( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : 'label';
189
+		$orderby = ( ! empty($_REQUEST['orderby'])) ? $_REQUEST['orderby'] : 'label';
190 190
 
191 191
 		//If no order, default to asc.
192
-		$order = ( ! empty( $_REQUEST['order'] ) ) ? $_REQUEST['order'] : 'asc';
192
+		$order = ( ! empty($_REQUEST['order'])) ? $_REQUEST['order'] : 'asc';
193 193
 
194 194
 		//Determine sort order.
195
-		$result = strcmp( $old_value[ $orderby ], $new_value[ $orderby ] );
195
+		$result = strcmp($old_value[$orderby], $new_value[$orderby]);
196 196
 
197
-		return ( $order === 'asc' ) ? $result : -$result;
197
+		return ($order === 'asc') ? $result : -$result;
198 198
 	}
199 199
 
200 200
 
@@ -211,10 +211,10 @@  discard block
 block discarded – undo
211 211
 		$gateways     = give_get_payment_gateways();
212 212
 		$stats        = new Give_Payment_Stats();
213 213
 
214
-		foreach ( $gateways as $gateway_id => $gateway ) {
214
+		foreach ($gateways as $gateway_id => $gateway) {
215 215
 
216
-			$complete_count = give_count_sales_by_gateway( $gateway_id, 'publish' );
217
-			$pending_count  = give_count_sales_by_gateway( $gateway_id, array( 'pending', 'failed' ) );
216
+			$complete_count = give_count_sales_by_gateway($gateway_id, 'publish');
217
+			$pending_count  = give_count_sales_by_gateway($gateway_id, array('pending', 'failed'));
218 218
 
219 219
 			$reports_data[] = array(
220 220
 				'ID'              => $gateway_id,
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 				'complete_sales'  => $complete_count,
223 223
 				'pending_sales'   => $pending_count,
224 224
 				'total_sales'     => $complete_count + $pending_count,
225
-				'total_donations' => give_currency_filter( give_format_amount( $stats->get_earnings( 0, strtotime('04/13/2015' ), current_time('timestamp' ), $gateway_id ), array( 'sanitize' => false ) ) ),
225
+				'total_donations' => give_currency_filter(give_format_amount($stats->get_earnings(0, strtotime('04/13/2015'), current_time('timestamp'), $gateway_id), array('sanitize' => false))),
226 226
 			);
227 227
 		}
228 228
 
@@ -243,11 +243,11 @@  discard block
 block discarded – undo
243 243
 		$columns               = $this->get_columns();
244 244
 		$hidden                = array(); // No hidden columns
245 245
 		$sortable              = $this->get_sortable_columns();
246
-		$this->_column_headers = array( $columns, $hidden, $sortable );
246
+		$this->_column_headers = array($columns, $hidden, $sortable);
247 247
 		$this->items           = $this->reports_data();
248 248
 
249 249
 		// Sort Array when we are sorting data in array.
250
-		usort( $this->items, array( $this, 'give_sort_total_donations' ) );
250
+		usort($this->items, array($this, 'give_sort_total_donations'));
251 251
 
252 252
 	}
253 253
 }
Please login to merge, or discard this patch.
includes/admin/dashboard-widgets.php 1 patch
Spacing   +32 added lines, -32 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
 
@@ -21,12 +21,12 @@  discard block
 block discarded – undo
21 21
  * @return void
22 22
  */
23 23
 function give_register_dashboard_widgets() {
24
-	if ( current_user_can( apply_filters( 'give_dashboard_stats_cap', 'view_give_reports' ) ) ) {
25
-		wp_add_dashboard_widget( 'give_dashboard_sales', __( 'Give: Donation Statistics', 'give' ), 'give_dashboard_sales_widget' );
24
+	if (current_user_can(apply_filters('give_dashboard_stats_cap', 'view_give_reports'))) {
25
+		wp_add_dashboard_widget('give_dashboard_sales', __('Give: Donation Statistics', 'give'), 'give_dashboard_sales_widget');
26 26
 	}
27 27
 }
28 28
 
29
-add_action( 'wp_dashboard_setup', 'give_register_dashboard_widgets', 10 );
29
+add_action('wp_dashboard_setup', 'give_register_dashboard_widgets', 10);
30 30
 
31 31
 /**
32 32
  * Sales Summary Dashboard Widget
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
  */
39 39
 function give_dashboard_sales_widget() {
40 40
 
41
-	if ( ! current_user_can( apply_filters( 'give_dashboard_stats_cap', 'view_give_reports' ) ) ) {
41
+	if ( ! current_user_can(apply_filters('give_dashboard_stats_cap', 'view_give_reports'))) {
42 42
 		return;
43 43
 	}
44 44
 	$stats = new Give_Payment_Stats(); ?>
@@ -46,27 +46,27 @@  discard block
 block discarded – undo
46 46
 	<div class="give-dashboard-widget">
47 47
 
48 48
 		<div class="give-dashboard-today give-clearfix">
49
-			<h3 class="give-dashboard-date-today"><?php echo date( _x( 'F j, Y', 'dashboard widget', 'give' ) ); ?></h3>
49
+			<h3 class="give-dashboard-date-today"><?php echo date(_x('F j, Y', 'dashboard widget', 'give')); ?></h3>
50 50
 
51 51
 			<p class="give-dashboard-happy-day"><?php
52 52
 				printf(
53 53
 				/* translators: %s: day of the week */
54
-					__( 'Happy %s!', 'give' ),
55
-					date( 'l', current_time( 'timestamp' ) )
54
+					__('Happy %s!', 'give'),
55
+					date('l', current_time('timestamp'))
56 56
 				);
57 57
 			?></p>
58 58
 
59 59
 			<p class="give-dashboard-today-earnings"><?php
60
-				$earnings_today = $stats->get_earnings( 0, 'today', false );
61
-				echo give_currency_filter( give_format_amount( $earnings_today, array( 'sanitize' => false ) ) );
60
+				$earnings_today = $stats->get_earnings(0, 'today', false);
61
+				echo give_currency_filter(give_format_amount($earnings_today, array('sanitize' => false)));
62 62
 			?></p>
63 63
 
64 64
 			<p class="give-donations-today"><?php
65
-				$donations_today = $stats->get_sales( 0, 'today', false );
65
+				$donations_today = $stats->get_sales(0, 'today', false);
66 66
 				printf(
67 67
 					/* translators: %s: daily donation count */
68
-					__( '%s donations today', 'give' ),
69
-					give_format_amount( $donations_today, array( 'decimal' => false, 'sanitize' => false ) )
68
+					__('%s donations today', 'give'),
69
+					give_format_amount($donations_today, array('decimal' => false, 'sanitize' => false))
70 70
 				);
71 71
 			?></p>
72 72
 
@@ -76,34 +76,34 @@  discard block
 block discarded – undo
76 76
 		<table class="give-table-stats">
77 77
 			<thead style="display: none;">
78 78
 			<tr>
79
-				<th><?php _e( 'This Week', 'give' ); ?></th>
80
-				<th><?php _e( 'This Month', 'give' ); ?></th>
81
-				<th><?php _e( 'Past 30 Days', 'give' ); ?></th>
79
+				<th><?php _e('This Week', 'give'); ?></th>
80
+				<th><?php _e('This Month', 'give'); ?></th>
81
+				<th><?php _e('Past 30 Days', 'give'); ?></th>
82 82
 			</tr>
83 83
 			</thead>
84 84
 			<tbody>
85 85
 			<tr id="give-table-stats-tr-1">
86 86
 				<td>
87
-					<p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_week' ), array( 'sanitize' => false ) ) ); ?></p>
87
+					<p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_week'), array('sanitize' => false))); ?></p>
88 88
 
89
-					<p class="give-dashboard-stat-total-label"><?php _e( 'This Week', 'give' ); ?></p>
89
+					<p class="give-dashboard-stat-total-label"><?php _e('This Week', 'give'); ?></p>
90 90
 				</td>
91 91
 				<td>
92
-					<p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'this_month' ), array( 'sanitize' => false ) ) ); ?></p>
92
+					<p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'this_month'), array('sanitize' => false))); ?></p>
93 93
 
94
-					<p class="give-dashboard-stat-total-label"><?php _e( 'This Month', 'give' ); ?></p>
94
+					<p class="give-dashboard-stat-total-label"><?php _e('This Month', 'give'); ?></p>
95 95
 				</td>
96 96
 			</tr>
97 97
 			<tr id="give-table-stats-tr-2">
98 98
 				<td>
99
-					<p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( $stats->get_earnings( 0, 'last_month' ), array( 'sanitize' => false ) ) ) ?></p>
99
+					<p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount($stats->get_earnings(0, 'last_month'), array('sanitize' => false))) ?></p>
100 100
 
101
-					<p class="give-dashboard-stat-total-label"><?php _e( 'Last Month', 'give' ); ?></p>
101
+					<p class="give-dashboard-stat-total-label"><?php _e('Last Month', 'give'); ?></p>
102 102
 				</td>
103 103
 				<td>
104
-					<p class="give-dashboard-stat-total"><?php echo give_currency_filter( give_format_amount( give_get_total_earnings(), array( 'sanitize' => false ) ) ) ?></p>
104
+					<p class="give-dashboard-stat-total"><?php echo give_currency_filter(give_format_amount(give_get_total_earnings(), array('sanitize' => false))) ?></p>
105 105
 
106
-					<p class="give-dashboard-stat-total-label"><?php _e( 'This Year', 'give' ); ?></p>
106
+					<p class="give-dashboard-stat-total-label"><?php _e('This Year', 'give'); ?></p>
107 107
 				</td>
108 108
 			</tr>
109 109
 			</tbody>
@@ -123,24 +123,24 @@  discard block
 block discarded – undo
123 123
  *
124 124
  * @return array
125 125
  */
126
-function give_dashboard_at_a_glance_widget( $items ) {
126
+function give_dashboard_at_a_glance_widget($items) {
127 127
 
128
-	$num_posts = wp_count_posts( 'give_forms' );
128
+	$num_posts = wp_count_posts('give_forms');
129 129
 
130
-	if ( $num_posts && $num_posts->publish ) {
130
+	if ($num_posts && $num_posts->publish) {
131 131
 
132 132
 		$text = sprintf(
133 133
 			/* translators: %s: number of posts published */
134
-			_n( '%s Give Form', '%s Give Forms', $num_posts->publish, 'give' ),
134
+			_n('%s Give Form', '%s Give Forms', $num_posts->publish, 'give'),
135 135
 			$num_posts->publish
136 136
 		);
137 137
 
138
-		$text = sprintf( $text, number_format_i18n( $num_posts->publish ) );
138
+		$text = sprintf($text, number_format_i18n($num_posts->publish));
139 139
 
140
-		if ( current_user_can( 'edit_give_forms', get_current_user_id() ) ) {
140
+		if (current_user_can('edit_give_forms', get_current_user_id())) {
141 141
 			$text = sprintf(
142 142
 				'<a class="give-forms-count" href="%1$s">%2$s</a>',
143
-				admin_url( 'edit.php?post_type=give_forms' ),
143
+				admin_url('edit.php?post_type=give_forms'),
144 144
 				$text
145 145
 			);
146 146
 		} else {
@@ -156,4 +156,4 @@  discard block
 block discarded – undo
156 156
 	return $items;
157 157
 }
158 158
 
159
-add_filter( 'dashboard_glance_items', 'give_dashboard_at_a_glance_widget', 1, 1 );
159
+add_filter('dashboard_glance_items', 'give_dashboard_at_a_glance_widget', 1, 1);
Please login to merge, or discard this patch.