Completed
Pull Request — master (#1731)
by Ravinder
17:37
created
includes/class-give-logging.php 1 patch
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -43,15 +43,15 @@  discard block
 block discarded – undo
43 43
 	 */
44 44
 	public function __setup_hooks() {
45 45
 		// Create the log post type
46
-		add_action( 'init', array( $this, 'register_post_type' ), 1 );
46
+		add_action('init', array($this, 'register_post_type'), 1);
47 47
 
48 48
 		// Create types taxonomy and default types
49
-		add_action( 'init', array( $this, 'register_taxonomy' ), 1 );
49
+		add_action('init', array($this, 'register_taxonomy'), 1);
50 50
 
51
-		add_action( 'save_post_give_payment', array( $this, 'background_process_delete_cache' ) );
52
-		add_action( 'save_post_give_forms', array( $this, 'background_process_delete_cache' ) );
53
-		add_action( 'save_post_give_log', array( $this, 'background_process_delete_cache' ) );
54
-		add_action( 'give_delete_log_cache', array( $this, 'delete_cache' ) );
51
+		add_action('save_post_give_payment', array($this, 'background_process_delete_cache'));
52
+		add_action('save_post_give_forms', array($this, 'background_process_delete_cache'));
53
+		add_action('save_post_give_log', array($this, 'background_process_delete_cache'));
54
+		add_action('give_delete_log_cache', array($this, 'delete_cache'));
55 55
 	}
56 56
 
57 57
 	/**
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 		/* Logs post type */
69 69
 		$log_args = array(
70 70
 			'labels'              => array(
71
-				'name' => esc_html__( 'Logs', 'give' ),
71
+				'name' => esc_html__('Logs', 'give'),
72 72
 			),
73 73
 			'public'              => false,
74 74
 			'exclude_from_search' => true,
@@ -77,11 +77,11 @@  discard block
 block discarded – undo
77 77
 			'query_var'           => false,
78 78
 			'rewrite'             => false,
79 79
 			'capability_type'     => 'post',
80
-			'supports'            => array( 'title', 'editor' ),
80
+			'supports'            => array('title', 'editor'),
81 81
 			'can_export'          => true,
82 82
 		);
83 83
 
84
-		register_post_type( 'give_log', $log_args );
84
+		register_post_type('give_log', $log_args);
85 85
 	}
86 86
 
87 87
 	/**
@@ -95,9 +95,9 @@  discard block
 block discarded – undo
95 95
 	 * @return void
96 96
 	 */
97 97
 	public function register_taxonomy() {
98
-		register_taxonomy( 'give_log_type', 'give_log', array(
98
+		register_taxonomy('give_log_type', 'give_log', array(
99 99
 			'public' => false,
100
-		) );
100
+		));
101 101
 	}
102 102
 
103 103
 	/**
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 			'api_request',
118 118
 		);
119 119
 
120
-		return apply_filters( 'give_log_types', $terms );
120
+		return apply_filters('give_log_types', $terms);
121 121
 	}
122 122
 
123 123
 	/**
@@ -132,8 +132,8 @@  discard block
 block discarded – undo
132 132
 	 *
133 133
 	 * @return bool         Whether log type is valid.
134 134
 	 */
135
-	public function valid_type( $type ) {
136
-		return in_array( $type, $this->log_types() );
135
+	public function valid_type($type) {
136
+		return in_array($type, $this->log_types());
137 137
 	}
138 138
 
139 139
 	/**
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	 *
153 153
 	 * @return int             Log ID.
154 154
 	 */
155
-	public function add( $title = '', $message = '', $parent = 0, $type = null ) {
155
+	public function add($title = '', $message = '', $parent = 0, $type = null) {
156 156
 		$log_data = array(
157 157
 			'post_title'   => $title,
158 158
 			'post_content' => $message,
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 			'log_type'     => $type,
161 161
 		);
162 162
 
163
-		return $this->insert_log( $log_data );
163
+		return $this->insert_log($log_data);
164 164
 	}
165 165
 
166 166
 	/**
@@ -177,12 +177,12 @@  discard block
 block discarded – undo
177 177
 	 *
178 178
 	 * @return array             An array of the connected logs.
179 179
 	 */
180
-	public function get_logs( $object_id = 0, $type = null, $paged = null ) {
181
-		return $this->get_connected_logs( array(
180
+	public function get_logs($object_id = 0, $type = null, $paged = null) {
181
+		return $this->get_connected_logs(array(
182 182
 			'post_parent' => $object_id,
183 183
 			'paged'       => $paged,
184 184
 			'log_type'    => $type,
185
-		) );
185
+		));
186 186
 	}
187 187
 
188 188
 	/**
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 	 *
197 197
 	 * @return int             The ID of the newly created log item.
198 198
 	 */
199
-	public function insert_log( $log_data = array(), $log_meta = array() ) {
199
+	public function insert_log($log_data = array(), $log_meta = array()) {
200 200
 		$defaults = array(
201 201
 			'post_type'    => 'give_log',
202 202
 			'post_status'  => 'publish',
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 			'log_type'     => false,
206 206
 		);
207 207
 
208
-		$args = wp_parse_args( $log_data, $defaults );
208
+		$args = wp_parse_args($log_data, $defaults);
209 209
 
210 210
 		/**
211 211
 		 * Fires before inserting log entry.
@@ -215,20 +215,20 @@  discard block
 block discarded – undo
215 215
 		 * @param array $log_data Log entry data.
216 216
 		 * @param array $log_meta Log entry meta.
217 217
 		 */
218
-		do_action( 'give_pre_insert_log', $log_data, $log_meta );
218
+		do_action('give_pre_insert_log', $log_data, $log_meta);
219 219
 
220 220
 		// Store the log entry
221
-		$log_id = wp_insert_post( $args );
221
+		$log_id = wp_insert_post($args);
222 222
 
223 223
 		// Set the log type, if any
224
-		if ( $log_data['log_type'] && $this->valid_type( $log_data['log_type'] ) ) {
225
-			wp_set_object_terms( $log_id, $log_data['log_type'], 'give_log_type', false );
224
+		if ($log_data['log_type'] && $this->valid_type($log_data['log_type'])) {
225
+			wp_set_object_terms($log_id, $log_data['log_type'], 'give_log_type', false);
226 226
 		}
227 227
 
228 228
 		// Set log meta, if any
229
-		if ( $log_id && ! empty( $log_meta ) ) {
230
-			foreach ( (array) $log_meta as $key => $meta ) {
231
-				give_update_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta );
229
+		if ($log_id && ! empty($log_meta)) {
230
+			foreach ((array) $log_meta as $key => $meta) {
231
+				give_update_meta($log_id, '_give_log_'.sanitize_key($key), $meta);
232 232
 			}
233 233
 		}
234 234
 
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 		 * @param array $log_data Log entry data.
242 242
 		 * @param array $log_meta Log entry meta.
243 243
 		 */
244
-		do_action( 'give_post_insert_log', $log_id, $log_data, $log_meta );
244
+		do_action('give_post_insert_log', $log_id, $log_data, $log_meta);
245 245
 
246 246
 		return $log_id;
247 247
 	}
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 	 *
258 258
 	 * @return bool|null       True if successful, false otherwise.
259 259
 	 */
260
-	public function update_log( $log_data = array(), $log_meta = array() ) {
260
+	public function update_log($log_data = array(), $log_meta = array()) {
261 261
 
262 262
 		/**
263 263
 		 * Fires before updating log entry.
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 		 * @param array $log_data Log entry data.
268 268
 		 * @param array $log_meta Log entry meta.
269 269
 		 */
270
-		do_action( 'give_pre_update_log', $log_data, $log_meta );
270
+		do_action('give_pre_update_log', $log_data, $log_meta);
271 271
 
272 272
 		$defaults = array(
273 273
 			'post_type'   => 'give_log',
@@ -275,15 +275,15 @@  discard block
 block discarded – undo
275 275
 			'post_parent' => 0,
276 276
 		);
277 277
 
278
-		$args = wp_parse_args( $log_data, $defaults );
278
+		$args = wp_parse_args($log_data, $defaults);
279 279
 
280 280
 		// Store the log entry
281
-		$log_id = wp_update_post( $args );
281
+		$log_id = wp_update_post($args);
282 282
 
283
-		if ( $log_id && ! empty( $log_meta ) ) {
284
-			foreach ( (array) $log_meta as $key => $meta ) {
285
-				if ( ! empty( $meta ) ) {
286
-					give_update_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta );
283
+		if ($log_id && ! empty($log_meta)) {
284
+			foreach ((array) $log_meta as $key => $meta) {
285
+				if ( ! empty($meta)) {
286
+					give_update_meta($log_id, '_give_log_'.sanitize_key($key), $meta);
287 287
 				}
288 288
 			}
289 289
 		}
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 		 * @param array $log_data Log entry data.
298 298
 		 * @param array $log_meta Log entry meta.
299 299
 		 */
300
-		do_action( 'give_post_update_log', $log_id, $log_data, $log_meta );
300
+		do_action('give_post_update_log', $log_id, $log_data, $log_meta);
301 301
 	}
302 302
 
303 303
 	/**
@@ -312,19 +312,19 @@  discard block
 block discarded – undo
312 312
 	 *
313 313
 	 * @return array|false Array if logs were found, false otherwise.
314 314
 	 */
315
-	public function get_connected_logs( $args = array() ) {
315
+	public function get_connected_logs($args = array()) {
316 316
 
317 317
 		$defaults = array(
318 318
 			'post_type'      => 'give_log',
319 319
 			'posts_per_page' => 20,
320 320
 			'post_status'    => 'publish',
321
-			'paged'          => get_query_var( 'paged' ),
321
+			'paged'          => get_query_var('paged'),
322 322
 			'log_type'       => false,
323 323
 		);
324 324
 
325
-		$query_args = wp_parse_args( $args, $defaults );
325
+		$query_args = wp_parse_args($args, $defaults);
326 326
 
327
-		if ( $query_args['log_type'] && $this->valid_type( $query_args['log_type'] ) ) {
327
+		if ($query_args['log_type'] && $this->valid_type($query_args['log_type'])) {
328 328
 			$query_args['tax_query'] = array(
329 329
 				array(
330 330
 					'taxonomy' => 'give_log_type',
@@ -334,9 +334,9 @@  discard block
 block discarded – undo
334 334
 			);
335 335
 		}
336 336
 
337
-		$logs = get_posts( $query_args );
337
+		$logs = get_posts($query_args);
338 338
 
339
-		if ( $logs ) {
339
+		if ($logs) {
340 340
 			return $logs;
341 341
 		}
342 342
 
@@ -359,20 +359,20 @@  discard block
 block discarded – undo
359 359
 	 *
360 360
 	 * @return int                Log count.
361 361
 	 */
362
-	public function get_log_count( $object_id = 0, $type = null, $meta_query = null, $date_query = null ) {
362
+	public function get_log_count($object_id = 0, $type = null, $meta_query = null, $date_query = null) {
363 363
 
364 364
 		$query_args = array(
365 365
 			'post_type'      => 'give_log',
366
-			'posts_per_page' => - 1,
366
+			'posts_per_page' => -1,
367 367
 			'post_status'    => 'publish',
368 368
 			'fields'         => 'ids',
369 369
 		);
370 370
 
371
-		if ( $object_id ) {
371
+		if ($object_id) {
372 372
 			$query_args['post_parent'] = $object_id;
373 373
 		}
374 374
 
375
-		if ( ! empty( $type ) && $this->valid_type( $type ) ) {
375
+		if ( ! empty($type) && $this->valid_type($type)) {
376 376
 			$query_args['tax_query'] = array(
377 377
 				array(
378 378
 					'taxonomy' => 'give_log_type',
@@ -382,24 +382,24 @@  discard block
 block discarded – undo
382 382
 			);
383 383
 		}
384 384
 
385
-		if ( ! empty( $meta_query ) ) {
385
+		if ( ! empty($meta_query)) {
386 386
 			$query_args['meta_query'] = $meta_query;
387 387
 		}
388 388
 
389
-		if ( ! empty( $date_query ) ) {
389
+		if ( ! empty($date_query)) {
390 390
 			$query_args['date_query'] = $date_query;
391 391
 		}
392 392
 
393 393
 		// Get cache key for current query.
394
-		$cache_key = Give_Cache::get_key( 'get_log_count', $query_args );
394
+		$cache_key = Give_Cache::get_key('get_log_count', $query_args);
395 395
 
396 396
 		// check if cache already exist or not.
397
-		if ( ! ( $logs_count = Give_Cache::get( $cache_key ) ) ) {
398
-			$logs       = new WP_Query( $query_args );
397
+		if ( ! ($logs_count = Give_Cache::get($cache_key))) {
398
+			$logs       = new WP_Query($query_args);
399 399
 			$logs_count = (int) $logs->post_count;
400 400
 
401 401
 			// Cache results.
402
-			Give_Cache::set( $cache_key, $logs_count );
402
+			Give_Cache::set($cache_key, $logs_count);
403 403
 		}
404 404
 
405 405
 		return $logs_count;
@@ -419,16 +419,16 @@  discard block
 block discarded – undo
419 419
 	 *
420 420
 	 * @return void
421 421
 	 */
422
-	public function delete_logs( $object_id = 0, $type = null, $meta_query = null ) {
422
+	public function delete_logs($object_id = 0, $type = null, $meta_query = null) {
423 423
 		$query_args = array(
424 424
 			'post_parent'    => $object_id,
425 425
 			'post_type'      => 'give_log',
426
-			'posts_per_page' => - 1,
426
+			'posts_per_page' => -1,
427 427
 			'post_status'    => 'publish',
428 428
 			'fields'         => 'ids',
429 429
 		);
430 430
 
431
-		if ( ! empty( $type ) && $this->valid_type( $type ) ) {
431
+		if ( ! empty($type) && $this->valid_type($type)) {
432 432
 			$query_args['tax_query'] = array(
433 433
 				array(
434 434
 					'taxonomy' => 'give_log_type',
@@ -438,15 +438,15 @@  discard block
 block discarded – undo
438 438
 			);
439 439
 		}
440 440
 
441
-		if ( ! empty( $meta_query ) ) {
441
+		if ( ! empty($meta_query)) {
442 442
 			$query_args['meta_query'] = $meta_query;
443 443
 		}
444 444
 
445
-		$logs = get_posts( $query_args );
445
+		$logs = get_posts($query_args);
446 446
 
447
-		if ( $logs ) {
448
-			foreach ( $logs as $log ) {
449
-				wp_delete_post( $log, true );
447
+		if ($logs) {
448
+			foreach ($logs as $log) {
449
+				wp_delete_post($log, true);
450 450
 			}
451 451
 		}
452 452
 	}
@@ -459,9 +459,9 @@  discard block
 block discarded – undo
459 459
 	 *
460 460
 	 * @param int $post_id
461 461
 	 */
462
-	public function background_process_delete_cache( $post_id ) {
462
+	public function background_process_delete_cache($post_id) {
463 463
 		// Delete log cache immediately
464
-		wp_schedule_single_event( time() - 5, 'give_delete_log_cache' );
464
+		wp_schedule_single_event(time() - 5, 'give_delete_log_cache');
465 465
 	}
466 466
 
467 467
 	/**
@@ -489,11 +489,11 @@  discard block
 block discarded – undo
489 489
 		);
490 490
 
491 491
 		// Bailout.
492
-		if ( empty( $cache_option_names ) ) {
492
+		if (empty($cache_option_names)) {
493 493
 			return false;
494 494
 		}
495 495
 
496
-		Give_Cache::delete( $cache_option_names );
496
+		Give_Cache::delete($cache_option_names);
497 497
 	}
498 498
 }
499 499
 
@@ -515,10 +515,10 @@  discard block
 block discarded – undo
515 515
  *
516 516
  * @return int             ID of the new log entry.
517 517
  */
518
-function give_record_log( $title = '', $message = '', $parent = 0, $type = null ) {
518
+function give_record_log($title = '', $message = '', $parent = 0, $type = null) {
519 519
 	/* @var Give_Logging $give_logs */
520 520
 	global $give_logs;
521
-	$log = $give_logs->add( $title, $message, $parent, $type );
521
+	$log = $give_logs->add($title, $message, $parent, $type);
522 522
 
523 523
 	return $log;
524 524
 }
Please login to merge, or discard this patch.
includes/forms/functions.php 1 patch
Spacing   +213 added lines, -213 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -23,14 +23,14 @@  discard block
 block discarded – undo
23 23
 
24 24
 	global $typenow;
25 25
 
26
-	if ( $typenow != 'give_forms' ) {
26
+	if ($typenow != 'give_forms') {
27 27
 		return true;
28 28
 	}
29 29
 
30 30
 	return false;
31 31
 }
32 32
 
33
-add_filter( 'give_shortcode_button_condition', 'give_shortcode_button_condition' );
33
+add_filter('give_shortcode_button_condition', 'give_shortcode_button_condition');
34 34
 
35 35
 
36 36
 /**
@@ -40,11 +40,11 @@  discard block
 block discarded – undo
40 40
  *
41 41
  * @return int|false
42 42
  */
43
-function get_form_id_from_args( $args ) {
43
+function get_form_id_from_args($args) {
44 44
 
45
-	if ( isset( $args['form_id'] ) && $args['form_id'] != 0 ) {
45
+	if (isset($args['form_id']) && $args['form_id'] != 0) {
46 46
 
47
-		return intval( $args['form_id'] );
47
+		return intval($args['form_id']);
48 48
 	}
49 49
 
50 50
 	return false;
@@ -59,23 +59,23 @@  discard block
 block discarded – undo
59 59
  *
60 60
  * @return bool
61 61
  */
62
-function give_is_float_labels_enabled( $args ) {
62
+function give_is_float_labels_enabled($args) {
63 63
 
64 64
 	$float_labels = '';
65 65
 
66
-	if ( ! empty( $args['float_labels'] ) ) {
66
+	if ( ! empty($args['float_labels'])) {
67 67
 		$float_labels = $args['float_labels'];
68 68
 	}
69 69
 
70
-	if ( empty( $float_labels ) ) {
71
-		$float_labels = give_get_meta( $args['form_id'], '_give_form_floating_labels', true );
70
+	if (empty($float_labels)) {
71
+		$float_labels = give_get_meta($args['form_id'], '_give_form_floating_labels', true);
72 72
 	}
73 73
 
74
-	if ( empty( $float_labels ) || ( 'global' === $float_labels ) ) {
75
-		$float_labels = give_get_option( 'floatlabels', 'disabled' );
74
+	if (empty($float_labels) || ('global' === $float_labels)) {
75
+		$float_labels = give_get_option('floatlabels', 'disabled');
76 76
 	}
77 77
 
78
-	return give_is_setting_enabled( $float_labels );
78
+	return give_is_setting_enabled($float_labels);
79 79
 }
80 80
 
81 81
 /**
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 
92 92
 	$can_checkout = true;
93 93
 
94
-	return (bool) apply_filters( 'give_can_checkout', $can_checkout );
94
+	return (bool) apply_filters('give_can_checkout', $can_checkout);
95 95
 }
96 96
 
97 97
 /**
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
 function give_get_success_page_uri() {
106 106
 	$give_options = give_get_settings();
107 107
 
108
-	$success_page = isset( $give_options['success_page'] ) ? get_permalink( absint( $give_options['success_page'] ) ) : get_bloginfo( 'url' );
108
+	$success_page = isset($give_options['success_page']) ? get_permalink(absint($give_options['success_page'])) : get_bloginfo('url');
109 109
 
110
-	return apply_filters( 'give_get_success_page_uri', $success_page );
110
+	return apply_filters('give_get_success_page_uri', $success_page);
111 111
 }
112 112
 
113 113
 /**
@@ -119,9 +119,9 @@  discard block
 block discarded – undo
119 119
  */
120 120
 function give_is_success_page() {
121 121
 	$give_options    = give_get_settings();
122
-	$is_success_page = isset( $give_options['success_page'] ) ? is_page( $give_options['success_page'] ) : false;
122
+	$is_success_page = isset($give_options['success_page']) ? is_page($give_options['success_page']) : false;
123 123
 
124
-	return apply_filters( 'give_is_success_page', $is_success_page );
124
+	return apply_filters('give_is_success_page', $is_success_page);
125 125
 }
126 126
 
127 127
 /**
@@ -135,17 +135,17 @@  discard block
 block discarded – undo
135 135
  * @since       1.0
136 136
  * @return      void
137 137
  */
138
-function give_send_to_success_page( $query_string = null ) {
138
+function give_send_to_success_page($query_string = null) {
139 139
 
140 140
 	$redirect = give_get_success_page_uri();
141 141
 
142
-	if ( $query_string ) {
142
+	if ($query_string) {
143 143
 		$redirect .= $query_string;
144 144
 	}
145 145
 
146
-	$gateway = isset( $_REQUEST['give-gateway'] ) ? $_REQUEST['give-gateway'] : '';
146
+	$gateway = isset($_REQUEST['give-gateway']) ? $_REQUEST['give-gateway'] : '';
147 147
 
148
-	wp_redirect( apply_filters( 'give_success_page_redirect', $redirect, $gateway, $query_string ) );
148
+	wp_redirect(apply_filters('give_success_page_redirect', $redirect, $gateway, $query_string));
149 149
 	give_die();
150 150
 }
151 151
 
@@ -161,19 +161,19 @@  discard block
 block discarded – undo
161 161
  * @since  1.0
162 162
  * @return Void
163 163
  */
164
-function give_send_back_to_checkout( $args = array() ) {
164
+function give_send_back_to_checkout($args = array()) {
165 165
 
166
-	$url     = isset( $_POST['give-current-url'] ) ? sanitize_text_field( $_POST['give-current-url'] ) : '';
166
+	$url     = isset($_POST['give-current-url']) ? sanitize_text_field($_POST['give-current-url']) : '';
167 167
 	$form_id = 0;
168 168
 
169 169
 	// Set the form_id.
170
-	if ( isset( $_POST['give-form-id'] ) ) {
171
-		$form_id = sanitize_text_field( $_POST['give-form-id'] );
170
+	if (isset($_POST['give-form-id'])) {
171
+		$form_id = sanitize_text_field($_POST['give-form-id']);
172 172
 	}
173 173
 
174 174
 	// Need a URL to continue. If none, redirect back to single form.
175
-	if ( empty( $url ) ) {
176
-		wp_safe_redirect( get_permalink( $form_id ) );
175
+	if (empty($url)) {
176
+		wp_safe_redirect(get_permalink($form_id));
177 177
 		give_die();
178 178
 	}
179 179
 
@@ -182,41 +182,41 @@  discard block
 block discarded – undo
182 182
 	);
183 183
 
184 184
 	// Set the $level_id.
185
-	if ( isset( $_POST['give-price-id'] ) ) {
186
-		$defaults['level-id'] = sanitize_text_field( $_POST['give-price-id'] );
185
+	if (isset($_POST['give-price-id'])) {
186
+		$defaults['level-id'] = sanitize_text_field($_POST['give-price-id']);
187 187
 	}
188 188
 
189 189
 	// Check for backward compatibility.
190
-	if ( is_string( $args ) ) {
191
-		$args = str_replace( '?', '', $args );
190
+	if (is_string($args)) {
191
+		$args = str_replace('?', '', $args);
192 192
 	}
193 193
 
194
-	$args = wp_parse_args( $args, $defaults );
194
+	$args = wp_parse_args($args, $defaults);
195 195
 
196 196
 	// Merge URL query with $args to maintain third-party URL parameters after redirect.
197
-	$url_data = wp_parse_url( $url );
197
+	$url_data = wp_parse_url($url);
198 198
 
199 199
 	// Check if an array to prevent notices before parsing.
200
-	if ( isset( $url_data['query'] ) && ! empty( $url_data['query'] ) ) {
201
-		parse_str( $url_data['query'], $query );
200
+	if (isset($url_data['query']) && ! empty($url_data['query'])) {
201
+		parse_str($url_data['query'], $query);
202 202
 
203 203
 		// Precaution: don't allow any CC info.
204
-		unset( $query['card_number'] );
205
-		unset( $query['card_cvc'] );
204
+		unset($query['card_number']);
205
+		unset($query['card_cvc']);
206 206
 
207 207
 	} else {
208 208
 		// No $url_data so pass empty array.
209 209
 		$query = array();
210 210
 	}
211 211
 
212
-	$new_query        = array_merge( $args, $query );
213
-	$new_query_string = http_build_query( $new_query );
212
+	$new_query        = array_merge($args, $query);
213
+	$new_query_string = http_build_query($new_query);
214 214
 
215 215
 	// Assemble URL parts.
216
-	$redirect = home_url( '/' . $url_data['path'] . '?' . $new_query_string . '#give-form-' . $form_id . '-wrap' );
216
+	$redirect = home_url('/'.$url_data['path'].'?'.$new_query_string.'#give-form-'.$form_id.'-wrap');
217 217
 
218 218
 	// Redirect them.
219
-	wp_safe_redirect( apply_filters( 'give_send_back_to_checkout', $redirect, $args ) );
219
+	wp_safe_redirect(apply_filters('give_send_back_to_checkout', $redirect, $args));
220 220
 	give_die();
221 221
 
222 222
 }
@@ -232,16 +232,16 @@  discard block
 block discarded – undo
232 232
  * @since       1.0
233 233
  * @return      string
234 234
  */
235
-function give_get_success_page_url( $query_string = null ) {
235
+function give_get_success_page_url($query_string = null) {
236 236
 
237
-	$success_page = give_get_option( 'success_page', 0 );
238
-	$success_page = get_permalink( $success_page );
237
+	$success_page = give_get_option('success_page', 0);
238
+	$success_page = get_permalink($success_page);
239 239
 
240
-	if ( $query_string ) {
240
+	if ($query_string) {
241 241
 		$success_page .= $query_string;
242 242
 	}
243 243
 
244
-	return apply_filters( 'give_success_page_url', $success_page );
244
+	return apply_filters('give_success_page_url', $success_page);
245 245
 
246 246
 }
247 247
 
@@ -254,15 +254,15 @@  discard block
 block discarded – undo
254 254
  *
255 255
  * @return mixed|void Full URL to the Failed Donation Page, if present, home page if it doesn't exist
256 256
  */
257
-function give_get_failed_transaction_uri( $extras = false ) {
257
+function give_get_failed_transaction_uri($extras = false) {
258 258
 	$give_options = give_get_settings();
259 259
 
260
-	$uri = ! empty( $give_options['failure_page'] ) ? trailingslashit( get_permalink( $give_options['failure_page'] ) ) : home_url();
261
-	if ( $extras ) {
260
+	$uri = ! empty($give_options['failure_page']) ? trailingslashit(get_permalink($give_options['failure_page'])) : home_url();
261
+	if ($extras) {
262 262
 		$uri .= $extras;
263 263
 	}
264 264
 
265
-	return apply_filters( 'give_get_failed_transaction_uri', $uri );
265
+	return apply_filters('give_get_failed_transaction_uri', $uri);
266 266
 }
267 267
 
268 268
 /**
@@ -273,9 +273,9 @@  discard block
 block discarded – undo
273 273
  */
274 274
 function give_is_failed_transaction_page() {
275 275
 	$give_options = give_get_settings();
276
-	$ret          = isset( $give_options['failure_page'] ) ? is_page( $give_options['failure_page'] ) : false;
276
+	$ret          = isset($give_options['failure_page']) ? is_page($give_options['failure_page']) : false;
277 277
 
278
-	return apply_filters( 'give_is_failure_page', $ret );
278
+	return apply_filters('give_is_failure_page', $ret);
279 279
 }
280 280
 
281 281
 /**
@@ -287,18 +287,18 @@  discard block
 block discarded – undo
287 287
  */
288 288
 function give_listen_for_failed_payments() {
289 289
 
290
-	$failed_page = give_get_option( 'failure_page', 0 );
290
+	$failed_page = give_get_option('failure_page', 0);
291 291
 
292
-	if ( ! empty( $failed_page ) && is_page( $failed_page ) && ! empty( $_GET['payment-id'] ) ) {
292
+	if ( ! empty($failed_page) && is_page($failed_page) && ! empty($_GET['payment-id'])) {
293 293
 
294
-		$payment_id = absint( $_GET['payment-id'] );
295
-		give_update_payment_status( $payment_id, 'failed' );
294
+		$payment_id = absint($_GET['payment-id']);
295
+		give_update_payment_status($payment_id, 'failed');
296 296
 
297 297
 	}
298 298
 
299 299
 }
300 300
 
301
-add_action( 'template_redirect', 'give_listen_for_failed_payments' );
301
+add_action('template_redirect', 'give_listen_for_failed_payments');
302 302
 
303 303
 /**
304 304
  * Retrieve the Donation History page URI
@@ -311,9 +311,9 @@  discard block
 block discarded – undo
311 311
 function give_get_history_page_uri() {
312 312
 	$give_options = give_get_settings();
313 313
 
314
-	$history_page = isset( $give_options['history_page'] ) ? get_permalink( absint( $give_options['history_page'] ) ) : get_bloginfo( 'url' );
314
+	$history_page = isset($give_options['history_page']) ? get_permalink(absint($give_options['history_page'])) : get_bloginfo('url');
315 315
 
316
-	return apply_filters( 'give_get_history_page_uri', $history_page );
316
+	return apply_filters('give_get_history_page_uri', $history_page);
317 317
 }
318 318
 
319 319
 /**
@@ -326,11 +326,11 @@  discard block
 block discarded – undo
326 326
  * @since       1.0
327 327
  * @return      bool
328 328
  */
329
-function give_field_is_required( $field = '', $form_id ) {
329
+function give_field_is_required($field = '', $form_id) {
330 330
 
331
-	$required_fields = give_get_required_fields( $form_id );
331
+	$required_fields = give_get_required_fields($form_id);
332 332
 
333
-	return array_key_exists( $field, $required_fields );
333
+	return array_key_exists($field, $required_fields);
334 334
 }
335 335
 
336 336
 /**
@@ -348,14 +348,14 @@  discard block
 block discarded – undo
348 348
  *
349 349
  * @return void
350 350
  */
351
-function give_record_sale_in_log( $give_form_id = 0, $payment_id, $price_id = false, $sale_date = null ) {
351
+function give_record_sale_in_log($give_form_id = 0, $payment_id, $price_id = false, $sale_date = null) {
352 352
 	global $give_logs;
353 353
 
354 354
 	$log_data = array(
355 355
 		'post_parent'   => $give_form_id,
356 356
 		'log_type'      => 'sale',
357
-		'post_date'     => isset( $sale_date ) ? $sale_date : null,
358
-		'post_date_gmt' => isset( $sale_date ) ? $sale_date : null,
357
+		'post_date'     => isset($sale_date) ? $sale_date : null,
358
+		'post_date_gmt' => isset($sale_date) ? $sale_date : null,
359 359
 	);
360 360
 
361 361
 	$log_meta = array(
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 		'price_id'   => (int) $price_id,
364 364
 	);
365 365
 
366
-	$give_logs->insert_log( $log_data, $log_meta );
366
+	$give_logs->insert_log($log_data, $log_meta);
367 367
 }
368 368
 
369 369
 
@@ -377,11 +377,11 @@  discard block
 block discarded – undo
377 377
  *
378 378
  * @return bool|int
379 379
  */
380
-function give_increase_purchase_count( $form_id = 0, $quantity = 1 ) {
380
+function give_increase_purchase_count($form_id = 0, $quantity = 1) {
381 381
 	$quantity = (int) $quantity;
382
-	$form     = new Give_Donate_Form( $form_id );
382
+	$form     = new Give_Donate_Form($form_id);
383 383
 
384
-	return $form->increase_sales( $quantity );
384
+	return $form->increase_sales($quantity);
385 385
 }
386 386
 
387 387
 /**
@@ -394,11 +394,11 @@  discard block
 block discarded – undo
394 394
  *
395 395
  * @return bool|int
396 396
  */
397
-function give_decrease_purchase_count( $form_id = 0, $quantity = 1 ) {
397
+function give_decrease_purchase_count($form_id = 0, $quantity = 1) {
398 398
 	$quantity = (int) $quantity;
399
-	$form     = new Give_Donate_Form( $form_id );
399
+	$form     = new Give_Donate_Form($form_id);
400 400
 
401
-	return $form->decrease_sales( $quantity );
401
+	return $form->decrease_sales($quantity);
402 402
 }
403 403
 
404 404
 /**
@@ -411,10 +411,10 @@  discard block
 block discarded – undo
411 411
  *
412 412
  * @return bool|int
413 413
  */
414
-function give_increase_earnings( $give_form_id = 0, $amount ) {
415
-	$form = new Give_Donate_Form( $give_form_id );
414
+function give_increase_earnings($give_form_id = 0, $amount) {
415
+	$form = new Give_Donate_Form($give_form_id);
416 416
 
417
-	return $form->increase_earnings( $amount );
417
+	return $form->increase_earnings($amount);
418 418
 }
419 419
 
420 420
 /**
@@ -427,10 +427,10 @@  discard block
 block discarded – undo
427 427
  *
428 428
  * @return bool|int
429 429
  */
430
-function give_decrease_earnings( $form_id = 0, $amount ) {
431
-	$form = new Give_Donate_Form( $form_id );
430
+function give_decrease_earnings($form_id = 0, $amount) {
431
+	$form = new Give_Donate_Form($form_id);
432 432
 
433
-	return $form->decrease_earnings( $amount );
433
+	return $form->decrease_earnings($amount);
434 434
 }
435 435
 
436 436
 
@@ -443,8 +443,8 @@  discard block
 block discarded – undo
443 443
  *
444 444
  * @return int $earnings Earnings for a certain form
445 445
  */
446
-function give_get_form_earnings_stats( $form_id = 0 ) {
447
-	$give_form = new Give_Donate_Form( $form_id );
446
+function give_get_form_earnings_stats($form_id = 0) {
447
+	$give_form = new Give_Donate_Form($form_id);
448 448
 
449 449
 	return $give_form->earnings;
450 450
 }
@@ -459,8 +459,8 @@  discard block
 block discarded – undo
459 459
  *
460 460
  * @return int $sales Amount of sales for a certain form
461 461
  */
462
-function give_get_form_sales_stats( $give_form_id = 0 ) {
463
-	$give_form = new Give_Donate_Form( $give_form_id );
462
+function give_get_form_sales_stats($give_form_id = 0) {
463
+	$give_form = new Give_Donate_Form($give_form_id);
464 464
 
465 465
 	return $give_form->sales;
466 466
 }
@@ -475,16 +475,16 @@  discard block
 block discarded – undo
475 475
  *
476 476
  * @return float $sales Average monthly sales
477 477
  */
478
-function give_get_average_monthly_form_sales( $form_id = 0 ) {
479
-	$sales        = give_get_form_sales_stats( $form_id );
480
-	$release_date = get_post_field( 'post_date', $form_id );
478
+function give_get_average_monthly_form_sales($form_id = 0) {
479
+	$sales        = give_get_form_sales_stats($form_id);
480
+	$release_date = get_post_field('post_date', $form_id);
481 481
 
482
-	$diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) );
482
+	$diff = abs(current_time('timestamp') - strtotime($release_date));
483 483
 
484
-	$months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication
484
+	$months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication
485 485
 
486
-	if ( $months > 0 ) {
487
-		$sales = ( $sales / $months );
486
+	if ($months > 0) {
487
+		$sales = ($sales / $months);
488 488
 	}
489 489
 
490 490
 	return $sales;
@@ -500,16 +500,16 @@  discard block
 block discarded – undo
500 500
  *
501 501
  * @return float $earnings Average monthly earnings
502 502
  */
503
-function give_get_average_monthly_form_earnings( $form_id = 0 ) {
504
-	$earnings     = give_get_form_earnings_stats( $form_id );
505
-	$release_date = get_post_field( 'post_date', $form_id );
503
+function give_get_average_monthly_form_earnings($form_id = 0) {
504
+	$earnings     = give_get_form_earnings_stats($form_id);
505
+	$release_date = get_post_field('post_date', $form_id);
506 506
 
507
-	$diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) );
507
+	$diff = abs(current_time('timestamp') - strtotime($release_date));
508 508
 
509
-	$months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication
509
+	$months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication
510 510
 
511
-	if ( $months > 0 ) {
512
-		$earnings = ( $earnings / $months );
511
+	if ($months > 0) {
512
+		$earnings = ($earnings / $months);
513 513
 	}
514 514
 
515 515
 	return $earnings < 0 ? 0 : $earnings;
@@ -529,23 +529,23 @@  discard block
 block discarded – undo
529 529
  *
530 530
  * @return string $price_name Name of the price option
531 531
  */
532
-function give_get_price_option_name( $form_id = 0, $price_id = 0, $payment_id = 0 ) {
532
+function give_get_price_option_name($form_id = 0, $price_id = 0, $payment_id = 0) {
533 533
 
534
-	$prices     = give_get_variable_prices( $form_id );
534
+	$prices     = give_get_variable_prices($form_id);
535 535
 	$price_name = '';
536 536
 
537
-	foreach ( $prices as $price ) {
537
+	foreach ($prices as $price) {
538 538
 
539
-		if ( intval( $price['_give_id']['level_id'] ) == intval( $price_id ) ) {
539
+		if (intval($price['_give_id']['level_id']) == intval($price_id)) {
540 540
 
541
-			$price_text     = isset( $price['_give_text'] ) ? $price['_give_text'] : '';
542
-			$price_fallback = give_currency_filter( give_format_amount( $price['_give_amount'] ) );
543
-			$price_name     = ! empty( $price_text ) ? $price_text : $price_fallback;
541
+			$price_text     = isset($price['_give_text']) ? $price['_give_text'] : '';
542
+			$price_fallback = give_currency_filter(give_format_amount($price['_give_amount']));
543
+			$price_name     = ! empty($price_text) ? $price_text : $price_fallback;
544 544
 
545 545
 		}
546 546
 	}
547 547
 
548
-	return apply_filters( 'give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id );
548
+	return apply_filters('give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id);
549 549
 }
550 550
 
551 551
 
@@ -558,14 +558,14 @@  discard block
 block discarded – undo
558 558
  *
559 559
  * @return string $range A fully formatted price range
560 560
  */
561
-function give_price_range( $form_id = 0 ) {
562
-	$low   = give_get_lowest_price_option( $form_id );
563
-	$high  = give_get_highest_price_option( $form_id );
564
-	$range = '<span class="give_price_range_low">' . give_currency_filter( give_format_amount( $low ) ) . '</span>';
561
+function give_price_range($form_id = 0) {
562
+	$low   = give_get_lowest_price_option($form_id);
563
+	$high  = give_get_highest_price_option($form_id);
564
+	$range = '<span class="give_price_range_low">'.give_currency_filter(give_format_amount($low)).'</span>';
565 565
 	$range .= '<span class="give_price_range_sep">&nbsp;&ndash;&nbsp;</span>';
566
-	$range .= '<span class="give_price_range_high">' . give_currency_filter( give_format_amount( $high ) ) . '</span>';
566
+	$range .= '<span class="give_price_range_high">'.give_currency_filter(give_format_amount($high)).'</span>';
567 567
 
568
-	return apply_filters( 'give_price_range', $range, $form_id, $low, $high );
568
+	return apply_filters('give_price_range', $range, $form_id, $low, $high);
569 569
 }
570 570
 
571 571
 
@@ -580,35 +580,35 @@  discard block
 block discarded – undo
580 580
  *
581 581
  * @return int ID of the lowest price
582 582
  */
583
-function give_get_lowest_price_id( $form_id = 0 ) {
583
+function give_get_lowest_price_id($form_id = 0) {
584 584
 
585
-	if ( empty( $form_id ) ) {
585
+	if (empty($form_id)) {
586 586
 		$form_id = get_the_ID();
587 587
 	}
588 588
 
589
-	if ( ! give_has_variable_prices( $form_id ) ) {
590
-		return give_get_form_price( $form_id );
589
+	if ( ! give_has_variable_prices($form_id)) {
590
+		return give_get_form_price($form_id);
591 591
 	}
592 592
 
593
-	$prices = give_get_variable_prices( $form_id );
593
+	$prices = give_get_variable_prices($form_id);
594 594
 
595 595
 	$min = $min_id = 0;
596 596
 
597
-	if ( ! empty( $prices ) ) {
597
+	if ( ! empty($prices)) {
598 598
 
599
-		foreach ( $prices as $key => $price ) {
599
+		foreach ($prices as $key => $price) {
600 600
 
601
-			if ( empty( $price['_give_amount'] ) ) {
601
+			if (empty($price['_give_amount'])) {
602 602
 				continue;
603 603
 			}
604 604
 
605
-			if ( ! isset( $min ) ) {
605
+			if ( ! isset($min)) {
606 606
 				$min = $price['_give_amount'];
607 607
 			} else {
608
-				$min = min( $min, $price['_give_amount'] );
608
+				$min = min($min, $price['_give_amount']);
609 609
 			}
610 610
 
611
-			if ( $price['_give_amount'] == $min ) {
611
+			if ($price['_give_amount'] == $min) {
612 612
 				$min_id = $price['_give_id']['level_id'];
613 613
 			}
614 614
 		}
@@ -626,45 +626,45 @@  discard block
 block discarded – undo
626 626
  *
627 627
  * @return float Amount of the lowest price
628 628
  */
629
-function give_get_lowest_price_option( $form_id = 0 ) {
630
-	if ( empty( $form_id ) ) {
629
+function give_get_lowest_price_option($form_id = 0) {
630
+	if (empty($form_id)) {
631 631
 		$form_id = get_the_ID();
632 632
 	}
633 633
 
634
-	if ( ! give_has_variable_prices( $form_id ) ) {
635
-		return give_get_form_price( $form_id );
634
+	if ( ! give_has_variable_prices($form_id)) {
635
+		return give_get_form_price($form_id);
636 636
 	}
637 637
 
638
-	$prices = give_get_variable_prices( $form_id );
638
+	$prices = give_get_variable_prices($form_id);
639 639
 
640 640
 	$low = 0;
641 641
 
642
-	if ( ! empty( $prices ) ) {
642
+	if ( ! empty($prices)) {
643 643
 
644 644
 		$min = $min_id = 0;
645 645
 
646
-		foreach ( $prices as $key => $price ) {
646
+		foreach ($prices as $key => $price) {
647 647
 
648
-			if ( empty( $price['_give_amount'] ) ) {
648
+			if (empty($price['_give_amount'])) {
649 649
 				continue;
650 650
 			}
651 651
 
652
-			if ( ! isset( $min ) ) {
652
+			if ( ! isset($min)) {
653 653
 				$min = $price['_give_amount'];
654 654
 			} else {
655
-				$min = min( $min, give_sanitize_amount( $price['_give_amount'] ) );
655
+				$min = min($min, give_sanitize_amount($price['_give_amount']));
656 656
 			}
657 657
 
658
-			if ( $price['_give_amount'] == $min ) {
658
+			if ($price['_give_amount'] == $min) {
659 659
 				$min_id = $key;
660 660
 			}
661 661
 		}
662 662
 
663
-		$low = $prices[ $min_id ]['_give_amount'];
663
+		$low = $prices[$min_id]['_give_amount'];
664 664
 
665 665
 	}
666 666
 
667
-	return give_sanitize_amount( $low );
667
+	return give_sanitize_amount($low);
668 668
 }
669 669
 
670 670
 /**
@@ -676,41 +676,41 @@  discard block
 block discarded – undo
676 676
  *
677 677
  * @return float Amount of the highest price
678 678
  */
679
-function give_get_highest_price_option( $form_id = 0 ) {
679
+function give_get_highest_price_option($form_id = 0) {
680 680
 
681
-	if ( empty( $form_id ) ) {
681
+	if (empty($form_id)) {
682 682
 		$form_id = get_the_ID();
683 683
 	}
684 684
 
685
-	if ( ! give_has_variable_prices( $form_id ) ) {
686
-		return give_get_form_price( $form_id );
685
+	if ( ! give_has_variable_prices($form_id)) {
686
+		return give_get_form_price($form_id);
687 687
 	}
688 688
 
689
-	$prices = give_get_variable_prices( $form_id );
689
+	$prices = give_get_variable_prices($form_id);
690 690
 
691 691
 	$high = 0.00;
692 692
 
693
-	if ( ! empty( $prices ) ) {
693
+	if ( ! empty($prices)) {
694 694
 
695 695
 		$max_id = $max = 0;
696 696
 
697
-		foreach ( $prices as $key => $price ) {
698
-			if ( empty( $price['_give_amount'] ) ) {
697
+		foreach ($prices as $key => $price) {
698
+			if (empty($price['_give_amount'])) {
699 699
 				continue;
700 700
 			}
701
-			$give_amount = give_sanitize_amount( $price['_give_amount'] );
701
+			$give_amount = give_sanitize_amount($price['_give_amount']);
702 702
 
703
-			$max = max( $max, $give_amount );
703
+			$max = max($max, $give_amount);
704 704
 
705
-			if ( $give_amount == $max ) {
705
+			if ($give_amount == $max) {
706 706
 				$max_id = $key;
707 707
 			}
708 708
 		}
709 709
 
710
-		$high = $prices[ $max_id ]['_give_amount'];
710
+		$high = $prices[$max_id]['_give_amount'];
711 711
 	}
712 712
 
713
-	return give_sanitize_amount( $high );
713
+	return give_sanitize_amount($high);
714 714
 }
715 715
 
716 716
 /**
@@ -722,15 +722,15 @@  discard block
 block discarded – undo
722 722
  *
723 723
  * @return mixed string|int Price of the form
724 724
  */
725
-function give_get_form_price( $form_id = 0 ) {
725
+function give_get_form_price($form_id = 0) {
726 726
 
727
-	if ( empty( $form_id ) ) {
727
+	if (empty($form_id)) {
728 728
 		return false;
729 729
 	}
730 730
 
731
-	$form = new Give_Donate_Form( $form_id );
731
+	$form = new Give_Donate_Form($form_id);
732 732
 
733
-	return $form->__get( 'price' );
733
+	return $form->__get('price');
734 734
 }
735 735
 
736 736
 /**
@@ -742,15 +742,15 @@  discard block
 block discarded – undo
742 742
  *
743 743
  * @return mixed string|int Minimum price of the form
744 744
  */
745
-function give_get_form_minimum_price( $form_id = 0 ) {
745
+function give_get_form_minimum_price($form_id = 0) {
746 746
 
747
-	if ( empty( $form_id ) ) {
747
+	if (empty($form_id)) {
748 748
 		return false;
749 749
 	}
750 750
 
751
-	$form = new Give_Donate_Form( $form_id );
751
+	$form = new Give_Donate_Form($form_id);
752 752
 
753
-	return $form->__get( 'minimum_price' );
753
+	return $form->__get('minimum_price');
754 754
 
755 755
 }
756 756
 
@@ -765,51 +765,51 @@  discard block
 block discarded – undo
765 765
  *
766 766
  * @return int $formatted_price
767 767
  */
768
-function give_price( $form_id = 0, $echo = true, $price_id = false ) {
768
+function give_price($form_id = 0, $echo = true, $price_id = false) {
769 769
 
770
-	if ( empty( $form_id ) ) {
770
+	if (empty($form_id)) {
771 771
 		$form_id = get_the_ID();
772 772
 	}
773 773
 
774
-	if ( give_has_variable_prices( $form_id ) ) {
774
+	if (give_has_variable_prices($form_id)) {
775 775
 
776
-		$prices = give_get_variable_prices( $form_id );
776
+		$prices = give_get_variable_prices($form_id);
777 777
 
778
-		if ( false !== $price_id ) {
778
+		if (false !== $price_id) {
779 779
 
780 780
 			// loop through multi-prices to see which is default
781
-			foreach ( $prices as $price ) {
781
+			foreach ($prices as $price) {
782 782
 				// this is the default price
783
-				if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) {
783
+				if (isset($price['_give_default']) && $price['_give_default'] === 'default') {
784 784
 					$price = (float) $price['_give_amount'];
785 785
 				};
786 786
 			}
787 787
 		} else {
788 788
 
789
-			$price = give_get_lowest_price_option( $form_id );
789
+			$price = give_get_lowest_price_option($form_id);
790 790
 		}
791 791
 
792
-		$price = give_sanitize_amount( $price );
792
+		$price = give_sanitize_amount($price);
793 793
 
794 794
 	} else {
795 795
 
796
-		$price = give_get_form_price( $form_id );
796
+		$price = give_get_form_price($form_id);
797 797
 
798 798
 	}
799 799
 
800
-	$price           = apply_filters( 'give_form_price', give_sanitize_amount( $price ), $form_id );
801
-	$formatted_price = '<span class="give_price" id="give_price_' . $form_id . '">' . $price . '</span>';
802
-	$formatted_price = apply_filters( 'give_form_price_after_html', $formatted_price, $form_id, $price );
800
+	$price           = apply_filters('give_form_price', give_sanitize_amount($price), $form_id);
801
+	$formatted_price = '<span class="give_price" id="give_price_'.$form_id.'">'.$price.'</span>';
802
+	$formatted_price = apply_filters('give_form_price_after_html', $formatted_price, $form_id, $price);
803 803
 
804
-	if ( $echo ) {
804
+	if ($echo) {
805 805
 		echo $formatted_price;
806 806
 	} else {
807 807
 		return $formatted_price;
808 808
 	}
809 809
 }
810 810
 
811
-add_filter( 'give_form_price', 'give_format_amount', 10 );
812
-add_filter( 'give_form_price', 'give_currency_filter', 20 );
811
+add_filter('give_form_price', 'give_format_amount', 10);
812
+add_filter('give_form_price', 'give_currency_filter', 20);
813 813
 
814 814
 
815 815
 /**
@@ -822,19 +822,19 @@  discard block
 block discarded – undo
822 822
  *
823 823
  * @return float $amount Amount of the price option
824 824
  */
825
-function give_get_price_option_amount( $form_id = 0, $price_id = 0 ) {
826
-	$prices = give_get_variable_prices( $form_id );
825
+function give_get_price_option_amount($form_id = 0, $price_id = 0) {
826
+	$prices = give_get_variable_prices($form_id);
827 827
 
828 828
 	$amount = 0.00;
829 829
 
830
-	foreach ( $prices as $price ) {
831
-		if ( isset( $price['_give_id']['level_id'] ) && $price['_give_id']['level_id'] == $price_id ) {
832
-			$amount = isset( $price['_give_amount'] ) ? $price['_give_amount'] : 0.00;
830
+	foreach ($prices as $price) {
831
+		if (isset($price['_give_id']['level_id']) && $price['_give_id']['level_id'] == $price_id) {
832
+			$amount = isset($price['_give_amount']) ? $price['_give_amount'] : 0.00;
833 833
 			break;
834 834
 		};
835 835
 	}
836 836
 
837
-	return apply_filters( 'give_get_price_option_amount', give_sanitize_amount( $amount ), $form_id, $price_id );
837
+	return apply_filters('give_get_price_option_amount', give_sanitize_amount($amount), $form_id, $price_id);
838 838
 }
839 839
 
840 840
 /**
@@ -846,13 +846,13 @@  discard block
 block discarded – undo
846 846
  *
847 847
  * @return mixed string|int Goal of the form
848 848
  */
849
-function give_get_form_goal( $form_id = 0 ) {
849
+function give_get_form_goal($form_id = 0) {
850 850
 
851
-	if ( empty( $form_id ) ) {
851
+	if (empty($form_id)) {
852 852
 		return false;
853 853
 	}
854 854
 
855
-	$form = new Give_Donate_Form( $form_id );
855
+	$form = new Give_Donate_Form($form_id);
856 856
 
857 857
 	return $form->goal;
858 858
 
@@ -868,27 +868,27 @@  discard block
 block discarded – undo
868 868
  *
869 869
  * @return string $formatted_goal
870 870
  */
871
-function give_goal( $form_id = 0, $echo = true ) {
871
+function give_goal($form_id = 0, $echo = true) {
872 872
 
873
-	if ( empty( $form_id ) ) {
873
+	if (empty($form_id)) {
874 874
 		$form_id = get_the_ID();
875 875
 	}
876 876
 
877
-	$goal = give_get_form_goal( $form_id );
877
+	$goal = give_get_form_goal($form_id);
878 878
 
879
-	$goal           = apply_filters( 'give_form_goal', give_sanitize_amount( $goal ), $form_id );
880
-	$formatted_goal = '<span class="give_price" id="give_price_' . $form_id . '">' . $goal . '</span>';
881
-	$formatted_goal = apply_filters( 'give_form_price_after_html', $formatted_goal, $form_id, $goal );
879
+	$goal           = apply_filters('give_form_goal', give_sanitize_amount($goal), $form_id);
880
+	$formatted_goal = '<span class="give_price" id="give_price_'.$form_id.'">'.$goal.'</span>';
881
+	$formatted_goal = apply_filters('give_form_price_after_html', $formatted_goal, $form_id, $goal);
882 882
 
883
-	if ( $echo ) {
883
+	if ($echo) {
884 884
 		echo $formatted_goal;
885 885
 	} else {
886 886
 		return $formatted_goal;
887 887
 	}
888 888
 }
889 889
 
890
-add_filter( 'give_form_goal', 'give_format_amount', 10 );
891
-add_filter( 'give_form_goal', 'give_currency_filter', 20 );
890
+add_filter('give_form_goal', 'give_format_amount', 10);
891
+add_filter('give_form_goal', 'give_currency_filter', 20);
892 892
 
893 893
 
894 894
 /**
@@ -900,15 +900,15 @@  discard block
 block discarded – undo
900 900
  *
901 901
  * @return bool  $ret Whether or not the logged_in_only setting is set
902 902
  */
903
-function give_logged_in_only( $form_id ) {
903
+function give_logged_in_only($form_id) {
904 904
 	// If _give_logged_in_only is set to enable then guest can donate from that specific form.
905 905
 	// Otherwise it is member only donation form.
906
-	$val = give_get_meta( $form_id, '_give_logged_in_only', true );
907
-	$val = ! empty( $val ) ? $val : 'enabled';
906
+	$val = give_get_meta($form_id, '_give_logged_in_only', true);
907
+	$val = ! empty($val) ? $val : 'enabled';
908 908
 
909
-	$ret = ! give_is_setting_enabled( $val );
909
+	$ret = ! give_is_setting_enabled($val);
910 910
 
911
-	return (bool) apply_filters( 'give_logged_in_only', $ret, $form_id );
911
+	return (bool) apply_filters('give_logged_in_only', $ret, $form_id);
912 912
 }
913 913
 
914 914
 
@@ -921,11 +921,11 @@  discard block
 block discarded – undo
921 921
  *
922 922
  * @return string
923 923
  */
924
-function give_show_login_register_option( $form_id ) {
924
+function give_show_login_register_option($form_id) {
925 925
 
926
-	$show_register_form = give_get_meta( $form_id, '_give_show_register_form', true );
926
+	$show_register_form = give_get_meta($form_id, '_give_show_register_form', true);
927 927
 
928
-	return apply_filters( 'give_show_register_form', $show_register_form, $form_id );
928
+	return apply_filters('give_show_register_form', $show_register_form, $form_id);
929 929
 
930 930
 }
931 931
 
@@ -941,12 +941,12 @@  discard block
 block discarded – undo
941 941
  *
942 942
  * @return array
943 943
  */
944
-function _give_get_prefill_form_field_values( $form_id ) {
944
+function _give_get_prefill_form_field_values($form_id) {
945 945
 	$logged_in_donor_info = array();
946 946
 
947
-	if ( is_user_logged_in() ) :
948
-		$donor_data    = get_userdata( get_current_user_id() );
949
-		$donor_address = get_user_meta( get_current_user_id(), '_give_user_address', true );
947
+	if (is_user_logged_in()) :
948
+		$donor_data    = get_userdata(get_current_user_id());
949
+		$donor_address = get_user_meta(get_current_user_id(), '_give_user_address', true);
950 950
 
951 951
 		$logged_in_donor_info = array(
952 952
 			// First name.
@@ -959,42 +959,42 @@  discard block
 block discarded – undo
959 959
 			'give_email'      => $donor_data->user_email,
960 960
 
961 961
 			// Street address 1.
962
-			'card_address'    => ( ! empty( $donor_address['line1'] ) ? $donor_address['line1'] : '' ),
962
+			'card_address'    => ( ! empty($donor_address['line1']) ? $donor_address['line1'] : ''),
963 963
 
964 964
 			// Street address 2.
965
-			'card_address_2'  => ( ! empty( $donor_address['line2'] ) ? $donor_address['line2'] : '' ),
965
+			'card_address_2'  => ( ! empty($donor_address['line2']) ? $donor_address['line2'] : ''),
966 966
 
967 967
 			// Country.
968
-			'billing_country' => ( ! empty( $donor_address['country'] ) ? $donor_address['country'] : '' ),
968
+			'billing_country' => ( ! empty($donor_address['country']) ? $donor_address['country'] : ''),
969 969
 
970 970
 			// State.
971
-			'card_state'      => ( ! empty( $donor_address['state'] ) ? $donor_address['state'] : '' ),
971
+			'card_state'      => ( ! empty($donor_address['state']) ? $donor_address['state'] : ''),
972 972
 
973 973
 			// City.
974
-			'card_city'       => ( ! empty( $donor_address['city'] ) ? $donor_address['city'] : '' ),
974
+			'card_city'       => ( ! empty($donor_address['city']) ? $donor_address['city'] : ''),
975 975
 
976 976
 			// Zipcode
977
-			'card_zip'        => ( ! empty( $donor_address['zip'] ) ? $donor_address['zip'] : '' ),
977
+			'card_zip'        => ( ! empty($donor_address['zip']) ? $donor_address['zip'] : ''),
978 978
 		);
979 979
 	endif;
980 980
 
981 981
 	// Bailout: Auto fill form field values only form form which donor is donating.
982 982
 	if (
983
-		empty( $_GET['form-id'] )
983
+		empty($_GET['form-id'])
984 984
 		|| ! $form_id
985
-		|| ( $form_id !== absint( $_GET['form-id'] ) )
985
+		|| ($form_id !== absint($_GET['form-id']))
986 986
 	) {
987 987
 		return $logged_in_donor_info;
988 988
 	}
989 989
 
990 990
 	// Get purchase data.
991
-	$give_purchase_data = Give()->session->get( 'give_purchase' );
991
+	$give_purchase_data = Give()->session->get('give_purchase');
992 992
 
993 993
 	// Get donor info from form data.
994
-	$give_donor_info_in_session = empty( $give_purchase_data['post_data'] )
994
+	$give_donor_info_in_session = empty($give_purchase_data['post_data'])
995 995
 		? array()
996 996
 		: $give_purchase_data['post_data'];
997 997
 
998 998
 	// Output.
999
-	return wp_parse_args( $give_donor_info_in_session, $logged_in_donor_info );
999
+	return wp_parse_args($give_donor_info_in_session, $logged_in_donor_info);
1000 1000
 }
Please login to merge, or discard this patch.
includes/price-functions.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -23,13 +23,13 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @return bool true if has variable prices, false otherwise
25 25
  */
26
-function give_has_variable_prices( $form_id = 0 ) {
26
+function give_has_variable_prices($form_id = 0) {
27 27
 
28
-	if ( empty( $form_id ) ) {
28
+	if (empty($form_id)) {
29 29
 		return false;
30 30
 	}
31 31
 
32
-	$form = new Give_Donate_Form( $form_id );
32
+	$form = new Give_Donate_Form($form_id);
33 33
 
34 34
 	return $form->has_variable_prices();
35 35
 }
@@ -44,13 +44,13 @@  discard block
 block discarded – undo
44 44
  *
45 45
  * @return array Variable prices
46 46
  */
47
-function give_get_variable_prices( $form_id = 0 ) {
47
+function give_get_variable_prices($form_id = 0) {
48 48
 
49
-	if ( empty( $form_id ) ) {
49
+	if (empty($form_id)) {
50 50
 		return false;
51 51
 	}
52 52
 
53
-	$form = new Give_Donate_Form( $form_id );
53
+	$form = new Give_Donate_Form($form_id);
54 54
 
55 55
 	return $form->prices;
56 56
 
@@ -67,13 +67,13 @@  discard block
 block discarded – undo
67 67
  *
68 68
  * @return string $default_price
69 69
  */
70
-function give_get_default_multilevel_amount( $form_id ) {
70
+function give_get_default_multilevel_amount($form_id) {
71 71
 	$default_price = '1.00';
72
-	$prices        = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id );
72
+	$prices        = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id);
73 73
 
74
-	foreach ( $prices as $price ) {
74
+	foreach ($prices as $price) {
75 75
 
76
-		if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) {
76
+		if (isset($price['_give_default']) && $price['_give_default'] === 'default') {
77 77
 			$default_price = $price['_give_amount'];
78 78
 		}
79 79
 
@@ -94,19 +94,19 @@  discard block
 block discarded – undo
94 94
  * @return string $default_price
95 95
  * @since      1.0
96 96
  */
97
-function give_get_default_form_amount( $form_id ) {
97
+function give_get_default_form_amount($form_id) {
98 98
 
99
-	if ( give_has_variable_prices( $form_id ) ) {
99
+	if (give_has_variable_prices($form_id)) {
100 100
 
101
-		$default_amount = give_get_default_multilevel_amount( $form_id );
101
+		$default_amount = give_get_default_multilevel_amount($form_id);
102 102
 
103 103
 	} else {
104 104
 
105
-		$default_amount = give_get_meta( $form_id, '_give_set_price', true );
105
+		$default_amount = give_get_meta($form_id, '_give_set_price', true);
106 106
 
107 107
 	}
108 108
 
109
-	return apply_filters( 'give_default_form_amount', $default_amount );
109
+	return apply_filters('give_default_form_amount', $default_amount);
110 110
 
111 111
 }
112 112
 
@@ -124,13 +124,13 @@  discard block
 block discarded – undo
124 124
  *
125 125
  * @return bool
126 126
  */
127
-function give_is_custom_price_mode( $form_id = 0 ) {
127
+function give_is_custom_price_mode($form_id = 0) {
128 128
 
129
-	if ( empty( $form_id ) ) {
129
+	if (empty($form_id)) {
130 130
 		return false;
131 131
 	}
132 132
 
133
-	$form = new Give_Donate_Form( $form_id );
133
+	$form = new Give_Donate_Form($form_id);
134 134
 
135 135
 	return $form->is_custom_price_mode();
136 136
 }
137 137
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/reporting/reports.php 1 patch
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  */
17 17
 
18 18
 // Exit if accessed directly.
19
-if ( ! defined( 'ABSPATH' ) ) {
19
+if ( ! defined('ABSPATH')) {
20 20
 	exit;
21 21
 }
22 22
 
@@ -29,8 +29,8 @@  discard block
 block discarded – undo
29 29
  * @return void
30 30
  */
31 31
 function give_reports_page() {
32
-	$current_page = admin_url( 'edit.php?post_type=give_forms&page=give-reports' );
33
-	$active_tab   = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'earnings';
32
+	$current_page = admin_url('edit.php?post_type=give_forms&page=give-reports');
33
+	$active_tab   = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'earnings';
34 34
 	$views        = give_reports_default_views();
35 35
 	?>
36 36
 	<div class="wrap give-settings-page">
@@ -38,17 +38,17 @@  discard block
 block discarded – undo
38 38
 		<h1 class="screen-reader-text"><?php echo get_admin_page_title(); ?></h1>
39 39
 
40 40
 		<h2 class="nav-tab-wrapper">
41
-			<?php foreach ( $views as $tab => $label ) { ?>
42
-				<a href="<?php echo esc_url( add_query_arg( array(
41
+			<?php foreach ($views as $tab => $label) { ?>
42
+				<a href="<?php echo esc_url(add_query_arg(array(
43 43
 					'tab'              => $tab,
44 44
 					'settings-updated' => false,
45
-				), $current_page ) ); ?>" class="nav-tab <?php echo $tab === $active_tab ? esc_attr( 'nav-tab-active' ) : ''; ?>"><?php echo esc_html( $label ); ?></a>
45
+				), $current_page)); ?>" class="nav-tab <?php echo $tab === $active_tab ? esc_attr('nav-tab-active') : ''; ?>"><?php echo esc_html($label); ?></a>
46 46
 			<?php } ?>
47
-			<?php if ( current_user_can( 'export_give_reports' ) ) { ?>
48
-				<a href="<?php echo esc_url( add_query_arg( array(
47
+			<?php if (current_user_can('export_give_reports')) { ?>
48
+				<a href="<?php echo esc_url(add_query_arg(array(
49 49
 					'tab'              => 'export',
50 50
 					'settings-updated' => false,
51
-				), $current_page ) ); ?>" class="nav-tab <?php echo 'export' === $active_tab ? esc_attr( 'nav-tab-active' ) : ''; ?>"><?php esc_html_e( 'Export', 'give' ); ?></a>
51
+				), $current_page)); ?>" class="nav-tab <?php echo 'export' === $active_tab ? esc_attr('nav-tab-active') : ''; ?>"><?php esc_html_e('Export', 'give'); ?></a>
52 52
 			<?php }
53 53
 			/**
54 54
 			 * Fires in the report tabs.
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 			 *
58 58
 			 * @since 1.0
59 59
 			 */
60
-			do_action( 'give_reports_tabs' );
60
+			do_action('give_reports_tabs');
61 61
 			?>
62 62
 		</h2>
63 63
 
@@ -67,10 +67,10 @@  discard block
 block discarded – undo
67 67
 		 *
68 68
 		 * @since 1.0
69 69
 		 */
70
-		do_action( 'give_reports_page_top' );
70
+		do_action('give_reports_page_top');
71 71
 
72 72
 		// Set $active_tab prior to hook firing.
73
-		if ( in_array( $active_tab, array_keys( $views ) ) ) {
73
+		if (in_array($active_tab, array_keys($views))) {
74 74
 			$active_tab = 'reports';
75 75
 		}
76 76
 
@@ -79,14 +79,14 @@  discard block
 block discarded – undo
79 79
 		 *
80 80
 		 * @since 1.0
81 81
 		 */
82
-		do_action( "give_reports_tab_{$active_tab}" );
82
+		do_action("give_reports_tab_{$active_tab}");
83 83
 
84 84
 		/**
85 85
 		 * Fires after the report page.
86 86
 		 *
87 87
 		 * @since 1.0
88 88
 		 */
89
-		do_action( 'give_reports_page_bottom' );
89
+		do_action('give_reports_page_bottom');
90 90
 		?>
91 91
 	</div><!-- .wrap -->
92 92
 	<?php
@@ -100,13 +100,13 @@  discard block
 block discarded – undo
100 100
  */
101 101
 function give_reports_default_views() {
102 102
 	$views = array(
103
-		'earnings' => esc_html__( 'Income', 'give' ),
104
-		'forms'    => esc_html__( 'Forms', 'give' ),
105
-		'donors'   => esc_html__( 'Donors', 'give' ),
106
-		'gateways' => esc_html__( 'Donation Methods', 'give' ),
103
+		'earnings' => esc_html__('Income', 'give'),
104
+		'forms'    => esc_html__('Forms', 'give'),
105
+		'donors'   => esc_html__('Donors', 'give'),
106
+		'gateways' => esc_html__('Donation Methods', 'give'),
107 107
 	);
108 108
 
109
-	$views = apply_filters( 'give_report_views', $views );
109
+	$views = apply_filters('give_report_views', $views);
110 110
 
111 111
 	return $views;
112 112
 }
@@ -121,15 +121,15 @@  discard block
 block discarded – undo
121 121
  * @since 1.0
122 122
  * @return string $view Report View
123 123
  */
124
-function give_get_reporting_view( $default = 'earnings' ) {
124
+function give_get_reporting_view($default = 'earnings') {
125 125
 
126
-	if ( ! isset( $_GET['view'] ) || ! in_array( $_GET['view'], array_keys( give_reports_default_views() ) ) ) {
126
+	if ( ! isset($_GET['view']) || ! in_array($_GET['view'], array_keys(give_reports_default_views()))) {
127 127
 		$view = $default;
128 128
 	} else {
129 129
 		$view = $_GET['view'];
130 130
 	}
131 131
 
132
-	return apply_filters( 'give_get_reporting_view', $view );
132
+	return apply_filters('give_get_reporting_view', $view);
133 133
 }
134 134
 
135 135
 /**
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	$current_view = 'earnings';
143 143
 	$views        = give_reports_default_views();
144 144
 
145
-	if ( isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $views ) ) {
145
+	if (isset($_GET['tab']) && array_key_exists($_GET['tab'], $views)) {
146 146
 		$current_view = $_GET['tab'];
147 147
 	}
148 148
 
@@ -151,10 +151,10 @@  discard block
 block discarded – undo
151 151
 	 *
152 152
 	 * @since 1.0
153 153
 	 */
154
-	do_action( "give_reports_view_{$current_view}" );
154
+	do_action("give_reports_view_{$current_view}");
155 155
 }
156 156
 
157
-add_action( 'give_reports_tab_reports', 'give_reports_tab_reports' );
157
+add_action('give_reports_tab_reports', 'give_reports_tab_reports');
158 158
 
159 159
 /**
160 160
  * Renders the Reports Page Views Drop Downs
@@ -164,19 +164,19 @@  discard block
 block discarded – undo
164 164
  */
165 165
 function give_report_views() {
166 166
 	$views        = give_reports_default_views();
167
-	$current_view = isset( $_GET['view'] ) ? $_GET['view'] : 'earnings';
167
+	$current_view = isset($_GET['view']) ? $_GET['view'] : 'earnings';
168 168
 	/**
169 169
 	 * Fires before the report page actions form.
170 170
 	 *
171 171
 	 * @since 1.0
172 172
 	 */
173
-	do_action( 'give_report_view_actions_before' );
173
+	do_action('give_report_view_actions_before');
174 174
 	?>
175 175
 	<form id="give-reports-filter" method="get">
176 176
 		<select id="give-reports-view" name="view">
177
-			<option value="-1"><?php esc_html_e( 'Report Type', 'give' ); ?></option>
178
-			<?php foreach ( $views as $view_id => $label ) : ?>
179
-				<option value="<?php echo esc_attr( $view_id ); ?>" <?php selected( $view_id, $current_view ); ?>><?php echo $label; ?></option>
177
+			<option value="-1"><?php esc_html_e('Report Type', 'give'); ?></option>
178
+			<?php foreach ($views as $view_id => $label) : ?>
179
+				<option value="<?php echo esc_attr($view_id); ?>" <?php selected($view_id, $current_view); ?>><?php echo $label; ?></option>
180 180
 			<?php endforeach; ?>
181 181
 		</select>
182 182
 
@@ -188,12 +188,12 @@  discard block
 block discarded – undo
188 188
 		 *
189 189
 		 * @since 1.0
190 190
 		 */
191
-		do_action( 'give_report_view_actions' );
191
+		do_action('give_report_view_actions');
192 192
 		?>
193 193
 
194 194
 		<input type="hidden" name="post_type" value="give_forms"/>
195 195
 		<input type="hidden" name="page" value="give-reports"/>
196
-		<?php submit_button( esc_html__( 'Show', 'give' ), 'secondary', 'submit', false ); ?>
196
+		<?php submit_button(esc_html__('Show', 'give'), 'secondary', 'submit', false); ?>
197 197
 	</form>
198 198
 	<?php
199 199
 	/**
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 	 *
202 202
 	 * @since 1.0
203 203
 	 */
204
-	do_action( 'give_report_view_actions_after' );
204
+	do_action('give_report_view_actions_after');
205 205
 }
206 206
 
207 207
 /**
@@ -214,18 +214,18 @@  discard block
 block discarded – undo
214 214
  */
215 215
 function give_reports_forms_table() {
216 216
 
217
-	if ( isset( $_GET['form-id'] ) ) {
217
+	if (isset($_GET['form-id'])) {
218 218
 		return;
219 219
 	}
220 220
 
221
-	include( dirname( __FILE__ ) . '/class-form-reports-table.php' );
221
+	include(dirname(__FILE__).'/class-form-reports-table.php');
222 222
 
223 223
 	$give_table = new Give_Form_Reports_Table();
224 224
 	$give_table->prepare_items();
225 225
 	$give_table->display();
226 226
 }
227 227
 
228
-add_action( 'give_reports_view_forms', 'give_reports_forms_table' );
228
+add_action('give_reports_view_forms', 'give_reports_forms_table');
229 229
 
230 230
 /**
231 231
  * Renders the detailed report for a specific give form
@@ -234,20 +234,20 @@  discard block
 block discarded – undo
234 234
  * @return void
235 235
  */
236 236
 function give_reports_form_details() {
237
-	if ( ! isset( $_GET['form-id'] ) ) {
237
+	if ( ! isset($_GET['form-id'])) {
238 238
 		return;
239 239
 	}
240 240
 	?>
241 241
 	<div class="tablenav top reports-forms-details-wrap">
242 242
 		<div class="actions bulkactions">
243
-			<button onclick="history.go(-1);" class="button-secondary"><?php esc_html_e( 'Go Back', 'give' ); ?></button>
243
+			<button onclick="history.go(-1);" class="button-secondary"><?php esc_html_e('Go Back', 'give'); ?></button>
244 244
 		</div>
245 245
 	</div>
246 246
 	<?php
247
-	give_reports_graph_of_form( absint( $_GET['form-id'] ) );
247
+	give_reports_graph_of_form(absint($_GET['form-id']));
248 248
 }
249 249
 
250
-add_action( 'give_reports_view_forms', 'give_reports_form_details' );
250
+add_action('give_reports_view_forms', 'give_reports_form_details');
251 251
 
252 252
 /**
253 253
  * Renders the Reports Donors Table
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
  * @return void
259 259
  */
260 260
 function give_reports_donors_table() {
261
-	include( dirname( __FILE__ ) . '/class-donor-reports-table.php' );
261
+	include(dirname(__FILE__).'/class-donor-reports-table.php');
262 262
 
263 263
 	$give_table = new Give_Donor_Reports_Table();
264 264
 	$give_table->prepare_items();
@@ -270,11 +270,11 @@  discard block
 block discarded – undo
270 270
 		 *
271 271
 		 * @since 1.0
272 272
 		 */
273
-		do_action( 'give_logs_donors_table_top' );
273
+		do_action('give_logs_donors_table_top');
274 274
 		?>
275 275
 		<form id="give-donors-filter" method="get">
276 276
 			<?php
277
-			$give_table->search_box( esc_html__( 'Search', 'give' ), 'give-donors' );
277
+			$give_table->search_box(esc_html__('Search', 'give'), 'give-donors');
278 278
 			$give_table->display();
279 279
 			?>
280 280
 			<input type="hidden" name="post_type" value="give_forms"/>
@@ -287,13 +287,13 @@  discard block
 block discarded – undo
287 287
 		 *
288 288
 		 * @since 1.0
289 289
 		 */
290
-		do_action( 'give_logs_donors_table_bottom' );
290
+		do_action('give_logs_donors_table_bottom');
291 291
 		?>
292 292
 	</div>
293 293
 	<?php
294 294
 }
295 295
 
296
-add_action( 'give_reports_view_donors', 'give_reports_donors_table' );
296
+add_action('give_reports_view_donors', 'give_reports_donors_table');
297 297
 
298 298
 
299 299
 /**
@@ -305,14 +305,14 @@  discard block
 block discarded – undo
305 305
  * @return void
306 306
  */
307 307
 function give_reports_gateways_table() {
308
-	include( dirname( __FILE__ ) . '/class-gateways-reports-table.php' );
308
+	include(dirname(__FILE__).'/class-gateways-reports-table.php');
309 309
 
310 310
 	$give_table = new Give_Gateway_Reports_Table();
311 311
 	$give_table->prepare_items();
312 312
 	$give_table->display();
313 313
 }
314 314
 
315
-add_action( 'give_reports_view_gateways', 'give_reports_gateways_table' );
315
+add_action('give_reports_view_gateways', 'give_reports_gateways_table');
316 316
 
317 317
 
318 318
 /**
@@ -324,13 +324,13 @@  discard block
 block discarded – undo
324 324
 function give_reports_earnings() {
325 325
 	?>
326 326
 	<div class="tablenav top reports-table-nav">
327
-		<h3 class="alignleft reports-earnings-title"><span><?php esc_html_e( 'Income Report', 'give' ); ?></span></h3>
327
+		<h3 class="alignleft reports-earnings-title"><span><?php esc_html_e('Income Report', 'give'); ?></span></h3>
328 328
 	</div>
329 329
 	<?php
330 330
 	give_reports_graph();
331 331
 }
332 332
 
333
-add_action( 'give_reports_view_earnings', 'give_reports_earnings' );
333
+add_action('give_reports_view_earnings', 'give_reports_earnings');
334 334
 
335 335
 
336 336
 /**
@@ -341,9 +341,9 @@  discard block
 block discarded – undo
341 341
  */
342 342
 function give_estimated_monthly_stats() {
343 343
 
344
-	$estimated = Give_Cache::get( 'give_estimated_monthly_stats', true );
344
+	$estimated = Give_Cache::get('give_estimated_monthly_stats', true);
345 345
 
346
-	if ( false === $estimated ) {
346
+	if (false === $estimated) {
347 347
 
348 348
 		$estimated = array(
349 349
 			'earnings' => 0,
@@ -352,22 +352,22 @@  discard block
 block discarded – undo
352 352
 
353 353
 		$stats = new Give_Payment_Stats;
354 354
 
355
-		$to_date_earnings = $stats->get_earnings( 0, 'this_month' );
356
-		$to_date_sales    = $stats->get_sales( 0, 'this_month' );
355
+		$to_date_earnings = $stats->get_earnings(0, 'this_month');
356
+		$to_date_sales    = $stats->get_sales(0, 'this_month');
357 357
 
358
-		$current_day   = date( 'd', current_time( 'timestamp' ) );
359
-		$current_month = date( 'n', current_time( 'timestamp' ) );
360
-		$current_year  = date( 'Y', current_time( 'timestamp' ) );
361
-		$days_in_month = cal_days_in_month( CAL_GREGORIAN, $current_month, $current_year );
358
+		$current_day   = date('d', current_time('timestamp'));
359
+		$current_month = date('n', current_time('timestamp'));
360
+		$current_year  = date('Y', current_time('timestamp'));
361
+		$days_in_month = cal_days_in_month(CAL_GREGORIAN, $current_month, $current_year);
362 362
 
363
-		$estimated['earnings'] = ( $to_date_earnings / $current_day ) * $days_in_month;
364
-		$estimated['sales']    = ( $to_date_sales / $current_day ) * $days_in_month;
363
+		$estimated['earnings'] = ($to_date_earnings / $current_day) * $days_in_month;
364
+		$estimated['sales']    = ($to_date_sales / $current_day) * $days_in_month;
365 365
 
366 366
 		// Cache for one day
367
-		Give_Cache::set( 'give_estimated_monthly_stats', $estimated, DAY_IN_SECONDS, true );
367
+		Give_Cache::set('give_estimated_monthly_stats', $estimated, DAY_IN_SECONDS, true);
368 368
 	}
369 369
 
370
-	return maybe_unserialize( $estimated );
370
+	return maybe_unserialize($estimated);
371 371
 }
372 372
 
373 373
 // @TODO: After release 1.8 Donations -> Reports generates with new setting api, so we can remove some old code from this file.
Please login to merge, or discard this patch.
includes/admin/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, array( 'dataType' => array( 'amount', 'count' ) ) );
195
-					$graph->set( 'x_mode', 'time' );
196
-					$graph->set( 'multiple_y_axes', true );
194
+					$graph = new Give_Graph($data, array('dataType' => array('amount', 'count')));
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, array( 'dataType' => array( 'amount', 'count' ) ) );
445
-					$graph->set( 'x_mode', 'time' );
446
-					$graph->set( 'multiple_y_axes', true );
444
+					$graph = new Give_Graph($data, array('dataType' => array('amount', 'count')));
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/class-give-graph.php 1 patch
Spacing   +35 added lines, -35 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
 
@@ -81,15 +81,15 @@  discard block
 block discarded – undo
81 81
 	 * @param array $_data
82 82
 	 * @param array $options
83 83
 	 */
84
-	public function __construct( $_data, $options = array() ) {
84
+	public function __construct($_data, $options = array()) {
85 85
 
86
-		$this->data      = $_data;
86
+		$this->data = $_data;
87 87
 
88 88
 		// Generate unique ID
89
-		$this->id = md5( rand() );
89
+		$this->id = md5(rand());
90 90
 
91 91
 		// Setup default options;
92
-		$this->options = apply_filters( 'give_graph_args', array(
92
+		$this->options = apply_filters('give_graph_args', array(
93 93
 			'y_mode'          => null,
94 94
 			'x_mode'          => null,
95 95
 			'y_decimals'      => 0,
@@ -107,9 +107,9 @@  discard block
 block discarded – undo
107 107
 			'lines'           => false,
108 108
 			'points'          => true,
109 109
 			'dataType'        => array()
110
-		) );
110
+		));
111 111
 
112
-		$this->options = wp_parse_args( $options, $this->options );
112
+		$this->options = wp_parse_args($options, $this->options);
113 113
 	}
114 114
 
115 115
 	/**
@@ -120,8 +120,8 @@  discard block
 block discarded – undo
120 120
 	 *
121 121
 	 * @since 1.0
122 122
 	 */
123
-	public function set( $key, $value ) {
124
-		$this->options[ $key ] = $value;
123
+	public function set($key, $value) {
124
+		$this->options[$key] = $value;
125 125
 	}
126 126
 
127 127
 	/**
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
 	 *
132 132
 	 * @since 1.0
133 133
 	 */
134
-	public function get( $key ) {
135
-		return isset( $this->options[ $key ] ) ? $this->options[ $key ] : false;
134
+	public function get($key) {
135
+		return isset($this->options[$key]) ? $this->options[$key] : false;
136 136
 	}
137 137
 
138 138
 	/**
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 * @since 1.0
142 142
 	 */
143 143
 	public function get_data() {
144
-		return apply_filters( 'give_get_graph_data', $this->data, $this );
144
+		return apply_filters('give_get_graph_data', $this->data, $this);
145 145
 	}
146 146
 
147 147
 	/**
@@ -151,19 +151,19 @@  discard block
 block discarded – undo
151 151
 	 */
152 152
 	public function load_scripts() {
153 153
 		// Use minified libraries if SCRIPT_DEBUG is turned off
154
-		$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
154
+		$suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
155 155
 
156
-		wp_register_script( 'jquery-flot-orderbars', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot.orderBars' . $suffix . '.js', array('jquery-flot'), GIVE_VERSION );
157
-		wp_enqueue_script( 'jquery-flot-orderbars' );
156
+		wp_register_script('jquery-flot-orderbars', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot.orderBars'.$suffix.'.js', array('jquery-flot'), GIVE_VERSION);
157
+		wp_enqueue_script('jquery-flot-orderbars');
158 158
 
159
-		wp_register_script( 'jquery-flot-time', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot.time' . $suffix . '.js', array('jquery-flot'), GIVE_VERSION );
160
-		wp_enqueue_script( 'jquery-flot-time' );
159
+		wp_register_script('jquery-flot-time', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot.time'.$suffix.'.js', array('jquery-flot'), GIVE_VERSION);
160
+		wp_enqueue_script('jquery-flot-time');
161 161
 
162
-		wp_register_script( 'jquery-flot-resize', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot.resize' . $suffix . '.js', array('jquery-flot'), GIVE_VERSION );
163
-		wp_enqueue_script( 'jquery-flot-resize' );
162
+		wp_register_script('jquery-flot-resize', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot.resize'.$suffix.'.js', array('jquery-flot'), GIVE_VERSION);
163
+		wp_enqueue_script('jquery-flot-resize');
164 164
 
165
-		wp_register_script( 'jquery-flot', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot' . $suffix . '.js', false, GIVE_VERSION );
166
-		wp_enqueue_script( 'jquery-flot' );
165
+		wp_register_script('jquery-flot', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot'.$suffix.'.js', false, GIVE_VERSION);
166
+		wp_enqueue_script('jquery-flot');
167 167
 
168 168
 	}
169 169
 
@@ -190,14 +190,14 @@  discard block
 block discarded – undo
190 190
 					[
191 191
 						<?php
192 192
 							$order = 0;
193
-							foreach( $this->get_data() as $label => $data ) :
193
+							foreach ($this->get_data() as $label => $data) :
194 194
 						?>
195 195
 						{
196
-							label : "<?php echo esc_attr( $label ); ?>",
197
-							id    : "<?php echo sanitize_key( $label ); ?>",
198
-							dataType  : '<?php echo ( ! empty( $this->options['dataType'][$order] ) ? $this->options['dataType'][$order] : 'count' ); ?>',
196
+							label : "<?php echo esc_attr($label); ?>",
197
+							id    : "<?php echo sanitize_key($label); ?>",
198
+							dataType  : '<?php echo ( ! empty($this->options['dataType'][$order]) ? $this->options['dataType'][$order] : 'count'); ?>',
199 199
 							// data format is: [ point on x, value on y ]
200
-							data  : [<?php foreach( $data as $point ) { echo '[' . implode( ',', $point ) . '],'; } ?>],
200
+							data  : [<?php foreach ($data as $point) { echo '['.implode(',', $point).'],'; } ?>],
201 201
 							points: {
202 202
 								show: <?php echo $this->options['points'] ? 'true' : 'false'; ?>,
203 203
 							},
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 								fill     : true,
213 213
 								fillColor: {colors: [{opacity: 0.4}, {opacity: 0.1}]}
214 214
 							},
215
-							<?php if( $this->options[ 'multiple_y_axes' ] ) : ?>
215
+							<?php if ($this->options['multiple_y_axes']) : ?>
216 216
 							yaxis : <?php echo $yaxis_count; ?>
217 217
 							<?php endif; ?>
218 218
 
@@ -226,10 +226,10 @@  discard block
 block discarded – undo
226 226
 						grid: {
227 227
 							show           : true,
228 228
 							aboveData      : false,
229
-							color          : "<?php echo $this->options[ 'color' ]; ?>",
230
-							backgroundColor: "<?php echo $this->options[ 'bgcolor' ]; ?>",
231
-							borderColor    : "<?php echo $this->options[ 'bordercolor' ]; ?>",
232
-							borderWidth    : <?php echo absint( $this->options[ 'borderwidth' ] ); ?>,
229
+							color          : "<?php echo $this->options['color']; ?>",
230
+							backgroundColor: "<?php echo $this->options['bgcolor']; ?>",
231
+							borderColor    : "<?php echo $this->options['bordercolor']; ?>",
232
+							borderWidth    : <?php echo absint($this->options['borderwidth']); ?>,
233 233
 							clickable      : false,
234 234
 							hoverable      : true
235 235
 						},
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 							mode        : "<?php echo $this->options['x_mode']; ?>",
241 241
 							timeFormat  : "<?php echo $this->options['x_mode'] == 'time' ? $this->options['time_format'] : ''; ?>",
242 242
 							tickSize    : "<?php echo $this->options['x_mode'] == 'time' ? '' : 1; ?>",
243
-							<?php if( $this->options['x_mode'] != 'time' ) : ?>
243
+							<?php if ($this->options['x_mode'] != 'time') : ?>
244 244
 							tickDecimals: <?php echo $this->options['x_decimals']; ?>
245 245
 							<?php endif; ?>
246 246
 						},
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 							min         : 0,
250 250
 							mode        : "<?php echo $this->options['y_mode']; ?>",
251 251
 							timeFormat  : "<?php echo $this->options['y_mode'] == 'time' ? $this->options['time_format'] : ''; ?>",
252
-							<?php if( $this->options['y_mode'] != 'time' ) : ?>
252
+							<?php if ($this->options['y_mode'] != 'time') : ?>
253 253
 							tickDecimals: <?php echo $this->options['y_decimals']; ?>
254 254
 							<?php endif; ?>
255 255
 						}
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 		 *
321 321
 		 * @param Give_Graph $this Graph object.
322 322
 		 */
323
-		do_action( 'give_before_graph', $this );
323
+		do_action('give_before_graph', $this);
324 324
 
325 325
 		// Build the graph.
326 326
 		echo $this->build_graph();
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 		 *
333 333
 		 * @param Give_Graph $this Graph object.
334 334
 		 */
335
-		do_action( 'give_after_graph', $this );
335
+		do_action('give_after_graph', $this);
336 336
 	}
337 337
 
338 338
 }
Please login to merge, or discard this patch.
includes/admin/class-admin-settings.php 1 patch
Spacing   +208 added lines, -208 removed lines patch added patch discarded remove patch
@@ -9,11 +9,11 @@  discard block
 block discarded – undo
9 9
  * @since       1.8
10 10
  */
11 11
 
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit;
14 14
 }
15 15
 
16
-if ( ! class_exists( 'Give_Admin_Settings' ) ) :
16
+if ( ! class_exists('Give_Admin_Settings')) :
17 17
 
18 18
 	/**
19 19
 	 * Give_Admin_Settings Class.
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 			 *
73 73
 			 * @param array $settings Array of settings class object.
74 74
 			 */
75
-			self::$settings = apply_filters( self::$setting_filter_prefix . '_get_settings_pages', array() );
75
+			self::$settings = apply_filters(self::$setting_filter_prefix.'_get_settings_pages', array());
76 76
 
77 77
 			return self::$settings;
78 78
 		}
@@ -86,8 +86,8 @@  discard block
 block discarded – undo
86 86
 		public static function save() {
87 87
 			$current_tab = give_get_current_setting_tab();
88 88
 
89
-			if ( empty( $_REQUEST['_give-save-settings'] ) || ! wp_verify_nonce( $_REQUEST['_give-save-settings'], 'give-save-settings' ) ) {
90
-				echo '<div class="notice error"><p>' . __( 'Action failed. Please refresh the page and retry.', 'give' ) . '</p></div>';
89
+			if (empty($_REQUEST['_give-save-settings']) || ! wp_verify_nonce($_REQUEST['_give-save-settings'], 'give-save-settings')) {
90
+				echo '<div class="notice error"><p>'.__('Action failed. Please refresh the page and retry.', 'give').'</p></div>';
91 91
 				die();
92 92
 			}
93 93
 
@@ -100,9 +100,9 @@  discard block
 block discarded – undo
100 100
 			 *
101 101
 			 * @since 1.8
102 102
 			 */
103
-			do_action( self::$setting_filter_prefix . '_save_' . $current_tab );
103
+			do_action(self::$setting_filter_prefix.'_save_'.$current_tab);
104 104
 
105
-			self::add_message( 'give-setting-updated', __( 'Your settings have been saved.', 'give' ) );
105
+			self::add_message('give-setting-updated', __('Your settings have been saved.', 'give'));
106 106
 
107 107
 			/**
108 108
 			 * Trigger Action.
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 			 *
114 114
 			 * @since 1.8
115 115
 			 */
116
-			do_action( self::$setting_filter_prefix . '_saved' );
116
+			do_action(self::$setting_filter_prefix.'_saved');
117 117
 		}
118 118
 
119 119
 		/**
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
 		 *
127 127
 		 * @return void
128 128
 		 */
129
-		public static function add_message( $code, $message ) {
130
-			self::$messages[ $code ] = $message;
129
+		public static function add_message($code, $message) {
130
+			self::$messages[$code] = $message;
131 131
 		}
132 132
 
133 133
 		/**
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
 		 *
141 141
 		 * @return void
142 142
 		 */
143
-		public static function add_error( $code, $message ) {
144
-			self::$errors[ $code ] = $message;
143
+		public static function add_error($code, $message) {
144
+			self::$errors[$code] = $message;
145 145
 		}
146 146
 
147 147
 		/**
@@ -154,18 +154,18 @@  discard block
 block discarded – undo
154 154
 			$notice_html = '';
155 155
 			$classes     = 'give-notice settings-error notice is-dismissible';
156 156
 
157
-			self::$errors   = apply_filters( self::$setting_filter_prefix . '_error_notices', self::$errors );
158
-			self::$messages = apply_filters( self::$setting_filter_prefix . '_update_notices', self::$messages );
157
+			self::$errors   = apply_filters(self::$setting_filter_prefix.'_error_notices', self::$errors);
158
+			self::$messages = apply_filters(self::$setting_filter_prefix.'_update_notices', self::$messages);
159 159
 
160
-			if ( 0 < count( self::$errors ) ) {
161
-				foreach ( self::$errors as $code => $message ) {
162
-					$notice_html .= '<div id="setting-error-' . $code . '" class="' . $classes . ' error"><p><strong>' . $message . '</strong></p></div>';
160
+			if (0 < count(self::$errors)) {
161
+				foreach (self::$errors as $code => $message) {
162
+					$notice_html .= '<div id="setting-error-'.$code.'" class="'.$classes.' error"><p><strong>'.$message.'</strong></p></div>';
163 163
 				}
164 164
 			}
165 165
 
166
-			if ( 0 < count( self::$messages ) ) {
167
-				foreach ( self::$messages as $code => $message ) {
168
-					$notice_html .= '<div id="setting-error-' . $code . '" class="' . $classes . ' updated"><p><strong>' . $message . '</strong></p></div>';
166
+			if (0 < count(self::$messages)) {
167
+				foreach (self::$messages as $code => $message) {
168
+					$notice_html .= '<div id="setting-error-'.$code.'" class="'.$classes.' updated"><p><strong>'.$message.'</strong></p></div>';
169 169
 				}
170 170
 			}
171 171
 
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 			self::$setting_filter_prefix = give_get_current_setting_page();
186 186
 
187 187
 			// Bailout: Exit if setting page is not defined.
188
-			if ( empty( self::$setting_filter_prefix ) ) {
188
+			if (empty(self::$setting_filter_prefix)) {
189 189
 				return false;
190 190
 			}
191 191
 
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 			 *
199 199
 			 * @since 1.8
200 200
 			 */
201
-			do_action( self::$setting_filter_prefix . '_start' );
201
+			do_action(self::$setting_filter_prefix.'_start');
202 202
 
203 203
 			$current_tab = give_get_current_setting_tab();
204 204
 
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 			self::get_settings_pages();
207 207
 
208 208
 			// Save settings if data has been posted.
209
-			if ( ! empty( $_POST ) ) {
209
+			if ( ! empty($_POST)) {
210 210
 				self::save();
211 211
 			}
212 212
 
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 			 *
220 220
 			 * @since 1.8
221 221
 			 */
222
-			$tabs = apply_filters( self::$setting_filter_prefix . '_tabs_array', array() );
222
+			$tabs = apply_filters(self::$setting_filter_prefix.'_tabs_array', array());
223 223
 
224 224
 			include 'views/html-admin-settings.php';
225 225
 
@@ -237,25 +237,25 @@  discard block
 block discarded – undo
237 237
 		 *
238 238
 		 * @return string|bool
239 239
 		 */
240
-		public static function get_option( $option_name = '', $field_id = '', $default = false ) {
240
+		public static function get_option($option_name = '', $field_id = '', $default = false) {
241 241
 			// Bailout.
242
-			if ( empty( $option_name ) && empty( $field_id ) ) {
242
+			if (empty($option_name) && empty($field_id)) {
243 243
 				return false;
244 244
 			}
245 245
 
246
-			if ( ! empty( $field_id ) && ! empty( $option_name ) ) {
246
+			if ( ! empty($field_id) && ! empty($option_name)) {
247 247
 				// Get field value if any.
248
-				$option_value = get_option( $option_name );
248
+				$option_value = get_option($option_name);
249 249
 
250
-				$option_value = ( is_array( $option_value ) && array_key_exists( $field_id, $option_value ) )
251
-					? $option_value[ $field_id ]
250
+				$option_value = (is_array($option_value) && array_key_exists($field_id, $option_value))
251
+					? $option_value[$field_id]
252 252
 					: $default;
253 253
 			} else {
254 254
 				// If option name is empty but not field name then this means, setting is direct store to option table under there field name.
255 255
 				$option_name = ! $option_name ? $field_id : $option_name;
256 256
 
257 257
 				// Get option value if any.
258
-				$option_value = get_option( $option_name, $default );
258
+				$option_value = get_option($option_name, $default);
259 259
 			}
260 260
 
261 261
 			return $option_value;
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 		 *
274 274
 		 * @return void
275 275
 		 */
276
-		public static function output_fields( $options, $option_name = '' ) {
276
+		public static function output_fields($options, $option_name = '') {
277 277
 			$current_tab = give_get_current_setting_tab();
278 278
 
279 279
 			// Field Default values.
@@ -286,52 +286,52 @@  discard block
 block discarded – undo
286 286
 				'table_html' => true,
287 287
 			);
288 288
 
289
-			foreach ( $options as $value ) {
290
-				if ( ! isset( $value['type'] ) ) {
289
+			foreach ($options as $value) {
290
+				if ( ! isset($value['type'])) {
291 291
 					continue;
292 292
 				}
293 293
 
294 294
 				// Set title.
295
-				$defaults['title'] = isset( $value['name'] ) ? $value['name'] : '';
295
+				$defaults['title'] = isset($value['name']) ? $value['name'] : '';
296 296
 
297 297
 				// Set default setting.
298
-				$value = wp_parse_args( $value, $defaults );
298
+				$value = wp_parse_args($value, $defaults);
299 299
 
300 300
 				// Colorpicker field.
301
-				$value['class'] = ( 'colorpicker' === $value['type'] ? trim( $value['class'] ) . ' give-colorpicker' : $value['class'] );
302
-				$value['type']  = ( 'colorpicker' === $value['type'] ? 'text' : $value['type'] );
301
+				$value['class'] = ('colorpicker' === $value['type'] ? trim($value['class']).' give-colorpicker' : $value['class']);
302
+				$value['type']  = ('colorpicker' === $value['type'] ? 'text' : $value['type']);
303 303
 
304 304
 
305 305
 				// Custom attribute handling.
306 306
 				$custom_attributes = array();
307 307
 
308
-				if ( ! empty( $value['attributes'] ) && is_array( $value['attributes'] ) ) {
309
-					foreach ( $value['attributes'] as $attribute => $attribute_value ) {
310
-						$custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"';
308
+				if ( ! empty($value['attributes']) && is_array($value['attributes'])) {
309
+					foreach ($value['attributes'] as $attribute => $attribute_value) {
310
+						$custom_attributes[] = esc_attr($attribute).'="'.esc_attr($attribute_value).'"';
311 311
 					}
312 312
 				}
313 313
 
314 314
 				// Description handling.
315
-				$description          = self::get_field_description( $value );
315
+				$description = self::get_field_description($value);
316 316
 
317 317
 				// Switch based on type.
318
-				switch ( $value['type'] ) {
318
+				switch ($value['type']) {
319 319
 
320 320
 					// Section Titles
321 321
 					case 'title':
322
-						if ( ! empty( $value['title'] ) ) {
323
-							echo '<div class="give-setting-tab-header give-setting-tab-header-' . $current_tab . '"><h2>' . self::get_field_title( $value ) . '</h2><hr></div>';
322
+						if ( ! empty($value['title'])) {
323
+							echo '<div class="give-setting-tab-header give-setting-tab-header-'.$current_tab.'"><h2>'.self::get_field_title($value).'</h2><hr></div>';
324 324
 						}
325 325
 
326
-						if ( ! empty( $value['desc'] ) ) {
327
-							echo wpautop( wptexturize( wp_kses_post( $value['desc'] ) ) );
326
+						if ( ! empty($value['desc'])) {
327
+							echo wpautop(wptexturize(wp_kses_post($value['desc'])));
328 328
 						}
329 329
 
330
-						if ( $value['table_html'] ) {
331
-							echo '<table class="form-table give-setting-tab-body give-setting-tab-body-' . $current_tab . '">' . "\n\n";
330
+						if ($value['table_html']) {
331
+							echo '<table class="form-table give-setting-tab-body give-setting-tab-body-'.$current_tab.'">'."\n\n";
332 332
 						}
333 333
 
334
-						if ( ! empty( $value['id'] ) ) {
334
+						if ( ! empty($value['id'])) {
335 335
 
336 336
 							/**
337 337
 							 * Trigger Action.
@@ -340,14 +340,14 @@  discard block
 block discarded – undo
340 340
 							 *
341 341
 							 * @since 1.8
342 342
 							 */
343
-							do_action( 'give_settings_' . sanitize_title( $value['id'] ) );
343
+							do_action('give_settings_'.sanitize_title($value['id']));
344 344
 						}
345 345
 
346 346
 						break;
347 347
 
348 348
 					// Section Ends.
349 349
 					case 'sectionend':
350
-						if ( ! empty( $value['id'] ) ) {
350
+						if ( ! empty($value['id'])) {
351 351
 
352 352
 							/**
353 353
 							 * Trigger Action.
@@ -356,14 +356,14 @@  discard block
 block discarded – undo
356 356
 							 *
357 357
 							 * @since 1.8
358 358
 							 */
359
-							do_action( 'give_settings_' . sanitize_title( $value['id'] ) . '_end' );
359
+							do_action('give_settings_'.sanitize_title($value['id']).'_end');
360 360
 						}
361 361
 
362
-						if ( $value['table_html'] ) {
362
+						if ($value['table_html']) {
363 363
 							echo '</table>';
364 364
 						}
365 365
 
366
-						if ( ! empty( $value['id'] ) ) {
366
+						if ( ! empty($value['id'])) {
367 367
 
368 368
 							/**
369 369
 							 * Trigger Action.
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
 							 *
373 373
 							 * @since 1.8
374 374
 							 */
375
-							do_action( 'give_settings_' . sanitize_title( $value['id'] ) . '_after' );
375
+							do_action('give_settings_'.sanitize_title($value['id']).'_after');
376 376
 						}
377 377
 
378 378
 						break;
@@ -385,22 +385,22 @@  discard block
 block discarded – undo
385 385
 					case 'password' :
386 386
 
387 387
 						$type = $value['type'];
388
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
388
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
389 389
 
390 390
 						?>
391
-                    <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
391
+                    <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
392 392
                         <th scope="row" class="titledesc">
393
-                            <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
393
+                            <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
394 394
                         </th>
395
-                        <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>">
395
+                        <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>">
396 396
                             <input
397
-                                    name="<?php echo esc_attr( $value['id'] ); ?>"
398
-                                    id="<?php echo esc_attr( $value['id'] ); ?>"
399
-                                    type="<?php echo esc_attr( $type ); ?>"
400
-                                    style="<?php echo esc_attr( $value['css'] ); ?>"
401
-                                    value="<?php echo esc_attr( $option_value ); ?>"
402
-                                    class="give-input-field<?php echo( empty( $value['class'] ) ? '' : ' ' . esc_attr( $value['class'] ) ); ?>"
403
-								<?php echo implode( ' ', $custom_attributes ); ?>
397
+                                    name="<?php echo esc_attr($value['id']); ?>"
398
+                                    id="<?php echo esc_attr($value['id']); ?>"
399
+                                    type="<?php echo esc_attr($type); ?>"
400
+                                    style="<?php echo esc_attr($value['css']); ?>"
401
+                                    value="<?php echo esc_attr($option_value); ?>"
402
+                                    class="give-input-field<?php echo(empty($value['class']) ? '' : ' '.esc_attr($value['class'])); ?>"
403
+								<?php echo implode(' ', $custom_attributes); ?>
404 404
                             /> <?php echo $description; ?>
405 405
                         </td>
406 406
                         </tr><?php
@@ -409,23 +409,23 @@  discard block
 block discarded – undo
409 409
 					// Textarea.
410 410
 					case 'textarea':
411 411
 
412
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
412
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
413 413
 
414 414
 						?>
415
-                    <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
415
+                    <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
416 416
                         <th scope="row" class="titledesc">
417
-                            <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
417
+                            <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
418 418
                         </th>
419
-                        <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>">
419
+                        <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>">
420 420
 								<textarea
421
-                                        name="<?php echo esc_attr( $value['id'] ); ?>"
422
-                                        id="<?php echo esc_attr( $value['id'] ); ?>"
423
-                                        style="<?php echo esc_attr( $value['css'] ); ?>"
424
-                                        class="<?php echo esc_attr( $value['class'] ); ?>"
421
+                                        name="<?php echo esc_attr($value['id']); ?>"
422
+                                        id="<?php echo esc_attr($value['id']); ?>"
423
+                                        style="<?php echo esc_attr($value['css']); ?>"
424
+                                        class="<?php echo esc_attr($value['class']); ?>"
425 425
                                         rows="10"
426 426
                                         cols="60"
427
-									<?php echo implode( ' ', $custom_attributes ); ?>
428
-                                ><?php echo esc_textarea( $option_value ); ?></textarea>
427
+									<?php echo implode(' ', $custom_attributes); ?>
428
+                                ><?php echo esc_textarea($option_value); ?></textarea>
429 429
 							<?php echo $description; ?>
430 430
                         </td>
431 431
                         </tr><?php
@@ -435,35 +435,35 @@  discard block
 block discarded – undo
435 435
 					case 'select' :
436 436
 					case 'multiselect' :
437 437
 
438
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
438
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
439 439
 
440 440
 						?>
441
-                    <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
441
+                    <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
442 442
                         <th scope="row" class="titledesc">
443
-                            <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
443
+                            <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
444 444
                         </th>
445
-                        <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>">
445
+                        <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>">
446 446
                             <select
447
-                                    name="<?php echo esc_attr( $value['id'] ); ?><?php if ( $value['type'] == 'multiselect' ) {
447
+                                    name="<?php echo esc_attr($value['id']); ?><?php if ($value['type'] == 'multiselect') {
448 448
 										echo '[]';
449 449
 									} ?>"
450
-                                    id="<?php echo esc_attr( $value['id'] ); ?>"
451
-                                    style="<?php echo esc_attr( $value['css'] ); ?>"
452
-                                    class="<?php echo esc_attr( $value['class'] ); ?>"
453
-								<?php echo implode( ' ', $custom_attributes ); ?>
454
-								<?php echo ( 'multiselect' == $value['type'] ) ? 'multiple="multiple"' : ''; ?>
450
+                                    id="<?php echo esc_attr($value['id']); ?>"
451
+                                    style="<?php echo esc_attr($value['css']); ?>"
452
+                                    class="<?php echo esc_attr($value['class']); ?>"
453
+								<?php echo implode(' ', $custom_attributes); ?>
454
+								<?php echo ('multiselect' == $value['type']) ? 'multiple="multiple"' : ''; ?>
455 455
                             >
456 456
 
457 457
 								<?php
458
-								if ( ! empty( $value['options'] ) ) {
459
-									foreach ( $value['options'] as $key => $val ) {
458
+								if ( ! empty($value['options'])) {
459
+									foreach ($value['options'] as $key => $val) {
460 460
 										?>
461
-                                        <option value="<?php echo esc_attr( $key ); ?>" <?php
461
+                                        <option value="<?php echo esc_attr($key); ?>" <?php
462 462
 
463
-										if ( is_array( $option_value ) ) {
464
-											selected( in_array( $key, $option_value ), true );
463
+										if (is_array($option_value)) {
464
+											selected(in_array($key, $option_value), true);
465 465
 										} else {
466
-											selected( $option_value, $key );
466
+											selected($option_value, $key);
467 467
 										}
468 468
 
469 469
 										?>><?php echo $val ?></option>
@@ -479,28 +479,28 @@  discard block
 block discarded – undo
479 479
 
480 480
 					// Radio inputs.
481 481
 					case 'radio_inline' :
482
-						$value['class'] = empty( $value['class'] ) ? 'give-radio-inline' : $value['class'] . ' give-radio-inline';
482
+						$value['class'] = empty($value['class']) ? 'give-radio-inline' : $value['class'].' give-radio-inline';
483 483
 					case 'radio' :
484
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
484
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
485 485
 						?>
486
-                    <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
486
+                    <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
487 487
                         <th scope="row" class="titledesc">
488
-                            <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
488
+                            <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
489 489
                         </th>
490
-                        <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?> <?php echo( ! empty( $value['class'] ) ? $value['class'] : '' ); ?>">
490
+                        <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?> <?php echo( ! empty($value['class']) ? $value['class'] : ''); ?>">
491 491
                             <fieldset>
492 492
                                 <ul>
493 493
 									<?php
494
-									foreach ( $value['options'] as $key => $val ) {
494
+									foreach ($value['options'] as $key => $val) {
495 495
 										?>
496 496
                                         <li>
497 497
                                             <label><input
498
-                                                        name="<?php echo esc_attr( $value['id'] ); ?>"
498
+                                                        name="<?php echo esc_attr($value['id']); ?>"
499 499
                                                         value="<?php echo $key; ?>"
500 500
                                                         type="radio"
501
-                                                        style="<?php echo esc_attr( $value['css'] ); ?>"
502
-													<?php echo implode( ' ', $custom_attributes ); ?>
503
-													<?php checked( $key, $option_value ); ?>
501
+                                                        style="<?php echo esc_attr($value['css']); ?>"
502
+													<?php echo implode(' ', $custom_attributes); ?>
503
+													<?php checked($key, $option_value); ?>
504 504
                                                 /> <?php echo $val ?></label>
505 505
                                         </li>
506 506
 										<?php
@@ -514,21 +514,21 @@  discard block
 block discarded – undo
514 514
 
515 515
 					// Checkbox input.
516 516
 					case 'checkbox' :
517
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
517
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
518 518
 						?>
519
-                        <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
519
+                        <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
520 520
                             <th scope="row" class="titledesc">
521
-                                <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
521
+                                <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
522 522
                             </th>
523 523
                             <td class="give-forminp">
524 524
                                 <input
525
-                                        name="<?php echo esc_attr( $value['id'] ); ?>"
526
-                                        id="<?php echo esc_attr( $value['id'] ); ?>"
525
+                                        name="<?php echo esc_attr($value['id']); ?>"
526
+                                        id="<?php echo esc_attr($value['id']); ?>"
527 527
                                         type="checkbox"
528
-                                        class="<?php echo esc_attr( isset( $value['class'] ) ? $value['class'] : '' ); ?>"
528
+                                        class="<?php echo esc_attr(isset($value['class']) ? $value['class'] : ''); ?>"
529 529
                                         value="1"
530
-									<?php checked( $option_value, 'on' ); ?>
531
-									<?php echo implode( ' ', $custom_attributes ); ?>
530
+									<?php checked($option_value, 'on'); ?>
531
+									<?php echo implode(' ', $custom_attributes); ?>
532 532
                                 />
533 533
 								<?php echo $description; ?>
534 534
                             </td>
@@ -538,28 +538,28 @@  discard block
 block discarded – undo
538 538
 
539 539
 					// Multi Checkbox input.
540 540
 					case 'multicheck' :
541
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
542
-						$option_value = is_array( $option_value ) ? $option_value : array();
541
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
542
+						$option_value = is_array($option_value) ? $option_value : array();
543 543
 						?>
544
-                        <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
544
+                        <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
545 545
                             <th scope="row" class="titledesc">
546
-                                <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
546
+                                <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
547 547
                             </th>
548
-                            <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?> <?php echo( ! empty( $value['class'] ) ? $value['class'] : '' ); ?>">
548
+                            <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?> <?php echo( ! empty($value['class']) ? $value['class'] : ''); ?>">
549 549
                                 <fieldset>
550 550
                                     <ul>
551 551
 										<?php
552
-										foreach ( $value['options'] as $key => $val ) {
552
+										foreach ($value['options'] as $key => $val) {
553 553
 											?>
554 554
                                             <li>
555 555
                                                 <label>
556 556
                                                     <input
557
-                                                            name="<?php echo esc_attr( $value['id'] ); ?>[]"
557
+                                                            name="<?php echo esc_attr($value['id']); ?>[]"
558 558
                                                             value="<?php echo $key; ?>"
559 559
                                                             type="checkbox"
560
-                                                            style="<?php echo esc_attr( $value['css'] ); ?>"
561
-														<?php echo implode( ' ', $custom_attributes ); ?>
562
-														<?php if ( in_array( $key, $option_value ) ) {
560
+                                                            style="<?php echo esc_attr($value['css']); ?>"
561
+														<?php echo implode(' ', $custom_attributes); ?>
562
+														<?php if (in_array($key, $option_value)) {
563 563
 															echo 'checked="checked"';
564 564
 														} ?>
565 565
                                                     /> <?php echo $val ?>
@@ -577,25 +577,25 @@  discard block
 block discarded – undo
577 577
 
578 578
 					// File input field.
579 579
 					case 'file' :
580
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
580
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
581 581
 						?>
582
-                    <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
582
+                    <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
583 583
                         <th scope="row" class="titledesc">
584
-                            <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
584
+                            <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
585 585
                         </th>
586 586
                         <td class="give-forminp">
587 587
                             <div class="give-field-wrap">
588 588
                                 <label for="<?php echo $value['id'] ?>">
589 589
                                     <input
590
-                                            name="<?php echo esc_attr( $value['id'] ); ?>"
591
-                                            id="<?php echo esc_attr( $value['id'] ); ?>"
590
+                                            name="<?php echo esc_attr($value['id']); ?>"
591
+                                            id="<?php echo esc_attr($value['id']); ?>"
592 592
                                             type="text"
593
-                                            class="give-input-field<?php echo esc_attr( isset( $value['class'] ) ? ' ' . $value['class'] : '' ); ?>"
593
+                                            class="give-input-field<?php echo esc_attr(isset($value['class']) ? ' '.$value['class'] : ''); ?>"
594 594
                                             value="<?php echo $option_value; ?>"
595
-                                            style="<?php echo esc_attr( $value['css'] ); ?>"
596
-										<?php echo implode( ' ', $custom_attributes ); ?>
595
+                                            style="<?php echo esc_attr($value['css']); ?>"
596
+										<?php echo implode(' ', $custom_attributes); ?>
597 597
                                     />&nbsp;&nbsp;&nbsp;&nbsp;<input class="give-upload-button button" type="button"
598
-                                                                     value="<?php echo esc_html__( 'Add or Upload File', 'give' ); ?>">
598
+                                                                     value="<?php echo esc_html__('Add or Upload File', 'give'); ?>">
599 599
 									<?php echo $description ?>
600 600
                                     <div class="give-image-thumb<?php echo ! $option_value ? ' give-hidden' : ''; ?>">
601 601
                                         <span class="give-delete-image-thumb dashicons dashicons-no-alt"></span>
@@ -610,17 +610,17 @@  discard block
 block discarded – undo
610 610
 					// WordPress Editor.
611 611
 					case 'wysiwyg' :
612 612
 						// Get option value.
613
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
613
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
614 614
 
615 615
 						// Get editor settings.
616
-						$editor_settings = ! empty( $value['options'] ) ? $value['options'] : array();
616
+						$editor_settings = ! empty($value['options']) ? $value['options'] : array();
617 617
 						?>
618
-                    <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
618
+                    <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
619 619
                         <th scope="row" class="titledesc">
620
-                            <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
620
+                            <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
621 621
                         </th>
622 622
                         <td class="give-forminp">
623
-							<?php wp_editor( $option_value, $value['id'], $editor_settings ); ?>
623
+							<?php wp_editor($option_value, $value['id'], $editor_settings); ?>
624 624
 							<?php echo $description; ?>
625 625
                         </td>
626 626
                         </tr><?php
@@ -629,9 +629,9 @@  discard block
 block discarded – undo
629 629
 					// Custom: System setting field.
630 630
 					case 'system_info' :
631 631
 						?>
632
-                    <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
632
+                    <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
633 633
                         <th scope="row" class="titledesc">
634
-                            <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
634
+                            <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
635 635
                         </th>
636 636
                         <td class="give-forminp">
637 637
 							<?php give_system_info_callback(); ?>
@@ -642,14 +642,14 @@  discard block
 block discarded – undo
642 642
 
643 643
 					// Custom: Default gateways setting field.
644 644
 					case 'default_gateway' :
645
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
645
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
646 646
 						?>
647
-                    <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
647
+                    <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
648 648
                         <th scope="row" class="titledesc">
649
-                            <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
649
+                            <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
650 650
                         </th>
651 651
                         <td class="give-forminp">
652
-							<?php give_default_gateway_callback( $value, $option_value ); ?>
652
+							<?php give_default_gateway_callback($value, $option_value); ?>
653 653
 							<?php echo $description; ?>
654 654
                         </td>
655 655
                         </tr><?php
@@ -657,14 +657,14 @@  discard block
 block discarded – undo
657 657
 
658 658
 					// Custom: Enable gateways setting field.
659 659
 					case 'enabled_gateways' :
660
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
660
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
661 661
 						?>
662
-                    <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
662
+                    <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
663 663
                         <th scope="row" class="titledesc">
664
-                            <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
664
+                            <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
665 665
                         </th>
666 666
                         <td class="give-forminp">
667
-							<?php give_enabled_gateways_callback( $value, $option_value ); ?>
667
+							<?php give_enabled_gateways_callback($value, $option_value); ?>
668 668
 							<?php echo $description; ?>
669 669
                         </td>
670 670
                         </tr><?php
@@ -673,9 +673,9 @@  discard block
 block discarded – undo
673 673
 					// Custom: Email preview buttons field.
674 674
 					case 'email_preview_buttons' :
675 675
 						?>
676
-                    <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
676
+                    <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
677 677
                         <th scope="row" class="titledesc">
678
-                            <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
678
+                            <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
679 679
                         </th>
680 680
                         <td class="give-forminp">
681 681
 							<?php give_email_preview_buttons_callback(); ?>
@@ -692,22 +692,22 @@  discard block
 block discarded – undo
692 692
 
693 693
 					// Custom: Gateway API key.
694 694
 					case 'api_key' :
695
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
696
-						$type         = ! empty( $option_value ) ? 'password' : 'text';
695
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
696
+						$type         = ! empty($option_value) ? 'password' : 'text';
697 697
 						?>
698
-                    <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
698
+                    <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
699 699
                         <th scope="row" class="titledesc">
700
-                            <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
700
+                            <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
701 701
                         </th>
702
-                        <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>">
702
+                        <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>">
703 703
                             <input
704
-                                    name="<?php echo esc_attr( $value['id'] ); ?>"
705
-                                    id="<?php echo esc_attr( $value['id'] ); ?>"
706
-                                    type="<?php echo esc_attr( $type ); ?>"
707
-                                    style="<?php echo esc_attr( $value['css'] ); ?>"
708
-                                    value="<?php echo esc_attr( trim( $option_value ) ); ?>"
709
-                                    class="give-input-field<?php echo( empty( $value['class'] ) ? '' : ' ' . esc_attr( $value['class'] ) ); ?>"
710
-								<?php echo implode( ' ', $custom_attributes ); ?>
704
+                                    name="<?php echo esc_attr($value['id']); ?>"
705
+                                    id="<?php echo esc_attr($value['id']); ?>"
706
+                                    type="<?php echo esc_attr($type); ?>"
707
+                                    style="<?php echo esc_attr($value['css']); ?>"
708
+                                    value="<?php echo esc_attr(trim($option_value)); ?>"
709
+                                    class="give-input-field<?php echo(empty($value['class']) ? '' : ' '.esc_attr($value['class'])); ?>"
710
+								<?php echo implode(' ', $custom_attributes); ?>
711 711
                             /> <?php echo $description; ?>
712 712
                         </td>
713 713
                         </tr><?php
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
 					// Custom: Log field.
717 717
 					case 'logs' :
718 718
 
719
-						include GIVE_PLUGIN_DIR . 'includes/admin/tools/logs/logs.php';
719
+						include GIVE_PLUGIN_DIR.'includes/admin/tools/logs/logs.php';
720 720
 
721 721
 						// Get current section.
722 722
 						$current_section = $_GET['section'] = give_get_current_setting_section();
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
 						 *
727 727
 						 * @since 1.0
728 728
 						 */
729
-						do_action( "give_logs_view_{$current_section}" );
729
+						do_action("give_logs_view_{$current_section}");
730 730
 
731 731
 						echo $description;
732 732
 						break;
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
 					// Custom: Data field.
735 735
 					case 'data' :
736 736
 
737
-						include  GIVE_PLUGIN_DIR . 'includes/admin/tools/views/html-admin-page-data.php';
737
+						include  GIVE_PLUGIN_DIR.'includes/admin/tools/views/html-admin-page-data.php';
738 738
 
739 739
 						echo $description;
740 740
 						break;
@@ -742,12 +742,12 @@  discard block
 block discarded – undo
742 742
 					// Custom: Give Docs Link field type.
743 743
 					case 'give_docs_link' :
744 744
 						?>
745
-                    <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
745
+                    <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
746 746
                         <td class="give-docs-link" colspan="2">
747 747
 							<?php
748
-							echo '<p class="give-docs-link"><a href="' . esc_url( $value['url'] )
748
+							echo '<p class="give-docs-link"><a href="'.esc_url($value['url'])
749 749
 							     . '" target="_blank">'
750
-							     . sprintf( esc_html__( 'Need Help? See docs on "%s"', 'give' ), $value['title'] )
750
+							     . sprintf(esc_html__('Need Help? See docs on "%s"', 'give'), $value['title'])
751 751
 							     . '<span class="dashicons dashicons-editor-help"></span></a></p>';
752 752
 							?>
753 753
                         </td>
@@ -758,8 +758,8 @@  discard block
 block discarded – undo
758 758
 					// You can add or handle your custom field action.
759 759
 					default:
760 760
 						// Get option value.
761
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
762
-						do_action( 'give_admin_field_' . $value['type'], $value, $option_value );
761
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
762
+						do_action('give_admin_field_'.$value['type'], $value, $option_value);
763 763
 						break;
764 764
 				}
765 765
 			}
@@ -775,15 +775,15 @@  discard block
 block discarded – undo
775 775
 		 *
776 776
 		 * @return string The HTML description of the field.
777 777
 		 */
778
-		public static function get_field_description( $value ) {
778
+		public static function get_field_description($value) {
779 779
 			$description = '';
780 780
 
781 781
 			// Support for both 'description' and 'desc' args.
782
-			$description_key = isset( $value['description'] ) ? 'description' : 'desc';
783
-			$value           = ( isset( $value[ $description_key ] ) && ! empty( $value[ $description_key ] ) ) ? $value[ $description_key ] : '';
782
+			$description_key = isset($value['description']) ? 'description' : 'desc';
783
+			$value           = (isset($value[$description_key]) && ! empty($value[$description_key])) ? $value[$description_key] : '';
784 784
 
785
-			if ( ! empty( $value ) ) {
786
-				$description = '<p class="give-field-description">' . wp_kses_post( $value ) . '</p>';
785
+			if ( ! empty($value)) {
786
+				$description = '<p class="give-field-description">'.wp_kses_post($value).'</p>';
787 787
 			}
788 788
 
789 789
 			return $description;
@@ -800,11 +800,11 @@  discard block
 block discarded – undo
800 800
 		 *
801 801
 		 * @return array The description and tip as a 2 element array
802 802
 		 */
803
-		public static function get_field_title( $value ) {
804
-			$title = esc_html( $value['title'] );
803
+		public static function get_field_title($value) {
804
+			$title = esc_html($value['title']);
805 805
 
806 806
 			// If html tag detected then allow them to print.
807
-			if ( strip_tags( $title ) ) {
807
+			if (strip_tags($title)) {
808 808
 				$title = $value['title'];
809 809
 			}
810 810
 
@@ -823,8 +823,8 @@  discard block
 block discarded – undo
823 823
 		 *
824 824
 		 * @return bool
825 825
 		 */
826
-		public static function save_fields( $options, $option_name = '' ) {
827
-			if ( empty( $_POST ) ) {
826
+		public static function save_fields($options, $option_name = '') {
827
+			if (empty($_POST)) {
828 828
 				return false;
829 829
 			}
830 830
 
@@ -832,37 +832,37 @@  discard block
 block discarded – undo
832 832
 			$update_options = array();
833 833
 
834 834
 			// Loop options and get values to save.
835
-			foreach ( $options as $option ) {
836
-				if ( ! isset( $option['id'] ) || ! isset( $option['type'] ) ) {
835
+			foreach ($options as $option) {
836
+				if ( ! isset($option['id']) || ! isset($option['type'])) {
837 837
 					continue;
838 838
 				}
839 839
 
840 840
 				// Get posted value.
841
-				if ( strstr( $option['id'], '[' ) ) {
842
-					parse_str( $option['id'], $option_name_array );
843
-					$field_option_name = current( array_keys( $option_name_array ) );
844
-					$setting_name      = key( $option_name_array[ $field_option_name ] );
845
-					$raw_value         = isset( $_POST[ $field_option_name ][ $setting_name ] ) ? wp_unslash( $_POST[ $field_option_name ][ $setting_name ] ) : null;
841
+				if (strstr($option['id'], '[')) {
842
+					parse_str($option['id'], $option_name_array);
843
+					$field_option_name = current(array_keys($option_name_array));
844
+					$setting_name      = key($option_name_array[$field_option_name]);
845
+					$raw_value         = isset($_POST[$field_option_name][$setting_name]) ? wp_unslash($_POST[$field_option_name][$setting_name]) : null;
846 846
 				} else {
847 847
 					$field_option_name = $option['id'];
848 848
 					$setting_name      = '';
849
-					$raw_value         = isset( $_POST[ $option['id'] ] ) ? wp_unslash( $_POST[ $option['id'] ] ) : null;
849
+					$raw_value         = isset($_POST[$option['id']]) ? wp_unslash($_POST[$option['id']]) : null;
850 850
 				}
851 851
 
852 852
 				// Format the value based on option type.
853
-				switch ( $option['type'] ) {
853
+				switch ($option['type']) {
854 854
 					case 'checkbox' :
855
-						$value = is_null( $raw_value ) ? '' : 'on';
855
+						$value = is_null($raw_value) ? '' : 'on';
856 856
 						break;
857 857
 					case 'wysiwyg'  :
858 858
 					case 'textarea' :
859
-						$value = wp_kses_post( trim( $raw_value ) );
859
+						$value = wp_kses_post(trim($raw_value));
860 860
 						break;
861 861
 					case 'multiselect' :
862
-						$value = array_filter( array_map( 'give_clean', (array) $raw_value ) );
862
+						$value = array_filter(array_map('give_clean', (array) $raw_value));
863 863
 						break;
864 864
 					default :
865
-						$value = give_clean( $raw_value );
865
+						$value = give_clean($raw_value);
866 866
 						break;
867 867
 				}
868 868
 
@@ -871,37 +871,37 @@  discard block
 block discarded – undo
871 871
 				 *
872 872
 				 * @since 1.8
873 873
 				 */
874
-				$value = apply_filters( 'give_admin_settings_sanitize_option', $value, $option, $raw_value );
874
+				$value = apply_filters('give_admin_settings_sanitize_option', $value, $option, $raw_value);
875 875
 
876 876
 				/**
877 877
 				 * Sanitize the value of an option by option name.
878 878
 				 *
879 879
 				 * @since 1.8
880 880
 				 */
881
-				$value = apply_filters( "give_admin_settings_sanitize_option_{$field_option_name}", $value, $option, $raw_value );
881
+				$value = apply_filters("give_admin_settings_sanitize_option_{$field_option_name}", $value, $option, $raw_value);
882 882
 
883
-				if ( is_null( $value ) ) {
883
+				if (is_null($value)) {
884 884
 					continue;
885 885
 				}
886 886
 
887 887
 				// Check if option is an array and handle that differently to single values.
888
-				if ( $field_option_name && $setting_name ) {
889
-					if ( ! isset( $update_options[ $field_option_name ] ) ) {
890
-						$update_options[ $field_option_name ] = get_option( $field_option_name, array() );
888
+				if ($field_option_name && $setting_name) {
889
+					if ( ! isset($update_options[$field_option_name])) {
890
+						$update_options[$field_option_name] = get_option($field_option_name, array());
891 891
 					}
892
-					if ( ! is_array( $update_options[ $field_option_name ] ) ) {
893
-						$update_options[ $field_option_name ] = array();
892
+					if ( ! is_array($update_options[$field_option_name])) {
893
+						$update_options[$field_option_name] = array();
894 894
 					}
895
-					$update_options[ $field_option_name ][ $setting_name ] = $value;
895
+					$update_options[$field_option_name][$setting_name] = $value;
896 896
 				} else {
897
-					$update_options[ $field_option_name ] = $value;
897
+					$update_options[$field_option_name] = $value;
898 898
 				}
899 899
 			}
900 900
 
901 901
 			// Save all options in our array or there own option name i.e. option id.
902
-			if ( empty( $option_name ) ) {
903
-				foreach ( $update_options as $name => $value ) {
904
-					update_option( $name, $value );
902
+			if (empty($option_name)) {
903
+				foreach ($update_options as $name => $value) {
904
+					update_option($name, $value);
905 905
 
906 906
 					/**
907 907
 					 * Trigger action.
@@ -910,13 +910,13 @@  discard block
 block discarded – undo
910 910
 					 *
911 911
 					 * @since 1.8
912 912
 					 */
913
-					do_action( "give_save_option_{$name}", $value, $name );
913
+					do_action("give_save_option_{$name}", $value, $name);
914 914
 				}
915 915
 			} else {
916
-				$old_options    = ( $old_options = get_option( $option_name ) ) ? $old_options : array();
917
-				$update_options = array_merge( $old_options, $update_options );
916
+				$old_options    = ($old_options = get_option($option_name)) ? $old_options : array();
917
+				$update_options = array_merge($old_options, $update_options);
918 918
 
919
-				update_option( $option_name, $update_options );
919
+				update_option($option_name, $update_options);
920 920
 
921 921
 				/**
922 922
 				 * Trigger action.
@@ -925,7 +925,7 @@  discard block
 block discarded – undo
925 925
 				 *
926 926
 				 * @since 1.8
927 927
 				 */
928
-				do_action( "give_save_settings_{$option_name}", $update_options, $option_name );
928
+				do_action("give_save_settings_{$option_name}", $update_options, $option_name);
929 929
 			}
930 930
 
931 931
 			return true;
Please login to merge, or discard this patch.
includes/admin/class-addon-activation-banner.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 // Exit if accessed directly.
11
-if ( ! defined( 'ABSPATH' ) ) {
11
+if ( ! defined('ABSPATH')) {
12 12
 	exit;
13 13
 }
14 14
 
@@ -32,14 +32,14 @@  discard block
 block discarded – undo
32 32
 	 *                               'testing'           => false, // (required) Never leave as "true" in production!!!
33 33
 	 *                               }
34 34
 	 */
35
-	function __construct( $_banner_details ) {
35
+	function __construct($_banner_details) {
36 36
 		$current_user = wp_get_current_user();
37 37
 
38 38
 		$this->plugin_activate_by   = 0;
39 39
 		$this->banner_details       = $_banner_details;
40
-		$this->test_mode            = ( $this->banner_details['testing'] == 'true' ) ? true : false;
41
-		$this->nag_meta_key         = 'give_addon_activation_ignore_' . sanitize_title( $this->banner_details['name'] );
42
-		$this->activate_by_meta_key = 'give_addon_' . sanitize_title( $this->banner_details['name'] ) . '_active_by_user';
40
+		$this->test_mode            = ($this->banner_details['testing'] == 'true') ? true : false;
41
+		$this->nag_meta_key         = 'give_addon_activation_ignore_'.sanitize_title($this->banner_details['name']);
42
+		$this->activate_by_meta_key = 'give_addon_'.sanitize_title($this->banner_details['name']).'_active_by_user';
43 43
 
44 44
 		//Get current user
45 45
 		$this->user_id = $current_user->ID;
@@ -62,19 +62,19 @@  discard block
 block discarded – undo
62 62
 	public function init() {
63 63
 
64 64
 		//Testing?
65
-		if ( $this->test_mode ) {
66
-			delete_user_meta( $this->user_id, $this->nag_meta_key );
65
+		if ($this->test_mode) {
66
+			delete_user_meta($this->user_id, $this->nag_meta_key);
67 67
 		}
68 68
 
69 69
 		//Get the current page to add the notice to
70
-		add_action( 'current_screen', array( $this, 'give_addon_notice_ignore' ) );
71
-		add_action( 'admin_notices', array( $this, 'give_addon_activation_admin_notice' ) );
70
+		add_action('current_screen', array($this, 'give_addon_notice_ignore'));
71
+		add_action('admin_notices', array($this, 'give_addon_activation_admin_notice'));
72 72
 
73 73
 		// File path of addon must be included in banner detail other addon activate meta will not delete.
74 74
 		$file_name = $this->get_plugin_file_name();
75 75
 
76
-		if ( ! empty( $file_name ) ) {
77
-			add_action( 'deactivate_' . $file_name, array( $this, 'remove_addon_activate_meta' ) );
76
+		if ( ! empty($file_name)) {
77
+			add_action('deactivate_'.$file_name, array($this, 'remove_addon_activate_meta'));
78 78
 		}
79 79
 	}
80 80
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	private function is_plugin_page() {
90 90
 		$screen = get_current_screen();
91 91
 
92
-		return ( $screen->parent_file === 'plugins.php' );
92
+		return ($screen->parent_file === 'plugins.php');
93 93
 	}
94 94
 
95 95
 
@@ -102,12 +102,12 @@  discard block
 block discarded – undo
102 102
 	public function give_addon_activation_admin_notice() {
103 103
 
104 104
 		// Bailout.
105
-		if ( ! $this->is_plugin_page() || $this->user_id !== $this->plugin_activate_by ) {
105
+		if ( ! $this->is_plugin_page() || $this->user_id !== $this->plugin_activate_by) {
106 106
 			return;
107 107
 		}
108 108
 
109 109
 		// If the user hasn't already dismissed the alert, output activation banner.
110
-		if ( ! get_user_meta( $this->user_id, $this->nag_meta_key ) ) {
110
+		if ( ! get_user_meta($this->user_id, $this->nag_meta_key)) {
111 111
 
112 112
 			// Output inline styles here because there's no reason
113 113
 			// to enqueued them after the alert is dismissed.
@@ -189,44 +189,44 @@  discard block
 block discarded – undo
189 189
 					<h3><?php
190 190
 						printf(
191 191
 						/* translators: %s: Add-on name */
192
-							esc_html__( "Thank you for installing Give's %s Add-on!", 'give' ),
193
-							'<span>' . $this->banner_details['name'] . '</span>'
192
+							esc_html__("Thank you for installing Give's %s Add-on!", 'give'),
193
+							'<span>'.$this->banner_details['name'].'</span>'
194 194
 						);
195 195
 						?></h3>
196 196
 
197 197
 					<a href="<?php
198 198
 					//The Dismiss Button.
199
-					$nag_admin_dismiss_url = 'plugins.php?' . $this->nag_meta_key . '=0';
200
-					echo admin_url( $nag_admin_dismiss_url ); ?>" class="dismiss"><span
199
+					$nag_admin_dismiss_url = 'plugins.php?'.$this->nag_meta_key.'=0';
200
+					echo admin_url($nag_admin_dismiss_url); ?>" class="dismiss"><span
201 201
 							class="dashicons dashicons-dismiss"></span></a>
202 202
 
203 203
 					<div class="alert-actions">
204 204
 
205 205
 						<?php //Point them to your settings page.
206
-						if ( isset( $this->banner_details['settings_url'] ) ) { ?>
206
+						if (isset($this->banner_details['settings_url'])) { ?>
207 207
 							<a href="<?php echo $this->banner_details['settings_url']; ?>">
208
-								<span class="dashicons dashicons-admin-settings"></span><?php esc_html_e( 'Go to Settings', 'give' ); ?>
208
+								<span class="dashicons dashicons-admin-settings"></span><?php esc_html_e('Go to Settings', 'give'); ?>
209 209
 							</a>
210 210
 						<?php } ?>
211 211
 
212 212
 						<?php
213 213
 						// Show them how to configure the Addon.
214
-						if ( isset( $this->banner_details['documentation_url'] ) ) { ?>
214
+						if (isset($this->banner_details['documentation_url'])) { ?>
215 215
 							<a href="<?php echo $this->banner_details['documentation_url'] ?>" target="_blank">
216 216
 								<span class="dashicons dashicons-media-text"></span><?php
217 217
 								printf(
218 218
 								/* translators: %s: Add-on name */
219
-									esc_html__( 'Documentation: %s Add-on', 'give' ),
219
+									esc_html__('Documentation: %s Add-on', 'give'),
220 220
 									$this->banner_details['name']
221 221
 								);
222 222
 								?></a>
223 223
 						<?php } ?>
224 224
 						<?php
225 225
 						//Let them signup for plugin updates
226
-						if ( isset( $this->banner_details['support_url'] ) ) { ?>
226
+						if (isset($this->banner_details['support_url'])) { ?>
227 227
 
228 228
 							<a href="<?php echo $this->banner_details['support_url'] ?>" target="_blank">
229
-								<span class="dashicons dashicons-sos"></span><?php esc_html_e( 'Get Support', 'give' ); ?>
229
+								<span class="dashicons dashicons-sos"></span><?php esc_html_e('Get Support', 'give'); ?>
230 230
 							</a>
231 231
 
232 232
 						<?php } ?>
@@ -253,13 +253,13 @@  discard block
 block discarded – undo
253 253
 		 * If user clicks to ignore the notice, add that to their user meta the banner then checks whether this tag exists already or not.
254 254
 		 * See here: http://codex.wordpress.org/Function_Reference/add_user_meta
255 255
 		 */
256
-		if ( isset( $_GET[ $this->nag_meta_key ] ) && '0' == $_GET[ $this->nag_meta_key ] ) {
256
+		if (isset($_GET[$this->nag_meta_key]) && '0' == $_GET[$this->nag_meta_key]) {
257 257
 
258 258
 			//Get the global user
259 259
 			$current_user = wp_get_current_user();
260 260
 			$user_id      = $current_user->ID;
261 261
 
262
-			add_user_meta( $user_id, $this->nag_meta_key, 'true', true );
262
+			add_user_meta($user_id, $this->nag_meta_key, 'true', true);
263 263
 		}
264 264
 	}
265 265
 
@@ -270,11 +270,11 @@  discard block
 block discarded – undo
270 270
 	 * @access private
271 271
 	 */
272 272
 	private function add_addon_activate_meta() {
273
-		$user_id                  = get_option( $this->activate_by_meta_key );
273
+		$user_id                  = get_option($this->activate_by_meta_key);
274 274
 		$this->plugin_activate_by = (int) $user_id;
275 275
 
276
-		if ( ! $user_id ) {
277
-			add_option( $this->activate_by_meta_key, $this->user_id, '', 'no' );
276
+		if ( ! $user_id) {
277
+			add_option($this->activate_by_meta_key, $this->user_id, '', 'no');
278 278
 			$this->plugin_activate_by = (int) $this->user_id;
279 279
 		}
280 280
 	}
@@ -287,10 +287,10 @@  discard block
 block discarded – undo
287 287
 	 * @access public
288 288
 	 */
289 289
 	public function remove_addon_activate_meta() {
290
-		$user_id = get_option( $this->activate_by_meta_key );
290
+		$user_id = get_option($this->activate_by_meta_key);
291 291
 
292
-		if ( $user_id ) {
293
-			delete_option( $this->activate_by_meta_key );
292
+		if ($user_id) {
293
+			delete_option($this->activate_by_meta_key);
294 294
 		}
295 295
 	}
296 296
 
@@ -303,39 +303,39 @@  discard block
 block discarded – undo
303 303
 	 * @return mixed
304 304
 	 */
305 305
 	private function get_plugin_file_name() {
306
-		$active_plugins = get_option( 'active_plugins' );
306
+		$active_plugins = get_option('active_plugins');
307 307
 		$file_name      = '';
308 308
 
309 309
 		try {
310 310
 
311 311
 			// Check addon file path.
312
-			if ( ! empty( $this->banner_details['file'] ) ) {
312
+			if ( ! empty($this->banner_details['file'])) {
313 313
 				$file_name = '';
314
-				if ( $file_path = explode( '/plugins/', $this->banner_details['file'] ) ) {
315
-					$file_path = array_pop( $file_path );
316
-					$file_name = current( explode( '/', $file_path ) );
314
+				if ($file_path = explode('/plugins/', $this->banner_details['file'])) {
315
+					$file_path = array_pop($file_path);
316
+					$file_name = current(explode('/', $file_path));
317 317
 				}
318 318
 
319
-				if ( empty( $file_name ) ) {
319
+				if (empty($file_name)) {
320 320
 					return false;
321 321
 				}
322 322
 
323
-				foreach ( $active_plugins as $plugin ) {
324
-					if ( false !== strpos( $plugin, $file_name ) ) {
323
+				foreach ($active_plugins as $plugin) {
324
+					if (false !== strpos($plugin, $file_name)) {
325 325
 						$file_name = $plugin;
326 326
 						break;
327 327
 					}
328 328
 				}
329
-			} elseif ( WP_DEBUG ) {
330
-				throw new Exception( __( "File path must be added within the {$this->banner_details['name']} add-on in the banner details.", 'give' ) );
329
+			} elseif (WP_DEBUG) {
330
+				throw new Exception(__("File path must be added within the {$this->banner_details['name']} add-on in the banner details.", 'give'));
331 331
 			}
332 332
 
333 333
 			// Check plugin path calculated by addon file path.
334
-			if ( empty( $file_name ) && WP_DEBUG ) {
335
-				throw new Exception( __( "Empty add-on plugin path for {$this->banner_details['name']} add-on.", 'give' ) );
334
+			if (empty($file_name) && WP_DEBUG) {
335
+				throw new Exception(__("Empty add-on plugin path for {$this->banner_details['name']} add-on.", 'give'));
336 336
 			}
337 337
 
338
-		} catch ( Exception $e ) {
338
+		} catch (Exception $e) {
339 339
 			echo $e->getMessage();
340 340
 		}
341 341
 
Please login to merge, or discard this patch.
includes/admin/upgrades/upgrade-functions.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 			give_v187_upgrades();
51 51
 			$did_upgrade = true;
52 52
 
53
-        case version_compare( $give_version, '1.8.8', '<' ) :
53
+		case version_compare( $give_version, '1.8.8', '<' ) :
54 54
 			give_v188_upgrades();
55 55
 			$did_upgrade = true;
56 56
 
@@ -909,19 +909,19 @@  discard block
 block discarded – undo
909 909
 
910 910
 	global $wp_roles;
911 911
 
912
-    // Get the role object.
913
-    $give_worker = get_role( 'give_worker' );
912
+	// Get the role object.
913
+	$give_worker = get_role( 'give_worker' );
914 914
 
915 915
 	// A list of capabilities to add for give workers.
916
-    $caps_to_add = array(
917
-        'edit_posts',
918
-        'edit_pages'
919
-    );
920
-
921
-    foreach ( $caps_to_add as $cap ) {
922
-        // Add the capability.
923
-        $give_worker->add_cap( $cap );
924
-    }
916
+	$caps_to_add = array(
917
+		'edit_posts',
918
+		'edit_pages'
919
+	);
920
+
921
+	foreach ( $caps_to_add as $cap ) {
922
+		// Add the capability.
923
+		$give_worker->add_cap( $cap );
924
+	}
925 925
 
926 926
 }
927 927
 
Please login to merge, or discard this patch.
Spacing   +185 added lines, -185 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,44 +25,44 @@  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
-        case version_compare( $give_version, '1.8.8', '<' ) :
53
+        case version_compare($give_version, '1.8.8', '<') :
54 54
 			give_v188_upgrades();
55 55
 			$did_upgrade = true;
56 56
 
57 57
 	}
58 58
 
59
-	if ( $did_upgrade ) {
60
-		update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) );
59
+	if ($did_upgrade) {
60
+		update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION));
61 61
 	}
62 62
 }
63 63
 
64
-add_action( 'admin_init', 'give_do_automatic_upgrades' );
65
-add_action( 'give_upgrades', 'give_do_automatic_upgrades' );
64
+add_action('admin_init', 'give_do_automatic_upgrades');
65
+add_action('give_upgrades', 'give_do_automatic_upgrades');
66 66
 
67 67
 /**
68 68
  * Display Upgrade Notices
@@ -72,18 +72,18 @@  discard block
 block discarded – undo
72 72
  */
73 73
 function give_show_upgrade_notices() {
74 74
 	// Don't show notices on the upgrades page.
75
-	if ( isset( $_GET['page'] ) && $_GET['page'] == 'give-upgrades' ) {
75
+	if (isset($_GET['page']) && $_GET['page'] == 'give-upgrades') {
76 76
 		return;
77 77
 	}
78 78
 
79
-	$give_version = get_option( 'give_version' );
79
+	$give_version = get_option('give_version');
80 80
 
81
-	if ( ! $give_version ) {
81
+	if ( ! $give_version) {
82 82
 		// 1.0 is the first version to use this option so we must add it.
83 83
 		$give_version = '1.0';
84 84
 	}
85 85
 
86
-	$give_version = preg_replace( '/[^0-9.].*/', '', $give_version );
86
+	$give_version = preg_replace('/[^0-9.].*/', '', $give_version);
87 87
 
88 88
 	/*
89 89
 	 *  NOTICE:
@@ -94,31 +94,31 @@  discard block
 block discarded – undo
94 94
 	 */
95 95
 
96 96
 	// v1.3.2 Upgrades
97
-	if ( version_compare( $give_version, '1.3.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_payment_customer_id' ) ) {
97
+	if (version_compare($give_version, '1.3.2', '<') || ! give_has_upgrade_completed('upgrade_give_payment_customer_id')) {
98 98
 		printf(
99 99
 			/* translators: %s: upgrade URL */
100
-			'<div class="updated"><p>' . __( 'Give needs to upgrade the donor database, click <a href="%s">here</a> to start the upgrade.', 'give' ) . '</p></div>',
101
-			esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=upgrade_give_payment_customer_id' ) )
100
+			'<div class="updated"><p>'.__('Give needs to upgrade the donor database, click <a href="%s">here</a> to start the upgrade.', 'give').'</p></div>',
101
+			esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=upgrade_give_payment_customer_id'))
102 102
 		);
103 103
 	}
104 104
 
105 105
 	// v1.3.4 Upgrades //ensure the user has gone through 1.3.4.
106
-	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' ) ) ) {
106
+	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'))) {
107 107
 		printf(
108 108
 			/* translators: %s: upgrade URL */
109
-			'<div class="updated"><p>' . __( 'Give needs to upgrade the donations database, click <a href="%s">here</a> to start the upgrade.', 'give' ) . '</p></div>',
110
-			esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=upgrade_give_offline_status' ) )
109
+			'<div class="updated"><p>'.__('Give needs to upgrade the donations database, click <a href="%s">here</a> to start the upgrade.', 'give').'</p></div>',
110
+			esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=upgrade_give_offline_status'))
111 111
 		);
112 112
 	}
113 113
 
114 114
 	// Check if we have a stalled upgrade.
115 115
 	$resume_upgrade = give_maybe_resume_upgrade();
116
-	if ( ! empty( $resume_upgrade ) ) {
117
-		$resume_url = add_query_arg( $resume_upgrade, admin_url( 'index.php' ) );
116
+	if ( ! empty($resume_upgrade)) {
117
+		$resume_url = add_query_arg($resume_upgrade, admin_url('index.php'));
118 118
 		echo Give_Notices::notice_html(
119 119
 			sprintf(
120
-				__( 'Give needs to complete a database upgrade that was previously started, click <a href="%s">here</a> to resume the upgrade.', 'give' ),
121
-				esc_url( $resume_url )
120
+				__('Give needs to complete a database upgrade that was previously started, click <a href="%s">here</a> to resume the upgrade.', 'give'),
121
+				esc_url($resume_url)
122 122
 			)
123 123
 		);
124 124
 
@@ -126,11 +126,11 @@  discard block
 block discarded – undo
126 126
 	}
127 127
 
128 128
 	// v1.8 form metadata upgrades.
129
-	if ( version_compare( $give_version, '1.8', '<' ) || ! give_has_upgrade_completed( 'v18_upgrades_form_metadata' ) ) {
129
+	if (version_compare($give_version, '1.8', '<') || ! give_has_upgrade_completed('v18_upgrades_form_metadata')) {
130 130
 		echo Give_Notices::notice_html(
131 131
 			sprintf(
132
-				esc_html__( 'Give needs to upgrade the form database, click %1$shere%2$s to start the upgrade.', 'give' ),
133
-				'<a class="give-upgrade-link" href="' . esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=give_v18_upgrades_form_metadata' ) ) . '">',
132
+				esc_html__('Give needs to upgrade the form database, click %1$shere%2$s to start the upgrade.', 'give'),
133
+				'<a class="give-upgrade-link" href="'.esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=give_v18_upgrades_form_metadata')).'">',
134 134
 				'</a>'
135 135
 			)
136 136
 		);
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 				$upgrade_links.on( 'click', function(e){
146 146
 					e.preventDefault();
147 147
 
148
-					if( ! window.confirm( '<?php _e( 'Please make sure to create a database backup before initiating the upgrade.', 'give' ); ?>' ) ) {
148
+					if( ! window.confirm( '<?php _e('Please make sure to create a database backup before initiating the upgrade.', 'give'); ?>' ) ) {
149 149
 						return;
150 150
 					}
151 151
 
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 	<?php
159 159
 }
160 160
 
161
-add_action( 'admin_notices', 'give_show_upgrade_notices' );
161
+add_action('admin_notices', 'give_show_upgrade_notices');
162 162
 
163 163
 /**
164 164
  * Triggers all upgrade functions
@@ -170,29 +170,29 @@  discard block
 block discarded – undo
170 170
  */
171 171
 function give_trigger_upgrades() {
172 172
 
173
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
174
-		wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array(
173
+	if ( ! current_user_can('manage_give_settings')) {
174
+		wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array(
175 175
 			'response' => 403,
176
-		) );
176
+		));
177 177
 	}
178 178
 
179
-	$give_version = get_option( 'give_version' );
179
+	$give_version = get_option('give_version');
180 180
 
181
-	if ( ! $give_version ) {
181
+	if ( ! $give_version) {
182 182
 		// 1.0 is the first version to use this option so we must add it.
183 183
 		$give_version = '1.0';
184
-		add_option( 'give_version', $give_version );
184
+		add_option('give_version', $give_version);
185 185
 	}
186 186
 
187
-	update_option( 'give_version', GIVE_VERSION );
188
-	delete_option( 'give_doing_upgrade' );
187
+	update_option('give_version', GIVE_VERSION);
188
+	delete_option('give_doing_upgrade');
189 189
 
190
-	if ( DOING_AJAX ) {
191
-		die( 'complete' );
190
+	if (DOING_AJAX) {
191
+		die('complete');
192 192
 	} // End if().
193 193
 }
194 194
 
195
-add_action( 'wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades' );
195
+add_action('wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades');
196 196
 
197 197
 /**
198 198
  * Check if the upgrade routine has been run for a specific action
@@ -203,15 +203,15 @@  discard block
 block discarded – undo
203 203
  *
204 204
  * @return bool                   If the action has been added to the completed actions array
205 205
  */
206
-function give_has_upgrade_completed( $upgrade_action = '' ) {
206
+function give_has_upgrade_completed($upgrade_action = '') {
207 207
 
208
-	if ( empty( $upgrade_action ) ) {
208
+	if (empty($upgrade_action)) {
209 209
 		return false;
210 210
 	}
211 211
 
212 212
 	$completed_upgrades = give_get_completed_upgrades();
213 213
 
214
-	return in_array( $upgrade_action, $completed_upgrades );
214
+	return in_array($upgrade_action, $completed_upgrades);
215 215
 
216 216
 }
217 217
 
@@ -223,8 +223,8 @@  discard block
 block discarded – undo
223 223
  * @return mixed   When nothing to resume returns false, otherwise starts the upgrade where it left off
224 224
  */
225 225
 function give_maybe_resume_upgrade() {
226
-	$doing_upgrade = get_option( 'give_doing_upgrade', false );
227
-	if ( empty( $doing_upgrade ) ) {
226
+	$doing_upgrade = get_option('give_doing_upgrade', false);
227
+	if (empty($doing_upgrade)) {
228 228
 		return false;
229 229
 	}
230 230
 
@@ -240,9 +240,9 @@  discard block
 block discarded – undo
240 240
  *
241 241
  * @return bool                   If the function was successfully added
242 242
  */
243
-function give_set_upgrade_complete( $upgrade_action = '' ) {
243
+function give_set_upgrade_complete($upgrade_action = '') {
244 244
 
245
-	if ( empty( $upgrade_action ) ) {
245
+	if (empty($upgrade_action)) {
246 246
 		return false;
247 247
 	}
248 248
 
@@ -250,9 +250,9 @@  discard block
 block discarded – undo
250 250
 	$completed_upgrades[] = $upgrade_action;
251 251
 
252 252
 	// Remove any blanks, and only show uniques.
253
-	$completed_upgrades = array_unique( array_values( $completed_upgrades ) );
253
+	$completed_upgrades = array_unique(array_values($completed_upgrades));
254 254
 
255
-	return update_option( 'give_completed_upgrades', $completed_upgrades );
255
+	return update_option('give_completed_upgrades', $completed_upgrades);
256 256
 }
257 257
 
258 258
 /**
@@ -263,9 +263,9 @@  discard block
 block discarded – undo
263 263
  */
264 264
 function give_get_completed_upgrades() {
265 265
 
266
-	$completed_upgrades = get_option( 'give_completed_upgrades' );
266
+	$completed_upgrades = get_option('give_completed_upgrades');
267 267
 
268
-	if ( false === $completed_upgrades ) {
268
+	if (false === $completed_upgrades) {
269 269
 		$completed_upgrades = array();
270 270
 	}
271 271
 
@@ -282,31 +282,31 @@  discard block
 block discarded – undo
282 282
  */
283 283
 function give_v132_upgrade_give_payment_customer_id() {
284 284
 	global $wpdb;
285
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
286
-		wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array(
285
+	if ( ! current_user_can('manage_give_settings')) {
286
+		wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array(
287 287
 			'response' => 403,
288
-		) );
288
+		));
289 289
 	}
290 290
 
291
-	ignore_user_abort( true );
291
+	ignore_user_abort(true);
292 292
 
293
-	if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
294
-		@set_time_limit( 0 );
293
+	if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
294
+		@set_time_limit(0);
295 295
 	}
296 296
 
297 297
 	// UPDATE DB METAKEYS.
298 298
 	$sql   = "UPDATE $wpdb->postmeta SET meta_key = '_give_payment_customer_id' WHERE meta_key = '_give_payment_donor_id'";
299
-	$query = $wpdb->query( $sql );
299
+	$query = $wpdb->query($sql);
300 300
 
301
-	update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) );
302
-	give_set_upgrade_complete( 'upgrade_give_payment_customer_id' );
303
-	delete_option( 'give_doing_upgrade' );
304
-	wp_redirect( admin_url() );
301
+	update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION));
302
+	give_set_upgrade_complete('upgrade_give_payment_customer_id');
303
+	delete_option('give_doing_upgrade');
304
+	wp_redirect(admin_url());
305 305
 	exit;
306 306
 
307 307
 }
308 308
 
309
-add_action( 'give_upgrade_give_payment_customer_id', 'give_v132_upgrade_give_payment_customer_id' );
309
+add_action('give_upgrade_give_payment_customer_id', 'give_v132_upgrade_give_payment_customer_id');
310 310
 
311 311
 /**
312 312
  * Upgrades the Offline Status
@@ -319,16 +319,16 @@  discard block
 block discarded – undo
319 319
 
320 320
 	global $wpdb;
321 321
 
322
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
323
-		wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array(
322
+	if ( ! current_user_can('manage_give_settings')) {
323
+		wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array(
324 324
 			'response' => 403,
325
-		) );
325
+		));
326 326
 	}
327 327
 
328
-	ignore_user_abort( true );
328
+	ignore_user_abort(true);
329 329
 
330
-	if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
331
-		@set_time_limit( 0 );
330
+	if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
331
+		@set_time_limit(0);
332 332
 	}
333 333
 
334 334
 	// Get abandoned offline payments.
@@ -338,31 +338,31 @@  discard block
 block discarded – undo
338 338
 	$where .= "AND ( p.post_status = 'abandoned' )";
339 339
 	$where .= "AND ( m.meta_key = '_give_payment_gateway' AND m.meta_value = 'offline' )";
340 340
 
341
-	$sql            = $select . $join . $where;
342
-	$found_payments = $wpdb->get_col( $sql );
341
+	$sql            = $select.$join.$where;
342
+	$found_payments = $wpdb->get_col($sql);
343 343
 
344
-	foreach ( $found_payments as $payment ) {
344
+	foreach ($found_payments as $payment) {
345 345
 
346 346
 		// Only change ones marked abandoned since our release last week because the admin may have marked some abandoned themselves.
347
-		$modified_time = get_post_modified_time( 'U', false, $payment );
347
+		$modified_time = get_post_modified_time('U', false, $payment);
348 348
 
349 349
 		// 1450124863 =  12/10/2015 20:42:25.
350
-		if ( $modified_time >= 1450124863 ) {
350
+		if ($modified_time >= 1450124863) {
351 351
 
352
-			give_update_payment_status( $payment, 'pending' );
352
+			give_update_payment_status($payment, 'pending');
353 353
 
354 354
 		}
355 355
 	}
356 356
 
357
-	update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) );
358
-	give_set_upgrade_complete( 'upgrade_give_offline_status' );
359
-	delete_option( 'give_doing_upgrade' );
360
-	wp_redirect( admin_url() );
357
+	update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION));
358
+	give_set_upgrade_complete('upgrade_give_offline_status');
359
+	delete_option('give_doing_upgrade');
360
+	wp_redirect(admin_url());
361 361
 	exit;
362 362
 
363 363
 }
364 364
 
365
-add_action( 'give_upgrade_give_offline_status', 'give_v134_upgrade_give_offline_status' );
365
+add_action('give_upgrade_give_offline_status', 'give_v134_upgrade_give_offline_status');
366 366
 
367 367
 /**
368 368
  * Cleanup User Roles
@@ -373,17 +373,17 @@  discard block
 block discarded – undo
373 373
  */
374 374
 function give_v152_cleanup_users() {
375 375
 
376
-	$give_version = get_option( 'give_version' );
376
+	$give_version = get_option('give_version');
377 377
 
378
-	if ( ! $give_version ) {
378
+	if ( ! $give_version) {
379 379
 		// 1.0 is the first version to use this option so we must add it.
380 380
 		$give_version = '1.0';
381 381
 	}
382 382
 
383
-	$give_version = preg_replace( '/[^0-9.].*/', '', $give_version );
383
+	$give_version = preg_replace('/[^0-9.].*/', '', $give_version);
384 384
 
385 385
 	// v1.5.2 Upgrades
386
-	if ( version_compare( $give_version, '1.5.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_user_caps_cleanup' ) ) {
386
+	if (version_compare($give_version, '1.5.2', '<') || ! give_has_upgrade_completed('upgrade_give_user_caps_cleanup')) {
387 387
 
388 388
 		// Delete all caps with "ss".
389 389
 		// Also delete all unused "campaign" roles.
@@ -430,9 +430,9 @@  discard block
 block discarded – undo
430 430
 		);
431 431
 
432 432
 		global $wp_roles;
433
-		foreach ( $delete_caps as $cap ) {
434
-			foreach ( array_keys( $wp_roles->roles ) as $role ) {
435
-				$wp_roles->remove_cap( $role, $cap );
433
+		foreach ($delete_caps as $cap) {
434
+			foreach (array_keys($wp_roles->roles) as $role) {
435
+				$wp_roles->remove_cap($role, $cap);
436 436
 			}
437 437
 		}
438 438
 
@@ -442,15 +442,15 @@  discard block
 block discarded – undo
442 442
 		$roles->add_caps();
443 443
 
444 444
 		// The Update Ran.
445
-		update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) );
446
-		give_set_upgrade_complete( 'upgrade_give_user_caps_cleanup' );
447
-		delete_option( 'give_doing_upgrade' );
445
+		update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION));
446
+		give_set_upgrade_complete('upgrade_give_user_caps_cleanup');
447
+		delete_option('give_doing_upgrade');
448 448
 
449 449
 	}// End if().
450 450
 
451 451
 }
452 452
 
453
-add_action( 'admin_init', 'give_v152_cleanup_users' );
453
+add_action('admin_init', 'give_v152_cleanup_users');
454 454
 
455 455
 /**
456 456
  * 1.6 Upgrade routine to create the customer meta table.
@@ -490,53 +490,53 @@  discard block
 block discarded – undo
490 490
 
491 491
 	// Get addons license key.
492 492
 	$addons = array();
493
-	foreach ( $give_options as $key => $value ) {
494
-		if ( false !== strpos( $key, '_license_key' ) ) {
495
-			$addons[ $key ] = $value;
493
+	foreach ($give_options as $key => $value) {
494
+		if (false !== strpos($key, '_license_key')) {
495
+			$addons[$key] = $value;
496 496
 		}
497 497
 	}
498 498
 
499 499
 	// Bailout: We do not have any addon license data to upgrade.
500
-	if ( empty( $addons ) ) {
500
+	if (empty($addons)) {
501 501
 		return false;
502 502
 	}
503 503
 
504
-	foreach ( $addons as $key => $addon_license ) {
504
+	foreach ($addons as $key => $addon_license) {
505 505
 
506 506
 		// Get addon shortname.
507
-		$shortname = str_replace( '_license_key', '', $key );
507
+		$shortname = str_replace('_license_key', '', $key);
508 508
 
509 509
 		// Addon license option name.
510
-		$addon_license_option_name = $shortname . '_license_active';
510
+		$addon_license_option_name = $shortname.'_license_active';
511 511
 
512 512
 		// bailout if license is empty.
513
-		if ( empty( $addon_license ) ) {
514
-			delete_option( $addon_license_option_name );
513
+		if (empty($addon_license)) {
514
+			delete_option($addon_license_option_name);
515 515
 			continue;
516 516
 		}
517 517
 
518 518
 		// Get addon name.
519 519
 		$addon_name       = array();
520
-		$addon_name_parts = explode( '_', str_replace( 'give_', '', $shortname ) );
521
-		foreach ( $addon_name_parts as $name_part ) {
520
+		$addon_name_parts = explode('_', str_replace('give_', '', $shortname));
521
+		foreach ($addon_name_parts as $name_part) {
522 522
 
523 523
 			// Fix addon name
524
-			switch ( $name_part ) {
524
+			switch ($name_part) {
525 525
 				case 'authorizenet' :
526 526
 					$name_part = 'authorize.net';
527 527
 					break;
528 528
 			}
529 529
 
530
-			$addon_name[] = ucfirst( $name_part );
530
+			$addon_name[] = ucfirst($name_part);
531 531
 		}
532 532
 
533
-		$addon_name = implode( ' ', $addon_name );
533
+		$addon_name = implode(' ', $addon_name);
534 534
 
535 535
 		// Data to send to the API
536 536
 		$api_params = array(
537 537
 			'edd_action' => 'activate_license', // never change from "edd_" to "give_"!
538 538
 			'license'    => $addon_license,
539
-			'item_name'  => urlencode( $addon_name ),
539
+			'item_name'  => urlencode($addon_name),
540 540
 			'url'        => home_url(),
541 541
 		);
542 542
 
@@ -551,17 +551,17 @@  discard block
 block discarded – undo
551 551
 		);
552 552
 
553 553
 		// Make sure there are no errors.
554
-		if ( is_wp_error( $response ) ) {
555
-			delete_option( $addon_license_option_name );
554
+		if (is_wp_error($response)) {
555
+			delete_option($addon_license_option_name);
556 556
 			continue;
557 557
 		}
558 558
 
559 559
 		// Tell WordPress to look for updates.
560
-		set_site_transient( 'update_plugins', null );
560
+		set_site_transient('update_plugins', null);
561 561
 
562 562
 		// Decode license data.
563
-		$license_data = json_decode( wp_remote_retrieve_body( $response ) );
564
-		update_option( $addon_license_option_name, $license_data );
563
+		$license_data = json_decode(wp_remote_retrieve_body($response));
564
+		update_option($addon_license_option_name, $license_data);
565 565
 	}// End foreach().
566 566
 }
567 567
 
@@ -591,9 +591,9 @@  discard block
 block discarded – undo
591 591
 	);
592 592
 
593 593
 	global $wp_roles;
594
-	foreach ( $delete_caps as $cap ) {
595
-		foreach ( array_keys( $wp_roles->roles ) as $role ) {
596
-			$wp_roles->remove_cap( $role, $cap );
594
+	foreach ($delete_caps as $cap) {
595
+		foreach (array_keys($wp_roles->roles) as $role) {
596
+			$wp_roles->remove_cap($role, $cap);
597 597
 		}
598 598
 	}
599 599
 
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
 function give_v18_upgrades_core_setting() {
628 628
 	// Core settings which changes from checkbox to radio.
629 629
 	$core_setting_names = array_merge(
630
-		array_keys( give_v18_renamed_core_settings() ),
630
+		array_keys(give_v18_renamed_core_settings()),
631 631
 		array(
632 632
 			'uninstall_on_delete',
633 633
 			'scripts_footer',
@@ -639,48 +639,48 @@  discard block
 block discarded – undo
639 639
 	);
640 640
 
641 641
 	// Bailout: If not any setting define.
642
-	if ( $give_settings = get_option( 'give_settings' ) ) {
642
+	if ($give_settings = get_option('give_settings')) {
643 643
 
644 644
 		$setting_changed = false;
645 645
 
646 646
 		// Loop: check each setting field.
647
-		foreach ( $core_setting_names as $setting_name ) {
647
+		foreach ($core_setting_names as $setting_name) {
648 648
 			// New setting name.
649
-			$new_setting_name = preg_replace( '/^(enable_|disable_)/', '', $setting_name );
649
+			$new_setting_name = preg_replace('/^(enable_|disable_)/', '', $setting_name);
650 650
 
651 651
 			// Continue: If setting already set.
652 652
 			if (
653
-				array_key_exists( $new_setting_name, $give_settings )
654
-				&& in_array( $give_settings[ $new_setting_name ], array( 'enabled', 'disabled' ) )
653
+				array_key_exists($new_setting_name, $give_settings)
654
+				&& in_array($give_settings[$new_setting_name], array('enabled', 'disabled'))
655 655
 			) {
656 656
 				continue;
657 657
 			}
658 658
 
659 659
 			// Set checkbox value to radio value.
660
-			$give_settings[ $setting_name ] = ( ! empty( $give_settings[ $setting_name ] ) && 'on' === $give_settings[ $setting_name ] ? 'enabled' : 'disabled' );
660
+			$give_settings[$setting_name] = ( ! empty($give_settings[$setting_name]) && 'on' === $give_settings[$setting_name] ? 'enabled' : 'disabled');
661 661
 
662 662
 			// @see https://github.com/WordImpress/Give/issues/1063
663
-			if ( false !== strpos( $setting_name, 'disable_' ) ) {
663
+			if (false !== strpos($setting_name, 'disable_')) {
664 664
 
665
-				$give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'disabled' : 'enabled' );
666
-			} elseif ( false !== strpos( $setting_name, 'enable_' ) ) {
665
+				$give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'disabled' : 'enabled');
666
+			} elseif (false !== strpos($setting_name, 'enable_')) {
667 667
 
668
-				$give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'enabled' : 'disabled' );
668
+				$give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'enabled' : 'disabled');
669 669
 			}
670 670
 
671 671
 			// Tell bot to update core setting to db.
672
-			if ( ! $setting_changed ) {
672
+			if ( ! $setting_changed) {
673 673
 				$setting_changed = true;
674 674
 			}
675 675
 		}
676 676
 
677 677
 		// Update setting only if they changed.
678
-		if ( $setting_changed ) {
679
-			update_option( 'give_settings', $give_settings );
678
+		if ($setting_changed) {
679
+			update_option('give_settings', $give_settings);
680 680
 		}
681 681
 	}// End if().
682 682
 
683
-	give_set_upgrade_complete( 'v18_upgrades_core_setting' );
683
+	give_set_upgrade_complete('v18_upgrades_core_setting');
684 684
 }
685 685
 
686 686
 /**
@@ -690,22 +690,22 @@  discard block
 block discarded – undo
690 690
  * @return void
691 691
  */
692 692
 function give_v18_upgrades_form_metadata() {
693
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
694
-		wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array(
693
+	if ( ! current_user_can('manage_give_settings')) {
694
+		wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array(
695 695
 			'response' => 403,
696
-		) );
696
+		));
697 697
 	}
698 698
 
699
-	ignore_user_abort( true );
699
+	ignore_user_abort(true);
700 700
 
701
-	if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
702
-		@set_time_limit( 0 );
701
+	if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
702
+		@set_time_limit(0);
703 703
 	}
704 704
 
705
-	$step = isset( $_GET['step'] ) ? absint( $_GET['step'] ) : 1;
705
+	$step = isset($_GET['step']) ? absint($_GET['step']) : 1;
706 706
 
707 707
 	// form query
708
-	$forms = new WP_Query( array(
708
+	$forms = new WP_Query(array(
709 709
 			'paged'          => $step,
710 710
 			'status'         => 'any',
711 711
 			'order'          => 'ASC',
@@ -714,39 +714,39 @@  discard block
 block discarded – undo
714 714
 		)
715 715
 	);
716 716
 
717
-	if ( $forms->have_posts() ) {
718
-		while ( $forms->have_posts() ) {
717
+	if ($forms->have_posts()) {
718
+		while ($forms->have_posts()) {
719 719
 			$forms->the_post();
720 720
 
721 721
 			// Form content.
722 722
 			// Note in version 1.8 display content setting split into display content and content placement setting.
723 723
 			// You can delete _give_content_option in future
724
-			$show_content = give_get_meta( get_the_ID(), '_give_content_option', true );
725
-			if ( $show_content && ! give_get_meta( get_the_ID(), '_give_display_content', true ) ) {
726
-				$field_value = ( 'none' !== $show_content ? 'enabled' : 'disabled' );
727
-				give_update_meta( get_the_ID(), '_give_display_content', $field_value );
724
+			$show_content = give_get_meta(get_the_ID(), '_give_content_option', true);
725
+			if ($show_content && ! give_get_meta(get_the_ID(), '_give_display_content', true)) {
726
+				$field_value = ('none' !== $show_content ? 'enabled' : 'disabled');
727
+				give_update_meta(get_the_ID(), '_give_display_content', $field_value);
728 728
 
729
-				$field_value = ( 'none' !== $show_content ? $show_content : 'give_pre_form' );
730
-				give_update_meta( get_the_ID(), '_give_content_placement', $field_value );
729
+				$field_value = ('none' !== $show_content ? $show_content : 'give_pre_form');
730
+				give_update_meta(get_the_ID(), '_give_content_placement', $field_value);
731 731
 			}
732 732
 
733 733
 			// "Disable" Guest Donation. Checkbox
734 734
 			// See: https://github.com/WordImpress/Give/issues/1470
735
-			$guest_donation = give_get_meta( get_the_ID(), '_give_logged_in_only', true );
736
-			$guest_donation_newval = ( in_array( $guest_donation, array( 'yes', 'on' ) ) ? 'disabled' : 'enabled' );
737
-			give_update_meta( get_the_ID(), '_give_logged_in_only', $guest_donation_newval );
735
+			$guest_donation = give_get_meta(get_the_ID(), '_give_logged_in_only', true);
736
+			$guest_donation_newval = (in_array($guest_donation, array('yes', 'on')) ? 'disabled' : 'enabled');
737
+			give_update_meta(get_the_ID(), '_give_logged_in_only', $guest_donation_newval);
738 738
 
739 739
 			// Offline Donations
740 740
 			// See: https://github.com/WordImpress/Give/issues/1579
741
-			$offline_donation = give_get_meta( get_the_ID(), '_give_customize_offline_donations', true );
742
-			if ( 'no' === $offline_donation ) {
741
+			$offline_donation = give_get_meta(get_the_ID(), '_give_customize_offline_donations', true);
742
+			if ('no' === $offline_donation) {
743 743
 				$offline_donation_newval = 'global';
744
-			} elseif ( 'yes' === $offline_donation ) {
744
+			} elseif ('yes' === $offline_donation) {
745 745
 				$offline_donation_newval = 'enabled';
746 746
 			} else {
747 747
 				$offline_donation_newval = 'disabled';
748 748
 			}
749
-			give_update_meta( get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval );
749
+			give_update_meta(get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval);
750 750
 
751 751
 			// Convert yes/no setting field to enabled/disabled.
752 752
 			$form_radio_settings = array(
@@ -766,15 +766,15 @@  discard block
 block discarded – undo
766 766
 				'_give_offline_donation_enable_billing_fields_single',
767 767
 			);
768 768
 
769
-			foreach ( $form_radio_settings as $meta_key ) {
769
+			foreach ($form_radio_settings as $meta_key) {
770 770
 				// Get value.
771
-				$field_value = give_get_meta( get_the_ID(), $meta_key, true );
771
+				$field_value = give_get_meta(get_the_ID(), $meta_key, true);
772 772
 
773 773
 				// Convert meta value only if it is in yes/no/none.
774
-				if ( in_array( $field_value, array( 'yes', 'on', 'no', 'none' ) ) ) {
774
+				if (in_array($field_value, array('yes', 'on', 'no', 'none'))) {
775 775
 
776
-					$field_value = ( in_array( $field_value, array( 'yes', 'on' ) ) ? 'enabled' : 'disabled' );
777
-					give_update_meta( get_the_ID(), $meta_key, $field_value );
776
+					$field_value = (in_array($field_value, array('yes', 'on')) ? 'enabled' : 'disabled');
777
+					give_update_meta(get_the_ID(), $meta_key, $field_value);
778 778
 				}
779 779
 			}
780 780
 		}// End while().
@@ -782,27 +782,27 @@  discard block
 block discarded – undo
782 782
 		wp_reset_postdata();
783 783
 
784 784
 		// Forms found so upgrade them
785
-		$step ++;
786
-		$redirect = add_query_arg( array(
785
+		$step++;
786
+		$redirect = add_query_arg(array(
787 787
 			'page'         => 'give-upgrades',
788 788
 			'give-upgrade' => 'give_v18_upgrades_form_metadata',
789 789
 			'step'         => $step,
790
-		), admin_url( 'index.php' ) );
791
-		wp_redirect( $redirect );
790
+		), admin_url('index.php'));
791
+		wp_redirect($redirect);
792 792
 		exit();
793 793
 
794 794
 	} else {
795 795
 		// No more forms found, finish up.
796
-		update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) );
797
-		delete_option( 'give_doing_upgrade' );
798
-		give_set_upgrade_complete( 'v18_upgrades_form_metadata' );
796
+		update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION));
797
+		delete_option('give_doing_upgrade');
798
+		give_set_upgrade_complete('v18_upgrades_form_metadata');
799 799
 
800
-		wp_redirect( admin_url() );
800
+		wp_redirect(admin_url());
801 801
 		exit;
802 802
 	}
803 803
 }
804 804
 
805
-add_action( 'give_give_v18_upgrades_form_metadata', 'give_v18_upgrades_form_metadata' );
805
+add_action('give_give_v18_upgrades_form_metadata', 'give_v18_upgrades_form_metadata');
806 806
 
807 807
 /**
808 808
  * Get list of core setting renamed in version 1.8.
@@ -835,7 +835,7 @@  discard block
 block discarded – undo
835 835
  * @since  1.8.7
836 836
  * @return void
837 837
  */
838
-function give_v187_upgrades(){
838
+function give_v187_upgrades() {
839 839
 	global $wpdb;
840 840
 
841 841
 	/**
@@ -875,24 +875,24 @@  discard block
 block discarded – undo
875 875
 		ARRAY_A
876 876
 	);
877 877
 
878
-	if( ! empty( $user_apikey_options ) ) {
879
-		foreach ( $user_apikey_options as $user ) {
880
-			$cached_options[] = '_transient_' . md5( 'give_api_user_' . $user['meta_key'] );
881
-			$cached_options[] = '_transient_' . md5( 'give_api_user_public_key' . $user['user_id'] );
882
-			$cached_options[] = '_transient_' . md5( 'give_api_user_secret_key' . $user['user_id'] );
878
+	if ( ! empty($user_apikey_options)) {
879
+		foreach ($user_apikey_options as $user) {
880
+			$cached_options[] = '_transient_'.md5('give_api_user_'.$user['meta_key']);
881
+			$cached_options[] = '_transient_'.md5('give_api_user_public_key'.$user['user_id']);
882
+			$cached_options[] = '_transient_'.md5('give_api_user_secret_key'.$user['user_id']);
883 883
 		}
884 884
 	}
885 885
 
886
-	if ( ! empty( $cached_options ) ) {
887
-		foreach ( $cached_options as $option ) {
888
-			switch ( true ) {
889
-				case ( false !== strpos( $option, 'transient' ) ):
890
-					$option = str_replace( '_transient_', '', $option );
891
-					delete_transient( $option );
886
+	if ( ! empty($cached_options)) {
887
+		foreach ($cached_options as $option) {
888
+			switch (true) {
889
+				case (false !== strpos($option, 'transient')):
890
+					$option = str_replace('_transient_', '', $option);
891
+					delete_transient($option);
892 892
 					break;
893 893
 
894 894
 				default:
895
-					delete_option( $option );
895
+					delete_option($option);
896 896
 			}
897 897
 		}
898 898
 	}
@@ -910,7 +910,7 @@  discard block
 block discarded – undo
910 910
 	global $wp_roles;
911 911
 
912 912
     // Get the role object.
913
-    $give_worker = get_role( 'give_worker' );
913
+    $give_worker = get_role('give_worker');
914 914
 
915 915
 	// A list of capabilities to add for give workers.
916 916
     $caps_to_add = array(
@@ -918,9 +918,9 @@  discard block
 block discarded – undo
918 918
         'edit_pages'
919 919
     );
920 920
 
921
-    foreach ( $caps_to_add as $cap ) {
921
+    foreach ($caps_to_add as $cap) {
922 922
         // Add the capability.
923
-        $give_worker->add_cap( $cap );
923
+        $give_worker->add_cap($cap);
924 924
     }
925 925
 
926 926
 }
Please login to merge, or discard this patch.