Completed
Pull Request — master (#1637)
by Ravinder
16:50
created
includes/admin/upgrades/upgrade-functions.php 1 patch
Spacing   +181 added lines, -181 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly.
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -25,39 +25,39 @@  discard block
 block discarded – undo
25 25
  */
26 26
 function give_do_automatic_upgrades() {
27 27
 	$did_upgrade  = false;
28
-	$give_version = preg_replace( '/[^0-9.].*/', '', get_option( 'give_version' ) );
28
+	$give_version = preg_replace('/[^0-9.].*/', '', get_option('give_version'));
29 29
 
30
-	if ( ! $give_version ) {
30
+	if ( ! $give_version) {
31 31
 		// 1.0 is the first version to use this option so we must add it.
32 32
 		$give_version = '1.0';
33 33
 	}
34 34
 
35
-	switch ( true ) {
35
+	switch (true) {
36 36
 
37
-		case version_compare( $give_version, '1.6', '<' ) :
37
+		case version_compare($give_version, '1.6', '<') :
38 38
 			give_v16_upgrades();
39 39
 			$did_upgrade = true;
40 40
 
41
-		case version_compare( $give_version, '1.7', '<' ) :
41
+		case version_compare($give_version, '1.7', '<') :
42 42
 			give_v17_upgrades();
43 43
 			$did_upgrade = true;
44 44
 
45
-		case version_compare( $give_version, '1.8', '<' ) :
45
+		case version_compare($give_version, '1.8', '<') :
46 46
 			give_v18_upgrades();
47 47
 			$did_upgrade = true;
48 48
 
49
-		case version_compare( $give_version, '1.8.7', '<' ) :
49
+		case version_compare($give_version, '1.8.7', '<') :
50 50
 			give_v187_upgrades();
51 51
 			$did_upgrade = true;
52 52
 	}
53 53
 
54
-	if ( $did_upgrade ) {
55
-		update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) );
54
+	if ($did_upgrade) {
55
+		update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION));
56 56
 	}
57 57
 }
58 58
 
59
-add_action( 'admin_init', 'give_do_automatic_upgrades' );
60
-add_action( 'give_upgrades', 'give_do_automatic_upgrades' );
59
+add_action('admin_init', 'give_do_automatic_upgrades');
60
+add_action('give_upgrades', 'give_do_automatic_upgrades');
61 61
 
62 62
 /**
63 63
  * Display Upgrade Notices
@@ -67,18 +67,18 @@  discard block
 block discarded – undo
67 67
  */
68 68
 function give_show_upgrade_notices() {
69 69
 	// Don't show notices on the upgrades page.
70
-	if ( isset( $_GET['page'] ) && $_GET['page'] == 'give-upgrades' ) {
70
+	if (isset($_GET['page']) && $_GET['page'] == 'give-upgrades') {
71 71
 		return;
72 72
 	}
73 73
 
74
-	$give_version = get_option( 'give_version' );
74
+	$give_version = get_option('give_version');
75 75
 
76
-	if ( ! $give_version ) {
76
+	if ( ! $give_version) {
77 77
 		// 1.0 is the first version to use this option so we must add it.
78 78
 		$give_version = '1.0';
79 79
 	}
80 80
 
81
-	$give_version = preg_replace( '/[^0-9.].*/', '', $give_version );
81
+	$give_version = preg_replace('/[^0-9.].*/', '', $give_version);
82 82
 
83 83
 	/*
84 84
 	 *  NOTICE:
@@ -89,31 +89,31 @@  discard block
 block discarded – undo
89 89
 	 */
90 90
 
91 91
 	// v1.3.2 Upgrades
92
-	if ( version_compare( $give_version, '1.3.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_payment_customer_id' ) ) {
92
+	if (version_compare($give_version, '1.3.2', '<') || ! give_has_upgrade_completed('upgrade_give_payment_customer_id')) {
93 93
 		printf(
94 94
 			/* translators: %s: upgrade URL */
95
-			'<div class="updated"><p>' . __( 'Give needs to upgrade the donor database, click <a href="%s">here</a> to start the upgrade.', 'give' ) . '</p></div>',
96
-			esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=upgrade_give_payment_customer_id' ) )
95
+			'<div class="updated"><p>'.__('Give needs to upgrade the donor database, click <a href="%s">here</a> to start the upgrade.', 'give').'</p></div>',
96
+			esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=upgrade_give_payment_customer_id'))
97 97
 		);
98 98
 	}
99 99
 
100 100
 	// v1.3.4 Upgrades //ensure the user has gone through 1.3.4.
101
-	if ( version_compare( $give_version, '1.3.4', '<' ) || ( ! give_has_upgrade_completed( 'upgrade_give_offline_status' ) && give_has_upgrade_completed( 'upgrade_give_payment_customer_id' ) ) ) {
101
+	if (version_compare($give_version, '1.3.4', '<') || ( ! give_has_upgrade_completed('upgrade_give_offline_status') && give_has_upgrade_completed('upgrade_give_payment_customer_id'))) {
102 102
 		printf(
103 103
 			/* translators: %s: upgrade URL */
104
-			'<div class="updated"><p>' . __( 'Give needs to upgrade the donations database, click <a href="%s">here</a> to start the upgrade.', 'give' ) . '</p></div>',
105
-			esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=upgrade_give_offline_status' ) )
104
+			'<div class="updated"><p>'.__('Give needs to upgrade the donations database, click <a href="%s">here</a> to start the upgrade.', 'give').'</p></div>',
105
+			esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=upgrade_give_offline_status'))
106 106
 		);
107 107
 	}
108 108
 
109 109
 	// Check if we have a stalled upgrade.
110 110
 	$resume_upgrade = give_maybe_resume_upgrade();
111
-	if ( ! empty( $resume_upgrade ) ) {
112
-		$resume_url = add_query_arg( $resume_upgrade, admin_url( 'index.php' ) );
111
+	if ( ! empty($resume_upgrade)) {
112
+		$resume_url = add_query_arg($resume_upgrade, admin_url('index.php'));
113 113
 		echo Give_Notices::notice_html(
114 114
 			sprintf(
115
-				__( 'Give needs to complete a database upgrade that was previously started, click <a href="%s">here</a> to resume the upgrade.', 'give' ),
116
-				esc_url( $resume_url )
115
+				__('Give needs to complete a database upgrade that was previously started, click <a href="%s">here</a> to resume the upgrade.', 'give'),
116
+				esc_url($resume_url)
117 117
 			)
118 118
 		);
119 119
 
@@ -121,11 +121,11 @@  discard block
 block discarded – undo
121 121
 	}
122 122
 
123 123
 	// v1.8 form metadata upgrades.
124
-	if ( version_compare( $give_version, '1.8', '<' ) || ! give_has_upgrade_completed( 'v18_upgrades_form_metadata' ) ) {
124
+	if (version_compare($give_version, '1.8', '<') || ! give_has_upgrade_completed('v18_upgrades_form_metadata')) {
125 125
 		echo Give_Notices::notice_html(
126 126
 			sprintf(
127
-				esc_html__( 'Give needs to upgrade the form database, click %1$shere%2$s to start the upgrade.', 'give' ),
128
-				'<a class="give-upgrade-link" href="' . esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=give_v18_upgrades_form_metadata' ) ) . '">',
127
+				esc_html__('Give needs to upgrade the form database, click %1$shere%2$s to start the upgrade.', 'give'),
128
+				'<a class="give-upgrade-link" href="'.esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=give_v18_upgrades_form_metadata')).'">',
129 129
 				'</a>'
130 130
 			)
131 131
 		);
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 				$upgrade_links.on( 'click', function(e){
141 141
 					e.preventDefault();
142 142
 
143
-					if( ! window.confirm( '<?php _e( 'Please make sure to create a database backup before initiating the upgrade.', 'give' ); ?>' ) ) {
143
+					if( ! window.confirm( '<?php _e('Please make sure to create a database backup before initiating the upgrade.', 'give'); ?>' ) ) {
144 144
 						return;
145 145
 					}
146 146
 
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	<?php
154 154
 }
155 155
 
156
-add_action( 'admin_notices', 'give_show_upgrade_notices' );
156
+add_action('admin_notices', 'give_show_upgrade_notices');
157 157
 
158 158
 /**
159 159
  * Triggers all upgrade functions
@@ -165,29 +165,29 @@  discard block
 block discarded – undo
165 165
  */
166 166
 function give_trigger_upgrades() {
167 167
 
168
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
169
-		wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array(
168
+	if ( ! current_user_can('manage_give_settings')) {
169
+		wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array(
170 170
 			'response' => 403,
171
-		) );
171
+		));
172 172
 	}
173 173
 
174
-	$give_version = get_option( 'give_version' );
174
+	$give_version = get_option('give_version');
175 175
 
176
-	if ( ! $give_version ) {
176
+	if ( ! $give_version) {
177 177
 		// 1.0 is the first version to use this option so we must add it.
178 178
 		$give_version = '1.0';
179
-		add_option( 'give_version', $give_version );
179
+		add_option('give_version', $give_version);
180 180
 	}
181 181
 
182
-	update_option( 'give_version', GIVE_VERSION );
183
-	delete_option( 'give_doing_upgrade' );
182
+	update_option('give_version', GIVE_VERSION);
183
+	delete_option('give_doing_upgrade');
184 184
 
185
-	if ( DOING_AJAX ) {
186
-		die( 'complete' );
185
+	if (DOING_AJAX) {
186
+		die('complete');
187 187
 	} // End if().
188 188
 }
189 189
 
190
-add_action( 'wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades' );
190
+add_action('wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades');
191 191
 
192 192
 /**
193 193
  * Check if the upgrade routine has been run for a specific action
@@ -198,15 +198,15 @@  discard block
 block discarded – undo
198 198
  *
199 199
  * @return bool                   If the action has been added to the completed actions array
200 200
  */
201
-function give_has_upgrade_completed( $upgrade_action = '' ) {
201
+function give_has_upgrade_completed($upgrade_action = '') {
202 202
 
203
-	if ( empty( $upgrade_action ) ) {
203
+	if (empty($upgrade_action)) {
204 204
 		return false;
205 205
 	}
206 206
 
207 207
 	$completed_upgrades = give_get_completed_upgrades();
208 208
 
209
-	return in_array( $upgrade_action, $completed_upgrades );
209
+	return in_array($upgrade_action, $completed_upgrades);
210 210
 
211 211
 }
212 212
 
@@ -218,8 +218,8 @@  discard block
 block discarded – undo
218 218
  * @return mixed   When nothing to resume returns false, otherwise starts the upgrade where it left off
219 219
  */
220 220
 function give_maybe_resume_upgrade() {
221
-	$doing_upgrade = get_option( 'give_doing_upgrade', false );
222
-	if ( empty( $doing_upgrade ) ) {
221
+	$doing_upgrade = get_option('give_doing_upgrade', false);
222
+	if (empty($doing_upgrade)) {
223 223
 		return false;
224 224
 	}
225 225
 
@@ -235,9 +235,9 @@  discard block
 block discarded – undo
235 235
  *
236 236
  * @return bool                   If the function was successfully added
237 237
  */
238
-function give_set_upgrade_complete( $upgrade_action = '' ) {
238
+function give_set_upgrade_complete($upgrade_action = '') {
239 239
 
240
-	if ( empty( $upgrade_action ) ) {
240
+	if (empty($upgrade_action)) {
241 241
 		return false;
242 242
 	}
243 243
 
@@ -245,9 +245,9 @@  discard block
 block discarded – undo
245 245
 	$completed_upgrades[] = $upgrade_action;
246 246
 
247 247
 	// Remove any blanks, and only show uniques.
248
-	$completed_upgrades = array_unique( array_values( $completed_upgrades ) );
248
+	$completed_upgrades = array_unique(array_values($completed_upgrades));
249 249
 
250
-	return update_option( 'give_completed_upgrades', $completed_upgrades );
250
+	return update_option('give_completed_upgrades', $completed_upgrades);
251 251
 }
252 252
 
253 253
 /**
@@ -258,9 +258,9 @@  discard block
 block discarded – undo
258 258
  */
259 259
 function give_get_completed_upgrades() {
260 260
 
261
-	$completed_upgrades = get_option( 'give_completed_upgrades' );
261
+	$completed_upgrades = get_option('give_completed_upgrades');
262 262
 
263
-	if ( false === $completed_upgrades ) {
263
+	if (false === $completed_upgrades) {
264 264
 		$completed_upgrades = array();
265 265
 	}
266 266
 
@@ -277,31 +277,31 @@  discard block
 block discarded – undo
277 277
  */
278 278
 function give_v132_upgrade_give_payment_customer_id() {
279 279
 	global $wpdb;
280
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
281
-		wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array(
280
+	if ( ! current_user_can('manage_give_settings')) {
281
+		wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array(
282 282
 			'response' => 403,
283
-		) );
283
+		));
284 284
 	}
285 285
 
286
-	ignore_user_abort( true );
286
+	ignore_user_abort(true);
287 287
 
288
-	if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
289
-		@set_time_limit( 0 );
288
+	if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
289
+		@set_time_limit(0);
290 290
 	}
291 291
 
292 292
 	// UPDATE DB METAKEYS.
293 293
 	$sql   = "UPDATE $wpdb->postmeta SET meta_key = '_give_payment_customer_id' WHERE meta_key = '_give_payment_donor_id'";
294
-	$query = $wpdb->query( $sql );
294
+	$query = $wpdb->query($sql);
295 295
 
296
-	update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) );
297
-	give_set_upgrade_complete( 'upgrade_give_payment_customer_id' );
298
-	delete_option( 'give_doing_upgrade' );
299
-	wp_redirect( admin_url() );
296
+	update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION));
297
+	give_set_upgrade_complete('upgrade_give_payment_customer_id');
298
+	delete_option('give_doing_upgrade');
299
+	wp_redirect(admin_url());
300 300
 	exit;
301 301
 
302 302
 }
303 303
 
304
-add_action( 'give_upgrade_give_payment_customer_id', 'give_v132_upgrade_give_payment_customer_id' );
304
+add_action('give_upgrade_give_payment_customer_id', 'give_v132_upgrade_give_payment_customer_id');
305 305
 
306 306
 /**
307 307
  * Upgrades the Offline Status
@@ -314,16 +314,16 @@  discard block
 block discarded – undo
314 314
 
315 315
 	global $wpdb;
316 316
 
317
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
318
-		wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array(
317
+	if ( ! current_user_can('manage_give_settings')) {
318
+		wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array(
319 319
 			'response' => 403,
320
-		) );
320
+		));
321 321
 	}
322 322
 
323
-	ignore_user_abort( true );
323
+	ignore_user_abort(true);
324 324
 
325
-	if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
326
-		@set_time_limit( 0 );
325
+	if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
326
+		@set_time_limit(0);
327 327
 	}
328 328
 
329 329
 	// Get abandoned offline payments.
@@ -333,31 +333,31 @@  discard block
 block discarded – undo
333 333
 	$where .= "AND ( p.post_status = 'abandoned' )";
334 334
 	$where .= "AND ( m.meta_key = '_give_payment_gateway' AND m.meta_value = 'offline' )";
335 335
 
336
-	$sql            = $select . $join . $where;
337
-	$found_payments = $wpdb->get_col( $sql );
336
+	$sql            = $select.$join.$where;
337
+	$found_payments = $wpdb->get_col($sql);
338 338
 
339
-	foreach ( $found_payments as $payment ) {
339
+	foreach ($found_payments as $payment) {
340 340
 
341 341
 		// Only change ones marked abandoned since our release last week because the admin may have marked some abandoned themselves.
342
-		$modified_time = get_post_modified_time( 'U', false, $payment );
342
+		$modified_time = get_post_modified_time('U', false, $payment);
343 343
 
344 344
 		// 1450124863 =  12/10/2015 20:42:25.
345
-		if ( $modified_time >= 1450124863 ) {
345
+		if ($modified_time >= 1450124863) {
346 346
 
347
-			give_update_payment_status( $payment, 'pending' );
347
+			give_update_payment_status($payment, 'pending');
348 348
 
349 349
 		}
350 350
 	}
351 351
 
352
-	update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) );
353
-	give_set_upgrade_complete( 'upgrade_give_offline_status' );
354
-	delete_option( 'give_doing_upgrade' );
355
-	wp_redirect( admin_url() );
352
+	update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION));
353
+	give_set_upgrade_complete('upgrade_give_offline_status');
354
+	delete_option('give_doing_upgrade');
355
+	wp_redirect(admin_url());
356 356
 	exit;
357 357
 
358 358
 }
359 359
 
360
-add_action( 'give_upgrade_give_offline_status', 'give_v134_upgrade_give_offline_status' );
360
+add_action('give_upgrade_give_offline_status', 'give_v134_upgrade_give_offline_status');
361 361
 
362 362
 /**
363 363
  * Cleanup User Roles
@@ -368,17 +368,17 @@  discard block
 block discarded – undo
368 368
  */
369 369
 function give_v152_cleanup_users() {
370 370
 
371
-	$give_version = get_option( 'give_version' );
371
+	$give_version = get_option('give_version');
372 372
 
373
-	if ( ! $give_version ) {
373
+	if ( ! $give_version) {
374 374
 		// 1.0 is the first version to use this option so we must add it.
375 375
 		$give_version = '1.0';
376 376
 	}
377 377
 
378
-	$give_version = preg_replace( '/[^0-9.].*/', '', $give_version );
378
+	$give_version = preg_replace('/[^0-9.].*/', '', $give_version);
379 379
 
380 380
 	// v1.5.2 Upgrades
381
-	if ( version_compare( $give_version, '1.5.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_user_caps_cleanup' ) ) {
381
+	if (version_compare($give_version, '1.5.2', '<') || ! give_has_upgrade_completed('upgrade_give_user_caps_cleanup')) {
382 382
 
383 383
 		// Delete all caps with "ss".
384 384
 		// Also delete all unused "campaign" roles.
@@ -425,9 +425,9 @@  discard block
 block discarded – undo
425 425
 		);
426 426
 
427 427
 		global $wp_roles;
428
-		foreach ( $delete_caps as $cap ) {
429
-			foreach ( array_keys( $wp_roles->roles ) as $role ) {
430
-				$wp_roles->remove_cap( $role, $cap );
428
+		foreach ($delete_caps as $cap) {
429
+			foreach (array_keys($wp_roles->roles) as $role) {
430
+				$wp_roles->remove_cap($role, $cap);
431 431
 			}
432 432
 		}
433 433
 
@@ -437,15 +437,15 @@  discard block
 block discarded – undo
437 437
 		$roles->add_caps();
438 438
 
439 439
 		// The Update Ran.
440
-		update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) );
441
-		give_set_upgrade_complete( 'upgrade_give_user_caps_cleanup' );
442
-		delete_option( 'give_doing_upgrade' );
440
+		update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION));
441
+		give_set_upgrade_complete('upgrade_give_user_caps_cleanup');
442
+		delete_option('give_doing_upgrade');
443 443
 
444 444
 	}// End if().
445 445
 
446 446
 }
447 447
 
448
-add_action( 'admin_init', 'give_v152_cleanup_users' );
448
+add_action('admin_init', 'give_v152_cleanup_users');
449 449
 
450 450
 /**
451 451
  * 1.6 Upgrade routine to create the customer meta table.
@@ -485,53 +485,53 @@  discard block
 block discarded – undo
485 485
 
486 486
 	// Get addons license key.
487 487
 	$addons = array();
488
-	foreach ( $give_options as $key => $value ) {
489
-		if ( false !== strpos( $key, '_license_key' ) ) {
490
-			$addons[ $key ] = $value;
488
+	foreach ($give_options as $key => $value) {
489
+		if (false !== strpos($key, '_license_key')) {
490
+			$addons[$key] = $value;
491 491
 		}
492 492
 	}
493 493
 
494 494
 	// Bailout: We do not have any addon license data to upgrade.
495
-	if ( empty( $addons ) ) {
495
+	if (empty($addons)) {
496 496
 		return false;
497 497
 	}
498 498
 
499
-	foreach ( $addons as $key => $addon_license ) {
499
+	foreach ($addons as $key => $addon_license) {
500 500
 
501 501
 		// Get addon shortname.
502
-		$shortname = str_replace( '_license_key', '', $key );
502
+		$shortname = str_replace('_license_key', '', $key);
503 503
 
504 504
 		// Addon license option name.
505
-		$addon_license_option_name = $shortname . '_license_active';
505
+		$addon_license_option_name = $shortname.'_license_active';
506 506
 
507 507
 		// bailout if license is empty.
508
-		if ( empty( $addon_license ) ) {
509
-			delete_option( $addon_license_option_name );
508
+		if (empty($addon_license)) {
509
+			delete_option($addon_license_option_name);
510 510
 			continue;
511 511
 		}
512 512
 
513 513
 		// Get addon name.
514 514
 		$addon_name       = array();
515
-		$addon_name_parts = explode( '_', str_replace( 'give_', '', $shortname ) );
516
-		foreach ( $addon_name_parts as $name_part ) {
515
+		$addon_name_parts = explode('_', str_replace('give_', '', $shortname));
516
+		foreach ($addon_name_parts as $name_part) {
517 517
 
518 518
 			// Fix addon name
519
-			switch ( $name_part ) {
519
+			switch ($name_part) {
520 520
 				case 'authorizenet' :
521 521
 					$name_part = 'authorize.net';
522 522
 					break;
523 523
 			}
524 524
 
525
-			$addon_name[] = ucfirst( $name_part );
525
+			$addon_name[] = ucfirst($name_part);
526 526
 		}
527 527
 
528
-		$addon_name = implode( ' ', $addon_name );
528
+		$addon_name = implode(' ', $addon_name);
529 529
 
530 530
 		// Data to send to the API
531 531
 		$api_params = array(
532 532
 			'edd_action' => 'activate_license', // never change from "edd_" to "give_"!
533 533
 			'license'    => $addon_license,
534
-			'item_name'  => urlencode( $addon_name ),
534
+			'item_name'  => urlencode($addon_name),
535 535
 			'url'        => home_url(),
536 536
 		);
537 537
 
@@ -546,17 +546,17 @@  discard block
 block discarded – undo
546 546
 		);
547 547
 
548 548
 		// Make sure there are no errors.
549
-		if ( is_wp_error( $response ) ) {
550
-			delete_option( $addon_license_option_name );
549
+		if (is_wp_error($response)) {
550
+			delete_option($addon_license_option_name);
551 551
 			continue;
552 552
 		}
553 553
 
554 554
 		// Tell WordPress to look for updates.
555
-		set_site_transient( 'update_plugins', null );
555
+		set_site_transient('update_plugins', null);
556 556
 
557 557
 		// Decode license data.
558
-		$license_data = json_decode( wp_remote_retrieve_body( $response ) );
559
-		update_option( $addon_license_option_name, $license_data );
558
+		$license_data = json_decode(wp_remote_retrieve_body($response));
559
+		update_option($addon_license_option_name, $license_data);
560 560
 	}// End foreach().
561 561
 }
562 562
 
@@ -586,9 +586,9 @@  discard block
 block discarded – undo
586 586
 	);
587 587
 
588 588
 	global $wp_roles;
589
-	foreach ( $delete_caps as $cap ) {
590
-		foreach ( array_keys( $wp_roles->roles ) as $role ) {
591
-			$wp_roles->remove_cap( $role, $cap );
589
+	foreach ($delete_caps as $cap) {
590
+		foreach (array_keys($wp_roles->roles) as $role) {
591
+			$wp_roles->remove_cap($role, $cap);
592 592
 		}
593 593
 	}
594 594
 
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
 function give_v18_upgrades_core_setting() {
623 623
 	// Core settings which changes from checkbox to radio.
624 624
 	$core_setting_names = array_merge(
625
-		array_keys( give_v18_renamed_core_settings() ),
625
+		array_keys(give_v18_renamed_core_settings()),
626 626
 		array(
627 627
 			'uninstall_on_delete',
628 628
 			'scripts_footer',
@@ -634,48 +634,48 @@  discard block
 block discarded – undo
634 634
 	);
635 635
 
636 636
 	// Bailout: If not any setting define.
637
-	if ( $give_settings = get_option( 'give_settings' ) ) {
637
+	if ($give_settings = get_option('give_settings')) {
638 638
 
639 639
 		$setting_changed = false;
640 640
 
641 641
 		// Loop: check each setting field.
642
-		foreach ( $core_setting_names as $setting_name ) {
642
+		foreach ($core_setting_names as $setting_name) {
643 643
 			// New setting name.
644
-			$new_setting_name = preg_replace( '/^(enable_|disable_)/', '', $setting_name );
644
+			$new_setting_name = preg_replace('/^(enable_|disable_)/', '', $setting_name);
645 645
 
646 646
 			// Continue: If setting already set.
647 647
 			if (
648
-				array_key_exists( $new_setting_name, $give_settings )
649
-				&& in_array( $give_settings[ $new_setting_name ], array( 'enabled', 'disabled' ) )
648
+				array_key_exists($new_setting_name, $give_settings)
649
+				&& in_array($give_settings[$new_setting_name], array('enabled', 'disabled'))
650 650
 			) {
651 651
 				continue;
652 652
 			}
653 653
 
654 654
 			// Set checkbox value to radio value.
655
-			$give_settings[ $setting_name ] = ( ! empty( $give_settings[ $setting_name ] ) && 'on' === $give_settings[ $setting_name ] ? 'enabled' : 'disabled' );
655
+			$give_settings[$setting_name] = ( ! empty($give_settings[$setting_name]) && 'on' === $give_settings[$setting_name] ? 'enabled' : 'disabled');
656 656
 
657 657
 			// @see https://github.com/WordImpress/Give/issues/1063
658
-			if ( false !== strpos( $setting_name, 'disable_' ) ) {
658
+			if (false !== strpos($setting_name, 'disable_')) {
659 659
 
660
-				$give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'disabled' : 'enabled' );
661
-			} elseif ( false !== strpos( $setting_name, 'enable_' ) ) {
660
+				$give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'disabled' : 'enabled');
661
+			} elseif (false !== strpos($setting_name, 'enable_')) {
662 662
 
663
-				$give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'enabled' : 'disabled' );
663
+				$give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'enabled' : 'disabled');
664 664
 			}
665 665
 
666 666
 			// Tell bot to update core setting to db.
667
-			if ( ! $setting_changed ) {
667
+			if ( ! $setting_changed) {
668 668
 				$setting_changed = true;
669 669
 			}
670 670
 		}
671 671
 
672 672
 		// Update setting only if they changed.
673
-		if ( $setting_changed ) {
674
-			update_option( 'give_settings', $give_settings );
673
+		if ($setting_changed) {
674
+			update_option('give_settings', $give_settings);
675 675
 		}
676 676
 	}// End if().
677 677
 
678
-	give_set_upgrade_complete( 'v18_upgrades_core_setting' );
678
+	give_set_upgrade_complete('v18_upgrades_core_setting');
679 679
 }
680 680
 
681 681
 /**
@@ -685,22 +685,22 @@  discard block
 block discarded – undo
685 685
  * @return void
686 686
  */
687 687
 function give_v18_upgrades_form_metadata() {
688
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
689
-		wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array(
688
+	if ( ! current_user_can('manage_give_settings')) {
689
+		wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array(
690 690
 			'response' => 403,
691
-		) );
691
+		));
692 692
 	}
693 693
 
694
-	ignore_user_abort( true );
694
+	ignore_user_abort(true);
695 695
 
696
-	if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
697
-		@set_time_limit( 0 );
696
+	if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
697
+		@set_time_limit(0);
698 698
 	}
699 699
 
700
-	$step = isset( $_GET['step'] ) ? absint( $_GET['step'] ) : 1;
700
+	$step = isset($_GET['step']) ? absint($_GET['step']) : 1;
701 701
 
702 702
 	// form query
703
-	$forms = new WP_Query( array(
703
+	$forms = new WP_Query(array(
704 704
 			'paged'          => $step,
705 705
 			'status'         => 'any',
706 706
 			'order'          => 'ASC',
@@ -709,39 +709,39 @@  discard block
 block discarded – undo
709 709
 		)
710 710
 	);
711 711
 
712
-	if ( $forms->have_posts() ) {
713
-		while ( $forms->have_posts() ) {
712
+	if ($forms->have_posts()) {
713
+		while ($forms->have_posts()) {
714 714
 			$forms->the_post();
715 715
 
716 716
 			// Form content.
717 717
 			// Note in version 1.8 display content setting split into display content and content placement setting.
718 718
 			// You can delete _give_content_option in future
719
-			$show_content = get_post_meta( get_the_ID(), '_give_content_option', true );
720
-			if ( $show_content && ! get_post_meta( get_the_ID(), '_give_display_content', true ) ) {
721
-				$field_value = ( 'none' !== $show_content ? 'enabled' : 'disabled' );
722
-				update_post_meta( get_the_ID(), '_give_display_content', $field_value );
719
+			$show_content = get_post_meta(get_the_ID(), '_give_content_option', true);
720
+			if ($show_content && ! get_post_meta(get_the_ID(), '_give_display_content', true)) {
721
+				$field_value = ('none' !== $show_content ? 'enabled' : 'disabled');
722
+				update_post_meta(get_the_ID(), '_give_display_content', $field_value);
723 723
 
724
-				$field_value = ( 'none' !== $show_content ? $show_content : 'give_pre_form' );
725
-				update_post_meta( get_the_ID(), '_give_content_placement', $field_value );
724
+				$field_value = ('none' !== $show_content ? $show_content : 'give_pre_form');
725
+				update_post_meta(get_the_ID(), '_give_content_placement', $field_value);
726 726
 			}
727 727
 
728 728
 			// "Disable" Guest Donation. Checkbox
729 729
 			// See: https://github.com/WordImpress/Give/issues/1470
730
-			$guest_donation = get_post_meta( get_the_ID(), '_give_logged_in_only', true );
731
-			$guest_donation_newval = ( in_array( $guest_donation, array( 'yes', 'on' ) ) ? 'disabled' : 'enabled' );
732
-			update_post_meta( get_the_ID(), '_give_logged_in_only', $guest_donation_newval );
730
+			$guest_donation = get_post_meta(get_the_ID(), '_give_logged_in_only', true);
731
+			$guest_donation_newval = (in_array($guest_donation, array('yes', 'on')) ? 'disabled' : 'enabled');
732
+			update_post_meta(get_the_ID(), '_give_logged_in_only', $guest_donation_newval);
733 733
 
734 734
 			// Offline Donations
735 735
 			// See: https://github.com/WordImpress/Give/issues/1579
736
-			$offline_donation = get_post_meta( get_the_ID(), '_give_customize_offline_donations', true );
737
-			if ( 'no' === $offline_donation ) {
736
+			$offline_donation = get_post_meta(get_the_ID(), '_give_customize_offline_donations', true);
737
+			if ('no' === $offline_donation) {
738 738
 				$offline_donation_newval = 'global';
739
-			} elseif ( 'yes' === $offline_donation ) {
739
+			} elseif ('yes' === $offline_donation) {
740 740
 				$offline_donation_newval = 'enabled';
741 741
 			} else {
742 742
 				$offline_donation_newval = 'disabled';
743 743
 			}
744
-			update_post_meta( get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval );
744
+			update_post_meta(get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval);
745 745
 
746 746
 			// Convert yes/no setting field to enabled/disabled.
747 747
 			$form_radio_settings = array(
@@ -761,15 +761,15 @@  discard block
 block discarded – undo
761 761
 				'_give_offline_donation_enable_billing_fields_single',
762 762
 			);
763 763
 
764
-			foreach ( $form_radio_settings as $meta_key ) {
764
+			foreach ($form_radio_settings as $meta_key) {
765 765
 				// Get value.
766
-				$field_value = get_post_meta( get_the_ID(), $meta_key, true );
766
+				$field_value = get_post_meta(get_the_ID(), $meta_key, true);
767 767
 
768 768
 				// Convert meta value only if it is in yes/no/none.
769
-				if ( in_array( $field_value, array( 'yes', 'on', 'no', 'none' ) ) ) {
769
+				if (in_array($field_value, array('yes', 'on', 'no', 'none'))) {
770 770
 
771
-					$field_value = ( in_array( $field_value, array( 'yes', 'on' ) ) ? 'enabled' : 'disabled' );
772
-					update_post_meta( get_the_ID(), $meta_key, $field_value );
771
+					$field_value = (in_array($field_value, array('yes', 'on')) ? 'enabled' : 'disabled');
772
+					update_post_meta(get_the_ID(), $meta_key, $field_value);
773 773
 				}
774 774
 			}
775 775
 		}// End while().
@@ -777,27 +777,27 @@  discard block
 block discarded – undo
777 777
 		wp_reset_postdata();
778 778
 
779 779
 		// Forms found so upgrade them
780
-		$step ++;
781
-		$redirect = add_query_arg( array(
780
+		$step++;
781
+		$redirect = add_query_arg(array(
782 782
 			'page'         => 'give-upgrades',
783 783
 			'give-upgrade' => 'give_v18_upgrades_form_metadata',
784 784
 			'step'         => $step,
785
-		), admin_url( 'index.php' ) );
786
-		wp_redirect( $redirect );
785
+		), admin_url('index.php'));
786
+		wp_redirect($redirect);
787 787
 		exit();
788 788
 
789 789
 	} else {
790 790
 		// No more forms found, finish up.
791
-		update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) );
792
-		delete_option( 'give_doing_upgrade' );
793
-		give_set_upgrade_complete( 'v18_upgrades_form_metadata' );
791
+		update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION));
792
+		delete_option('give_doing_upgrade');
793
+		give_set_upgrade_complete('v18_upgrades_form_metadata');
794 794
 
795
-		wp_redirect( admin_url() );
795
+		wp_redirect(admin_url());
796 796
 		exit;
797 797
 	}
798 798
 }
799 799
 
800
-add_action( 'give_give_v18_upgrades_form_metadata', 'give_v18_upgrades_form_metadata' );
800
+add_action('give_give_v18_upgrades_form_metadata', 'give_v18_upgrades_form_metadata');
801 801
 
802 802
 /**
803 803
  * Get list of core setting renamed in version 1.8.
@@ -830,7 +830,7 @@  discard block
 block discarded – undo
830 830
  * @since  1.8.7
831 831
  * @return void
832 832
  */
833
-function give_v187_upgrades(){
833
+function give_v187_upgrades() {
834 834
 	global $wpdb;
835 835
 
836 836
 	/**
@@ -870,24 +870,24 @@  discard block
 block discarded – undo
870 870
 		ARRAY_A
871 871
 	);
872 872
 
873
-	if( ! empty( $user_apikey_options ) ) {
874
-		foreach ( $user_apikey_options as $user ) {
875
-			$cached_options[] = '_transient_' . md5( 'give_api_user_' . $user['meta_key'] );
876
-			$cached_options[] = '_transient_' . md5( 'give_api_user_public_key' . $user['user_id'] );
877
-			$cached_options[] = '_transient_' . md5( 'give_api_user_secret_key' . $user['user_id'] );
873
+	if ( ! empty($user_apikey_options)) {
874
+		foreach ($user_apikey_options as $user) {
875
+			$cached_options[] = '_transient_'.md5('give_api_user_'.$user['meta_key']);
876
+			$cached_options[] = '_transient_'.md5('give_api_user_public_key'.$user['user_id']);
877
+			$cached_options[] = '_transient_'.md5('give_api_user_secret_key'.$user['user_id']);
878 878
 		}
879 879
 	}
880 880
 
881
-	if ( ! empty( $cached_options ) ) {
882
-		foreach ( $cached_options as $option ) {
883
-			switch ( true ) {
884
-				case ( false !== strpos( $option, 'transient' ) ):
885
-					$option = str_replace( '_transient_', '', $option );
886
-					delete_transient( $option );
881
+	if ( ! empty($cached_options)) {
882
+		foreach ($cached_options as $option) {
883
+			switch (true) {
884
+				case (false !== strpos($option, 'transient')):
885
+					$option = str_replace('_transient_', '', $option);
886
+					delete_transient($option);
887 887
 					break;
888 888
 
889 889
 				default:
890
-					delete_option( $option );
890
+					delete_option($option);
891 891
 			}
892 892
 		}
893 893
 	}
Please login to merge, or discard this patch.
includes/admin/class-give-settings.php 1 patch
Spacing   +362 added lines, -362 removed lines patch added patch discarded remove patch
@@ -43,14 +43,14 @@  discard block
 block discarded – undo
43 43
 	public function __construct() {
44 44
 
45 45
 		// Custom CMB2 Settings Fields
46
-		add_action( 'cmb2_render_give_title', 'give_title_callback', 10, 5 );
47
-		add_action( 'cmb2_render_give_description', 'give_description_callback', 10, 5 );
48
-		add_action( 'cmb2_render_enabled_gateways', 'give_enabled_gateways_callback', 10, 5 );
49
-		add_action( 'cmb2_render_default_gateway', 'give_default_gateway_callback', 10, 5 );
50
-		add_action( 'cmb2_render_email_preview_buttons', 'give_email_preview_buttons_callback', 10, 5 );
51
-		add_action( 'cmb2_render_system_info', 'give_system_info_callback', 10, 5 );
52
-		add_action( 'cmb2_render_api', 'give_api_callback', 10, 5 );
53
-		add_action( 'cmb2_render_license_key', 'give_license_key_callback', 10, 5 );
46
+		add_action('cmb2_render_give_title', 'give_title_callback', 10, 5);
47
+		add_action('cmb2_render_give_description', 'give_description_callback', 10, 5);
48
+		add_action('cmb2_render_enabled_gateways', 'give_enabled_gateways_callback', 10, 5);
49
+		add_action('cmb2_render_default_gateway', 'give_default_gateway_callback', 10, 5);
50
+		add_action('cmb2_render_email_preview_buttons', 'give_email_preview_buttons_callback', 10, 5);
51
+		add_action('cmb2_render_system_info', 'give_system_info_callback', 10, 5);
52
+		add_action('cmb2_render_api', 'give_api_callback', 10, 5);
53
+		add_action('cmb2_render_license_key', 'give_license_key_callback', 10, 5);
54 54
 	}
55 55
 
56 56
 
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	 * @since  1.0
61 61
 	 */
62 62
 	public function init() {
63
-		register_setting( $this->key, $this->key );
63
+		register_setting($this->key, $this->key);
64 64
 
65 65
 	}
66 66
 
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
 	 *
75 75
 	 * @return mixed
76 76
 	 */
77
-	public function give_update_cmb_meta_box_url( $url ) {
77
+	public function give_update_cmb_meta_box_url($url) {
78 78
 		// Path to Give's CMB
79
-		return GIVE_PLUGIN_URL . '/includes/libraries/cmb2';
79
+		return GIVE_PLUGIN_URL.'/includes/libraries/cmb2';
80 80
 	}
81 81
 
82 82
 
@@ -88,27 +88,27 @@  discard block
 block discarded – undo
88 88
 	 */
89 89
 	public function give_get_settings_tabs() {
90 90
 
91
-		$settings = $this->give_settings( null );
91
+		$settings = $this->give_settings(null);
92 92
 
93 93
 		$tabs             = array();
94
-		$tabs['general']  = esc_html__( 'General', 'give' );
95
-		$tabs['gateways'] = esc_html__( 'Payment Gateways', 'give' );
96
-		$tabs['display']  = esc_html__( 'Display Options', 'give' );
97
-		$tabs['emails']   = esc_html__( 'Emails', 'give' );
94
+		$tabs['general']  = esc_html__('General', 'give');
95
+		$tabs['gateways'] = esc_html__('Payment Gateways', 'give');
96
+		$tabs['display']  = esc_html__('Display Options', 'give');
97
+		$tabs['emails']   = esc_html__('Emails', 'give');
98 98
 
99
-		if ( ! empty( $settings['addons']['fields'] ) ) {
100
-			$tabs['addons'] = esc_html__( 'Add-ons', 'give' );
99
+		if ( ! empty($settings['addons']['fields'])) {
100
+			$tabs['addons'] = esc_html__('Add-ons', 'give');
101 101
 		}
102 102
 
103
-		if ( ! empty( $settings['licenses']['fields'] ) ) {
104
-			$tabs['licenses'] = esc_html__( 'Licenses', 'give' );
103
+		if ( ! empty($settings['licenses']['fields'])) {
104
+			$tabs['licenses'] = esc_html__('Licenses', 'give');
105 105
 		}
106 106
 
107
-		$tabs['advanced']    = esc_html__( 'Advanced', 'give' );
108
-		$tabs['api']         = esc_html__( 'API', 'give' );
109
-		$tabs['system_info'] = esc_html__( 'System Info', 'give' );
107
+		$tabs['advanced']    = esc_html__('Advanced', 'give');
108
+		$tabs['api']         = esc_html__('API', 'give');
109
+		$tabs['system_info'] = esc_html__('System Info', 'give');
110 110
 
111
-		return apply_filters( 'give_settings_tabs', $tabs );
111
+		return apply_filters('give_settings_tabs', $tabs);
112 112
 	}
113 113
 
114 114
 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	 */
120 120
 	public function admin_page_display() {
121 121
 
122
-		$active_tab = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $this->give_get_settings_tabs() ) ? $_GET['tab'] : 'general';
122
+		$active_tab = isset($_GET['tab']) && array_key_exists($_GET['tab'], $this->give_get_settings_tabs()) ? $_GET['tab'] : 'general';
123 123
 
124 124
 		?>
125 125
 
@@ -129,22 +129,22 @@  discard block
 block discarded – undo
129 129
 
130 130
 			<h2 class="nav-tab-wrapper">
131 131
 				<?php
132
-				foreach ( $this->give_get_settings_tabs() as $tab_id => $tab_name ) {
132
+				foreach ($this->give_get_settings_tabs() as $tab_id => $tab_name) {
133 133
 
134
-					$tab_url = esc_url( add_query_arg( array(
134
+					$tab_url = esc_url(add_query_arg(array(
135 135
 						'settings-updated' => false,
136 136
 						'tab'              => $tab_id,
137
-					) ) );
137
+					)));
138 138
 
139 139
 					$active = $active_tab == $tab_id ? ' nav-tab-active' : '';
140 140
 
141
-					echo '<a href="' . esc_url( $tab_url ) . '" class="nav-tab' . $active . '" id="tab-' . $tab_id . '">' . esc_html( $tab_name ) . '</a>';
141
+					echo '<a href="'.esc_url($tab_url).'" class="nav-tab'.$active.'" id="tab-'.$tab_id.'">'.esc_html($tab_name).'</a>';
142 142
 
143 143
 				}
144 144
 				?>
145 145
 			</h2>
146 146
 
147
-			<?php cmb2_metabox_form( $this->give_settings( $active_tab ), $this->key ); ?>
147
+			<?php cmb2_metabox_form($this->give_settings($active_tab), $this->key); ?>
148 148
 
149 149
 		</div><!-- .wrap -->
150 150
 
@@ -166,12 +166,12 @@  discard block
 block discarded – undo
166 166
 	 *
167 167
 	 * @return string
168 168
 	 */
169
-	function give_modify_cmb2_form_output( $form_format, $object_id, $cmb ) {
169
+	function give_modify_cmb2_form_output($form_format, $object_id, $cmb) {
170 170
 
171 171
 		// only modify the give settings form
172
-		if ( 'give_settings' == $object_id ) {
172
+		if ('give_settings' == $object_id) {
173 173
 
174
-			return '<form class="cmb-form" method="post" id="%1$s" enctype="multipart/form-data" encoding="multipart/form-data"><input type="hidden" name="give_settings_saved" value="true"><input type="hidden" name="object_id" value="%2$s">%3$s<div class="give-submit-wrap"><input type="submit" name="submit-cmb" value="' . esc_attr__( 'Save Settings', 'give' ) . '" class="button-primary"></div></form>';
174
+			return '<form class="cmb-form" method="post" id="%1$s" enctype="multipart/form-data" encoding="multipart/form-data"><input type="hidden" name="give_settings_saved" value="true"><input type="hidden" name="object_id" value="%2$s">%3$s<div class="give-submit-wrap"><input type="submit" name="submit-cmb" value="'.esc_attr__('Save Settings', 'give').'" class="button-primary"></div></form>';
175 175
 
176 176
 		}
177 177
 
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 	 *
189 189
 	 * @return array
190 190
 	 */
191
-	public function give_settings( $active_tab ) {
191
+	public function give_settings($active_tab) {
192 192
 
193 193
 		$give_settings = array(
194 194
 			/**
@@ -196,99 +196,99 @@  discard block
 block discarded – undo
196 196
 			 */
197 197
 			'general'     => array(
198 198
 				'id'         => 'general_settings',
199
-				'give_title' => esc_html__( 'General Settings', 'give' ),
200
-				'show_on'    => array( 'key' => 'options-page', 'value' => array( $this->key ) ),
201
-				'fields'     => apply_filters( 'give_settings_general', array(
199
+				'give_title' => esc_html__('General Settings', 'give'),
200
+				'show_on'    => array('key' => 'options-page', 'value' => array($this->key)),
201
+				'fields'     => apply_filters('give_settings_general', array(
202 202
 						array(
203
-							'name' => esc_html__( 'General Settings', 'give' ),
203
+							'name' => esc_html__('General Settings', 'give'),
204 204
 							'desc' => '',
205 205
 							'type' => 'give_title',
206 206
 							'id'   => 'give_title_general_settings_1',
207 207
 						),
208 208
 						array(
209
-							'name'    => esc_html__( 'Success Page', 'give' ),
209
+							'name'    => esc_html__('Success Page', 'give'),
210 210
 							/* translators: %s: [give_receipt] */
211
-							'desc'    => sprintf( __( 'The page donors are sent to after completing their donations. The %s shortcode should be on this page.', 'give' ), '<code>[give_receipt]</code>' ),
211
+							'desc'    => sprintf(__('The page donors are sent to after completing their donations. The %s shortcode should be on this page.', 'give'), '<code>[give_receipt]</code>'),
212 212
 							'id'      => 'success_page',
213 213
 							'type'    => 'select',
214
-							'options' => give_cmb2_get_post_options( array(
214
+							'options' => give_cmb2_get_post_options(array(
215 215
 								'post_type'   => 'page',
216
-								'numberposts' => - 1,
217
-							) ),
216
+								'numberposts' => -1,
217
+							)),
218 218
 						),
219 219
 						array(
220
-							'name'    => esc_html__( 'Failed Donation Page', 'give' ),
221
-							'desc'    => esc_html__( 'The page donors are sent to if their donation is cancelled or fails.', 'give' ),
220
+							'name'    => esc_html__('Failed Donation Page', 'give'),
221
+							'desc'    => esc_html__('The page donors are sent to if their donation is cancelled or fails.', 'give'),
222 222
 							'id'      => 'failure_page',
223 223
 							'type'    => 'select',
224
-							'options' => give_cmb2_get_post_options( array(
224
+							'options' => give_cmb2_get_post_options(array(
225 225
 								'post_type'   => 'page',
226
-								'numberposts' => - 1,
227
-							) ),
226
+								'numberposts' => -1,
227
+							)),
228 228
 						),
229 229
 						array(
230
-							'name'    => esc_html__( 'Donation History Page', 'give' ),
230
+							'name'    => esc_html__('Donation History Page', 'give'),
231 231
 							/* translators: %s: [donation_history] */
232
-							'desc'    => sprintf( __( 'The page showing a complete donation history for the current user. The %s shortcode should be on this page.', 'give' ), '<code>[donation_history]</code>' ),
232
+							'desc'    => sprintf(__('The page showing a complete donation history for the current user. The %s shortcode should be on this page.', 'give'), '<code>[donation_history]</code>'),
233 233
 							'id'      => 'history_page',
234 234
 							'type'    => 'select',
235
-							'options' => give_cmb2_get_post_options( array(
235
+							'options' => give_cmb2_get_post_options(array(
236 236
 								'post_type'   => 'page',
237
-								'numberposts' => - 1,
238
-							) ),
237
+								'numberposts' => -1,
238
+							)),
239 239
 						),
240 240
 						array(
241
-							'name'    => esc_html__( 'Base Country', 'give' ),
242
-							'desc'    => esc_html__( 'The country your site operates from.', 'give' ),
241
+							'name'    => esc_html__('Base Country', 'give'),
242
+							'desc'    => esc_html__('The country your site operates from.', 'give'),
243 243
 							'id'      => 'base_country',
244 244
 							'type'    => 'select',
245 245
 							'options' => give_get_country_list(),
246 246
 						),
247 247
 						array(
248
-							'name' => esc_html__( 'Currency Settings', 'give' ),
248
+							'name' => esc_html__('Currency Settings', 'give'),
249 249
 							'desc' => '',
250 250
 							'type' => 'give_title',
251 251
 							'id'   => 'give_title_general_settings_2',
252 252
 						),
253 253
 						array(
254
-							'name'    => esc_html__( 'Currency', 'give' ),
255
-							'desc'    => esc_html__( 'The donation currency. Note that some payment gateways have currency restrictions.', 'give' ),
254
+							'name'    => esc_html__('Currency', 'give'),
255
+							'desc'    => esc_html__('The donation currency. Note that some payment gateways have currency restrictions.', 'give'),
256 256
 							'id'      => 'currency',
257 257
 							'type'    => 'select',
258 258
 							'options' => give_get_currencies(),
259 259
 							'default' => 'USD',
260 260
 						),
261 261
 						array(
262
-							'name'    => esc_html__( 'Currency Position', 'give' ),
263
-							'desc'    => esc_html__( 'The position of the currency symbol.', 'give' ),
262
+							'name'    => esc_html__('Currency Position', 'give'),
263
+							'desc'    => esc_html__('The position of the currency symbol.', 'give'),
264 264
 							'id'      => 'currency_position',
265 265
 							'type'    => 'select',
266 266
 							'options' => array(
267 267
 								/* translators: %s: currency symbol */
268
-								'before' => sprintf( esc_html__( 'Before - %s10', 'give' ), give_currency_symbol( give_get_currency() ) ),
268
+								'before' => sprintf(esc_html__('Before - %s10', 'give'), give_currency_symbol(give_get_currency())),
269 269
 								/* translators: %s: currency symbol */
270
-								'after'  => sprintf( esc_html__( 'After - 10%s', 'give' ), give_currency_symbol( give_get_currency() ) ),
270
+								'after'  => sprintf(esc_html__('After - 10%s', 'give'), give_currency_symbol(give_get_currency())),
271 271
 							),
272 272
 							'default' => 'before',
273 273
 						),
274 274
 						array(
275
-							'name'            => esc_html__( 'Thousands Separator', 'give' ),
276
-							'desc'            => esc_html__( 'The symbol (usually , or .) to separate thousands.', 'give' ),
275
+							'name'            => esc_html__('Thousands Separator', 'give'),
276
+							'desc'            => esc_html__('The symbol (usually , or .) to separate thousands.', 'give'),
277 277
 							'id'              => 'thousands_separator',
278 278
 							'type'            => 'text_small',
279 279
 							'sanitization_cb' => 'give_sanitize_thousand_separator',
280 280
 							'default'         => ',',
281 281
 						),
282 282
 						array(
283
-							'name'    => esc_html__( 'Decimal Separator', 'give' ),
284
-							'desc'    => esc_html__( 'The symbol (usually , or .) to separate decimal points.', 'give' ),
283
+							'name'    => esc_html__('Decimal Separator', 'give'),
284
+							'desc'    => esc_html__('The symbol (usually , or .) to separate decimal points.', 'give'),
285 285
 							'id'      => 'decimal_separator',
286 286
 							'type'    => 'text_small',
287 287
 							'default' => '.',
288 288
 						),
289 289
 						array(
290
-							'name'            => esc_html__( 'Number of Decimals', 'give' ),
291
-							'desc'            => esc_html__( 'The number of decimal points displayed in amounts.', 'give' ),
290
+							'name'            => esc_html__('Number of Decimals', 'give'),
291
+							'desc'            => esc_html__('The number of decimal points displayed in amounts.', 'give'),
292 292
 							'id'              => 'number_decimals',
293 293
 							'type'            => 'text_small',
294 294
 							'default'         => 2,
@@ -302,83 +302,83 @@  discard block
 block discarded – undo
302 302
 			 */
303 303
 			'gateways'    => array(
304 304
 				'id'         => 'payment_gateways',
305
-				'give_title' => esc_html__( 'Payment Gateways', 'give' ),
306
-				'show_on'    => array( 'key' => 'options-page', 'value' => array( $this->key ) ),
307
-				'fields'     => apply_filters( 'give_settings_gateways', array(
305
+				'give_title' => esc_html__('Payment Gateways', 'give'),
306
+				'show_on'    => array('key' => 'options-page', 'value' => array($this->key)),
307
+				'fields'     => apply_filters('give_settings_gateways', array(
308 308
 						array(
309
-							'name' => esc_html__( 'Gateways Settings', 'give' ),
309
+							'name' => esc_html__('Gateways Settings', 'give'),
310 310
 							'desc' => '',
311 311
 							'id'   => 'give_title_gateway_settings_1',
312 312
 							'type' => 'give_title',
313 313
 						),
314 314
 						array(
315
-							'name' => esc_html__( 'Test Mode', 'give' ),
316
-							'desc' => esc_html__( 'While in test mode no live donations are processed. To fully use test mode, you must have a sandbox (test) account for the payment gateway you are testing.', 'give' ),
315
+							'name' => esc_html__('Test Mode', 'give'),
316
+							'desc' => esc_html__('While in test mode no live donations are processed. To fully use test mode, you must have a sandbox (test) account for the payment gateway you are testing.', 'give'),
317 317
 							'id'   => 'test_mode',
318 318
 							'type' => 'checkbox',
319 319
 						),
320 320
 						array(
321
-							'name' => esc_html__( 'Enabled Gateways', 'give' ),
322
-							'desc' => esc_html__( 'Enable your payment gateway. Can be ordered by dragging.', 'give' ),
321
+							'name' => esc_html__('Enabled Gateways', 'give'),
322
+							'desc' => esc_html__('Enable your payment gateway. Can be ordered by dragging.', 'give'),
323 323
 							'id'   => 'gateways',
324 324
 							'type' => 'enabled_gateways',
325 325
 						),
326 326
 						array(
327
-							'name' => esc_html__( 'Default Gateway', 'give' ),
328
-							'desc' => esc_html__( 'The gateway that will be selected by default.', 'give' ),
327
+							'name' => esc_html__('Default Gateway', 'give'),
328
+							'desc' => esc_html__('The gateway that will be selected by default.', 'give'),
329 329
 							'id'   => 'default_gateway',
330 330
 							'type' => 'default_gateway',
331 331
 						),
332 332
 						array(
333
-							'name' => esc_html__( 'PayPal Standard', 'give' ),
333
+							'name' => esc_html__('PayPal Standard', 'give'),
334 334
 							'desc' => '',
335 335
 							'type' => 'give_title',
336 336
 							'id'   => 'give_title_gateway_settings_2',
337 337
 						),
338 338
 						array(
339
-							'name' => esc_html__( 'PayPal Email', 'give' ),
340
-							'desc' => esc_html__( 'Enter your PayPal account\'s email.', 'give' ),
339
+							'name' => esc_html__('PayPal Email', 'give'),
340
+							'desc' => esc_html__('Enter your PayPal account\'s email.', 'give'),
341 341
 							'id'   => 'paypal_email',
342 342
 							'type' => 'text_email',
343 343
 						),
344 344
 						array(
345
-							'name' => esc_html__( 'PayPal Page Style', 'give' ),
346
-							'desc' => esc_html__( 'Enter the name of the page style to use, or leave blank to use the default.', 'give' ),
345
+							'name' => esc_html__('PayPal Page Style', 'give'),
346
+							'desc' => esc_html__('Enter the name of the page style to use, or leave blank to use the default.', 'give'),
347 347
 							'id'   => 'paypal_page_style',
348 348
 							'type' => 'text',
349 349
 						),
350 350
 						array(
351
-							'name'    => esc_html__( 'PayPal Transaction Type', 'give' ),
352
-							'desc'    => esc_html__( 'Nonprofits must verify their status to withdraw donations they receive via PayPal. PayPal users that are not verified nonprofits must demonstrate how their donations will be used, once they raise more than $10,000. By default, Give transactions are sent to PayPal as donations. You may change the transaction type using this option if you feel you may not meet PayPal\'s donation requirements.', 'give' ),
351
+							'name'    => esc_html__('PayPal Transaction Type', 'give'),
352
+							'desc'    => esc_html__('Nonprofits must verify their status to withdraw donations they receive via PayPal. PayPal users that are not verified nonprofits must demonstrate how their donations will be used, once they raise more than $10,000. By default, Give transactions are sent to PayPal as donations. You may change the transaction type using this option if you feel you may not meet PayPal\'s donation requirements.', 'give'),
353 353
 							'id'      => 'paypal_button_type',
354 354
 							'type'    => 'radio_inline',
355 355
 							'options' => array(
356
-								'donation' => esc_html__( 'Donation', 'give' ),
357
-								'standard' => esc_html__( 'Standard Transaction', 'give' ),
356
+								'donation' => esc_html__('Donation', 'give'),
357
+								'standard' => esc_html__('Standard Transaction', 'give'),
358 358
 							),
359 359
 							'default' => 'donation',
360 360
 						),
361 361
 						array(
362
-							'name' => esc_html__( 'Disable PayPal IPN Verification', 'give' ),
363
-							'desc' => esc_html__( 'If donations are not getting marked as complete, use a slightly less secure method of verifying donations.', 'give' ),
362
+							'name' => esc_html__('Disable PayPal IPN Verification', 'give'),
363
+							'desc' => esc_html__('If donations are not getting marked as complete, use a slightly less secure method of verifying donations.', 'give'),
364 364
 							'id'   => 'disable_paypal_verification',
365 365
 							'type' => 'checkbox',
366 366
 						),
367 367
 						array(
368
-							'name' => esc_html__( 'Offline Donations', 'give' ),
368
+							'name' => esc_html__('Offline Donations', 'give'),
369 369
 							'desc' => '',
370 370
 							'type' => 'give_title',
371 371
 							'id'   => 'give_title_gateway_settings_3',
372 372
 						),
373 373
 						array(
374
-							'name' => esc_html__( 'Collect Billing Details', 'give' ),
375
-							'desc' => esc_html__( 'Enable to request billing details for offline donations. Will appear above offline donation instructions. Can be enabled/disabled per form.', 'give' ),
374
+							'name' => esc_html__('Collect Billing Details', 'give'),
375
+							'desc' => esc_html__('Enable to request billing details for offline donations. Will appear above offline donation instructions. Can be enabled/disabled per form.', 'give'),
376 376
 							'id'   => 'give_offline_donation_enable_billing_fields',
377 377
 							'type' => 'checkbox',
378 378
 						),
379 379
 						array(
380
-							'name'    => esc_html__( 'Offline Donation Instructions', 'give' ),
381
-							'desc'    => esc_html__( 'The following content will appear for all forms when the user selects the offline donation payment option. Note: You may customize the content per form as needed.', 'give' ),
380
+							'name'    => esc_html__('Offline Donation Instructions', 'give'),
381
+							'desc'    => esc_html__('The following content will appear for all forms when the user selects the offline donation payment option. Note: You may customize the content per form as needed.', 'give'),
382 382
 							'id'      => 'global_offline_donation_content',
383 383
 							'default' => give_get_default_offline_donation_content(),
384 384
 							'type'    => 'wysiwyg',
@@ -387,15 +387,15 @@  discard block
 block discarded – undo
387 387
 							),
388 388
 						),
389 389
 						array(
390
-							'name'    => esc_html__( 'Offline Donation Email Instructions Subject', 'give' ),
391
-							'desc'    => esc_html__( 'Enter the subject line for the donation receipt email.', 'give' ),
390
+							'name'    => esc_html__('Offline Donation Email Instructions Subject', 'give'),
391
+							'desc'    => esc_html__('Enter the subject line for the donation receipt email.', 'give'),
392 392
 							'id'      => 'offline_donation_subject',
393
-							'default' => esc_attr__( '{donation} - Offline Donation Instructions', 'give' ),
393
+							'default' => esc_attr__('{donation} - Offline Donation Instructions', 'give'),
394 394
 							'type'    => 'text',
395 395
 						),
396 396
 						array(
397
-							'name'    => esc_html__( 'Offline Donation Email Instructions', 'give' ),
398
-							'desc'    => esc_html__( 'Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ),
397
+							'name'    => esc_html__('Offline Donation Email Instructions', 'give'),
398
+							'desc'    => esc_html__('Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give'),
399 399
 							'id'      => 'global_offline_donation_email',
400 400
 							'default' => give_get_default_offline_donation_email_content(),
401 401
 							'type'    => 'wysiwyg',
@@ -409,104 +409,104 @@  discard block
 block discarded – undo
409 409
 			/** Display Settings */
410 410
 			'display'     => array(
411 411
 				'id'         => 'display_settings',
412
-				'give_title' => esc_html__( 'Display Settings', 'give' ),
413
-				'show_on'    => array( 'key' => 'options-page', 'value' => array( $this->key ) ),
414
-				'fields'     => apply_filters( 'give_settings_display', array(
412
+				'give_title' => esc_html__('Display Settings', 'give'),
413
+				'show_on'    => array('key' => 'options-page', 'value' => array($this->key)),
414
+				'fields'     => apply_filters('give_settings_display', array(
415 415
 						array(
416
-							'name' => esc_html__( 'Display Settings', 'give' ),
416
+							'name' => esc_html__('Display Settings', 'give'),
417 417
 							'desc' => '',
418 418
 							'id'   => 'give_title_display_settings_1',
419 419
 							'type' => 'give_title',
420 420
 						),
421 421
 						array(
422
-							'name' => esc_html__( 'Disable CSS', 'give' ),
423
-							'desc' => esc_html__( 'Enable this option if you would like to disable all of Give\'s included CSS stylesheets.', 'give' ),
422
+							'name' => esc_html__('Disable CSS', 'give'),
423
+							'desc' => esc_html__('Enable this option if you would like to disable all of Give\'s included CSS stylesheets.', 'give'),
424 424
 							'id'   => 'disable_css',
425 425
 							'type' => 'checkbox',
426 426
 						),
427 427
 						array(
428
-							'name' => esc_html__( 'Enable Floating Labels', 'give' ),
428
+							'name' => esc_html__('Enable Floating Labels', 'give'),
429 429
 							/* translators: %s: http://docs.givewp.com/form-floating-labels */
430
-							'desc' => sprintf( wp_kses( __( 'Enable <a href="%s" target="_blank">floating labels</a> in Give\'s donation forms. Note that if the "Disable CSS" option is enabled, you will need to style the floating labels yourself.', 'give' ), array(
430
+							'desc' => sprintf(wp_kses(__('Enable <a href="%s" target="_blank">floating labels</a> in Give\'s donation forms. Note that if the "Disable CSS" option is enabled, you will need to style the floating labels yourself.', 'give'), array(
431 431
 								'a' => array(
432 432
 									'href'   => array(),
433 433
 									'target' => array(),
434 434
 								),
435
-							) ), esc_url( 'http://docs.givewp.com/form-floating-labels' ) ),
435
+							)), esc_url('http://docs.givewp.com/form-floating-labels')),
436 436
 							'id'   => 'floatlabels',
437 437
 							'type' => 'checkbox',
438 438
 						),
439 439
 						array(
440
-							'name' => esc_html__( 'Disable Welcome Screen', 'give' ),
440
+							'name' => esc_html__('Disable Welcome Screen', 'give'),
441 441
 							/* translators: %s: about page URL */
442
-							'desc' => sprintf( wp_kses( __( 'Enable this option if you would like to disable the <a href="%s" target="_blank">Give Welcome screen</a> every time Give is activated and/or updated.', 'give' ), array(
442
+							'desc' => sprintf(wp_kses(__('Enable this option if you would like to disable the <a href="%s" target="_blank">Give Welcome screen</a> every time Give is activated and/or updated.', 'give'), array(
443 443
 								'a' => array(
444 444
 									'href'   => array(),
445 445
 									'target' => array(),
446 446
 								),
447
-							) ), esc_url( admin_url( 'index.php?page=give-about' ) ) ),
447
+							)), esc_url(admin_url('index.php?page=give-about'))),
448 448
 							'id'   => 'disable_welcome',
449 449
 							'type' => 'checkbox',
450 450
 						),
451 451
 						array(
452
-							'name' => esc_html__( 'Post Types', 'give' ),
452
+							'name' => esc_html__('Post Types', 'give'),
453 453
 							'desc' => '',
454 454
 							'id'   => 'give_title_display_settings_2',
455 455
 							'type' => 'give_title',
456 456
 						),
457 457
 						array(
458
-							'name' => esc_html__( 'Disable Form Single Views', 'give' ),
459
-							'desc' => esc_html__( 'By default, all forms have single views enabled which create a specific URL on your website for that form. This option disables the singular and archive views from being publicly viewable. Note: you will need to embed forms using a shortcode or widget if enabled.', 'give' ),
458
+							'name' => esc_html__('Disable Form Single Views', 'give'),
459
+							'desc' => esc_html__('By default, all forms have single views enabled which create a specific URL on your website for that form. This option disables the singular and archive views from being publicly viewable. Note: you will need to embed forms using a shortcode or widget if enabled.', 'give'),
460 460
 							'id'   => 'disable_forms_singular',
461 461
 							'type' => 'checkbox',
462 462
 						),
463 463
 						array(
464
-							'name' => esc_html__( 'Disable Form Archives', 'give' ),
465
-							'desc' => esc_html__( 'Archives pages list all the forms you have created. This option will disable only the form\'s archive page(s). The single form\'s view will remain in place. Note: you will need to refresh your permalinks after this option has been enabled.', 'give' ),
464
+							'name' => esc_html__('Disable Form Archives', 'give'),
465
+							'desc' => esc_html__('Archives pages list all the forms you have created. This option will disable only the form\'s archive page(s). The single form\'s view will remain in place. Note: you will need to refresh your permalinks after this option has been enabled.', 'give'),
466 466
 							'id'   => 'disable_forms_archives',
467 467
 							'type' => 'checkbox',
468 468
 						),
469 469
 						array(
470
-							'name' => esc_html__( 'Disable Form Excerpts', 'give' ),
471
-							'desc' => esc_html__( 'The excerpt is an optional summary or description of a donation form; in short, a summary as to why the user should give.', 'give' ),
470
+							'name' => esc_html__('Disable Form Excerpts', 'give'),
471
+							'desc' => esc_html__('The excerpt is an optional summary or description of a donation form; in short, a summary as to why the user should give.', 'give'),
472 472
 							'id'   => 'disable_forms_excerpt',
473 473
 							'type' => 'checkbox',
474 474
 						),
475 475
 						array(
476
-							'name'    => esc_html__( 'Featured Image Size', 'give' ),
477
-							'desc'    => esc_html__( 'The Featured Image is an image that is chosen as the representative image for a donation form. Some themes may have custom featured image sizes. Please select the size you would like to display for your single donation form\'s featured image.', 'give' ),
476
+							'name'    => esc_html__('Featured Image Size', 'give'),
477
+							'desc'    => esc_html__('The Featured Image is an image that is chosen as the representative image for a donation form. Some themes may have custom featured image sizes. Please select the size you would like to display for your single donation form\'s featured image.', 'give'),
478 478
 							'id'      => 'featured_image_size',
479 479
 							'type'    => 'select',
480 480
 							'default' => 'large',
481 481
 							'options' => give_get_featured_image_sizes(),
482 482
 						),
483 483
 						array(
484
-							'name' => esc_html__( 'Disable Form Featured Image', 'give' ),
485
-							'desc' => esc_html__( 'If you do not wish to use the featured image functionality you can disable it using this option and it will not be displayed for single donation forms.', 'give' ),
484
+							'name' => esc_html__('Disable Form Featured Image', 'give'),
485
+							'desc' => esc_html__('If you do not wish to use the featured image functionality you can disable it using this option and it will not be displayed for single donation forms.', 'give'),
486 486
 							'id'   => 'disable_form_featured_img',
487 487
 							'type' => 'checkbox',
488 488
 						),
489 489
 						array(
490
-							'name' => esc_html__( 'Disable Single Form Sidebar', 'give' ),
491
-							'desc' => esc_html__( 'The sidebar allows you to add additional widget to the Give single form view. If you don\'t plan on using the sidebar you may disable it with this option.', 'give' ),
490
+							'name' => esc_html__('Disable Single Form Sidebar', 'give'),
491
+							'desc' => esc_html__('The sidebar allows you to add additional widget to the Give single form view. If you don\'t plan on using the sidebar you may disable it with this option.', 'give'),
492 492
 							'id'   => 'disable_form_sidebar',
493 493
 							'type' => 'checkbox',
494 494
 						),
495 495
 						array(
496
-							'name' => esc_html__( 'Taxonomies', 'give' ),
496
+							'name' => esc_html__('Taxonomies', 'give'),
497 497
 							'desc' => '',
498 498
 							'id'   => 'give_title_display_settings_3',
499 499
 							'type' => 'give_title',
500 500
 						),
501 501
 						array(
502
-							'name' => esc_html__( 'Enable Form Categories', 'give' ),
503
-							'desc' => esc_html__( 'Enables the "Category" taxonomy for all Give forms.', 'give' ),
502
+							'name' => esc_html__('Enable Form Categories', 'give'),
503
+							'desc' => esc_html__('Enables the "Category" taxonomy for all Give forms.', 'give'),
504 504
 							'id'   => 'categories',
505 505
 							'type' => 'checkbox',
506 506
 						),
507 507
 						array(
508
-							'name' => esc_html__( 'Enable Form Tags', 'give' ),
509
-							'desc' => esc_html__( 'Enables the "Tag" taxonomy for all Give forms.', 'give' ),
508
+							'name' => esc_html__('Enable Form Tags', 'give'),
509
+							'desc' => esc_html__('Enables the "Tag" taxonomy for all Give forms.', 'give'),
510 510
 							'id'   => 'tags',
511 511
 							'type' => 'checkbox',
512 512
 						),
@@ -519,101 +519,101 @@  discard block
 block discarded – undo
519 519
 			 */
520 520
 			'emails'      => array(
521 521
 				'id'         => 'email_settings',
522
-				'give_title' => esc_html__( 'Email Settings', 'give' ),
523
-				'show_on'    => array( 'key' => 'options-page', 'value' => array( $this->key ) ),
524
-				'fields'     => apply_filters( 'give_settings_emails', array(
522
+				'give_title' => esc_html__('Email Settings', 'give'),
523
+				'show_on'    => array('key' => 'options-page', 'value' => array($this->key)),
524
+				'fields'     => apply_filters('give_settings_emails', array(
525 525
 						array(
526
-							'name' => esc_html__( 'Email Settings', 'give' ),
526
+							'name' => esc_html__('Email Settings', 'give'),
527 527
 							'desc' => '',
528 528
 							'id'   => 'give_title_email_settings_1',
529 529
 							'type' => 'give_title',
530 530
 						),
531 531
 						array(
532 532
 							'id'      => 'email_template',
533
-							'name'    => esc_html__( 'Email Template', 'give' ),
534
-							'desc'    => esc_html__( 'Choose a template. Click "Save Changes" then "Preview Donation Receipt" to see the new template.', 'give' ),
533
+							'name'    => esc_html__('Email Template', 'give'),
534
+							'desc'    => esc_html__('Choose a template. Click "Save Changes" then "Preview Donation Receipt" to see the new template.', 'give'),
535 535
 							'type'    => 'select',
536 536
 							'options' => give_get_email_templates(),
537 537
 						),
538 538
 						array(
539 539
 							'id'   => 'email_logo',
540
-							'name' => esc_html__( 'Logo', 'give' ),
541
-							'desc' => esc_html__( 'Upload or choose a logo to be displayed at the top of the donation receipt emails. Displayed on HTML emails only.', 'give' ),
540
+							'name' => esc_html__('Logo', 'give'),
541
+							'desc' => esc_html__('Upload or choose a logo to be displayed at the top of the donation receipt emails. Displayed on HTML emails only.', 'give'),
542 542
 							'type' => 'file',
543 543
 						),
544 544
 						array(
545 545
 							'id'      => 'from_name',
546
-							'name'    => esc_html__( 'From Name', 'give' ),
547
-							'desc'    => esc_html__( 'The name that appears in the "From" field in donation receipt emails.', 'give' ),
548
-							'default' => get_bloginfo( 'name' ),
546
+							'name'    => esc_html__('From Name', 'give'),
547
+							'desc'    => esc_html__('The name that appears in the "From" field in donation receipt emails.', 'give'),
548
+							'default' => get_bloginfo('name'),
549 549
 							'type'    => 'text',
550 550
 						),
551 551
 						array(
552 552
 							'id'      => 'from_email',
553
-							'name'    => esc_html__( 'From Email', 'give' ),
554
-							'desc'    => esc_html__( 'Email to send donation receipts from. This will act as the "from" and "reply-to" address.', 'give' ),
555
-							'default' => get_bloginfo( 'admin_email' ),
553
+							'name'    => esc_html__('From Email', 'give'),
554
+							'desc'    => esc_html__('Email to send donation receipts from. This will act as the "from" and "reply-to" address.', 'give'),
555
+							'default' => get_bloginfo('admin_email'),
556 556
 							'type'    => 'text',
557 557
 						),
558 558
 						array(
559
-							'name' => esc_html__( 'Donation Receipt', 'give' ),
559
+							'name' => esc_html__('Donation Receipt', 'give'),
560 560
 							'desc' => '',
561 561
 							'id'   => 'give_title_email_settings_2',
562 562
 							'type' => 'give_title',
563 563
 						),
564 564
 						array(
565 565
 							'id'      => 'donation_subject',
566
-							'name'    => esc_html__( 'Donation Email Subject', 'give' ),
567
-							'desc'    => esc_html__( 'Enter the subject line for the donation receipt email.', 'give' ),
568
-							'default' => esc_attr__( 'Donation Receipt', 'give' ),
566
+							'name'    => esc_html__('Donation Email Subject', 'give'),
567
+							'desc'    => esc_html__('Enter the subject line for the donation receipt email.', 'give'),
568
+							'default' => esc_attr__('Donation Receipt', 'give'),
569 569
 							'type'    => 'text',
570 570
 						),
571 571
 						array(
572 572
 							'id'      => 'donation_receipt',
573
-							'name'    => esc_html__( 'Donation Receipt', 'give' ),
573
+							'name'    => esc_html__('Donation Receipt', 'give'),
574 574
 							'desc'    => sprintf(
575 575
 								/* translators: %s: emails tags list */
576
-								esc_html__( 'Enter the email that is sent to users after completing a successful donation. HTML is accepted. Available template tags: %s', 'give' ),
577
-								'<br/>' . give_get_emails_tags_list()
576
+								esc_html__('Enter the email that is sent to users after completing a successful donation. HTML is accepted. Available template tags: %s', 'give'),
577
+								'<br/>'.give_get_emails_tags_list()
578 578
 							),
579 579
 							'type'    => 'wysiwyg',
580 580
 							'default' => give_get_default_donation_receipt_email(),
581 581
 						),
582 582
 						array(
583
-							'name' => esc_html__( 'New Donation Notification', 'give' ),
583
+							'name' => esc_html__('New Donation Notification', 'give'),
584 584
 							'desc' => '',
585 585
 							'id'   => 'give_title_email_settings_3',
586 586
 							'type' => 'give_title',
587 587
 						),
588 588
 						array(
589 589
 							'id'      => 'donation_notification_subject',
590
-							'name'    => esc_html__( 'Donation Notification Subject', 'give' ),
591
-							'desc'    => esc_html__( 'Enter the subject line for the donation notification email.', 'give' ),
590
+							'name'    => esc_html__('Donation Notification Subject', 'give'),
591
+							'desc'    => esc_html__('Enter the subject line for the donation notification email.', 'give'),
592 592
 							'type'    => 'text',
593
-							'default' => esc_attr__( 'New Donation - #{payment_id}', 'give' ),
593
+							'default' => esc_attr__('New Donation - #{payment_id}', 'give'),
594 594
 						),
595 595
 						array(
596 596
 							'id'      => 'donation_notification',
597
-							'name'    => esc_html__( 'Donation Notification', 'give' ),
597
+							'name'    => esc_html__('Donation Notification', 'give'),
598 598
 							'desc'    => sprintf(
599 599
 								/* translators: %s: emails tags list */
600
-								esc_html__( 'Enter the email that is sent to donation notification emails after completion of a donation. HTML is accepted. Available template tags: %s', 'give' ),
601
-								'<br/>' . give_get_emails_tags_list()
600
+								esc_html__('Enter the email that is sent to donation notification emails after completion of a donation. HTML is accepted. Available template tags: %s', 'give'),
601
+								'<br/>'.give_get_emails_tags_list()
602 602
 							),
603 603
 							'type'    => 'wysiwyg',
604 604
 							'default' => give_get_default_donation_notification_email(),
605 605
 						),
606 606
 						array(
607 607
 							'id'      => 'admin_notice_emails',
608
-							'name'    => esc_html__( 'Donation Notification Emails', 'give' ),
609
-							'desc'    => __( 'Enter the email address(es) that should receive a notification anytime a donation is made, please only enter <span class="give-underline">one email address per line</span> and <strong>not separated by commas</strong>.', 'give' ),
608
+							'name'    => esc_html__('Donation Notification Emails', 'give'),
609
+							'desc'    => __('Enter the email address(es) that should receive a notification anytime a donation is made, please only enter <span class="give-underline">one email address per line</span> and <strong>not separated by commas</strong>.', 'give'),
610 610
 							'type'    => 'textarea',
611
-							'default' => get_bloginfo( 'admin_email' ),
611
+							'default' => get_bloginfo('admin_email'),
612 612
 						),
613 613
 						array(
614 614
 							'id'   => 'disable_admin_notices',
615
-							'name' => esc_html__( 'Disable Admin Notifications', 'give' ),
616
-							'desc' => esc_html__( 'Check this box if you do not want to receive emails when new donations are made.', 'give' ),
615
+							'name' => esc_html__('Disable Admin Notifications', 'give'),
616
+							'desc' => esc_html__('Check this box if you do not want to receive emails when new donations are made.', 'give'),
617 617
 							'type' => 'checkbox',
618 618
 						),
619 619
 					)
@@ -622,99 +622,99 @@  discard block
 block discarded – undo
622 622
 			/** Extension Settings */
623 623
 			'addons'      => array(
624 624
 				'id'         => 'addons',
625
-				'give_title' => esc_html__( 'Give Add-ons Settings', 'give' ),
626
-				'show_on'    => array( 'key' => 'options-page', 'value' => array( $this->key ) ),
627
-				'fields'     => apply_filters( 'give_settings_addons', array()
625
+				'give_title' => esc_html__('Give Add-ons Settings', 'give'),
626
+				'show_on'    => array('key' => 'options-page', 'value' => array($this->key)),
627
+				'fields'     => apply_filters('give_settings_addons', array()
628 628
 				),
629 629
 			),
630 630
 			/** Licenses Settings */
631 631
 			'licenses'    => array(
632 632
 				'id'         => 'licenses',
633
-				'give_title' => esc_html__( 'Give Licenses', 'give' ),
634
-				'show_on'    => array( 'key' => 'options-page', 'value' => array( $this->key ) ),
635
-				'fields'     => apply_filters( 'give_settings_licenses', array()
633
+				'give_title' => esc_html__('Give Licenses', 'give'),
634
+				'show_on'    => array('key' => 'options-page', 'value' => array($this->key)),
635
+				'fields'     => apply_filters('give_settings_licenses', array()
636 636
 				),
637 637
 			),
638 638
 			/** Advanced Options */
639 639
 			'advanced'    => array(
640 640
 				'id'         => 'advanced_options',
641
-				'give_title' => esc_html__( 'Advanced Options', 'give' ),
642
-				'show_on'    => array( 'key' => 'options-page', 'value' => array( $this->key ) ),
643
-				'fields'     => apply_filters( 'give_settings_advanced', array(
641
+				'give_title' => esc_html__('Advanced Options', 'give'),
642
+				'show_on'    => array('key' => 'options-page', 'value' => array($this->key)),
643
+				'fields'     => apply_filters('give_settings_advanced', array(
644 644
 						array(
645
-							'name' => esc_html__( 'Access Control', 'give' ),
645
+							'name' => esc_html__('Access Control', 'give'),
646 646
 							'desc' => '',
647 647
 							'id'   => 'give_title_session_control_1',
648 648
 							'type' => 'give_title',
649 649
 						),
650 650
 						array(
651 651
 							'id'      => 'session_lifetime',
652
-							'name'    => esc_html__( 'Session Lifetime', 'give' ),
653
-							'desc'    => esc_html__( 'The length of time a user\'s session is kept alive. Give starts a new session per user upon donation. Sessions allow donors to view their donation receipts without being logged in.', 'give' ),
652
+							'name'    => esc_html__('Session Lifetime', 'give'),
653
+							'desc'    => esc_html__('The length of time a user\'s session is kept alive. Give starts a new session per user upon donation. Sessions allow donors to view their donation receipts without being logged in.', 'give'),
654 654
 							'type'    => 'select',
655 655
 							'options' => array(
656
-								'86400'  => esc_html__( '24 Hours', 'give' ),
657
-								'172800' => esc_html__( '48 Hours', 'give' ),
658
-								'259200' => esc_html__( '72 Hours', 'give' ),
659
-								'604800' => esc_html__( '1 Week', 'give' ),
656
+								'86400'  => esc_html__('24 Hours', 'give'),
657
+								'172800' => esc_html__('48 Hours', 'give'),
658
+								'259200' => esc_html__('72 Hours', 'give'),
659
+								'604800' => esc_html__('1 Week', 'give'),
660 660
 							),
661 661
 						),
662 662
 						array(
663
-							'name' => esc_html__( 'Email Access', 'give' ),
664
-							'desc' => esc_html__( 'Would you like your donors to be able to access their donation history using only email? Donors whose sessions have expired and do not have an account may still access their donation history via a temporary email access link.', 'give' ),
663
+							'name' => esc_html__('Email Access', 'give'),
664
+							'desc' => esc_html__('Would you like your donors to be able to access their donation history using only email? Donors whose sessions have expired and do not have an account may still access their donation history via a temporary email access link.', 'give'),
665 665
 							'id'   => 'email_access',
666 666
 							'type' => 'checkbox',
667 667
 						),
668 668
 						array(
669 669
 							'id'      => 'recaptcha_key',
670
-							'name'    => esc_html__( 'reCAPTCHA Site Key', 'give' ),
670
+							'name'    => esc_html__('reCAPTCHA Site Key', 'give'),
671 671
 							/* translators: %s: https://www.google.com/recaptcha/ */
672
-							'desc'    => sprintf( __( 'If you would like to prevent spam on the email access form navigate to <a href="%s" target="_blank">the reCAPTCHA website</a> and sign up for an API key. The reCAPTCHA uses Google\'s user-friendly single click verification method.', 'give' ), esc_url( 'https://www.google.com/recaptcha/' ) ),
672
+							'desc'    => sprintf(__('If you would like to prevent spam on the email access form navigate to <a href="%s" target="_blank">the reCAPTCHA website</a> and sign up for an API key. The reCAPTCHA uses Google\'s user-friendly single click verification method.', 'give'), esc_url('https://www.google.com/recaptcha/')),
673 673
 							'default' => '',
674 674
 							'type'    => 'text',
675 675
 						),
676 676
 						array(
677 677
 							'id'      => 'recaptcha_secret',
678
-							'name'    => esc_html__( 'reCAPTCHA Secret Key', 'give' ),
679
-							'desc'    => esc_html__( 'Please paste the reCAPTCHA secret key here from your manage reCAPTCHA API Keys panel.', 'give' ),
678
+							'name'    => esc_html__('reCAPTCHA Secret Key', 'give'),
679
+							'desc'    => esc_html__('Please paste the reCAPTCHA secret key here from your manage reCAPTCHA API Keys panel.', 'give'),
680 680
 							'default' => '',
681 681
 							'type'    => 'text',
682 682
 						),
683 683
 						array(
684
-							'name' => esc_html__( 'Data Control', 'give' ),
684
+							'name' => esc_html__('Data Control', 'give'),
685 685
 							'desc' => '',
686 686
 							'id'   => 'give_title_data_control_2',
687 687
 							'type' => 'give_title',
688 688
 						),
689 689
 						array(
690
-							'name' => esc_html__( 'Remove All Data on Uninstall?', 'give' ),
691
-							'desc' => esc_html__( 'When the plugin is deleted, completely remove all Give data.', 'give' ),
690
+							'name' => esc_html__('Remove All Data on Uninstall?', 'give'),
691
+							'desc' => esc_html__('When the plugin is deleted, completely remove all Give data.', 'give'),
692 692
 							'id'   => 'uninstall_on_delete',
693 693
 							'type' => 'checkbox',
694 694
 						),
695 695
 						array(
696
-							'name' => esc_html__( 'Filter Control', 'give' ),
696
+							'name' => esc_html__('Filter Control', 'give'),
697 697
 							'desc' => '',
698 698
 							'id'   => 'give_title_filter_control',
699 699
 							'type' => 'give_title',
700 700
 						),
701 701
 						array(
702 702
 							/* translators: %s: the_content */
703
-							'name' => sprintf( __( 'Disable %s filter', 'give' ), '<code>the_content</code>' ),
703
+							'name' => sprintf(__('Disable %s filter', 'give'), '<code>the_content</code>'),
704 704
 							/* translators: 1: https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content 2: the_content */
705
-							'desc' => sprintf( __( 'If you are seeing extra social buttons, related posts, or other unwanted elements appearing within your forms then you can disable WordPress\' content filter. <a href="%1$s" target="_blank">Learn more</a> about %2$s filter.', 'give' ), esc_url( 'https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content' ), '<code>the_content</code>' ),
705
+							'desc' => sprintf(__('If you are seeing extra social buttons, related posts, or other unwanted elements appearing within your forms then you can disable WordPress\' content filter. <a href="%1$s" target="_blank">Learn more</a> about %2$s filter.', 'give'), esc_url('https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content'), '<code>the_content</code>'),
706 706
 							'id'   => 'disable_the_content_filter',
707 707
 							'type' => 'checkbox',
708 708
 						),
709 709
 						array(
710
-							'name' => esc_html__( 'Script Loading', 'give' ),
710
+							'name' => esc_html__('Script Loading', 'give'),
711 711
 							'desc' => '',
712 712
 							'id'   => 'give_title_script_control',
713 713
 							'type' => 'give_title',
714 714
 						),
715 715
 						array(
716
-							'name' => esc_html__( 'Load Scripts in Footer?', 'give' ),
717
-							'desc' => esc_html__( 'Check this box if you would like Give to load all frontend JavaScript files in the footer.', 'give' ),
716
+							'name' => esc_html__('Load Scripts in Footer?', 'give'),
717
+							'desc' => esc_html__('Check this box if you would like Give to load all frontend JavaScript files in the footer.', 'give'),
718 718
 							'id'   => 'scripts_footer',
719 719
 							'type' => 'checkbox',
720 720
 						),
@@ -724,13 +724,13 @@  discard block
 block discarded – undo
724 724
 			/** API Settings */
725 725
 			'api'         => array(
726 726
 				'id'         => 'api',
727
-				'give_title' => esc_html__( 'API', 'give' ),
728
-				'show_on'    => array( 'key' => 'options-page', 'value' => array( $this->key ) ),
727
+				'give_title' => esc_html__('API', 'give'),
728
+				'show_on'    => array('key' => 'options-page', 'value' => array($this->key)),
729 729
 				'show_names' => false, // Hide field names on the left
730
-				'fields'     => apply_filters( 'give_settings_system', array(
730
+				'fields'     => apply_filters('give_settings_system', array(
731 731
 						array(
732 732
 							'id'   => 'api',
733
-							'name' => esc_html__( 'API', 'give' ),
733
+							'name' => esc_html__('API', 'give'),
734 734
 							'type' => 'api',
735 735
 						),
736 736
 					)
@@ -739,13 +739,13 @@  discard block
 block discarded – undo
739 739
 			/** Licenses Settings */
740 740
 			'system_info' => array(
741 741
 				'id'         => 'system_info',
742
-				'give_title' => esc_html__( 'System Info', 'give' ),
743
-				'show_on'    => array( 'key' => 'options-page', 'value' => array( $this->key ) ),
744
-				'fields'     => apply_filters( 'give_settings_system', array(
742
+				'give_title' => esc_html__('System Info', 'give'),
743
+				'show_on'    => array('key' => 'options-page', 'value' => array($this->key)),
744
+				'fields'     => apply_filters('give_settings_system', array(
745 745
 						array(
746 746
 							'id'   => 'system-info-textarea',
747
-							'name' => esc_html__( 'System Info', 'give' ),
748
-							'desc' => esc_html__( 'Please copy and paste this information in your ticket when contacting support.', 'give' ),
747
+							'name' => esc_html__('System Info', 'give'),
748
+							'desc' => esc_html__('Please copy and paste this information in your ticket when contacting support.', 'give'),
749 749
 							'type' => 'system_info',
750 750
 						),
751 751
 					)
@@ -753,15 +753,15 @@  discard block
 block discarded – undo
753 753
 			),
754 754
 		);
755 755
 
756
-		$give_settings = apply_filters( 'give_registered_settings', $give_settings );
756
+		$give_settings = apply_filters('give_registered_settings', $give_settings);
757 757
 
758 758
 		// Return all settings array if no active tab
759
-		if ( empty( $active_tab ) || ! isset( $give_settings[ $active_tab ] ) ) {
759
+		if (empty($active_tab) || ! isset($give_settings[$active_tab])) {
760 760
 			return $give_settings;
761 761
 		}
762 762
 
763 763
 		// Add other tabs and settings fields as needed
764
-		return $give_settings[ $active_tab ];
764
+		return $give_settings[$active_tab];
765 765
 
766 766
 	}
767 767
 
@@ -770,11 +770,11 @@  discard block
 block discarded – undo
770 770
 	 */
771 771
 	public function settings_notices() {
772 772
 
773
-		if ( ! isset( $_POST['give_settings_saved'] ) ) {
773
+		if ( ! isset($_POST['give_settings_saved'])) {
774 774
 			return;
775 775
 		}
776 776
 
777
-		add_settings_error( 'give-notices', 'global-settings-updated', esc_html__( 'Settings updated.', 'give' ), 'updated' );
777
+		add_settings_error('give-notices', 'global-settings-updated', esc_html__('Settings updated.', 'give'), 'updated');
778 778
 
779 779
 	}
780 780
 
@@ -789,14 +789,14 @@  discard block
 block discarded – undo
789 789
 	 * @return mixed         Field value or exception is thrown.
790 790
 	 * @throws Exception     Throws an exception if the field is invalid.
791 791
 	 */
792
-	public function __get( $field ) {
792
+	public function __get($field) {
793 793
 
794 794
 		// Allowed fields to retrieve
795
-		if ( in_array( $field, array( 'key', 'fields', 'give_title', 'options_page' ), true ) ) {
795
+		if (in_array($field, array('key', 'fields', 'give_title', 'options_page'), true)) {
796 796
 			return $this->{$field};
797 797
 		}
798 798
 
799
-		throw new Exception( sprintf( esc_html__( 'Invalid property: %s', 'give' ), $field ) );
799
+		throw new Exception(sprintf(esc_html__('Invalid property: %s', 'give'), $field));
800 800
 	}
801 801
 
802 802
 
@@ -815,12 +815,12 @@  discard block
 block discarded – undo
815 815
  *
816 816
  * @return mixed        Option value
817 817
  */
818
-function give_get_option( $key = '', $default = false ) {
818
+function give_get_option($key = '', $default = false) {
819 819
 	$give_options = give_get_settings();
820
-	$value        = ! empty( $give_options[ $key ] ) ? $give_options[ $key ] : $default;
821
-	$value        = apply_filters( 'give_get_option', $value, $key, $default );
820
+	$value        = ! empty($give_options[$key]) ? $give_options[$key] : $default;
821
+	$value        = apply_filters('give_get_option', $value, $key, $default);
822 822
 
823
-	return apply_filters( "give_get_option_{$key}", $value, $key, $default );
823
+	return apply_filters("give_get_option_{$key}", $value, $key, $default);
824 824
 }
825 825
 
826 826
 
@@ -838,33 +838,33 @@  discard block
 block discarded – undo
838 838
  *
839 839
  * @return boolean True if updated, false if not.
840 840
  */
841
-function give_update_option( $key = '', $value = false ) {
841
+function give_update_option($key = '', $value = false) {
842 842
 
843 843
 	// If no key, exit
844
-	if ( empty( $key ) ) {
844
+	if (empty($key)) {
845 845
 		return false;
846 846
 	}
847 847
 
848
-	if ( empty( $value ) ) {
849
-		$remove_option = give_delete_option( $key );
848
+	if (empty($value)) {
849
+		$remove_option = give_delete_option($key);
850 850
 
851 851
 		return $remove_option;
852 852
 	}
853 853
 
854 854
 	// First let's grab the current settings
855
-	$options = get_option( 'give_settings' );
855
+	$options = get_option('give_settings');
856 856
 
857 857
 	// Let's let devs alter that value coming in
858
-	$value = apply_filters( 'give_update_option', $value, $key );
858
+	$value = apply_filters('give_update_option', $value, $key);
859 859
 
860 860
 	// Next let's try to update the value
861
-	$options[ $key ] = $value;
862
-	$did_update      = update_option( 'give_settings', $options );
861
+	$options[$key] = $value;
862
+	$did_update      = update_option('give_settings', $options);
863 863
 
864 864
 	// If it updated, let's update the global variable
865
-	if ( $did_update ) {
865
+	if ($did_update) {
866 866
 		global $give_options;
867
-		$give_options[ $key ] = $value;
867
+		$give_options[$key] = $value;
868 868
 	}
869 869
 
870 870
 	return $did_update;
@@ -883,25 +883,25 @@  discard block
 block discarded – undo
883 883
  *
884 884
  * @return boolean True if updated, false if not.
885 885
  */
886
-function give_delete_option( $key = '' ) {
886
+function give_delete_option($key = '') {
887 887
 
888 888
 	// If no key, exit
889
-	if ( empty( $key ) ) {
889
+	if (empty($key)) {
890 890
 		return false;
891 891
 	}
892 892
 
893 893
 	// First let's grab the current settings
894
-	$options = get_option( 'give_settings' );
894
+	$options = get_option('give_settings');
895 895
 
896 896
 	// Next let's try to update the value
897
-	if ( isset( $options[ $key ] ) ) {
898
-		unset( $options[ $key ] );
897
+	if (isset($options[$key])) {
898
+		unset($options[$key]);
899 899
 	}
900 900
 
901
-	$did_update = update_option( 'give_settings', $options );
901
+	$did_update = update_option('give_settings', $options);
902 902
 
903 903
 	// If it updated, let's update the global variable
904
-	if ( $did_update ) {
904
+	if ($did_update) {
905 905
 		global $give_options;
906 906
 		$give_options = $options;
907 907
 	}
@@ -920,9 +920,9 @@  discard block
 block discarded – undo
920 920
  */
921 921
 function give_get_settings() {
922 922
 
923
-	$settings = get_option( 'give_settings' );
923
+	$settings = get_option('give_settings');
924 924
 
925
-	return (array) apply_filters( 'give_get_settings', $settings );
925
+	return (array) apply_filters('give_get_settings', $settings);
926 926
 
927 927
 }
928 928
 
@@ -940,25 +940,25 @@  discard block
 block discarded – undo
940 940
  *
941 941
  * @return array
942 942
  */
943
-function give_settings_array_insert( $array, $position, $insert ) {
944
-	if ( is_int( $position ) ) {
945
-		array_splice( $array, $position, 0, $insert );
943
+function give_settings_array_insert($array, $position, $insert) {
944
+	if (is_int($position)) {
945
+		array_splice($array, $position, 0, $insert);
946 946
 	} else {
947 947
 
948
-		foreach ( $array as $index => $subarray ) {
949
-			if ( isset( $subarray['id'] ) && $subarray['id'] == $position ) {
948
+		foreach ($array as $index => $subarray) {
949
+			if (isset($subarray['id']) && $subarray['id'] == $position) {
950 950
 				$pos = $index;
951 951
 			}
952 952
 		}
953 953
 
954
-		if ( ! isset( $pos ) ) {
954
+		if ( ! isset($pos)) {
955 955
 			return $array;
956 956
 		}
957 957
 
958 958
 		$array = array_merge(
959
-			array_slice( $array, 0, $pos ),
959
+			array_slice($array, 0, $pos),
960 960
 			$insert,
961
-			array_slice( $array, $pos )
961
+			array_slice($array, $pos)
962 962
 		);
963 963
 	}
964 964
 
@@ -978,23 +978,23 @@  discard block
 block discarded – undo
978 978
  *
979 979
  * @return void
980 980
  */
981
-function give_enabled_gateways_callback( $field_arr, $saved_values = array() ) {
981
+function give_enabled_gateways_callback($field_arr, $saved_values = array()) {
982 982
 
983 983
 	$id       = $field_arr['id'];
984
-	$gateways = give_get_ordered_payment_gateways( give_get_payment_gateways() );
984
+	$gateways = give_get_ordered_payment_gateways(give_get_payment_gateways());
985 985
 
986 986
 	echo '<ul class="give-checklist-fields give-payment-gatways-list">';
987 987
 
988
-	foreach ( $gateways as $key => $option ) :
988
+	foreach ($gateways as $key => $option) :
989 989
 
990
-		if ( is_array( $saved_values ) && array_key_exists( $key, $saved_values ) ) {
990
+		if (is_array($saved_values) && array_key_exists($key, $saved_values)) {
991 991
 			$enabled = '1';
992 992
 		} else {
993 993
 			$enabled = null;
994 994
 		}
995 995
 
996
-		echo '<li><span class="give-drag-handle"><span class="dashicons dashicons-menu"></span></span><input name="' . $id . '[' . $key . ']" id="' . $id . '[' . $key . ']" type="checkbox" value="1" ' . checked( '1', $enabled, false ) . '/>&nbsp;';
997
-		echo '<label for="' . $id . '[' . $key . ']">' . $option['admin_label'] . '</label></li>';
996
+		echo '<li><span class="give-drag-handle"><span class="dashicons dashicons-menu"></span></span><input name="'.$id.'['.$key.']" id="'.$id.'['.$key.']" type="checkbox" value="1" '.checked('1', $enabled, false).'/>&nbsp;';
997
+		echo '<label for="'.$id.'['.$key.']">'.$option['admin_label'].'</label></li>';
998 998
 
999 999
 	endforeach;
1000 1000
 
@@ -1013,16 +1013,16 @@  discard block
 block discarded – undo
1013 1013
  *
1014 1014
  * @return void
1015 1015
  */
1016
-function give_default_gateway_callback( $field_arr, $saved_value ) {
1016
+function give_default_gateway_callback($field_arr, $saved_value) {
1017 1017
 	$id          = $field_arr['id'];
1018 1018
 	$gateways    = give_get_enabled_payment_gateways();
1019
-	$saved_value = give_get_default_gateway( null );
1019
+	$saved_value = give_get_default_gateway(null);
1020 1020
 
1021
-	echo '<select class="give-select" name="' . $id . '" id="' . $id . '">';
1021
+	echo '<select class="give-select" name="'.$id.'" id="'.$id.'">';
1022 1022
 
1023
-	foreach ( $gateways as $key => $option ) :
1024
-		$selected = isset( $saved_value ) ? selected( $key, $saved_value, false ) : '';
1025
-		echo '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
1023
+	foreach ($gateways as $key => $option) :
1024
+		$selected = isset($saved_value) ? selected($key, $saved_value, false) : '';
1025
+		echo '<option value="'.esc_attr($key).'"'.$selected.'>'.esc_html($option['admin_label']).'</option>';
1026 1026
 	endforeach;
1027 1027
 
1028 1028
 	echo '</select>';
@@ -1040,13 +1040,13 @@  discard block
 block discarded – undo
1040 1040
  *
1041 1041
  * @return void
1042 1042
  */
1043
-function give_title_callback( $field_object, $escaped_value, $object_id, $object_type, $field_type_object ) {
1043
+function give_title_callback($field_object, $escaped_value, $object_id, $object_type, $field_type_object) {
1044 1044
 
1045 1045
 	$id                = $field_type_object->field->args['id'];
1046 1046
 	$title             = $field_type_object->field->args['name'];
1047 1047
 	$field_description = $field_type_object->field->args['desc'];
1048 1048
 
1049
-	echo '<hr>' . $field_description;
1049
+	echo '<hr>'.$field_description;
1050 1050
 
1051 1051
 }
1052 1052
 
@@ -1061,7 +1061,7 @@  discard block
 block discarded – undo
1061 1061
  *
1062 1062
  * @return void
1063 1063
  */
1064
-function give_description_callback( $field_object, $escaped_value, $object_id, $object_type, $field_type_object ) {
1064
+function give_description_callback($field_object, $escaped_value, $object_id, $object_type, $field_type_object) {
1065 1065
 
1066 1066
 	$id                = $field_type_object->field->args['id'];
1067 1067
 	$title             = $field_type_object->field->args['name'];
@@ -1080,25 +1080,25 @@  discard block
 block discarded – undo
1080 1080
  * @see: https://github.com/WebDevStudios/CMB2/wiki/Adding-your-own-field-types
1081 1081
  * @return array An array of options that matches the CMB2 options array
1082 1082
  */
1083
-function give_cmb2_get_post_options( $query_args, $force = false ) {
1083
+function give_cmb2_get_post_options($query_args, $force = false) {
1084 1084
 
1085
-	$post_options = array( '' => '' ); // Blank option
1085
+	$post_options = array('' => ''); // Blank option
1086 1086
 
1087
-	if ( ( ! isset( $_GET['page'] ) || 'give-settings' != $_GET['page'] ) && ! $force ) {
1087
+	if (( ! isset($_GET['page']) || 'give-settings' != $_GET['page']) && ! $force) {
1088 1088
 		return $post_options;
1089 1089
 	}
1090 1090
 
1091
-	$args = wp_parse_args( $query_args, array(
1091
+	$args = wp_parse_args($query_args, array(
1092 1092
 		'post_type'   => 'page',
1093 1093
 		'numberposts' => 10,
1094
-	) );
1094
+	));
1095 1095
 
1096
-	$posts = get_posts( $args );
1096
+	$posts = get_posts($args);
1097 1097
 
1098
-	if ( $posts ) {
1099
-		foreach ( $posts as $post ) {
1098
+	if ($posts) {
1099
+		foreach ($posts as $post) {
1100 1100
 
1101
-			$post_options[ $post->ID ] = $post->post_title;
1101
+			$post_options[$post->ID] = $post->post_title;
1102 1102
 
1103 1103
 		}
1104 1104
 	}
@@ -1124,20 +1124,20 @@  discard block
 block discarded – undo
1124 1124
 	$get_sizes = get_intermediate_image_sizes();
1125 1125
 
1126 1126
 	// check whether intermediate image sizes exist first
1127
-	if ( empty( $get_sizes ) ) {
1128
-		$get_sizes = array( 'thumbnail', 'medium', 'medium_large', 'large' );
1127
+	if (empty($get_sizes)) {
1128
+		$get_sizes = array('thumbnail', 'medium', 'medium_large', 'large');
1129 1129
 	}
1130 1130
 
1131
-	foreach ( $get_sizes as $_size ) {
1131
+	foreach ($get_sizes as $_size) {
1132 1132
 
1133
-		if ( in_array( $_size, array( 'thumbnail', 'medium', 'medium_large', 'large' ) ) ) {
1134
-			$sizes[ $_size ] = $_size . ' - ' . get_option( "{$_size}_size_w" ) . 'x' . get_option( "{$_size}_size_h" );
1135
-		} elseif ( isset( $_wp_additional_image_sizes[ $_size ] ) ) {
1136
-			$sizes[ $_size ] = $_size . ' - ' . $_wp_additional_image_sizes[ $_size ]['width'] . 'x' . $_wp_additional_image_sizes[ $_size ]['height'];
1133
+		if (in_array($_size, array('thumbnail', 'medium', 'medium_large', 'large'))) {
1134
+			$sizes[$_size] = $_size.' - '.get_option("{$_size}_size_w").'x'.get_option("{$_size}_size_h");
1135
+		} elseif (isset($_wp_additional_image_sizes[$_size])) {
1136
+			$sizes[$_size] = $_size.' - '.$_wp_additional_image_sizes[$_size]['width'].'x'.$_wp_additional_image_sizes[$_size]['height'];
1137 1137
 		}
1138 1138
 	}
1139 1139
 
1140
-	return apply_filters( 'give_get_featured_image_sizes', $sizes );
1140
+	return apply_filters('give_get_featured_image_sizes', $sizes);
1141 1141
 }
1142 1142
 
1143 1143
 
@@ -1152,18 +1152,18 @@  discard block
 block discarded – undo
1152 1152
  *
1153 1153
  * @return void
1154 1154
  */
1155
-function give_license_key_callback( $field_object, $escaped_value, $object_id, $object_type, $field_type_object ) {
1155
+function give_license_key_callback($field_object, $escaped_value, $object_id, $object_type, $field_type_object) {
1156 1156
 	/* @var CMB2_Types $field_type_object */
1157 1157
 
1158 1158
 	$id                 = $field_type_object->field->args['id'];
1159 1159
 	$field_description  = $field_type_object->field->args['desc'];
1160 1160
 	$license            = $field_type_object->field->args['options']['license'];
1161 1161
 	$license_key        = $escaped_value;
1162
-	$is_license_key     = apply_filters( 'give_is_license_key', ( is_object( $license ) && ! empty( $license ) ) );
1163
-	$is_valid_license   = apply_filters( 'give_is_valid_license', ( $is_license_key && property_exists( $license, 'license' ) && 'valid' === $license->license ) );
1162
+	$is_license_key     = apply_filters('give_is_license_key', (is_object($license) && ! empty($license)));
1163
+	$is_valid_license   = apply_filters('give_is_valid_license', ($is_license_key && property_exists($license, 'license') && 'valid' === $license->license));
1164 1164
 	$shortname          = $field_type_object->field->args['options']['shortname'];
1165 1165
 	$field_classes      = 'regular-text give-license-field';
1166
-	$type               = empty( $escaped_value ) || ! $is_valid_license ? 'text' : 'password';
1166
+	$type               = empty($escaped_value) || ! $is_valid_license ? 'text' : 'password';
1167 1167
 	$custom_html        = '';
1168 1168
 	$messages           = array();
1169 1169
 	$class              = '';
@@ -1175,135 +1175,135 @@  discard block
 block discarded – undo
1175 1175
 
1176 1176
 	// By default query on edd api url will return license object which contain status and message property, this can break below functionality.
1177 1177
 	// To combat that check if status is set to error or not, if yes then set $is_license_key to false.
1178
-	if ( $is_license_key && property_exists( $license, 'status' ) && 'error' === $license->status ) {
1178
+	if ($is_license_key && property_exists($license, 'status') && 'error' === $license->status) {
1179 1179
 		$is_license_key = false;
1180 1180
 	}
1181 1181
 
1182 1182
 	// Check if current license is part of subscription or not.
1183
-	$subscriptions = get_option( 'give_subscriptions' );
1183
+	$subscriptions = get_option('give_subscriptions');
1184 1184
 
1185
-	if ( $is_license_key && $subscriptions ) {
1186
-		foreach ( $subscriptions as $subscription ) {
1187
-			if ( in_array( $license_key, $subscription['licenses'] ) ) {
1185
+	if ($is_license_key && $subscriptions) {
1186
+		foreach ($subscriptions as $subscription) {
1187
+			if (in_array($license_key, $subscription['licenses'])) {
1188 1188
 				$is_in_subscription = $subscription['id'];
1189 1189
 				break;
1190 1190
 			}
1191 1191
 		}
1192 1192
 	}
1193 1193
 
1194
-	if ( $is_license_key ) {
1195
-		if ( $is_in_subscription ) {
1196
-			$subscription_expires = strtotime( $subscriptions[ $is_in_subscription ]['expires'] );
1197
-			$subscription_status  = esc_html__( 'renew', 'give' );
1194
+	if ($is_license_key) {
1195
+		if ($is_in_subscription) {
1196
+			$subscription_expires = strtotime($subscriptions[$is_in_subscription]['expires']);
1197
+			$subscription_status  = esc_html__('renew', 'give');
1198 1198
 
1199
-			if ( ( 'active' !== $subscriptions[ $is_in_subscription ]['status'] ) ) {
1200
-				$subscription_status = esc_html__( 'expire', 'give' );
1199
+			if (('active' !== $subscriptions[$is_in_subscription]['status'])) {
1200
+				$subscription_status = esc_html__('expire', 'give');
1201 1201
 			}
1202 1202
 
1203
-			if ( $subscription_expires < current_time( 'timestamp', 1 ) ) {
1204
-				$messages[]     = sprintf(
1205
-					__( 'Your subscription (<a href="%1$s" target="_blank">#%2$d</a>) expired. Please <a href="%3$s" target="_blank" title="Renew your license key">renew your license key</a>', 'give' ),
1206
-					urldecode( $subscriptions[ $is_in_subscription ]['invoice_url'] ),
1207
-					$subscriptions[ $is_in_subscription ]['payment_id'],
1208
-					$checkout_page_link . '?edd_license_key=' . $subscriptions[ $is_in_subscription ]['license_key'] . '&utm_campaign=admin&utm_source=licenses&utm_medium=expired'
1203
+			if ($subscription_expires < current_time('timestamp', 1)) {
1204
+				$messages[] = sprintf(
1205
+					__('Your subscription (<a href="%1$s" target="_blank">#%2$d</a>) expired. Please <a href="%3$s" target="_blank" title="Renew your license key">renew your license key</a>', 'give'),
1206
+					urldecode($subscriptions[$is_in_subscription]['invoice_url']),
1207
+					$subscriptions[$is_in_subscription]['payment_id'],
1208
+					$checkout_page_link.'?edd_license_key='.$subscriptions[$is_in_subscription]['license_key'].'&utm_campaign=admin&utm_source=licenses&utm_medium=expired'
1209 1209
 				);
1210 1210
 				$license_status = 'license-expired';
1211
-			} elseif ( strtotime( '- 7 days', $subscription_expires ) < current_time( 'timestamp', 1 ) ) {
1211
+			} elseif (strtotime('- 7 days', $subscription_expires) < current_time('timestamp', 1)) {
1212 1212
 				$messages[]     = sprintf(
1213
-					__( 'Your subscription (<a href="%1$s" target="_blank">#%2$d</a>) will %3$s in %4$s.', 'give' ),
1214
-					urldecode( $subscriptions[ $is_in_subscription ]['invoice_url'] ),
1215
-					$subscriptions[ $is_in_subscription ]['payment_id'],
1213
+					__('Your subscription (<a href="%1$s" target="_blank">#%2$d</a>) will %3$s in %4$s.', 'give'),
1214
+					urldecode($subscriptions[$is_in_subscription]['invoice_url']),
1215
+					$subscriptions[$is_in_subscription]['payment_id'],
1216 1216
 					$subscription_status,
1217
-					human_time_diff( current_time( 'timestamp', 1 ), strtotime( $subscriptions[ $is_in_subscription ]['expires'] ) )
1217
+					human_time_diff(current_time('timestamp', 1), strtotime($subscriptions[$is_in_subscription]['expires']))
1218 1218
 				);
1219 1219
 				$license_status = 'license-expires-soon';
1220 1220
 			} else {
1221 1221
 				$messages[]     = sprintf(
1222
-					__( 'Your subscription (<a href="%1$s" target="_blank">#%2$d</a>) will %3$s on %4$s.', 'give' ),
1223
-					urldecode( $subscriptions[ $is_in_subscription ]['invoice_url'] ),
1224
-					$subscriptions[ $is_in_subscription ]['payment_id'],
1222
+					__('Your subscription (<a href="%1$s" target="_blank">#%2$d</a>) will %3$s on %4$s.', 'give'),
1223
+					urldecode($subscriptions[$is_in_subscription]['invoice_url']),
1224
+					$subscriptions[$is_in_subscription]['payment_id'],
1225 1225
 					$subscription_status,
1226
-					date_i18n( get_option( 'date_format' ), strtotime( $subscriptions[ $is_in_subscription ]['expires'], current_time( 'timestamp' ) ) )
1226
+					date_i18n(get_option('date_format'), strtotime($subscriptions[$is_in_subscription]['expires'], current_time('timestamp')))
1227 1227
 				);
1228 1228
 				$license_status = 'license-expiration-date';
1229 1229
 			}
1230
-		} elseif ( empty( $license->success ) && property_exists( $license, 'error' ) ) {
1230
+		} elseif (empty($license->success) && property_exists($license, 'error')) {
1231 1231
 
1232 1232
 			// activate_license 'invalid' on anything other than valid, so if there was an error capture it
1233
-			switch ( $license->error ) {
1233
+			switch ($license->error) {
1234 1234
 				case 'expired' :
1235 1235
 					$class          = $license->error;
1236 1236
 					$messages[]     = sprintf(
1237
-						__( 'Your license key expired on %1$s. Please <a href="%2$s" target="_blank" title="Renew your license key">renew your license key</a>.', 'give' ),
1238
-						date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ),
1239
-						$checkout_page_link . '?edd_license_key=' . $license_key . '&utm_campaign=admin&utm_source=licenses&utm_medium=expired'
1237
+						__('Your license key expired on %1$s. Please <a href="%2$s" target="_blank" title="Renew your license key">renew your license key</a>.', 'give'),
1238
+						date_i18n(get_option('date_format'), strtotime($license->expires, current_time('timestamp'))),
1239
+						$checkout_page_link.'?edd_license_key='.$license_key.'&utm_campaign=admin&utm_source=licenses&utm_medium=expired'
1240 1240
 					);
1241
-					$license_status = 'license-' . $class;
1241
+					$license_status = 'license-'.$class;
1242 1242
 					break;
1243 1243
 
1244 1244
 				case 'missing' :
1245 1245
 					$class          = $license->error;
1246 1246
 					$messages[]     = sprintf(
1247
-						__( 'Invalid license. Please <a href="%s" target="_blank" title="Visit account page">visit your account page</a> and verify it.', 'give' ),
1248
-						$account_page_link . '?utm_campaign=admin&utm_source=licenses&utm_medium=missing'
1247
+						__('Invalid license. Please <a href="%s" target="_blank" title="Visit account page">visit your account page</a> and verify it.', 'give'),
1248
+						$account_page_link.'?utm_campaign=admin&utm_source=licenses&utm_medium=missing'
1249 1249
 					);
1250
-					$license_status = 'license-' . $class;
1250
+					$license_status = 'license-'.$class;
1251 1251
 					break;
1252 1252
 
1253 1253
 				case 'invalid' :
1254 1254
 					$class          = $license->error;
1255 1255
 					$messages[]     = sprintf(
1256
-						__( 'Your %1$s is not active for this URL. Please <a href="%2$s" target="_blank" title="Visit account page">visit your account page</a> to manage your license key URLs.', 'give' ),
1256
+						__('Your %1$s is not active for this URL. Please <a href="%2$s" target="_blank" title="Visit account page">visit your account page</a> to manage your license key URLs.', 'give'),
1257 1257
 						$addon_name,
1258
-						$account_page_link . '?utm_campaign=admin&utm_source=licenses&utm_medium=invalid'
1258
+						$account_page_link.'?utm_campaign=admin&utm_source=licenses&utm_medium=invalid'
1259 1259
 					);
1260
-					$license_status = 'license-' . $class;
1260
+					$license_status = 'license-'.$class;
1261 1261
 					break;
1262 1262
 
1263 1263
 				case 'site_inactive' :
1264 1264
 					$class          = $license->error;
1265 1265
 					$messages[]     = sprintf(
1266
-						__( 'Your %1$s is not active for this URL. Please <a href="%2$s" target="_blank" title="Visit account page">visit your account page</a> to manage your license key URLs.', 'give' ),
1266
+						__('Your %1$s is not active for this URL. Please <a href="%2$s" target="_blank" title="Visit account page">visit your account page</a> to manage your license key URLs.', 'give'),
1267 1267
 						$addon_name,
1268
-						$account_page_link . '?utm_campaign=admin&utm_source=licenses&utm_medium=invalid'
1268
+						$account_page_link.'?utm_campaign=admin&utm_source=licenses&utm_medium=invalid'
1269 1269
 					);
1270
-					$license_status = 'license-' . $class;
1270
+					$license_status = 'license-'.$class;
1271 1271
 					break;
1272 1272
 
1273 1273
 				case 'item_name_mismatch' :
1274 1274
 					$class          = $license->error;
1275
-					$messages[]     = sprintf( __( 'This license %1$s does not belong to %2$s.', 'give' ), $license_key, $addon_name );
1276
-					$license_status = 'license-' . $class;
1275
+					$messages[]     = sprintf(__('This license %1$s does not belong to %2$s.', 'give'), $license_key, $addon_name);
1276
+					$license_status = 'license-'.$class;
1277 1277
 					break;
1278 1278
 
1279 1279
 				case 'no_activations_left':
1280 1280
 					$class          = $license->error;
1281
-					$messages[]     = sprintf( __( 'Your license key has reached it\'s activation limit. <a href="%s">View possible upgrades</a> now.', 'give' ), $account_page_link );
1282
-					$license_status = 'license-' . $class;
1281
+					$messages[]     = sprintf(__('Your license key has reached it\'s activation limit. <a href="%s">View possible upgrades</a> now.', 'give'), $account_page_link);
1282
+					$license_status = 'license-'.$class;
1283 1283
 					break;
1284 1284
 			}
1285 1285
 		} else {
1286
-			switch ( $license->license ) {
1286
+			switch ($license->license) {
1287 1287
 				case 'valid' :
1288 1288
 				default:
1289 1289
 					$class      = 'valid';
1290
-					$now        = current_time( 'timestamp' );
1291
-					$expiration = strtotime( $license->expires, current_time( 'timestamp' ) );
1290
+					$now        = current_time('timestamp');
1291
+					$expiration = strtotime($license->expires, current_time('timestamp'));
1292 1292
 
1293
-					if ( 'lifetime' === $license->expires ) {
1294
-						$messages[]     = esc_html__( 'License key never expires.', 'give' );
1293
+					if ('lifetime' === $license->expires) {
1294
+						$messages[]     = esc_html__('License key never expires.', 'give');
1295 1295
 						$license_status = 'license-lifetime-notice';
1296
-					} elseif ( $expiration > $now && $expiration - $now < ( DAY_IN_SECONDS * 30 ) ) {
1296
+					} elseif ($expiration > $now && $expiration - $now < (DAY_IN_SECONDS * 30)) {
1297 1297
 						$messages[]     = sprintf(
1298
-							__( 'Your license key expires soon! It expires on %1$s. <a href="%2$s" target="_blank" title="Renew license">Renew your license key</a>.', 'give' ),
1299
-							date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ),
1300
-							$checkout_page_link . '?edd_license_key=' . $license_key . '&utm_campaign=admin&utm_source=licenses&utm_medium=renew'
1298
+							__('Your license key expires soon! It expires on %1$s. <a href="%2$s" target="_blank" title="Renew license">Renew your license key</a>.', 'give'),
1299
+							date_i18n(get_option('date_format'), strtotime($license->expires, current_time('timestamp'))),
1300
+							$checkout_page_link.'?edd_license_key='.$license_key.'&utm_campaign=admin&utm_source=licenses&utm_medium=renew'
1301 1301
 						);
1302 1302
 						$license_status = 'license-expires-soon';
1303 1303
 					} else {
1304 1304
 						$messages[]     = sprintf(
1305
-							__( 'Your license key expires on %s.', 'give' ),
1306
-							date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) )
1305
+							__('Your license key expires on %s.', 'give'),
1306
+							date_i18n(get_option('date_format'), strtotime($license->expires, current_time('timestamp')))
1307 1307
 						);
1308 1308
 						$license_status = 'license-expiration-date';
1309 1309
 					}
@@ -1311,15 +1311,15 @@  discard block
 block discarded – undo
1311 1311
 			}
1312 1312
 		}
1313 1313
 	} else {
1314
-		$messages[]     = sprintf(
1315
-			__( 'To receive updates, please enter your valid %s license key.', 'give' ),
1314
+		$messages[] = sprintf(
1315
+			__('To receive updates, please enter your valid %s license key.', 'give'),
1316 1316
 			$addon_name
1317 1317
 		);
1318 1318
 		$license_status = 'inactive';
1319 1319
 	}
1320 1320
 
1321 1321
 	// Add class for input field if license is active.
1322
-	if ( $is_valid_license ) {
1322
+	if ($is_valid_license) {
1323 1323
 		$field_classes .= ' give-license-active';
1324 1324
 	}
1325 1325
 
@@ -1327,33 +1327,33 @@  discard block
 block discarded – undo
1327 1327
 	$input_field_html = "<input type=\"{$type}\" name=\"{$id}\" class=\"{$field_classes}\" value=\"{$license_key}\">";
1328 1328
 
1329 1329
 	// If license is active so show deactivate button.
1330
-	if ( $is_valid_license ) {
1330
+	if ($is_valid_license) {
1331 1331
 		// Get input field html.
1332 1332
 		$input_field_html = "<input type=\"{$type}\" name=\"{$id}\" class=\"{$field_classes}\" value=\"{$license_key}\" readonly=\"readonly\">";
1333 1333
 
1334
-		$custom_html = '<input type="submit" class="button button-small give-license-deactivate" name="' . $id . '_deactivate" value="' . esc_attr__( 'Deactivate License', 'give' ) . '"/>';
1334
+		$custom_html = '<input type="submit" class="button button-small give-license-deactivate" name="'.$id.'_deactivate" value="'.esc_attr__('Deactivate License', 'give').'"/>';
1335 1335
 
1336 1336
 	}
1337 1337
 
1338 1338
 	// Field description.
1339
-	$custom_html .= '<label for="give_settings[' . $id . ']"> ' . $field_description . '</label>';
1339
+	$custom_html .= '<label for="give_settings['.$id.']"> '.$field_description.'</label>';
1340 1340
 
1341 1341
 	// If no messages found then inform user that to get updated in future register yourself.
1342
-	if ( empty( $messages ) ) {
1343
-		$messages[] = apply_filters( "{$shortname}_default_addon_notice", esc_html__( 'To receive updates, please enter your valid license key.', 'give' ) );
1342
+	if (empty($messages)) {
1343
+		$messages[] = apply_filters("{$shortname}_default_addon_notice", esc_html__('To receive updates, please enter your valid license key.', 'give'));
1344 1344
 	}
1345 1345
 
1346
-	foreach ( $messages as $message ) {
1347
-		$custom_html .= '<div class="give-license-status-notice give-' . $license_status . '">';
1348
-		$custom_html .= '<p>' . $message . '</p>';
1346
+	foreach ($messages as $message) {
1347
+		$custom_html .= '<div class="give-license-status-notice give-'.$license_status.'">';
1348
+		$custom_html .= '<p>'.$message.'</p>';
1349 1349
 		$custom_html .= '</div>';
1350 1350
 	}
1351 1351
 
1352 1352
 	// Field html.
1353
-	$custom_html = apply_filters( 'give_license_key_field_html', $input_field_html . $custom_html, $field_type_object );
1353
+	$custom_html = apply_filters('give_license_key_field_html', $input_field_html.$custom_html, $field_type_object);
1354 1354
 
1355 1355
 	// Nonce.
1356
-	wp_nonce_field( $id . '-nonce', $id . '-nonce' );
1356
+	wp_nonce_field($id.'-nonce', $id.'-nonce');
1357 1357
 
1358 1358
 	// Print field html.
1359 1359
 	echo "<div class=\"give-license-key\"><label for=\"{$id}\">{$addon_name }</label></div><div class=\"give-license-block\">{$custom_html}</div>";
@@ -1368,7 +1368,7 @@  discard block
 block discarded – undo
1368 1368
  */
1369 1369
 function give_api_callback() {
1370 1370
 
1371
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
1371
+	if ( ! current_user_can('manage_give_settings')) {
1372 1372
 		return;
1373 1373
 	}
1374 1374
 
@@ -1377,9 +1377,9 @@  discard block
 block discarded – undo
1377 1377
 	 *
1378 1378
 	 * @since 1.0
1379 1379
 	 */
1380
-	do_action( 'give_tools_api_keys_before' );
1380
+	do_action('give_tools_api_keys_before');
1381 1381
 
1382
-	require_once GIVE_PLUGIN_DIR . 'includes/admin/class-api-keys-table.php';
1382
+	require_once GIVE_PLUGIN_DIR.'includes/admin/class-api-keys-table.php';
1383 1383
 
1384 1384
 	$api_keys_table = new Give_API_Keys_Table();
1385 1385
 	$api_keys_table->prepare_items();
@@ -1388,9 +1388,9 @@  discard block
 block discarded – undo
1388 1388
 	<span class="cmb2-metabox-description api-description">
1389 1389
 		<?php echo sprintf(
1390 1390
 			/* translators: 1: http://docs.givewp.com/api 2: http://docs.givewp.com/addon-zapier */
1391
-			__( 'You can create API keys for individual users within their profile edit screen. API keys allow users to use the <a href="%1$s" target="_blank">Give REST API</a> to retrieve donation data in JSON or XML for external applications or devices, such as <a href="%2$s" target="_blank">Zapier</a>.', 'give' ),
1392
-			esc_url( 'http://docs.givewp.com/api' ),
1393
-			esc_url( 'http://docs.givewp.com/addon-zapier' )
1391
+			__('You can create API keys for individual users within their profile edit screen. API keys allow users to use the <a href="%1$s" target="_blank">Give REST API</a> to retrieve donation data in JSON or XML for external applications or devices, such as <a href="%2$s" target="_blank">Zapier</a>.', 'give'),
1392
+			esc_url('http://docs.givewp.com/api'),
1393
+			esc_url('http://docs.givewp.com/addon-zapier')
1394 1394
 		); ?>
1395 1395
 	</span>
1396 1396
 	<?php
@@ -1400,10 +1400,10 @@  discard block
 block discarded – undo
1400 1400
 	 *
1401 1401
 	 * @since 1.0
1402 1402
 	 */
1403
-	do_action( 'give_tools_api_keys_after' );
1403
+	do_action('give_tools_api_keys_after');
1404 1404
 }
1405 1405
 
1406
-add_action( 'give_settings_tab_api_keys', 'give_api_callback' );
1406
+add_action('give_settings_tab_api_keys', 'give_api_callback');
1407 1407
 
1408 1408
 /**
1409 1409
  * Hook Callback
@@ -1416,7 +1416,7 @@  discard block
 block discarded – undo
1416 1416
  *
1417 1417
  * @return void
1418 1418
  */
1419
-function give_hook_callback( $args ) {
1419
+function give_hook_callback($args) {
1420 1420
 
1421 1421
 	$id = $args['id'];
1422 1422
 
@@ -1425,7 +1425,7 @@  discard block
 block discarded – undo
1425 1425
 	 *
1426 1426
 	 * @since 1.0
1427 1427
 	 */
1428
-	do_action( "give_{$id}" );
1428
+	do_action("give_{$id}");
1429 1429
 
1430 1430
 }
1431 1431
 
@@ -1440,19 +1440,19 @@  discard block
 block discarded – undo
1440 1440
  *
1441 1441
  * @return bool
1442 1442
  */
1443
-function give_is_setting_enabled( $value, $compare_with = null ) {
1444
-	if ( ! is_null( $compare_with ) ) {
1443
+function give_is_setting_enabled($value, $compare_with = null) {
1444
+	if ( ! is_null($compare_with)) {
1445 1445
 
1446
-		if ( is_array( $compare_with ) ) {
1446
+		if (is_array($compare_with)) {
1447 1447
 			// Output.
1448
-			return in_array( $value, $compare_with );
1448
+			return in_array($value, $compare_with);
1449 1449
 		}
1450 1450
 
1451 1451
 		// Output.
1452
-		return ( $value === $compare_with );
1452
+		return ($value === $compare_with);
1453 1453
 	}
1454 1454
 
1455 1455
 	// Backward compatibility: From version 1.8 most of setting is modified to enabled/disabled
1456 1456
 	// Output.
1457
-	return ( in_array( $value, array( 'enabled', 'on', 'yes' ) ) ? true : false );
1457
+	return (in_array($value, array('enabled', 'on', 'yes')) ? true : false);
1458 1458
 }
Please login to merge, or discard this patch.
includes/admin/class-i18n-module.php 1 patch
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -65,23 +65,23 @@  discard block
 block discarded – undo
65 65
 	 *
66 66
 	 * @param $args
67 67
 	 */
68
-	public function __construct( $args ) {
68
+	public function __construct($args) {
69 69
 
70 70
 		// Only for admins.
71
-		if ( ! is_admin() ) {
71
+		if ( ! is_admin()) {
72 72
 			return;
73 73
 		}
74 74
 
75 75
 		// This plugin is en_US native.
76 76
 		$this->locale = get_locale();
77
-		if ( 'en_US' === $this->locale ) {
77
+		if ('en_US' === $this->locale) {
78 78
 			return;
79 79
 		}
80 80
 
81
-		$this->init( $args );
81
+		$this->init($args);
82 82
 
83
-		if ( ! $this->hide_promo() ) {
84
-			add_action( $this->hook, array( $this, 'promo' ) );
83
+		if ( ! $this->hide_promo()) {
84
+			add_action($this->hook, array($this, 'promo'));
85 85
 		}
86 86
 	}
87 87
 
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
 	 *
93 93
 	 * @param array $args
94 94
 	 */
95
-	private function init( $args ) {
96
-		foreach ( $args as $key => $arg ) {
95
+	private function init($args) {
96
+		foreach ($args as $key => $arg) {
97 97
 			$this->$key = $arg;
98 98
 		}
99 99
 
@@ -107,11 +107,11 @@  discard block
 block discarded – undo
107 107
 	 * @return bool
108 108
 	 */
109 109
 	private function hide_promo() {
110
-		$hide_promo = Give_Cache::get( 'give_i18n_give_promo_hide', true );
111
-		if ( ! $hide_promo ) {
112
-			if ( filter_input( INPUT_GET, 'remove_i18n_promo', FILTER_VALIDATE_INT ) === 1 ) {
110
+		$hide_promo = Give_Cache::get('give_i18n_give_promo_hide', true);
111
+		if ( ! $hide_promo) {
112
+			if (filter_input(INPUT_GET, 'remove_i18n_promo', FILTER_VALIDATE_INT) === 1) {
113 113
 				// No expiration time, so this would normally not expire, but it wouldn't be copied to other sites etc.
114
-				Give_Cache::set( 'give_i18n_give_promo_hide', true, null, true );
114
+				Give_Cache::set('give_i18n_give_promo_hide', true, null, true);
115 115
 				$hide_promo = true;
116 116
 			}
117 117
 		}
@@ -130,20 +130,20 @@  discard block
 block discarded – undo
130 130
 		$message = false;
131 131
 
132 132
 		// Using a translation less than 90% complete.
133
-		if ( $this->translation_exists && $this->translation_loaded && $this->percent_translated < 90 ) {
134
-			$message = __( 'As you can see, there is a translation of this plugin in %1$s. This translation is currently %3$d%% complete. We need your help to make it complete and to fix any errors. Please register at %4$s to help %5$s to %1$s!', 'give' );
135
-		} elseif ( ! $this->translation_loaded && $this->translation_exists ) {
136
-			$message = __( 'You\'re using WordPress in %1$s. While %2$s has been %3$d%% translated to %1$s, it has not been shipped with the plugin yet. You can help! Register at %4$s to help complete the translation to %1$s!', 'give' );
137
-		} elseif ( ! $this->translation_exists ) {
138
-			$message = __( 'You\'re using WordPress in a language we don\'t support yet. We\'d love for %2$s to be translated in that language too, but unfortunately, it isn\'t right now. You can change that! Register at %4$s to help translate it!', 'give' );
133
+		if ($this->translation_exists && $this->translation_loaded && $this->percent_translated < 90) {
134
+			$message = __('As you can see, there is a translation of this plugin in %1$s. This translation is currently %3$d%% complete. We need your help to make it complete and to fix any errors. Please register at %4$s to help %5$s to %1$s!', 'give');
135
+		} elseif ( ! $this->translation_loaded && $this->translation_exists) {
136
+			$message = __('You\'re using WordPress in %1$s. While %2$s has been %3$d%% translated to %1$s, it has not been shipped with the plugin yet. You can help! Register at %4$s to help complete the translation to %1$s!', 'give');
137
+		} elseif ( ! $this->translation_exists) {
138
+			$message = __('You\'re using WordPress in a language we don\'t support yet. We\'d love for %2$s to be translated in that language too, but unfortunately, it isn\'t right now. You can change that! Register at %4$s to help translate it!', 'give');
139 139
 		}
140 140
 
141 141
 		// Links.
142
-		$registration_link = sprintf( '<a href="%1$s" target="_blank">%2$s</a>', 'https://wordpress.org/support/register.php', esc_html__( 'WordPress.org', 'give' ) );
143
-		$translations_link = sprintf( '<a href="%1$s" target="_blank">%2$s</a>', 'https://translate.wordpress.org/projects/wp-plugins/give', esc_html__( 'complete the translation', 'give' ) );
142
+		$registration_link = sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://wordpress.org/support/register.php', esc_html__('WordPress.org', 'give'));
143
+		$translations_link = sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://translate.wordpress.org/projects/wp-plugins/give', esc_html__('complete the translation', 'give'));
144 144
 
145 145
 		// Message.
146
-		$message = sprintf( $message, $this->locale_name, 'Give', $this->percent_translated, $registration_link, $translations_link );
146
+		$message = sprintf($message, $this->locale_name, 'Give', $this->percent_translated, $registration_link, $translations_link);
147 147
 
148 148
 		return $message;
149 149
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 		$this->translation_details();
158 158
 		$message = $this->promo_message();
159 159
 
160
-		if ( $message ) { ?>
160
+		if ($message) { ?>
161 161
 
162 162
 			<style>
163 163
 				/* Banner specific styles */
@@ -220,12 +220,12 @@  discard block
 block discarded – undo
220 220
 				<a href="https://wordpress.org/support/register.php" class="alignleft give-i18n-icon" style="margin:0" target="_blank"><span class="dashicons dashicons-translation" style="font-size: 110px; text-decoration: none;"></span></a>
221 221
 
222 222
 				<div class="give-i18n-notice-content">
223
-					<a href="<?php echo esc_url( add_query_arg( array( 'remove_i18n_promo' => '1' ) ) ); ?>" class="dismiss"><span class="dashicons dashicons-dismiss"></span></a>
223
+					<a href="<?php echo esc_url(add_query_arg(array('remove_i18n_promo' => '1'))); ?>" class="dismiss"><span class="dashicons dashicons-dismiss"></span></a>
224 224
 
225
-					<h2 style="margin: 10px 0;"><?php printf( esc_html__( 'Help Translate Give to %s', 'give' ), $this->locale_name ); ?></h2>
225
+					<h2 style="margin: 10px 0;"><?php printf(esc_html__('Help Translate Give to %s', 'give'), $this->locale_name); ?></h2>
226 226
 					<p><?php echo $message; ?></p>
227 227
 					<p>
228
-						<a href="https://wordpress.org/support/register.php" target="_blank"><?php _e( 'Register now &raquo;', 'give' ); ?></a>
228
+						<a href="https://wordpress.org/support/register.php" target="_blank"><?php _e('Register now &raquo;', 'give'); ?></a>
229 229
 					</p>
230 230
 				</div>
231 231
 			</div>
@@ -242,11 +242,11 @@  discard block
 block discarded – undo
242 242
 	 */
243 243
 	private function find_or_initialize_translation_details() {
244 244
 
245
-		$set = Give_Cache::get( "give_i18n_give_{$this->locale}", true );
245
+		$set = Give_Cache::get("give_i18n_give_{$this->locale}", true);
246 246
 
247
-		if ( ! $set ) {
247
+		if ( ! $set) {
248 248
 			$set = $this->retrieve_translation_details();
249
-			Give_Cache::set( "give_i18n_give_{$this->locale}", $set, DAY_IN_SECONDS, true );
249
+			Give_Cache::set("give_i18n_give_{$this->locale}", $set, DAY_IN_SECONDS, true);
250 250
 		}
251 251
 
252 252
 		return $set;
@@ -260,10 +260,10 @@  discard block
 block discarded – undo
260 260
 	private function translation_details() {
261 261
 		$set = $this->find_or_initialize_translation_details();
262 262
 
263
-		$this->translation_exists = ! is_null( $set );
264
-		$this->translation_loaded = is_textdomain_loaded( 'give' );
263
+		$this->translation_exists = ! is_null($set);
264
+		$this->translation_loaded = is_textdomain_loaded('give');
265 265
 
266
-		$this->parse_translation_set( $set );
266
+		$this->parse_translation_set($set);
267 267
 	}
268 268
 
269 269
 	/**
@@ -275,26 +275,26 @@  discard block
 block discarded – undo
275 275
 	 */
276 276
 	private function retrieve_translation_details() {
277 277
 
278
-		$api_url = trailingslashit( $this->glotpress_url );
278
+		$api_url = trailingslashit($this->glotpress_url);
279 279
 
280
-		$resp = wp_remote_get( $api_url );
280
+		$resp = wp_remote_get($api_url);
281 281
 
282
-		if ( is_wp_error( $resp ) || wp_remote_retrieve_response_code( $resp ) === '404' ) {
282
+		if (is_wp_error($resp) || wp_remote_retrieve_response_code($resp) === '404') {
283 283
 			return null;
284 284
 		}
285 285
 
286
-		$body = wp_remote_retrieve_body( $resp );
287
-		unset( $resp );
286
+		$body = wp_remote_retrieve_body($resp);
287
+		unset($resp);
288 288
 
289
-		if ( $body ) {
290
-			$body = json_decode( $body );
289
+		if ($body) {
290
+			$body = json_decode($body);
291 291
 
292
-			foreach ( $body->translation_sets as $set ) {
293
-				if ( ! property_exists( $set, 'wp_locale' ) ) {
292
+			foreach ($body->translation_sets as $set) {
293
+				if ( ! property_exists($set, 'wp_locale')) {
294 294
 					continue;
295 295
 				}
296 296
 
297
-				if ( $this->locale == $set->wp_locale ) {
297
+				if ($this->locale == $set->wp_locale) {
298 298
 					return $set;
299 299
 				}
300 300
 			}
@@ -310,8 +310,8 @@  discard block
 block discarded – undo
310 310
 	 *
311 311
 	 * @access private
312 312
 	 */
313
-	private function parse_translation_set( $set ) {
314
-		if ( $this->translation_exists && is_object( $set ) ) {
313
+	private function parse_translation_set($set) {
314
+		if ($this->translation_exists && is_object($set)) {
315 315
 			$this->locale_name        = $set->name;
316 316
 			$this->percent_translated = $set->percent_translated;
317 317
 		} else {
Please login to merge, or discard this patch.
admin/reporting/tools/class-give-tools-delete-test-transactions.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly.
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -55,22 +55,22 @@  discard block
 block discarded – undo
55 55
 	public function get_data() {
56 56
 		global $wpdb;
57 57
 
58
-		$items = $this->get_stored_data( 'give_temp_reset_ids' );
58
+		$items = $this->get_stored_data('give_temp_reset_ids');
59 59
 
60
-		if ( ! is_array( $items ) ) {
60
+		if ( ! is_array($items)) {
61 61
 			return false;
62 62
 		}
63 63
 
64
-		$offset     = ( $this->step - 1 ) * $this->per_step;
65
-		$step_items = array_slice( $items, $offset, $this->per_step );
64
+		$offset     = ($this->step - 1) * $this->per_step;
65
+		$step_items = array_slice($items, $offset, $this->per_step);
66 66
 
67
-		if ( $step_items ) {
67
+		if ($step_items) {
68 68
 
69 69
 			$step_ids = array(
70 70
 				'other' => array(),
71 71
 			);
72 72
 
73
-			foreach ( $step_items as $item ) {
73
+			foreach ($step_items as $item) {
74 74
 
75 75
 				$step_ids['other'][] = $item['id'];
76 76
 
@@ -78,15 +78,15 @@  discard block
 block discarded – undo
78 78
 
79 79
 			$sql = array();
80 80
 
81
-			foreach ( $step_ids as $type => $ids ) {
81
+			foreach ($step_ids as $type => $ids) {
82 82
 
83
-				if ( empty( $ids ) ) {
83
+				if (empty($ids)) {
84 84
 					continue;
85 85
 				}
86 86
 
87
-				$ids = implode( ',', $ids );
87
+				$ids = implode(',', $ids);
88 88
 
89
-				switch ( $type ) {
89
+				switch ($type) {
90 90
 					case 'other':
91 91
 						$sql[] = "DELETE FROM $wpdb->posts WHERE id IN ($ids)";
92 92
 						$sql[] = "DELETE FROM $wpdb->postmeta WHERE post_id IN ($ids)";
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
 
98 98
 			}
99 99
 
100
-			if ( ! empty( $sql ) ) {
101
-				foreach ( $sql as $query ) {
102
-					$wpdb->query( $query );
100
+			if ( ! empty($sql)) {
101
+				foreach ($sql as $query) {
102
+					$wpdb->query($query);
103 103
 				}
104 104
 			}
105 105
 
@@ -119,16 +119,16 @@  discard block
 block discarded – undo
119 119
 	 */
120 120
 	public function get_percentage_complete() {
121 121
 
122
-		$items = $this->get_stored_data( 'give_temp_reset_ids', false );
123
-		$total = count( $items );
122
+		$items = $this->get_stored_data('give_temp_reset_ids', false);
123
+		$total = count($items);
124 124
 
125 125
 		$percentage = 100;
126 126
 
127
-		if ( $total > 0 ) {
128
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
127
+		if ($total > 0) {
128
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
129 129
 		}
130 130
 
131
-		if ( $percentage > 100 ) {
131
+		if ($percentage > 100) {
132 132
 			$percentage = 100;
133 133
 		}
134 134
 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	 *
143 143
 	 * @param array $request The Form Data passed into the batch processing
144 144
 	 */
145
-	public function set_properties( $request ) {
145
+	public function set_properties($request) {
146 146
 	}
147 147
 
148 148
 	/**
@@ -153,29 +153,29 @@  discard block
 block discarded – undo
153 153
 	 */
154 154
 	public function process_step() {
155 155
 
156
-		if ( ! $this->can_export() ) {
157
-			wp_die( esc_html__( 'You do not have permission to delete test transactions.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
156
+		if ( ! $this->can_export()) {
157
+			wp_die(esc_html__('You do not have permission to delete test transactions.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
158 158
 		}
159 159
 
160 160
 		$had_data = $this->get_data();
161 161
 
162
-		if ( $had_data ) {
162
+		if ($had_data) {
163 163
 			$this->done = false;
164 164
 
165 165
 			return true;
166 166
 		} else {
167
-			update_option( 'give_earnings_total', give_get_total_earnings( true ) );
168
-			Give_Cache::delete( Give_Cache::get_key('give_estimated_monthly_stats' ) );
167
+			update_option('give_earnings_total', give_get_total_earnings(true));
168
+			Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats'));
169 169
 
170
-			$this->delete_data( 'give_temp_reset_ids' );
170
+			$this->delete_data('give_temp_reset_ids');
171 171
 
172 172
 			// Reset the sequential order numbers
173
-			if ( give_get_option( 'enable_sequential' ) ) {
174
-				delete_option( 'give_last_payment_number' );
173
+			if (give_get_option('enable_sequential')) {
174
+				delete_option('give_last_payment_number');
175 175
 			}
176 176
 
177 177
 			$this->done    = true;
178
-			$this->message = esc_html__( 'Test transactions successfully deleted.', 'give' );
178
+			$this->message = esc_html__('Test transactions successfully deleted.', 'give');
179 179
 
180 180
 			return false;
181 181
 		}
@@ -185,10 +185,10 @@  discard block
 block discarded – undo
185 185
 	 * Headers
186 186
 	 */
187 187
 	public function headers() {
188
-		ignore_user_abort( true );
188
+		ignore_user_abort(true);
189 189
 
190
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
191
-			set_time_limit( 0 );
190
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
191
+			set_time_limit(0);
192 192
 		}
193 193
 	}
194 194
 
@@ -212,26 +212,26 @@  discard block
 block discarded – undo
212 212
 	 */
213 213
 	public function pre_fetch() {
214 214
 
215
-		if ( $this->step == 1 ) {
216
-			$this->delete_data( 'give_temp_reset_ids' );
215
+		if ($this->step == 1) {
216
+			$this->delete_data('give_temp_reset_ids');
217 217
 		}
218 218
 
219
-		$items = get_option( 'give_temp_reset_ids', false );
219
+		$items = get_option('give_temp_reset_ids', false);
220 220
 
221
-		if ( false === $items ) {
221
+		if (false === $items) {
222 222
 			$items = array();
223 223
 
224
-			$args = apply_filters( 'give_tools_reset_stats_total_args', array(
224
+			$args = apply_filters('give_tools_reset_stats_total_args', array(
225 225
 				'post_type'      => 'give_payment',
226 226
 				'post_status'    => 'any',
227
-				'posts_per_page' => - 1,
227
+				'posts_per_page' => -1,
228 228
 				//ONLY TEST MODE TRANSACTIONS!!!
229 229
 				'meta_key'   => '_give_payment_mode',
230 230
 				'meta_value' => 'test'
231
-			) );
231
+			));
232 232
 
233
-			$posts = get_posts( $args );
234
-			foreach ( $posts as $post ) {
233
+			$posts = get_posts($args);
234
+			foreach ($posts as $post) {
235 235
 				$items[] = array(
236 236
 					'id'   => (int) $post->ID,
237 237
 					'type' => $post->post_type,
@@ -240,9 +240,9 @@  discard block
 block discarded – undo
240 240
 
241 241
 			// Allow filtering of items to remove with an unassociative array for each item.
242 242
 			// The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method.
243
-			$items = apply_filters( 'give_reset_items', $items );
243
+			$items = apply_filters('give_reset_items', $items);
244 244
 
245
-			$this->store_data( 'give_temp_reset_ids', $items );
245
+			$this->store_data('give_temp_reset_ids', $items);
246 246
 		}
247 247
 
248 248
 	}
@@ -256,11 +256,11 @@  discard block
 block discarded – undo
256 256
 	 *
257 257
 	 * @return mixed       Returns the data from the database
258 258
 	 */
259
-	private function get_stored_data( $key ) {
259
+	private function get_stored_data($key) {
260 260
 		global $wpdb;
261
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
261
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
262 262
 
263
-		return empty( $value ) ? false : maybe_unserialize( $value );
263
+		return empty($value) ? false : maybe_unserialize($value);
264 264
 	}
265 265
 
266 266
 	/**
@@ -273,10 +273,10 @@  discard block
 block discarded – undo
273 273
 	 *
274 274
 	 * @return void
275 275
 	 */
276
-	private function store_data( $key, $value ) {
276
+	private function store_data($key, $value) {
277 277
 		global $wpdb;
278 278
 
279
-		$value = maybe_serialize( $value );
279
+		$value = maybe_serialize($value);
280 280
 
281 281
 		$data = array(
282 282
 			'option_name'  => $key,
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 			'%s',
291 291
 		);
292 292
 
293
-		$wpdb->replace( $wpdb->options, $data, $formats );
293
+		$wpdb->replace($wpdb->options, $data, $formats);
294 294
 	}
295 295
 
296 296
 	/**
@@ -302,9 +302,9 @@  discard block
 block discarded – undo
302 302
 	 *
303 303
 	 * @return void
304 304
 	 */
305
-	private function delete_data( $key ) {
305
+	private function delete_data($key) {
306 306
 		global $wpdb;
307
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
307
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
308 308
 	}
309 309
 
310 310
 }
Please login to merge, or discard this patch.
includes/admin/reporting/tools/class-give-tools-reset-stats.php 1 patch
Spacing   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly.
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -58,16 +58,16 @@  discard block
 block discarded – undo
58 58
 	public function get_data() {
59 59
 		global $wpdb;
60 60
 
61
-		$items = $this->get_stored_data( 'give_temp_reset_ids' );
61
+		$items = $this->get_stored_data('give_temp_reset_ids');
62 62
 
63
-		if ( ! is_array( $items ) ) {
63
+		if ( ! is_array($items)) {
64 64
 			return false;
65 65
 		}
66 66
 
67
-		$offset     = ( $this->step - 1 ) * $this->per_step;
68
-		$step_items = array_slice( $items, $offset, $this->per_step );
67
+		$offset     = ($this->step - 1) * $this->per_step;
68
+		$step_items = array_slice($items, $offset, $this->per_step);
69 69
 
70
-		if ( $step_items ) {
70
+		if ($step_items) {
71 71
 
72 72
 			$step_ids = array(
73 73
 				'customers' => array(),
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
 				'other'     => array(),
76 76
 			);
77 77
 
78
-			foreach ( $step_items as $item ) {
78
+			foreach ($step_items as $item) {
79 79
 
80
-				switch ( $item['type'] ) {
80
+				switch ($item['type']) {
81 81
 					case 'customer':
82 82
 						$step_ids['customers'][] = $item['id'];
83 83
 						break;
@@ -85,25 +85,25 @@  discard block
 block discarded – undo
85 85
 						$step_ids['give_forms'][] = $item['id'];
86 86
 						break;
87 87
 					default:
88
-						$item_type                = apply_filters( 'give_reset_item_type', 'other', $item );
89
-						$step_ids[ $item_type ][] = $item['id'];
88
+						$item_type                = apply_filters('give_reset_item_type', 'other', $item);
89
+						$step_ids[$item_type][] = $item['id'];
90 90
 						break;
91 91
 				}
92 92
 			}
93 93
 
94 94
 			$sql = array();
95 95
 
96
-			foreach ( $step_ids as $type => $ids ) {
96
+			foreach ($step_ids as $type => $ids) {
97 97
 
98
-				if ( empty( $ids ) ) {
98
+				if (empty($ids)) {
99 99
 					continue;
100 100
 				}
101 101
 
102
-				$ids = implode( ',', $ids );
102
+				$ids = implode(',', $ids);
103 103
 
104
-				switch ( $type ) {
104
+				switch ($type) {
105 105
 					case 'customers':
106
-						$table_name = $wpdb->prefix . 'give_customers';
106
+						$table_name = $wpdb->prefix.'give_customers';
107 107
 						$sql[]      = "DELETE FROM $table_name WHERE id IN ($ids)";
108 108
 						break;
109 109
 					case 'forms':
@@ -118,16 +118,16 @@  discard block
 block discarded – undo
118 118
 						break;
119 119
 				}
120 120
 
121
-				if ( ! in_array( $type, array( 'customers', 'forms', 'other' ) ) ) {
121
+				if ( ! in_array($type, array('customers', 'forms', 'other'))) {
122 122
 					// Allows other types of custom post types to filter on their own post_type
123 123
 					// and add items to the query list, for the IDs found in their post type.
124
-					$sql = apply_filters( "give_reset_add_queries_{$type}", $sql, $ids );
124
+					$sql = apply_filters("give_reset_add_queries_{$type}", $sql, $ids);
125 125
 				}
126 126
 			}
127 127
 
128
-			if ( ! empty( $sql ) ) {
129
-				foreach ( $sql as $query ) {
130
-					$wpdb->query( $query );
128
+			if ( ! empty($sql)) {
129
+				foreach ($sql as $query) {
130
+					$wpdb->query($query);
131 131
 				}
132 132
 			}
133 133
 
@@ -147,16 +147,16 @@  discard block
 block discarded – undo
147 147
 	 */
148 148
 	public function get_percentage_complete() {
149 149
 
150
-		$items = $this->get_stored_data( 'give_temp_reset_ids', false );
151
-		$total = count( $items );
150
+		$items = $this->get_stored_data('give_temp_reset_ids', false);
151
+		$total = count($items);
152 152
 
153 153
 		$percentage = 100;
154 154
 
155
-		if ( $total > 0 ) {
156
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
155
+		if ($total > 0) {
156
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
157 157
 		}
158 158
 
159
-		if ( $percentage > 100 ) {
159
+		if ($percentage > 100) {
160 160
 			$percentage = 100;
161 161
 		}
162 162
 
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 	 *
171 171
 	 * @param array $request The Form Data passed into the batch processing
172 172
 	 */
173
-	public function set_properties( $request ) {
173
+	public function set_properties($request) {
174 174
 	}
175 175
 
176 176
 	/**
@@ -181,29 +181,29 @@  discard block
 block discarded – undo
181 181
 	 */
182 182
 	public function process_step() {
183 183
 
184
-		if ( ! $this->can_export() ) {
185
-			wp_die( esc_html__( 'You do not have permission to reset data.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
184
+		if ( ! $this->can_export()) {
185
+			wp_die(esc_html__('You do not have permission to reset data.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
186 186
 		}
187 187
 
188 188
 		$had_data = $this->get_data();
189 189
 
190
-		if ( $had_data ) {
190
+		if ($had_data) {
191 191
 			$this->done = false;
192 192
 
193 193
 			return true;
194 194
 		} else {
195
-			update_option( 'give_earnings_total', 0 );
196
-			Give_Cache::delete( Give_Cache::get_key('give_estimated_monthly_stats' ) );
195
+			update_option('give_earnings_total', 0);
196
+			Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats'));
197 197
 
198
-			$this->delete_data( 'give_temp_reset_ids' );
198
+			$this->delete_data('give_temp_reset_ids');
199 199
 
200 200
 			// Reset the sequential order numbers
201
-			if ( give_get_option( 'enable_sequential' ) ) {
202
-				delete_option( 'give_last_payment_number' );
201
+			if (give_get_option('enable_sequential')) {
202
+				delete_option('give_last_payment_number');
203 203
 			}
204 204
 
205 205
 			$this->done    = true;
206
-			$this->message = esc_html__( 'Donation forms, income, donations counts, and logs successfully reset.', 'give' );
206
+			$this->message = esc_html__('Donation forms, income, donations counts, and logs successfully reset.', 'give');
207 207
 
208 208
 			return false;
209 209
 		}
@@ -213,10 +213,10 @@  discard block
 block discarded – undo
213 213
 	 * Headers
214 214
 	 */
215 215
 	public function headers() {
216
-		ignore_user_abort( true );
216
+		ignore_user_abort(true);
217 217
 
218
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
219
-			set_time_limit( 0 );
218
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
219
+			set_time_limit(0);
220 220
 		}
221 221
 	}
222 222
 
@@ -240,35 +240,35 @@  discard block
 block discarded – undo
240 240
 	 */
241 241
 	public function pre_fetch() {
242 242
 
243
-		if ( $this->step == 1 ) {
244
-			$this->delete_data( 'give_temp_reset_ids' );
243
+		if ($this->step == 1) {
244
+			$this->delete_data('give_temp_reset_ids');
245 245
 		}
246 246
 
247
-		$items = get_option( 'give_temp_reset_ids', false );
247
+		$items = get_option('give_temp_reset_ids', false);
248 248
 
249
-		if ( false === $items ) {
249
+		if (false === $items) {
250 250
 			$items = array();
251 251
 
252
-			$give_types_for_reset = array( 'give_forms', 'give_log', 'give_payment' );
253
-			$give_types_for_reset = apply_filters( 'give_reset_store_post_types', $give_types_for_reset );
252
+			$give_types_for_reset = array('give_forms', 'give_log', 'give_payment');
253
+			$give_types_for_reset = apply_filters('give_reset_store_post_types', $give_types_for_reset);
254 254
 
255
-			$args = apply_filters( 'give_tools_reset_stats_total_args', array(
255
+			$args = apply_filters('give_tools_reset_stats_total_args', array(
256 256
 				'post_type'      => $give_types_for_reset,
257 257
 				'post_status'    => 'any',
258
-				'posts_per_page' => - 1,
259
-			) );
258
+				'posts_per_page' => -1,
259
+			));
260 260
 
261
-			$posts = get_posts( $args );
262
-			foreach ( $posts as $post ) {
261
+			$posts = get_posts($args);
262
+			foreach ($posts as $post) {
263 263
 				$items[] = array(
264 264
 					'id'   => (int) $post->ID,
265 265
 					'type' => $post->post_type,
266 266
 				);
267 267
 			}
268 268
 
269
-			$customer_args = array( 'number' => - 1 );
270
-			$customers     = Give()->customers->get_customers( $customer_args );
271
-			foreach ( $customers as $customer ) {
269
+			$customer_args = array('number' => -1);
270
+			$customers     = Give()->customers->get_customers($customer_args);
271
+			foreach ($customers as $customer) {
272 272
 				$items[] = array(
273 273
 					'id'   => (int) $customer->id,
274 274
 					'type' => 'customer',
@@ -277,9 +277,9 @@  discard block
 block discarded – undo
277 277
 
278 278
 			// Allow filtering of items to remove with an unassociative array for each item
279 279
 			// The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method
280
-			$items = apply_filters( 'give_reset_items', $items );
280
+			$items = apply_filters('give_reset_items', $items);
281 281
 
282
-			$this->store_data( 'give_temp_reset_ids', $items );
282
+			$this->store_data('give_temp_reset_ids', $items);
283 283
 		}
284 284
 
285 285
 	}
@@ -293,11 +293,11 @@  discard block
 block discarded – undo
293 293
 	 *
294 294
 	 * @return mixed       Returns the data from the database.
295 295
 	 */
296
-	private function get_stored_data( $key ) {
296
+	private function get_stored_data($key) {
297 297
 		global $wpdb;
298
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
298
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
299 299
 
300
-		return empty( $value ) ? false : maybe_unserialize( $value );
300
+		return empty($value) ? false : maybe_unserialize($value);
301 301
 	}
302 302
 
303 303
 	/**
@@ -310,10 +310,10 @@  discard block
 block discarded – undo
310 310
 	 *
311 311
 	 * @return void
312 312
 	 */
313
-	private function store_data( $key, $value ) {
313
+	private function store_data($key, $value) {
314 314
 		global $wpdb;
315 315
 
316
-		$value = maybe_serialize( $value );
316
+		$value = maybe_serialize($value);
317 317
 
318 318
 		$data = array(
319 319
 			'option_name'  => $key,
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 			'%s',
328 328
 		);
329 329
 
330
-		$wpdb->replace( $wpdb->options, $data, $formats );
330
+		$wpdb->replace($wpdb->options, $data, $formats);
331 331
 	}
332 332
 
333 333
 	/**
@@ -339,9 +339,9 @@  discard block
 block discarded – undo
339 339
 	 *
340 340
 	 * @return void
341 341
 	 */
342
-	private function delete_data( $key ) {
342
+	private function delete_data($key) {
343 343
 		global $wpdb;
344
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
344
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
345 345
 	}
346 346
 
347 347
 }
Please login to merge, or discard this patch.
includes/admin/reporting/tools/class-give-tools-recount-income.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly.
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -53,49 +53,49 @@  discard block
 block discarded – undo
53 53
 	 */
54 54
 	public function get_data() {
55 55
 
56
-		if ( $this->step == 1 ) {
57
-			$this->delete_data( 'give_temp_recount_earnings' );
56
+		if ($this->step == 1) {
57
+			$this->delete_data('give_temp_recount_earnings');
58 58
 		}
59 59
 
60
-		$total = get_option( 'give_temp_recount_earnings', false );
60
+		$total = get_option('give_temp_recount_earnings', false);
61 61
 
62
-		if ( false === $total ) {
62
+		if (false === $total) {
63 63
 			$total = (float) 0;
64
-			$this->store_data( 'give_temp_recount_earnings', $total );
64
+			$this->store_data('give_temp_recount_earnings', $total);
65 65
 		}
66 66
 
67
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
67
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
68 68
 
69
-		$args = apply_filters( 'give_recount_earnings_args', array(
69
+		$args = apply_filters('give_recount_earnings_args', array(
70 70
 			'number' => $this->per_step,
71 71
 			'page'   => $this->step,
72 72
 			'status' => $accepted_statuses,
73 73
 			'fields' => 'ids'
74
-		) );
74
+		));
75 75
 
76
-		$payments = give_get_payments( $args );
76
+		$payments = give_get_payments($args);
77 77
 
78
-		if ( ! empty( $payments ) ) {
78
+		if ( ! empty($payments)) {
79 79
 
80
-			foreach ( $payments as $payment ) {
80
+			foreach ($payments as $payment) {
81 81
 
82
-				$total += give_get_payment_amount( $payment );
82
+				$total += give_get_payment_amount($payment);
83 83
 
84 84
 			}
85 85
 
86
-			if ( $total < 0 ) {
86
+			if ($total < 0) {
87 87
 				$totals = 0;
88 88
 			}
89 89
 
90
-			$total = round( $total, give_currency_decimal_filter() );
90
+			$total = round($total, give_currency_decimal_filter());
91 91
 
92
-			$this->store_data( 'give_temp_recount_earnings', $total );
92
+			$this->store_data('give_temp_recount_earnings', $total);
93 93
 
94 94
 			return true;
95 95
 
96 96
 		}
97 97
 
98
-		update_option( 'give_earnings_total', $total );
98
+		update_option('give_earnings_total', $total);
99 99
 
100 100
 		return false;
101 101
 
@@ -109,25 +109,25 @@  discard block
 block discarded – undo
109 109
 	 */
110 110
 	public function get_percentage_complete() {
111 111
 
112
-		$total = $this->get_stored_data( 'give_recount_earnings_total' );
112
+		$total = $this->get_stored_data('give_recount_earnings_total');
113 113
 
114
-		if ( false === $total ) {
115
-			$args = apply_filters( 'give_recount_earnings_total_args', array() );
114
+		if (false === $total) {
115
+			$args = apply_filters('give_recount_earnings_total_args', array());
116 116
 
117
-			$counts = give_count_payments( $args );
118
-			$total  = absint( $counts->publish );
119
-			$total  = apply_filters( 'give_recount_store_earnings_total', $total );
117
+			$counts = give_count_payments($args);
118
+			$total  = absint($counts->publish);
119
+			$total  = apply_filters('give_recount_store_earnings_total', $total);
120 120
 
121
-			$this->store_data( 'give_recount_earnings_total', $total );
121
+			$this->store_data('give_recount_earnings_total', $total);
122 122
 		}
123 123
 
124 124
 		$percentage = 100;
125 125
 
126
-		if ( $total > 0 ) {
127
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
126
+		if ($total > 0) {
127
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
128 128
 		}
129 129
 
130
-		if ( $percentage > 100 ) {
130
+		if ($percentage > 100) {
131 131
 			$percentage = 100;
132 132
 		}
133 133
 
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 *
142 142
 	 * @param array $request The Form Data passed into the batch processing
143 143
 	 */
144
-	public function set_properties( $request ) {
144
+	public function set_properties($request) {
145 145
 	}
146 146
 
147 147
 	/**
@@ -152,31 +152,31 @@  discard block
 block discarded – undo
152 152
 	 */
153 153
 	public function process_step() {
154 154
 
155
-		if ( ! $this->can_export() ) {
156
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
155
+		if ( ! $this->can_export()) {
156
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
157 157
 		}
158 158
 
159 159
 		$had_data = $this->get_data();
160 160
 
161
-		if ( $had_data ) {
161
+		if ($had_data) {
162 162
 			$this->done = false;
163 163
 
164 164
 			return true;
165 165
 		} else {
166
-			$this->delete_data( 'give_recount_earnings_total' );
167
-			$this->delete_data( 'give_temp_recount_earnings' );
166
+			$this->delete_data('give_recount_earnings_total');
167
+			$this->delete_data('give_temp_recount_earnings');
168 168
 			$this->done    = true;
169
-			$this->message = esc_html__( 'Income stats have been successfully recounted.', 'give' );
169
+			$this->message = esc_html__('Income stats have been successfully recounted.', 'give');
170 170
 
171 171
 			return false;
172 172
 		}
173 173
 	}
174 174
 
175 175
 	public function headers() {
176
-		ignore_user_abort( true );
176
+		ignore_user_abort(true);
177 177
 
178
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
179
-			set_time_limit( 0 );
178
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
179
+			set_time_limit(0);
180 180
 		}
181 181
 	}
182 182
 
@@ -204,11 +204,11 @@  discard block
 block discarded – undo
204 204
 	 *
205 205
 	 * @return mixed       Returns the data from the database
206 206
 	 */
207
-	private function get_stored_data( $key ) {
207
+	private function get_stored_data($key) {
208 208
 		global $wpdb;
209
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
209
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
210 210
 
211
-		return empty( $value ) ? false : maybe_unserialize( $value );
211
+		return empty($value) ? false : maybe_unserialize($value);
212 212
 	}
213 213
 
214 214
 	/**
@@ -221,10 +221,10 @@  discard block
 block discarded – undo
221 221
 	 *
222 222
 	 * @return void
223 223
 	 */
224
-	private function store_data( $key, $value ) {
224
+	private function store_data($key, $value) {
225 225
 		global $wpdb;
226 226
 
227
-		$value = maybe_serialize( $value );
227
+		$value = maybe_serialize($value);
228 228
 
229 229
 		$data = array(
230 230
 			'option_name'  => $key,
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 			'%s',
239 239
 		);
240 240
 
241
-		$wpdb->replace( $wpdb->options, $data, $formats );
241
+		$wpdb->replace($wpdb->options, $data, $formats);
242 242
 	}
243 243
 
244 244
 	/**
@@ -250,9 +250,9 @@  discard block
 block discarded – undo
250 250
 	 *
251 251
 	 * @return void
252 252
 	 */
253
-	private function delete_data( $key ) {
253
+	private function delete_data($key) {
254 254
 		global $wpdb;
255
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
255
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
256 256
 	}
257 257
 
258 258
 }
Please login to merge, or discard this patch.
includes/admin/reporting/class-sales-logs-list-table.php 1 patch
Spacing   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -9,13 +9,13 @@  discard block
 block discarded – undo
9 9
  */
10 10
 
11 11
 // Exit if accessed directly.
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit;
14 14
 }
15 15
 
16 16
 // Load WP_List_Table if not loaded
17
-if ( ! class_exists( 'WP_List_Table' ) ) {
18
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
17
+if ( ! class_exists('WP_List_Table')) {
18
+	require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
19 19
 }
20 20
 
21 21
 /**
@@ -44,13 +44,13 @@  discard block
 block discarded – undo
44 44
 		global $status, $page;
45 45
 
46 46
 		// Set parent defaults
47
-		parent::__construct( array(
48
-			'singular' => give_get_forms_label_singular(),    // Singular name of the listed records
49
-			'plural'   => give_get_forms_label_plural(),        // Plural name of the listed records
50
-			'ajax'     => false,// Does this table support ajax?
51
-		) );
47
+		parent::__construct(array(
48
+			'singular' => give_get_forms_label_singular(), // Singular name of the listed records
49
+			'plural'   => give_get_forms_label_plural(), // Plural name of the listed records
50
+			'ajax'     => false, // Does this table support ajax?
51
+		));
52 52
 
53
-		add_action( 'give_log_view_actions', array( $this, 'give_forms_filter' ) );
53
+		add_action('give_log_view_actions', array($this, 'give_forms_filter'));
54 54
 	}
55 55
 
56 56
 	/**
@@ -64,39 +64,39 @@  discard block
 block discarded – undo
64 64
 	 *
65 65
 	 * @return string Column Name
66 66
 	 */
67
-	public function column_default( $item, $column_name ) {
67
+	public function column_default($item, $column_name) {
68 68
 
69
-		$payment = give_get_payment_by( 'id', $item['payment_id'] );
69
+		$payment = give_get_payment_by('id', $item['payment_id']);
70 70
 
71
-		switch ( $column_name ) {
71
+		switch ($column_name) {
72 72
 			case 'form' :
73
-				$form_title = get_the_title( $item[ $column_name ] );
74
-				$form_title = empty( $form_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $item[ $column_name ] ) : $form_title;
75
-				return '<a href="' . esc_url( add_query_arg( 'form', $item[ $column_name ] ) ) . '" >' . $form_title . '</a>';
73
+				$form_title = get_the_title($item[$column_name]);
74
+				$form_title = empty($form_title) ? sprintf(__('Untitled (#%s)', 'give'), $item[$column_name]) : $form_title;
75
+				return '<a href="'.esc_url(add_query_arg('form', $item[$column_name])).'" >'.$form_title.'</a>';
76 76
 
77 77
 			case 'user_id' :
78
-				return '<a href="' .
79
-					   admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . ( ! empty( $item['user_id'] ) ? urlencode( $item['user_id'] ) : give_get_payment_user_email( $item['payment_id'] ) ) ) .
80
-					   '">' . $item['user_name'] . '</a>';
78
+				return '<a href="'.
79
+					   admin_url('edit.php?post_type=give_forms&page=give-payment-history&user='.( ! empty($item['user_id']) ? urlencode($item['user_id']) : give_get_payment_user_email($item['payment_id']))).
80
+					   '">'.$item['user_name'].'</a>';
81 81
 
82 82
 			case 'amount' :
83
-				return give_currency_filter( give_format_amount( $item['amount'] ) );
83
+				return give_currency_filter(give_format_amount($item['amount']));
84 84
 
85 85
 			case 'status' :
86 86
 
87
-				$value = '<div class="give-donation-status status-' . sanitize_title( give_get_payment_status( $payment, true ) ) . '"><span class="give-donation-status-icon"></span> ' . give_get_payment_status( $payment, true ) . '</div>';
87
+				$value = '<div class="give-donation-status status-'.sanitize_title(give_get_payment_status($payment, true)).'"><span class="give-donation-status-icon"></span> '.give_get_payment_status($payment, true).'</div>';
88 88
 
89
-				if ( $payment->mode == 'test' ) {
90
-					$value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="' . esc_attr__( 'This donation was made in test mode.', 'give' ) . '">' . esc_html__( 'Test', 'give' ) . '</span>';
89
+				if ($payment->mode == 'test') {
90
+					$value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="'.esc_attr__('This donation was made in test mode.', 'give').'">'.esc_html__('Test', 'give').'</span>';
91 91
 				}
92 92
 
93 93
 				return $value;
94 94
 
95 95
 			case 'payment_id' :
96
-				return '<a href="' . admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $item['payment_id'] ) . '">' . give_get_payment_number( $item['payment_id'] ) . '</a>';
96
+				return '<a href="'.admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id='.$item['payment_id']).'">'.give_get_payment_number($item['payment_id']).'</a>';
97 97
 
98 98
 			default:
99
-				return $item[ $column_name ];
99
+				return $item[$column_name];
100 100
 		}
101 101
 	}
102 102
 
@@ -109,13 +109,13 @@  discard block
 block discarded – undo
109 109
 	 */
110 110
 	public function get_columns() {
111 111
 		$columns = array(
112
-			'ID'         => esc_html__( 'Log ID', 'give' ),
113
-			'user_id'    => esc_html__( 'Donor', 'give' ),
114
-			'form'       => esc_html__( 'Form', 'give' ),
115
-			'amount'     => esc_html__( 'Donation Amount', 'give' ),
116
-			'status'     => esc_html__( 'Status', 'give' ),
117
-			'payment_id' => esc_html__( 'Transaction ID', 'give' ),
118
-			'date'       => esc_html__( 'Date', 'give' ),
112
+			'ID'         => esc_html__('Log ID', 'give'),
113
+			'user_id'    => esc_html__('Donor', 'give'),
114
+			'form'       => esc_html__('Form', 'give'),
115
+			'amount'     => esc_html__('Donation Amount', 'give'),
116
+			'status'     => esc_html__('Status', 'give'),
117
+			'payment_id' => esc_html__('Transaction ID', 'give'),
118
+			'date'       => esc_html__('Date', 'give'),
119 119
 		);
120 120
 
121 121
 		return $columns;
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 	 * @return int Current page number
130 130
 	 */
131 131
 	public function get_paged() {
132
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
132
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
133 133
 	}
134 134
 
135 135
 	/**
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 	 * @return mixed int If User ID, string If Email/Login
141 141
 	 */
142 142
 	public function get_filtered_user() {
143
-		return isset( $_GET['user'] ) ? absint( $_GET['user'] ) : false;
143
+		return isset($_GET['user']) ? absint($_GET['user']) : false;
144 144
 	}
145 145
 
146 146
 	/**
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 	 * @return int Download ID
152 152
 	 */
153 153
 	public function get_filtered_give_form() {
154
-		return ! empty( $_GET['form'] ) ? absint( $_GET['form'] ) : false;
154
+		return ! empty($_GET['form']) ? absint($_GET['form']) : false;
155 155
 	}
156 156
 
157 157
 	/**
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 	 * @return string|bool string If search is present, false otherwise
163 163
 	 */
164 164
 	public function get_search() {
165
-		return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false;
165
+		return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false;
166 166
 	}
167 167
 
168 168
 
@@ -178,20 +178,20 @@  discard block
 block discarded – undo
178 178
 	 *
179 179
 	 * @param string $which
180 180
 	 */
181
-	protected function display_tablenav( $which ) {
181
+	protected function display_tablenav($which) {
182 182
 
183
-		if ( 'top' === $which ) {
184
-			wp_nonce_field( 'bulk-' . $this->_args['plural'] );
183
+		if ('top' === $which) {
184
+			wp_nonce_field('bulk-'.$this->_args['plural']);
185 185
 		}
186 186
 		?>
187
-		<div class="tablenav <?php echo esc_attr( $which ); ?>">
187
+		<div class="tablenav <?php echo esc_attr($which); ?>">
188 188
 
189 189
 			<div class="alignleft actions bulkactions">
190
-				<?php $this->bulk_actions( $which ); ?>
190
+				<?php $this->bulk_actions($which); ?>
191 191
 			</div>
192 192
 			<?php
193
-			$this->extra_tablenav( $which );
194
-			$this->pagination( $which );
193
+			$this->extra_tablenav($which);
194
+			$this->pagination($which);
195 195
 			?>
196 196
 
197 197
 			<br class="clear"/>
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 
215 215
 		$meta_query = array();
216 216
 
217
-		if ( $user ) {
217
+		if ($user) {
218 218
 			// Show only logs from a specific user
219 219
 			$meta_query[] = array(
220 220
 				'key'   => '_give_log_user_id',
@@ -223,8 +223,8 @@  discard block
 block discarded – undo
223 223
 		}
224 224
 
225 225
 		$search = $this->get_search();
226
-		if ( $search ) {
227
-			if ( is_email( $search ) ) {
226
+		if ($search) {
227
+			if (is_email($search)) {
228 228
 				// This is an email search. We use this to ensure it works for guest users and logged-in users
229 229
 				$key     = '_give_log_user_info';
230 230
 				$compare = 'LIKE';
@@ -233,32 +233,32 @@  discard block
 block discarded – undo
233 233
 				$key     = '_give_log_user_id';
234 234
 				$compare = 'LIKE';
235 235
 
236
-				if ( ! is_numeric( $search ) ) {
236
+				if ( ! is_numeric($search)) {
237 237
 					// Searching for user by username
238
-					$user = get_user_by( 'login', $search );
238
+					$user = get_user_by('login', $search);
239 239
 
240
-					if ( $user ) {
240
+					if ($user) {
241 241
 						// Found one, set meta value to user's ID
242 242
 						$search = $user->ID;
243 243
 					} else {
244 244
 						// No user found so let's do a real search query
245
-						$users = new WP_User_Query( array(
245
+						$users = new WP_User_Query(array(
246 246
 							'search'         => $search,
247
-							'search_columns' => array( 'user_url', 'user_nicename' ),
247
+							'search_columns' => array('user_url', 'user_nicename'),
248 248
 							'number'         => 1,
249 249
 							'fields'         => 'ids',
250
-						) );
250
+						));
251 251
 
252 252
 						$found_user = $users->get_results();
253 253
 
254
-						if ( $found_user ) {
254
+						if ($found_user) {
255 255
 							$search = $found_user[0];
256 256
 						}
257 257
 					}
258 258
 				}
259 259
 			}
260 260
 
261
-			if ( ! $this->file_search ) {
261
+			if ( ! $this->file_search) {
262 262
 				// Meta query only works for non file name searche
263 263
 				$meta_query[] = array(
264 264
 					'key'     => $key,
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 	 * @since  1.0
280 280
 	 * @return void
281 281
 	 */
282
-	function bulk_actions( $which = '' ) {
282
+	function bulk_actions($which = '') {
283 283
 		give_log_views();
284 284
 	}
285 285
 
@@ -291,24 +291,24 @@  discard block
 block discarded – undo
291 291
 	 * @return void
292 292
 	 */
293 293
 	public function give_forms_filter() {
294
-		$give_forms = get_posts( array(
294
+		$give_forms = get_posts(array(
295 295
 			'post_type'              => 'give_forms',
296 296
 			'post_status'            => 'any',
297
-			'posts_per_page'         => - 1,
297
+			'posts_per_page'         => -1,
298 298
 			'orderby'                => 'title',
299 299
 			'order'                  => 'ASC',
300 300
 			'fields'                 => 'ids',
301 301
 			'update_post_meta_cache' => false,
302 302
 			'update_post_term_cache' => false,
303
-		) );
303
+		));
304 304
 
305
-		if ( $give_forms ) {
305
+		if ($give_forms) {
306 306
 			echo '<select name="form" id="give-log-form-filter">';
307
-			echo '<option value="0">' . esc_html__( 'All', 'give' ) . '</option>';
308
-			foreach ( $give_forms as $form ) {
309
-				$form_title = get_the_title( $form );
310
-				$form_title = empty( $form_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $form ) : $form_title;
311
-				echo '<option value="' . $form . '"' . selected( $form, $this->get_filtered_give_form() ) . '>' . esc_html( $form_title ) . '</option>';
307
+			echo '<option value="0">'.esc_html__('All', 'give').'</option>';
308
+			foreach ($give_forms as $form) {
309
+				$form_title = get_the_title($form);
310
+				$form_title = empty($form_title) ? sprintf(__('Untitled (#%s)', 'give'), $form) : $form_title;
311
+				echo '<option value="'.$form.'"'.selected($form, $this->get_filtered_give_form()).'>'.esc_html($form_title).'</option>';
312 312
 			}
313 313
 			echo '</select>';
314 314
 		}
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 
329 329
 		$logs_data = array();
330 330
 		$paged     = $this->get_paged();
331
-		$give_form = empty( $_GET['s'] ) ? $this->get_filtered_give_form() : null;
331
+		$give_form = empty($_GET['s']) ? $this->get_filtered_give_form() : null;
332 332
 		$user      = $this->get_filtered_user();
333 333
 
334 334
 		$log_query = array(
@@ -338,38 +338,38 @@  discard block
 block discarded – undo
338 338
 			'meta_query'  => $this->get_meta_query(),
339 339
 		);
340 340
 
341
-		$cache_key = Give_Cache::get_key( 'get_logs', $log_query );
341
+		$cache_key = Give_Cache::get_key('get_logs', $log_query);
342 342
 
343 343
 		// Return result from cache if exist.
344
-		if ( ! ( $logs_data = Give_Cache::get( $cache_key ) ) ) {
345
-			$logs = $give_logs->get_connected_logs( $log_query );
344
+		if ( ! ($logs_data = Give_Cache::get($cache_key))) {
345
+			$logs = $give_logs->get_connected_logs($log_query);
346 346
 
347
-			if ( $logs ) {
348
-				foreach ( $logs as $log ) {
349
-					$payment_id = get_post_meta( $log->ID, '_give_log_payment_id', true );
347
+			if ($logs) {
348
+				foreach ($logs as $log) {
349
+					$payment_id = get_post_meta($log->ID, '_give_log_payment_id', true);
350 350
 
351 351
 					// Make sure this payment hasn't been deleted
352
-					if ( get_post( $payment_id ) ) :
353
-						$user_info      = give_get_payment_meta_user_info( $payment_id );
354
-						$payment_meta   = give_get_payment_meta( $payment_id );
355
-						$payment_amount = give_get_payment_amount( $payment_id );
352
+					if (get_post($payment_id)) :
353
+						$user_info      = give_get_payment_meta_user_info($payment_id);
354
+						$payment_meta   = give_get_payment_meta($payment_id);
355
+						$payment_amount = give_get_payment_amount($payment_id);
356 356
 
357 357
 						$logs_data[] = array(
358
-							'ID'         => '<span class="give-item-label give-item-label-gray">' . $log->ID . '</span>',
358
+							'ID'         => '<span class="give-item-label give-item-label-gray">'.$log->ID.'</span>',
359 359
 							'payment_id' => $payment_id,
360 360
 							'form'       => $log->post_parent,
361 361
 							'amount'     => $payment_amount,
362 362
 							'user_id'    => $user_info['id'],
363
-							'user_name'  => $user_info['first_name'] . ' ' . $user_info['last_name'],
364
-							'date'       => get_post_field( 'post_date', $payment_id ),
363
+							'user_name'  => $user_info['first_name'].' '.$user_info['last_name'],
364
+							'date'       => get_post_field('post_date', $payment_id),
365 365
 						);
366 366
 
367 367
 					endif;
368 368
 				}
369 369
 
370 370
 				// Cache results.
371
-				if ( ! empty( $logs_data ) ) {
372
-					Give_Cache::set( $cache_key, $logs_data );
371
+				if ( ! empty($logs_data)) {
372
+					Give_Cache::set($cache_key, $logs_data);
373 373
 				}
374 374
 			}
375 375
 		}
@@ -397,15 +397,15 @@  discard block
 block discarded – undo
397 397
 		$columns               = $this->get_columns();
398 398
 		$hidden                = array();
399 399
 		$sortable              = $this->get_sortable_columns();
400
-		$this->_column_headers = array( $columns, $hidden, $sortable );
400
+		$this->_column_headers = array($columns, $hidden, $sortable);
401 401
 		$current_page          = $this->get_pagenum();
402 402
 		$this->items           = $this->get_logs();
403
-		$total_items           = $give_logs->get_log_count( $this->get_filtered_give_form(), 'sale', $this->get_meta_query() );
403
+		$total_items           = $give_logs->get_log_count($this->get_filtered_give_form(), 'sale', $this->get_meta_query());
404 404
 
405
-		$this->set_pagination_args( array(
405
+		$this->set_pagination_args(array(
406 406
 				'total_items' => $total_items,
407 407
 				'per_page'    => $this->per_page,
408
-				'total_pages' => ceil( $total_items / $this->per_page ),
408
+				'total_pages' => ceil($total_items / $this->per_page),
409 409
 			)
410 410
 		);
411 411
 	}
Please login to merge, or discard this patch.
includes/admin/reporting/graphing.php 1 patch
Spacing   +246 added lines, -246 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	$dates = give_get_report_dates();
26 26
 
27 27
 	// Determine graph options
28
-	switch ( $dates['range'] ) :
28
+	switch ($dates['range']) :
29 29
 		case 'today' :
30 30
 		case 'yesterday' :
31 31
 			$day_by_day = true;
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 			$day_by_day = false;
38 38
 			break;
39 39
 		case 'other' :
40
-			if ( $dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year'] && ( $dates['m_start'] != '12' && $dates['m_end'] != '1' ) ) {
40
+			if ($dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year'] && ($dates['m_start'] != '12' && $dates['m_end'] != '1')) {
41 41
 				$day_by_day = false;
42 42
 			} else {
43 43
 				$day_by_day = true;
@@ -49,61 +49,61 @@  discard block
 block discarded – undo
49 49
 	endswitch;
50 50
 
51 51
 	$earnings_totals = 0.00; // Total earnings for time period shown
52
-	$sales_totals    = 0;            // Total sales for time period shown
52
+	$sales_totals    = 0; // Total sales for time period shown
53 53
 
54 54
 	$earnings_data = array();
55 55
 	$sales_data    = array();
56 56
 
57
-	if ( $dates['range'] == 'today' || $dates['range'] == 'yesterday' ) {
57
+	if ($dates['range'] == 'today' || $dates['range'] == 'yesterday') {
58 58
 		// Hour by hour
59 59
 		$hour  = 1;
60
-		$month = date( 'n', current_time( 'timestamp' ) );
61
-		while ( $hour <= 23 ) :
60
+		$month = date('n', current_time('timestamp'));
61
+		while ($hour <= 23) :
62 62
 
63
-			$sales    = give_get_sales_by_date( $dates['day'], $month, $dates['year'], $hour );
64
-			$earnings = give_get_earnings_by_date( $dates['day'], $month, $dates['year'], $hour );
63
+			$sales    = give_get_sales_by_date($dates['day'], $month, $dates['year'], $hour);
64
+			$earnings = give_get_earnings_by_date($dates['day'], $month, $dates['year'], $hour);
65 65
 
66 66
 			$sales_totals += $sales;
67 67
 			$earnings_totals += $earnings;
68 68
 
69
-			$date            = mktime( $hour, 0, 0, $month, $dates['day'], $dates['year'] ) * 1000;
70
-			$sales_data[]    = array( $date, $sales );
71
-			$earnings_data[] = array( $date, $earnings );
69
+			$date            = mktime($hour, 0, 0, $month, $dates['day'], $dates['year']) * 1000;
70
+			$sales_data[]    = array($date, $sales);
71
+			$earnings_data[] = array($date, $earnings);
72 72
 
73
-			$hour ++;
73
+			$hour++;
74 74
 		endwhile;
75 75
 
76
-	} elseif ( $dates['range'] == 'this_week' || $dates['range'] == 'last_week' ) {
76
+	} elseif ($dates['range'] == 'this_week' || $dates['range'] == 'last_week') {
77 77
 
78 78
 		// Day by day
79 79
 		$day     = $dates['day'];
80 80
 		$day_end = $dates['day_end'];
81 81
 		$month   = $dates['m_start'];
82
-		while ( $day <= $day_end ) :
83
-			$sales = give_get_sales_by_date( $day, $month, $dates['year'] );
82
+		while ($day <= $day_end) :
83
+			$sales = give_get_sales_by_date($day, $month, $dates['year']);
84 84
 			$sales_totals += $sales;
85 85
 
86
-			$earnings = give_get_earnings_by_date( $day, $month, $dates['year'] );
86
+			$earnings = give_get_earnings_by_date($day, $month, $dates['year']);
87 87
 			$earnings_totals += $earnings;
88 88
 
89
-			$date            = mktime( 0, 0, 0, $month, $day, $dates['year'] ) * 1000;
90
-			$sales_data[]    = array( $date, $sales );
91
-			$earnings_data[] = array( $date, $earnings );
92
-			$day ++;
89
+			$date            = mktime(0, 0, 0, $month, $day, $dates['year']) * 1000;
90
+			$sales_data[]    = array($date, $sales);
91
+			$earnings_data[] = array($date, $earnings);
92
+			$day++;
93 93
 		endwhile;
94 94
 
95 95
 	} else {
96 96
 
97 97
 		$y = $dates['year'];
98
-		while ( $y <= $dates['year_end'] ) :
98
+		while ($y <= $dates['year_end']) :
99 99
 
100
-			if ( $dates['year'] == $dates['year_end'] ) {
100
+			if ($dates['year'] == $dates['year_end']) {
101 101
 				$month_start = $dates['m_start'];
102 102
 				$month_end   = $dates['m_end'];
103
-			} elseif ( $y == $dates['year'] ) {
103
+			} elseif ($y == $dates['year']) {
104 104
 				$month_start = $dates['m_start'];
105 105
 				$month_end   = 12;
106
-			} elseif ( $y == $dates['year_end'] ) {
106
+			} elseif ($y == $dates['year_end']) {
107 107
 				$month_start = 1;
108 108
 				$month_end   = $dates['m_end'];
109 109
 			} else {
@@ -112,48 +112,48 @@  discard block
 block discarded – undo
112 112
 			}
113 113
 
114 114
 			$i = $month_start;
115
-			while ( $i <= $month_end ) :
115
+			while ($i <= $month_end) :
116 116
 
117
-				if ( $day_by_day ) {
117
+				if ($day_by_day) {
118 118
 
119
-					if ( $i == $month_end ) {
119
+					if ($i == $month_end) {
120 120
 
121 121
 						$num_of_days = $dates['day_end'];
122 122
 
123 123
 					} else {
124 124
 
125
-						$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
125
+						$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
126 126
 
127 127
 					}
128 128
 
129 129
 					$d = $dates['day'];
130 130
 
131
-					while ( $d <= $num_of_days ) :
131
+					while ($d <= $num_of_days) :
132 132
 
133
-						$sales = give_get_sales_by_date( $d, $i, $y );
133
+						$sales = give_get_sales_by_date($d, $i, $y);
134 134
 						$sales_totals += $sales;
135 135
 
136
-						$earnings = give_get_earnings_by_date( $d, $i, $y );
136
+						$earnings = give_get_earnings_by_date($d, $i, $y);
137 137
 						$earnings_totals += $earnings;
138 138
 
139
-						$date            = mktime( 0, 0, 0, $i, $d, $y ) * 1000;
140
-						$sales_data[]    = array( $date, $sales );
141
-						$earnings_data[] = array( $date, $earnings );
142
-						$d ++;
139
+						$date            = mktime(0, 0, 0, $i, $d, $y) * 1000;
140
+						$sales_data[]    = array($date, $sales);
141
+						$earnings_data[] = array($date, $earnings);
142
+						$d++;
143 143
 
144 144
 					endwhile;
145 145
 
146 146
 				} else {
147 147
 
148
-					$sales = give_get_sales_by_date( null, $i, $y );
148
+					$sales = give_get_sales_by_date(null, $i, $y);
149 149
 					$sales_totals += $sales;
150 150
 
151
-					$earnings = give_get_earnings_by_date( null, $i, $y );
151
+					$earnings = give_get_earnings_by_date(null, $i, $y);
152 152
 					$earnings_totals += $earnings;
153 153
 
154
-					if ( $i == $month_end ) {
154
+					if ($i == $month_end) {
155 155
 
156
-						$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
156
+						$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
157 157
 
158 158
 					} else {
159 159
 
@@ -161,24 +161,24 @@  discard block
 block discarded – undo
161 161
 
162 162
 					}
163 163
 
164
-					$date            = mktime( 0, 0, 0, $i, $num_of_days, $y ) * 1000;
165
-					$sales_data[]    = array( $date, $sales );
166
-					$earnings_data[] = array( $date, $earnings );
164
+					$date            = mktime(0, 0, 0, $i, $num_of_days, $y) * 1000;
165
+					$sales_data[]    = array($date, $sales);
166
+					$earnings_data[] = array($date, $earnings);
167 167
 
168 168
 				}
169 169
 
170
-				$i ++;
170
+				$i++;
171 171
 
172 172
 			endwhile;
173 173
 
174
-			$y ++;
174
+			$y++;
175 175
 		endwhile;
176 176
 
177 177
 	}
178 178
 
179 179
 	$data = array(
180
-		esc_html__( 'Income', 'give' )    => $earnings_data,
181
-		esc_html__( 'Donations', 'give' ) => $sales_data
180
+		esc_html__('Income', 'give')    => $earnings_data,
181
+		esc_html__('Donations', 'give') => $sales_data
182 182
 	);
183 183
 
184 184
 	// start our own output buffer
@@ -191,12 +191,12 @@  discard block
 block discarded – undo
191 191
 				<div class="inside">
192 192
 					<?php give_reports_graph_controls(); ?>
193 193
 					<?php
194
-					$graph = new Give_Graph( $data );
195
-					$graph->set( 'x_mode', 'time' );
196
-					$graph->set( 'multiple_y_axes', true );
194
+					$graph = new Give_Graph($data);
195
+					$graph->set('x_mode', 'time');
196
+					$graph->set('multiple_y_axes', true);
197 197
 					$graph->display();
198 198
 
199
-					if ( 'this_month' == $dates['range'] ) {
199
+					if ('this_month' == $dates['range']) {
200 200
 						$estimated = give_estimated_monthly_stats();
201 201
 					}
202 202
 					?>
@@ -205,21 +205,21 @@  discard block
 block discarded – undo
205 205
 			<table class="widefat reports-table alignleft" style="max-width:450px">
206 206
 				<tbody>
207 207
 				<tr>
208
-					<th scope="row"><strong><?php esc_html_e( 'Total income for period:', 'give' ); ?></strong></th>
209
-					<td><?php echo give_currency_filter( give_format_amount( $earnings_totals ) ); ?></td>
208
+					<th scope="row"><strong><?php esc_html_e('Total income for period:', 'give'); ?></strong></th>
209
+					<td><?php echo give_currency_filter(give_format_amount($earnings_totals)); ?></td>
210 210
 				</tr>
211 211
 				<tr class="alternate">
212
-					<th scope="row"><strong><?php esc_html_e( 'Total donations for period:', 'give' ); ?><strong></th>
212
+					<th scope="row"><strong><?php esc_html_e('Total donations for period:', 'give'); ?><strong></th>
213 213
 					<td><?php echo $sales_totals; ?></td>
214 214
 				</tr>
215
-				<?php if ( 'this_month' == $dates['range'] ) : ?>
215
+				<?php if ('this_month' == $dates['range']) : ?>
216 216
 					<tr>
217
-						<th scope="row"><strong><?php esc_html_e( 'Estimated monthly income:', 'give' ); ?></strong></th>
218
-						<td><?php echo give_currency_filter( give_format_amount( $estimated['earnings'] ) ); ?></td>
217
+						<th scope="row"><strong><?php esc_html_e('Estimated monthly income:', 'give'); ?></strong></th>
218
+						<td><?php echo give_currency_filter(give_format_amount($estimated['earnings'])); ?></td>
219 219
 					</tr>
220 220
 					<tr class="alternate">
221
-						<th scope="row"><strong><?php esc_html_e( 'Estimated monthly donations:', 'give' ); ?></strong></th>
222
-						<td><?php echo floor( $estimated['sales'] ); ?></td>
221
+						<th scope="row"><strong><?php esc_html_e('Estimated monthly donations:', 'give'); ?></strong></th>
222
+						<td><?php echo floor($estimated['sales']); ?></td>
223 223
 					</tr>
224 224
 				<?php endif; ?>
225 225
 			</table>
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 			 *
233 233
 			 * @since 1.0
234 234
 			 */
235
-			do_action( 'give_reports_graph_additional_stats' );
235
+			do_action('give_reports_graph_additional_stats');
236 236
 			?>
237 237
 
238 238
 		</div>
@@ -251,12 +251,12 @@  discard block
 block discarded – undo
251 251
  * @since 1.0
252 252
  * @return void
253 253
  */
254
-function give_reports_graph_of_form( $form_id = 0 ) {
254
+function give_reports_graph_of_form($form_id = 0) {
255 255
 	// Retrieve the queried dates
256 256
 	$dates = give_get_report_dates();
257 257
 
258 258
 	// Determine graph options
259
-	switch ( $dates['range'] ) :
259
+	switch ($dates['range']) :
260 260
 		case 'today' :
261 261
 		case 'yesterday' :
262 262
 			$day_by_day = true;
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 			$day_by_day = false;
275 275
 			break;
276 276
 		case 'other' :
277
-			if ( $dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year'] ) {
277
+			if ($dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year']) {
278 278
 				$day_by_day = false;
279 279
 			} else {
280 280
 				$day_by_day = true;
@@ -286,75 +286,75 @@  discard block
 block discarded – undo
286 286
 	endswitch;
287 287
 
288 288
 	$earnings_totals = (float) 0.00; // Total earnings for time period shown
289
-	$sales_totals    = 0;            // Total sales for time period shown
289
+	$sales_totals    = 0; // Total sales for time period shown
290 290
 
291 291
 	$earnings_data = array();
292 292
 	$sales_data    = array();
293 293
 	$stats         = new Give_Payment_Stats;
294 294
 
295
-	if ( $dates['range'] == 'today' || $dates['range'] == 'yesterday' ) {
295
+	if ($dates['range'] == 'today' || $dates['range'] == 'yesterday') {
296 296
 
297 297
 		// Hour by hour
298 298
 		$month  = $dates['m_start'];
299 299
 		$hour   = 1;
300 300
 		$minute = 0;
301 301
 		$second = 0;
302
-		while ( $hour <= 23 ) :
302
+		while ($hour <= 23) :
303 303
 
304
-			if ( $hour == 23 ) {
304
+			if ($hour == 23) {
305 305
 				$minute = $second = 59;
306 306
 			}
307 307
 
308
-			$date     = mktime( $hour, $minute, $second, $month, $dates['day'], $dates['year'] );
309
-			$date_end = mktime( $hour + 1, $minute, $second, $month, $dates['day'], $dates['year'] );
308
+			$date     = mktime($hour, $minute, $second, $month, $dates['day'], $dates['year']);
309
+			$date_end = mktime($hour + 1, $minute, $second, $month, $dates['day'], $dates['year']);
310 310
 
311
-			$sales = $stats->get_sales( $form_id, $date, $date_end );
311
+			$sales = $stats->get_sales($form_id, $date, $date_end);
312 312
 			$sales_totals += $sales;
313 313
 
314
-			$earnings = $stats->get_earnings( $form_id, $date, $date_end );
314
+			$earnings = $stats->get_earnings($form_id, $date, $date_end);
315 315
 			$earnings_totals += $earnings;
316 316
 
317
-			$sales_data[]    = array( $date * 1000, $sales );
318
-			$earnings_data[] = array( $date * 1000, $earnings );
317
+			$sales_data[]    = array($date * 1000, $sales);
318
+			$earnings_data[] = array($date * 1000, $earnings);
319 319
 
320
-			$hour ++;
320
+			$hour++;
321 321
 		endwhile;
322 322
 
323
-	} elseif ( $dates['range'] == 'this_week' || $dates['range'] == 'last_week' ) {
323
+	} elseif ($dates['range'] == 'this_week' || $dates['range'] == 'last_week') {
324 324
 
325 325
 		//Day by day
326 326
 		$day     = $dates['day'];
327 327
 		$day_end = $dates['day_end'];
328 328
 		$month   = $dates['m_start'];
329
-		while ( $day <= $day_end ) :
329
+		while ($day <= $day_end) :
330 330
 
331
-			$date     = mktime( 0, 0, 0, $month, $day, $dates['year'] );
332
-			$date_end = mktime( 0, 0, 0, $month, $day + 1, $dates['year'] );
333
-			$sales    = $stats->get_sales( $form_id, $date, $date_end );
331
+			$date     = mktime(0, 0, 0, $month, $day, $dates['year']);
332
+			$date_end = mktime(0, 0, 0, $month, $day + 1, $dates['year']);
333
+			$sales    = $stats->get_sales($form_id, $date, $date_end);
334 334
 			$sales_totals += $sales;
335 335
 
336
-			$earnings = $stats->get_earnings( $form_id, $date, $date_end );
336
+			$earnings = $stats->get_earnings($form_id, $date, $date_end);
337 337
 			$earnings_totals += $earnings;
338 338
 
339
-			$sales_data[]    = array( $date * 1000, $sales );
340
-			$earnings_data[] = array( $date * 1000, $earnings );
339
+			$sales_data[]    = array($date * 1000, $sales);
340
+			$earnings_data[] = array($date * 1000, $earnings);
341 341
 
342
-			$day ++;
342
+			$day++;
343 343
 		endwhile;
344 344
 
345 345
 	} else {
346 346
 
347 347
 		$y = $dates['year'];
348 348
 
349
-		while ( $y <= $dates['year_end'] ) :
349
+		while ($y <= $dates['year_end']) :
350 350
 
351 351
 			$last_year = false;
352 352
 
353
-			if ( $dates['year'] == $dates['year_end'] ) {
353
+			if ($dates['year'] == $dates['year_end']) {
354 354
 				$month_start = $dates['m_start'];
355 355
 				$month_end   = $dates['m_end'];
356 356
 				$last_year   = true;
357
-			} elseif ( $y == $dates['year'] ) {
357
+			} elseif ($y == $dates['year']) {
358 358
 				$month_start = $dates['m_start'];
359 359
 				$month_end   = 12;
360 360
 			} else {
@@ -363,76 +363,76 @@  discard block
 block discarded – undo
363 363
 			}
364 364
 
365 365
 			$i = $month_start;
366
-			while ( $i <= $month_end ) :
366
+			while ($i <= $month_end) :
367 367
 
368
-				if ( $day_by_day ) {
368
+				if ($day_by_day) {
369 369
 
370
-					if ( $i == $month_end && $last_year ) {
370
+					if ($i == $month_end && $last_year) {
371 371
 
372 372
 						$num_of_days = $dates['day_end'];
373 373
 
374 374
 					} else {
375 375
 
376
-						$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
376
+						$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
377 377
 
378 378
 					}
379 379
 
380 380
 					$d = $dates['day'];
381
-					while ( $d <= $num_of_days ) :
381
+					while ($d <= $num_of_days) :
382 382
 
383
-						$date     = mktime( 0, 0, 0, $i, $d, $y );
384
-						$end_date = mktime( 23, 59, 59, $i, $d, $y );
383
+						$date     = mktime(0, 0, 0, $i, $d, $y);
384
+						$end_date = mktime(23, 59, 59, $i, $d, $y);
385 385
 
386
-						$sales = $stats->get_sales( $form_id, $date, $end_date );
386
+						$sales = $stats->get_sales($form_id, $date, $end_date);
387 387
 						$sales_totals += $sales;
388 388
 
389
-						$earnings = $stats->get_earnings( $form_id, $date, $end_date );
389
+						$earnings = $stats->get_earnings($form_id, $date, $end_date);
390 390
 						$earnings_totals += $earnings;
391 391
 
392
-						$sales_data[]    = array( $date * 1000, $sales );
393
-						$earnings_data[] = array( $date * 1000, $earnings );
394
-						$d ++;
392
+						$sales_data[]    = array($date * 1000, $sales);
393
+						$earnings_data[] = array($date * 1000, $earnings);
394
+						$d++;
395 395
 
396 396
 					endwhile;
397 397
 
398 398
 				} else {
399 399
 
400
-					$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
400
+					$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
401 401
 
402
-					$date     = mktime( 0, 0, 0, $i, 1, $y );
403
-					$end_date = mktime( 23, 59, 59, $i, $num_of_days, $y );
402
+					$date     = mktime(0, 0, 0, $i, 1, $y);
403
+					$end_date = mktime(23, 59, 59, $i, $num_of_days, $y);
404 404
 
405
-					$sales = $stats->get_sales( $form_id, $date, $end_date );
405
+					$sales = $stats->get_sales($form_id, $date, $end_date);
406 406
 					$sales_totals += $sales;
407 407
 
408
-					$earnings = $stats->get_earnings( $form_id, $date, $end_date );
408
+					$earnings = $stats->get_earnings($form_id, $date, $end_date);
409 409
 					$earnings_totals += $earnings;
410 410
 
411
-					$sales_data[]    = array( $date * 1000, $sales );
412
-					$earnings_data[] = array( $date * 1000, $earnings );
411
+					$sales_data[]    = array($date * 1000, $sales);
412
+					$earnings_data[] = array($date * 1000, $earnings);
413 413
 
414 414
 				}
415 415
 
416
-				$i ++;
416
+				$i++;
417 417
 
418 418
 			endwhile;
419 419
 
420
-			$y ++;
420
+			$y++;
421 421
 		endwhile;
422 422
 
423 423
 	}
424 424
 
425 425
 	$data = array(
426
-		esc_html__( 'Income', 'give' )    => $earnings_data,
427
-		esc_html__( 'Donations', 'give' ) => $sales_data
426
+		esc_html__('Income', 'give')    => $earnings_data,
427
+		esc_html__('Donations', 'give') => $sales_data
428 428
 	);
429 429
 
430 430
 	?>
431 431
 	<h3><span><?php
432 432
 		printf(
433 433
 			/* translators: %s: form title */
434
-			esc_html__( 'Income Report for %s', 'give' ),
435
-			get_the_title( $form_id )
434
+			esc_html__('Income Report for %s', 'give'),
435
+			get_the_title($form_id)
436 436
 		);
437 437
 	?></span></h3>
438 438
 	<div id="give-dashboard-widgets-wrap">
@@ -441,9 +441,9 @@  discard block
 block discarded – undo
441 441
 				<div class="inside">
442 442
 					<?php give_reports_graph_controls(); ?>
443 443
 					<?php
444
-					$graph = new Give_Graph( $data );
445
-					$graph->set( 'x_mode', 'time' );
446
-					$graph->set( 'multiple_y_axes', true );
444
+					$graph = new Give_Graph($data);
445
+					$graph->set('x_mode', 'time');
446
+					$graph->set('multiple_y_axes', true);
447 447
 					$graph->display();
448 448
 					?>
449 449
 				</div>
@@ -452,20 +452,20 @@  discard block
 block discarded – undo
452 452
 			<table class="widefat reports-table alignleft" style="max-width:450px">
453 453
 				<tbody>
454 454
 				<tr>
455
-					<th scope="row"><strong><?php esc_html_e( 'Total income for period:', 'give' ); ?></strong></th>
456
-					<td><?php echo give_currency_filter( give_format_amount( $earnings_totals ) ); ?></td>
455
+					<th scope="row"><strong><?php esc_html_e('Total income for period:', 'give'); ?></strong></th>
456
+					<td><?php echo give_currency_filter(give_format_amount($earnings_totals)); ?></td>
457 457
 				</tr>
458 458
 				<tr class="alternate">
459
-					<th scope="row"><strong><?php esc_html_e( 'Total donations for period:', 'give' ); ?></strong></th>
459
+					<th scope="row"><strong><?php esc_html_e('Total donations for period:', 'give'); ?></strong></th>
460 460
 					<td><?php echo $sales_totals; ?></td>
461 461
 				</tr>
462 462
 				<tr>
463
-					<th scope="row"><strong><?php esc_html_e( 'Average monthly income:', 'give' ); ?></strong></th>
464
-					<td><?php echo give_currency_filter( give_format_amount( give_get_average_monthly_form_earnings( $form_id ) ) ); ?></td>
463
+					<th scope="row"><strong><?php esc_html_e('Average monthly income:', 'give'); ?></strong></th>
464
+					<td><?php echo give_currency_filter(give_format_amount(give_get_average_monthly_form_earnings($form_id))); ?></td>
465 465
 				</tr>
466 466
 				<tr class="alternate">
467
-					<th scope="row"><strong><?php esc_html_e( 'Average monthly donations:', 'give' ); ?></strong></th>
468
-					<td><?php echo number_format( give_get_average_monthly_form_sales( $form_id ), 0 ); ?></td>
467
+					<th scope="row"><strong><?php esc_html_e('Average monthly donations:', 'give'); ?></strong></th>
468
+					<td><?php echo number_format(give_get_average_monthly_form_sales($form_id), 0); ?></td>
469 469
 				</tr>
470 470
 				</tbody>
471 471
 			</table>
@@ -484,26 +484,26 @@  discard block
 block discarded – undo
484 484
  * @return void
485 485
  */
486 486
 function give_reports_graph_controls() {
487
-	$date_options = apply_filters( 'give_report_date_options', array(
488
-		'today'        => esc_html__( 'Today', 'give' ),
489
-		'yesterday'    => esc_html__( 'Yesterday', 'give' ),
490
-		'this_week'    => esc_html__( 'This Week', 'give' ),
491
-		'last_week'    => esc_html__( 'Last Week', 'give' ),
492
-		'this_month'   => esc_html__( 'This Month', 'give' ),
493
-		'last_month'   => esc_html__( 'Last Month', 'give' ),
494
-		'this_quarter' => esc_html__( 'This Quarter', 'give' ),
495
-		'last_quarter' => esc_html__( 'Last Quarter', 'give' ),
496
-		'this_year'    => esc_html__( 'This Year', 'give' ),
497
-		'last_year'    => esc_html__( 'Last Year', 'give' ),
498
-		'other'        => esc_html__( 'Custom', 'give' )
499
-	) );
487
+	$date_options = apply_filters('give_report_date_options', array(
488
+		'today'        => esc_html__('Today', 'give'),
489
+		'yesterday'    => esc_html__('Yesterday', 'give'),
490
+		'this_week'    => esc_html__('This Week', 'give'),
491
+		'last_week'    => esc_html__('Last Week', 'give'),
492
+		'this_month'   => esc_html__('This Month', 'give'),
493
+		'last_month'   => esc_html__('Last Month', 'give'),
494
+		'this_quarter' => esc_html__('This Quarter', 'give'),
495
+		'last_quarter' => esc_html__('Last Quarter', 'give'),
496
+		'this_year'    => esc_html__('This Year', 'give'),
497
+		'last_year'    => esc_html__('Last Year', 'give'),
498
+		'other'        => esc_html__('Custom', 'give')
499
+	));
500 500
 
501 501
 	$dates   = give_get_report_dates();
502 502
 	$display = $dates['range'] == 'other' ? '' : 'display: none;';
503
-	$tab     = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'earnings';
503
+	$tab     = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'earnings';
504 504
 
505
-	if ( empty( $dates['day_end'] ) ) {
506
-		$dates['day_end'] = cal_days_in_month( CAL_GREGORIAN, date( 'n' ), date( 'Y' ) );
505
+	if (empty($dates['day_end'])) {
506
+		$dates['day_end'] = cal_days_in_month(CAL_GREGORIAN, date('n'), date('Y'));
507 507
 	}
508 508
 
509 509
 	/**
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
 	 *
512 512
 	 * @since 1.0
513 513
 	 */
514
-	do_action( 'give_report_graph_controls_before' );
514
+	do_action('give_report_graph_controls_before');
515 515
 	?>
516 516
 	<form id="give-graphs-filter" method="get">
517 517
 		<div class="tablenav top">
@@ -519,56 +519,56 @@  discard block
 block discarded – undo
519 519
 
520 520
 				<input type="hidden" name="post_type" value="give_forms" />
521 521
 				<input type="hidden" name="page" value="give-reports" />
522
-				<input type="hidden" name="tab" value="<?php echo esc_attr( $tab ); ?>" />
522
+				<input type="hidden" name="tab" value="<?php echo esc_attr($tab); ?>" />
523 523
 
524
-				<?php if ( isset( $_GET['form-id'] ) ) : ?>
525
-					<input type="hidden" name="form-id" value="<?php echo absint( $_GET['form-id'] ); ?>" />
524
+				<?php if (isset($_GET['form-id'])) : ?>
525
+					<input type="hidden" name="form-id" value="<?php echo absint($_GET['form-id']); ?>" />
526 526
 				<?php endif; ?>
527 527
 
528 528
 				<div id="give-graphs-date-options-wrap">
529 529
 					<select id="give-graphs-date-options" name="range">
530
-						<?php foreach ( $date_options as $key => $option ) : ?>
531
-							<option value="<?php echo esc_attr( $key ); ?>"<?php selected( $key, $dates['range'] ); ?>><?php echo esc_html( $option ); ?></option>
530
+						<?php foreach ($date_options as $key => $option) : ?>
531
+							<option value="<?php echo esc_attr($key); ?>"<?php selected($key, $dates['range']); ?>><?php echo esc_html($option); ?></option>
532 532
 						<?php endforeach; ?>
533 533
 					</select>
534 534
 
535
-					<div id="give-date-range-options" style="<?php echo esc_attr( $display ); ?>">
536
-						<span class="screen-reader-text"><?php esc_html_e( 'From', 'give' ); ?>&nbsp;</span>
535
+					<div id="give-date-range-options" style="<?php echo esc_attr($display); ?>">
536
+						<span class="screen-reader-text"><?php esc_html_e('From', 'give'); ?>&nbsp;</span>
537 537
 						<select id="give-graphs-month-start" name="m_start" aria-label="Start Month">
538
-							<?php for ( $i = 1; $i <= 12; $i ++ ) : ?>
539
-								<option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['m_start'] ) ); ?>><?php echo esc_html( give_month_num_to_name( $i ) ); ?></option>
538
+							<?php for ($i = 1; $i <= 12; $i++) : ?>
539
+								<option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['m_start'])); ?>><?php echo esc_html(give_month_num_to_name($i)); ?></option>
540 540
 							<?php endfor; ?>
541 541
 						</select>
542 542
 						<select id="give-graphs-day-start" name="day" aria-label="Start Day">
543
-							<?php for ( $i = 1; $i <= 31; $i ++ ) : ?>
544
-								<option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['day'] ) ); ?>><?php echo esc_html( $i ); ?></option>
543
+							<?php for ($i = 1; $i <= 31; $i++) : ?>
544
+								<option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['day'])); ?>><?php echo esc_html($i); ?></option>
545 545
 							<?php endfor; ?>
546 546
 						</select>
547 547
 						<select id="give-graphs-year-start" name="year" aria-label="Start Year">
548
-							<?php for ( $i = 2007; $i <= date( 'Y' ); $i ++ ) : ?>
549
-								<option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['year'] ) ); ?>><?php echo esc_html( $i ); ?></option>
548
+							<?php for ($i = 2007; $i <= date('Y'); $i++) : ?>
549
+								<option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['year'])); ?>><?php echo esc_html($i); ?></option>
550 550
 							<?php endfor; ?>
551 551
 						</select>
552
-						<span class="screen-reader-text"><?php esc_html_e( 'To', 'give' ); ?>&nbsp;</span>
552
+						<span class="screen-reader-text"><?php esc_html_e('To', 'give'); ?>&nbsp;</span>
553 553
 						<span>&ndash;</span>
554 554
 						<select id="give-graphs-month-end" name="m_end" aria-label="End Month">
555
-							<?php for ( $i = 1; $i <= 12; $i ++ ) : ?>
556
-								<option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['m_end'] ) ); ?>><?php echo esc_html( give_month_num_to_name( $i ) ); ?></option>
555
+							<?php for ($i = 1; $i <= 12; $i++) : ?>
556
+								<option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['m_end'])); ?>><?php echo esc_html(give_month_num_to_name($i)); ?></option>
557 557
 							<?php endfor; ?>
558 558
 						</select>
559 559
 						<select id="give-graphs-day-end" name="day_end" aria-label="End Day">
560
-							<?php for ( $i = 1; $i <= 31; $i ++ ) : ?>
561
-								<option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['day_end'] ) ); ?>><?php echo esc_html( $i ); ?></option>
560
+							<?php for ($i = 1; $i <= 31; $i++) : ?>
561
+								<option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['day_end'])); ?>><?php echo esc_html($i); ?></option>
562 562
 							<?php endfor; ?>
563 563
 						</select>
564 564
 						<select id="give-graphs-year-end" name="year_end" aria-label="End Year">
565
-							<?php for ( $i = 2007; $i <= date( 'Y' ); $i ++ ) : ?>
566
-								<option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['year_end'] ) ); ?>><?php echo esc_html( $i ); ?></option>
565
+							<?php for ($i = 2007; $i <= date('Y'); $i++) : ?>
566
+								<option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['year_end'])); ?>><?php echo esc_html($i); ?></option>
567 567
 							<?php endfor; ?>
568 568
 						</select>
569 569
 					</div>
570 570
 
571
-					<input type="submit" class="button-secondary" value="<?php esc_attr_e( 'Filter', 'give' ); ?>" />
571
+					<input type="submit" class="button-secondary" value="<?php esc_attr_e('Filter', 'give'); ?>" />
572 572
 				</div>
573 573
 
574 574
 				<input type="hidden" name="give_action" value="filter_reports" />
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
 	 *
582 582
 	 * @since 1.0
583 583
 	 */
584
-	do_action( 'give_report_graph_controls_after' );
584
+	do_action('give_report_graph_controls_after');
585 585
 }
586 586
 
587 587
 /**
@@ -596,65 +596,65 @@  discard block
 block discarded – undo
596 596
 function give_get_report_dates() {
597 597
 	$dates = array();
598 598
 
599
-	$current_time = current_time( 'timestamp' );
599
+	$current_time = current_time('timestamp');
600 600
 
601
-	$dates['range']    = isset( $_GET['range'] ) ? $_GET['range'] : 'this_month';
602
-	$dates['year']     = isset( $_GET['year'] ) ? $_GET['year'] : date( 'Y' );
603
-	$dates['year_end'] = isset( $_GET['year_end'] ) ? $_GET['year_end'] : date( 'Y' );
604
-	$dates['m_start']  = isset( $_GET['m_start'] ) ? $_GET['m_start'] : 1;
605
-	$dates['m_end']    = isset( $_GET['m_end'] ) ? $_GET['m_end'] : 12;
606
-	$dates['day']      = isset( $_GET['day'] ) ? $_GET['day'] : 1;
607
-	$dates['day_end']  = isset( $_GET['day_end'] ) ? $_GET['day_end'] : cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] );
601
+	$dates['range']    = isset($_GET['range']) ? $_GET['range'] : 'this_month';
602
+	$dates['year']     = isset($_GET['year']) ? $_GET['year'] : date('Y');
603
+	$dates['year_end'] = isset($_GET['year_end']) ? $_GET['year_end'] : date('Y');
604
+	$dates['m_start']  = isset($_GET['m_start']) ? $_GET['m_start'] : 1;
605
+	$dates['m_end']    = isset($_GET['m_end']) ? $_GET['m_end'] : 12;
606
+	$dates['day']      = isset($_GET['day']) ? $_GET['day'] : 1;
607
+	$dates['day_end']  = isset($_GET['day_end']) ? $_GET['day_end'] : cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']);
608 608
 
609 609
 	// Modify dates based on predefined ranges
610
-	switch ( $dates['range'] ) :
610
+	switch ($dates['range']) :
611 611
 
612 612
 		case 'this_month' :
613
-			$dates['m_start']  = date( 'n', $current_time );
614
-			$dates['m_end']    = date( 'n', $current_time );
613
+			$dates['m_start']  = date('n', $current_time);
614
+			$dates['m_end']    = date('n', $current_time);
615 615
 			$dates['day']      = 1;
616
-			$dates['day_end']  = cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] );
617
-			$dates['year']     = date( 'Y' );
618
-			$dates['year_end'] = date( 'Y' );
616
+			$dates['day_end']  = cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']);
617
+			$dates['year']     = date('Y');
618
+			$dates['year_end'] = date('Y');
619 619
 			break;
620 620
 
621 621
 		case 'last_month' :
622
-			if ( date( 'n' ) == 1 ) {
622
+			if (date('n') == 1) {
623 623
 				$dates['m_start']  = 12;
624 624
 				$dates['m_end']    = 12;
625
-				$dates['year']     = date( 'Y', $current_time ) - 1;
626
-				$dates['year_end'] = date( 'Y', $current_time ) - 1;
625
+				$dates['year']     = date('Y', $current_time) - 1;
626
+				$dates['year_end'] = date('Y', $current_time) - 1;
627 627
 			} else {
628
-				$dates['m_start']  = date( 'n' ) - 1;
629
-				$dates['m_end']    = date( 'n' ) - 1;
628
+				$dates['m_start']  = date('n') - 1;
629
+				$dates['m_end']    = date('n') - 1;
630 630
 				$dates['year_end'] = $dates['year'];
631 631
 			}
632
-			$dates['day_end'] = cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] );
632
+			$dates['day_end'] = cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']);
633 633
 			break;
634 634
 
635 635
 		case 'today' :
636
-			$dates['day']     = date( 'd', $current_time );
637
-			$dates['m_start'] = date( 'n', $current_time );
638
-			$dates['m_end']   = date( 'n', $current_time );
639
-			$dates['year']    = date( 'Y', $current_time );
636
+			$dates['day']     = date('d', $current_time);
637
+			$dates['m_start'] = date('n', $current_time);
638
+			$dates['m_end']   = date('n', $current_time);
639
+			$dates['year']    = date('Y', $current_time);
640 640
 			break;
641 641
 
642 642
 		case 'yesterday' :
643 643
 
644
-			$year  = date( 'Y', $current_time );
645
-			$month = date( 'n', $current_time );
646
-			$day   = date( 'd', $current_time );
644
+			$year  = date('Y', $current_time);
645
+			$month = date('n', $current_time);
646
+			$day   = date('d', $current_time);
647 647
 
648
-			if ( $month == 1 && $day == 1 ) {
648
+			if ($month == 1 && $day == 1) {
649 649
 
650 650
 				$year -= 1;
651 651
 				$month = 12;
652
-				$day   = cal_days_in_month( CAL_GREGORIAN, $month, $year );
652
+				$day   = cal_days_in_month(CAL_GREGORIAN, $month, $year);
653 653
 
654
-			} elseif ( $month > 1 && $day == 1 ) {
654
+			} elseif ($month > 1 && $day == 1) {
655 655
 
656 656
 				$month -= 1;
657
-				$day = cal_days_in_month( CAL_GREGORIAN, $month, $year );
657
+				$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
658 658
 
659 659
 			} else {
660 660
 
@@ -670,91 +670,91 @@  discard block
 block discarded – undo
670 670
 			break;
671 671
 
672 672
 		case 'this_week' :
673
-			$dates['day'] = date( 'd', $current_time - ( date( 'w', $current_time ) - 1 ) * 60 * 60 * 24 ) - 1;
674
-			$dates['day'] += get_option( 'start_of_week' );
673
+			$dates['day'] = date('d', $current_time - (date('w', $current_time) - 1) * 60 * 60 * 24) - 1;
674
+			$dates['day'] += get_option('start_of_week');
675 675
 			$dates['day_end'] = $dates['day'] + 6;
676
-			$dates['m_start'] = date( 'n', $current_time );
677
-			$dates['m_end']   = date( 'n', $current_time );
678
-			$dates['year']    = date( 'Y', $current_time );
676
+			$dates['m_start'] = date('n', $current_time);
677
+			$dates['m_end']   = date('n', $current_time);
678
+			$dates['year']    = date('Y', $current_time);
679 679
 			break;
680 680
 
681 681
 		case 'last_week' :
682
-			$dates['day'] = date( 'd', $current_time - ( date( 'w' ) - 1 ) * 60 * 60 * 24 ) - 8;
683
-			$dates['day'] += get_option( 'start_of_week' );
682
+			$dates['day'] = date('d', $current_time - (date('w') - 1) * 60 * 60 * 24) - 8;
683
+			$dates['day'] += get_option('start_of_week');
684 684
 			$dates['day_end'] = $dates['day'] + 6;
685
-			$dates['year']    = date( 'Y' );
686
-
687
-			if ( date( 'j', $current_time ) <= 7 ) {
688
-				$dates['m_start'] = date( 'n', $current_time ) - 1;
689
-				$dates['m_end']   = date( 'n', $current_time ) - 1;
690
-				if ( $dates['m_start'] <= 1 ) {
691
-					$dates['year']     = date( 'Y', $current_time ) - 1;
692
-					$dates['year_end'] = date( 'Y', $current_time ) - 1;
685
+			$dates['year']    = date('Y');
686
+
687
+			if (date('j', $current_time) <= 7) {
688
+				$dates['m_start'] = date('n', $current_time) - 1;
689
+				$dates['m_end']   = date('n', $current_time) - 1;
690
+				if ($dates['m_start'] <= 1) {
691
+					$dates['year']     = date('Y', $current_time) - 1;
692
+					$dates['year_end'] = date('Y', $current_time) - 1;
693 693
 				}
694 694
 			} else {
695
-				$dates['m_start'] = date( 'n', $current_time );
696
-				$dates['m_end']   = date( 'n', $current_time );
695
+				$dates['m_start'] = date('n', $current_time);
696
+				$dates['m_end']   = date('n', $current_time);
697 697
 			}
698 698
 			break;
699 699
 
700 700
 		case 'this_quarter' :
701
-			$month_now = date( 'n', $current_time );
701
+			$month_now = date('n', $current_time);
702 702
 
703
-			if ( $month_now <= 3 ) {
703
+			if ($month_now <= 3) {
704 704
 
705 705
 				$dates['m_start'] = 1;
706 706
 				$dates['m_end']   = 4;
707
-				$dates['year']    = date( 'Y', $current_time );
707
+				$dates['year']    = date('Y', $current_time);
708 708
 
709
-			} else if ( $month_now <= 6 ) {
709
+			} else if ($month_now <= 6) {
710 710
 
711 711
 				$dates['m_start'] = 4;
712 712
 				$dates['m_end']   = 7;
713
-				$dates['year']    = date( 'Y', $current_time );
713
+				$dates['year']    = date('Y', $current_time);
714 714
 
715
-			} else if ( $month_now <= 9 ) {
715
+			} else if ($month_now <= 9) {
716 716
 
717 717
 				$dates['m_start'] = 7;
718 718
 				$dates['m_end']   = 10;
719
-				$dates['year']    = date( 'Y', $current_time );
719
+				$dates['year']    = date('Y', $current_time);
720 720
 
721 721
 			} else {
722 722
 
723 723
 				$dates['m_start']  = 10;
724 724
 				$dates['m_end']    = 1;
725
-				$dates['year']     = date( 'Y', $current_time );
726
-				$dates['year_end'] = date( 'Y', $current_time ) + 1;
725
+				$dates['year']     = date('Y', $current_time);
726
+				$dates['year_end'] = date('Y', $current_time) + 1;
727 727
 
728 728
 			}
729 729
 			break;
730 730
 
731 731
 		case 'last_quarter' :
732
-			$month_now = date( 'n' );
732
+			$month_now = date('n');
733 733
 
734
-			if ( $month_now <= 3 ) {
734
+			if ($month_now <= 3) {
735 735
 
736 736
 				$dates['m_start']  = 10;
737 737
 				$dates['m_end']    = 12;
738
-				$dates['year']     = date( 'Y', $current_time ) - 1; // Previous year
739
-				$dates['year_end'] = date( 'Y', $current_time ) - 1; // Previous year
738
+				$dates['year']     = date('Y', $current_time) - 1; // Previous year
739
+				$dates['year_end'] = date('Y', $current_time) - 1; // Previous year
740 740
 
741
-			} else if ( $month_now <= 6 ) {
741
+			} else if ($month_now <= 6) {
742 742
 
743 743
 				$dates['m_start'] = 1;
744 744
 				$dates['m_end']   = 3;
745
-				$dates['year']    = date( 'Y', $current_time );
745
+				$dates['year']    = date('Y', $current_time);
746 746
 
747
-			} else if ( $month_now <= 9 ) {
747
+			} else if ($month_now <= 9) {
748 748
 
749 749
 				$dates['m_start'] = 4;
750 750
 				$dates['m_end']   = 6;
751
-				$dates['year']    = date( 'Y', $current_time );
751
+				$dates['year']    = date('Y', $current_time);
752 752
 
753 753
 			} else {
754 754
 
755 755
 				$dates['m_start'] = 7;
756 756
 				$dates['m_end']   = 9;
757
-				$dates['year']    = date( 'Y', $current_time );
757
+				$dates['year']    = date('Y', $current_time);
758 758
 
759 759
 			}
760 760
 			break;
@@ -762,19 +762,19 @@  discard block
 block discarded – undo
762 762
 		case 'this_year' :
763 763
 			$dates['m_start'] = 1;
764 764
 			$dates['m_end']   = 12;
765
-			$dates['year']    = date( 'Y', $current_time );
765
+			$dates['year']    = date('Y', $current_time);
766 766
 			break;
767 767
 
768 768
 		case 'last_year' :
769 769
 			$dates['m_start']  = 1;
770 770
 			$dates['m_end']    = 12;
771
-			$dates['year']     = date( 'Y', $current_time ) - 1;
772
-			$dates['year_end'] = date( 'Y', $current_time ) - 1;
771
+			$dates['year']     = date('Y', $current_time) - 1;
772
+			$dates['year_end'] = date('Y', $current_time) - 1;
773 773
 			break;
774 774
 
775 775
 	endswitch;
776 776
 
777
-	return apply_filters( 'give_report_dates', $dates );
777
+	return apply_filters('give_report_dates', $dates);
778 778
 }
779 779
 
780 780
 /**
@@ -785,18 +785,18 @@  discard block
 block discarded – undo
785 785
  *
786 786
  * @param $data
787 787
  */
788
-function give_parse_report_dates( $data ) {
788
+function give_parse_report_dates($data) {
789 789
 	$dates = give_get_report_dates();
790 790
 
791 791
 	$view = give_get_reporting_view();
792
-	$tab  = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'earnings';
793
-	$id   = isset( $_GET['form-id'] ) ? $_GET['form-id'] : null;
792
+	$tab  = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'earnings';
793
+	$id   = isset($_GET['form-id']) ? $_GET['form-id'] : null;
794 794
 
795
-	wp_redirect( add_query_arg( $dates, admin_url( 'edit.php?post_type=give_forms&page=give-reports&tab=' . esc_attr( $tab ) . '&view=' . esc_attr( $view ) . '&form-id=' . absint( $id ) ) ) );
795
+	wp_redirect(add_query_arg($dates, admin_url('edit.php?post_type=give_forms&page=give-reports&tab='.esc_attr($tab).'&view='.esc_attr($view).'&form-id='.absint($id))));
796 796
 	give_die();
797 797
 }
798 798
 
799
-add_action( 'give_filter_reports', 'give_parse_report_dates' );
799
+add_action('give_filter_reports', 'give_parse_report_dates');
800 800
 
801 801
 
802 802
 /**
@@ -808,22 +808,22 @@  discard block
 block discarded – undo
808 808
  */
809 809
 function give_reports_refresh_button() {
810 810
 
811
-	$url = wp_nonce_url( add_query_arg( array(
811
+	$url = wp_nonce_url(add_query_arg(array(
812 812
 		'give_action'  => 'refresh_reports_transients',
813 813
 		'give-message' => 'refreshed-reports'
814
-	) ), 'give-refresh-reports' );
814
+	)), 'give-refresh-reports');
815 815
 
816 816
 	echo '<a href="'
817
-	     . esc_url_raw( $url )
818
-	     . '" data-tooltip="'. esc_attr__( 'Clicking this will clear the reports cache.', 'give' )
817
+	     . esc_url_raw($url)
818
+	     . '" data-tooltip="'.esc_attr__('Clicking this will clear the reports cache.', 'give')
819 819
 	     . '" data-tooltip-my-position="right center"  data-tooltip-target-position="left center" class="button alignright give-admin-button give-tooltip">'
820 820
 	     . '<span class="give-admin-button-icon give-admin-button-icon-update"></span>'
821
-	     . esc_html__( 'Refresh Report Data', 'give' )
821
+	     . esc_html__('Refresh Report Data', 'give')
822 822
 	     . '</a>';
823 823
 
824 824
 }
825 825
 
826
-add_action( 'give_reports_graph_additional_stats', 'give_reports_refresh_button' );
826
+add_action('give_reports_graph_additional_stats', 'give_reports_refresh_button');
827 827
 
828 828
 /**
829 829
  * Trigger the refresh of reports transients
@@ -834,20 +834,20 @@  discard block
 block discarded – undo
834 834
  *
835 835
  * @return void
836 836
  */
837
-function give_run_refresh_reports_transients( $data ) {
837
+function give_run_refresh_reports_transients($data) {
838 838
 
839
-	if ( ! wp_verify_nonce( $data['_wpnonce'], 'give-refresh-reports' ) ) {
839
+	if ( ! wp_verify_nonce($data['_wpnonce'], 'give-refresh-reports')) {
840 840
 		return;
841 841
 	}
842 842
 
843 843
 	// Monthly stats.
844
-	Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) );
844
+	Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats'));
845 845
 
846 846
 	// Total earning.
847
-	delete_option( 'give_earnings_total' );
847
+	delete_option('give_earnings_total');
848 848
 
849 849
 	// @todo: Refresh only range related stat cache
850 850
 	give_delete_donation_stats();
851 851
 }
852 852
 
853
-add_action( 'give_refresh_reports_transients', 'give_run_refresh_reports_transients' );
854 853
\ No newline at end of file
854
+add_action('give_refresh_reports_transients', 'give_run_refresh_reports_transients');
855 855
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/reporting/export/class-batch-export-customers.php 1 patch
Spacing   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly.
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -62,26 +62,26 @@  discard block
 block discarded – undo
62 62
 	 *
63 63
 	 * @param array $request The Form Data passed into the batch processing
64 64
 	 */
65
-	public function set_properties( $request ) {
65
+	public function set_properties($request) {
66 66
 
67 67
 		// Set data from form submission
68
-		if ( isset( $_POST['form'] ) ) {
69
-			parse_str( $_POST['form'], $this->data );
68
+		if (isset($_POST['form'])) {
69
+			parse_str($_POST['form'], $this->data);
70 70
 		}
71 71
 
72 72
 		$this->form = $this->data['forms'];
73 73
 
74 74
 		// Setup donor ids cache.
75
-		if( ! empty( $this->form ) ) {
75
+		if ( ! empty($this->form)) {
76 76
 			// Cache donor ids to output unique list of donor.
77
-			$this->query_id = give_clean( $_REQUEST['give_export_option']['query_id'] );
78
-			if( ! ( $this->donor_ids = Give_Cache::get( $this->query_id, true ) ) ) {
77
+			$this->query_id = give_clean($_REQUEST['give_export_option']['query_id']);
78
+			if ( ! ($this->donor_ids = Give_Cache::get($this->query_id, true))) {
79 79
 				$this->donor_ids = array();
80
-				Give_Cache::set( $this->query_id, $this->donor_ids, HOUR_IN_SECONDS, true );
80
+				Give_Cache::set($this->query_id, $this->donor_ids, HOUR_IN_SECONDS, true);
81 81
 			}
82 82
 		}
83 83
 
84
-		$this->price_id = ! empty( $request['give_price_option'] ) && 'all' !== $request['give_price_option'] ? absint( $request['give_price_option'] ) : null;
84
+		$this->price_id = ! empty($request['give_price_option']) && 'all' !== $request['give_price_option'] ? absint($request['give_price_option']) : null;
85 85
 
86 86
 	}
87 87
 
@@ -94,14 +94,14 @@  discard block
 block discarded – undo
94 94
 	 */
95 95
 	public function csv_cols() {
96 96
 
97
-		$columns = isset( $this->data['give_export_option'] ) ? $this->data['give_export_option'] : array();
97
+		$columns = isset($this->data['give_export_option']) ? $this->data['give_export_option'] : array();
98 98
 
99 99
 		// We need columns.
100
-		if ( empty( $columns ) ) {
100
+		if (empty($columns)) {
101 101
 			return false;
102 102
 		}
103 103
 
104
-		$cols = $this->get_cols( $columns );
104
+		$cols = $this->get_cols($columns);
105 105
 
106 106
 		return $cols;
107 107
 	}
@@ -113,38 +113,38 @@  discard block
 block discarded – undo
113 113
 	 *
114 114
 	 * @return array
115 115
 	 */
116
-	private function get_cols( $columns ) {
116
+	private function get_cols($columns) {
117 117
 
118 118
 		$cols = array();
119 119
 
120
-		foreach ( $columns as $key => $value ) {
120
+		foreach ($columns as $key => $value) {
121 121
 
122
-			switch ( $key ) {
122
+			switch ($key) {
123 123
 				case 'full_name' :
124
-					$cols['full_name'] = esc_html__( 'Full Name', 'give' );
124
+					$cols['full_name'] = esc_html__('Full Name', 'give');
125 125
 					break;
126 126
 				case 'email' :
127
-					$cols['email'] = esc_html__( 'Email Address', 'give' );
127
+					$cols['email'] = esc_html__('Email Address', 'give');
128 128
 					break;
129 129
 				case 'address' :
130
-					$cols['address_line1']   = esc_html__( 'Address', 'give' );
131
-					$cols['address_line2']   = esc_html__( 'Address 2', 'give' );
132
-					$cols['address_city']    = esc_html__( 'City', 'give' );
133
-					$cols['address_state']   = esc_html__( 'State', 'give' );
134
-					$cols['address_zip']     = esc_html__( 'Zip', 'give' );
135
-					$cols['address_country'] = esc_html__( 'Country', 'give' );
130
+					$cols['address_line1']   = esc_html__('Address', 'give');
131
+					$cols['address_line2']   = esc_html__('Address 2', 'give');
132
+					$cols['address_city']    = esc_html__('City', 'give');
133
+					$cols['address_state']   = esc_html__('State', 'give');
134
+					$cols['address_zip']     = esc_html__('Zip', 'give');
135
+					$cols['address_country'] = esc_html__('Country', 'give');
136 136
 					break;
137 137
 				case 'userid' :
138
-					$cols['userid'] = esc_html__( 'User ID', 'give' );
138
+					$cols['userid'] = esc_html__('User ID', 'give');
139 139
 					break;
140 140
 				case 'date_first_donated' :
141
-					$cols['date_first_donated'] = esc_html__( 'First Donation Date', 'give' );
141
+					$cols['date_first_donated'] = esc_html__('First Donation Date', 'give');
142 142
 					break;
143 143
 				case 'donations' :
144
-					$cols['donations'] = esc_html__( 'Number of Donations', 'give' );
144
+					$cols['donations'] = esc_html__('Number of Donations', 'give');
145 145
 					break;
146 146
 				case 'donation_sum' :
147
-					$cols['donation_sum'] = esc_html__( 'Sum of Donations', 'give' );
147
+					$cols['donation_sum'] = esc_html__('Sum of Donations', 'give');
148 148
 					break;
149 149
 			}
150 150
 		}
@@ -167,20 +167,20 @@  discard block
 block discarded – undo
167 167
 
168 168
 		$i = 0;
169 169
 
170
-		if ( ! empty( $this->form ) ) {
170
+		if ( ! empty($this->form)) {
171 171
 
172 172
 			// Export donors of a specific product
173 173
 			global $give_logs;
174 174
 
175 175
 			$args = array(
176
-				'post_parent'    => absint( $this->form ),
176
+				'post_parent'    => absint($this->form),
177 177
 				'log_type'       => 'sale',
178 178
 				'posts_per_page' => 30,
179 179
 				'paged'          => $this->step,
180 180
 			);
181 181
 
182 182
 			// Check for price option
183
-			if ( null !== $this->price_id ) {
183
+			if (null !== $this->price_id) {
184 184
 				$args['meta_query'] = array(
185 185
 					array(
186 186
 						'key'   => '_give_log_price_id',
@@ -189,44 +189,44 @@  discard block
 block discarded – undo
189 189
 				);
190 190
 			}
191 191
 
192
-			$logs = $give_logs->get_connected_logs( $args );
192
+			$logs = $give_logs->get_connected_logs($args);
193 193
 
194
-			if ( $logs ) {
195
-				foreach ( $logs as $log ) {
196
-					$payment_id = get_post_meta( $log->ID, '_give_log_payment_id', true );
197
-					$payment    = new Give_Payment( $payment_id );
194
+			if ($logs) {
195
+				foreach ($logs as $log) {
196
+					$payment_id = get_post_meta($log->ID, '_give_log_payment_id', true);
197
+					$payment    = new Give_Payment($payment_id);
198 198
 
199 199
 					// Continue if donor already included.
200
-					if( in_array( $payment->customer_id , $this->donor_ids ) ) {
200
+					if (in_array($payment->customer_id, $this->donor_ids)) {
201 201
 						continue;
202 202
 					}
203 203
 
204 204
 					$this->donor_ids[] = $payment->customer_id;
205 205
 
206
-					$donor      = Give()->customers->get_customer_by( 'id', $payment->customer_id );
207
-					$data[]     = $this->set_donor_data( $i, $data, $donor );
208
-					$i ++;
206
+					$donor      = Give()->customers->get_customer_by('id', $payment->customer_id);
207
+					$data[]     = $this->set_donor_data($i, $data, $donor);
208
+					$i++;
209 209
 				}
210 210
 
211 211
 				// Cache donor ids only if admin export donor for specific form.
212
-				Give_Cache::set( $this->query_id, array_unique( $this->donor_ids ), HOUR_IN_SECONDS, true );
212
+				Give_Cache::set($this->query_id, array_unique($this->donor_ids), HOUR_IN_SECONDS, true);
213 213
 			}
214 214
 		} else {
215 215
 
216 216
 			// Export all donors.
217
-			$offset = 30 * ( $this->step - 1 );
218
-			$donors = Give()->customers->get_customers( array( 'number' => 30, 'offset' => $offset ) );
217
+			$offset = 30 * ($this->step - 1);
218
+			$donors = Give()->customers->get_customers(array('number' => 30, 'offset' => $offset));
219 219
 
220
-			foreach ( $donors as $donor ) {
220
+			foreach ($donors as $donor) {
221 221
 
222
-				$data[] = $this->set_donor_data( $i, $data, $donor );
223
-				$i ++;
222
+				$data[] = $this->set_donor_data($i, $data, $donor);
223
+				$i++;
224 224
 			}
225 225
 		}
226 226
 
227 227
 
228
-		$data = apply_filters( 'give_export_get_data', $data );
229
-		$data = apply_filters( "give_export_get_data_{$this->export_type}", $data );
228
+		$data = apply_filters('give_export_get_data', $data);
229
+		$data = apply_filters("give_export_get_data_{$this->export_type}", $data);
230 230
 
231 231
 		return $data;
232 232
 	}
@@ -242,18 +242,18 @@  discard block
 block discarded – undo
242 242
 		$percentage = 0;
243 243
 
244 244
 		// We can't count the number when getting them for a specific form
245
-		if ( empty( $this->form ) ) {
245
+		if (empty($this->form)) {
246 246
 
247 247
 			$total = Give()->customers->count();
248 248
 
249
-			if ( $total > 0 ) {
249
+			if ($total > 0) {
250 250
 
251
-				$percentage = ( ( 30 * $this->step ) / $total ) * 100;
251
+				$percentage = ((30 * $this->step) / $total) * 100;
252 252
 
253 253
 			}
254 254
 		}
255 255
 
256
-		if ( $percentage > 100 ) {
256
+		if ($percentage > 100) {
257 257
 			$percentage = 100;
258 258
 		}
259 259
 
@@ -269,46 +269,46 @@  discard block
 block discarded – undo
269 269
 	 *
270 270
 	 * @return mixed
271 271
 	 */
272
-	private function set_donor_data( $i, $data, $donor ) {
272
+	private function set_donor_data($i, $data, $donor) {
273 273
 
274 274
 		$columns = $this->csv_cols();
275 275
 
276 276
 		// Set address variable
277 277
 		$address = '';
278
-		if ( isset( $donor->user_id ) && $donor->user_id > 0 ) {
279
-			$address = give_get_donor_address( $donor->user_id );
278
+		if (isset($donor->user_id) && $donor->user_id > 0) {
279
+			$address = give_get_donor_address($donor->user_id);
280 280
 		}
281 281
 
282 282
 		// Set columns
283
-		if ( ! empty( $columns['full_name'] ) ) {
284
-			$data[ $i ]['full_name'] = $donor->name;
283
+		if ( ! empty($columns['full_name'])) {
284
+			$data[$i]['full_name'] = $donor->name;
285 285
 		}
286
-		if ( ! empty( $columns['email'] ) ) {
287
-			$data[ $i ]['email'] = $donor->email;
286
+		if ( ! empty($columns['email'])) {
287
+			$data[$i]['email'] = $donor->email;
288 288
 		}
289
-		if ( ! empty( $columns['address_line1'] ) ) {
290
-
291
-			$data[ $i ]['address_line1']   = isset( $address['line1'] ) ? $address['line1'] : '';
292
-			$data[ $i ]['address_line2']   = isset( $address['line2'] ) ? $address['line2'] : '';
293
-			$data[ $i ]['address_city']    = isset( $address['city'] ) ? $address['city'] : '';
294
-			$data[ $i ]['address_state']   = isset( $address['state'] ) ? $address['state'] : '';
295
-			$data[ $i ]['address_zip']     = isset( $address['zip'] ) ? $address['zip'] : '';
296
-			$data[ $i ]['address_country'] = isset( $address['country'] ) ? $address['country'] : '';
289
+		if ( ! empty($columns['address_line1'])) {
290
+
291
+			$data[$i]['address_line1']   = isset($address['line1']) ? $address['line1'] : '';
292
+			$data[$i]['address_line2']   = isset($address['line2']) ? $address['line2'] : '';
293
+			$data[$i]['address_city']    = isset($address['city']) ? $address['city'] : '';
294
+			$data[$i]['address_state']   = isset($address['state']) ? $address['state'] : '';
295
+			$data[$i]['address_zip']     = isset($address['zip']) ? $address['zip'] : '';
296
+			$data[$i]['address_country'] = isset($address['country']) ? $address['country'] : '';
297 297
 		}
298
-		if ( ! empty( $columns['userid'] ) ) {
299
-			$data[ $i ]['userid'] = ! empty( $donor->user_id ) ? $donor->user_id : '';
298
+		if ( ! empty($columns['userid'])) {
299
+			$data[$i]['userid'] = ! empty($donor->user_id) ? $donor->user_id : '';
300 300
 		}
301
-		if ( ! empty( $columns['date_first_donated'] ) ) {
302
-			$data[ $i ]['date_first_donated'] = date_i18n( give_date_format(), strtotime( $donor->date_created ) );
301
+		if ( ! empty($columns['date_first_donated'])) {
302
+			$data[$i]['date_first_donated'] = date_i18n(give_date_format(), strtotime($donor->date_created));
303 303
 		}
304
-		if ( ! empty( $columns['donations'] ) ) {
305
-			$data[ $i ]['donations'] = $donor->purchase_count;
304
+		if ( ! empty($columns['donations'])) {
305
+			$data[$i]['donations'] = $donor->purchase_count;
306 306
 		}
307
-		if ( ! empty( $columns['donation_sum'] ) ) {
308
-			$data[ $i ]['donation_sum'] = give_format_amount( $donor->purchase_value );
307
+		if ( ! empty($columns['donation_sum'])) {
308
+			$data[$i]['donation_sum'] = give_format_amount($donor->purchase_value);
309 309
 		}
310 310
 
311
-		return $data[ $i ];
311
+		return $data[$i];
312 312
 
313 313
 	}
314 314
 
Please login to merge, or discard this patch.