Completed
Pull Request — master (#1248)
by Devin
17:40
created
includes/class-give-logging.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@
 block discarded – undo
37 37
 	 *
38 38
 	 * Display admin bar when active
39 39
 	 *
40
-	 * @return bool
40
+	 * @return false|null
41 41
 	 */
42 42
 	public function give_admin_bar_menu() {
43 43
 		global $wp_admin_bar;
Please login to merge, or discard this patch.
Spacing   +68 added lines, -68 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
 	/**
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	public function register_post_type() {
68 68
 		/* Logs post type */
69 69
 		$log_args = array(
70
-			'labels'              => array( 'name' => esc_html__( 'Logs', 'give' ) ),
70
+			'labels'              => array('name' => esc_html__('Logs', 'give')),
71 71
 			'public'              => false,
72 72
 			'exclude_from_search' => true,
73 73
 			'publicly_queryable'  => false,
@@ -75,11 +75,11 @@  discard block
 block discarded – undo
75 75
 			'query_var'           => false,
76 76
 			'rewrite'             => false,
77 77
 			'capability_type'     => 'post',
78
-			'supports'            => array( 'title', 'editor' ),
78
+			'supports'            => array('title', 'editor'),
79 79
 			'can_export'          => true,
80 80
 		);
81 81
 
82
-		register_post_type( 'give_log', $log_args );
82
+		register_post_type('give_log', $log_args);
83 83
 	}
84 84
 
85 85
 	/**
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 * @return void
94 94
 	 */
95 95
 	public function register_taxonomy() {
96
-		register_taxonomy( 'give_log_type', 'give_log', array( 'public' => false ) );
96
+		register_taxonomy('give_log_type', 'give_log', array('public' => false));
97 97
 	}
98 98
 
99 99
 	/**
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 			'api_request',
114 114
 		);
115 115
 
116
-		return apply_filters( 'give_log_types', $terms );
116
+		return apply_filters('give_log_types', $terms);
117 117
 	}
118 118
 
119 119
 	/**
@@ -128,8 +128,8 @@  discard block
 block discarded – undo
128 128
 	 *
129 129
 	 * @return bool         Whether log type is valid.
130 130
 	 */
131
-	public function valid_type( $type ) {
132
-		return in_array( $type, $this->log_types() );
131
+	public function valid_type($type) {
132
+		return in_array($type, $this->log_types());
133 133
 	}
134 134
 
135 135
 	/**
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 	 *
149 149
 	 * @return int             Log ID.
150 150
 	 */
151
-	public function add( $title = '', $message = '', $parent = 0, $type = null ) {
151
+	public function add($title = '', $message = '', $parent = 0, $type = null) {
152 152
 		$log_data = array(
153 153
 			'post_title'   => $title,
154 154
 			'post_content' => $message,
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 			'log_type'     => $type,
157 157
 		);
158 158
 
159
-		return $this->insert_log( $log_data );
159
+		return $this->insert_log($log_data);
160 160
 	}
161 161
 
162 162
 	/**
@@ -173,12 +173,12 @@  discard block
 block discarded – undo
173 173
 	 *
174 174
 	 * @return array             An array of the connected logs.
175 175
 	 */
176
-	public function get_logs( $object_id = 0, $type = null, $paged = null ) {
177
-		return $this->get_connected_logs( array(
176
+	public function get_logs($object_id = 0, $type = null, $paged = null) {
177
+		return $this->get_connected_logs(array(
178 178
 			'post_parent' => $object_id,
179 179
 			'paged'       => $paged,
180 180
 			'log_type'    => $type,
181
-		) );
181
+		));
182 182
 	}
183 183
 
184 184
 	/**
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	 *
193 193
 	 * @return int             The ID of the newly created log item.
194 194
 	 */
195
-	public function insert_log( $log_data = array(), $log_meta = array() ) {
195
+	public function insert_log($log_data = array(), $log_meta = array()) {
196 196
 		$defaults = array(
197 197
 			'post_type'    => 'give_log',
198 198
 			'post_status'  => 'publish',
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 			'log_type'     => false,
202 202
 		);
203 203
 
204
-		$args = wp_parse_args( $log_data, $defaults );
204
+		$args = wp_parse_args($log_data, $defaults);
205 205
 
206 206
 		/**
207 207
 		 * Fires before inserting log entry.
@@ -211,20 +211,20 @@  discard block
 block discarded – undo
211 211
 		 * @param array $log_data Log entry data.
212 212
 		 * @param array $log_meta Log entry meta.
213 213
 		 */
214
-		do_action( 'give_pre_insert_log', $log_data, $log_meta );
214
+		do_action('give_pre_insert_log', $log_data, $log_meta);
215 215
 
216 216
 		// Store the log entry
217
-		$log_id = wp_insert_post( $args );
217
+		$log_id = wp_insert_post($args);
218 218
 
219 219
 		// Set the log type, if any
220
-		if ( $log_data['log_type'] && $this->valid_type( $log_data['log_type'] ) ) {
221
-			wp_set_object_terms( $log_id, $log_data['log_type'], 'give_log_type', false );
220
+		if ($log_data['log_type'] && $this->valid_type($log_data['log_type'])) {
221
+			wp_set_object_terms($log_id, $log_data['log_type'], 'give_log_type', false);
222 222
 		}
223 223
 
224 224
 		// Set log meta, if any
225
-		if ( $log_id && ! empty( $log_meta ) ) {
226
-			foreach ( (array) $log_meta as $key => $meta ) {
227
-				update_post_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta );
225
+		if ($log_id && ! empty($log_meta)) {
226
+			foreach ((array) $log_meta as $key => $meta) {
227
+				update_post_meta($log_id, '_give_log_'.sanitize_key($key), $meta);
228 228
 			}
229 229
 		}
230 230
 
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 		 * @param array $log_data Log entry data.
238 238
 		 * @param array $log_meta Log entry meta.
239 239
 		 */
240
-		do_action( 'give_post_insert_log', $log_id, $log_data, $log_meta );
240
+		do_action('give_post_insert_log', $log_id, $log_data, $log_meta);
241 241
 
242 242
 		return $log_id;
243 243
 	}
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 	 *
254 254
 	 * @return bool|null       True if successful, false otherwise.
255 255
 	 */
256
-	public function update_log( $log_data = array(), $log_meta = array() ) {
256
+	public function update_log($log_data = array(), $log_meta = array()) {
257 257
 
258 258
 		/**
259 259
 		 * Fires before updating log entry.
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 		 * @param array $log_data Log entry data.
264 264
 		 * @param array $log_meta Log entry meta.
265 265
 		 */
266
-		do_action( 'give_pre_update_log', $log_data, $log_meta );
266
+		do_action('give_pre_update_log', $log_data, $log_meta);
267 267
 
268 268
 		$defaults = array(
269 269
 			'post_type'   => 'give_log',
@@ -271,15 +271,15 @@  discard block
 block discarded – undo
271 271
 			'post_parent' => 0,
272 272
 		);
273 273
 
274
-		$args = wp_parse_args( $log_data, $defaults );
274
+		$args = wp_parse_args($log_data, $defaults);
275 275
 
276 276
 		// Store the log entry
277
-		$log_id = wp_update_post( $args );
277
+		$log_id = wp_update_post($args);
278 278
 
279
-		if ( $log_id && ! empty( $log_meta ) ) {
280
-			foreach ( (array) $log_meta as $key => $meta ) {
281
-				if ( ! empty( $meta ) ) {
282
-					update_post_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta );
279
+		if ($log_id && ! empty($log_meta)) {
280
+			foreach ((array) $log_meta as $key => $meta) {
281
+				if ( ! empty($meta)) {
282
+					update_post_meta($log_id, '_give_log_'.sanitize_key($key), $meta);
283 283
 				}
284 284
 			}
285 285
 		}
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 		 * @param array $log_data Log entry data.
294 294
 		 * @param array $log_meta Log entry meta.
295 295
 		 */
296
-		do_action( 'give_post_update_log', $log_id, $log_data, $log_meta );
296
+		do_action('give_post_update_log', $log_id, $log_data, $log_meta);
297 297
 	}
298 298
 
299 299
 	/**
@@ -308,19 +308,19 @@  discard block
 block discarded – undo
308 308
 	 *
309 309
 	 * @return array|false Array if logs were found, false otherwise.
310 310
 	 */
311
-	public function get_connected_logs( $args = array() ) {
311
+	public function get_connected_logs($args = array()) {
312 312
 
313 313
 		$defaults = array(
314 314
 			'post_type'      => 'give_log',
315 315
 			'posts_per_page' => 20,
316 316
 			'post_status'    => 'publish',
317
-			'paged'          => get_query_var( 'paged' ),
317
+			'paged'          => get_query_var('paged'),
318 318
 			'log_type'       => false,
319 319
 		);
320 320
 
321
-		$query_args = wp_parse_args( $args, $defaults );
321
+		$query_args = wp_parse_args($args, $defaults);
322 322
 
323
-		if ( $query_args['log_type'] && $this->valid_type( $query_args['log_type'] ) ) {
323
+		if ($query_args['log_type'] && $this->valid_type($query_args['log_type'])) {
324 324
 			$query_args['tax_query'] = array(
325 325
 				array(
326 326
 					'taxonomy' => 'give_log_type',
@@ -330,9 +330,9 @@  discard block
 block discarded – undo
330 330
 			);
331 331
 		}
332 332
 
333
-		$logs = get_posts( $query_args );
333
+		$logs = get_posts($query_args);
334 334
 
335
-		if ( $logs ) {
335
+		if ($logs) {
336 336
 			return $logs;
337 337
 		}
338 338
 
@@ -355,17 +355,17 @@  discard block
 block discarded – undo
355 355
 	 *
356 356
 	 * @return int                Log count.
357 357
 	 */
358
-	public function get_log_count( $object_id = 0, $type = null, $meta_query = null, $date_query = null ) {
358
+	public function get_log_count($object_id = 0, $type = null, $meta_query = null, $date_query = null) {
359 359
 
360 360
 		$query_args = array(
361 361
 			'post_parent'    => $object_id,
362 362
 			'post_type'      => 'give_log',
363
-			'posts_per_page' => - 1,
363
+			'posts_per_page' => -1,
364 364
 			'post_status'    => 'publish',
365 365
 			'fields'         => 'ids',
366 366
 		);
367 367
 
368
-		if ( ! empty( $type ) && $this->valid_type( $type ) ) {
368
+		if ( ! empty($type) && $this->valid_type($type)) {
369 369
 			$query_args['tax_query'] = array(
370 370
 				array(
371 371
 					'taxonomy' => 'give_log_type',
@@ -375,25 +375,25 @@  discard block
 block discarded – undo
375 375
 			);
376 376
 		}
377 377
 
378
-		if ( ! empty( $meta_query ) ) {
378
+		if ( ! empty($meta_query)) {
379 379
 			$query_args['meta_query'] = $meta_query;
380 380
 		}
381 381
 
382
-		if ( ! empty( $date_query ) ) {
382
+		if ( ! empty($date_query)) {
383 383
 			$query_args['date_query'] = $date_query;
384 384
 		}
385 385
 
386 386
 
387 387
 		// Get cache key for current query.
388
-		$cache_key =  give_get_cache_key( 'get_log_count', $query_args );
388
+		$cache_key = give_get_cache_key('get_log_count', $query_args);
389 389
 
390 390
 		// check if cache already exist or not.
391
-		if( ! ( $logs_count = get_option( $cache_key ) ) ) {
392
-			$logs = new WP_Query( $query_args );
391
+		if ( ! ($logs_count = get_option($cache_key))) {
392
+			$logs = new WP_Query($query_args);
393 393
 			$logs_count = (int) $logs->post_count;
394 394
 
395 395
 			// Cache results.
396
-			add_option( $cache_key, $logs_count, '', 'no' );
396
+			add_option($cache_key, $logs_count, '', 'no');
397 397
 		}
398 398
 
399 399
 		return $logs_count;
@@ -413,16 +413,16 @@  discard block
 block discarded – undo
413 413
 	 *
414 414
 	 * @return void
415 415
 	 */
416
-	public function delete_logs( $object_id = 0, $type = null, $meta_query = null ) {
416
+	public function delete_logs($object_id = 0, $type = null, $meta_query = null) {
417 417
 		$query_args = array(
418 418
 			'post_parent'    => $object_id,
419 419
 			'post_type'      => 'give_log',
420
-			'posts_per_page' => - 1,
420
+			'posts_per_page' => -1,
421 421
 			'post_status'    => 'publish',
422 422
 			'fields'         => 'ids',
423 423
 		);
424 424
 
425
-		if ( ! empty( $type ) && $this->valid_type( $type ) ) {
425
+		if ( ! empty($type) && $this->valid_type($type)) {
426 426
 			$query_args['tax_query'] = array(
427 427
 				array(
428 428
 					'taxonomy' => 'give_log_type',
@@ -432,15 +432,15 @@  discard block
 block discarded – undo
432 432
 			);
433 433
 		}
434 434
 
435
-		if ( ! empty( $meta_query ) ) {
435
+		if ( ! empty($meta_query)) {
436 436
 			$query_args['meta_query'] = $meta_query;
437 437
 		}
438 438
 
439
-		$logs = get_posts( $query_args );
439
+		$logs = get_posts($query_args);
440 440
 
441
-		if ( $logs ) {
442
-			foreach ( $logs as $log ) {
443
-				wp_delete_post( $log, true );
441
+		if ($logs) {
442
+			foreach ($logs as $log) {
443
+				wp_delete_post($log, true);
444 444
 			}
445 445
 		}
446 446
 	}
@@ -453,8 +453,8 @@  discard block
 block discarded – undo
453 453
 	 *
454 454
 	 * @param int $post_id
455 455
 	 */
456
-	public function background_process_delete_cache( $post_id ) {
457
-		wp_schedule_single_event( time(), 'give_delete_log_cache' );
456
+	public function background_process_delete_cache($post_id) {
457
+		wp_schedule_single_event(time(), 'give_delete_log_cache');
458 458
 	}
459 459
 
460 460
 	/**
@@ -476,14 +476,14 @@  discard block
 block discarded – undo
476 476
 		);
477 477
 
478 478
 		// Bailout.
479
-		if( empty( $cache_option_names ) ) {
479
+		if (empty($cache_option_names)) {
480 480
 			return false;
481 481
 		}
482 482
 
483 483
 
484 484
 		// Delete log cache.
485
-		foreach ( $cache_option_names as $option_name ) {
486
-			delete_option( $option_name['option_name'] );
485
+		foreach ($cache_option_names as $option_name) {
486
+			delete_option($option_name['option_name']);
487 487
 		}
488 488
 	}
489 489
 }
@@ -506,10 +506,10 @@  discard block
 block discarded – undo
506 506
  *
507 507
  * @return int             ID of the new log entry.
508 508
  */
509
-function give_record_log( $title = '', $message = '', $parent = 0, $type = null ) {
509
+function give_record_log($title = '', $message = '', $parent = 0, $type = null) {
510 510
 	/* @var Give_Logging $give_logs */
511 511
 	global $give_logs;
512
-	$log = $give_logs->add( $title, $message, $parent, $type );
512
+	$log = $give_logs->add($title, $message, $parent, $type);
513 513
 
514 514
 	return $log;
515 515
 }
Please login to merge, or discard this patch.
includes/emails/functions.php 1 patch
Spacing   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -26,11 +26,11 @@  discard block
 block discarded – undo
26 26
  *
27 27
  * @return void
28 28
  */
29
-function give_email_donation_receipt( $payment_id, $admin_notice = true ) {
29
+function give_email_donation_receipt($payment_id, $admin_notice = true) {
30 30
 
31
-	$payment_data = give_get_payment_meta( $payment_id );
31
+	$payment_data = give_get_payment_meta($payment_id);
32 32
 
33
-	$from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) );
33
+	$from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES));
34 34
 
35 35
 	/**
36 36
 	 * Filters the from name.
@@ -40,9 +40,9 @@  discard block
 block discarded – undo
40 40
 	 *
41 41
 	 * @since 1.0
42 42
 	 */
43
-	$from_name = apply_filters( 'give_donation_from_name', $from_name, $payment_id, $payment_data );
43
+	$from_name = apply_filters('give_donation_from_name', $from_name, $payment_id, $payment_data);
44 44
 
45
-	$from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) );
45
+	$from_email = give_get_option('from_email', get_bloginfo('admin_email'));
46 46
 
47 47
 	/**
48 48
 	 * Filters the from email.
@@ -52,19 +52,19 @@  discard block
 block discarded – undo
52 52
 	 *
53 53
 	 * @since 1.0
54 54
 	 */
55
-	$from_email = apply_filters( 'give_donation_from_address', $from_email, $payment_id, $payment_data );
55
+	$from_email = apply_filters('give_donation_from_address', $from_email, $payment_id, $payment_data);
56 56
 
57
-	$to_email = give_get_payment_user_email( $payment_id );
57
+	$to_email = give_get_payment_user_email($payment_id);
58 58
 
59
-	$subject = give_get_option( 'donation_subject', esc_html__( 'Donation Receipt', 'give' ) );
59
+	$subject = give_get_option('donation_subject', esc_html__('Donation Receipt', 'give'));
60 60
 
61 61
 	/**
62 62
 	 * Filters the donation email receipt subject.
63 63
 	 *
64 64
 	 * @since 1.0
65 65
 	 */
66
-	$subject = apply_filters( 'give_donation_subject', wp_strip_all_tags( $subject ), $payment_id );
67
-	$subject = give_do_email_tags( $subject, $payment_id );
66
+	$subject = apply_filters('give_donation_subject', wp_strip_all_tags($subject), $payment_id);
67
+	$subject = give_do_email_tags($subject, $payment_id);
68 68
 
69 69
 	/**
70 70
 	 * Filters the donation email receipt attachments. By default, there is no attachment but plugins can hook in to provide one more multiple for the donor. Examples would be a printable ticket or PDF receipt.
@@ -74,14 +74,14 @@  discard block
 block discarded – undo
74 74
 	 *
75 75
 	 * @since 1.0
76 76
 	 */
77
-	$attachments = apply_filters( 'give_receipt_attachments', array(), $payment_id, $payment_data );
78
-	$message     = give_do_email_tags( give_get_email_body_content( $payment_id, $payment_data ), $payment_id );
77
+	$attachments = apply_filters('give_receipt_attachments', array(), $payment_id, $payment_data);
78
+	$message     = give_do_email_tags(give_get_email_body_content($payment_id, $payment_data), $payment_id);
79 79
 
80 80
 	$emails = Give()->emails;
81 81
 
82
-	$emails->__set( 'from_name', $from_name );
83
-	$emails->__set( 'from_email', $from_email );
84
-	$emails->__set( 'heading', esc_html__( 'Donation Receipt', 'give' ) );
82
+	$emails->__set('from_name', $from_name);
83
+	$emails->__set('from_email', $from_email);
84
+	$emails->__set('heading', esc_html__('Donation Receipt', 'give'));
85 85
 
86 86
 	/**
87 87
 	 * Filters the donation receipt's email headers.
@@ -91,14 +91,14 @@  discard block
 block discarded – undo
91 91
 	 *
92 92
 	 * @since 1.0
93 93
 	 */
94
-	$headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data );
95
-	$emails->__set( 'headers', $headers );
94
+	$headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data);
95
+	$emails->__set('headers', $headers);
96 96
 
97 97
 	//Send the donation receipt.
98
-	$emails->send( $to_email, $subject, $message, $attachments );
98
+	$emails->send($to_email, $subject, $message, $attachments);
99 99
 
100 100
 	//If admin notifications are on, send the admin notice.
101
-	if ( $admin_notice && ! give_admin_notices_disabled( $payment_id ) ) {
101
+	if ($admin_notice && ! give_admin_notices_disabled($payment_id)) {
102 102
 		/**
103 103
 		 * Fires in the donation email receipt.
104 104
 		 *
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 		 * @param int $payment_id Payment id.
110 110
 		 * @param mixed $payment_data Payment meta data.
111 111
 		 */
112
-		do_action( 'give_admin_donation_email', $payment_id, $payment_data );
112
+		do_action('give_admin_donation_email', $payment_id, $payment_data);
113 113
 	}
114 114
 }
115 115
 
@@ -122,41 +122,41 @@  discard block
 block discarded – undo
122 122
  */
123 123
 function give_email_test_donation_receipt() {
124 124
 
125
-	$from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) );
125
+	$from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES));
126 126
 
127 127
 	/**
128 128
 	 * Filters the from name.
129 129
 	 *
130 130
 	 * @since 1.7
131 131
 	 */
132
-	$from_name = apply_filters( 'give_donation_from_name', $from_name, 0, array() );
132
+	$from_name = apply_filters('give_donation_from_name', $from_name, 0, array());
133 133
 
134
-	$from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) );
134
+	$from_email = give_get_option('from_email', get_bloginfo('admin_email'));
135 135
 
136 136
 	/**
137 137
 	 * Filters the from email.
138 138
 	 *
139 139
 	 * @since 1.7
140 140
 	 */
141
-	$from_email = apply_filters( 'give_donation_from_address', $from_email, 0, array() );
141
+	$from_email = apply_filters('give_donation_from_address', $from_email, 0, array());
142 142
 
143
-	$subject = give_get_option( 'donation_subject', esc_html__( 'Donation Receipt', 'give' ) );
144
-	$subject = apply_filters( 'give_donation_subject', wp_strip_all_tags( $subject ), 0 );
145
-	$subject = give_do_email_tags( $subject, 0 );
143
+	$subject = give_get_option('donation_subject', esc_html__('Donation Receipt', 'give'));
144
+	$subject = apply_filters('give_donation_subject', wp_strip_all_tags($subject), 0);
145
+	$subject = give_do_email_tags($subject, 0);
146 146
 
147
-	$attachments = apply_filters( 'give_receipt_attachments', array(), 0, array() );
147
+	$attachments = apply_filters('give_receipt_attachments', array(), 0, array());
148 148
 
149
-	$message = give_email_preview_template_tags( give_get_email_body_content( 0, array() ) );
149
+	$message = give_email_preview_template_tags(give_get_email_body_content(0, array()));
150 150
 
151 151
 	$emails = Give()->emails;
152
-	$emails->__set( 'from_name', $from_name );
153
-	$emails->__set( 'from_email', $from_email );
154
-	$emails->__set( 'heading', esc_html__( 'Donation Receipt', 'give' ) );
152
+	$emails->__set('from_name', $from_name);
153
+	$emails->__set('from_email', $from_email);
154
+	$emails->__set('heading', esc_html__('Donation Receipt', 'give'));
155 155
 
156
-	$headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), 0, array() );
157
-	$emails->__set( 'headers', $headers );
156
+	$headers = apply_filters('give_receipt_headers', $emails->get_headers(), 0, array());
157
+	$emails->__set('headers', $headers);
158 158
 
159
-	$emails->send( give_get_admin_notice_emails(), $subject, $message, $attachments );
159
+	$emails->send(give_get_admin_notice_emails(), $subject, $message, $attachments);
160 160
 
161 161
 }
162 162
 
@@ -170,49 +170,49 @@  discard block
 block discarded – undo
170 170
  *
171 171
  * @return void
172 172
  */
173
-function give_admin_email_notice( $payment_id = 0, $payment_data = array() ) {
173
+function give_admin_email_notice($payment_id = 0, $payment_data = array()) {
174 174
 
175
-	$payment_id = absint( $payment_id );
175
+	$payment_id = absint($payment_id);
176 176
 
177
-	if ( empty( $payment_id ) ) {
177
+	if (empty($payment_id)) {
178 178
 		return;
179 179
 	}
180 180
 
181
-	if ( ! give_get_payment_by( 'id', $payment_id ) ) {
181
+	if ( ! give_get_payment_by('id', $payment_id)) {
182 182
 		return;
183 183
 	}
184 184
 
185
-	$from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) );
185
+	$from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES));
186 186
 
187 187
 	/**
188 188
 	 * Filters the from name.
189 189
 	 *
190 190
 	 * @since 1.0
191 191
 	 */
192
-	$from_name = apply_filters( 'give_donation_from_name', $from_name, $payment_id, $payment_data );
192
+	$from_name = apply_filters('give_donation_from_name', $from_name, $payment_id, $payment_data);
193 193
 
194
-	$from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) );
194
+	$from_email = give_get_option('from_email', get_bloginfo('admin_email'));
195 195
 
196 196
 	/**
197 197
 	 * Filters the from email.
198 198
 	 *
199 199
 	 * @since 1.0
200 200
 	 */
201
-	$from_email = apply_filters( 'give_donation_from_address', $from_email, $payment_id, $payment_data );
201
+	$from_email = apply_filters('give_donation_from_address', $from_email, $payment_id, $payment_data);
202 202
 
203 203
 	/* translators: %s: payment id */
204
-	$subject = give_get_option( 'donation_notification_subject', sprintf( esc_html__( 'New Donation - Payment #%s', 'give' ), $payment_id ) );
204
+	$subject = give_get_option('donation_notification_subject', sprintf(esc_html__('New Donation - Payment #%s', 'give'), $payment_id));
205 205
 
206 206
 	/**
207 207
 	 * Filters the donation notification subject.
208 208
 	 *
209 209
 	 * @since 1.0
210 210
 	 */
211
-	$subject = apply_filters( 'give_admin_donation_notification_subject', wp_strip_all_tags( $subject ), $payment_id );
212
-	$subject = give_do_email_tags( $subject, $payment_id );
211
+	$subject = apply_filters('give_admin_donation_notification_subject', wp_strip_all_tags($subject), $payment_id);
212
+	$subject = give_do_email_tags($subject, $payment_id);
213 213
 
214
-	$headers = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n";
215
-	$headers .= "Reply-To: " . $from_email . "\r\n";
214
+	$headers = "From: ".stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8'))." <$from_email>\r\n";
215
+	$headers .= "Reply-To: ".$from_email."\r\n";
216 216
 	//$headers  .= "MIME-Version: 1.0\r\n";
217 217
 	$headers .= "Content-Type: text/html; charset=utf-8\r\n";
218 218
 
@@ -221,28 +221,28 @@  discard block
 block discarded – undo
221 221
 	 *
222 222
 	 * @since 1.0
223 223
 	 */
224
-	$headers = apply_filters( 'give_admin_donation_notification_headers', $headers, $payment_id, $payment_data );
224
+	$headers = apply_filters('give_admin_donation_notification_headers', $headers, $payment_id, $payment_data);
225 225
 
226 226
 	/**
227 227
 	 * Filters the donation notification email attachments. By default, there is no attachment but plugins can hook in to provide one more multiple.
228 228
 	 *
229 229
 	 * @since 1.0
230 230
 	 */
231
-	$attachments = apply_filters( 'give_admin_donation_notification_attachments', array(), $payment_id, $payment_data );
231
+	$attachments = apply_filters('give_admin_donation_notification_attachments', array(), $payment_id, $payment_data);
232 232
 
233
-	$message = give_get_donation_notification_body_content( $payment_id, $payment_data );
233
+	$message = give_get_donation_notification_body_content($payment_id, $payment_data);
234 234
 
235 235
 	$emails = Give()->emails;
236
-	$emails->__set( 'from_name', $from_name );
237
-	$emails->__set( 'from_email', $from_email );
238
-	$emails->__set( 'headers', $headers );
239
-	$emails->__set( 'heading', esc_html__( 'New Donation!', 'give' ) );
236
+	$emails->__set('from_name', $from_name);
237
+	$emails->__set('from_email', $from_email);
238
+	$emails->__set('headers', $headers);
239
+	$emails->__set('heading', esc_html__('New Donation!', 'give'));
240 240
 
241
-	$emails->send( give_get_admin_notice_emails(), $subject, $message, $attachments );
241
+	$emails->send(give_get_admin_notice_emails(), $subject, $message, $attachments);
242 242
 
243 243
 }
244 244
 
245
-add_action( 'give_admin_donation_email', 'give_admin_email_notice', 10, 2 );
245
+add_action('give_admin_donation_email', 'give_admin_email_notice', 10, 2);
246 246
 
247 247
 /**
248 248
  * Retrieves the emails for which admin notifications are sent to (these can be changed in the Give Settings).
@@ -252,12 +252,12 @@  discard block
 block discarded – undo
252 252
  */
253 253
 function give_get_admin_notice_emails() {
254 254
 
255
-	$email_option = give_get_option( 'admin_notice_emails' );
255
+	$email_option = give_get_option('admin_notice_emails');
256 256
 
257
-	$emails = ! empty( $email_option ) && strlen( trim( $email_option ) ) > 0 ? $email_option : get_bloginfo( 'admin_email' );
258
-	$emails = array_map( 'trim', explode( "\n", $emails ) );
257
+	$emails = ! empty($email_option) && strlen(trim($email_option)) > 0 ? $email_option : get_bloginfo('admin_email');
258
+	$emails = array_map('trim', explode("\n", $emails));
259 259
 
260
-	return apply_filters( 'give_admin_notice_emails', $emails );
260
+	return apply_filters('give_admin_notice_emails', $emails);
261 261
 }
262 262
 
263 263
 /**
@@ -269,11 +269,11 @@  discard block
 block discarded – undo
269 269
  *
270 270
  * @return mixed
271 271
  */
272
-function give_admin_notices_disabled( $payment_id = 0 ) {
272
+function give_admin_notices_disabled($payment_id = 0) {
273 273
 
274
-	$retval = give_get_option( 'disable_admin_notices' );
274
+	$retval = give_get_option('disable_admin_notices');
275 275
 
276
-	return apply_filters( 'give_admin_notices_disabled', $retval, $payment_id );
276
+	return apply_filters('give_admin_notices_disabled', $retval, $payment_id);
277 277
 }
278 278
 
279 279
 /**
@@ -286,19 +286,19 @@  discard block
 block discarded – undo
286 286
  */
287 287
 function give_get_default_donation_notification_email() {
288 288
 
289
-	$default_email_body = esc_html__( 'Hi there,', 'give' ) . "\n\n";
290
-	$default_email_body .= esc_html__( 'This email is to inform you that a new donation has been made on your website:', 'give' ) . ' <a href="' . get_bloginfo( 'url' ) . '" target="_blank">' . get_bloginfo( 'url' ) . '</a>' . ".\n\n";
291
-	$default_email_body .= '<strong>' . esc_html__( 'Donor:', 'give' ) . '</strong> {name}' . "\n";
292
-	$default_email_body .= '<strong>' . esc_html__( 'Donation:', 'give' ) . '</strong> {donation}' . "\n";
293
-	$default_email_body .= '<strong>' . esc_html__( 'Amount:', 'give' ) . '</strong> {amount}' . "\n";
294
-	$default_email_body .= '<strong>' . esc_html__( 'Payment Method:', 'give' ) . '</strong> {payment_method}' . "\n\n";
295
-	$default_email_body .= esc_html__( 'Thank you,', 'give' ) . "\n\n";
296
-	$default_email_body .= '{sitename}' . "\n";
289
+	$default_email_body = esc_html__('Hi there,', 'give')."\n\n";
290
+	$default_email_body .= esc_html__('This email is to inform you that a new donation has been made on your website:', 'give').' <a href="'.get_bloginfo('url').'" target="_blank">'.get_bloginfo('url').'</a>'.".\n\n";
291
+	$default_email_body .= '<strong>'.esc_html__('Donor:', 'give').'</strong> {name}'."\n";
292
+	$default_email_body .= '<strong>'.esc_html__('Donation:', 'give').'</strong> {donation}'."\n";
293
+	$default_email_body .= '<strong>'.esc_html__('Amount:', 'give').'</strong> {amount}'."\n";
294
+	$default_email_body .= '<strong>'.esc_html__('Payment Method:', 'give').'</strong> {payment_method}'."\n\n";
295
+	$default_email_body .= esc_html__('Thank you,', 'give')."\n\n";
296
+	$default_email_body .= '{sitename}'."\n";
297 297
 
298
-	$custom_message = give_get_option( 'donation_notification' );
299
-	$message        = ! empty( $custom_message ) ? $custom_message : $default_email_body;
298
+	$custom_message = give_get_option('donation_notification');
299
+	$message        = ! empty($custom_message) ? $custom_message : $default_email_body;
300 300
 
301
-	return apply_filters( 'give_default_donation_notification_email', $message );
301
+	return apply_filters('give_default_donation_notification_email', $message);
302 302
 }
303 303
 
304 304
 
@@ -312,25 +312,25 @@  discard block
 block discarded – undo
312 312
  */
313 313
 function give_get_default_donation_receipt_email() {
314 314
 
315
-	$default_email_body = esc_html__( 'Dear', 'give' ) . " {name},\n\n";
316
-	$default_email_body .= esc_html__( 'Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give' ) . "\n\n";
317
-	$default_email_body .= '<strong>' . esc_html__( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n";
318
-	$default_email_body .= '<strong>' . esc_html__( 'Donation:', 'give' ) . '</strong> {donation}' . "\n";
319
-	$default_email_body .= '<strong>' . esc_html__( 'Donation Date:', 'give' ) . '</strong> {date}' . "\n";
320
-	$default_email_body .= '<strong>' . esc_html__( 'Amount:', 'give' ) . '</strong> {amount}' . "\n";
321
-	$default_email_body .= '<strong>' . esc_html__( 'Payment Method:', 'give' ) . '</strong> {payment_method}' . "\n";
322
-	$default_email_body .= '<strong>' . esc_html__( 'Payment ID:', 'give' ) . '</strong> {payment_id}' . "\n";
323
-	$default_email_body .= '<strong>' . esc_html__( 'Receipt ID:', 'give' ) . '</strong> {receipt_id}' . "\n\n";
324
-	$default_email_body .= '{receipt_link}' . "\n\n";
315
+	$default_email_body = esc_html__('Dear', 'give')." {name},\n\n";
316
+	$default_email_body .= esc_html__('Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give')."\n\n";
317
+	$default_email_body .= '<strong>'.esc_html__('Donor:', 'give').'</strong> {fullname}'."\n";
318
+	$default_email_body .= '<strong>'.esc_html__('Donation:', 'give').'</strong> {donation}'."\n";
319
+	$default_email_body .= '<strong>'.esc_html__('Donation Date:', 'give').'</strong> {date}'."\n";
320
+	$default_email_body .= '<strong>'.esc_html__('Amount:', 'give').'</strong> {amount}'."\n";
321
+	$default_email_body .= '<strong>'.esc_html__('Payment Method:', 'give').'</strong> {payment_method}'."\n";
322
+	$default_email_body .= '<strong>'.esc_html__('Payment ID:', 'give').'</strong> {payment_id}'."\n";
323
+	$default_email_body .= '<strong>'.esc_html__('Receipt ID:', 'give').'</strong> {receipt_id}'."\n\n";
324
+	$default_email_body .= '{receipt_link}'."\n\n";
325 325
 	$default_email_body .= "\n\n";
326
-	$default_email_body .= esc_html__( 'Sincerely,', 'give' ) . "\n";
327
-	$default_email_body .= '{sitename}' . "\n";
326
+	$default_email_body .= esc_html__('Sincerely,', 'give')."\n";
327
+	$default_email_body .= '{sitename}'."\n";
328 328
 
329
-	$custom_message = give_get_option( 'donation_receipt' );
329
+	$custom_message = give_get_option('donation_receipt');
330 330
 
331
-	$message = ! empty( $custom_message ) ? $custom_message : $default_email_body;
331
+	$message = ! empty($custom_message) ? $custom_message : $default_email_body;
332 332
 
333
-	return apply_filters( 'give_default_donation_receipt_email', $message );
333
+	return apply_filters('give_default_donation_receipt_email', $message);
334 334
 }
335 335
 
336 336
 /**
@@ -342,19 +342,19 @@  discard block
 block discarded – undo
342 342
  *
343 343
  * @return array $email_names
344 344
  */
345
-function give_get_email_names( $user_info ) {
345
+function give_get_email_names($user_info) {
346 346
 	$email_names = array();
347
-	$user_info   = maybe_unserialize( $user_info );
347
+	$user_info   = maybe_unserialize($user_info);
348 348
 
349 349
 	$email_names['fullname'] = '';
350
-	if ( isset( $user_info['id'] ) && $user_info['id'] > 0 && isset( $user_info['first_name'] ) ) {
351
-		$user_data               = get_userdata( $user_info['id'] );
350
+	if (isset($user_info['id']) && $user_info['id'] > 0 && isset($user_info['first_name'])) {
351
+		$user_data               = get_userdata($user_info['id']);
352 352
 		$email_names['name']     = $user_info['first_name'];
353
-		$email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name'];
353
+		$email_names['fullname'] = $user_info['first_name'].' '.$user_info['last_name'];
354 354
 		$email_names['username'] = $user_data->user_login;
355
-	} elseif ( isset( $user_info['first_name'] ) ) {
355
+	} elseif (isset($user_info['first_name'])) {
356 356
 		$email_names['name']     = $user_info['first_name'];
357
-		$email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name'];
357
+		$email_names['fullname'] = $user_info['first_name'].' '.$user_info['last_name'];
358 358
 		$email_names['username'] = $user_info['first_name'];
359 359
 	} else {
360 360
 		$email_names['name']     = $user_info['email'];
Please login to merge, or discard this patch.
includes/emails/template.php 1 patch
Spacing   +104 added lines, -104 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
 
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
  *
42 42
  * @return string $message Fully formatted message
43 43
  */
44
-function give_email_template_tags( $message, $payment_data, $payment_id, $admin_notice = false ) {
45
-	return give_do_email_tags( $message, $payment_id );
44
+function give_email_template_tags($message, $payment_data, $payment_id, $admin_notice = false) {
45
+	return give_do_email_tags($message, $payment_id);
46 46
 }
47 47
 
48 48
 /**
@@ -56,42 +56,42 @@  discard block
 block discarded – undo
56 56
  *
57 57
  * @return string $message Fully formatted message
58 58
  */
59
-function give_email_preview_template_tags( $message ) {
59
+function give_email_preview_template_tags($message) {
60 60
 
61
-	$price = give_currency_filter( give_format_amount( 10.50 ) );
61
+	$price = give_currency_filter(give_format_amount(10.50));
62 62
 
63 63
 	$gateway = 'PayPal';
64 64
 
65
-	$receipt_id = strtolower( md5( uniqid() ) );
65
+	$receipt_id = strtolower(md5(uniqid()));
66 66
 
67
-	$payment_id = rand( 1, 100 );
67
+	$payment_id = rand(1, 100);
68 68
 
69
-	$receipt_link_url = esc_url( add_query_arg( array( 'payment_key' => $receipt_id, 'give_action' => 'view_receipt' ), home_url() ) );
69
+	$receipt_link_url = esc_url(add_query_arg(array('payment_key' => $receipt_id, 'give_action' => 'view_receipt'), home_url()));
70 70
 	$receipt_link = sprintf(
71 71
 		'<a href="%1$s">%2$s</a>',
72 72
 		$receipt_link_url,
73
-		esc_html__( 'View the receipt in your browser &raquo;', 'give' )
73
+		esc_html__('View the receipt in your browser &raquo;', 'give')
74 74
 	);
75 75
 
76 76
 	$user = wp_get_current_user();
77 77
 
78
-	$message = str_replace( '{name}', $user->display_name, $message );
79
-	$message = str_replace( '{fullname}', $user->display_name, $message );
80
-	$message = str_replace( '{username}', $user->user_login, $message );
81
-	$message = str_replace( '{date}', date( give_date_format(), current_time( 'timestamp' ) ), $message );
82
-	$message = str_replace( '{amount}', $price, $message );
83
-	$message = str_replace( '{price}', $price, $message );
84
-	$message = str_replace( '{donation}', esc_html__( 'Sample Donation Form Title', 'give' ), $message );
85
-	$message = str_replace( '{form_title}', esc_html__( 'Sample Donation Form Title - Sample Donation Level', 'give' ), $message );
86
-	$message = str_replace( '{receipt_id}', $receipt_id, $message );
87
-	$message = str_replace( '{payment_method}', $gateway, $message );
88
-	$message = str_replace( '{sitename}', get_bloginfo( 'name' ), $message );
89
-	$message = str_replace( '{payment_id}', $payment_id, $message );
90
-	$message = str_replace( '{receipt_link}', $receipt_link, $message );
91
-	$message = str_replace( '{receipt_link_url}', $receipt_link_url, $message );
92
-	$message = str_replace( '{pdf_receipt}', '<a href="#">Download Receipt</a>', $message );
93
-
94
-	return wpautop( apply_filters( 'give_email_preview_template_tags', $message ) );
78
+	$message = str_replace('{name}', $user->display_name, $message);
79
+	$message = str_replace('{fullname}', $user->display_name, $message);
80
+	$message = str_replace('{username}', $user->user_login, $message);
81
+	$message = str_replace('{date}', date(give_date_format(), current_time('timestamp')), $message);
82
+	$message = str_replace('{amount}', $price, $message);
83
+	$message = str_replace('{price}', $price, $message);
84
+	$message = str_replace('{donation}', esc_html__('Sample Donation Form Title', 'give'), $message);
85
+	$message = str_replace('{form_title}', esc_html__('Sample Donation Form Title - Sample Donation Level', 'give'), $message);
86
+	$message = str_replace('{receipt_id}', $receipt_id, $message);
87
+	$message = str_replace('{payment_method}', $gateway, $message);
88
+	$message = str_replace('{sitename}', get_bloginfo('name'), $message);
89
+	$message = str_replace('{payment_id}', $payment_id, $message);
90
+	$message = str_replace('{receipt_link}', $receipt_link, $message);
91
+	$message = str_replace('{receipt_link_url}', $receipt_link_url, $message);
92
+	$message = str_replace('{pdf_receipt}', '<a href="#">Download Receipt</a>', $message);
93
+
94
+	return wpautop(apply_filters('give_email_preview_template_tags', $message));
95 95
 }
96 96
 
97 97
 /**
@@ -103,23 +103,23 @@  discard block
 block discarded – undo
103 103
  * @since  1.0
104 104
  * @return array|bool
105 105
  */
106
-function give_email_template_preview( $array ) {
106
+function give_email_template_preview($array) {
107 107
 
108
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
108
+	if ( ! current_user_can('manage_give_settings')) {
109 109
 		return false;
110 110
 	}
111 111
 	$custom_field = array(
112
-		'name' => esc_html__( 'Preview Email', 'give' ),
113
-		'desc' => esc_html__( 'Click the buttons to preview emails.', 'give' ),
112
+		'name' => esc_html__('Preview Email', 'give'),
113
+		'desc' => esc_html__('Click the buttons to preview emails.', 'give'),
114 114
 		'id'   => 'give_email_preview_buttons',
115 115
 		'type' => 'email_preview_buttons'
116 116
 	);
117 117
 
118
-	return give_settings_array_insert( $array, 'donation_subject', array( $custom_field ) );
118
+	return give_settings_array_insert($array, 'donation_subject', array($custom_field));
119 119
 
120 120
 }
121 121
 
122
-add_filter( 'give_settings_emails', 'give_email_template_preview' );
122
+add_filter('give_settings_emails', 'give_email_template_preview');
123 123
 
124 124
 /**
125 125
  * Output Email Template Preview Buttons.
@@ -131,12 +131,12 @@  discard block
 block discarded – undo
131 131
 function give_email_preview_buttons_callback() {
132 132
 	ob_start();
133 133
 	?>
134
-	<a href="<?php echo esc_url( add_query_arg( array( 'give_action' => 'preview_email' ), home_url() ) ); ?>" class="button-secondary" target="_blank"><?php esc_html_e( 'Preview Donation Receipt', 'give' ); ?></a>
135
-	<a href="<?php echo wp_nonce_url( add_query_arg( array(
134
+	<a href="<?php echo esc_url(add_query_arg(array('give_action' => 'preview_email'), home_url())); ?>" class="button-secondary" target="_blank"><?php esc_html_e('Preview Donation Receipt', 'give'); ?></a>
135
+	<a href="<?php echo wp_nonce_url(add_query_arg(array(
136 136
 		'give_action'  => 'send_test_email',
137 137
 		'give-message' => 'sent-test-email',
138 138
 		'tag'          => 'emails'
139
-	) ), 'give-test-email' ); ?>" aria-label="<?php esc_attr_e( 'Send demo donation receipt to the emails listed below.', 'give' ); ?>" class="button-secondary"><?php esc_html_e( 'Send Test Email', 'give' ); ?></a>
139
+	)), 'give-test-email'); ?>" aria-label="<?php esc_attr_e('Send demo donation receipt to the emails listed below.', 'give'); ?>" class="button-secondary"><?php esc_html_e('Send Test Email', 'give'); ?></a>
140 140
 	<?php
141 141
 	echo ob_get_clean();
142 142
 }
@@ -149,46 +149,46 @@  discard block
 block discarded – undo
149 149
  */
150 150
 function give_display_email_template_preview() {
151 151
 
152
-	if ( empty( $_GET['give_action'] ) ) {
152
+	if (empty($_GET['give_action'])) {
153 153
 		return;
154 154
 	}
155 155
 
156
-	if ( 'preview_email' !== $_GET['give_action'] ) {
156
+	if ('preview_email' !== $_GET['give_action']) {
157 157
 		return;
158 158
 	}
159 159
 
160
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
160
+	if ( ! current_user_can('manage_give_settings')) {
161 161
 		return;
162 162
 	}
163 163
 
164 164
 
165
-	Give()->emails->heading = esc_html__( 'Donation Receipt', 'give' );
165
+	Give()->emails->heading = esc_html__('Donation Receipt', 'give');
166 166
 
167
-	$payment_id = (int) isset( $_GET['preview_id'] ) ? $_GET['preview_id'] : '';
167
+	$payment_id = (int) isset($_GET['preview_id']) ? $_GET['preview_id'] : '';
168 168
 
169 169
 	echo give_get_preview_email_header();
170 170
 
171 171
 	//Are we previewing an actual payment?
172
-	if ( ! empty( $payment_id ) ) {
172
+	if ( ! empty($payment_id)) {
173 173
 
174
-		$content = give_get_email_body_content( $payment_id );
174
+		$content = give_get_email_body_content($payment_id);
175 175
 
176
-		$preview_content = give_do_email_tags( $content, $payment_id );
176
+		$preview_content = give_do_email_tags($content, $payment_id);
177 177
 
178 178
 	} else {
179 179
 
180 180
 		//No payment ID, use sample preview content
181
-		$preview_content = give_email_preview_template_tags( give_get_email_body_content( 0, array() ) );
181
+		$preview_content = give_email_preview_template_tags(give_get_email_body_content(0, array()));
182 182
 	}
183 183
 
184 184
 
185
-	echo Give()->emails->build_email( $preview_content );
185
+	echo Give()->emails->build_email($preview_content);
186 186
 
187 187
 	exit;
188 188
 
189 189
 }
190 190
 
191
-add_action( 'init', 'give_display_email_template_preview' );
191
+add_action('init', 'give_display_email_template_preview');
192 192
 
193 193
 /**
194 194
  * Email Template Body.
@@ -200,18 +200,18 @@  discard block
 block discarded – undo
200 200
  *
201 201
  * @return string $email_body Body of the email
202 202
  */
203
-function give_get_email_body_content( $payment_id = 0, $payment_data = array() ) {
203
+function give_get_email_body_content($payment_id = 0, $payment_data = array()) {
204 204
 
205 205
 	$default_email_body = give_get_default_donation_receipt_email();
206 206
 
207
-	$email_content = give_get_option( 'donation_receipt' );
208
-	$email_content = isset( $email_content ) ? stripslashes( $email_content ) : $default_email_body;
207
+	$email_content = give_get_option('donation_receipt');
208
+	$email_content = isset($email_content) ? stripslashes($email_content) : $default_email_body;
209 209
 
210
-	$email_body = wpautop( $email_content );
210
+	$email_body = wpautop($email_content);
211 211
 
212
-	$email_body = apply_filters( 'give_donation_receipt_' . Give()->emails->get_template(), $email_body, $payment_id, $payment_data );
212
+	$email_body = apply_filters('give_donation_receipt_'.Give()->emails->get_template(), $email_body, $payment_id, $payment_data);
213 213
 
214
-	return apply_filters( 'give_donation_receipt', $email_body, $payment_id, $payment_data );
214
+	return apply_filters('give_donation_receipt', $email_body, $payment_id, $payment_data);
215 215
 }
216 216
 
217 217
 /**
@@ -224,36 +224,36 @@  discard block
 block discarded – undo
224 224
  *
225 225
  * @return string $email_body Body of the email
226 226
  */
227
-function give_get_donation_notification_body_content( $payment_id = 0, $payment_data = array() ) {
227
+function give_get_donation_notification_body_content($payment_id = 0, $payment_data = array()) {
228 228
 
229
-	$user_info = maybe_unserialize( $payment_data['user_info'] );
230
-	$email     = give_get_payment_user_email( $payment_id );
229
+	$user_info = maybe_unserialize($payment_data['user_info']);
230
+	$email     = give_get_payment_user_email($payment_id);
231 231
 
232
-	if ( isset( $user_info['id'] ) && $user_info['id'] > 0 ) {
233
-		$user_data = get_userdata( $user_info['id'] );
232
+	if (isset($user_info['id']) && $user_info['id'] > 0) {
233
+		$user_data = get_userdata($user_info['id']);
234 234
 		$name      = $user_data->display_name;
235
-	} elseif ( isset( $user_info['first_name'] ) && isset( $user_info['last_name'] ) ) {
236
-		$name = $user_info['first_name'] . ' ' . $user_info['last_name'];
235
+	} elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) {
236
+		$name = $user_info['first_name'].' '.$user_info['last_name'];
237 237
 	} else {
238 238
 		$name = $email;
239 239
 	}
240 240
 
241
-	$gateway = give_get_gateway_admin_label( get_post_meta( $payment_id, '_give_payment_gateway', true ) );
241
+	$gateway = give_get_gateway_admin_label(get_post_meta($payment_id, '_give_payment_gateway', true));
242 242
 
243
-	$default_email_body = esc_html__( 'Hello', 'give' ) . "\n\n";
244
-	$default_email_body .= esc_html__( 'A donation has been made.', 'give' ) . "\n\n";
245
-	$default_email_body .= esc_html__( 'Donation:', 'give' ) . "\n\n";
246
-	$default_email_body .= esc_html__( 'Donor:', 'give' ) . ' ' . html_entity_decode( $name, ENT_COMPAT, 'UTF-8' ) . "\n";
247
-	$default_email_body .= esc_html__( 'Amount:', 'give' ) . ' ' . html_entity_decode( give_currency_filter( give_format_amount( give_get_payment_amount( $payment_id ) ) ), ENT_COMPAT, 'UTF-8' ) . "\n";
248
-	$default_email_body .= esc_html__( 'Payment Method:', 'give' ) . ' ' . $gateway . "\n\n";
249
-	$default_email_body .= esc_html__( 'Thank you', 'give' );
243
+	$default_email_body = esc_html__('Hello', 'give')."\n\n";
244
+	$default_email_body .= esc_html__('A donation has been made.', 'give')."\n\n";
245
+	$default_email_body .= esc_html__('Donation:', 'give')."\n\n";
246
+	$default_email_body .= esc_html__('Donor:', 'give').' '.html_entity_decode($name, ENT_COMPAT, 'UTF-8')."\n";
247
+	$default_email_body .= esc_html__('Amount:', 'give').' '.html_entity_decode(give_currency_filter(give_format_amount(give_get_payment_amount($payment_id))), ENT_COMPAT, 'UTF-8')."\n";
248
+	$default_email_body .= esc_html__('Payment Method:', 'give').' '.$gateway."\n\n";
249
+	$default_email_body .= esc_html__('Thank you', 'give');
250 250
 
251
-	$email = give_get_option( 'donation_notification' );
252
-	$email = isset( $email ) ? stripslashes( $email ) : $default_email_body;
251
+	$email = give_get_option('donation_notification');
252
+	$email = isset($email) ? stripslashes($email) : $default_email_body;
253 253
 
254
-	$email_body = give_do_email_tags( $email, $payment_id );
254
+	$email_body = give_do_email_tags($email, $payment_id);
255 255
 
256
-	return apply_filters( 'give_donation_notification', wpautop( $email_body ), $payment_id, $payment_data );
256
+	return apply_filters('give_donation_notification', wpautop($email_body), $payment_id, $payment_data);
257 257
 }
258 258
 
259 259
 /**
@@ -266,19 +266,19 @@  discard block
 block discarded – undo
266 266
  * @since  1.0
267 267
  */
268 268
 function give_render_receipt_in_browser() {
269
-	if ( ! isset( $_GET['payment_key'] ) ) {
270
-		wp_die( esc_html__( 'Missing donation payment key.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) );
269
+	if ( ! isset($_GET['payment_key'])) {
270
+		wp_die(esc_html__('Missing donation payment key.', 'give'), esc_html__('Error', 'give'), array('response' => 400));
271 271
 	}
272 272
 
273
-	$key = urlencode( $_GET['payment_key'] );
273
+	$key = urlencode($_GET['payment_key']);
274 274
 
275 275
 	ob_start();
276 276
 	//Disallows caching of the page
277
-	header( "Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . " GMT" );
278
-	header( "Cache-Control: no-store, no-cache, must-revalidate" ); // HTTP/1.1
279
-	header( "Cache-Control: post-check=0, pre-check=0", false );
280
-	header( "Pragma: no-cache" ); // HTTP/1.0
281
-	header( "Expires: Sat, 23 Oct 1977 05:00:00 PST" ); // Date in the past
277
+	header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
278
+	header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
279
+	header("Cache-Control: post-check=0, pre-check=0", false);
280
+	header("Pragma: no-cache"); // HTTP/1.0
281
+	header("Expires: Sat, 23 Oct 1977 05:00:00 PST"); // Date in the past
282 282
 	?>
283 283
 	<!DOCTYPE html>
284 284
 	<html lang="en">
@@ -289,10 +289,10 @@  discard block
 block discarded – undo
289 289
 		 *
290 290
 		 * @since 1.0
291 291
 		 */
292
-		do_action( 'give_receipt_head' );
292
+		do_action('give_receipt_head');
293 293
 		?>
294 294
 	</head>
295
-	<body class="<?php echo apply_filters( 'give_receipt_page_body_class', 'give_receipt_page' ); ?>">
295
+	<body class="<?php echo apply_filters('give_receipt_page_body_class', 'give_receipt_page'); ?>">
296 296
 
297 297
 	<div id="give_receipt_wrapper">
298 298
 		<?php
@@ -301,16 +301,16 @@  discard block
 block discarded – undo
301 301
 		 *
302 302
 		 * @since 1.0
303 303
 		 */
304
-		do_action( 'give_render_receipt_in_browser_before' );
304
+		do_action('give_render_receipt_in_browser_before');
305 305
 
306
-		echo do_shortcode( '[give_receipt payment_key=' . $key . ']' );
306
+		echo do_shortcode('[give_receipt payment_key='.$key.']');
307 307
 
308 308
 		/**
309 309
 		 * Fires in the receipt template after the content.
310 310
 		 *
311 311
 		 * @since 1.0
312 312
 		 */
313
-		do_action( 'give_render_receipt_in_browser_after' );
313
+		do_action('give_render_receipt_in_browser_after');
314 314
 		?>
315 315
 	</div>
316 316
 
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 	 *
321 321
 	 * @since 1.0
322 322
 	 */
323
-	do_action( 'give_receipt_footer' );
323
+	do_action('give_receipt_footer');
324 324
 	?>
325 325
 	</body>
326 326
 	</html>
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 	die();
330 330
 }
331 331
 
332
-add_action( 'give_view_receipt', 'give_render_receipt_in_browser' );
332
+add_action('give_view_receipt', 'give_render_receipt_in_browser');
333 333
 
334 334
 
335 335
 /**
@@ -344,29 +344,29 @@  discard block
 block discarded – undo
344 344
 
345 345
 	//Payment receipt switcher
346 346
 	$payment_count = give_count_payments()->publish;
347
-	$payment_id    = (int) isset( $_GET['preview_id'] ) ? $_GET['preview_id'] : '';
347
+	$payment_id    = (int) isset($_GET['preview_id']) ? $_GET['preview_id'] : '';
348 348
 
349
-	if ( $payment_count <= 0 ) {
349
+	if ($payment_count <= 0) {
350 350
 		return false;
351 351
 	}
352 352
 
353 353
 	//Get payments.
354
-	$payments = new Give_Payments_Query( array(
354
+	$payments = new Give_Payments_Query(array(
355 355
 		'number' => 100
356
-	) );
356
+	));
357 357
 	$payments = $payments->get_payments();
358 358
 	$options  = array();
359 359
 
360 360
 	//Provide nice human readable options.
361
-	if ( $payments ) {
362
-		$options[0] = esc_html__( '- Select a donation -', 'give' );
363
-		foreach ( $payments as $payment ) {
361
+	if ($payments) {
362
+		$options[0] = esc_html__('- Select a donation -', 'give');
363
+		foreach ($payments as $payment) {
364 364
 
365
-			$options[ $payment->ID ] = esc_html( '#' . $payment->ID . ' - ' . $payment->email . ' - ' . $payment->form_title );
365
+			$options[$payment->ID] = esc_html('#'.$payment->ID.' - '.$payment->email.' - '.$payment->form_title);
366 366
 
367 367
 		}
368 368
 	} else {
369
-		$options[0] = esc_html__( 'No donations found.', 'give' );
369
+		$options[0] = esc_html__('No donations found.', 'give');
370 370
 	}
371 371
 
372 372
 	//Start constructing HTML output.
@@ -379,16 +379,16 @@  discard block
 block discarded – undo
379 379
 			        var selected_trans = transactions.options[transactions.selectedIndex];
380 380
 				        console.log(selected_trans);
381 381
 				        if (selected_trans){
382
-				            var url_string = "' . get_bloginfo( 'url' ) . '?give_action=preview_email&preview_id=" + selected_trans.value;
382
+				            var url_string = "' . get_bloginfo('url').'?give_action=preview_email&preview_id=" + selected_trans.value;
383 383
 				                window.location = url_string;
384 384
 				        }
385 385
 				    }
386 386
 			    </script>';
387 387
 
388
-	$transaction_header .= '<label for="give_preview_email_payment_id" style="font-size:12px;color:#333;margin:0 4px 0 0;">' . esc_html__( 'Preview email with a donation:', 'give' ) . '</label>';
388
+	$transaction_header .= '<label for="give_preview_email_payment_id" style="font-size:12px;color:#333;margin:0 4px 0 0;">'.esc_html__('Preview email with a donation:', 'give').'</label>';
389 389
 
390 390
 	//The select field with 100 latest transactions
391
-	$transaction_header .= Give()->html->select( array(
391
+	$transaction_header .= Give()->html->select(array(
392 392
 		'name'             => 'preview_email_payment_id',
393 393
 		'selected'         => $payment_id,
394 394
 		'id'               => 'give_preview_email_payment_id',
@@ -398,12 +398,12 @@  discard block
 block discarded – undo
398 398
 		'select_atts'      => 'onchange="change_preview()">',
399 399
 		'show_option_all'  => false,
400 400
 		'show_option_none' => false
401
-	) );
401
+	));
402 402
 
403 403
 	//Closing tag
404 404
 	$transaction_header .= '</div>';
405 405
 
406
-	return apply_filters( 'give_preview_email_receipt_header', $transaction_header );
406
+	return apply_filters('give_preview_email_receipt_header', $transaction_header);
407 407
 
408 408
 }
409 409
 
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
 function give_receipt_head_content() {
418 418
 
419 419
 	//Title.
420
-	$output = '<title>' . esc_html__( 'Donation Receipt', 'give' ) . '</title>';
420
+	$output = '<title>'.esc_html__('Donation Receipt', 'give').'</title>';
421 421
 
422 422
 	//Meta.
423 423
 	$output .= '<meta charset="utf-8"/>
@@ -431,10 +431,10 @@  discard block
 block discarded – undo
431 431
 		<meta name="robots" content="noindex, nofollow"/>';
432 432
 
433 433
 	//CSS
434
-	$output .= '<link rel="stylesheet" href="' . give_get_stylesheet_uri() . '?ver=' . GIVE_VERSION . '">';
434
+	$output .= '<link rel="stylesheet" href="'.give_get_stylesheet_uri().'?ver='.GIVE_VERSION.'">';
435 435
 
436
-	echo apply_filters( 'give_receipt_head_content', $output );
436
+	echo apply_filters('give_receipt_head_content', $output);
437 437
 
438 438
 }
439 439
 
440
-add_action( 'give_receipt_head', 'give_receipt_head_content' );
441 440
\ No newline at end of file
441
+add_action('give_receipt_head', 'give_receipt_head_content');
442 442
\ No newline at end of file
Please login to merge, or discard this patch.
includes/process-donation.php 1 patch
Spacing   +259 added lines, -259 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @since 1.0
32 32
 	 */
33
-	do_action( 'give_pre_process_donation' );
33
+	do_action('give_pre_process_donation');
34 34
 
35 35
 	// Validate the form $_POST data
36 36
 	$valid_data = give_purchase_form_validate_fields();
@@ -45,26 +45,26 @@  discard block
 block discarded – undo
45 45
 	 * @param bool|array $valid_data Validate fields.
46 46
 	 * @param array      $_POST      Array of variables passed via the HTTP POST.
47 47
 	 */
48
-	do_action( 'give_checkout_error_checks', $valid_data, $_POST );
48
+	do_action('give_checkout_error_checks', $valid_data, $_POST);
49 49
 
50
-	$is_ajax = isset( $_POST['give_ajax'] );
50
+	$is_ajax = isset($_POST['give_ajax']);
51 51
 
52 52
 	// Process the login form
53
-	if ( isset( $_POST['give_login_submit'] ) ) {
53
+	if (isset($_POST['give_login_submit'])) {
54 54
 		give_process_form_login();
55 55
 	}
56 56
 
57 57
 	// Validate the user
58
-	$user = give_get_purchase_form_user( $valid_data );
58
+	$user = give_get_purchase_form_user($valid_data);
59 59
 
60
-	if ( false === $valid_data || give_get_errors() || ! $user ) {
61
-		if ( $is_ajax ) {
60
+	if (false === $valid_data || give_get_errors() || ! $user) {
61
+		if ($is_ajax) {
62 62
 			/**
63 63
 			 * Fires when AJAX sends back errors from the donation form.
64 64
 			 *
65 65
 			 * @since 1.0
66 66
 			 */
67
-			do_action( 'give_ajax_donation_errors' );
67
+			do_action('give_ajax_donation_errors');
68 68
 			give_die();
69 69
 		} else {
70 70
 			return false;
@@ -72,17 +72,17 @@  discard block
 block discarded – undo
72 72
 	}
73 73
 
74 74
 	// If AJAX send back success to proceed with form submission
75
-	if ( $is_ajax ) {
75
+	if ($is_ajax) {
76 76
 		echo 'success';
77 77
 		give_die();
78 78
 	}
79 79
 
80 80
 	// After AJAX: Setup session if not using php_sessions
81
-	if ( ! Give()->session->use_php_sessions() ) {
81
+	if ( ! Give()->session->use_php_sessions()) {
82 82
 		// Double-check that set_cookie is publicly accessible;
83 83
 		// we're using a slightly modified class-wp-sessions.php
84
-		$session_reflection = new ReflectionMethod( 'WP_Session', 'set_cookie' );
85
-		if ( $session_reflection->isPublic() ) {
84
+		$session_reflection = new ReflectionMethod('WP_Session', 'set_cookie');
85
+		if ($session_reflection->isPublic()) {
86 86
 			// Manually set the cookie.
87 87
 			Give()->session->init()->set_cookie();
88 88
 		}
@@ -97,18 +97,18 @@  discard block
 block discarded – undo
97 97
 		'address'    => $user['address'],
98 98
 	);
99 99
 
100
-	$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
100
+	$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
101 101
 
102
-	$price        = isset( $_POST['give-amount'] ) ? (float) apply_filters( 'give_donation_total', give_sanitize_amount( give_format_amount( $_POST['give-amount'] ) ) ) : '0.00';
103
-	$purchase_key = strtolower( md5( $user['user_email'] . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) );
102
+	$price        = isset($_POST['give-amount']) ? (float) apply_filters('give_donation_total', give_sanitize_amount(give_format_amount($_POST['give-amount']))) : '0.00';
103
+	$purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true)));
104 104
 
105 105
 	// Setup donation information
106 106
 	$purchase_data = array(
107 107
 		'price'        => $price,
108 108
 		'purchase_key' => $purchase_key,
109 109
 		'user_email'   => $user['user_email'],
110
-		'date'         => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ),
111
-		'user_info'    => stripslashes_deep( $user_info ),
110
+		'date'         => date('Y-m-d H:i:s', current_time('timestamp')),
111
+		'user_info'    => stripslashes_deep($user_info),
112 112
 		'post_data'    => $_POST,
113 113
 		'gateway'      => $valid_data['gateway'],
114 114
 		'card_info'    => $valid_data['cc_info'],
@@ -128,10 +128,10 @@  discard block
 block discarded – undo
128 128
 	 * @param array      $user_info  Array containing basic user information.
129 129
 	 * @param bool|array $valid_data Validate fields.
130 130
 	 */
131
-	do_action( 'give_checkout_before_gateway', $_POST, $user_info, $valid_data );
131
+	do_action('give_checkout_before_gateway', $_POST, $user_info, $valid_data);
132 132
 
133 133
 	// Sanity check for price
134
-	if ( ! $purchase_data['price'] ) {
134
+	if ( ! $purchase_data['price']) {
135 135
 		// Revert to manual
136 136
 		$purchase_data['gateway'] = 'manual';
137 137
 		$_POST['give-gateway']    = 'manual';
@@ -142,27 +142,27 @@  discard block
 block discarded – undo
142 142
 	 *
143 143
 	 * @since 1.7
144 144
 	 */
145
-	$purchase_data = apply_filters( 'give_donation_data_before_gateway', $purchase_data, $valid_data );
145
+	$purchase_data = apply_filters('give_donation_data_before_gateway', $purchase_data, $valid_data);
146 146
 
147 147
 	// Setup the data we're storing in the donation session
148 148
 	$session_data = $purchase_data;
149 149
 
150 150
 	// Make sure credit card numbers are never stored in sessions
151
-	unset( $session_data['card_info']['card_number'] );
152
-	unset( $session_data['post_data']['card_number'] );
151
+	unset($session_data['card_info']['card_number']);
152
+	unset($session_data['post_data']['card_number']);
153 153
 
154 154
 	// Used for showing data to non logged-in users after donation, and for other plugins needing donation data.
155
-	give_set_purchase_session( $session_data );
155
+	give_set_purchase_session($session_data);
156 156
 
157 157
 	// Send info to the gateway for payment processing
158
-	give_send_to_gateway( $purchase_data['gateway'], $purchase_data );
158
+	give_send_to_gateway($purchase_data['gateway'], $purchase_data);
159 159
 	give_die();
160 160
 
161 161
 }
162 162
 
163
-add_action( 'give_purchase', 'give_process_purchase_form' );
164
-add_action( 'wp_ajax_give_process_checkout', 'give_process_purchase_form' );
165
-add_action( 'wp_ajax_nopriv_give_process_checkout', 'give_process_purchase_form' );
163
+add_action('give_purchase', 'give_process_purchase_form');
164
+add_action('wp_ajax_give_process_checkout', 'give_process_purchase_form');
165
+add_action('wp_ajax_nopriv_give_process_checkout', 'give_process_purchase_form');
166 166
 
167 167
 
168 168
 /**
@@ -175,26 +175,26 @@  discard block
 block discarded – undo
175 175
  *
176 176
  * @return void
177 177
  */
178
-function give_checkout_check_existing_email( $valid_data, $post ) {
178
+function give_checkout_check_existing_email($valid_data, $post) {
179 179
 
180 180
 	// Verify that the email address belongs to this customer
181
-	if ( is_user_logged_in() ) {
181
+	if (is_user_logged_in()) {
182 182
 
183 183
 		$email    = $valid_data['logged_in_user']['user_email'];
184
-		$customer = new Give_Customer( get_current_user_id(), true );
184
+		$customer = new Give_Customer(get_current_user_id(), true);
185 185
 
186 186
 		// If this email address is not registered with this customer, see if it belongs to any other customer
187
-		if ( $email !== $customer->email && ( is_array( $customer->emails ) && ! in_array( $email, $customer->emails ) ) ) {
188
-			$found_customer = new Give_Customer( $email );
187
+		if ($email !== $customer->email && (is_array($customer->emails) && ! in_array($email, $customer->emails))) {
188
+			$found_customer = new Give_Customer($email);
189 189
 
190
-			if ( $found_customer->id > 0 ) {
191
-				give_set_error( 'give-customer-email-exists', sprintf( esc_html__( 'The email address %s is already in use.', 'give' ), $email ) );
190
+			if ($found_customer->id > 0) {
191
+				give_set_error('give-customer-email-exists', sprintf(esc_html__('The email address %s is already in use.', 'give'), $email));
192 192
 			}
193 193
 		}
194 194
 	}
195 195
 }
196 196
 
197
-add_action( 'give_checkout_error_checks', 'give_checkout_check_existing_email', 10, 2 );
197
+add_action('give_checkout_error_checks', 'give_checkout_check_existing_email', 10, 2);
198 198
 
199 199
 /**
200 200
  * Process the checkout login form
@@ -205,37 +205,37 @@  discard block
 block discarded – undo
205 205
  */
206 206
 function give_process_form_login() {
207 207
 
208
-	$is_ajax = isset( $_POST['give_ajax'] );
208
+	$is_ajax = isset($_POST['give_ajax']);
209 209
 
210 210
 	$user_data = give_purchase_form_validate_user_login();
211 211
 
212
-	if ( give_get_errors() || $user_data['user_id'] < 1 ) {
213
-		if ( $is_ajax ) {
212
+	if (give_get_errors() || $user_data['user_id'] < 1) {
213
+		if ($is_ajax) {
214 214
 			/**
215 215
 			 * Fires when AJAX sends back errors from the donation form.
216 216
 			 *
217 217
 			 * @since 1.0
218 218
 			 */
219
-			do_action( 'give_ajax_donation_errors' );
219
+			do_action('give_ajax_donation_errors');
220 220
 			give_die();
221 221
 		} else {
222
-			wp_redirect( $_SERVER['HTTP_REFERER'] );
222
+			wp_redirect($_SERVER['HTTP_REFERER']);
223 223
 			exit;
224 224
 		}
225 225
 	}
226 226
 
227
-	give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] );
227
+	give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']);
228 228
 
229
-	if ( $is_ajax ) {
229
+	if ($is_ajax) {
230 230
 		echo 'success';
231 231
 		give_die();
232 232
 	} else {
233
-		wp_redirect( $_SERVER['HTTP_REFERER'] );
233
+		wp_redirect($_SERVER['HTTP_REFERER']);
234 234
 	}
235 235
 }
236 236
 
237
-add_action( 'wp_ajax_give_process_checkout_login', 'give_process_form_login' );
238
-add_action( 'wp_ajax_nopriv_give_process_checkout_login', 'give_process_form_login' );
237
+add_action('wp_ajax_give_process_checkout_login', 'give_process_form_login');
238
+add_action('wp_ajax_nopriv_give_process_checkout_login', 'give_process_form_login');
239 239
 
240 240
 /**
241 241
  * Donation Form Validate Fields
@@ -247,45 +247,45 @@  discard block
 block discarded – undo
247 247
 function give_purchase_form_validate_fields() {
248 248
 
249 249
 	// Check if there is $_POST
250
-	if ( empty( $_POST ) ) {
250
+	if (empty($_POST)) {
251 251
 		return false;
252 252
 	}
253 253
 
254
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
254
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
255 255
 
256 256
 	// Start an array to collect valid data
257 257
 	$valid_data = array(
258 258
 		'gateway'          => give_purchase_form_validate_gateway(), // Gateway fallback (amount is validated here)
259
-		'need_new_user'    => false,     // New user flag
260
-		'need_user_login'  => false,     // Login user flag
261
-		'logged_user_data' => array(),   // Logged user collected data
262
-		'new_user_data'    => array(),   // New user collected data
263
-		'login_user_data'  => array(),   // Login user collected data
264
-		'guest_user_data'  => array(),   // Guest user collected data
265
-		'cc_info'          => give_purchase_form_validate_cc(),// Credit card info
259
+		'need_new_user'    => false, // New user flag
260
+		'need_user_login'  => false, // Login user flag
261
+		'logged_user_data' => array(), // Logged user collected data
262
+		'new_user_data'    => array(), // New user collected data
263
+		'login_user_data'  => array(), // Login user collected data
264
+		'guest_user_data'  => array(), // Guest user collected data
265
+		'cc_info'          => give_purchase_form_validate_cc(), // Credit card info
266 266
 	);
267 267
 
268 268
 	// Validate Honeypot First
269
-	if ( ! empty( $_POST['give-honeypot'] ) ) {
270
-		give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) );
269
+	if ( ! empty($_POST['give-honeypot'])) {
270
+		give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give'));
271 271
 	}
272 272
 
273 273
 	// Validate agree to terms
274
-	$terms_option = get_post_meta( $form_id, '_give_terms_option', true );
275
-	if ( isset( $terms_option ) && $terms_option === 'yes' ) {
274
+	$terms_option = get_post_meta($form_id, '_give_terms_option', true);
275
+	if (isset($terms_option) && $terms_option === 'yes') {
276 276
 		give_purchase_form_validate_agree_to_terms();
277 277
 	}
278 278
 
279
-	if ( is_user_logged_in() ) {
279
+	if (is_user_logged_in()) {
280 280
 		// Collect logged in user data
281 281
 		$valid_data['logged_in_user'] = give_purchase_form_validate_logged_in_user();
282
-	} elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' ) {
282
+	} elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register') {
283 283
 		// Set new user registration as required
284 284
 		$valid_data['need_new_user'] = true;
285 285
 		// Validate new user data
286 286
 		$valid_data['new_user_data'] = give_purchase_form_validate_new_user();
287 287
 		// Check if login validation is needed
288
-	} elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) {
288
+	} elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') {
289 289
 		// Set user login as required
290 290
 		$valid_data['need_user_login'] = true;
291 291
 		// Validate users login info
@@ -310,40 +310,40 @@  discard block
 block discarded – undo
310 310
  */
311 311
 function give_purchase_form_validate_gateway() {
312 312
 
313
-	$form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0;
314
-	$amount  = isset( $_REQUEST['give-amount'] ) ? give_sanitize_amount( $_REQUEST['give-amount'] ) : 0;
315
-	$gateway = give_get_default_gateway( $form_id );
313
+	$form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;
314
+	$amount  = isset($_REQUEST['give-amount']) ? give_sanitize_amount($_REQUEST['give-amount']) : 0;
315
+	$gateway = give_get_default_gateway($form_id);
316 316
 
317 317
 	// Check if a gateway value is present
318
-	if ( ! empty( $_REQUEST['give-gateway'] ) ) {
318
+	if ( ! empty($_REQUEST['give-gateway'])) {
319 319
 
320
-		$gateway = sanitize_text_field( $_REQUEST['give-gateway'] );
320
+		$gateway = sanitize_text_field($_REQUEST['give-gateway']);
321 321
 
322 322
 		// Is amount being donated in LIVE mode 0.00? If so, error:
323
-		if ( $amount == 0 && ! give_is_test_mode() ) {
323
+		if ($amount == 0 && ! give_is_test_mode()) {
324 324
 
325
-			give_set_error( 'invalid_donation_amount', esc_html__( 'Please insert a valid donation amount.', 'give' ) );
325
+			give_set_error('invalid_donation_amount', esc_html__('Please insert a valid donation amount.', 'give'));
326 326
 
327 327
 		} //Check for a minimum custom amount
328
-		elseif ( ! give_verify_minimum_price() ) {
328
+		elseif ( ! give_verify_minimum_price()) {
329 329
 			// translators: %s: minimum donation amount.
330 330
 			give_set_error(
331 331
 				'invalid_donation_minimum',
332 332
 				sprintf(
333
-					esc_html__( 'This form has a minimum donation amount of %s.', 'give' ),
334
-					give_currency_filter( give_format_amount( give_get_form_minimum_price( $form_id ) ) )
333
+					esc_html__('This form has a minimum donation amount of %s.', 'give'),
334
+					give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id)))
335 335
 				)
336 336
 			);
337 337
 
338 338
 		} //Is this test mode zero donation? Let it through but set to manual gateway.
339
-		elseif ( $amount == 0 && give_is_test_mode() ) {
339
+		elseif ($amount == 0 && give_is_test_mode()) {
340 340
 
341 341
 			$gateway = 'manual';
342 342
 
343 343
 		} //Check if this gateway is active.
344
-		elseif ( ! give_is_gateway_active( $gateway ) ) {
344
+		elseif ( ! give_is_gateway_active($gateway)) {
345 345
 
346
-			give_set_error( 'invalid_gateway', esc_html__( 'The selected payment gateway is not enabled.', 'give' ) );
346
+			give_set_error('invalid_gateway', esc_html__('The selected payment gateway is not enabled.', 'give'));
347 347
 
348 348
 		}
349 349
 	}
@@ -361,23 +361,23 @@  discard block
 block discarded – undo
361 361
  */
362 362
 function give_verify_minimum_price() {
363 363
 
364
-	$amount          = give_sanitize_amount( $_REQUEST['give-amount'] );
365
-	$form_id         = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0;
366
-	$price_id        = isset( $_REQUEST['give-price-id'] ) ? $_REQUEST['give-price-id'] : 0;
367
-	$variable_prices = give_has_variable_prices( $form_id );
364
+	$amount          = give_sanitize_amount($_REQUEST['give-amount']);
365
+	$form_id         = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;
366
+	$price_id        = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : 0;
367
+	$variable_prices = give_has_variable_prices($form_id);
368 368
 
369
-	if ( $variable_prices && ! empty( $price_id ) ) {
369
+	if ($variable_prices && ! empty($price_id)) {
370 370
 
371
-		$price_level_amount = give_get_price_option_amount( $form_id, $price_id );
371
+		$price_level_amount = give_get_price_option_amount($form_id, $price_id);
372 372
 
373
-		if ( $price_level_amount == $amount ) {
373
+		if ($price_level_amount == $amount) {
374 374
 			return true;
375 375
 		}
376 376
 	}
377 377
 
378
-	$minimum = give_get_form_minimum_price( $form_id );
378
+	$minimum = give_get_form_minimum_price($form_id);
379 379
 
380
-	if ( $minimum > $amount ) {
380
+	if ($minimum > $amount) {
381 381
 		return false;
382 382
 	}
383 383
 
@@ -393,9 +393,9 @@  discard block
 block discarded – undo
393 393
  */
394 394
 function give_purchase_form_validate_agree_to_terms() {
395 395
 	// Validate agree to terms.
396
-	if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) {
396
+	if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) {
397 397
 		// User did not agree.
398
-		give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', esc_html__( 'You must agree to the terms and conditions.', 'give' ) ) );
398
+		give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', esc_html__('You must agree to the terms and conditions.', 'give')));
399 399
 	}
400 400
 }
401 401
 
@@ -409,43 +409,43 @@  discard block
 block discarded – undo
409 409
  *
410 410
  * @return      array
411 411
  */
412
-function give_get_required_fields( $form_id ) {
412
+function give_get_required_fields($form_id) {
413 413
 
414
-	$payment_mode = give_get_chosen_gateway( $form_id );
414
+	$payment_mode = give_get_chosen_gateway($form_id);
415 415
 
416 416
 	$required_fields = array(
417 417
 		'give_email' => array(
418 418
 			'error_id'      => 'invalid_email',
419
-			'error_message' => esc_html__( 'Please enter a valid email address.', 'give' ),
419
+			'error_message' => esc_html__('Please enter a valid email address.', 'give'),
420 420
 		),
421 421
 		'give_first' => array(
422 422
 			'error_id'      => 'invalid_first_name',
423
-			'error_message' => esc_html__( 'Please enter your first name.', 'give' ),
423
+			'error_message' => esc_html__('Please enter your first name.', 'give'),
424 424
 		),
425 425
 	);
426 426
 
427
-	$require_address = give_require_billing_address( $payment_mode );
427
+	$require_address = give_require_billing_address($payment_mode);
428 428
 
429
-	if ( $require_address ) {
430
-		$required_fields['card_address']    = array(
429
+	if ($require_address) {
430
+		$required_fields['card_address'] = array(
431 431
 			'error_id'      => 'invalid_card_address',
432
-			'error_message' => esc_html__( 'Please enter your primary billing address.', 'give' ),
432
+			'error_message' => esc_html__('Please enter your primary billing address.', 'give'),
433 433
 		);
434
-		$required_fields['card_zip']        = array(
434
+		$required_fields['card_zip'] = array(
435 435
 			'error_id'      => 'invalid_zip_code',
436
-			'error_message' => esc_html__( 'Please enter your zip / postal code.', 'give' ),
436
+			'error_message' => esc_html__('Please enter your zip / postal code.', 'give'),
437 437
 		);
438
-		$required_fields['card_city']       = array(
438
+		$required_fields['card_city'] = array(
439 439
 			'error_id'      => 'invalid_city',
440
-			'error_message' => esc_html__( 'Please enter your billing city.', 'give' ),
440
+			'error_message' => esc_html__('Please enter your billing city.', 'give'),
441 441
 		);
442 442
 		$required_fields['billing_country'] = array(
443 443
 			'error_id'      => 'invalid_country',
444
-			'error_message' => esc_html__( 'Please select your billing country.', 'give' ),
444
+			'error_message' => esc_html__('Please select your billing country.', 'give'),
445 445
 		);
446
-		$required_fields['card_state']      = array(
446
+		$required_fields['card_state'] = array(
447 447
 			'error_id'      => 'invalid_state',
448
-			'error_message' => esc_html__( 'Please enter billing state / province.', 'give' ),
448
+			'error_message' => esc_html__('Please enter billing state / province.', 'give'),
449 449
 		);
450 450
 	}
451 451
 
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 	 *
455 455
 	 * @since 1.7
456 456
 	 */
457
-	$required_fields = apply_filters( 'give_donation_form_required_fields', $required_fields, $form_id );
457
+	$required_fields = apply_filters('give_donation_form_required_fields', $required_fields, $form_id);
458 458
 
459 459
 	return $required_fields;
460 460
 
@@ -469,16 +469,16 @@  discard block
 block discarded – undo
469 469
  *
470 470
  * @return mixed|void
471 471
  */
472
-function give_require_billing_address( $payment_mode ) {
472
+function give_require_billing_address($payment_mode) {
473 473
 
474 474
 	$return = false;
475 475
 
476
-	if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) {
476
+	if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) {
477 477
 		$return = true;
478 478
 	}
479 479
 
480 480
 	// Let payment gateways and other extensions determine if address fields should be required.
481
-	return apply_filters( 'give_require_billing_address', $return );
481
+	return apply_filters('give_require_billing_address', $return);
482 482
 
483 483
 }
484 484
 
@@ -492,42 +492,42 @@  discard block
 block discarded – undo
492 492
 function give_purchase_form_validate_logged_in_user() {
493 493
 	global $user_ID;
494 494
 
495
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
495
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
496 496
 
497 497
 	// Start empty array to collect valid user data.
498 498
 	$valid_user_data = array(
499 499
 		// Assume there will be errors.
500
-		'user_id' => - 1,
500
+		'user_id' => -1,
501 501
 	);
502 502
 
503 503
 	// Verify there is a user_ID.
504
-	if ( $user_ID > 0 ) {
504
+	if ($user_ID > 0) {
505 505
 		// Get the logged in user data.
506
-		$user_data = get_userdata( $user_ID );
506
+		$user_data = get_userdata($user_ID);
507 507
 
508 508
 		// Loop through required fields and show error messages.
509
-		foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) {
510
-			if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
511
-				give_set_error( $value['error_id'], $value['error_message'] );
509
+		foreach (give_get_required_fields($form_id) as $field_name => $value) {
510
+			if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) {
511
+				give_set_error($value['error_id'], $value['error_message']);
512 512
 			}
513 513
 		}
514 514
 
515 515
 		// Verify data.
516
-		if ( $user_data ) {
516
+		if ($user_data) {
517 517
 			// Collected logged in user data.
518 518
 			$valid_user_data = array(
519 519
 				'user_id'    => $user_ID,
520
-				'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email,
521
-				'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name,
522
-				'user_last'  => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name,
520
+				'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email,
521
+				'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name,
522
+				'user_last'  => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name,
523 523
 			);
524 524
 
525
-			if ( ! is_email( $valid_user_data['user_email'] ) ) {
526
-				give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
525
+			if ( ! is_email($valid_user_data['user_email'])) {
526
+				give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
527 527
 			}
528 528
 		} else {
529 529
 			// Set invalid user error.
530
-			give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) );
530
+			give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give'));
531 531
 		}
532 532
 	}
533 533
 
@@ -545,90 +545,90 @@  discard block
 block discarded – undo
545 545
 function give_purchase_form_validate_new_user() {
546 546
 
547 547
 	$registering_new_user = false;
548
-	$form_id              = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
548
+	$form_id              = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
549 549
 
550 550
 	// Start an empty array to collect valid user data.
551 551
 	$valid_user_data = array(
552 552
 		// Assume there will be errors.
553
-		'user_id'    => - 1,
553
+		'user_id'    => -1,
554 554
 		// Get first name.
555
-		'user_first' => isset( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : '',
555
+		'user_first' => isset($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : '',
556 556
 		// Get last name.
557
-		'user_last'  => isset( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : '',
557
+		'user_last'  => isset($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : '',
558 558
 	);
559 559
 
560 560
 	// Check the new user's credentials against existing ones.
561
-	$user_login   = isset( $_POST['give_user_login'] ) ? trim( $_POST['give_user_login'] ) : false;
562
-	$user_email   = isset( $_POST['give_email'] ) ? trim( $_POST['give_email'] ) : false;
563
-	$user_pass    = isset( $_POST['give_user_pass'] ) ? trim( $_POST['give_user_pass'] ) : false;
564
-	$pass_confirm = isset( $_POST['give_user_pass_confirm'] ) ? trim( $_POST['give_user_pass_confirm'] ) : false;
561
+	$user_login   = isset($_POST['give_user_login']) ? trim($_POST['give_user_login']) : false;
562
+	$user_email   = isset($_POST['give_email']) ? trim($_POST['give_email']) : false;
563
+	$user_pass    = isset($_POST['give_user_pass']) ? trim($_POST['give_user_pass']) : false;
564
+	$pass_confirm = isset($_POST['give_user_pass_confirm']) ? trim($_POST['give_user_pass_confirm']) : false;
565 565
 
566 566
 	// Loop through required fields and show error messages.
567
-	foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) {
568
-		if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
569
-			give_set_error( $value['error_id'], $value['error_message'] );
567
+	foreach (give_get_required_fields($form_id) as $field_name => $value) {
568
+		if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) {
569
+			give_set_error($value['error_id'], $value['error_message']);
570 570
 		}
571 571
 	}
572 572
 
573 573
 	// Check if we have an username to register.
574
-	if ( $user_login && strlen( $user_login ) > 0 ) {
574
+	if ($user_login && strlen($user_login) > 0) {
575 575
 		$registering_new_user = true;
576 576
 
577 577
 		// We have an user name, check if it already exists.
578
-		if ( username_exists( $user_login ) ) {
578
+		if (username_exists($user_login)) {
579 579
 			// Username already registered.
580
-			give_set_error( 'username_unavailable', esc_html__( 'Username already taken.', 'give' ) );
580
+			give_set_error('username_unavailable', esc_html__('Username already taken.', 'give'));
581 581
 			// Check if it's valid.
582
-		} elseif ( ! give_validate_username( $user_login ) ) {
582
+		} elseif ( ! give_validate_username($user_login)) {
583 583
 			// Invalid username.
584
-			if ( is_multisite() ) {
585
-				give_set_error( 'username_invalid', esc_html__( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ) );
584
+			if (is_multisite()) {
585
+				give_set_error('username_invalid', esc_html__('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give'));
586 586
 			} else {
587
-				give_set_error( 'username_invalid', esc_html__( 'Invalid username.', 'give' ) );
587
+				give_set_error('username_invalid', esc_html__('Invalid username.', 'give'));
588 588
 			}
589 589
 		} else {
590 590
 			// All the checks have run and it's good to go.
591 591
 			$valid_user_data['user_login'] = $user_login;
592 592
 		}
593
-	} elseif ( give_logged_in_only( $form_id ) ) {
594
-		give_set_error( 'registration_required', esc_html__( 'You must register or login to complete your donation.', 'give' ) );
593
+	} elseif (give_logged_in_only($form_id)) {
594
+		give_set_error('registration_required', esc_html__('You must register or login to complete your donation.', 'give'));
595 595
 	}
596 596
 
597 597
 	// Check if we have an email to verify.
598
-	if ( $user_email && strlen( $user_email ) > 0 ) {
598
+	if ($user_email && strlen($user_email) > 0) {
599 599
 		// Validate email.
600
-		if ( ! is_email( $user_email ) ) {
601
-			give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
600
+		if ( ! is_email($user_email)) {
601
+			give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
602 602
 			// Check if email exists.
603
-		} elseif ( email_exists( $user_email ) && $registering_new_user ) {
604
-			give_set_error( 'email_used', esc_html__( 'The email already active for another user.', 'give' ) );
603
+		} elseif (email_exists($user_email) && $registering_new_user) {
604
+			give_set_error('email_used', esc_html__('The email already active for another user.', 'give'));
605 605
 		} else {
606 606
 			// All the checks have run and it's good to go.
607 607
 			$valid_user_data['user_email'] = $user_email;
608 608
 		}
609 609
 	} else {
610 610
 		// No email.
611
-		give_set_error( 'email_empty', esc_html__( 'Enter an email.', 'give' ) );
611
+		give_set_error('email_empty', esc_html__('Enter an email.', 'give'));
612 612
 	}
613 613
 
614 614
 	// Check password.
615
-	if ( $user_pass && $pass_confirm ) {
615
+	if ($user_pass && $pass_confirm) {
616 616
 		// Verify confirmation matches.
617
-		if ( $user_pass != $pass_confirm ) {
617
+		if ($user_pass != $pass_confirm) {
618 618
 			// Passwords do not match
619
-			give_set_error( 'password_mismatch', esc_html__( 'Passwords don\'t match.', 'give' ) );
619
+			give_set_error('password_mismatch', esc_html__('Passwords don\'t match.', 'give'));
620 620
 		} else {
621 621
 			// All is good to go.
622 622
 			$valid_user_data['user_pass'] = $user_pass;
623 623
 		}
624 624
 	} else {
625 625
 		// Password or confirmation missing.
626
-		if ( ! $user_pass && $registering_new_user ) {
626
+		if ( ! $user_pass && $registering_new_user) {
627 627
 			// The password is invalid.
628
-			give_set_error( 'password_empty', esc_html__( 'Enter a password.', 'give' ) );
629
-		} elseif ( ! $pass_confirm && $registering_new_user ) {
628
+			give_set_error('password_empty', esc_html__('Enter a password.', 'give'));
629
+		} elseif ( ! $pass_confirm && $registering_new_user) {
630 630
 			// Confirmation password is invalid.
631
-			give_set_error( 'confirmation_empty', esc_html__( 'Enter the password confirmation.', 'give' ) );
631
+			give_set_error('confirmation_empty', esc_html__('Enter the password confirmation.', 'give'));
632 632
 		}
633 633
 	}
634 634
 
@@ -647,36 +647,36 @@  discard block
 block discarded – undo
647 647
 	// Start an array to collect valid user data.
648 648
 	$valid_user_data = array(
649 649
 		// Assume there will be errors
650
-		'user_id' => - 1,
650
+		'user_id' => -1,
651 651
 	);
652 652
 
653 653
 	// Username.
654
-	if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) {
655
-		give_set_error( 'must_log_in', esc_html__( 'You must register or login to complete your donation.', 'give' ) );
654
+	if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') {
655
+		give_set_error('must_log_in', esc_html__('You must register or login to complete your donation.', 'give'));
656 656
 
657 657
 		return $valid_user_data;
658 658
 	}
659 659
 
660 660
 	// Get the user by login.
661
-	$user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) );
661
+	$user_data = get_user_by('login', strip_tags($_POST['give_user_login']));
662 662
 
663 663
 	// Check if user exists.
664
-	if ( $user_data ) {
664
+	if ($user_data) {
665 665
 		// Get password.
666
-		$user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false;
666
+		$user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false;
667 667
 
668 668
 		// Check user_pass.
669
-		if ( $user_pass ) {
669
+		if ($user_pass) {
670 670
 			// Check if password is valid.
671
-			if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) {
671
+			if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) {
672 672
 				// Incorrect password.
673 673
 				give_set_error(
674 674
 					'password_incorrect',
675 675
 					sprintf(
676 676
 						'%1$s <a href="%2$s">%3$s</a>',
677
-						esc_html__( 'The password you entered is incorrect.', 'give' ),
678
-						wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ),
679
-						esc_html__( 'Reset Password', 'give' )
677
+						esc_html__('The password you entered is incorrect.', 'give'),
678
+						wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"),
679
+						esc_html__('Reset Password', 'give')
680 680
 					)
681 681
 				);
682 682
 				// All is correct.
@@ -693,11 +693,11 @@  discard block
 block discarded – undo
693 693
 			}
694 694
 		} else {
695 695
 			// Empty password.
696
-			give_set_error( 'password_empty', esc_html__( 'Enter a password.', 'give' ) );
696
+			give_set_error('password_empty', esc_html__('Enter a password.', 'give'));
697 697
 		}
698 698
 	} else {
699 699
 		// No username.
700
-		give_set_error( 'username_incorrect', esc_html__( 'The username you entered does not exist.', 'give' ) );
700
+		give_set_error('username_incorrect', esc_html__('The username you entered does not exist.', 'give'));
701 701
 	}
702 702
 
703 703
 	return $valid_user_data;
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
  */
713 713
 function give_purchase_form_validate_guest_user() {
714 714
 
715
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
715
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
716 716
 
717 717
 	// Start an array to collect valid user data.
718 718
 	$valid_user_data = array(
@@ -721,38 +721,38 @@  discard block
 block discarded – undo
721 721
 	);
722 722
 
723 723
 	// Show error message if user must be logged in.
724
-	if ( give_logged_in_only( $form_id ) ) {
725
-		give_set_error( 'logged_in_only', esc_html__( 'You must be logged in to donate.', 'give' ) );
724
+	if (give_logged_in_only($form_id)) {
725
+		give_set_error('logged_in_only', esc_html__('You must be logged in to donate.', 'give'));
726 726
 	}
727 727
 
728 728
 	// Get the guest email.
729
-	$guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false;
729
+	$guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false;
730 730
 
731 731
 	// Check email.
732
-	if ( $guest_email && strlen( $guest_email ) > 0 ) {
732
+	if ($guest_email && strlen($guest_email) > 0) {
733 733
 		// Validate email.
734
-		if ( ! is_email( $guest_email ) ) {
734
+		if ( ! is_email($guest_email)) {
735 735
 			// Invalid email.
736
-			give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
736
+			give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
737 737
 		} else {
738 738
 			// All is good to go.
739 739
 			$valid_user_data['user_email'] = $guest_email;
740 740
 
741 741
 			// Get user_id from donor if exist.
742
-			$donor = new Give_Customer( $guest_email );
743
-			if ( $donor->id && $donor->user_id ) {
742
+			$donor = new Give_Customer($guest_email);
743
+			if ($donor->id && $donor->user_id) {
744 744
 				$valid_user_data['user_id'] = $donor->user_id;
745 745
 			}
746 746
 		}
747 747
 	} else {
748 748
 		// No email.
749
-		give_set_error( 'email_empty', esc_html__( 'Enter an email.', 'give' ) );
749
+		give_set_error('email_empty', esc_html__('Enter an email.', 'give'));
750 750
 	}
751 751
 
752 752
 	// Loop through required fields and show error messages.
753
-	foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) {
754
-		if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
755
-			give_set_error( $value['error_id'], $value['error_message'] );
753
+	foreach (give_get_required_fields($form_id) as $field_name => $value) {
754
+		if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) {
755
+			give_set_error($value['error_id'], $value['error_message']);
756 756
 		}
757 757
 	}
758 758
 
@@ -768,36 +768,36 @@  discard block
 block discarded – undo
768 768
  * @since   1.0
769 769
  * @return  integer
770 770
  */
771
-function give_register_and_login_new_user( $user_data = array() ) {
771
+function give_register_and_login_new_user($user_data = array()) {
772 772
 	// Verify the array.
773
-	if ( empty( $user_data ) ) {
774
-		return - 1;
773
+	if (empty($user_data)) {
774
+		return -1;
775 775
 	}
776 776
 
777
-	if ( give_get_errors() ) {
778
-		return - 1;
777
+	if (give_get_errors()) {
778
+		return -1;
779 779
 	}
780 780
 
781
-	$user_args = apply_filters( 'give_insert_user_args', array(
782
-		'user_login'      => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '',
783
-		'user_pass'       => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '',
784
-		'user_email'      => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '',
785
-		'first_name'      => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '',
786
-		'last_name'       => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '',
787
-		'user_registered' => date( 'Y-m-d H:i:s' ),
788
-		'role'            => get_option( 'default_role' ),
789
-	), $user_data );
781
+	$user_args = apply_filters('give_insert_user_args', array(
782
+		'user_login'      => isset($user_data['user_login']) ? $user_data['user_login'] : '',
783
+		'user_pass'       => isset($user_data['user_pass']) ? $user_data['user_pass'] : '',
784
+		'user_email'      => isset($user_data['user_email']) ? $user_data['user_email'] : '',
785
+		'first_name'      => isset($user_data['user_first']) ? $user_data['user_first'] : '',
786
+		'last_name'       => isset($user_data['user_last']) ? $user_data['user_last'] : '',
787
+		'user_registered' => date('Y-m-d H:i:s'),
788
+		'role'            => get_option('default_role'),
789
+	), $user_data);
790 790
 
791 791
 	// Insert new user.
792
-	$user_id = wp_insert_user( $user_args );
792
+	$user_id = wp_insert_user($user_args);
793 793
 
794 794
 	// Validate inserted user.
795
-	if ( is_wp_error( $user_id ) ) {
796
-		return - 1;
795
+	if (is_wp_error($user_id)) {
796
+		return -1;
797 797
 	}
798 798
 
799 799
 	// Allow themes and plugins to filter the user data.
800
-	$user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args );
800
+	$user_data = apply_filters('give_insert_user_data', $user_data, $user_args);
801 801
 
802 802
 	/**
803 803
 	 * Fires after inserting user.
@@ -807,10 +807,10 @@  discard block
 block discarded – undo
807 807
 	 * @param int   $user_id   User id.
808 808
 	 * @param array $user_data Array containing user data.
809 809
 	 */
810
-	do_action( 'give_insert_user', $user_id, $user_data );
810
+	do_action('give_insert_user', $user_id, $user_data);
811 811
 
812 812
 	// Login new user.
813
-	give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] );
813
+	give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']);
814 814
 
815 815
 	// Return user id.
816 816
 	return $user_id;
@@ -825,27 +825,27 @@  discard block
 block discarded – undo
825 825
  * @since   1.0
826 826
  * @return  array
827 827
  */
828
-function give_get_purchase_form_user( $valid_data = array() ) {
828
+function give_get_purchase_form_user($valid_data = array()) {
829 829
 
830 830
 	// Initialize user.
831 831
 	$user    = false;
832
-	$is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
832
+	$is_ajax = defined('DOING_AJAX') && DOING_AJAX;
833 833
 
834
-	if ( $is_ajax ) {
834
+	if ($is_ajax) {
835 835
 		// Do not create or login the user during the ajax submission (check for errors only).
836 836
 		return true;
837
-	} elseif ( is_user_logged_in() ) {
837
+	} elseif (is_user_logged_in()) {
838 838
 		// Set the valid user as the logged in collected data.
839 839
 		$user = $valid_data['logged_in_user'];
840
-	} elseif ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) {
840
+	} elseif ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) {
841 841
 		// New user registration.
842
-		if ( $valid_data['need_new_user'] === true ) {
842
+		if ($valid_data['need_new_user'] === true) {
843 843
 			// Set user.
844 844
 			$user = $valid_data['new_user_data'];
845 845
 			// Register and login new user.
846
-			$user['user_id'] = give_register_and_login_new_user( $user );
846
+			$user['user_id'] = give_register_and_login_new_user($user);
847 847
 			// User login
848
-		} elseif ( $valid_data['need_user_login'] === true && ! $is_ajax ) {
848
+		} elseif ($valid_data['need_user_login'] === true && ! $is_ajax) {
849 849
 
850 850
 			/*
851 851
 			 * The login form is now processed in the give_process_purchase_login() function.
@@ -858,48 +858,48 @@  discard block
 block discarded – undo
858 858
 			// Set user.
859 859
 			$user = $valid_data['login_user_data'];
860 860
 			// Login user.
861
-			give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] );
861
+			give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']);
862 862
 		}
863 863
 	}
864 864
 
865 865
 	// Check guest checkout.
866
-	if ( false === $user && false === give_logged_in_only( $_POST['give-form-id'] ) ) {
866
+	if (false === $user && false === give_logged_in_only($_POST['give-form-id'])) {
867 867
 		// Set user
868 868
 		$user = $valid_data['guest_user_data'];
869 869
 	}
870 870
 
871 871
 	// Verify we have an user.
872
-	if ( false === $user || empty( $user ) ) {
872
+	if (false === $user || empty($user)) {
873 873
 		// Return false.
874 874
 		return false;
875 875
 	}
876 876
 
877 877
 	// Get user first name.
878
-	if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) {
879
-		$user['user_first'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : '';
878
+	if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) {
879
+		$user['user_first'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : '';
880 880
 	}
881 881
 
882 882
 	// Get user last name.
883
-	if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) {
884
-		$user['user_last'] = isset( $_POST['give_last'] ) ? strip_tags( trim( $_POST['give_last'] ) ) : '';
883
+	if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) {
884
+		$user['user_last'] = isset($_POST['give_last']) ? strip_tags(trim($_POST['give_last'])) : '';
885 885
 	}
886 886
 
887 887
 	// Get the user's billing address details.
888 888
 	$user['address']            = array();
889
-	$user['address']['line1']   = ! empty( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : false;
890
-	$user['address']['line2']   = ! empty( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : false;
891
-	$user['address']['city']    = ! empty( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : false;
892
-	$user['address']['state']   = ! empty( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : false;
893
-	$user['address']['country'] = ! empty( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : false;
894
-	$user['address']['zip']     = ! empty( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : false;
895
-
896
-	if ( empty( $user['address']['country'] ) ) {
889
+	$user['address']['line1']   = ! empty($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : false;
890
+	$user['address']['line2']   = ! empty($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : false;
891
+	$user['address']['city']    = ! empty($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : false;
892
+	$user['address']['state']   = ! empty($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : false;
893
+	$user['address']['country'] = ! empty($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : false;
894
+	$user['address']['zip']     = ! empty($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : false;
895
+
896
+	if (empty($user['address']['country'])) {
897 897
 		$user['address'] = false;
898 898
 	} // Country will always be set if address fields are present.
899 899
 
900
-	if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) {
900
+	if ( ! empty($user['user_id']) && $user['user_id'] > 0 && ! empty($user['address'])) {
901 901
 		// Store the address in the user's meta so the donation form can be pre-populated with it on return purchases.
902
-		update_user_meta( $user['user_id'], '_give_user_address', $user['address'] );
902
+		update_user_meta($user['user_id'], '_give_user_address', $user['address']);
903 903
 	}
904 904
 
905 905
 	// Return valid user.
@@ -918,16 +918,16 @@  discard block
 block discarded – undo
918 918
 	$card_data = give_get_purchase_cc_info();
919 919
 
920 920
 	// Validate the card zip.
921
-	if ( ! empty( $card_data['card_zip'] ) ) {
922
-		if ( ! give_purchase_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) {
923
-			give_set_error( 'invalid_cc_zip', esc_html__( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) );
921
+	if ( ! empty($card_data['card_zip'])) {
922
+		if ( ! give_purchase_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) {
923
+			give_set_error('invalid_cc_zip', esc_html__('The zip / postal code you entered for your billing address is invalid.', 'give'));
924 924
 		}
925 925
 	}
926 926
 
927 927
 	// Ensure no spaces.
928
-	if ( ! empty( $card_data['card_number'] ) ) {
929
-		$card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); // no "+" signs
930
-		$card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces
928
+	if ( ! empty($card_data['card_number'])) {
929
+		$card_data['card_number'] = str_replace('+', '', $card_data['card_number']); // no "+" signs
930
+		$card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces
931 931
 	}
932 932
 
933 933
 	// This should validate card numbers at some point too.
@@ -943,17 +943,17 @@  discard block
 block discarded – undo
943 943
  */
944 944
 function give_get_purchase_cc_info() {
945 945
 	$cc_info                   = array();
946
-	$cc_info['card_name']      = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : '';
947
-	$cc_info['card_number']    = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : '';
948
-	$cc_info['card_cvc']       = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : '';
949
-	$cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : '';
950
-	$cc_info['card_exp_year']  = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : '';
951
-	$cc_info['card_address']   = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : '';
952
-	$cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : '';
953
-	$cc_info['card_city']      = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : '';
954
-	$cc_info['card_state']     = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : '';
955
-	$cc_info['card_country']   = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : '';
956
-	$cc_info['card_zip']       = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : '';
946
+	$cc_info['card_name']      = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : '';
947
+	$cc_info['card_number']    = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : '';
948
+	$cc_info['card_cvc']       = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : '';
949
+	$cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : '';
950
+	$cc_info['card_exp_year']  = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : '';
951
+	$cc_info['card_address']   = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : '';
952
+	$cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : '';
953
+	$cc_info['card_city']      = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : '';
954
+	$cc_info['card_state']     = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : '';
955
+	$cc_info['card_country']   = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : '';
956
+	$cc_info['card_zip']       = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : '';
957 957
 
958 958
 	// Return cc info
959 959
 	return $cc_info;
@@ -969,14 +969,14 @@  discard block
 block discarded – undo
969 969
  *
970 970
  * @return bool|mixed|void
971 971
  */
972
-function give_purchase_form_validate_cc_zip( $zip = 0, $country_code = '' ) {
972
+function give_purchase_form_validate_cc_zip($zip = 0, $country_code = '') {
973 973
 	$ret = false;
974 974
 
975
-	if ( empty( $zip ) || empty( $country_code ) ) {
975
+	if (empty($zip) || empty($country_code)) {
976 976
 		return $ret;
977 977
 	}
978 978
 
979
-	$country_code = strtoupper( $country_code );
979
+	$country_code = strtoupper($country_code);
980 980
 
981 981
 	$zip_regex = array(
982 982
 		'AD' => 'AD\d{3}',
@@ -1136,11 +1136,11 @@  discard block
 block discarded – undo
1136 1136
 		'ZM' => '\d{5}',
1137 1137
 	);
1138 1138
 
1139
-	if ( ! isset( $zip_regex[ $country_code ] ) || preg_match( '/' . $zip_regex[ $country_code ] . '/i', $zip ) ) {
1139
+	if ( ! isset($zip_regex[$country_code]) || preg_match('/'.$zip_regex[$country_code].'/i', $zip)) {
1140 1140
 		$ret = true;
1141 1141
 	}
1142 1142
 
1143
-	return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code );
1143
+	return apply_filters('give_is_zip_valid', $ret, $zip, $country_code);
1144 1144
 }
1145 1145
 
1146 1146
 
@@ -1154,36 +1154,36 @@  discard block
 block discarded – undo
1154 1154
  *
1155 1155
  * @return bool
1156 1156
  */
1157
-function give_validate_multi_donation_form_level( $valid_data, $data ) {
1157
+function give_validate_multi_donation_form_level($valid_data, $data) {
1158 1158
 	/* @var Give_Donate_Form $form */
1159
-	$form = new Give_Donate_Form( $data['give-form-id'] );
1159
+	$form = new Give_Donate_Form($data['give-form-id']);
1160 1160
 
1161 1161
 	$donation_level_matched = false;
1162 1162
 
1163
-	if ( $form->is_multi_type_donation_form() ) {
1163
+	if ($form->is_multi_type_donation_form()) {
1164 1164
 
1165 1165
 		// Bailout.
1166
-		if ( ! ( $variable_prices = $form->get_prices() ) ) {
1166
+		if ( ! ($variable_prices = $form->get_prices())) {
1167 1167
 			return false;
1168 1168
 		}
1169 1169
 
1170 1170
 		// Sanitize donation amount.
1171
-		$data['give-amount'] = give_sanitize_amount( $data['give-amount'] );
1171
+		$data['give-amount'] = give_sanitize_amount($data['give-amount']);
1172 1172
 
1173 1173
 		// Get number of decimals.
1174 1174
 		$default_decimals = give_get_price_decimals();
1175 1175
 
1176
-		if ( $data['give-amount'] === give_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ), $default_decimals ) ) {
1176
+		if ($data['give-amount'] === give_sanitize_amount(give_get_price_option_amount($data['give-form-id'], $data['give-price-id']), $default_decimals)) {
1177 1177
 			return true;
1178 1178
 		}
1179 1179
 
1180 1180
 		// Find correct donation level from all donation levels.
1181
-		foreach ( $variable_prices as $variable_price ) {
1181
+		foreach ($variable_prices as $variable_price) {
1182 1182
 			// Sanitize level amount.
1183
-			$variable_price['_give_amount'] = give_sanitize_amount( $variable_price['_give_amount'], $default_decimals );
1183
+			$variable_price['_give_amount'] = give_sanitize_amount($variable_price['_give_amount'], $default_decimals);
1184 1184
 
1185 1185
 			// Set first match donation level ID.
1186
-			if ( $data['give-amount'] === $variable_price['_give_amount'] ) {
1186
+			if ($data['give-amount'] === $variable_price['_give_amount']) {
1187 1187
 				$_POST['give-price-id'] = $variable_price['_give_id']['level_id'];
1188 1188
 				$donation_level_matched = true;
1189 1189
 				break;
@@ -1194,19 +1194,19 @@  discard block
 block discarded – undo
1194 1194
 		// If yes then set price id to custom if amount is greater then custom minimum amount (if any).
1195 1195
 		if (
1196 1196
 			! $donation_level_matched
1197
-			&& ( 'yes' === get_post_meta( $data['give-form-id'], '_give_custom_amount', true ) )
1197
+			&& ('yes' === get_post_meta($data['give-form-id'], '_give_custom_amount', true))
1198 1198
 		) {
1199 1199
 			// Sanitize custom minimum amount.
1200
-			$custom_minimum_amount = give_sanitize_amount( get_post_meta( $data['give-form-id'], '_give_custom_amount_minimum', true ), $default_decimals );
1200
+			$custom_minimum_amount = give_sanitize_amount(get_post_meta($data['give-form-id'], '_give_custom_amount_minimum', true), $default_decimals);
1201 1201
 
1202
-			if ( $data['give-amount'] >= $custom_minimum_amount ) {
1202
+			if ($data['give-amount'] >= $custom_minimum_amount) {
1203 1203
 				$_POST['give-price-id'] = 'custom';
1204 1204
 				$donation_level_matched = true;
1205 1205
 			}
1206 1206
 		}
1207 1207
 	}
1208 1208
 
1209
-	return ( $donation_level_matched ? true : false );
1209
+	return ($donation_level_matched ? true : false);
1210 1210
 }
1211 1211
 
1212
-add_action( 'give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2 );
1212
+add_action('give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2);
Please login to merge, or discard this patch.
includes/class-give-email-access.php 1 patch
Spacing   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	public function __construct() {
97 97
 
98 98
 		// get it started
99
-		add_action( 'init', array( $this, 'init' ) );
99
+		add_action('init', array($this, 'init'));
100 100
 	}
101 101
 
102 102
 	/**
@@ -111,30 +111,30 @@  discard block
 block discarded – undo
111 111
 	 */
112 112
 	public function init() {
113 113
 
114
-		$is_enabled = give_get_option( 'email_access' );
114
+		$is_enabled = give_get_option('email_access');
115 115
 
116 116
 		//Non-logged in users only
117
-		if ( is_user_logged_in() || $is_enabled !== 'on' || is_admin() ) {
117
+		if (is_user_logged_in() || $is_enabled !== 'on' || is_admin()) {
118 118
 			return;
119 119
 		}
120 120
 
121 121
 		//Are db columns setup?
122
-		$is_setup = give_get_option( 'email_access_installed' );
123
-		if ( empty( $is_setup ) ) {
122
+		$is_setup = give_get_option('email_access_installed');
123
+		if (empty($is_setup)) {
124 124
 			$this->create_columns();
125 125
 		}
126 126
 
127 127
 		// Timeouts
128
-		$this->verify_throttle  = apply_filters( 'give_nl_verify_throttle', 300 );
129
-		$this->token_expiration = apply_filters( 'give_nl_token_expiration', 7200 );
128
+		$this->verify_throttle  = apply_filters('give_nl_verify_throttle', 300);
129
+		$this->token_expiration = apply_filters('give_nl_token_expiration', 7200);
130 130
 
131 131
 		// Setup login
132 132
 		$this->check_for_token();
133 133
 
134
-		if ( $this->token_exists ) {
135
-			add_filter( 'give_can_view_receipt', '__return_true' );
136
-			add_filter( 'give_user_pending_verification', '__return_false' );
137
-			add_filter( 'give_get_users_donations_args', array( $this, 'users_donations_args' ) );
134
+		if ($this->token_exists) {
135
+			add_filter('give_can_view_receipt', '__return_true');
136
+			add_filter('give_user_pending_verification', '__return_false');
137
+			add_filter('give_get_users_donations_args', array($this, 'users_donations_args'));
138 138
 		}
139 139
 	}
140 140
 
@@ -148,25 +148,25 @@  discard block
 block discarded – undo
148 148
 	 *
149 149
 	 * @return bool
150 150
 	 */
151
-	public function can_send_email( $customer_id ) {
151
+	public function can_send_email($customer_id) {
152 152
 		/* @var WPDB $wpdb */
153 153
 		global $wpdb;
154 154
 
155 155
 		// Prevent multiple emails within X minutes
156
-		$throttle = date( 'Y-m-d H:i:s', time() - $this->verify_throttle );
156
+		$throttle = date('Y-m-d H:i:s', time() - $this->verify_throttle);
157 157
 
158 158
 		// Does a user row exist?
159 159
 		$exists = (int) $wpdb->get_var(
160
-			$wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->prefix}give_customers WHERE id = %d", $customer_id )
160
+			$wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->prefix}give_customers WHERE id = %d", $customer_id)
161 161
 		);
162 162
 
163
-		if ( 0 < $exists ) {
163
+		if (0 < $exists) {
164 164
 			$row_id = (int) $wpdb->get_var(
165
-				$wpdb->prepare( "SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d AND (verify_throttle < %s OR verify_key = '') LIMIT 1", $customer_id, $throttle )
165
+				$wpdb->prepare("SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d AND (verify_throttle < %s OR verify_key = '') LIMIT 1", $customer_id, $throttle)
166 166
 			);
167 167
 
168
-			if ( $row_id < 1 ) {
169
-				give_set_error( 'give_email_access_attempts_exhausted', esc_html__( 'Please wait a few minutes before requesting a new email access link.', 'give' ) );
168
+			if ($row_id < 1) {
169
+				give_set_error('give_email_access_attempts_exhausted', esc_html__('Please wait a few minutes before requesting a new email access link.', 'give'));
170 170
 
171 171
 				return false;
172 172
 			}
@@ -186,34 +186,34 @@  discard block
 block discarded – undo
186 186
 	 *
187 187
 	 * @return void
188 188
 	 */
189
-	public function send_email( $customer_id, $email ) {
189
+	public function send_email($customer_id, $email) {
190 190
 
191
-		$verify_key = wp_generate_password( 20, false );
191
+		$verify_key = wp_generate_password(20, false);
192 192
 
193 193
 		// Generate a new verify key
194
-		$this->set_verify_key( $customer_id, $email, $verify_key );
194
+		$this->set_verify_key($customer_id, $email, $verify_key);
195 195
 
196 196
 		// Get the donation history page
197
-		$page_id = give_get_option( 'history_page' );
197
+		$page_id = give_get_option('history_page');
198 198
 
199
-		$access_url = add_query_arg( array(
199
+		$access_url = add_query_arg(array(
200 200
 			'give_nl' => $verify_key,
201
-		), get_permalink( $page_id ) );
201
+		), get_permalink($page_id));
202 202
 
203 203
 		//Nice subject and message
204
-		$subject = apply_filters( 'give_email_access_token_subject', sprintf( esc_html__( 'Your Access Link to %s', 'give' ), get_bloginfo( 'name' ) ) );
204
+		$subject = apply_filters('give_email_access_token_subject', sprintf(esc_html__('Your Access Link to %s', 'give'), get_bloginfo('name')));
205 205
 
206
-		$message = esc_html__( 'You or someone in your organization requested an access link be sent to this email address. This is a temporary access link for you to view your donation information. Click on the link below to view:', 'give' ) . "\n\n";
207
-		$message .= '<a href="' . esc_url( $access_url ) . '" target="_blank">' . esc_html__( 'Access My Donation Details &raquo;', 'give' ) . '</a>' . "\n\n";
206
+		$message = esc_html__('You or someone in your organization requested an access link be sent to this email address. This is a temporary access link for you to view your donation information. Click on the link below to view:', 'give')."\n\n";
207
+		$message .= '<a href="'.esc_url($access_url).'" target="_blank">'.esc_html__('Access My Donation Details &raquo;', 'give').'</a>'."\n\n";
208 208
 		$message .= "\n\n";
209
-		$message .= esc_html__( 'Sincerely,', 'give' ) . "\n";
210
-		$message .= get_bloginfo( 'name' ) . "\n";
209
+		$message .= esc_html__('Sincerely,', 'give')."\n";
210
+		$message .= get_bloginfo('name')."\n";
211 211
 
212
-		$message = apply_filters( 'give_email_access_token_message', $message );
212
+		$message = apply_filters('give_email_access_token_message', $message);
213 213
 
214 214
 		// Send the email
215
-		Give()->emails->__set( 'heading', apply_filters( 'give_email_access_token_heading', esc_html__( 'Your Access Link', 'give' ) ) );
216
-		Give()->emails->send( $email, $subject, $message );
215
+		Give()->emails->__set('heading', apply_filters('give_email_access_token_heading', esc_html__('Your Access Link', 'give')));
216
+		Give()->emails->send($email, $subject, $message);
217 217
 
218 218
 	}
219 219
 
@@ -227,24 +227,24 @@  discard block
 block discarded – undo
227 227
 	 */
228 228
 	public function check_for_token() {
229 229
 
230
-		$token = isset( $_GET['give_nl'] ) ? $_GET['give_nl'] : '';
230
+		$token = isset($_GET['give_nl']) ? $_GET['give_nl'] : '';
231 231
 
232 232
 		// Check for cookie
233
-		if ( empty( $token ) ) {
234
-			$token = isset( $_COOKIE['give_nl'] ) ? $_COOKIE['give_nl'] : '';
233
+		if (empty($token)) {
234
+			$token = isset($_COOKIE['give_nl']) ? $_COOKIE['give_nl'] : '';
235 235
 		}
236 236
 
237
-		if ( ! empty( $token ) ) {
238
-			if ( ! $this->is_valid_token( $token ) ) {
239
-				if ( ! $this->is_valid_verify_key( $token ) ) {
237
+		if ( ! empty($token)) {
238
+			if ( ! $this->is_valid_token($token)) {
239
+				if ( ! $this->is_valid_verify_key($token)) {
240 240
 					return;
241 241
 				}
242 242
 			}
243 243
 
244 244
 			$this->token_exists = true;
245 245
 			// Set cookie
246
-			$lifetime = current_time( 'timestamp' ) + Give()->session->set_expiration_time();
247
-			@setcookie( 'give_nl', $token, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false );
246
+			$lifetime = current_time('timestamp') + Give()->session->set_expiration_time();
247
+			@setcookie('give_nl', $token, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false);
248 248
 		}
249 249
 	}
250 250
 
@@ -258,18 +258,18 @@  discard block
 block discarded – undo
258 258
 	 *
259 259
 	 * @return bool
260 260
 	 */
261
-	public function is_valid_token( $token ) {
261
+	public function is_valid_token($token) {
262 262
 
263 263
 		global $wpdb;
264 264
 
265 265
 		// Make sure token isn't expired
266
-		$expires = date( 'Y-m-d H:i:s', time() - $this->token_expiration );
266
+		$expires = date('Y-m-d H:i:s', time() - $this->token_expiration);
267 267
 
268 268
 		$email = $wpdb->get_var(
269
-			$wpdb->prepare( "SELECT email FROM {$wpdb->prefix}give_customers WHERE token = %s AND verify_throttle >= %s LIMIT 1", $token, $expires )
269
+			$wpdb->prepare("SELECT email FROM {$wpdb->prefix}give_customers WHERE token = %s AND verify_throttle >= %s LIMIT 1", $token, $expires)
270 270
 		);
271 271
 
272
-		if ( ! empty( $email ) ) {
272
+		if ( ! empty($email)) {
273 273
 			$this->token_email = $email;
274 274
 			$this->token       = $token;
275 275
 
@@ -277,8 +277,8 @@  discard block
 block discarded – undo
277 277
 		}
278 278
 
279 279
 		//Set error only if email access form isn't being submitted
280
-		if ( ! isset( $_POST['give_email'] ) && ! isset( $_POST['_wpnonce'] ) ) {
281
-			give_set_error( 'give_email_token_expired', apply_filters( 'give_email_token_expired_message', esc_html__( 'Your access token has expired. Please request a new one below:', 'give' ) ) );
280
+		if ( ! isset($_POST['give_email']) && ! isset($_POST['_wpnonce'])) {
281
+			give_set_error('give_email_token_expired', apply_filters('give_email_token_expired_message', esc_html__('Your access token has expired. Please request a new one below:', 'give')));
282 282
 		}
283 283
 
284 284
 		return false;
@@ -297,25 +297,25 @@  discard block
 block discarded – undo
297 297
 	 *
298 298
 	 * @return void
299 299
 	 */
300
-	public function set_verify_key( $customer_id, $email, $verify_key ) {
300
+	public function set_verify_key($customer_id, $email, $verify_key) {
301 301
 		global $wpdb;
302 302
 
303
-		$now = date( 'Y-m-d H:i:s' );
303
+		$now = date('Y-m-d H:i:s');
304 304
 
305 305
 		// Insert or update?
306 306
 		$row_id = (int) $wpdb->get_var(
307
-			$wpdb->prepare( "SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d LIMIT 1", $customer_id )
307
+			$wpdb->prepare("SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d LIMIT 1", $customer_id)
308 308
 		);
309 309
 
310 310
 		// Update
311
-		if ( ! empty( $row_id ) ) {
311
+		if ( ! empty($row_id)) {
312 312
 			$wpdb->query(
313
-				$wpdb->prepare( "UPDATE {$wpdb->prefix}give_customers SET verify_key = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $verify_key, $now, $row_id )
313
+				$wpdb->prepare("UPDATE {$wpdb->prefix}give_customers SET verify_key = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $verify_key, $now, $row_id)
314 314
 			);
315 315
 		} // Insert
316 316
 		else {
317 317
 			$wpdb->query(
318
-				$wpdb->prepare( "INSERT INTO {$wpdb->prefix}give_customers ( verify_key, verify_throttle) VALUES (%s, %s)", $verify_key, $now )
318
+				$wpdb->prepare("INSERT INTO {$wpdb->prefix}give_customers ( verify_key, verify_throttle) VALUES (%s, %s)", $verify_key, $now)
319 319
 			);
320 320
 		}
321 321
 	}
@@ -330,21 +330,21 @@  discard block
 block discarded – undo
330 330
 	 *
331 331
 	 * @return bool
332 332
 	 */
333
-	public function is_valid_verify_key( $token ) {
333
+	public function is_valid_verify_key($token) {
334 334
 		/* @var WPDB $wpdb */
335 335
 		global $wpdb;
336 336
 
337 337
 		// See if the verify_key exists
338 338
 		$row = $wpdb->get_row(
339
-			$wpdb->prepare( "SELECT id, email FROM {$wpdb->prefix}give_customers WHERE verify_key = %s LIMIT 1", $token )
339
+			$wpdb->prepare("SELECT id, email FROM {$wpdb->prefix}give_customers WHERE verify_key = %s LIMIT 1", $token)
340 340
 		);
341 341
 
342
-		$now = date( 'Y-m-d H:i:s' );
342
+		$now = date('Y-m-d H:i:s');
343 343
 
344 344
 		// Set token
345
-		if ( ! empty( $row ) ) {
345
+		if ( ! empty($row)) {
346 346
 			$wpdb->query(
347
-				$wpdb->prepare( "UPDATE {$wpdb->prefix}give_customers SET verify_key = '', token = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $token, $now, $row->id )
347
+				$wpdb->prepare("UPDATE {$wpdb->prefix}give_customers SET verify_key = '', token = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $token, $now, $row->id)
348 348
 			);
349 349
 
350 350
 			$this->token_email = $row->email;
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 	 *
369 369
 	 * @return mixed
370 370
 	 */
371
-	public function users_donations_args( $args ) {
371
+	public function users_donations_args($args) {
372 372
 		$args['user'] = $this->token_email;
373 373
 
374 374
 		return $args;
@@ -389,11 +389,11 @@  discard block
 block discarded – undo
389 389
 		global $wpdb;
390 390
 
391 391
 		//Create columns in customers table
392
-		$query = $wpdb->query( "ALTER TABLE {$wpdb->prefix}give_customers ADD `token` VARCHAR(255) CHARACTER SET utf8 NOT NULL, ADD `verify_key` VARCHAR(255) CHARACTER SET utf8 NOT NULL AFTER `token`, ADD `verify_throttle` DATETIME NOT NULL AFTER `verify_key`" );
392
+		$query = $wpdb->query("ALTER TABLE {$wpdb->prefix}give_customers ADD `token` VARCHAR(255) CHARACTER SET utf8 NOT NULL, ADD `verify_key` VARCHAR(255) CHARACTER SET utf8 NOT NULL AFTER `token`, ADD `verify_throttle` DATETIME NOT NULL AFTER `verify_key`");
393 393
 
394 394
 		//Columns added properly
395
-		if ( $query ) {
396
-			give_update_option( 'email_access_installed', 1 );
395
+		if ($query) {
396
+			give_update_option('email_access_installed', 1);
397 397
 		}
398 398
 
399 399
 	}
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 = get_post_meta( $form_id, '_give_set_price', true );
105
+		$default_amount = get_post_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/scripts.php 1 patch
Spacing   +148 added lines, -148 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,105 +25,105 @@  discard block
 block discarded – undo
25 25
  */
26 26
 function give_load_scripts() {
27 27
 
28
-	$js_dir         = GIVE_PLUGIN_URL . 'assets/js/frontend/';
29
-	$js_plugins     = GIVE_PLUGIN_URL . 'assets/js/plugins/';
30
-	$scripts_footer = ( give_get_option( 'scripts_footer' ) == 'on' ) ? true : false;
28
+	$js_dir         = GIVE_PLUGIN_URL.'assets/js/frontend/';
29
+	$js_plugins     = GIVE_PLUGIN_URL.'assets/js/plugins/';
30
+	$scripts_footer = (give_get_option('scripts_footer') == 'on') ? true : false;
31 31
 
32 32
 	// Use minified libraries if SCRIPT_DEBUG is turned off.
33
-	$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
33
+	$suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
34 34
 
35 35
 	// Localize / PHP to AJAX vars.
36
-	$localize_give_checkout = apply_filters( 'give_global_script_vars', array(
36
+	$localize_give_checkout = apply_filters('give_global_script_vars', array(
37 37
 		'ajaxurl'             => give_get_ajax_url(),
38
-		'checkout_nonce'      => wp_create_nonce( 'give_checkout_nonce' ),
39
-		'currency_sign'       => give_currency_filter( '' ),
38
+		'checkout_nonce'      => wp_create_nonce('give_checkout_nonce'),
39
+		'currency_sign'       => give_currency_filter(''),
40 40
 		'currency_pos'        => give_get_currency_position(),
41 41
 		'thousands_separator' => give_get_price_thousand_separator(),
42 42
 		'decimal_separator'   => give_get_price_decimal_separator(),
43
-		'no_gateway'          => esc_html__( 'Please select a payment method.', 'give' ),
44
-		'bad_minimum'         => esc_html__( 'The minimum donation amount for this form is', 'give' ),
45
-		'general_loading'     => esc_html__( 'Loading...', 'give' ),
46
-		'purchase_loading'    => esc_html__( 'Please Wait...', 'give' ),
43
+		'no_gateway'          => esc_html__('Please select a payment method.', 'give'),
44
+		'bad_minimum'         => esc_html__('The minimum donation amount for this form is', 'give'),
45
+		'general_loading'     => esc_html__('Loading...', 'give'),
46
+		'purchase_loading'    => esc_html__('Please Wait...', 'give'),
47 47
 		'number_decimals'     => give_get_price_decimals(),
48 48
 		'give_version'        => GIVE_VERSION,
49 49
 		'form_translation'    => apply_filters(
50 50
 			'give_form_translation_js',
51 51
 			array(
52 52
 				// Field name               Validation message.
53
-				'payment-mode'           => esc_html__( 'Please select payment mode.', 'give' ),
54
-				'give_first'             => esc_html__( 'Please enter your first name.', 'give' ),
55
-				'give_email'             => esc_html__( 'Please enter a valid email address.', 'give' ),
56
-				'give_user_login'        => esc_html__( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ),
57
-				'give_user_pass'         => esc_html__( 'Enter a password.', 'give' ),
58
-				'give_user_pass_confirm' => esc_html__( 'Enter a confirm password.', 'give' ),
59
-				'give_agree_to_terms'    => esc_html__( 'You must agree to the terms and conditions.', 'give' ),
53
+				'payment-mode'           => esc_html__('Please select payment mode.', 'give'),
54
+				'give_first'             => esc_html__('Please enter your first name.', 'give'),
55
+				'give_email'             => esc_html__('Please enter a valid email address.', 'give'),
56
+				'give_user_login'        => esc_html__('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give'),
57
+				'give_user_pass'         => esc_html__('Enter a password.', 'give'),
58
+				'give_user_pass_confirm' => esc_html__('Enter a confirm password.', 'give'),
59
+				'give_agree_to_terms'    => esc_html__('You must agree to the terms and conditions.', 'give'),
60 60
 			)
61 61
 		),
62
-	) );
63
-	$localize_give_ajax     = apply_filters( 'give_global_ajax_vars', array(
62
+	));
63
+	$localize_give_ajax = apply_filters('give_global_ajax_vars', array(
64 64
 		'ajaxurl'         => give_get_ajax_url(),
65
-		'loading'         => esc_html__( 'Loading', 'give' ),
65
+		'loading'         => esc_html__('Loading', 'give'),
66 66
 		// General loading message.
67
-		'select_option'   => esc_html__( 'Please select an option', 'give' ),
67
+		'select_option'   => esc_html__('Please select an option', 'give'),
68 68
 		// Variable pricing error with multi-donation option enabled.
69
-		'default_gateway' => give_get_default_gateway( null ),
70
-		'permalinks'      => get_option( 'permalink_structure' ) ? '1' : '0',
69
+		'default_gateway' => give_get_default_gateway(null),
70
+		'permalinks'      => get_option('permalink_structure') ? '1' : '0',
71 71
 		'number_decimals' => give_get_price_decimals(),
72
-	) );
72
+	));
73 73
 
74 74
 	// DEBUG is On.
75
-	if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
75
+	if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) {
76 76
 
77
-		if ( give_is_cc_verify_enabled() ) {
78
-			wp_register_script( 'give-cc-validator', $js_plugins . 'jquery.payment' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
79
-			wp_enqueue_script( 'give-cc-validator' );
77
+		if (give_is_cc_verify_enabled()) {
78
+			wp_register_script('give-cc-validator', $js_plugins.'jquery.payment'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
79
+			wp_enqueue_script('give-cc-validator');
80 80
 		}
81 81
 
82
-		wp_register_script( 'give-float-labels', $js_plugins . 'float-labels' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
83
-		wp_enqueue_script( 'give-float-labels' );
82
+		wp_register_script('give-float-labels', $js_plugins.'float-labels'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
83
+		wp_enqueue_script('give-float-labels');
84 84
 
85
-		wp_register_script( 'give-blockui', $js_plugins . 'jquery.blockUI' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
86
-		wp_enqueue_script( 'give-blockui' );
85
+		wp_register_script('give-blockui', $js_plugins.'jquery.blockUI'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
86
+		wp_enqueue_script('give-blockui');
87 87
 
88
-		wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
89
-		wp_enqueue_script( 'give-qtip' );
88
+		wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
89
+		wp_enqueue_script('give-qtip');
90 90
 
91
-		wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
92
-		wp_enqueue_script( 'give-accounting' );
91
+		wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
92
+		wp_enqueue_script('give-accounting');
93 93
 
94
-		wp_register_script( 'give-magnific', $js_plugins . 'jquery.magnific-popup' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
95
-		wp_enqueue_script( 'give-magnific' );
94
+		wp_register_script('give-magnific', $js_plugins.'jquery.magnific-popup'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
95
+		wp_enqueue_script('give-magnific');
96 96
 
97
-		wp_register_script( 'give-checkout-global', $js_dir . 'give-checkout-global' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
98
-		wp_enqueue_script( 'give-checkout-global' );
97
+		wp_register_script('give-checkout-global', $js_dir.'give-checkout-global'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
98
+		wp_enqueue_script('give-checkout-global');
99 99
 
100 100
 		// General scripts.
101
-		wp_register_script( 'give-scripts', $js_dir . 'give' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
102
-		wp_enqueue_script( 'give-scripts' );
101
+		wp_register_script('give-scripts', $js_dir.'give'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
102
+		wp_enqueue_script('give-scripts');
103 103
 
104 104
 		// Load AJAX scripts, if enabled.
105
-		wp_register_script( 'give-ajax', $js_dir . 'give-ajax' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
106
-		wp_enqueue_script( 'give-ajax' );
105
+		wp_register_script('give-ajax', $js_dir.'give-ajax'.$suffix.'.js', array('jquery'), GIVE_VERSION, $scripts_footer);
106
+		wp_enqueue_script('give-ajax');
107 107
 
108 108
 		// Localize / Pass AJAX vars from PHP,
109
-		wp_localize_script( 'give-checkout-global', 'give_global_vars', $localize_give_checkout );
110
-		wp_localize_script( 'give-ajax', 'give_scripts', $localize_give_ajax );
109
+		wp_localize_script('give-checkout-global', 'give_global_vars', $localize_give_checkout);
110
+		wp_localize_script('give-ajax', 'give_scripts', $localize_give_ajax);
111 111
 
112 112
 	} else {
113 113
 
114 114
 		// DEBUG is OFF (one JS file to rule them all!).
115
-		wp_register_script( 'give', $js_dir . 'give.all.min.js', array( 'jquery' ), GIVE_VERSION, $scripts_footer );
116
-		wp_enqueue_script( 'give' );
115
+		wp_register_script('give', $js_dir.'give.all.min.js', array('jquery'), GIVE_VERSION, $scripts_footer);
116
+		wp_enqueue_script('give');
117 117
 
118 118
 		// Localize / Pass AJAX vars from PHP.
119
-		wp_localize_script( 'give', 'give_global_vars', $localize_give_checkout );
120
-		wp_localize_script( 'give', 'give_scripts', $localize_give_ajax );
119
+		wp_localize_script('give', 'give_global_vars', $localize_give_checkout);
120
+		wp_localize_script('give', 'give_scripts', $localize_give_ajax);
121 121
 
122 122
 	}
123 123
 
124 124
 }
125 125
 
126
-add_action( 'wp_enqueue_scripts', 'give_load_scripts' );
126
+add_action('wp_enqueue_scripts', 'give_load_scripts');
127 127
 
128 128
 /**
129 129
  * Register styles.
@@ -136,16 +136,16 @@  discard block
 block discarded – undo
136 136
  */
137 137
 function give_register_styles() {
138 138
 
139
-	if ( give_get_option( 'disable_css', false ) ) {
139
+	if (give_get_option('disable_css', false)) {
140 140
 		return;
141 141
 	}
142 142
 
143
-	wp_register_style( 'give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all' );
144
-	wp_enqueue_style( 'give-styles' );
143
+	wp_register_style('give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all');
144
+	wp_enqueue_style('give-styles');
145 145
 
146 146
 }
147 147
 
148
-add_action( 'wp_enqueue_scripts', 'give_register_styles' );
148
+add_action('wp_enqueue_scripts', 'give_register_styles');
149 149
 
150 150
 
151 151
 /**
@@ -158,42 +158,42 @@  discard block
 block discarded – undo
158 158
 function give_get_stylesheet_uri() {
159 159
 
160 160
 	// Use minified libraries if SCRIPT_DEBUG is turned off.
161
-	$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
161
+	$suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
162 162
 
163 163
 	// LTR or RTL files.
164
-	$direction = ( is_rtl() ) ? '-rtl' : '';
164
+	$direction = (is_rtl()) ? '-rtl' : '';
165 165
 
166
-	$file          = 'give' . $direction . $suffix . '.css';
166
+	$file          = 'give'.$direction.$suffix.'.css';
167 167
 	$templates_dir = give_get_theme_template_dir_name();
168 168
 
169
-	$child_theme_style_sheet    = trailingslashit( get_stylesheet_directory() ) . $templates_dir . $file;
170
-	$child_theme_style_sheet_2  = trailingslashit( get_stylesheet_directory() ) . $templates_dir . 'give' . $direction . '.css';
171
-	$parent_theme_style_sheet   = trailingslashit( get_template_directory() ) . $templates_dir . $file;
172
-	$parent_theme_style_sheet_2 = trailingslashit( get_template_directory() ) . $templates_dir . 'give' . $direction . '.css';
173
-	$give_plugin_style_sheet    = trailingslashit( give_get_templates_dir() ) . $file;
169
+	$child_theme_style_sheet    = trailingslashit(get_stylesheet_directory()).$templates_dir.$file;
170
+	$child_theme_style_sheet_2  = trailingslashit(get_stylesheet_directory()).$templates_dir.'give'.$direction.'.css';
171
+	$parent_theme_style_sheet   = trailingslashit(get_template_directory()).$templates_dir.$file;
172
+	$parent_theme_style_sheet_2 = trailingslashit(get_template_directory()).$templates_dir.'give'.$direction.'.css';
173
+	$give_plugin_style_sheet    = trailingslashit(give_get_templates_dir()).$file;
174 174
 
175 175
 	$uri = false;
176 176
 
177 177
 	// Look in the child theme directory first, followed by the parent theme,
178 178
 	// followed by the Give core templates directory also look for the min version first, followed by non minified version, even if SCRIPT_DEBUG is not enabled.
179 179
 	// This allows users to copy just give.css to their theme.
180
-	if ( file_exists( $child_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $child_theme_style_sheet_2 ) ) ) ) {
181
-		if ( ! empty( $nonmin ) ) {
182
-			$uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . 'give' . $direction . '.css';
180
+	if (file_exists($child_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($child_theme_style_sheet_2)))) {
181
+		if ( ! empty($nonmin)) {
182
+			$uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.'give'.$direction.'.css';
183 183
 		} else {
184
-			$uri = trailingslashit( get_stylesheet_directory_uri() ) . $templates_dir . $file;
184
+			$uri = trailingslashit(get_stylesheet_directory_uri()).$templates_dir.$file;
185 185
 		}
186
-	} elseif ( file_exists( $parent_theme_style_sheet ) || ( ! empty( $suffix ) && ( $nonmin = file_exists( $parent_theme_style_sheet_2 ) ) ) ) {
187
-		if ( ! empty( $nonmin ) ) {
188
-			$uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . 'give' . $direction . '.css';
186
+	} elseif (file_exists($parent_theme_style_sheet) || ( ! empty($suffix) && ($nonmin = file_exists($parent_theme_style_sheet_2)))) {
187
+		if ( ! empty($nonmin)) {
188
+			$uri = trailingslashit(get_template_directory_uri()).$templates_dir.'give'.$direction.'.css';
189 189
 		} else {
190
-			$uri = trailingslashit( get_template_directory_uri() ) . $templates_dir . $file;
190
+			$uri = trailingslashit(get_template_directory_uri()).$templates_dir.$file;
191 191
 		}
192
-	} elseif ( file_exists( $give_plugin_style_sheet ) || file_exists( $give_plugin_style_sheet ) ) {
193
-		$uri = trailingslashit( give_get_templates_url() ) . $file;
192
+	} elseif (file_exists($give_plugin_style_sheet) || file_exists($give_plugin_style_sheet)) {
193
+		$uri = trailingslashit(give_get_templates_url()).$file;
194 194
 	}
195 195
 
196
-	return apply_filters( 'give_get_stylesheet_uri', $uri );
196
+	return apply_filters('give_get_stylesheet_uri', $uri);
197 197
 
198 198
 }
199 199
 
@@ -210,70 +210,70 @@  discard block
 block discarded – undo
210 210
  *
211 211
  * @return void
212 212
  */
213
-function give_load_admin_scripts( $hook ) {
213
+function give_load_admin_scripts($hook) {
214 214
 
215 215
 	global $post, $post_type;
216 216
 
217 217
 	$give_options = give_get_settings();
218 218
 
219 219
 	// Directories of assets.
220
-	$js_dir     = GIVE_PLUGIN_URL . 'assets/js/admin/';
221
-	$js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/';
222
-	$css_dir    = GIVE_PLUGIN_URL . 'assets/css/';
220
+	$js_dir     = GIVE_PLUGIN_URL.'assets/js/admin/';
221
+	$js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/';
222
+	$css_dir    = GIVE_PLUGIN_URL.'assets/css/';
223 223
 
224 224
 	// Use minified libraries if SCRIPT_DEBUG is turned off.
225
-	$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
225
+	$suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
226 226
 
227 227
 	// LTR or RTL files.
228
-	$direction = ( is_rtl() ) ? '-rtl' : '';
228
+	$direction = (is_rtl()) ? '-rtl' : '';
229 229
 
230 230
 	// Global Admin.
231
-	wp_register_style( 'give-admin-bar-notification', $css_dir . 'adminbar-style.css' );
232
-	wp_enqueue_style( 'give-admin-bar-notification' );
231
+	wp_register_style('give-admin-bar-notification', $css_dir.'adminbar-style.css');
232
+	wp_enqueue_style('give-admin-bar-notification');
233 233
 
234 234
 	// Give Admin Only.
235
-	if ( ! apply_filters( 'give_load_admin_scripts', give_is_admin_page(), $hook ) ) {
235
+	if ( ! apply_filters('give_load_admin_scripts', give_is_admin_page(), $hook)) {
236 236
 		return;
237 237
 	}
238 238
 
239 239
 	// CSS.
240
-	wp_register_style( 'jquery-ui-css', $css_dir . 'jquery-ui-fresh' . $suffix . '.css' );
241
-	wp_enqueue_style( 'jquery-ui-css' );
242
-	wp_register_style( 'give-admin', $css_dir . 'give-admin' . $direction . $suffix . '.css', GIVE_VERSION );
243
-	wp_enqueue_style( 'give-admin' );
244
-	wp_register_style( 'jquery-chosen', $css_dir . 'chosen' . $suffix . '.css', array(), GIVE_VERSION );
245
-	wp_enqueue_style( 'jquery-chosen' );
246
-	wp_enqueue_style( 'thickbox' );
240
+	wp_register_style('jquery-ui-css', $css_dir.'jquery-ui-fresh'.$suffix.'.css');
241
+	wp_enqueue_style('jquery-ui-css');
242
+	wp_register_style('give-admin', $css_dir.'give-admin'.$direction.$suffix.'.css', GIVE_VERSION);
243
+	wp_enqueue_style('give-admin');
244
+	wp_register_style('jquery-chosen', $css_dir.'chosen'.$suffix.'.css', array(), GIVE_VERSION);
245
+	wp_enqueue_style('jquery-chosen');
246
+	wp_enqueue_style('thickbox');
247 247
 
248 248
 	// JS.
249
-	wp_register_script( 'jquery-chosen', $js_plugins . 'chosen.jquery' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION );
250
-	wp_enqueue_script( 'jquery-chosen' );
249
+	wp_register_script('jquery-chosen', $js_plugins.'chosen.jquery'.$suffix.'.js', array('jquery'), GIVE_VERSION);
250
+	wp_enqueue_script('jquery-chosen');
251 251
 
252
-	wp_register_script( 'give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
253
-	wp_enqueue_script( 'give-accounting' );
252
+	wp_register_script('give-accounting', $js_plugins.'accounting'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
253
+	wp_enqueue_script('give-accounting');
254 254
 
255
-	wp_register_script( 'give-admin-scripts', $js_dir . 'admin-scripts' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
256
-	wp_enqueue_script( 'give-admin-scripts' );
255
+	wp_register_script('give-admin-scripts', $js_dir.'admin-scripts'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
256
+	wp_enqueue_script('give-admin-scripts');
257 257
 
258
-	wp_register_script( 'jquery-flot', $js_plugins . 'jquery.flot' . $suffix . '.js' );
259
-	wp_enqueue_script( 'jquery-flot' );
258
+	wp_register_script('jquery-flot', $js_plugins.'jquery.flot'.$suffix.'.js');
259
+	wp_enqueue_script('jquery-flot');
260 260
 
261
-	wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
262
-	wp_enqueue_script( 'give-qtip' );
261
+	wp_register_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
262
+	wp_enqueue_script('give-qtip');
263 263
 
264
-	wp_enqueue_script( 'jquery-ui-datepicker' );
265
-	wp_enqueue_script( 'thickbox' );
264
+	wp_enqueue_script('jquery-ui-datepicker');
265
+	wp_enqueue_script('thickbox');
266 266
 
267 267
 	// Forms CPT Script.
268
-	if ( $post_type === 'give_forms' ) {
269
-		wp_register_script( 'give-admin-forms-scripts', $js_dir . 'admin-forms' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
270
-		wp_enqueue_script( 'give-admin-forms-scripts' );
268
+	if ($post_type === 'give_forms') {
269
+		wp_register_script('give-admin-forms-scripts', $js_dir.'admin-forms'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
270
+		wp_enqueue_script('give-admin-forms-scripts');
271 271
 	}
272 272
 
273 273
 	// Settings Scripts.
274
-	if ( isset( $_GET['page'] ) && $_GET['page'] == 'give-settings' ) {
275
-		wp_register_script( 'give-admin-settings-scripts', $js_dir . 'admin-settings' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
276
-		wp_enqueue_script( 'give-admin-settings-scripts' );
274
+	if (isset($_GET['page']) && $_GET['page'] == 'give-settings') {
275
+		wp_register_script('give-admin-settings-scripts', $js_dir.'admin-settings'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
276
+		wp_enqueue_script('give-admin-settings-scripts');
277 277
 	}
278 278
 
279 279
 	// Price Separators.
@@ -281,46 +281,46 @@  discard block
 block discarded – undo
281 281
 	$decimal_separator  = give_get_price_decimal_separator();
282 282
 
283 283
 	// Localize strings & variables for JS.
284
-	wp_localize_script( 'give-admin-scripts', 'give_vars', array(
285
-		'post_id'                 => isset( $post->ID ) ? $post->ID : null,
284
+	wp_localize_script('give-admin-scripts', 'give_vars', array(
285
+		'post_id'                 => isset($post->ID) ? $post->ID : null,
286 286
 		'give_version'            => GIVE_VERSION,
287 287
 		'thousands_separator'     => $thousand_separator,
288 288
 		'decimal_separator'       => $decimal_separator,
289
-		'quick_edit_warning'      => esc_html__( 'Not available for variable priced forms.', 'give' ),
290
-		'delete_payment'         => esc_html__( 'Are you sure you wish to delete this payment?', 'give' ),
291
-		'delete_payment_note'    => esc_html__( 'Are you sure you wish to delete this note?', 'give' ),
292
-		'revoke_api_key'          => esc_html__( 'Are you sure you wish to revoke this API key?', 'give' ),
293
-		'regenerate_api_key'      => esc_html__( 'Are you sure you wish to regenerate this API key?', 'give' ),
294
-		'resend_receipt'          => esc_html__( 'Are you sure you wish to resend the donation receipt?', 'give' ),
295
-		'copy_download_link_text' => esc_html__( 'Copy these links to your clipboard and give them to your donor.', 'give' ),
296
-		'delete_payment_download' => esc_html__( 'Are you sure you wish to delete this form?', 'give' ),
297
-		'one_price_min'           => esc_html__( 'You must have at least one price.', 'give' ),
298
-		'one_file_min'            => esc_html__( 'You must have at least one file.', 'give' ),
299
-		'one_field_min'           => esc_html__( 'You must have at least one field.', 'give' ),
300
-		'one_option'              => esc_html__( 'Choose a form', 'give' ),
301
-		'one_or_more_option'      => esc_html__( 'Choose one or more forms', 'give' ),
302
-		'numeric_item_price'      => esc_html__( 'Item price must be numeric.', 'give' ),
303
-		'numeric_quantity'        => esc_html__( 'Quantity must be numeric.', 'give' ),
304
-		'currency_sign'           => give_currency_filter( '' ),
305
-		'currency_pos'            => isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before',
306
-		'currency_decimals'       => give_currency_decimal_filter( give_get_price_decimals() ),
307
-		'new_media_ui'            => apply_filters( 'give_use_35_media_ui', 1 ),
308
-		'remove_text'             => esc_html__( 'Remove', 'give' ),
309
-		'type_to_search'          => esc_html__( 'Type to search forms', 'give' ),
310
-		'batch_export_no_class'   => esc_html__( 'You must choose a method.', 'give' ),
311
-		'batch_export_no_reqs'    => esc_html__( 'Required fields not completed.', 'give' ),
312
-		'reset_stats_warn'        => __( 'Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give' ),
313
-		'price_format_guide'      => sprintf( esc_html__( 'Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give' ), $decimal_separator, $thousand_separator ),
314
-	) );
315
-
316
-	if ( function_exists( 'wp_enqueue_media' ) && version_compare( get_bloginfo( 'version' ), '3.5', '>=' ) ) {
289
+		'quick_edit_warning'      => esc_html__('Not available for variable priced forms.', 'give'),
290
+		'delete_payment'         => esc_html__('Are you sure you wish to delete this payment?', 'give'),
291
+		'delete_payment_note'    => esc_html__('Are you sure you wish to delete this note?', 'give'),
292
+		'revoke_api_key'          => esc_html__('Are you sure you wish to revoke this API key?', 'give'),
293
+		'regenerate_api_key'      => esc_html__('Are you sure you wish to regenerate this API key?', 'give'),
294
+		'resend_receipt'          => esc_html__('Are you sure you wish to resend the donation receipt?', 'give'),
295
+		'copy_download_link_text' => esc_html__('Copy these links to your clipboard and give them to your donor.', 'give'),
296
+		'delete_payment_download' => esc_html__('Are you sure you wish to delete this form?', 'give'),
297
+		'one_price_min'           => esc_html__('You must have at least one price.', 'give'),
298
+		'one_file_min'            => esc_html__('You must have at least one file.', 'give'),
299
+		'one_field_min'           => esc_html__('You must have at least one field.', 'give'),
300
+		'one_option'              => esc_html__('Choose a form', 'give'),
301
+		'one_or_more_option'      => esc_html__('Choose one or more forms', 'give'),
302
+		'numeric_item_price'      => esc_html__('Item price must be numeric.', 'give'),
303
+		'numeric_quantity'        => esc_html__('Quantity must be numeric.', 'give'),
304
+		'currency_sign'           => give_currency_filter(''),
305
+		'currency_pos'            => isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before',
306
+		'currency_decimals'       => give_currency_decimal_filter(give_get_price_decimals()),
307
+		'new_media_ui'            => apply_filters('give_use_35_media_ui', 1),
308
+		'remove_text'             => esc_html__('Remove', 'give'),
309
+		'type_to_search'          => esc_html__('Type to search forms', 'give'),
310
+		'batch_export_no_class'   => esc_html__('You must choose a method.', 'give'),
311
+		'batch_export_no_reqs'    => esc_html__('Required fields not completed.', 'give'),
312
+		'reset_stats_warn'        => __('Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give'),
313
+		'price_format_guide'      => sprintf(esc_html__('Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give'), $decimal_separator, $thousand_separator),
314
+	));
315
+
316
+	if (function_exists('wp_enqueue_media') && version_compare(get_bloginfo('version'), '3.5', '>=')) {
317 317
 		// call for new media manager.
318 318
 		wp_enqueue_media();
319 319
 	}
320 320
 
321 321
 }
322 322
 
323
-add_action( 'admin_enqueue_scripts', 'give_load_admin_scripts', 100 );
323
+add_action('admin_enqueue_scripts', 'give_load_admin_scripts', 100);
324 324
 
325 325
 /**
326 326
  * Admin Give Icon
@@ -335,13 +335,13 @@  discard block
 block discarded – undo
335 335
 	?>
336 336
 	<style type="text/css" media="screen">
337 337
 
338
-		<?php if ( version_compare( get_bloginfo( 'version' ), '3.8-RC', '>=' ) || version_compare( get_bloginfo( 'version' ), '3.8', '>=' ) ) { ?>
338
+		<?php if (version_compare(get_bloginfo('version'), '3.8-RC', '>=') || version_compare(get_bloginfo('version'), '3.8', '>=')) { ?>
339 339
 		@font-face {
340 340
 			font-family: 'give-icomoon';
341
-			src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?-ngjl88'; ?>');
342
-			src: url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.eot?#iefix-ngjl88'?>') format('embedded-opentype'),
343
-			url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.woff?-ngjl88'; ?>') format('woff'),
344
-			url('<?php echo GIVE_PLUGIN_URL . '/assets/fonts/icomoon.svg?-ngjl88#icomoon'; ?>') format('svg');
341
+			src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?-ngjl88'; ?>');
342
+			src: url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.eot?#iefix-ngjl88'?>') format('embedded-opentype'),
343
+			url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.woff?-ngjl88'; ?>') format('woff'),
344
+			url('<?php echo GIVE_PLUGIN_URL.'/assets/fonts/icomoon.svg?-ngjl88#icomoon'; ?>') format('svg');
345 345
 			font-weight: normal;
346 346
 			font-style: normal;
347 347
 		}
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 	<?php
361 361
 }
362 362
 
363
-add_action( 'admin_head', 'give_admin_icon' );
363
+add_action('admin_head', 'give_admin_icon');
364 364
 
365 365
 /**
366 366
  * Admin js code
@@ -390,4 +390,4 @@  discard block
 block discarded – undo
390 390
 	<?php
391 391
 }
392 392
 
393
-add_action( 'admin_head', 'give_admin_hide_notice_shortly_js' );
393
+add_action('admin_head', 'give_admin_hide_notice_shortly_js');
Please login to merge, or discard this patch.
includes/class-give-roles.php 1 patch
Spacing   +58 added lines, -58 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
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 * @access public
36 36
 	 */
37 37
 	public function __construct() {
38
-		add_filter( 'give_map_meta_cap', array( $this, 'meta_caps' ), 10, 4 );
38
+		add_filter('give_map_meta_cap', array($this, 'meta_caps'), 10, 4);
39 39
 	}
40 40
 
41 41
 	/**
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	 * @return void
50 50
 	 */
51 51
 	public function add_roles() {
52
-		add_role( 'give_manager', esc_html__( 'Give Manager', 'give' ), array(
52
+		add_role('give_manager', esc_html__('Give Manager', 'give'), array(
53 53
 			'read'                   => true,
54 54
 			'edit_posts'             => true,
55 55
 			'delete_posts'           => true,
@@ -78,20 +78,20 @@  discard block
 block discarded – undo
78 78
 			'publish_posts'          => true,
79 79
 			'read_private_pages'     => true,
80 80
 			'read_private_posts'     => true
81
-		) );
81
+		));
82 82
 
83
-		add_role( 'give_accountant', esc_html__( 'Give Accountant', 'give' ), array(
83
+		add_role('give_accountant', esc_html__('Give Accountant', 'give'), array(
84 84
 			'read'         => true,
85 85
 			'edit_posts'   => false,
86 86
 			'delete_posts' => false
87
-		) );
87
+		));
88 88
 
89
-		add_role( 'give_worker', esc_html__( 'Give Worker', 'give' ), array(
89
+		add_role('give_worker', esc_html__('Give Worker', 'give'), array(
90 90
 			'read'         => true,
91 91
 			'edit_posts'   => false,
92 92
 			'upload_files' => true,
93 93
 			'delete_posts' => false
94
-		) );
94
+		));
95 95
 
96 96
 	}
97 97
 
@@ -110,38 +110,38 @@  discard block
 block discarded – undo
110 110
 	public function add_caps() {
111 111
 		global $wp_roles;
112 112
 
113
-		if ( class_exists( 'WP_Roles' ) ) {
114
-			if ( ! isset( $wp_roles ) ) {
113
+		if (class_exists('WP_Roles')) {
114
+			if ( ! isset($wp_roles)) {
115 115
 				$wp_roles = new WP_Roles();
116 116
 			}
117 117
 		}
118 118
 
119
-		if ( is_object( $wp_roles ) ) {
120
-			$wp_roles->add_cap( 'give_manager', 'view_give_reports' );
121
-			$wp_roles->add_cap( 'give_manager', 'view_give_sensitive_data' );
122
-			$wp_roles->add_cap( 'give_manager', 'export_give_reports' );
123
-			$wp_roles->add_cap( 'give_manager', 'manage_give_settings' );
119
+		if (is_object($wp_roles)) {
120
+			$wp_roles->add_cap('give_manager', 'view_give_reports');
121
+			$wp_roles->add_cap('give_manager', 'view_give_sensitive_data');
122
+			$wp_roles->add_cap('give_manager', 'export_give_reports');
123
+			$wp_roles->add_cap('give_manager', 'manage_give_settings');
124 124
 
125
-			$wp_roles->add_cap( 'administrator', 'view_give_reports' );
126
-			$wp_roles->add_cap( 'administrator', 'view_give_sensitive_data' );
127
-			$wp_roles->add_cap( 'administrator', 'export_give_reports' );
128
-			$wp_roles->add_cap( 'administrator', 'manage_give_settings' );
125
+			$wp_roles->add_cap('administrator', 'view_give_reports');
126
+			$wp_roles->add_cap('administrator', 'view_give_sensitive_data');
127
+			$wp_roles->add_cap('administrator', 'export_give_reports');
128
+			$wp_roles->add_cap('administrator', 'manage_give_settings');
129 129
 
130 130
 			// Add the main post type capabilities.
131 131
 			$capabilities = $this->get_core_caps();
132
-			foreach ( $capabilities as $cap_group ) {
133
-				foreach ( $cap_group as $cap ) {
134
-					$wp_roles->add_cap( 'administrator', $cap );
135
-					$wp_roles->add_cap( 'give_manager', $cap );
136
-					$wp_roles->add_cap( 'give_worker', $cap );
132
+			foreach ($capabilities as $cap_group) {
133
+				foreach ($cap_group as $cap) {
134
+					$wp_roles->add_cap('administrator', $cap);
135
+					$wp_roles->add_cap('give_manager', $cap);
136
+					$wp_roles->add_cap('give_worker', $cap);
137 137
 				}
138 138
 			}
139 139
 
140
-			$wp_roles->add_cap( 'give_accountant', 'edit_give_forms' );
141
-			$wp_roles->add_cap( 'give_accountant', 'read_private_give_forms' );
142
-			$wp_roles->add_cap( 'give_accountant', 'view_give_reports' );
143
-			$wp_roles->add_cap( 'give_accountant', 'export_give_reports' );
144
-			$wp_roles->add_cap( 'give_accountant', 'edit_give_payments' );
140
+			$wp_roles->add_cap('give_accountant', 'edit_give_forms');
141
+			$wp_roles->add_cap('give_accountant', 'read_private_give_forms');
142
+			$wp_roles->add_cap('give_accountant', 'view_give_reports');
143
+			$wp_roles->add_cap('give_accountant', 'export_give_reports');
144
+			$wp_roles->add_cap('give_accountant', 'edit_give_payments');
145 145
 
146 146
 		}
147 147
 	}
@@ -159,10 +159,10 @@  discard block
 block discarded – undo
159 159
 	public function get_core_caps() {
160 160
 		$capabilities = array();
161 161
 
162
-		$capability_types = array( 'give_form', 'give_payment' );
162
+		$capability_types = array('give_form', 'give_payment');
163 163
 
164
-		foreach ( $capability_types as $capability_type ) {
165
-			$capabilities[ $capability_type ] = array(
164
+		foreach ($capability_types as $capability_type) {
165
+			$capabilities[$capability_type] = array(
166 166
 				// Post type.
167 167
 				"edit_{$capability_type}",
168 168
 				"read_{$capability_type}",
@@ -208,22 +208,22 @@  discard block
 block discarded – undo
208 208
 	 *
209 209
 	 * @return array  $caps    Meta capabilities.
210 210
 	 */
211
-	public function meta_caps( $caps, $cap, $user_id, $args ) {
211
+	public function meta_caps($caps, $cap, $user_id, $args) {
212 212
 
213
-		switch ( $cap ) {
213
+		switch ($cap) {
214 214
 
215 215
 			case 'view_give_form_stats' :
216 216
 
217
-				if ( empty( $args[0] ) ) {
217
+				if (empty($args[0])) {
218 218
 					break;
219 219
 				}
220 220
 
221
-				$form = get_post( $args[0] );
222
-				if ( empty( $form ) ) {
221
+				$form = get_post($args[0]);
222
+				if (empty($form)) {
223 223
 					break;
224 224
 				}
225 225
 
226
-				if ( user_can( $user_id, 'view_give_reports' ) || $user_id == $form->post_author ) {
226
+				if (user_can($user_id, 'view_give_reports') || $user_id == $form->post_author) {
227 227
 					$caps = array();
228 228
 				}
229 229
 
@@ -250,41 +250,41 @@  discard block
 block discarded – undo
250 250
 
251 251
 		global $wp_roles;
252 252
 
253
-		if ( class_exists( 'WP_Roles' ) ) {
254
-			if ( ! isset( $wp_roles ) ) {
253
+		if (class_exists('WP_Roles')) {
254
+			if ( ! isset($wp_roles)) {
255 255
 				$wp_roles = new WP_Roles();
256 256
 			}
257 257
 		}
258 258
 
259
-		if ( is_object( $wp_roles ) ) {
259
+		if (is_object($wp_roles)) {
260 260
 			// Give Manager Capabilities.
261
-			$wp_roles->remove_cap( 'give_manager', 'view_give_reports' );
262
-			$wp_roles->remove_cap( 'give_manager', 'view_give_sensitive_data' );
263
-			$wp_roles->remove_cap( 'give_manager', 'export_give_reports' );
264
-			$wp_roles->remove_cap( 'give_manager', 'manage_give_settings' );
261
+			$wp_roles->remove_cap('give_manager', 'view_give_reports');
262
+			$wp_roles->remove_cap('give_manager', 'view_give_sensitive_data');
263
+			$wp_roles->remove_cap('give_manager', 'export_give_reports');
264
+			$wp_roles->remove_cap('give_manager', 'manage_give_settings');
265 265
 
266 266
 			// Site Administrator Capabilities.
267
-			$wp_roles->remove_cap( 'administrator', 'view_give_reports' );
268
-			$wp_roles->remove_cap( 'administrator', 'view_give_sensitive_data' );
269
-			$wp_roles->remove_cap( 'administrator', 'export_give_reports' );
270
-			$wp_roles->remove_cap( 'administrator', 'manage_give_settings' );
267
+			$wp_roles->remove_cap('administrator', 'view_give_reports');
268
+			$wp_roles->remove_cap('administrator', 'view_give_sensitive_data');
269
+			$wp_roles->remove_cap('administrator', 'export_give_reports');
270
+			$wp_roles->remove_cap('administrator', 'manage_give_settings');
271 271
 
272 272
 			// Remove the Main Post Type Capabilities.
273 273
 			$capabilities = $this->get_core_caps();
274 274
 
275
-			foreach ( $capabilities as $cap_group ) {
276
-				foreach ( $cap_group as $cap ) {
277
-					$wp_roles->remove_cap( 'give_manager', $cap );
278
-					$wp_roles->remove_cap( 'administrator', $cap );
279
-					$wp_roles->remove_cap( 'give_worker', $cap );
275
+			foreach ($capabilities as $cap_group) {
276
+				foreach ($cap_group as $cap) {
277
+					$wp_roles->remove_cap('give_manager', $cap);
278
+					$wp_roles->remove_cap('administrator', $cap);
279
+					$wp_roles->remove_cap('give_worker', $cap);
280 280
 				}
281 281
 			}
282 282
 
283 283
 			/** Give Accountant Capabilities */
284
-			$wp_roles->remove_cap( 'give_accountant', 'edit_give_forms' );
285
-			$wp_roles->remove_cap( 'give_accountant', 'read_private_give_forms' );
286
-			$wp_roles->remove_cap( 'give_accountant', 'view_give_reports' );
287
-			$wp_roles->remove_cap( 'give_accountant', 'export_give_reports' );
284
+			$wp_roles->remove_cap('give_accountant', 'edit_give_forms');
285
+			$wp_roles->remove_cap('give_accountant', 'read_private_give_forms');
286
+			$wp_roles->remove_cap('give_accountant', 'view_give_reports');
287
+			$wp_roles->remove_cap('give_accountant', 'export_give_reports');
288 288
 
289 289
 		}
290 290
 	}
Please login to merge, or discard this patch.
includes/admin/upgrades/upgrade-functions.php 1 patch
Spacing   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  */
14 14
 
15 15
 // Exit if accessed directly.
16
-if ( ! defined( 'ABSPATH' ) ) {
16
+if ( ! defined('ABSPATH')) {
17 17
 	exit;
18 18
 }
19 19
 
@@ -26,30 +26,30 @@  discard block
 block discarded – undo
26 26
  */
27 27
 function give_do_automatic_upgrades() {
28 28
 	$did_upgrade  = false;
29
-	$give_version = preg_replace( '/[^0-9.].*/', '', get_option( 'give_version' ) );
29
+	$give_version = preg_replace('/[^0-9.].*/', '', get_option('give_version'));
30 30
 
31
-	if ( ! $give_version ) {
31
+	if ( ! $give_version) {
32 32
 		// 1.0 is the first version to use this option so we must add it.
33 33
 		$give_version = '1.0';
34 34
 	}
35 35
 
36
-	switch ( true ) {
36
+	switch (true) {
37 37
 
38
-		case version_compare( $give_version, '1.6', '<' ) :
38
+		case version_compare($give_version, '1.6', '<') :
39 39
 			give_v16_upgrades();
40 40
 			$did_upgrade = true;
41 41
 
42
-		case version_compare( $give_version, '1.7', '<' ) :
42
+		case version_compare($give_version, '1.7', '<') :
43 43
 			give_v17_upgrades();
44 44
 			$did_upgrade = true;
45 45
 	}
46 46
 
47
-	if ( $did_upgrade ) {
48
-		update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) );
47
+	if ($did_upgrade) {
48
+		update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION));
49 49
 	}
50 50
 }
51 51
 
52
-add_action( 'admin_init', 'give_do_automatic_upgrades' );
52
+add_action('admin_init', 'give_do_automatic_upgrades');
53 53
 
54 54
 /**
55 55
  * Display Upgrade Notices
@@ -59,18 +59,18 @@  discard block
 block discarded – undo
59 59
  */
60 60
 function give_show_upgrade_notices() {
61 61
 
62
-	if ( isset( $_GET['page'] ) && $_GET['page'] == 'give-upgrades' ) {
62
+	if (isset($_GET['page']) && $_GET['page'] == 'give-upgrades') {
63 63
 		return;
64 64
 	} // Don't show notices on the upgrades page
65 65
 
66
-	$give_version = get_option( 'give_version' );
66
+	$give_version = get_option('give_version');
67 67
 
68
-	if ( ! $give_version ) {
68
+	if ( ! $give_version) {
69 69
 		// 1.0 is the first version to use this option so we must add it
70 70
 		$give_version = '1.0';
71 71
 	}
72 72
 
73
-	$give_version = preg_replace( '/[^0-9.].*/', '', $give_version );
73
+	$give_version = preg_replace('/[^0-9.].*/', '', $give_version);
74 74
 
75 75
 	/*
76 76
 	 *  NOTICE:
@@ -81,20 +81,20 @@  discard block
 block discarded – undo
81 81
 	 */
82 82
 
83 83
 	//v1.3.2 Upgrades
84
-	if ( version_compare( $give_version, '1.3.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_payment_customer_id' ) ) {
84
+	if (version_compare($give_version, '1.3.2', '<') || ! give_has_upgrade_completed('upgrade_give_payment_customer_id')) {
85 85
 		printf(
86 86
 		/* translators: %s: upgrade URL */
87
-			'<div class="updated"><p>' . __( 'Give needs to upgrade the donor database, click <a href="%s">here</a> to start the upgrade.', 'give' ) . '</p></div>',
88
-			esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=upgrade_give_payment_customer_id' ) )
87
+			'<div class="updated"><p>'.__('Give needs to upgrade the donor database, click <a href="%s">here</a> to start the upgrade.', 'give').'</p></div>',
88
+			esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=upgrade_give_payment_customer_id'))
89 89
 		);
90 90
 	}
91 91
 
92 92
 	//v1.3.4 Upgrades //ensure the user has gone through 1.3.4
93
-	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' ) ) ) {
93
+	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'))) {
94 94
 		printf(
95 95
 		/* translators: %s: upgrade URL */
96
-			'<div class="updated"><p>' . __( 'Give needs to upgrade the donations database, click <a href="%s">here</a> to start the upgrade.', 'give' ) . '</p></div>',
97
-			esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=upgrade_give_offline_status' ) )
96
+			'<div class="updated"><p>'.__('Give needs to upgrade the donations database, click <a href="%s">here</a> to start the upgrade.', 'give').'</p></div>',
97
+			esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=upgrade_give_offline_status'))
98 98
 		);
99 99
 	}
100 100
 
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 
105 105
 }
106 106
 
107
-add_action( 'admin_notices', 'give_show_upgrade_notices' );
107
+add_action('admin_notices', 'give_show_upgrade_notices');
108 108
 
109 109
 /**
110 110
  * Triggers all upgrade functions
@@ -116,26 +116,26 @@  discard block
 block discarded – undo
116 116
  */
117 117
 function give_trigger_upgrades() {
118 118
 
119
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
120
-		wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
119
+	if ( ! current_user_can('manage_give_settings')) {
120
+		wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
121 121
 	}
122 122
 
123
-	$give_version = get_option( 'give_version' );
123
+	$give_version = get_option('give_version');
124 124
 
125
-	if ( ! $give_version ) {
125
+	if ( ! $give_version) {
126 126
 		// 1.0 is the first version to use this option so we must add it
127 127
 		$give_version = '1.0';
128
-		add_option( 'give_version', $give_version );
128
+		add_option('give_version', $give_version);
129 129
 	}
130 130
 
131
-	update_option( 'give_version', GIVE_VERSION );
131
+	update_option('give_version', GIVE_VERSION);
132 132
 
133
-	if ( DOING_AJAX ) {
134
-		die( 'complete' );
133
+	if (DOING_AJAX) {
134
+		die('complete');
135 135
 	} // Let AJAX know that the upgrade is complete
136 136
 }
137 137
 
138
-add_action( 'wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades' );
138
+add_action('wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades');
139 139
 
140 140
 /**
141 141
  * Check if the upgrade routine has been run for a specific action
@@ -146,15 +146,15 @@  discard block
 block discarded – undo
146 146
  *
147 147
  * @return bool                   If the action has been added to the completed actions array
148 148
  */
149
-function give_has_upgrade_completed( $upgrade_action = '' ) {
149
+function give_has_upgrade_completed($upgrade_action = '') {
150 150
 
151
-	if ( empty( $upgrade_action ) ) {
151
+	if (empty($upgrade_action)) {
152 152
 		return false;
153 153
 	}
154 154
 
155 155
 	$completed_upgrades = give_get_completed_upgrades();
156 156
 
157
-	return in_array( $upgrade_action, $completed_upgrades );
157
+	return in_array($upgrade_action, $completed_upgrades);
158 158
 
159 159
 }
160 160
 
@@ -167,9 +167,9 @@  discard block
 block discarded – undo
167 167
  *
168 168
  * @return bool                   If the function was successfully added
169 169
  */
170
-function give_set_upgrade_complete( $upgrade_action = '' ) {
170
+function give_set_upgrade_complete($upgrade_action = '') {
171 171
 
172
-	if ( empty( $upgrade_action ) ) {
172
+	if (empty($upgrade_action)) {
173 173
 		return false;
174 174
 	}
175 175
 
@@ -177,9 +177,9 @@  discard block
 block discarded – undo
177 177
 	$completed_upgrades[] = $upgrade_action;
178 178
 
179 179
 	// Remove any blanks, and only show uniques
180
-	$completed_upgrades = array_unique( array_values( $completed_upgrades ) );
180
+	$completed_upgrades = array_unique(array_values($completed_upgrades));
181 181
 
182
-	return update_option( 'give_completed_upgrades', $completed_upgrades );
182
+	return update_option('give_completed_upgrades', $completed_upgrades);
183 183
 }
184 184
 
185 185
 /**
@@ -190,9 +190,9 @@  discard block
 block discarded – undo
190 190
  */
191 191
 function give_get_completed_upgrades() {
192 192
 
193
-	$completed_upgrades = get_option( 'give_completed_upgrades' );
193
+	$completed_upgrades = get_option('give_completed_upgrades');
194 194
 
195
-	if ( false === $completed_upgrades ) {
195
+	if (false === $completed_upgrades) {
196 196
 		$completed_upgrades = array();
197 197
 	}
198 198
 
@@ -210,30 +210,30 @@  discard block
 block discarded – undo
210 210
  */
211 211
 function give_v132_upgrade_give_payment_customer_id() {
212 212
 	global $wpdb;
213
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
214
-		wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
213
+	if ( ! current_user_can('manage_give_settings')) {
214
+		wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
215 215
 	}
216 216
 
217
-	ignore_user_abort( true );
217
+	ignore_user_abort(true);
218 218
 
219
-	if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
220
-		@set_time_limit( 0 );
219
+	if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
220
+		@set_time_limit(0);
221 221
 	}
222 222
 
223 223
 	//UPDATE DB METAKEYS
224 224
 	$sql   = "UPDATE $wpdb->postmeta SET meta_key = '_give_payment_customer_id' WHERE meta_key = '_give_payment_donor_id'";
225
-	$query = $wpdb->query( $sql );
225
+	$query = $wpdb->query($sql);
226 226
 
227
-	update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) );
228
-	give_set_upgrade_complete( 'upgrade_give_payment_customer_id' );
229
-	delete_option( 'give_doing_upgrade' );
230
-	wp_redirect( admin_url() );
227
+	update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION));
228
+	give_set_upgrade_complete('upgrade_give_payment_customer_id');
229
+	delete_option('give_doing_upgrade');
230
+	wp_redirect(admin_url());
231 231
 	exit;
232 232
 
233 233
 
234 234
 }
235 235
 
236
-add_action( 'give_upgrade_give_payment_customer_id', 'give_v132_upgrade_give_payment_customer_id' );
236
+add_action('give_upgrade_give_payment_customer_id', 'give_v132_upgrade_give_payment_customer_id');
237 237
 
238 238
 /**
239 239
  * Upgrades the Offline Status
@@ -247,14 +247,14 @@  discard block
 block discarded – undo
247 247
 
248 248
 	global $wpdb;
249 249
 
250
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
251
-		wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
250
+	if ( ! current_user_can('manage_give_settings')) {
251
+		wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
252 252
 	}
253 253
 
254
-	ignore_user_abort( true );
254
+	ignore_user_abort(true);
255 255
 
256
-	if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
257
-		@set_time_limit( 0 );
256
+	if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
257
+		@set_time_limit(0);
258 258
 	}
259 259
 
260 260
 	// Get abandoned offline payments
@@ -264,35 +264,35 @@  discard block
 block discarded – undo
264 264
 	$where .= "AND ( p.post_status = 'abandoned' )";
265 265
 	$where .= "AND ( m.meta_key = '_give_payment_gateway' AND m.meta_value = 'offline' )";
266 266
 
267
-	$sql            = $select . $join . $where;
268
-	$found_payments = $wpdb->get_col( $sql );
267
+	$sql            = $select.$join.$where;
268
+	$found_payments = $wpdb->get_col($sql);
269 269
 
270 270
 
271
-	foreach ( $found_payments as $payment ) {
271
+	foreach ($found_payments as $payment) {
272 272
 
273 273
 		//Only change ones marked abandoned since our release last week
274 274
 		//because the admin may have marked some abandoned themselves
275
-		$modified_time = get_post_modified_time( 'U', false, $payment );
275
+		$modified_time = get_post_modified_time('U', false, $payment);
276 276
 
277 277
 		//1450124863 =  12/10/2015 20:42:25
278
-		if ( $modified_time >= 1450124863 ) {
278
+		if ($modified_time >= 1450124863) {
279 279
 
280
-			give_update_payment_status( $payment, 'pending' );
280
+			give_update_payment_status($payment, 'pending');
281 281
 
282 282
 		}
283 283
 
284 284
 	}
285 285
 
286
-	update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) );
287
-	give_set_upgrade_complete( 'upgrade_give_offline_status' );
288
-	delete_option( 'give_doing_upgrade' );
289
-	wp_redirect( admin_url() );
286
+	update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION));
287
+	give_set_upgrade_complete('upgrade_give_offline_status');
288
+	delete_option('give_doing_upgrade');
289
+	wp_redirect(admin_url());
290 290
 	exit;
291 291
 
292 292
 
293 293
 }
294 294
 
295
-add_action( 'give_upgrade_give_offline_status', 'give_v134_upgrade_give_offline_status' );
295
+add_action('give_upgrade_give_offline_status', 'give_v134_upgrade_give_offline_status');
296 296
 
297 297
 /**
298 298
  * Cleanup User Roles
@@ -303,17 +303,17 @@  discard block
 block discarded – undo
303 303
  */
304 304
 function give_v152_cleanup_users() {
305 305
 
306
-	$give_version = get_option( 'give_version' );
306
+	$give_version = get_option('give_version');
307 307
 
308
-	if ( ! $give_version ) {
308
+	if ( ! $give_version) {
309 309
 		// 1.0 is the first version to use this option so we must add it
310 310
 		$give_version = '1.0';
311 311
 	}
312 312
 
313
-	$give_version = preg_replace( '/[^0-9.].*/', '', $give_version );
313
+	$give_version = preg_replace('/[^0-9.].*/', '', $give_version);
314 314
 
315 315
 	//v1.5.2 Upgrades
316
-	if ( version_compare( $give_version, '1.5.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_user_caps_cleanup' ) ) {
316
+	if (version_compare($give_version, '1.5.2', '<') || ! give_has_upgrade_completed('upgrade_give_user_caps_cleanup')) {
317 317
 
318 318
 		//Delete all caps with "ss"
319 319
 		//Also delete all unused "campaign" roles
@@ -360,9 +360,9 @@  discard block
 block discarded – undo
360 360
 		);
361 361
 
362 362
 		global $wp_roles;
363
-		foreach ( $delete_caps as $cap ) {
364
-			foreach ( array_keys( $wp_roles->roles ) as $role ) {
365
-				$wp_roles->remove_cap( $role, $cap );
363
+		foreach ($delete_caps as $cap) {
364
+			foreach (array_keys($wp_roles->roles) as $role) {
365
+				$wp_roles->remove_cap($role, $cap);
366 366
 			}
367 367
 		}
368 368
 
@@ -372,15 +372,15 @@  discard block
 block discarded – undo
372 372
 		$roles->add_caps();
373 373
 
374 374
 		//The Update Ran
375
-		update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) );
376
-		give_set_upgrade_complete( 'upgrade_give_user_caps_cleanup' );
377
-		delete_option( 'give_doing_upgrade' );
375
+		update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION));
376
+		give_set_upgrade_complete('upgrade_give_user_caps_cleanup');
377
+		delete_option('give_doing_upgrade');
378 378
 
379 379
 	}
380 380
 
381 381
 }
382 382
 
383
-add_action( 'admin_init', 'give_v152_cleanup_users' );
383
+add_action('admin_init', 'give_v152_cleanup_users');
384 384
 
385 385
 /**
386 386
  * 1.6 Upgrade routine to create the customer meta table.
@@ -418,53 +418,53 @@  discard block
 block discarded – undo
418 418
 
419 419
 	// Get addons license key.
420 420
 	$addons = array();
421
-	foreach ( $give_options as $key => $value ) {
422
-		if ( false !== strpos( $key, '_license_key' ) ) {
423
-			$addons[ $key ] = $value;
421
+	foreach ($give_options as $key => $value) {
422
+		if (false !== strpos($key, '_license_key')) {
423
+			$addons[$key] = $value;
424 424
 		}
425 425
 	}
426 426
 
427 427
 	// Bailout: We do not have any addon license data to upgrade.
428
-	if ( empty( $addons ) ) {
428
+	if (empty($addons)) {
429 429
 		return false;
430 430
 	}
431 431
 
432
-	foreach ( $addons as $key => $addon_license ) {
432
+	foreach ($addons as $key => $addon_license) {
433 433
 
434 434
 		// Get addon shortname.
435
-		$shortname = str_replace( '_license_key', '', $key );
435
+		$shortname = str_replace('_license_key', '', $key);
436 436
 
437 437
 		// Addon license option name.
438
-		$addon_license_option_name = $shortname . '_license_active';
438
+		$addon_license_option_name = $shortname.'_license_active';
439 439
 
440 440
 		// bailout if license is empty.
441
-		if ( empty( $addon_license ) ) {
442
-			delete_option( $addon_license_option_name );
441
+		if (empty($addon_license)) {
442
+			delete_option($addon_license_option_name);
443 443
 			continue;
444 444
 		}
445 445
 
446 446
 		// Get addon name.
447 447
 		$addon_name       = array();
448
-		$addon_name_parts = explode( '_', str_replace( 'give_', '', $shortname ) );
449
-		foreach ( $addon_name_parts as $name_part ) {
448
+		$addon_name_parts = explode('_', str_replace('give_', '', $shortname));
449
+		foreach ($addon_name_parts as $name_part) {
450 450
 
451 451
 			// Fix addon name
452
-			switch ( $name_part ) {
452
+			switch ($name_part) {
453 453
 				case 'authorizenet' :
454 454
 					$name_part = 'authorize.net';
455 455
 					break;
456 456
 			}
457 457
 
458
-			$addon_name[] = ucfirst( $name_part );
458
+			$addon_name[] = ucfirst($name_part);
459 459
 		}
460 460
 
461
-		$addon_name = implode( ' ', $addon_name );
461
+		$addon_name = implode(' ', $addon_name);
462 462
 
463 463
 		// Data to send to the API
464 464
 		$api_params = array(
465 465
 			'edd_action' => 'activate_license', //never change from "edd_" to "give_"!
466 466
 			'license'    => $addon_license,
467
-			'item_name'  => urlencode( $addon_name ),
467
+			'item_name'  => urlencode($addon_name),
468 468
 			'url'        => home_url()
469 469
 		);
470 470
 
@@ -479,17 +479,17 @@  discard block
 block discarded – undo
479 479
 		);
480 480
 
481 481
 		// Make sure there are no errors
482
-		if ( is_wp_error( $response ) ) {
483
-			delete_option( $addon_license_option_name );
482
+		if (is_wp_error($response)) {
483
+			delete_option($addon_license_option_name);
484 484
 			continue;
485 485
 		}
486 486
 
487 487
 		// Tell WordPress to look for updates
488
-		set_site_transient( 'update_plugins', null );
488
+		set_site_transient('update_plugins', null);
489 489
 
490 490
 		// Decode license data
491
-		$license_data = json_decode( wp_remote_retrieve_body( $response ) );
492
-		update_option( $addon_license_option_name, $license_data );
491
+		$license_data = json_decode(wp_remote_retrieve_body($response));
492
+		update_option($addon_license_option_name, $license_data);
493 493
 	}
494 494
 }
495 495
 
@@ -519,9 +519,9 @@  discard block
 block discarded – undo
519 519
 	);
520 520
 
521 521
 	global $wp_roles;
522
-	foreach ( $delete_caps as $cap ) {
523
-		foreach ( array_keys( $wp_roles->roles ) as $role ) {
524
-			$wp_roles->remove_cap( $role, $cap );
522
+	foreach ($delete_caps as $cap) {
523
+		foreach (array_keys($wp_roles->roles) as $role) {
524
+			$wp_roles->remove_cap($role, $cap);
525 525
 		}
526 526
 	}
527 527
 
Please login to merge, or discard this patch.