Completed
Pull Request — master (#1619)
by Ravinder
17:48
created
includes/admin/class-admin-settings.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -725,9 +725,9 @@
 block discarded – undo
725 725
                         <td class="give-docs-link" colspan="2">
726 726
 							<?php
727 727
 							echo '<p class="give-docs-link"><a href="' . esc_url( $value['url'] )
728
-							     . '" target="_blank">'
729
-							     . sprintf( esc_html__( 'Need Help? See docs on "%s"' ), $value['title'] )
730
-							     . '<span class="dashicons dashicons-editor-help"></span></a></p>';
728
+								 . '" target="_blank">'
729
+								 . sprintf( esc_html__( 'Need Help? See docs on "%s"' ), $value['title'] )
730
+								 . '<span class="dashicons dashicons-editor-help"></span></a></p>';
731 731
 							?>
732 732
                         </td>
733 733
                         </tr><?php
Please login to merge, or discard this patch.
Spacing   +205 added lines, -205 removed lines patch added patch discarded remove patch
@@ -9,11 +9,11 @@  discard block
 block discarded – undo
9 9
  * @since       1.8
10 10
  */
11 11
 
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit;
14 14
 }
15 15
 
16
-if ( ! class_exists( 'Give_Admin_Settings' ) ) :
16
+if ( ! class_exists('Give_Admin_Settings')) :
17 17
 
18 18
 	/**
19 19
 	 * Give_Admin_Settings Class.
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 			 *
73 73
 			 * @param array $settings Array of settings class object.
74 74
 			 */
75
-			self::$settings = apply_filters( self::$setting_filter_prefix . '_get_settings_pages', array() );
75
+			self::$settings = apply_filters(self::$setting_filter_prefix.'_get_settings_pages', array());
76 76
 
77 77
 			return self::$settings;
78 78
 		}
@@ -86,8 +86,8 @@  discard block
 block discarded – undo
86 86
 		public static function save() {
87 87
 			$current_tab = give_get_current_setting_tab();
88 88
 
89
-			if ( empty( $_REQUEST['_give-save-settings'] ) || ! wp_verify_nonce( $_REQUEST['_give-save-settings'], 'give-save-settings' ) ) {
90
-				echo '<div class="notice error"><p>' . __( 'Action failed. Please refresh the page and retry.', 'give' ) . '</p></div>';
89
+			if (empty($_REQUEST['_give-save-settings']) || ! wp_verify_nonce($_REQUEST['_give-save-settings'], 'give-save-settings')) {
90
+				echo '<div class="notice error"><p>'.__('Action failed. Please refresh the page and retry.', 'give').'</p></div>';
91 91
 				die();
92 92
 			}
93 93
 
@@ -100,9 +100,9 @@  discard block
 block discarded – undo
100 100
 			 *
101 101
 			 * @since 1.8
102 102
 			 */
103
-			do_action( self::$setting_filter_prefix . '_save_' . $current_tab );
103
+			do_action(self::$setting_filter_prefix.'_save_'.$current_tab);
104 104
 
105
-			self::add_message( 'give-setting-updated', __( 'Your settings have been saved.', 'give' ) );
105
+			self::add_message('give-setting-updated', __('Your settings have been saved.', 'give'));
106 106
 
107 107
 			/**
108 108
 			 * Trigger Action.
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 			 *
114 114
 			 * @since 1.8
115 115
 			 */
116
-			do_action( self::$setting_filter_prefix . '_saved' );
116
+			do_action(self::$setting_filter_prefix.'_saved');
117 117
 		}
118 118
 
119 119
 		/**
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
 		 *
127 127
 		 * @return void
128 128
 		 */
129
-		public static function add_message( $code, $message ) {
130
-			self::$messages[ $code ] = $message;
129
+		public static function add_message($code, $message) {
130
+			self::$messages[$code] = $message;
131 131
 		}
132 132
 
133 133
 		/**
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
 		 *
141 141
 		 * @return void
142 142
 		 */
143
-		public static function add_error( $code, $message ) {
144
-			self::$errors[ $code ] = $message;
143
+		public static function add_error($code, $message) {
144
+			self::$errors[$code] = $message;
145 145
 		}
146 146
 
147 147
 		/**
@@ -154,18 +154,18 @@  discard block
 block discarded – undo
154 154
 			$notice_html = '';
155 155
 			$classes     = 'give-notice settings-error notice is-dismissible';
156 156
 
157
-			self::$errors   = apply_filters( self::$setting_filter_prefix . '_error_notices', self::$errors );
158
-			self::$messages = apply_filters( self::$setting_filter_prefix . '_update_notices', self::$messages );
157
+			self::$errors   = apply_filters(self::$setting_filter_prefix.'_error_notices', self::$errors);
158
+			self::$messages = apply_filters(self::$setting_filter_prefix.'_update_notices', self::$messages);
159 159
 
160
-			if ( 0 < count( self::$errors ) ) {
161
-				foreach ( self::$errors as $code => $message ) {
162
-					$notice_html .= '<div id="setting-error-' . $code . '" class="' . $classes . ' error"><p><strong>' . $message . '</strong></p></div>';
160
+			if (0 < count(self::$errors)) {
161
+				foreach (self::$errors as $code => $message) {
162
+					$notice_html .= '<div id="setting-error-'.$code.'" class="'.$classes.' error"><p><strong>'.$message.'</strong></p></div>';
163 163
 				}
164 164
 			}
165 165
 
166
-			if ( 0 < count( self::$messages ) ) {
167
-				foreach ( self::$messages as $code => $message ) {
168
-					$notice_html .= '<div id="setting-error-' . $code . '" class="' . $classes . ' updated"><p><strong>' . $message . '</strong></p></div>';
166
+			if (0 < count(self::$messages)) {
167
+				foreach (self::$messages as $code => $message) {
168
+					$notice_html .= '<div id="setting-error-'.$code.'" class="'.$classes.' updated"><p><strong>'.$message.'</strong></p></div>';
169 169
 				}
170 170
 			}
171 171
 
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 			self::$setting_filter_prefix = give_get_current_setting_page();
186 186
 
187 187
 			// Bailout: Exit if setting page is not defined.
188
-			if ( empty( self::$setting_filter_prefix ) ) {
188
+			if (empty(self::$setting_filter_prefix)) {
189 189
 				return false;
190 190
 			}
191 191
 
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 			 *
199 199
 			 * @since 1.8
200 200
 			 */
201
-			do_action( self::$setting_filter_prefix . '_start' );
201
+			do_action(self::$setting_filter_prefix.'_start');
202 202
 
203 203
 			$current_tab = give_get_current_setting_tab();
204 204
 
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 			self::get_settings_pages();
207 207
 
208 208
 			// Save settings if data has been posted.
209
-			if ( ! empty( $_POST ) ) {
209
+			if ( ! empty($_POST)) {
210 210
 				self::save();
211 211
 			}
212 212
 
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 			 *
220 220
 			 * @since 1.8
221 221
 			 */
222
-			$tabs = apply_filters( self::$setting_filter_prefix . '_tabs_array', array() );
222
+			$tabs = apply_filters(self::$setting_filter_prefix.'_tabs_array', array());
223 223
 
224 224
 			include 'views/html-admin-settings.php';
225 225
 
@@ -237,25 +237,25 @@  discard block
 block discarded – undo
237 237
 		 *
238 238
 		 * @return string|bool
239 239
 		 */
240
-		public static function get_option( $option_name = '', $field_id = '', $default = false ) {
240
+		public static function get_option($option_name = '', $field_id = '', $default = false) {
241 241
 			// Bailout.
242
-			if ( empty( $option_name ) && empty( $field_id ) ) {
242
+			if (empty($option_name) && empty($field_id)) {
243 243
 				return false;
244 244
 			}
245 245
 
246
-			if ( ! empty( $field_id ) && ! empty( $option_name ) ) {
246
+			if ( ! empty($field_id) && ! empty($option_name)) {
247 247
 				// Get field value if any.
248
-				$option_value = get_option( $option_name );
248
+				$option_value = get_option($option_name);
249 249
 
250
-				$option_value = ( is_array( $option_value ) && array_key_exists( $field_id, $option_value ) )
251
-					? $option_value[ $field_id ]
250
+				$option_value = (is_array($option_value) && array_key_exists($field_id, $option_value))
251
+					? $option_value[$field_id]
252 252
 					: $default;
253 253
 			} else {
254 254
 				// If option name is empty but not field name then this means, setting is direct store to option table under there field name.
255 255
 				$option_name = ! $option_name ? $field_id : $option_name;
256 256
 
257 257
 				// Get option value if any.
258
-				$option_value = get_option( $option_name, $default );
258
+				$option_value = get_option($option_name, $default);
259 259
 			}
260 260
 
261 261
 			return $option_value;
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 		 *
274 274
 		 * @return void
275 275
 		 */
276
-		public static function output_fields( $options, $option_name = '' ) {
276
+		public static function output_fields($options, $option_name = '') {
277 277
 			$current_tab = give_get_current_setting_tab();
278 278
 
279 279
 			// Field Default values.
@@ -286,52 +286,52 @@  discard block
 block discarded – undo
286 286
 				'table_html' => true,
287 287
 			);
288 288
 
289
-			foreach ( $options as $value ) {
290
-				if ( ! isset( $value['type'] ) ) {
289
+			foreach ($options as $value) {
290
+				if ( ! isset($value['type'])) {
291 291
 					continue;
292 292
 				}
293 293
 
294 294
 				// Set title.
295
-				$defaults['title'] = isset( $value['name'] ) ? $value['name'] : '';
295
+				$defaults['title'] = isset($value['name']) ? $value['name'] : '';
296 296
 
297 297
 				// Set default setting.
298
-				$value = wp_parse_args( $value, $defaults );
298
+				$value = wp_parse_args($value, $defaults);
299 299
 
300 300
 				// Colorpicker field.
301
-				$value['class'] = ( 'colorpicker' === $value['type'] ? trim( $value['class'] ) . ' give-colorpicker' : $value['class'] );
302
-				$value['type']  = ( 'colorpicker' === $value['type'] ? 'text' : $value['type'] );
301
+				$value['class'] = ('colorpicker' === $value['type'] ? trim($value['class']).' give-colorpicker' : $value['class']);
302
+				$value['type']  = ('colorpicker' === $value['type'] ? 'text' : $value['type']);
303 303
 
304 304
 
305 305
 				// Custom attribute handling.
306 306
 				$custom_attributes = array();
307 307
 
308
-				if ( ! empty( $value['attributes'] ) && is_array( $value['attributes'] ) ) {
309
-					foreach ( $value['attributes'] as $attribute => $attribute_value ) {
310
-						$custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"';
308
+				if ( ! empty($value['attributes']) && is_array($value['attributes'])) {
309
+					foreach ($value['attributes'] as $attribute => $attribute_value) {
310
+						$custom_attributes[] = esc_attr($attribute).'="'.esc_attr($attribute_value).'"';
311 311
 					}
312 312
 				}
313 313
 
314 314
 				// Description handling.
315
-				$description          = self::get_field_description( $value );
315
+				$description = self::get_field_description($value);
316 316
 
317 317
 				// Switch based on type.
318
-				switch ( $value['type'] ) {
318
+				switch ($value['type']) {
319 319
 
320 320
 					// Section Titles
321 321
 					case 'title':
322
-						if ( ! empty( $value['title'] ) ) {
323
-							echo '<div class="give-setting-tab-header give-setting-tab-header-' . $current_tab . '"><h2>' . self::get_field_title( $value ) . '</h2><hr></div>';
322
+						if ( ! empty($value['title'])) {
323
+							echo '<div class="give-setting-tab-header give-setting-tab-header-'.$current_tab.'"><h2>'.self::get_field_title($value).'</h2><hr></div>';
324 324
 						}
325 325
 
326
-						if ( ! empty( $value['desc'] ) ) {
327
-							echo wpautop( wptexturize( wp_kses_post( $value['desc'] ) ) );
326
+						if ( ! empty($value['desc'])) {
327
+							echo wpautop(wptexturize(wp_kses_post($value['desc'])));
328 328
 						}
329 329
 
330
-						if ( $value['table_html'] ) {
331
-							echo '<table class="form-table give-setting-tab-body give-setting-tab-body-' . $current_tab . '">' . "\n\n";
330
+						if ($value['table_html']) {
331
+							echo '<table class="form-table give-setting-tab-body give-setting-tab-body-'.$current_tab.'">'."\n\n";
332 332
 						}
333 333
 
334
-						if ( ! empty( $value['id'] ) ) {
334
+						if ( ! empty($value['id'])) {
335 335
 
336 336
 							/**
337 337
 							 * Trigger Action.
@@ -340,14 +340,14 @@  discard block
 block discarded – undo
340 340
 							 *
341 341
 							 * @since 1.8
342 342
 							 */
343
-							do_action( 'give_settings_' . sanitize_title( $value['id'] ) );
343
+							do_action('give_settings_'.sanitize_title($value['id']));
344 344
 						}
345 345
 
346 346
 						break;
347 347
 
348 348
 					// Section Ends.
349 349
 					case 'sectionend':
350
-						if ( ! empty( $value['id'] ) ) {
350
+						if ( ! empty($value['id'])) {
351 351
 
352 352
 							/**
353 353
 							 * Trigger Action.
@@ -356,14 +356,14 @@  discard block
 block discarded – undo
356 356
 							 *
357 357
 							 * @since 1.8
358 358
 							 */
359
-							do_action( 'give_settings_' . sanitize_title( $value['id'] ) . '_end' );
359
+							do_action('give_settings_'.sanitize_title($value['id']).'_end');
360 360
 						}
361 361
 
362
-						if ( $value['table_html'] ) {
362
+						if ($value['table_html']) {
363 363
 							echo '</table>';
364 364
 						}
365 365
 
366
-						if ( ! empty( $value['id'] ) ) {
366
+						if ( ! empty($value['id'])) {
367 367
 
368 368
 							/**
369 369
 							 * Trigger Action.
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
 							 *
373 373
 							 * @since 1.8
374 374
 							 */
375
-							do_action( 'give_settings_' . sanitize_title( $value['id'] ) . '_after' );
375
+							do_action('give_settings_'.sanitize_title($value['id']).'_after');
376 376
 						}
377 377
 
378 378
 						break;
@@ -385,22 +385,22 @@  discard block
 block discarded – undo
385 385
 					case 'password' :
386 386
 
387 387
 						$type = $value['type'];
388
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
388
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
389 389
 
390 390
 						?>
391
-                    <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
391
+                    <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
392 392
                         <th scope="row" class="titledesc">
393
-                            <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
393
+                            <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
394 394
                         </th>
395
-                        <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>">
395
+                        <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>">
396 396
                             <input
397
-                                    name="<?php echo esc_attr( $value['id'] ); ?>"
398
-                                    id="<?php echo esc_attr( $value['id'] ); ?>"
399
-                                    type="<?php echo esc_attr( $type ); ?>"
400
-                                    style="<?php echo esc_attr( $value['css'] ); ?>"
401
-                                    value="<?php echo esc_attr( $option_value ); ?>"
402
-                                    class="give-input-field<?php echo( empty( $value['class'] ) ? '' : ' ' . esc_attr( $value['class'] ) ); ?>"
403
-								<?php echo implode( ' ', $custom_attributes ); ?>
397
+                                    name="<?php echo esc_attr($value['id']); ?>"
398
+                                    id="<?php echo esc_attr($value['id']); ?>"
399
+                                    type="<?php echo esc_attr($type); ?>"
400
+                                    style="<?php echo esc_attr($value['css']); ?>"
401
+                                    value="<?php echo esc_attr($option_value); ?>"
402
+                                    class="give-input-field<?php echo(empty($value['class']) ? '' : ' '.esc_attr($value['class'])); ?>"
403
+								<?php echo implode(' ', $custom_attributes); ?>
404 404
                             /> <?php echo $description; ?>
405 405
                         </td>
406 406
                         </tr><?php
@@ -409,23 +409,23 @@  discard block
 block discarded – undo
409 409
 					// Textarea.
410 410
 					case 'textarea':
411 411
 
412
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
412
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
413 413
 
414 414
 						?>
415
-                    <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
415
+                    <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
416 416
                         <th scope="row" class="titledesc">
417
-                            <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
417
+                            <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
418 418
                         </th>
419
-                        <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>">
419
+                        <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>">
420 420
 								<textarea
421
-                                        name="<?php echo esc_attr( $value['id'] ); ?>"
422
-                                        id="<?php echo esc_attr( $value['id'] ); ?>"
423
-                                        style="<?php echo esc_attr( $value['css'] ); ?>"
424
-                                        class="<?php echo esc_attr( $value['class'] ); ?>"
421
+                                        name="<?php echo esc_attr($value['id']); ?>"
422
+                                        id="<?php echo esc_attr($value['id']); ?>"
423
+                                        style="<?php echo esc_attr($value['css']); ?>"
424
+                                        class="<?php echo esc_attr($value['class']); ?>"
425 425
                                         rows="10"
426 426
                                         cols="60"
427
-									<?php echo implode( ' ', $custom_attributes ); ?>
428
-                                ><?php echo esc_textarea( $option_value ); ?></textarea>
427
+									<?php echo implode(' ', $custom_attributes); ?>
428
+                                ><?php echo esc_textarea($option_value); ?></textarea>
429 429
 							<?php echo $description; ?>
430 430
                         </td>
431 431
                         </tr><?php
@@ -435,35 +435,35 @@  discard block
 block discarded – undo
435 435
 					case 'select' :
436 436
 					case 'multiselect' :
437 437
 
438
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
438
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
439 439
 
440 440
 						?>
441
-                    <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
441
+                    <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
442 442
                         <th scope="row" class="titledesc">
443
-                            <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
443
+                            <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
444 444
                         </th>
445
-                        <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>">
445
+                        <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>">
446 446
                             <select
447
-                                    name="<?php echo esc_attr( $value['id'] ); ?><?php if ( $value['type'] == 'multiselect' ) {
447
+                                    name="<?php echo esc_attr($value['id']); ?><?php if ($value['type'] == 'multiselect') {
448 448
 										echo '[]';
449 449
 									} ?>"
450
-                                    id="<?php echo esc_attr( $value['id'] ); ?>"
451
-                                    style="<?php echo esc_attr( $value['css'] ); ?>"
452
-                                    class="<?php echo esc_attr( $value['class'] ); ?>"
453
-								<?php echo implode( ' ', $custom_attributes ); ?>
454
-								<?php echo ( 'multiselect' == $value['type'] ) ? 'multiple="multiple"' : ''; ?>
450
+                                    id="<?php echo esc_attr($value['id']); ?>"
451
+                                    style="<?php echo esc_attr($value['css']); ?>"
452
+                                    class="<?php echo esc_attr($value['class']); ?>"
453
+								<?php echo implode(' ', $custom_attributes); ?>
454
+								<?php echo ('multiselect' == $value['type']) ? 'multiple="multiple"' : ''; ?>
455 455
                             >
456 456
 
457 457
 								<?php
458
-								if ( ! empty( $value['options'] ) ) {
459
-									foreach ( $value['options'] as $key => $val ) {
458
+								if ( ! empty($value['options'])) {
459
+									foreach ($value['options'] as $key => $val) {
460 460
 										?>
461
-                                        <option value="<?php echo esc_attr( $key ); ?>" <?php
461
+                                        <option value="<?php echo esc_attr($key); ?>" <?php
462 462
 
463
-										if ( is_array( $option_value ) ) {
464
-											selected( in_array( $key, $option_value ), true );
463
+										if (is_array($option_value)) {
464
+											selected(in_array($key, $option_value), true);
465 465
 										} else {
466
-											selected( $option_value, $key );
466
+											selected($option_value, $key);
467 467
 										}
468 468
 
469 469
 										?>><?php echo $val ?></option>
@@ -479,28 +479,28 @@  discard block
 block discarded – undo
479 479
 
480 480
 					// Radio inputs.
481 481
 					case 'radio_inline' :
482
-						$value['class'] = empty( $value['class'] ) ? 'give-radio-inline' : $value['class'] . ' give-radio-inline';
482
+						$value['class'] = empty($value['class']) ? 'give-radio-inline' : $value['class'].' give-radio-inline';
483 483
 					case 'radio' :
484
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
484
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
485 485
 						?>
486
-                    <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
486
+                    <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
487 487
                         <th scope="row" class="titledesc">
488
-                            <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
488
+                            <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
489 489
                         </th>
490
-                        <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?> <?php echo( ! empty( $value['class'] ) ? $value['class'] : '' ); ?>">
490
+                        <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?> <?php echo( ! empty($value['class']) ? $value['class'] : ''); ?>">
491 491
                             <fieldset>
492 492
                                 <ul>
493 493
 									<?php
494
-									foreach ( $value['options'] as $key => $val ) {
494
+									foreach ($value['options'] as $key => $val) {
495 495
 										?>
496 496
                                         <li>
497 497
                                             <label><input
498
-                                                        name="<?php echo esc_attr( $value['id'] ); ?>"
498
+                                                        name="<?php echo esc_attr($value['id']); ?>"
499 499
                                                         value="<?php echo $key; ?>"
500 500
                                                         type="radio"
501
-                                                        style="<?php echo esc_attr( $value['css'] ); ?>"
502
-													<?php echo implode( ' ', $custom_attributes ); ?>
503
-													<?php checked( $key, $option_value ); ?>
501
+                                                        style="<?php echo esc_attr($value['css']); ?>"
502
+													<?php echo implode(' ', $custom_attributes); ?>
503
+													<?php checked($key, $option_value); ?>
504 504
                                                 /> <?php echo $val ?></label>
505 505
                                         </li>
506 506
 										<?php
@@ -514,21 +514,21 @@  discard block
 block discarded – undo
514 514
 
515 515
 					// Checkbox input.
516 516
 					case 'checkbox' :
517
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
517
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
518 518
 						?>
519
-                        <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
519
+                        <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
520 520
                             <th scope="row" class="titledesc">
521
-                                <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
521
+                                <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
522 522
                             </th>
523 523
                             <td class="give-forminp">
524 524
                                 <input
525
-                                        name="<?php echo esc_attr( $value['id'] ); ?>"
526
-                                        id="<?php echo esc_attr( $value['id'] ); ?>"
525
+                                        name="<?php echo esc_attr($value['id']); ?>"
526
+                                        id="<?php echo esc_attr($value['id']); ?>"
527 527
                                         type="checkbox"
528
-                                        class="<?php echo esc_attr( isset( $value['class'] ) ? $value['class'] : '' ); ?>"
528
+                                        class="<?php echo esc_attr(isset($value['class']) ? $value['class'] : ''); ?>"
529 529
                                         value="1"
530
-									<?php checked( $option_value, 'on' ); ?>
531
-									<?php echo implode( ' ', $custom_attributes ); ?>
530
+									<?php checked($option_value, 'on'); ?>
531
+									<?php echo implode(' ', $custom_attributes); ?>
532 532
                                 />
533 533
 								<?php echo $description; ?>
534 534
                             </td>
@@ -538,28 +538,28 @@  discard block
 block discarded – undo
538 538
 
539 539
 					// Multi Checkbox input.
540 540
 					case 'multicheck' :
541
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
542
-						$option_value = is_array( $option_value ) ? $option_value : array();
541
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
542
+						$option_value = is_array($option_value) ? $option_value : array();
543 543
 						?>
544
-                        <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
544
+                        <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
545 545
                             <th scope="row" class="titledesc">
546
-                                <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
546
+                                <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
547 547
                             </th>
548
-                            <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?> <?php echo( ! empty( $value['class'] ) ? $value['class'] : '' ); ?>">
548
+                            <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?> <?php echo( ! empty($value['class']) ? $value['class'] : ''); ?>">
549 549
                                 <fieldset>
550 550
                                     <ul>
551 551
 										<?php
552
-										foreach ( $value['options'] as $key => $val ) {
552
+										foreach ($value['options'] as $key => $val) {
553 553
 											?>
554 554
                                             <li>
555 555
                                                 <label>
556 556
                                                     <input
557
-                                                            name="<?php echo esc_attr( $value['id'] ); ?>[]"
557
+                                                            name="<?php echo esc_attr($value['id']); ?>[]"
558 558
                                                             value="<?php echo $key; ?>"
559 559
                                                             type="checkbox"
560
-                                                            style="<?php echo esc_attr( $value['css'] ); ?>"
561
-														<?php echo implode( ' ', $custom_attributes ); ?>
562
-														<?php if ( in_array( $key, $option_value ) ) {
560
+                                                            style="<?php echo esc_attr($value['css']); ?>"
561
+														<?php echo implode(' ', $custom_attributes); ?>
562
+														<?php if (in_array($key, $option_value)) {
563 563
 															echo 'checked="checked"';
564 564
 														} ?>
565 565
                                                     /> <?php echo $val ?>
@@ -577,25 +577,25 @@  discard block
 block discarded – undo
577 577
 
578 578
 					// File input field.
579 579
 					case 'file' :
580
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
580
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
581 581
 						?>
582
-                    <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
582
+                    <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
583 583
                         <th scope="row" class="titledesc">
584
-                            <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
584
+                            <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
585 585
                         </th>
586 586
                         <td class="give-forminp">
587 587
                             <div class="give-field-wrap">
588 588
                                 <label for="<?php echo $value['id'] ?>">
589 589
                                     <input
590
-                                            name="<?php echo esc_attr( $value['id'] ); ?>"
591
-                                            id="<?php echo esc_attr( $value['id'] ); ?>"
590
+                                            name="<?php echo esc_attr($value['id']); ?>"
591
+                                            id="<?php echo esc_attr($value['id']); ?>"
592 592
                                             type="text"
593
-                                            class="give-input-field<?php echo esc_attr( isset( $value['class'] ) ? ' ' . $value['class'] : '' ); ?>"
593
+                                            class="give-input-field<?php echo esc_attr(isset($value['class']) ? ' '.$value['class'] : ''); ?>"
594 594
                                             value="<?php echo $option_value; ?>"
595
-                                            style="<?php echo esc_attr( $value['css'] ); ?>"
596
-										<?php echo implode( ' ', $custom_attributes ); ?>
595
+                                            style="<?php echo esc_attr($value['css']); ?>"
596
+										<?php echo implode(' ', $custom_attributes); ?>
597 597
                                     />&nbsp;&nbsp;&nbsp;&nbsp;<input class="give-upload-button button" type="button"
598
-                                                                     value="<?php echo esc_html__( 'Add or Upload File', 'give' ); ?>">
598
+                                                                     value="<?php echo esc_html__('Add or Upload File', 'give'); ?>">
599 599
 									<?php echo $description ?>
600 600
                                     <div class="give-image-thumb<?php echo ! $option_value ? ' give-hidden' : ''; ?>">
601 601
                                         <span class="give-delete-image-thumb dashicons dashicons-no-alt"></span>
@@ -610,17 +610,17 @@  discard block
 block discarded – undo
610 610
 					// WordPress Editor.
611 611
 					case 'wysiwyg' :
612 612
 						// Get option value.
613
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
613
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
614 614
 
615 615
 						// Get editor settings.
616
-						$editor_settings = ! empty( $value['options'] ) ? $value['options'] : array();
616
+						$editor_settings = ! empty($value['options']) ? $value['options'] : array();
617 617
 						?>
618
-                    <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
618
+                    <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
619 619
                         <th scope="row" class="titledesc">
620
-                            <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
620
+                            <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
621 621
                         </th>
622 622
                         <td class="give-forminp">
623
-							<?php wp_editor( $option_value, $value['id'], $editor_settings ); ?>
623
+							<?php wp_editor($option_value, $value['id'], $editor_settings); ?>
624 624
 							<?php echo $description; ?>
625 625
                         </td>
626 626
                         </tr><?php
@@ -629,9 +629,9 @@  discard block
 block discarded – undo
629 629
 					// Custom: System setting field.
630 630
 					case 'system_info' :
631 631
 						?>
632
-                    <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
632
+                    <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
633 633
                         <th scope="row" class="titledesc">
634
-                            <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
634
+                            <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
635 635
                         </th>
636 636
                         <td class="give-forminp">
637 637
 							<?php give_system_info_callback(); ?>
@@ -642,14 +642,14 @@  discard block
 block discarded – undo
642 642
 
643 643
 					// Custom: Default gateways setting field.
644 644
 					case 'default_gateway' :
645
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
645
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
646 646
 						?>
647
-                    <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
647
+                    <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
648 648
                         <th scope="row" class="titledesc">
649
-                            <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
649
+                            <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
650 650
                         </th>
651 651
                         <td class="give-forminp">
652
-							<?php give_default_gateway_callback( $value, $option_value ); ?>
652
+							<?php give_default_gateway_callback($value, $option_value); ?>
653 653
 							<?php echo $description; ?>
654 654
                         </td>
655 655
                         </tr><?php
@@ -657,14 +657,14 @@  discard block
 block discarded – undo
657 657
 
658 658
 					// Custom: Enable gateways setting field.
659 659
 					case 'enabled_gateways' :
660
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
660
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
661 661
 						?>
662
-                    <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
662
+                    <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
663 663
                         <th scope="row" class="titledesc">
664
-                            <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
664
+                            <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
665 665
                         </th>
666 666
                         <td class="give-forminp">
667
-							<?php give_enabled_gateways_callback( $value, $option_value ); ?>
667
+							<?php give_enabled_gateways_callback($value, $option_value); ?>
668 668
 							<?php echo $description; ?>
669 669
                         </td>
670 670
                         </tr><?php
@@ -673,9 +673,9 @@  discard block
 block discarded – undo
673 673
 					// Custom: Email preview buttons field.
674 674
 					case 'email_preview_buttons' :
675 675
 						?>
676
-                    <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
676
+                    <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
677 677
                         <th scope="row" class="titledesc">
678
-                            <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
678
+                            <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
679 679
                         </th>
680 680
                         <td class="give-forminp">
681 681
 							<?php give_email_preview_buttons_callback(); ?>
@@ -692,22 +692,22 @@  discard block
 block discarded – undo
692 692
 
693 693
 					// Custom: Gateway API key.
694 694
 					case 'api_key' :
695
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
696
-						$type         = ! empty( $option_value ) ? 'password' : 'text';
695
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
696
+						$type         = ! empty($option_value) ? 'password' : 'text';
697 697
 						?>
698
-                    <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
698
+                    <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
699 699
                         <th scope="row" class="titledesc">
700
-                            <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo self::get_field_title( $value ); ?></label>
700
+                            <label for="<?php echo esc_attr($value['id']); ?>"><?php echo self::get_field_title($value); ?></label>
701 701
                         </th>
702
-                        <td class="give-forminp give-forminp-<?php echo sanitize_title( $value['type'] ) ?>">
702
+                        <td class="give-forminp give-forminp-<?php echo sanitize_title($value['type']) ?>">
703 703
                             <input
704
-                                    name="<?php echo esc_attr( $value['id'] ); ?>"
705
-                                    id="<?php echo esc_attr( $value['id'] ); ?>"
706
-                                    type="<?php echo esc_attr( $type ); ?>"
707
-                                    style="<?php echo esc_attr( $value['css'] ); ?>"
708
-                                    value="<?php echo esc_attr( trim( $option_value ) ); ?>"
709
-                                    class="give-input-field<?php echo( empty( $value['class'] ) ? '' : ' ' . esc_attr( $value['class'] ) ); ?>"
710
-								<?php echo implode( ' ', $custom_attributes ); ?>
704
+                                    name="<?php echo esc_attr($value['id']); ?>"
705
+                                    id="<?php echo esc_attr($value['id']); ?>"
706
+                                    type="<?php echo esc_attr($type); ?>"
707
+                                    style="<?php echo esc_attr($value['css']); ?>"
708
+                                    value="<?php echo esc_attr(trim($option_value)); ?>"
709
+                                    class="give-input-field<?php echo(empty($value['class']) ? '' : ' '.esc_attr($value['class'])); ?>"
710
+								<?php echo implode(' ', $custom_attributes); ?>
711 711
                             /> <?php echo $description; ?>
712 712
                         </td>
713 713
                         </tr><?php
@@ -729,12 +729,12 @@  discard block
 block discarded – undo
729 729
 					// Custom: Give Docs Link field type.
730 730
 					case 'give_docs_link' :
731 731
 						?>
732
-                    <tr valign="top" <?php echo ! empty( $value['wrapper_class'] ) ? 'class="' . $value['wrapper_class'] . '"' : '' ?>>
732
+                    <tr valign="top" <?php echo ! empty($value['wrapper_class']) ? 'class="'.$value['wrapper_class'].'"' : '' ?>>
733 733
                         <td class="give-docs-link" colspan="2">
734 734
 							<?php
735
-							echo '<p class="give-docs-link"><a href="' . esc_url( $value['url'] )
735
+							echo '<p class="give-docs-link"><a href="'.esc_url($value['url'])
736 736
 							     . '" target="_blank">'
737
-							     . sprintf( esc_html__( 'Need Help? See docs on "%s"' ), $value['title'] )
737
+							     . sprintf(esc_html__('Need Help? See docs on "%s"'), $value['title'])
738 738
 							     . '<span class="dashicons dashicons-editor-help"></span></a></p>';
739 739
 							?>
740 740
                         </td>
@@ -745,8 +745,8 @@  discard block
 block discarded – undo
745 745
 					// You can add or handle your custom field action.
746 746
 					default:
747 747
 						// Get option value.
748
-						$option_value = self::get_option( $option_name, $value['id'], $value['default'] );
749
-						do_action( 'give_admin_field_' . $value['type'], $value, $option_value );
748
+						$option_value = self::get_option($option_name, $value['id'], $value['default']);
749
+						do_action('give_admin_field_'.$value['type'], $value, $option_value);
750 750
 						break;
751 751
 				}
752 752
 			}
@@ -762,15 +762,15 @@  discard block
 block discarded – undo
762 762
 		 *
763 763
 		 * @return string The HTML description of the field.
764 764
 		 */
765
-		public static function get_field_description( $value ) {
765
+		public static function get_field_description($value) {
766 766
 			$description = '';
767 767
 
768 768
 			// Support for both 'description' and 'desc' args.
769
-			$description_key = isset( $value['description'] ) ? 'description' : 'desc';
770
-			$value           = ( isset( $value[ $description_key ] ) && ! empty( $value[ $description_key ] ) ) ? $value[ $description_key ] : '';
769
+			$description_key = isset($value['description']) ? 'description' : 'desc';
770
+			$value           = (isset($value[$description_key]) && ! empty($value[$description_key])) ? $value[$description_key] : '';
771 771
 
772
-			if ( ! empty( $value ) ) {
773
-				$description = '<p class="give-field-description">' . wp_kses_post( $value ) . '</p>';
772
+			if ( ! empty($value)) {
773
+				$description = '<p class="give-field-description">'.wp_kses_post($value).'</p>';
774 774
 			}
775 775
 
776 776
 			return $description;
@@ -787,11 +787,11 @@  discard block
 block discarded – undo
787 787
 		 *
788 788
 		 * @return array The description and tip as a 2 element array
789 789
 		 */
790
-		public static function get_field_title( $value ) {
791
-			$title = esc_html( $value['title'] );
790
+		public static function get_field_title($value) {
791
+			$title = esc_html($value['title']);
792 792
 
793 793
 			// If html tag detected then allow them to print.
794
-			if ( strip_tags( $title ) ) {
794
+			if (strip_tags($title)) {
795 795
 				$title = $value['title'];
796 796
 			}
797 797
 
@@ -810,8 +810,8 @@  discard block
 block discarded – undo
810 810
 		 *
811 811
 		 * @return bool
812 812
 		 */
813
-		public static function save_fields( $options, $option_name = '' ) {
814
-			if ( empty( $_POST ) ) {
813
+		public static function save_fields($options, $option_name = '') {
814
+			if (empty($_POST)) {
815 815
 				return false;
816 816
 			}
817 817
 
@@ -819,37 +819,37 @@  discard block
 block discarded – undo
819 819
 			$update_options = array();
820 820
 
821 821
 			// Loop options and get values to save.
822
-			foreach ( $options as $option ) {
823
-				if ( ! isset( $option['id'] ) || ! isset( $option['type'] ) ) {
822
+			foreach ($options as $option) {
823
+				if ( ! isset($option['id']) || ! isset($option['type'])) {
824 824
 					continue;
825 825
 				}
826 826
 
827 827
 				// Get posted value.
828
-				if ( strstr( $option['id'], '[' ) ) {
829
-					parse_str( $option['id'], $option_name_array );
830
-					$field_option_name = current( array_keys( $option_name_array ) );
831
-					$setting_name      = key( $option_name_array[ $field_option_name ] );
832
-					$raw_value         = isset( $_POST[ $field_option_name ][ $setting_name ] ) ? wp_unslash( $_POST[ $field_option_name ][ $setting_name ] ) : null;
828
+				if (strstr($option['id'], '[')) {
829
+					parse_str($option['id'], $option_name_array);
830
+					$field_option_name = current(array_keys($option_name_array));
831
+					$setting_name      = key($option_name_array[$field_option_name]);
832
+					$raw_value         = isset($_POST[$field_option_name][$setting_name]) ? wp_unslash($_POST[$field_option_name][$setting_name]) : null;
833 833
 				} else {
834 834
 					$field_option_name = $option['id'];
835 835
 					$setting_name      = '';
836
-					$raw_value         = isset( $_POST[ $option['id'] ] ) ? wp_unslash( $_POST[ $option['id'] ] ) : null;
836
+					$raw_value         = isset($_POST[$option['id']]) ? wp_unslash($_POST[$option['id']]) : null;
837 837
 				}
838 838
 
839 839
 				// Format the value based on option type.
840
-				switch ( $option['type'] ) {
840
+				switch ($option['type']) {
841 841
 					case 'checkbox' :
842
-						$value = is_null( $raw_value ) ? '' : 'on';
842
+						$value = is_null($raw_value) ? '' : 'on';
843 843
 						break;
844 844
 					case 'wysiwyg'  :
845 845
 					case 'textarea' :
846
-						$value = wp_kses_post( trim( $raw_value ) );
846
+						$value = wp_kses_post(trim($raw_value));
847 847
 						break;
848 848
 					case 'multiselect' :
849
-						$value = array_filter( array_map( 'give_clean', (array) $raw_value ) );
849
+						$value = array_filter(array_map('give_clean', (array) $raw_value));
850 850
 						break;
851 851
 					default :
852
-						$value = give_clean( $raw_value );
852
+						$value = give_clean($raw_value);
853 853
 						break;
854 854
 				}
855 855
 
@@ -858,37 +858,37 @@  discard block
 block discarded – undo
858 858
 				 *
859 859
 				 * @since 1.8
860 860
 				 */
861
-				$value = apply_filters( 'give_admin_settings_sanitize_option', $value, $option, $raw_value );
861
+				$value = apply_filters('give_admin_settings_sanitize_option', $value, $option, $raw_value);
862 862
 
863 863
 				/**
864 864
 				 * Sanitize the value of an option by option name.
865 865
 				 *
866 866
 				 * @since 1.8
867 867
 				 */
868
-				$value = apply_filters( "give_admin_settings_sanitize_option_{$field_option_name}", $value, $option, $raw_value );
868
+				$value = apply_filters("give_admin_settings_sanitize_option_{$field_option_name}", $value, $option, $raw_value);
869 869
 
870
-				if ( is_null( $value ) ) {
870
+				if (is_null($value)) {
871 871
 					continue;
872 872
 				}
873 873
 
874 874
 				// Check if option is an array and handle that differently to single values.
875
-				if ( $field_option_name && $setting_name ) {
876
-					if ( ! isset( $update_options[ $field_option_name ] ) ) {
877
-						$update_options[ $field_option_name ] = get_option( $field_option_name, array() );
875
+				if ($field_option_name && $setting_name) {
876
+					if ( ! isset($update_options[$field_option_name])) {
877
+						$update_options[$field_option_name] = get_option($field_option_name, array());
878 878
 					}
879
-					if ( ! is_array( $update_options[ $field_option_name ] ) ) {
880
-						$update_options[ $field_option_name ] = array();
879
+					if ( ! is_array($update_options[$field_option_name])) {
880
+						$update_options[$field_option_name] = array();
881 881
 					}
882
-					$update_options[ $field_option_name ][ $setting_name ] = $value;
882
+					$update_options[$field_option_name][$setting_name] = $value;
883 883
 				} else {
884
-					$update_options[ $field_option_name ] = $value;
884
+					$update_options[$field_option_name] = $value;
885 885
 				}
886 886
 			}
887 887
 
888 888
 			// Save all options in our array or there own option name i.e. option id.
889
-			if ( empty( $option_name ) ) {
890
-				foreach ( $update_options as $name => $value ) {
891
-					update_option( $name, $value );
889
+			if (empty($option_name)) {
890
+				foreach ($update_options as $name => $value) {
891
+					update_option($name, $value);
892 892
 
893 893
 					/**
894 894
 					 * Trigger action.
@@ -897,13 +897,13 @@  discard block
 block discarded – undo
897 897
 					 *
898 898
 					 * @since 1.8
899 899
 					 */
900
-					do_action( "give_save_option_{$name}", $value, $name );
900
+					do_action("give_save_option_{$name}", $value, $name);
901 901
 				}
902 902
 			} else {
903
-				$old_options    = ( $old_options = get_option( $option_name ) ) ? $old_options : array();
904
-				$update_options = array_merge( $old_options, $update_options );
903
+				$old_options    = ($old_options = get_option($option_name)) ? $old_options : array();
904
+				$update_options = array_merge($old_options, $update_options);
905 905
 
906
-				update_option( $option_name, $update_options );
906
+				update_option($option_name, $update_options);
907 907
 
908 908
 				/**
909 909
 				 * Trigger action.
@@ -912,7 +912,7 @@  discard block
 block discarded – undo
912 912
 				 *
913 913
 				 * @since 1.8
914 914
 				 */
915
-				do_action( "give_save_settings_{$option_name}", $update_options, $option_name );
915
+				do_action("give_save_settings_{$option_name}", $update_options, $option_name);
916 916
 			}
917 917
 
918 918
 			return true;
Please login to merge, or discard this patch.
includes/admin/settings/class-settings-gateways.php 2 patches
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -86,13 +86,13 @@  discard block
 block discarded – undo
86 86
 								'disabled' => __( 'Disabled', 'give' ),
87 87
 							)
88 88
 						),
89
-                        array(
90
-                            'name'  => __( 'PayPal Standard Gateway Settings Docs Link', 'give' ),
91
-                            'id'    => 'paypal_standard_gateway_settings_docs_link',
92
-                            'url'   => esc_url( 'http://docs.givewp.com/settings-gateway-paypal-standard' ),
93
-                            'title' => __( 'PayPal Standard Gateway Settings', 'give' ),
94
-                            'type'  => 'give_docs_link',
95
-                        ),
89
+						array(
90
+							'name'  => __( 'PayPal Standard Gateway Settings Docs Link', 'give' ),
91
+							'id'    => 'paypal_standard_gateway_settings_docs_link',
92
+							'url'   => esc_url( 'http://docs.givewp.com/settings-gateway-paypal-standard' ),
93
+							'title' => __( 'PayPal Standard Gateway Settings', 'give' ),
94
+							'type'  => 'give_docs_link',
95
+						),
96 96
 						array(
97 97
 							'type' => 'sectionend',
98 98
 							'id'   => 'give_title_gateway_settings_2',
@@ -145,13 +145,13 @@  discard block
 block discarded – undo
145 145
 								'textarea_rows' => 6,
146 146
 							)
147 147
 						),
148
-                        array(
149
-                            'name'  => __( 'Offline Donations Settings Docs Link', 'give' ),
150
-                            'id'    => 'offline_gateway_settings_docs_link',
151
-                            'url'   => esc_url( 'http://docs.givewp.com/settings-gateway-offline-donations' ),
152
-                            'title' => __( 'Offline Gateway Settings', 'give' ),
153
-                            'type'  => 'give_docs_link',
154
-                        ),
148
+						array(
149
+							'name'  => __( 'Offline Donations Settings Docs Link', 'give' ),
150
+							'id'    => 'offline_gateway_settings_docs_link',
151
+							'url'   => esc_url( 'http://docs.givewp.com/settings-gateway-offline-donations' ),
152
+							'title' => __( 'Offline Gateway Settings', 'give' ),
153
+							'type'  => 'give_docs_link',
154
+						),
155 155
 						array(
156 156
 							'type' => 'sectionend',
157 157
 							'id'   => 'give_title_gateway_settings_3',
@@ -189,13 +189,13 @@  discard block
 block discarded – undo
189 189
 							'id'   => 'default_gateway',
190 190
 							'type' => 'default_gateway'
191 191
 						),
192
-                        array(
193
-                            'name'  => __( 'Gateways Docs Link', 'give' ),
194
-                            'id'    => 'gateway_settings_docs_link',
195
-                            'url'   => esc_url( 'http://docs.givewp.com/settings-gateways' ),
196
-                            'title' => __( 'Gateway Settings', 'give' ),
197
-                            'type'  => 'give_docs_link',
198
-                        ),
192
+						array(
193
+							'name'  => __( 'Gateways Docs Link', 'give' ),
194
+							'id'    => 'gateway_settings_docs_link',
195
+							'url'   => esc_url( 'http://docs.givewp.com/settings-gateways' ),
196
+							'title' => __( 'Gateway Settings', 'give' ),
197
+							'type'  => 'give_docs_link',
198
+						),
199 199
 						array(
200 200
 							'id'   => 'give_title_gateway_settings_1',
201 201
 							'type' => 'sectionend'
Please login to merge, or discard this patch.
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -9,11 +9,11 @@  discard block
 block discarded – undo
9 9
  * @since       1.8
10 10
  */
11 11
 
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit; // Exit if accessed directly
14 14
 }
15 15
 
16
-if ( ! class_exists( 'Give_Settings_Gateways' ) ) :
16
+if ( ! class_exists('Give_Settings_Gateways')) :
17 17
 
18 18
 	/**
19 19
 	 * Give_Settings_Gateways.
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 		 */
28 28
 		public function __construct() {
29 29
 			$this->id    = 'gateways';
30
-			$this->label = esc_html__( 'Payment Gateways', 'give' );
30
+			$this->label = esc_html__('Payment Gateways', 'give');
31 31
 
32 32
 			$this->default_tab = 'gateways-settings';
33 33
 
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 			$settings        = array();
45 45
 			$current_section = give_get_current_setting_section();
46 46
 
47
-			switch ( $current_section ) {
47
+			switch ($current_section) {
48 48
 				case 'paypal-standard':
49 49
 					$settings = array(
50 50
 						// Section 2: PayPal Standard.
@@ -53,55 +53,55 @@  discard block
 block discarded – undo
53 53
 							'id'   => 'give_title_gateway_settings_2',
54 54
 						),
55 55
 						array(
56
-							'name' => __( 'PayPal Email', 'give' ),
57
-							'desc' => __( 'Enter your PayPal account\'s email.', 'give' ),
56
+							'name' => __('PayPal Email', 'give'),
57
+							'desc' => __('Enter your PayPal account\'s email.', 'give'),
58 58
 							'id'   => 'paypal_email',
59 59
 							'type' => 'email',
60 60
 						),
61 61
 						array(
62
-							'name' => __( 'PayPal Page Style', 'give' ),
63
-							'desc' => __( 'Enter the name of the PayPal page style to use, or leave blank to use the default.', 'give' ),
62
+							'name' => __('PayPal Page Style', 'give'),
63
+							'desc' => __('Enter the name of the PayPal page style to use, or leave blank to use the default.', 'give'),
64 64
 							'id'   => 'paypal_page_style',
65 65
 							'type' => 'text',
66 66
 						),
67 67
 						array(
68
-							'name'    => __( 'PayPal Transaction Type', 'give' ),
69
-							'desc'    => __( 'Nonprofits must verify their status to withdraw donations they receive via PayPal. PayPal users that are not verified nonprofits must demonstrate how their donations will be used, once they raise more than $10,000. By default, Give transactions are sent to PayPal as donations. You may change the transaction type using this option if you feel you may not meet PayPal\'s donation requirements.', 'give' ),
68
+							'name'    => __('PayPal Transaction Type', 'give'),
69
+							'desc'    => __('Nonprofits must verify their status to withdraw donations they receive via PayPal. PayPal users that are not verified nonprofits must demonstrate how their donations will be used, once they raise more than $10,000. By default, Give transactions are sent to PayPal as donations. You may change the transaction type using this option if you feel you may not meet PayPal\'s donation requirements.', 'give'),
70 70
 							'id'      => 'paypal_button_type',
71 71
 							'type'    => 'radio_inline',
72 72
 							'options' => array(
73
-								'donation' => __( 'Donation', 'give' ),
74
-								'standard' => __( 'Standard Transaction', 'give' )
73
+								'donation' => __('Donation', 'give'),
74
+								'standard' => __('Standard Transaction', 'give')
75 75
 							),
76 76
 							'default' => 'donation',
77 77
 						),
78 78
 						array(
79
-							'name'    => __( 'Billing Details', 'give' ),
80
-							'desc'    => __( 'This option will enable the billing details section for PayPal Standard which requires the donor\'s address to complete the donation. These fields are not required by PayPal to process the transaction, but you may have a need to collect the data.', 'give' ),
79
+							'name'    => __('Billing Details', 'give'),
80
+							'desc'    => __('This option will enable the billing details section for PayPal Standard which requires the donor\'s address to complete the donation. These fields are not required by PayPal to process the transaction, but you may have a need to collect the data.', 'give'),
81 81
 							'id'      => 'paypal_standard_billing_details',
82 82
 							'type'    => 'radio_inline',
83 83
 							'default' => 'disabled',
84 84
 							'options' => array(
85
-								'enabled'  => __( 'Enabled', 'give' ),
86
-								'disabled' => __( 'Disabled', 'give' ),
85
+								'enabled'  => __('Enabled', 'give'),
86
+								'disabled' => __('Disabled', 'give'),
87 87
 							)
88 88
 						),
89 89
 						array(
90
-							'name'    => __( 'PayPal IPN Verification', 'give' ),
91
-							'desc'    => __( 'If donations are not getting marked as complete, use a slightly less secure method of verifying donations.', 'give' ),
90
+							'name'    => __('PayPal IPN Verification', 'give'),
91
+							'desc'    => __('If donations are not getting marked as complete, use a slightly less secure method of verifying donations.', 'give'),
92 92
 							'id'      => 'paypal_verification',
93 93
 							'type'    => 'radio_inline',
94 94
 							'default' => 'enabled',
95 95
 							'options' => array(
96
-								'enabled'  => __( 'Enabled', 'give' ),
97
-								'disabled' => __( 'Disabled', 'give' ),
96
+								'enabled'  => __('Enabled', 'give'),
97
+								'disabled' => __('Disabled', 'give'),
98 98
 							)
99 99
 						),
100 100
                         array(
101
-                            'name'  => __( 'PayPal Standard Gateway Settings Docs Link', 'give' ),
101
+                            'name'  => __('PayPal Standard Gateway Settings Docs Link', 'give'),
102 102
                             'id'    => 'paypal_standard_gateway_settings_docs_link',
103
-                            'url'   => esc_url( 'http://docs.givewp.com/settings-gateway-paypal-standard' ),
104
-                            'title' => __( 'PayPal Standard Gateway Settings', 'give' ),
103
+                            'url'   => esc_url('http://docs.givewp.com/settings-gateway-paypal-standard'),
104
+                            'title' => __('PayPal Standard Gateway Settings', 'give'),
105 105
                             'type'  => 'give_docs_link',
106 106
                         ),
107 107
 						array(
@@ -119,19 +119,19 @@  discard block
 block discarded – undo
119 119
 							'id'   => 'give_title_gateway_settings_3',
120 120
 						),
121 121
 						array(
122
-							'name'    => __( 'Collect Billing Details', 'give' ),
123
-							'desc'    => __( 'Enable to request billing details for offline donations. Will appear above offline donation instructions. Can be enabled/disabled per form.', 'give' ),
122
+							'name'    => __('Collect Billing Details', 'give'),
123
+							'desc'    => __('Enable to request billing details for offline donations. Will appear above offline donation instructions. Can be enabled/disabled per form.', 'give'),
124 124
 							'id'      => 'give_offline_donation_enable_billing_fields',
125 125
 							'type'    => 'radio_inline',
126 126
 							'default' => 'disabled',
127 127
 							'options' => array(
128
-								'enabled'  => __( 'Enabled', 'give' ),
129
-								'disabled' => __( 'Disabled', 'give' )
128
+								'enabled'  => __('Enabled', 'give'),
129
+								'disabled' => __('Disabled', 'give')
130 130
 							)
131 131
 						),
132 132
 						array(
133
-							'name'    => __( 'Offline Donation Instructions', 'give' ),
134
-							'desc'    => __( 'The following content will appear for all forms when the user selects the offline donation payment option. Note: You may customize the content per form as needed.', 'give' ),
133
+							'name'    => __('Offline Donation Instructions', 'give'),
134
+							'desc'    => __('The following content will appear for all forms when the user selects the offline donation payment option. Note: You may customize the content per form as needed.', 'give'),
135 135
 							'id'      => 'global_offline_donation_content',
136 136
 							'default' => give_get_default_offline_donation_content(),
137 137
 							'type'    => 'wysiwyg',
@@ -140,15 +140,15 @@  discard block
 block discarded – undo
140 140
 							)
141 141
 						),
142 142
 						array(
143
-							'name'    => __( 'Offline Donation Email Instructions Subject', 'give' ),
144
-							'desc'    => __( 'Enter the subject line for the donation receipt email.', 'give' ),
143
+							'name'    => __('Offline Donation Email Instructions Subject', 'give'),
144
+							'desc'    => __('Enter the subject line for the donation receipt email.', 'give'),
145 145
 							'id'      => 'offline_donation_subject',
146
-							'default' => esc_attr__( '{donation} - Offline Donation Instructions', 'give' ),
146
+							'default' => esc_attr__('{donation} - Offline Donation Instructions', 'give'),
147 147
 							'type'    => 'text'
148 148
 						),
149 149
 						array(
150
-							'name'    => __( 'Offline Donation Email Instructions', 'give' ),
151
-							'desc'    => __( 'Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ) . ' ' . __( 'Available template tags:', 'give' ) . give_get_emails_tags_list(),
150
+							'name'    => __('Offline Donation Email Instructions', 'give'),
151
+							'desc'    => __('Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give').' '.__('Available template tags:', 'give').give_get_emails_tags_list(),
152 152
 							'id'      => 'global_offline_donation_email',
153 153
 							'default' => give_get_default_offline_donation_email_content(),
154 154
 							'type'    => 'wysiwyg',
@@ -157,10 +157,10 @@  discard block
 block discarded – undo
157 157
 							)
158 158
 						),
159 159
                         array(
160
-                            'name'  => __( 'Offline Donations Settings Docs Link', 'give' ),
160
+                            'name'  => __('Offline Donations Settings Docs Link', 'give'),
161 161
                             'id'    => 'offline_gateway_settings_docs_link',
162
-                            'url'   => esc_url( 'http://docs.givewp.com/settings-gateway-offline-donations' ),
163
-                            'title' => __( 'Offline Gateway Settings', 'give' ),
162
+                            'url'   => esc_url('http://docs.givewp.com/settings-gateway-offline-donations'),
163
+                            'title' => __('Offline Gateway Settings', 'give'),
164 164
                             'type'  => 'give_docs_link',
165 165
                         ),
166 166
 						array(
@@ -178,33 +178,33 @@  discard block
 block discarded – undo
178 178
 							'type' => 'title'
179 179
 						),
180 180
 						array(
181
-							'name'    => __( 'Test Mode', 'give' ),
182
-							'desc'    => __( 'While in test mode no live donations are processed. To fully use test mode, you must have a sandbox (test) account for the payment gateway you are testing.', 'give' ),
181
+							'name'    => __('Test Mode', 'give'),
182
+							'desc'    => __('While in test mode no live donations are processed. To fully use test mode, you must have a sandbox (test) account for the payment gateway you are testing.', 'give'),
183 183
 							'id'      => 'test_mode',
184 184
 							'type'    => 'radio_inline',
185 185
 							'default' => 'disabled',
186 186
 							'options' => array(
187
-								'enabled'  => __( 'Enabled', 'give' ),
188
-								'disabled' => __( 'Disabled', 'give' ),
187
+								'enabled'  => __('Enabled', 'give'),
188
+								'disabled' => __('Disabled', 'give'),
189 189
 							)
190 190
 						),
191 191
 						array(
192
-							'name' => __( 'Enabled Gateways', 'give' ),
193
-							'desc' => __( 'Enable your payment gateway. Can be ordered by dragging.', 'give' ),
192
+							'name' => __('Enabled Gateways', 'give'),
193
+							'desc' => __('Enable your payment gateway. Can be ordered by dragging.', 'give'),
194 194
 							'id'   => 'gateways',
195 195
 							'type' => 'enabled_gateways'
196 196
 						),
197 197
 						array(
198
-							'name' => __( 'Default Gateway', 'give' ),
199
-							'desc' => __( 'The gateway that will be selected by default.', 'give' ),
198
+							'name' => __('Default Gateway', 'give'),
199
+							'desc' => __('The gateway that will be selected by default.', 'give'),
200 200
 							'id'   => 'default_gateway',
201 201
 							'type' => 'default_gateway'
202 202
 						),
203 203
                         array(
204
-                            'name'  => __( 'Gateways Docs Link', 'give' ),
204
+                            'name'  => __('Gateways Docs Link', 'give'),
205 205
                             'id'    => 'gateway_settings_docs_link',
206
-                            'url'   => esc_url( 'http://docs.givewp.com/settings-gateways' ),
207
-                            'title' => __( 'Gateway Settings', 'give' ),
206
+                            'url'   => esc_url('http://docs.givewp.com/settings-gateways'),
207
+                            'title' => __('Gateway Settings', 'give'),
208 208
                             'type'  => 'give_docs_link',
209 209
                         ),
210 210
 						array(
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 			 * Filter the payment gateways settings.
220 220
 			 * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8
221 221
 			 */
222
-			$settings = apply_filters( 'give_settings_gateways', $settings );
222
+			$settings = apply_filters('give_settings_gateways', $settings);
223 223
 
224 224
 			/**
225 225
 			 * Filter the settings.
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 			 *
229 229
 			 * @param  array $settings
230 230
 			 */
231
-			$settings = apply_filters( 'give_get_settings_' . $this->id, $settings );
231
+			$settings = apply_filters('give_get_settings_'.$this->id, $settings);
232 232
 
233 233
 			// Output.
234 234
 			return $settings;
@@ -242,12 +242,12 @@  discard block
 block discarded – undo
242 242
 		 */
243 243
 		public function get_sections() {
244 244
 			$sections = array(
245
-				'gateways-settings' => __( 'Gateways', 'give' ),
246
-				'paypal-standard'   => __( 'PayPal Standard', 'give' ),
247
-				'offline-donations' => __( 'Offline Donations', 'give' )
245
+				'gateways-settings' => __('Gateways', 'give'),
246
+				'paypal-standard'   => __('PayPal Standard', 'give'),
247
+				'offline-donations' => __('Offline Donations', 'give')
248 248
 			);
249 249
 
250
-			return apply_filters( 'give_get_sections_' . $this->id, $sections );
250
+			return apply_filters('give_get_sections_'.$this->id, $sections);
251 251
 		}
252 252
 	}
253 253
 
Please login to merge, or discard this patch.
includes/admin/reporting/class-gateway-error-logs-list-table.php 1 patch
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -9,13 +9,13 @@  discard block
 block discarded – undo
9 9
  */
10 10
 
11 11
 // Exit if accessed directly.
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit;
14 14
 }
15 15
 
16 16
 // Load WP_List_Table if not loaded.
17
-if ( ! class_exists( 'WP_List_Table' ) ) {
18
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
17
+if ( ! class_exists('WP_List_Table')) {
18
+	require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
19 19
 }
20 20
 
21 21
 /**
@@ -44,11 +44,11 @@  discard block
 block discarded – undo
44 44
 	 */
45 45
 	public function __construct() {
46 46
 		// Set parent defaults.
47
-		parent::__construct( array(
48
-			'singular' => give_get_forms_label_singular(),    // Singular name of the listed records.
49
-			'plural'   => give_get_forms_label_plural(),        // Plural name of the listed records.
47
+		parent::__construct(array(
48
+			'singular' => give_get_forms_label_singular(), // Singular name of the listed records.
49
+			'plural'   => give_get_forms_label_plural(), // Plural name of the listed records.
50 50
 			'ajax'     => false                        // Does this table support ajax?.
51
-		) );
51
+		));
52 52
 	}
53 53
 
54 54
 	/**
@@ -62,19 +62,19 @@  discard block
 block discarded – undo
62 62
 	 *
63 63
 	 * @return string Column Name.
64 64
 	 */
65
-	public function column_default( $item, $column_name ) {
65
+	public function column_default($item, $column_name) {
66 66
 
67
-		switch ( $column_name ) {
67
+		switch ($column_name) {
68 68
 			case 'ID' :
69 69
 				return $item['ID_label'];
70 70
 			case 'payment_id' :
71
-				return empty( $item['payment_id'] ) ? esc_html__( 'n/a', 'give' ) : sprintf( "<a href=\"%s\" target=\"_blank\">{$item['payment_id']}</a>", get_edit_post_link( $item['payment_id'] ) );
71
+				return empty($item['payment_id']) ? esc_html__('n/a', 'give') : sprintf("<a href=\"%s\" target=\"_blank\">{$item['payment_id']}</a>", get_edit_post_link($item['payment_id']));
72 72
 			case 'gateway' :
73
-				return empty( $item['gateway'] ) ? esc_html__( 'n/a', 'give' ) : $item['gateway'];
73
+				return empty($item['gateway']) ? esc_html__('n/a', 'give') : $item['gateway'];
74 74
 			case 'error' :
75
-				return get_the_title( $item['ID'] ) ? get_the_title( $item['ID'] ) : esc_html__( 'Payment Error', 'give' );
75
+				return get_the_title($item['ID']) ? get_the_title($item['ID']) : esc_html__('Payment Error', 'give');
76 76
 			default:
77
-				return $item[ $column_name ];
77
+				return $item[$column_name];
78 78
 		}
79 79
 	}
80 80
 
@@ -88,27 +88,27 @@  discard block
 block discarded – undo
88 88
 	 *
89 89
 	 * @return void
90 90
 	 */
91
-	public function column_message( $item ) { ?>
92
-		<a href="#TB_inline?width=640&amp;inlineId=log-message-<?php echo $item['ID']; ?>" class="thickbox give-error-log-details-link button button-small" data-tooltip="<?php esc_attr_e( 'View Log Message', 'give' ); ?>"><span class="dashicons dashicons-visibility"></span></a>
91
+	public function column_message($item) { ?>
92
+		<a href="#TB_inline?width=640&amp;inlineId=log-message-<?php echo $item['ID']; ?>" class="thickbox give-error-log-details-link button button-small" data-tooltip="<?php esc_attr_e('View Log Message', 'give'); ?>"><span class="dashicons dashicons-visibility"></span></a>
93 93
 		<div id="log-message-<?php echo $item['ID']; ?>" style="display:none;">
94 94
 			<?php
95 95
 
96
-			$log_message = get_post_field( 'post_content', $item['ID'] );
96
+			$log_message = get_post_field('post_content', $item['ID']);
97 97
 
98
-			$serialized = strpos( $log_message, '{"' );
98
+			$serialized = strpos($log_message, '{"');
99 99
 
100 100
 			// Check to see if the log message contains serialized information
101
-			if ( $serialized !== false ) {
102
-				$length = strlen( $log_message ) - $serialized;
103
-				$intro  = substr( $log_message, 0, - $length );
104
-				$data   = substr( $log_message, $serialized, strlen( $log_message ) - 1 );
101
+			if ($serialized !== false) {
102
+				$length = strlen($log_message) - $serialized;
103
+				$intro  = substr($log_message, 0, - $length);
104
+				$data   = substr($log_message, $serialized, strlen($log_message) - 1);
105 105
 
106
-				echo wpautop( $intro );
107
-				echo wpautop( '<strong>' . esc_html__( 'Log data:', 'give' ) . '</strong>' );
108
-				echo '<div style="word-wrap: break-word;">' . wpautop( $data ) . '</div>';
106
+				echo wpautop($intro);
107
+				echo wpautop('<strong>'.esc_html__('Log data:', 'give').'</strong>');
108
+				echo '<div style="word-wrap: break-word;">'.wpautop($data).'</div>';
109 109
 			} else {
110 110
 				// No serialized data found
111
-				echo wpautop( $log_message );
111
+				echo wpautop($log_message);
112 112
 			}
113 113
 			?>
114 114
 		</div>
@@ -124,12 +124,12 @@  discard block
 block discarded – undo
124 124
 	 */
125 125
 	public function get_columns() {
126 126
 		$columns = array(
127
-			'ID'         => esc_html__( 'Log ID', 'give' ),
128
-			'error'      => esc_html__( 'Error', 'give' ),
129
-			'gateway'    => esc_html__( 'Gateway', 'give' ),
130
-			'payment_id' => esc_html__( 'Donation ID', 'give' ),
131
-			'date'       => esc_html__( 'Date', 'give' ),
132
-			'message'    => esc_html__( 'Details', 'give' )
127
+			'ID'         => esc_html__('Log ID', 'give'),
128
+			'error'      => esc_html__('Error', 'give'),
129
+			'gateway'    => esc_html__('Gateway', 'give'),
130
+			'payment_id' => esc_html__('Donation ID', 'give'),
131
+			'date'       => esc_html__('Date', 'give'),
132
+			'message'    => esc_html__('Details', 'give')
133 133
 		);
134 134
 
135 135
 		return $columns;
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 	 * @return int Current page number
144 144
 	 */
145 145
 	public function get_paged() {
146
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
146
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
147 147
 	}
148 148
 
149 149
 	/**
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	 * @since  1.0
154 154
 	 * @return void
155 155
 	 */
156
-	public function bulk_actions( $which = '' ) {
156
+	public function bulk_actions($which = '') {
157 157
 		give_log_views();
158 158
 	}
159 159
 
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 
172 172
 		// Prevent the queries from getting cached.
173 173
 		// Without this there are occasional memory issues for some installs.
174
-		wp_suspend_cache_addition( true );
174
+		wp_suspend_cache_addition(true);
175 175
 
176 176
 		$logs_data = array();
177 177
 		$paged     = $this->get_paged();
@@ -180,17 +180,17 @@  discard block
 block discarded – undo
180 180
 			'paged'    => $paged
181 181
 		);
182 182
 
183
-		$logs = $give_logs->get_connected_logs( $log_query );
183
+		$logs = $give_logs->get_connected_logs($log_query);
184 184
 
185
-		if ( $logs ) {
186
-			foreach ( $logs as $log ) {
185
+		if ($logs) {
186
+			foreach ($logs as $log) {
187 187
 
188 188
 				$logs_data[] = array(
189 189
 					'ID'         => $log->ID,
190
-					'ID_label'   => '<span class=\'give-item-label give-item-label-gray\'>' . $log->ID . '</span>',
190
+					'ID_label'   => '<span class=\'give-item-label give-item-label-gray\'>'.$log->ID.'</span>',
191 191
 					'payment_id' => $log->post_parent,
192 192
 					'error'      => 'error',
193
-					'gateway'    => give_get_payment_gateway( $log->post_parent ),
193
+					'gateway'    => give_get_payment_gateway($log->post_parent),
194 194
 					'date'       => $log->post_date
195 195
 				);
196 196
 			}
@@ -212,19 +212,19 @@  discard block
 block discarded – undo
212 212
 	 *
213 213
 	 * @param string $which
214 214
 	 */
215
-	protected function display_tablenav( $which ) {
216
-		if ( 'top' === $which ) {
217
-			wp_nonce_field( 'bulk-' . $this->_args['plural'] );
215
+	protected function display_tablenav($which) {
216
+		if ('top' === $which) {
217
+			wp_nonce_field('bulk-'.$this->_args['plural']);
218 218
 		}
219 219
 		?>
220
-		<div class="tablenav <?php echo esc_attr( $which ); ?>">
220
+		<div class="tablenav <?php echo esc_attr($which); ?>">
221 221
 
222 222
 			<div class="alignleft actions bulkactions">
223
-				<?php $this->bulk_actions( $which ); ?>
223
+				<?php $this->bulk_actions($which); ?>
224 224
 			</div>
225 225
 			<?php
226
-			$this->extra_tablenav( $which );
227
-			$this->pagination( $which );
226
+			$this->extra_tablenav($which);
227
+			$this->pagination($which);
228 228
 			?>
229 229
 
230 230
 			<br class="clear"/>
@@ -251,14 +251,14 @@  discard block
 block discarded – undo
251 251
 		$columns               = $this->get_columns();
252 252
 		$hidden                = array(); // No hidden columns
253 253
 		$sortable              = $this->get_sortable_columns();
254
-		$this->_column_headers = array( $columns, $hidden, $sortable );
254
+		$this->_column_headers = array($columns, $hidden, $sortable);
255 255
 		$this->items           = $this->get_logs();
256
-		$total_items           = $give_logs->get_log_count( 0, 'gateway_error' );
256
+		$total_items           = $give_logs->get_log_count(0, 'gateway_error');
257 257
 
258
-		$this->set_pagination_args( array(
258
+		$this->set_pagination_args(array(
259 259
 				'total_items' => $total_items,
260 260
 				'per_page'    => $this->per_page,
261
-				'total_pages' => ceil( $total_items / $this->per_page )
261
+				'total_pages' => ceil($total_items / $this->per_page)
262 262
 			)
263 263
 		);
264 264
 	}
Please login to merge, or discard this patch.
includes/class-give-email-access.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -232,7 +232,7 @@
 block discarded – undo
232 232
 	 * @since  1.0
233 233
 	 * @access public
234 234
 	 *
235
-	 * @return bool
235
+	 * @return null|boolean
236 236
 	 */
237 237
 	public function check_for_token() {
238 238
 
Please login to merge, or discard this patch.
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -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
 	/**
@@ -120,29 +120,29 @@  discard block
 block discarded – undo
120 120
 		 */
121 121
 		if (
122 122
 			is_user_logged_in()
123
-			|| ! give_is_setting_enabled( give_get_option( 'email_access' ) )
123
+			|| ! give_is_setting_enabled(give_get_option('email_access'))
124 124
 			|| is_admin()
125 125
 		) {
126 126
 			return;
127 127
 		}
128 128
 
129 129
 		// Are db columns setup?
130
-		$is_setup = give_get_option( 'email_access_installed' );
131
-		if ( empty( $is_setup ) ) {
130
+		$is_setup = give_get_option('email_access_installed');
131
+		if (empty($is_setup)) {
132 132
 			$this->create_columns();
133 133
 		}
134 134
 
135 135
 		// Timeouts.
136
-		$this->verify_throttle  = apply_filters( 'give_nl_verify_throttle', 300 );
137
-		$this->token_expiration = apply_filters( 'give_nl_token_expiration', 7200 );
136
+		$this->verify_throttle  = apply_filters('give_nl_verify_throttle', 300);
137
+		$this->token_expiration = apply_filters('give_nl_token_expiration', 7200);
138 138
 
139 139
 		// Setup login.
140 140
 		$this->check_for_token();
141 141
 
142
-		if ( $this->token_exists ) {
143
-			add_filter( 'give_can_view_receipt', '__return_true' );
144
-			add_filter( 'give_user_pending_verification', '__return_false' );
145
-			add_filter( 'give_get_users_donations_args', array( $this, 'users_donations_args' ) );
142
+		if ($this->token_exists) {
143
+			add_filter('give_can_view_receipt', '__return_true');
144
+			add_filter('give_user_pending_verification', '__return_false');
145
+			add_filter('give_get_users_donations_args', array($this, 'users_donations_args'));
146 146
 		}
147 147
 
148 148
 	}
@@ -157,25 +157,25 @@  discard block
 block discarded – undo
157 157
 	 *
158 158
 	 * @return bool
159 159
 	 */
160
-	public function can_send_email( $customer_id ) {
160
+	public function can_send_email($customer_id) {
161 161
 		/* @var WPDB $wpdb */
162 162
 		global $wpdb;
163 163
 
164 164
 		// Prevent multiple emails within X minutes
165
-		$throttle = date( 'Y-m-d H:i:s', time() - $this->verify_throttle );
165
+		$throttle = date('Y-m-d H:i:s', time() - $this->verify_throttle);
166 166
 
167 167
 		// Does a user row exist?
168 168
 		$exists = (int) $wpdb->get_var(
169
-			$wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->prefix}give_customers WHERE id = %d", $customer_id )
169
+			$wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->prefix}give_customers WHERE id = %d", $customer_id)
170 170
 		);
171 171
 
172
-		if ( 0 < $exists ) {
172
+		if (0 < $exists) {
173 173
 			$row_id = (int) $wpdb->get_var(
174
-				$wpdb->prepare( "SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d AND (verify_throttle < %s OR verify_key = '') LIMIT 1", $customer_id, $throttle )
174
+				$wpdb->prepare("SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d AND (verify_throttle < %s OR verify_key = '') LIMIT 1", $customer_id, $throttle)
175 175
 			);
176 176
 
177
-			if ( $row_id < 1 ) {
178
-				give_set_error( 'give_email_access_attempts_exhausted', __( 'Please wait a few minutes before requesting a new email access link.', 'give' ) );
177
+			if ($row_id < 1) {
178
+				give_set_error('give_email_access_attempts_exhausted', __('Please wait a few minutes before requesting a new email access link.', 'give'));
179 179
 
180 180
 				return false;
181 181
 			}
@@ -195,34 +195,34 @@  discard block
 block discarded – undo
195 195
 	 *
196 196
 	 * @return void
197 197
 	 */
198
-	public function send_email( $customer_id, $email ) {
198
+	public function send_email($customer_id, $email) {
199 199
 
200
-		$verify_key = wp_generate_password( 20, false );
200
+		$verify_key = wp_generate_password(20, false);
201 201
 
202 202
 		// Generate a new verify key
203
-		$this->set_verify_key( $customer_id, $email, $verify_key );
203
+		$this->set_verify_key($customer_id, $email, $verify_key);
204 204
 
205 205
 		// Get the donation history page
206
-		$page_id = give_get_option( 'history_page' );
206
+		$page_id = give_get_option('history_page');
207 207
 
208
-		$access_url = add_query_arg( array(
208
+		$access_url = add_query_arg(array(
209 209
 			'give_nl' => $verify_key,
210
-		), get_permalink( $page_id ) );
210
+		), get_permalink($page_id));
211 211
 
212 212
 		// Nice subject and message.
213
-		$subject = apply_filters( 'give_email_access_token_subject', sprintf( __( 'Your Access Link to %s', 'give' ), get_bloginfo( 'name' ) ) );
213
+		$subject = apply_filters('give_email_access_token_subject', sprintf(__('Your Access Link to %s', 'give'), get_bloginfo('name')));
214 214
 
215
-		$message = __( '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";
216
-		$message .= '<a href="' . esc_url( $access_url ) . '" target="_blank">' . __( 'Access Donation Details &raquo;', 'give' ) . '</a>' . "\n\n";
215
+		$message = __('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";
216
+		$message .= '<a href="'.esc_url($access_url).'" target="_blank">'.__('Access Donation Details &raquo;', 'give').'</a>'."\n\n";
217 217
 		$message .= "\n\n";
218
-		$message .= __( 'Sincerely,', 'give' ) . "\n";
219
-		$message .= get_bloginfo( 'name' ) . "\n";
218
+		$message .= __('Sincerely,', 'give')."\n";
219
+		$message .= get_bloginfo('name')."\n";
220 220
 
221
-		$message = apply_filters( 'give_email_access_token_message', $message );
221
+		$message = apply_filters('give_email_access_token_message', $message);
222 222
 
223 223
 		// Send the email.
224
-		Give()->emails->__set( 'heading', apply_filters( 'give_email_access_token_heading', __( 'Your Access Link', 'give' ) ) );
225
-		Give()->emails->send( $email, $subject, $message );
224
+		Give()->emails->__set('heading', apply_filters('give_email_access_token_heading', __('Your Access Link', 'give')));
225
+		Give()->emails->send($email, $subject, $message);
226 226
 
227 227
 	}
228 228
 
@@ -236,26 +236,26 @@  discard block
 block discarded – undo
236 236
 	 */
237 237
 	public function check_for_token() {
238 238
 
239
-		$token = isset( $_GET['give_nl'] ) ? $_GET['give_nl'] : '';
239
+		$token = isset($_GET['give_nl']) ? $_GET['give_nl'] : '';
240 240
 
241 241
 		// Check for cookie.
242
-		if ( empty( $token ) ) {
243
-			$token = isset( $_COOKIE['give_nl'] ) ? $_COOKIE['give_nl'] : '';
242
+		if (empty($token)) {
243
+			$token = isset($_COOKIE['give_nl']) ? $_COOKIE['give_nl'] : '';
244 244
 		}
245 245
 
246 246
 		// Must have a token.
247
-		if ( ! empty( $token ) ) {
247
+		if ( ! empty($token)) {
248 248
 
249
-			if ( ! $this->is_valid_token( $token ) ) {
250
-				if ( ! $this->is_valid_verify_key( $token ) ) {
249
+			if ( ! $this->is_valid_token($token)) {
250
+				if ( ! $this->is_valid_verify_key($token)) {
251 251
 					return;
252 252
 				}
253 253
 			}
254 254
 
255 255
 			$this->token_exists = true;
256 256
 			// Set cookie.
257
-			$lifetime = current_time( 'timestamp' ) + Give()->session->set_expiration_time();
258
-			@setcookie( 'give_nl', $token, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false );
257
+			$lifetime = current_time('timestamp') + Give()->session->set_expiration_time();
258
+			@setcookie('give_nl', $token, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false);
259 259
 
260 260
 			return true;
261 261
 		}
@@ -271,26 +271,26 @@  discard block
 block discarded – undo
271 271
 	 *
272 272
 	 * @return bool
273 273
 	 */
274
-	public function is_valid_token( $token ) {
274
+	public function is_valid_token($token) {
275 275
 
276 276
 		global $wpdb;
277 277
 
278 278
 		// Make sure token isn't expired.
279
-		$expires = date( 'Y-m-d H:i:s', time() - $this->token_expiration );
279
+		$expires = date('Y-m-d H:i:s', time() - $this->token_expiration);
280 280
 
281 281
 		$email = $wpdb->get_var(
282
-			$wpdb->prepare( "SELECT email FROM {$wpdb->prefix}give_customers WHERE token = %s AND verify_throttle >= %s LIMIT 1", $token, $expires )
282
+			$wpdb->prepare("SELECT email FROM {$wpdb->prefix}give_customers WHERE token = %s AND verify_throttle >= %s LIMIT 1", $token, $expires)
283 283
 		);
284 284
 
285
-		if ( ! empty( $email ) ) {
285
+		if ( ! empty($email)) {
286 286
 			$this->token_email = $email;
287 287
 			$this->token       = $token;
288 288
 			return true;
289 289
 		}
290 290
 
291 291
 		// Set error only if email access form isn't being submitted
292
-		if ( ! isset( $_POST['give_email'] ) && ! isset( $_POST['_wpnonce'] ) ) {
293
-			give_set_error( 'give_email_token_expired', apply_filters( 'give_email_token_expired_message', __( 'Your access token has expired. Please request a new one below:', 'give' ) ) );
292
+		if ( ! isset($_POST['give_email']) && ! isset($_POST['_wpnonce'])) {
293
+			give_set_error('give_email_token_expired', apply_filters('give_email_token_expired_message', __('Your access token has expired. Please request a new one below:', 'give')));
294 294
 		}
295 295
 
296 296
 		return false;
@@ -309,25 +309,25 @@  discard block
 block discarded – undo
309 309
 	 *
310 310
 	 * @return void
311 311
 	 */
312
-	public function set_verify_key( $customer_id, $email, $verify_key ) {
312
+	public function set_verify_key($customer_id, $email, $verify_key) {
313 313
 		global $wpdb;
314 314
 
315
-		$now = date( 'Y-m-d H:i:s' );
315
+		$now = date('Y-m-d H:i:s');
316 316
 
317 317
 		// Insert or update?
318 318
 		$row_id = (int) $wpdb->get_var(
319
-			$wpdb->prepare( "SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d LIMIT 1", $customer_id )
319
+			$wpdb->prepare("SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d LIMIT 1", $customer_id)
320 320
 		);
321 321
 
322 322
 		// Update.
323
-		if ( ! empty( $row_id ) ) {
323
+		if ( ! empty($row_id)) {
324 324
 			$wpdb->query(
325
-				$wpdb->prepare( "UPDATE {$wpdb->prefix}give_customers SET verify_key = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $verify_key, $now, $row_id )
325
+				$wpdb->prepare("UPDATE {$wpdb->prefix}give_customers SET verify_key = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $verify_key, $now, $row_id)
326 326
 			);
327 327
 		} // Insert.
328 328
 		else {
329 329
 			$wpdb->query(
330
-				$wpdb->prepare( "INSERT INTO {$wpdb->prefix}give_customers ( verify_key, verify_throttle) VALUES (%s, %s)", $verify_key, $now )
330
+				$wpdb->prepare("INSERT INTO {$wpdb->prefix}give_customers ( verify_key, verify_throttle) VALUES (%s, %s)", $verify_key, $now)
331 331
 			);
332 332
 		}
333 333
 	}
@@ -342,21 +342,21 @@  discard block
 block discarded – undo
342 342
 	 *
343 343
 	 * @return bool
344 344
 	 */
345
-	public function is_valid_verify_key( $token ) {
345
+	public function is_valid_verify_key($token) {
346 346
 		/* @var WPDB $wpdb */
347 347
 		global $wpdb;
348 348
 
349 349
 		// See if the verify_key exists.
350 350
 		$row = $wpdb->get_row(
351
-			$wpdb->prepare( "SELECT id, email FROM {$wpdb->prefix}give_customers WHERE verify_key = %s LIMIT 1", $token )
351
+			$wpdb->prepare("SELECT id, email FROM {$wpdb->prefix}give_customers WHERE verify_key = %s LIMIT 1", $token)
352 352
 		);
353 353
 
354
-		$now = date( 'Y-m-d H:i:s' );
354
+		$now = date('Y-m-d H:i:s');
355 355
 
356 356
 		// Set token and remove verify key.
357
-		if ( ! empty( $row ) ) {
357
+		if ( ! empty($row)) {
358 358
 			$wpdb->query(
359
-				$wpdb->prepare( "UPDATE {$wpdb->prefix}give_customers SET verify_key = '', token = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $token, $now, $row->id )
359
+				$wpdb->prepare("UPDATE {$wpdb->prefix}give_customers SET verify_key = '', token = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $token, $now, $row->id)
360 360
 			);
361 361
 
362 362
 			$this->token_email = $row->email;
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 	 *
381 381
 	 * @return mixed
382 382
 	 */
383
-	public function users_donations_args( $args ) {
383
+	public function users_donations_args($args) {
384 384
 		$args['user'] = $this->token_email;
385 385
 
386 386
 		return $args;
@@ -401,11 +401,11 @@  discard block
 block discarded – undo
401 401
 		global $wpdb;
402 402
 
403 403
 		// Create columns in customers table
404
-		$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`" );
404
+		$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`");
405 405
 
406 406
 		// Columns added properly
407
-		if ( $query ) {
408
-			give_update_option( 'email_access_installed', 1 );
407
+		if ($query) {
408
+			give_update_option('email_access_installed', 1);
409 409
 		}
410 410
 
411 411
 	}
Please login to merge, or discard this patch.
includes/admin/EDD_SL_Plugin_Updater.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@
 block discarded – undo
77 77
 	 * @uses api_request()
78 78
 	 *
79 79
 	 * @param array   $_transient_data Update array build by WordPress.
80
-	 * @return array Modified update array with custom plugin data.
80
+	 * @return stdClass Modified update array with custom plugin data.
81 81
 	 */
82 82
 	public function check_update( $_transient_data ) {
83 83
 
Please login to merge, or discard this patch.
Spacing   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Exit if accessed directly
4
-if ( ! defined( 'ABSPATH' ) ) exit;
4
+if ( ! defined('ABSPATH')) exit;
5 5
 
6 6
 /**
7 7
  * Allows plugins to use their own update API.
@@ -29,20 +29,20 @@  discard block
 block discarded – undo
29 29
 	 * @param string  $_plugin_file Path to the plugin file.
30 30
 	 * @param array   $_api_data    Optional data to send with API calls.
31 31
 	 */
32
-	public function __construct( $_api_url, $_plugin_file, $_api_data = null ) {
32
+	public function __construct($_api_url, $_plugin_file, $_api_data = null) {
33 33
 
34 34
 		global $edd_plugin_data;
35 35
 
36
-		$this->api_url     = trailingslashit( $_api_url );
36
+		$this->api_url     = trailingslashit($_api_url);
37 37
 		$this->api_data    = $_api_data;
38
-		$this->name        = plugin_basename( $_plugin_file );
39
-		$this->slug        = basename( $_plugin_file, '.php' );
38
+		$this->name        = plugin_basename($_plugin_file);
39
+		$this->slug        = basename($_plugin_file, '.php');
40 40
 		$this->version     = $_api_data['version'];
41
-		$this->wp_override = isset( $_api_data['wp_override'] ) ? (bool) $_api_data['wp_override'] : false;
42
-		$this->beta        = ! empty( $this->api_data['beta'] ) ? true : false;
43
-		$this->cache_key   = md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) );
41
+		$this->wp_override = isset($_api_data['wp_override']) ? (bool) $_api_data['wp_override'] : false;
42
+		$this->beta        = ! empty($this->api_data['beta']) ? true : false;
43
+		$this->cache_key   = md5(serialize($this->slug.$this->api_data['license'].$this->beta));
44 44
 
45
-		$edd_plugin_data[ $this->slug ] = $this->api_data;
45
+		$edd_plugin_data[$this->slug] = $this->api_data;
46 46
 
47 47
 		// Set up hooks.
48 48
 		$this->init();
@@ -58,11 +58,11 @@  discard block
 block discarded – undo
58 58
 	 */
59 59
 	public function init() {
60 60
 
61
-		add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
62
-		add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
63
-		remove_action( 'after_plugin_row_' . $this->name, 'wp_plugin_update_row', 10 );
64
-		add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 );
65
-		add_action( 'admin_init', array( $this, 'show_changelog' ) );
61
+		add_filter('pre_set_site_transient_update_plugins', array($this, 'check_update'));
62
+		add_filter('plugins_api', array($this, 'plugins_api_filter'), 10, 3);
63
+		remove_action('after_plugin_row_'.$this->name, 'wp_plugin_update_row', 10);
64
+		add_action('after_plugin_row_'.$this->name, array($this, 'show_update_notification'), 10, 2);
65
+		add_action('admin_init', array($this, 'show_changelog'));
66 66
 
67 67
 	}
68 68
 
@@ -79,41 +79,41 @@  discard block
 block discarded – undo
79 79
 	 * @param array   $_transient_data Update array build by WordPress.
80 80
 	 * @return array Modified update array with custom plugin data.
81 81
 	 */
82
-	public function check_update( $_transient_data ) {
82
+	public function check_update($_transient_data) {
83 83
 
84 84
 		global $pagenow;
85 85
 
86
-		if ( ! is_object( $_transient_data ) ) {
86
+		if ( ! is_object($_transient_data)) {
87 87
 			$_transient_data = new stdClass;
88 88
 		}
89 89
 
90
-		if ( 'plugins.php' == $pagenow && is_multisite() ) {
90
+		if ('plugins.php' == $pagenow && is_multisite()) {
91 91
 			return $_transient_data;
92 92
 		}
93 93
 
94
-		if ( ! empty( $_transient_data->response ) && ! empty( $_transient_data->response[ $this->name ] ) && false === $this->wp_override ) {
94
+		if ( ! empty($_transient_data->response) && ! empty($_transient_data->response[$this->name]) && false === $this->wp_override) {
95 95
 			return $_transient_data;
96 96
 		}
97 97
 
98 98
 		$version_info = $this->get_cached_version_info();
99 99
 
100
-		if ( false === $version_info ) {
101
-			$version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) );
100
+		if (false === $version_info) {
101
+			$version_info = $this->api_request('plugin_latest_version', array('slug' => $this->slug, 'beta' => $this->beta));
102 102
 
103
-			$this->set_version_info_cache( $version_info );
103
+			$this->set_version_info_cache($version_info);
104 104
 
105 105
 		}
106 106
 
107
-		if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
107
+		if (false !== $version_info && is_object($version_info) && isset($version_info->new_version)) {
108 108
 
109
-			if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
109
+			if (version_compare($this->version, $version_info->new_version, '<')) {
110 110
 
111
-				$_transient_data->response[ $this->name ] = $version_info;
111
+				$_transient_data->response[$this->name] = $version_info;
112 112
 
113 113
 			}
114 114
 
115
-			$_transient_data->last_checked           = current_time( 'timestamp' );
116
-			$_transient_data->checked[ $this->name ] = $this->version;
115
+			$_transient_data->last_checked           = current_time('timestamp');
116
+			$_transient_data->checked[$this->name] = $this->version;
117 117
 
118 118
 		}
119 119
 
@@ -126,97 +126,97 @@  discard block
 block discarded – undo
126 126
 	 * @param string  $file
127 127
 	 * @param array   $plugin
128 128
 	 */
129
-	public function show_update_notification( $file, $plugin ) {
129
+	public function show_update_notification($file, $plugin) {
130 130
 
131
-		if ( is_network_admin() ) {
131
+		if (is_network_admin()) {
132 132
 			return;
133 133
 		}
134 134
 
135
-		if( ! current_user_can( 'update_plugins' ) ) {
135
+		if ( ! current_user_can('update_plugins')) {
136 136
 			return;
137 137
 		}
138 138
 
139
-		if( ! is_multisite() ) {
139
+		if ( ! is_multisite()) {
140 140
 			return;
141 141
 		}
142 142
 
143
-		if ( $this->name != $file ) {
143
+		if ($this->name != $file) {
144 144
 			return;
145 145
 		}
146 146
 
147 147
 		// Remove our filter on the site transient
148
-		remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 );
148
+		remove_filter('pre_set_site_transient_update_plugins', array($this, 'check_update'), 10);
149 149
 
150
-		$update_cache = get_site_transient( 'update_plugins' );
150
+		$update_cache = get_site_transient('update_plugins');
151 151
 
152
-		$update_cache = is_object( $update_cache ) ? $update_cache : new stdClass();
152
+		$update_cache = is_object($update_cache) ? $update_cache : new stdClass();
153 153
 
154
-		if ( empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) {
154
+		if (empty($update_cache->response) || empty($update_cache->response[$this->name])) {
155 155
 
156 156
 			$version_info = $this->get_cached_version_info();
157 157
 
158
-			if ( false === $version_info ) {
159
-				$version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) );
158
+			if (false === $version_info) {
159
+				$version_info = $this->api_request('plugin_latest_version', array('slug' => $this->slug, 'beta' => $this->beta));
160 160
 
161
-				$this->set_version_info_cache( $version_info );
161
+				$this->set_version_info_cache($version_info);
162 162
 			}
163 163
 
164
-			if ( ! is_object( $version_info ) ) {
164
+			if ( ! is_object($version_info)) {
165 165
 				return;
166 166
 			}
167 167
 
168
-			if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
168
+			if (version_compare($this->version, $version_info->new_version, '<')) {
169 169
 
170
-				$update_cache->response[ $this->name ] = $version_info;
170
+				$update_cache->response[$this->name] = $version_info;
171 171
 
172 172
 			}
173 173
 
174
-			$update_cache->last_checked = current_time( 'timestamp' );
175
-			$update_cache->checked[ $this->name ] = $this->version;
174
+			$update_cache->last_checked = current_time('timestamp');
175
+			$update_cache->checked[$this->name] = $this->version;
176 176
 
177
-			set_site_transient( 'update_plugins', $update_cache );
177
+			set_site_transient('update_plugins', $update_cache);
178 178
 
179 179
 		} else {
180 180
 
181
-			$version_info = $update_cache->response[ $this->name ];
181
+			$version_info = $update_cache->response[$this->name];
182 182
 
183 183
 		}
184 184
 
185 185
 		// Restore our filter
186
-		add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
186
+		add_filter('pre_set_site_transient_update_plugins', array($this, 'check_update'));
187 187
 
188
-		if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {
188
+		if ( ! empty($update_cache->response[$this->name]) && version_compare($this->version, $version_info->new_version, '<')) {
189 189
 
190 190
 			// build a plugin list row, with update notification
191
-			$wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
191
+			$wp_list_table = _get_list_table('WP_Plugins_List_Table');
192 192
 			# <tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange">
193
-			echo '<tr class="plugin-update-tr" id="' . $this->slug . '-update" data-slug="' . $this->slug . '" data-plugin="' . $this->slug . '/' . $file . '">';
193
+			echo '<tr class="plugin-update-tr" id="'.$this->slug.'-update" data-slug="'.$this->slug.'" data-plugin="'.$this->slug.'/'.$file.'">';
194 194
 			echo '<td colspan="3" class="plugin-update colspanchange">';
195 195
 			echo '<div class="update-message notice inline notice-warning notice-alt">';
196 196
 
197
-			$changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' );
197
+			$changelog_link = self_admin_url('index.php?edd_sl_action=view_plugin_changelog&plugin='.$this->name.'&slug='.$this->slug.'&TB_iframe=true&width=772&height=911');
198 198
 
199
-			if ( empty( $version_info->download_link ) ) {
199
+			if (empty($version_info->download_link)) {
200 200
 				printf(
201
-					__( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s.', 'easy-digital-downloads' ),
202
-					esc_html( $version_info->name ),
203
-					'<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
204
-					esc_html( $version_info->new_version ),
201
+					__('There is a new version of %1$s available. %2$sView version %3$s details%4$s.', 'easy-digital-downloads'),
202
+					esc_html($version_info->name),
203
+					'<a target="_blank" class="thickbox" href="'.esc_url($changelog_link).'">',
204
+					esc_html($version_info->new_version),
205 205
 					'</a>'
206 206
 				);
207 207
 			} else {
208 208
 				printf(
209
-					__( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s or %5$supdate now%6$s.', 'easy-digital-downloads' ),
210
-					esc_html( $version_info->name ),
211
-					'<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
212
-					esc_html( $version_info->new_version ),
209
+					__('There is a new version of %1$s available. %2$sView version %3$s details%4$s or %5$supdate now%6$s.', 'easy-digital-downloads'),
210
+					esc_html($version_info->name),
211
+					'<a target="_blank" class="thickbox" href="'.esc_url($changelog_link).'">',
212
+					esc_html($version_info->new_version),
213 213
 					'</a>',
214
-					'<a href="' . esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) .'">',
214
+					'<a href="'.esc_url(wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=').$this->name, 'upgrade-plugin_'.$this->name)).'">',
215 215
 					'</a>'
216 216
 				);
217 217
 			}
218 218
 
219
-			do_action( "in_plugin_update_message-{$file}", $plugin, $version_info );
219
+			do_action("in_plugin_update_message-{$file}", $plugin, $version_info);
220 220
 
221 221
 			echo '</div></td></tr>';
222 222
 		}
@@ -232,15 +232,15 @@  discard block
 block discarded – undo
232 232
 	 * @param object  $_args
233 233
 	 * @return object $_data
234 234
 	 */
235
-	public function plugins_api_filter( $_data, $_action = '', $_args = null ) {
235
+	public function plugins_api_filter($_data, $_action = '', $_args = null) {
236 236
 
237
-		if ( $_action != 'plugin_information' ) {
237
+		if ($_action != 'plugin_information') {
238 238
 
239 239
 			return $_data;
240 240
 
241 241
 		}
242 242
 
243
-		if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) {
243
+		if ( ! isset($_args->slug) || ($_args->slug != $this->slug)) {
244 244
 
245 245
 			return $_data;
246 246
 
@@ -255,20 +255,20 @@  discard block
 block discarded – undo
255 255
 			)
256 256
 		);
257 257
 
258
-		$cache_key = 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) );
258
+		$cache_key = 'edd_api_request_'.md5(serialize($this->slug.$this->api_data['license'].$this->beta));
259 259
 
260 260
 		// Get the transient where we store the api request for this plugin for 24 hours
261
-		$edd_api_request_transient = $this->get_cached_version_info( $cache_key );
261
+		$edd_api_request_transient = $this->get_cached_version_info($cache_key);
262 262
 
263 263
 		//If we have no transient-saved value, run the API, set a fresh transient with the API value, and return that value too right now.
264
-		if ( empty( $edd_api_request_transient ) ) {
264
+		if (empty($edd_api_request_transient)) {
265 265
 
266
-			$api_response = $this->api_request( 'plugin_information', $to_send );
266
+			$api_response = $this->api_request('plugin_information', $to_send);
267 267
 
268 268
 			// Expires in 3 hours
269
-			$this->set_version_info_cache( $api_response, $cache_key );
269
+			$this->set_version_info_cache($api_response, $cache_key);
270 270
 
271
-			if ( false !== $api_response ) {
271
+			if (false !== $api_response) {
272 272
 				$_data = $api_response;
273 273
 			}
274 274
 
@@ -277,20 +277,20 @@  discard block
 block discarded – undo
277 277
 		}
278 278
 
279 279
 		// Convert sections into an associative array, since we're getting an object, but Core expects an array.
280
-		if ( isset( $_data->sections ) && ! is_array( $_data->sections ) ) {
280
+		if (isset($_data->sections) && ! is_array($_data->sections)) {
281 281
 			$new_sections = array();
282
-			foreach ( $_data->sections as $key => $key ) {
283
-				$new_sections[ $key ] = $key;
282
+			foreach ($_data->sections as $key => $key) {
283
+				$new_sections[$key] = $key;
284 284
 			}
285 285
 
286 286
 			$_data->sections = $new_sections;
287 287
 		}
288 288
 
289 289
 		// Convert banners into an associative array, since we're getting an object, but Core expects an array.
290
-		if ( isset( $_data->banners ) && ! is_array( $_data->banners ) ) {
290
+		if (isset($_data->banners) && ! is_array($_data->banners)) {
291 291
 			$new_banners = array();
292
-			foreach ( $_data->banners as $key => $key ) {
293
-				$new_banners[ $key ] = $key;
292
+			foreach ($_data->banners as $key => $key) {
293
+				$new_banners[$key] = $key;
294 294
 			}
295 295
 
296 296
 			$_data->banners = $new_banners;
@@ -306,9 +306,9 @@  discard block
 block discarded – undo
306 306
 	 * @param string  $url
307 307
 	 * @return object $array
308 308
 	 */
309
-	public function http_request_args( $args, $url ) {
309
+	public function http_request_args($args, $url) {
310 310
 		// If it is an https request and we are performing a package download, disable ssl verification
311
-		if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
311
+		if (strpos($url, 'https://') !== false && strpos($url, 'edd_action=package_download')) {
312 312
 			$args['sslverify'] = false;
313 313
 		}
314 314
 		return $args;
@@ -325,50 +325,50 @@  discard block
 block discarded – undo
325 325
 	 * @param array   $_data   Parameters for the API action.
326 326
 	 * @return false|object
327 327
 	 */
328
-	private function api_request( $_action, $_data ) {
328
+	private function api_request($_action, $_data) {
329 329
 
330 330
 		global $wp_version;
331 331
 
332
-		$data = array_merge( $this->api_data, $_data );
332
+		$data = array_merge($this->api_data, $_data);
333 333
 
334
-		if ( $data['slug'] != $this->slug ) {
334
+		if ($data['slug'] != $this->slug) {
335 335
 			return;
336 336
 		}
337 337
 
338
-		if( $this->api_url == trailingslashit (home_url() ) ) {
338
+		if ($this->api_url == trailingslashit(home_url())) {
339 339
 			return false; // Don't allow a plugin to ping itself
340 340
 		}
341 341
 
342 342
 		$api_params = array(
343 343
 			'edd_action' => 'get_version',
344
-			'license'    => ! empty( $data['license'] ) ? $data['license'] : '',
345
-			'item_name'  => isset( $data['item_name'] ) ? $data['item_name'] : false,
346
-			'item_id'    => isset( $data['item_id'] ) ? $data['item_id'] : false,
347
-			'version'    => isset( $data['version'] ) ? $data['version'] : false,
344
+			'license'    => ! empty($data['license']) ? $data['license'] : '',
345
+			'item_name'  => isset($data['item_name']) ? $data['item_name'] : false,
346
+			'item_id'    => isset($data['item_id']) ? $data['item_id'] : false,
347
+			'version'    => isset($data['version']) ? $data['version'] : false,
348 348
 			'slug'       => $data['slug'],
349 349
 			'author'     => $data['author'],
350 350
 			'url'        => home_url(),
351
-			'beta'       => ! empty( $data['beta'] ),
351
+			'beta'       => ! empty($data['beta']),
352 352
 		);
353 353
 
354
-		$request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
354
+		$request = wp_remote_post($this->api_url, array('timeout' => 15, 'sslverify' => false, 'body' => $api_params));
355 355
 
356
-		if ( ! is_wp_error( $request ) ) {
357
-			$request = json_decode( wp_remote_retrieve_body( $request ) );
356
+		if ( ! is_wp_error($request)) {
357
+			$request = json_decode(wp_remote_retrieve_body($request));
358 358
 		}
359 359
 
360
-		if ( $request && isset( $request->sections ) ) {
361
-			$request->sections = maybe_unserialize( $request->sections );
360
+		if ($request && isset($request->sections)) {
361
+			$request->sections = maybe_unserialize($request->sections);
362 362
 		} else {
363 363
 			$request = false;
364 364
 		}
365 365
 
366
-		if ( $request && isset( $request->banners ) ) {
367
-			$request->banners = maybe_unserialize( $request->banners );
366
+		if ($request && isset($request->banners)) {
367
+			$request->banners = maybe_unserialize($request->banners);
368 368
 		}
369 369
 
370
-		if( ! empty( $request->sections ) ) {
371
-			foreach( $request->sections as $key => $section ) {
370
+		if ( ! empty($request->sections)) {
371
+			foreach ($request->sections as $key => $section) {
372 372
 				$request->$key = (array) $section;
373 373
 			}
374 374
 		}
@@ -380,97 +380,97 @@  discard block
 block discarded – undo
380 380
 
381 381
 		global $edd_plugin_data;
382 382
 
383
-		if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
383
+		if (empty($_REQUEST['edd_sl_action']) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action']) {
384 384
 			return;
385 385
 		}
386 386
 
387
-		if( empty( $_REQUEST['plugin'] ) ) {
387
+		if (empty($_REQUEST['plugin'])) {
388 388
 			return;
389 389
 		}
390 390
 
391
-		if( empty( $_REQUEST['slug'] ) ) {
391
+		if (empty($_REQUEST['slug'])) {
392 392
 			return;
393 393
 		}
394 394
 
395
-		if( ! current_user_can( 'update_plugins' ) ) {
396
-			wp_die( __( 'You do not have permission to install plugin updates', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) );
395
+		if ( ! current_user_can('update_plugins')) {
396
+			wp_die(__('You do not have permission to install plugin updates', 'easy-digital-downloads'), __('Error', 'easy-digital-downloads'), array('response' => 403));
397 397
 		}
398 398
 
399
-		$data         = $edd_plugin_data[ $_REQUEST['slug'] ];
400
-		$beta         = ! empty( $data['beta'] ) ? true : false;
401
-		$cache_key    = md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_' . $beta . '_version_info' );
402
-		$version_info = $this->get_cached_version_info( $cache_key );
399
+		$data         = $edd_plugin_data[$_REQUEST['slug']];
400
+		$beta         = ! empty($data['beta']) ? true : false;
401
+		$cache_key    = md5('edd_plugin_'.sanitize_key($_REQUEST['plugin']).'_'.$beta.'_version_info');
402
+		$version_info = $this->get_cached_version_info($cache_key);
403 403
 
404
-		if( false === $version_info ) {
404
+		if (false === $version_info) {
405 405
 
406 406
 			$api_params = array(
407 407
 				'edd_action' => 'get_version',
408
-				'item_name'  => isset( $data['item_name'] ) ? $data['item_name'] : false,
409
-				'item_id'    => isset( $data['item_id'] ) ? $data['item_id'] : false,
408
+				'item_name'  => isset($data['item_name']) ? $data['item_name'] : false,
409
+				'item_id'    => isset($data['item_id']) ? $data['item_id'] : false,
410 410
 				'slug'       => $_REQUEST['slug'],
411 411
 				'author'     => $data['author'],
412 412
 				'url'        => home_url(),
413
-				'beta'       => ! empty( $data['beta'] )
413
+				'beta'       => ! empty($data['beta'])
414 414
 			);
415 415
 
416
-			$request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
416
+			$request = wp_remote_post($this->api_url, array('timeout' => 15, 'sslverify' => false, 'body' => $api_params));
417 417
 
418
-			if ( ! is_wp_error( $request ) ) {
419
-				$version_info = json_decode( wp_remote_retrieve_body( $request ) );
418
+			if ( ! is_wp_error($request)) {
419
+				$version_info = json_decode(wp_remote_retrieve_body($request));
420 420
 			}
421 421
 
422 422
 
423
-			if ( ! empty( $version_info ) && isset( $version_info->sections ) ) {
424
-				$version_info->sections = maybe_unserialize( $version_info->sections );
423
+			if ( ! empty($version_info) && isset($version_info->sections)) {
424
+				$version_info->sections = maybe_unserialize($version_info->sections);
425 425
 			} else {
426 426
 				$version_info = false;
427 427
 			}
428 428
 
429
-			if( ! empty( $version_info ) ) {
430
-				foreach( $version_info->sections as $key => $section ) {
429
+			if ( ! empty($version_info)) {
430
+				foreach ($version_info->sections as $key => $section) {
431 431
 					$version_info->$key = (array) $section;
432 432
 				}
433 433
 			}
434 434
 
435
-			$this->set_version_info_cache( $version_info, $cache_key );
435
+			$this->set_version_info_cache($version_info, $cache_key);
436 436
 
437 437
 		}
438 438
 
439
-		if( ! empty( $version_info ) && isset( $version_info->sections['changelog'] ) ) {
440
-			echo '<div style="background:#fff;padding:10px;">' . $version_info->sections['changelog'] . '</div>';
439
+		if ( ! empty($version_info) && isset($version_info->sections['changelog'])) {
440
+			echo '<div style="background:#fff;padding:10px;">'.$version_info->sections['changelog'].'</div>';
441 441
 		}
442 442
 
443 443
 		exit;
444 444
 	}
445 445
 
446
-	public function get_cached_version_info( $cache_key = '' ) {
446
+	public function get_cached_version_info($cache_key = '') {
447 447
 
448
-		if( empty( $cache_key ) ) {
448
+		if (empty($cache_key)) {
449 449
 			$cache_key = $this->cache_key;
450 450
 		}
451 451
 
452
-		$cache = get_option( $cache_key );
452
+		$cache = get_option($cache_key);
453 453
 
454
-		if( empty( $cache['timeout'] ) || current_time( 'timestamp' ) > $cache['timeout'] ) {
454
+		if (empty($cache['timeout']) || current_time('timestamp') > $cache['timeout']) {
455 455
 			return false; // Cache is expired
456 456
 		}
457 457
 
458
-		return json_decode( $cache['value'] );
458
+		return json_decode($cache['value']);
459 459
 
460 460
 	}
461 461
 
462
-	public function set_version_info_cache( $value = '', $cache_key = '' ) {
462
+	public function set_version_info_cache($value = '', $cache_key = '') {
463 463
 
464
-		if( empty( $cache_key ) ) {
464
+		if (empty($cache_key)) {
465 465
 			$cache_key = $this->cache_key;
466 466
 		}
467 467
 
468 468
 		$data = array(
469
-			'timeout' => strtotime( '+3 hours', current_time( 'timestamp' ) ),
470
-			'value'   => json_encode( $value )
469
+			'timeout' => strtotime('+3 hours', current_time('timestamp')),
470
+			'value'   => json_encode($value)
471 471
 		);
472 472
 
473
-		update_option( $cache_key, $data );
473
+		update_option($cache_key, $data);
474 474
 
475 475
 	}
476 476
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,9 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Exit if accessed directly
4
-if ( ! defined( 'ABSPATH' ) ) exit;
4
+if ( ! defined( 'ABSPATH' ) ) {
5
+	exit;
6
+}
5 7
 
6 8
 /**
7 9
  * Allows plugins to use their own update API.
Please login to merge, or discard this patch.
includes/admin/settings/class-settings-license.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -9,11 +9,11 @@  discard block
 block discarded – undo
9 9
  * @since       1.8
10 10
  */
11 11
 
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit; // Exit if accessed directly
14 14
 }
15 15
 
16
-if ( ! class_exists( 'Give_Settings_License' ) ) :
16
+if ( ! class_exists('Give_Settings_License')) :
17 17
 
18 18
 	/**
19 19
 	 * Give_Settings_License.
@@ -43,11 +43,11 @@  discard block
 block discarded – undo
43 43
 		 */
44 44
 		public function __construct() {
45 45
 			$this->id    = 'licenses';
46
-			$this->label = esc_html__( 'Licenses', 'give' );
46
+			$this->label = esc_html__('Licenses', 'give');
47 47
 
48
-			add_filter( 'give-settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
49
-			add_action( "give-settings_settings_{$this->id}_page", array( $this, 'output' ) );
50
-			add_action( "give-settings_save_{$this->id}", array( $this, 'save' ) );
48
+			add_filter('give-settings_tabs_array', array($this, 'add_settings_page'), 20);
49
+			add_action("give-settings_settings_{$this->id}_page", array($this, 'output'));
50
+			add_action("give-settings_save_{$this->id}", array($this, 'save'));
51 51
 		}
52 52
 
53 53
 		/**
@@ -57,11 +57,11 @@  discard block
 block discarded – undo
57 57
 		 * @param  array $pages Lst of pages.
58 58
 		 * @return array
59 59
 		 */
60
-		public function add_settings_page( $pages ) {
60
+		public function add_settings_page($pages) {
61 61
 			$setting = $this->get_settings();
62 62
 			// Bailout: Do not add licenses setting tab if it does not contain any setting fields.
63
-			if( ! empty( $setting ) ) {
64
-				$pages[ $this->id ] = $this->label;
63
+			if ( ! empty($setting)) {
64
+				$pages[$this->id] = $this->label;
65 65
 			}
66 66
 
67 67
 			return $pages;
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 			 * Filter the licenses settings.
81 81
 			 * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8
82 82
 			 */
83
-			$settings = apply_filters( 'give_settings_licenses', $settings );
83
+			$settings = apply_filters('give_settings_licenses', $settings);
84 84
 
85 85
 			/**
86 86
 			 * Filter the settings.
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 			 * @since  1.8
89 89
 			 * @param  array $settings
90 90
 			 */
91
-			$settings = apply_filters( 'give_get_settings_' . $this->id, $settings );
91
+			$settings = apply_filters('give_get_settings_'.$this->id, $settings);
92 92
 
93 93
 			// Output.
94 94
 			return $settings;
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 		public function output() {
104 104
 			$settings = $this->get_settings();
105 105
 
106
-			Give_Admin_Settings::output_fields( $settings, 'give_settings' );
106
+			Give_Admin_Settings::output_fields($settings, 'give_settings');
107 107
 		}
108 108
 
109 109
 		/**
@@ -116,14 +116,14 @@  discard block
 block discarded – undo
116 116
 			$settings        = $this->get_settings();
117 117
 			$current_section = give_get_current_setting_section();
118 118
 
119
-			Give_Admin_Settings::save_fields( $settings, 'give_settings' );
119
+			Give_Admin_Settings::save_fields($settings, 'give_settings');
120 120
 
121 121
 			/**
122 122
 			 * Trigger Action
123 123
 			 *
124 124
 			 * @since 1.8
125 125
 			 */
126
-			do_action( 'give_update_options_' . $this->id . '_' . $current_section );
126
+			do_action('give_update_options_'.$this->id.'_'.$current_section);
127 127
 		}
128 128
 	}
129 129
 
Please login to merge, or discard this patch.
includes/admin/class-i18n-module.php 1 patch
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -65,23 +65,23 @@  discard block
 block discarded – undo
65 65
 	 *
66 66
 	 * @param $args
67 67
 	 */
68
-	public function __construct( $args ) {
68
+	public function __construct($args) {
69 69
 
70 70
 		// Only for admins.
71
-		if ( ! is_admin() ) {
71
+		if ( ! is_admin()) {
72 72
 			return;
73 73
 		}
74 74
 
75 75
 		// This plugin is en_US native.
76 76
 		$this->locale = get_locale();
77
-		if ( 'en_US' === $this->locale ) {
77
+		if ('en_US' === $this->locale) {
78 78
 			return;
79 79
 		}
80 80
 
81
-		$this->init( $args );
81
+		$this->init($args);
82 82
 
83
-		if ( ! $this->hide_promo() ) {
84
-			add_action( $this->hook, array( $this, 'promo' ) );
83
+		if ( ! $this->hide_promo()) {
84
+			add_action($this->hook, array($this, 'promo'));
85 85
 		}
86 86
 	}
87 87
 
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
 	 *
93 93
 	 * @param array $args
94 94
 	 */
95
-	private function init( $args ) {
96
-		foreach ( $args as $key => $arg ) {
95
+	private function init($args) {
96
+		foreach ($args as $key => $arg) {
97 97
 			$this->$key = $arg;
98 98
 		}
99 99
 
@@ -107,11 +107,11 @@  discard block
 block discarded – undo
107 107
 	 * @return bool
108 108
 	 */
109 109
 	private function hide_promo() {
110
-		$hide_promo = get_transient( 'give_i18n_give_promo_hide' );
111
-		if ( ! $hide_promo ) {
112
-			if ( filter_input( INPUT_GET, 'remove_i18n_promo', FILTER_VALIDATE_INT ) === 1 ) {
110
+		$hide_promo = get_transient('give_i18n_give_promo_hide');
111
+		if ( ! $hide_promo) {
112
+			if (filter_input(INPUT_GET, 'remove_i18n_promo', FILTER_VALIDATE_INT) === 1) {
113 113
 				// No expiration time, so this would normally not expire, but it wouldn't be copied to other sites etc.
114
-				set_transient( 'give_i18n_give_promo_hide', true );
114
+				set_transient('give_i18n_give_promo_hide', true);
115 115
 				$hide_promo = true;
116 116
 			}
117 117
 		}
@@ -130,20 +130,20 @@  discard block
 block discarded – undo
130 130
 		$message = false;
131 131
 
132 132
 		// Using a translation less than 90% complete.
133
-		if ( $this->translation_exists && $this->translation_loaded && $this->percent_translated < 90 ) {
134
-			$message = __( 'As you can see, there is a translation of this plugin in %1$s. This translation is currently %3$d%% complete. We need your help to make it complete and to fix any errors. Please register at %4$s to help %5$s to %1$s!', 'give' );
135
-		} elseif ( ! $this->translation_loaded && $this->translation_exists ) {
136
-			$message = __( 'You\'re using WordPress in %1$s. While %2$s has been %3$d%% translated to %1$s, it has not been shipped with the plugin yet. You can help! Register at %4$s to help complete the translation to %1$s!', 'give' );
137
-		} elseif ( ! $this->translation_exists ) {
138
-			$message = __( 'You\'re using WordPress in a language we don\'t support yet. We\'d love for %2$s to be translated in that language too, but unfortunately, it isn\'t right now. You can change that! Register at %4$s to help translate it!', 'give' );
133
+		if ($this->translation_exists && $this->translation_loaded && $this->percent_translated < 90) {
134
+			$message = __('As you can see, there is a translation of this plugin in %1$s. This translation is currently %3$d%% complete. We need your help to make it complete and to fix any errors. Please register at %4$s to help %5$s to %1$s!', 'give');
135
+		} elseif ( ! $this->translation_loaded && $this->translation_exists) {
136
+			$message = __('You\'re using WordPress in %1$s. While %2$s has been %3$d%% translated to %1$s, it has not been shipped with the plugin yet. You can help! Register at %4$s to help complete the translation to %1$s!', 'give');
137
+		} elseif ( ! $this->translation_exists) {
138
+			$message = __('You\'re using WordPress in a language we don\'t support yet. We\'d love for %2$s to be translated in that language too, but unfortunately, it isn\'t right now. You can change that! Register at %4$s to help translate it!', 'give');
139 139
 		}
140 140
 
141 141
 		// Links.
142
-		$registration_link = sprintf( '<a href="%1$s" target="_blank">%2$s</a>', 'https://wordpress.org/support/register.php', esc_html__( 'WordPress.org', 'give' ) );
143
-		$translations_link = sprintf( '<a href="%1$s" target="_blank">%2$s</a>', 'https://translate.wordpress.org/projects/wp-plugins/give', esc_html__( 'complete the translation', 'give' ) );
142
+		$registration_link = sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://wordpress.org/support/register.php', esc_html__('WordPress.org', 'give'));
143
+		$translations_link = sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://translate.wordpress.org/projects/wp-plugins/give', esc_html__('complete the translation', 'give'));
144 144
 
145 145
 		// Message.
146
-		$message = sprintf( $message, $this->locale_name, 'Give', $this->percent_translated, $registration_link, $translations_link );
146
+		$message = sprintf($message, $this->locale_name, 'Give', $this->percent_translated, $registration_link, $translations_link);
147 147
 
148 148
 		return $message;
149 149
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 		$this->translation_details();
158 158
 		$message = $this->promo_message();
159 159
 
160
-		if ( $message ) { ?>
160
+		if ($message) { ?>
161 161
 
162 162
 			<style>
163 163
 				/* Banner specific styles */
@@ -220,12 +220,12 @@  discard block
 block discarded – undo
220 220
 				<a href="https://wordpress.org/support/register.php" class="alignleft give-i18n-icon" style="margin:0" target="_blank"><span class="dashicons dashicons-translation" style="font-size: 110px; text-decoration: none;"></span></a>
221 221
 
222 222
 				<div class="give-i18n-notice-content">
223
-					<a href="<?php echo esc_url( add_query_arg( array( 'remove_i18n_promo' => '1' ) ) ); ?>" class="dismiss"><span class="dashicons dashicons-dismiss"></span></a>
223
+					<a href="<?php echo esc_url(add_query_arg(array('remove_i18n_promo' => '1'))); ?>" class="dismiss"><span class="dashicons dashicons-dismiss"></span></a>
224 224
 
225
-					<h2 style="margin: 10px 0;"><?php printf( esc_html__( 'Help Translate Give to %s', 'give' ), $this->locale_name ); ?></h2>
225
+					<h2 style="margin: 10px 0;"><?php printf(esc_html__('Help Translate Give to %s', 'give'), $this->locale_name); ?></h2>
226 226
 					<p><?php echo $message; ?></p>
227 227
 					<p>
228
-						<a href="https://wordpress.org/support/register.php" target="_blank"><?php _e( 'Register now &raquo;', 'give' ); ?></a>
228
+						<a href="https://wordpress.org/support/register.php" target="_blank"><?php _e('Register now &raquo;', 'give'); ?></a>
229 229
 					</p>
230 230
 				</div>
231 231
 			</div>
@@ -242,11 +242,11 @@  discard block
 block discarded – undo
242 242
 	 */
243 243
 	private function find_or_initialize_translation_details() {
244 244
 
245
-		$set = get_transient( 'give_i18n_give_' . $this->locale );
245
+		$set = get_transient('give_i18n_give_'.$this->locale);
246 246
 
247
-		if ( ! $set ) {
247
+		if ( ! $set) {
248 248
 			$set = $this->retrieve_translation_details();
249
-			set_transient( 'give_i18n_give_' . $this->locale, $set, DAY_IN_SECONDS );
249
+			set_transient('give_i18n_give_'.$this->locale, $set, DAY_IN_SECONDS);
250 250
 		}
251 251
 
252 252
 		return $set;
@@ -260,10 +260,10 @@  discard block
 block discarded – undo
260 260
 	private function translation_details() {
261 261
 		$set = $this->find_or_initialize_translation_details();
262 262
 
263
-		$this->translation_exists = ! is_null( $set );
264
-		$this->translation_loaded = is_textdomain_loaded( 'give' );
263
+		$this->translation_exists = ! is_null($set);
264
+		$this->translation_loaded = is_textdomain_loaded('give');
265 265
 
266
-		$this->parse_translation_set( $set );
266
+		$this->parse_translation_set($set);
267 267
 	}
268 268
 
269 269
 	/**
@@ -275,26 +275,26 @@  discard block
 block discarded – undo
275 275
 	 */
276 276
 	private function retrieve_translation_details() {
277 277
 
278
-		$api_url = trailingslashit( $this->glotpress_url );
278
+		$api_url = trailingslashit($this->glotpress_url);
279 279
 
280
-		$resp = wp_remote_get( $api_url );
280
+		$resp = wp_remote_get($api_url);
281 281
 
282
-		if ( is_wp_error( $resp ) || wp_remote_retrieve_response_code( $resp ) === '404' ) {
282
+		if (is_wp_error($resp) || wp_remote_retrieve_response_code($resp) === '404') {
283 283
 			return null;
284 284
 		}
285 285
 
286
-		$body = wp_remote_retrieve_body( $resp );
287
-		unset( $resp );
286
+		$body = wp_remote_retrieve_body($resp);
287
+		unset($resp);
288 288
 
289
-		if ( $body ) {
290
-			$body = json_decode( $body );
289
+		if ($body) {
290
+			$body = json_decode($body);
291 291
 
292
-			foreach ( $body->translation_sets as $set ) {
293
-				if ( ! property_exists( $set, 'wp_locale' ) ) {
292
+			foreach ($body->translation_sets as $set) {
293
+				if ( ! property_exists($set, 'wp_locale')) {
294 294
 					continue;
295 295
 				}
296 296
 
297
-				if ( $this->locale == $set->wp_locale ) {
297
+				if ($this->locale == $set->wp_locale) {
298 298
 					return $set;
299 299
 				}
300 300
 			}
@@ -310,8 +310,8 @@  discard block
 block discarded – undo
310 310
 	 *
311 311
 	 * @access private
312 312
 	 */
313
-	private function parse_translation_set( $set ) {
314
-		if ( $this->translation_exists && is_object( $set ) ) {
313
+	private function parse_translation_set($set) {
314
+		if ($this->translation_exists && is_object($set)) {
315 315
 			$this->locale_name        = $set->name;
316 316
 			$this->percent_translated = $set->percent_translated;
317 317
 		} else {
Please login to merge, or discard this patch.
includes/user-functions.php 1 patch
Spacing   +125 added lines, -125 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly.
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -30,36 +30,36 @@  discard block
 block discarded – undo
30 30
  *
31 31
  * @return bool|object List of all user donations
32 32
  */
33
-function give_get_users_purchases( $user = 0, $number = 20, $pagination = false, $status = 'complete' ) {
33
+function give_get_users_purchases($user = 0, $number = 20, $pagination = false, $status = 'complete') {
34 34
 
35
-	if ( empty( $user ) ) {
35
+	if (empty($user)) {
36 36
 		$user = get_current_user_id();
37 37
 	}
38 38
 
39
-	if ( 0 === $user && ! Give()->email_access->token_exists ) {
39
+	if (0 === $user && ! Give()->email_access->token_exists) {
40 40
 		return false;
41 41
 	}
42 42
 
43 43
 	$status = $status === 'complete' ? 'publish' : $status;
44 44
 
45
-	if ( $pagination ) {
46
-		if ( get_query_var( 'paged' ) ) {
47
-			$paged = get_query_var( 'paged' );
48
-		} elseif ( get_query_var( 'page' ) ) {
49
-			$paged = get_query_var( 'page' );
45
+	if ($pagination) {
46
+		if (get_query_var('paged')) {
47
+			$paged = get_query_var('paged');
48
+		} elseif (get_query_var('page')) {
49
+			$paged = get_query_var('page');
50 50
 		} else {
51 51
 			$paged = 1;
52 52
 		}
53 53
 	}
54 54
 
55
-	$args = apply_filters( 'give_get_users_donations_args', array(
55
+	$args = apply_filters('give_get_users_donations_args', array(
56 56
 		'user'    => $user,
57 57
 		'number'  => $number,
58 58
 		'status'  => $status,
59 59
 		'orderby' => 'date',
60
-	) );
60
+	));
61 61
 
62
-	if ( $pagination ) {
62
+	if ($pagination) {
63 63
 
64 64
 		$args['page'] = $paged;
65 65
 
@@ -69,20 +69,20 @@  discard block
 block discarded – undo
69 69
 
70 70
 	}
71 71
 
72
-	$by_user_id = is_numeric( $user ) ? true : false;
73
-	$customer   = new Give_Customer( $user, $by_user_id );
72
+	$by_user_id = is_numeric($user) ? true : false;
73
+	$customer   = new Give_Customer($user, $by_user_id);
74 74
 
75
-	if ( ! empty( $customer->payment_ids ) ) {
75
+	if ( ! empty($customer->payment_ids)) {
76 76
 
77
-		unset( $args['user'] );
78
-		$args['post__in'] = array_map( 'absint', explode( ',', $customer->payment_ids ) );
77
+		unset($args['user']);
78
+		$args['post__in'] = array_map('absint', explode(',', $customer->payment_ids));
79 79
 
80 80
 	}
81 81
 
82
-	$purchases = give_get_payments( apply_filters( 'give_get_users_donations_args', $args ) );
82
+	$purchases = give_get_payments(apply_filters('give_get_users_donations_args', $args));
83 83
 
84 84
 	// No donations
85
-	if ( ! $purchases ) {
85
+	if ( ! $purchases) {
86 86
 		return false;
87 87
 	}
88 88
 
@@ -101,65 +101,65 @@  discard block
 block discarded – undo
101 101
  *
102 102
  * @return bool|object List of unique forms donated by user
103 103
  */
104
-function give_get_users_completed_donations( $user = 0, $status = 'complete' ) {
105
-	if ( empty( $user ) ) {
104
+function give_get_users_completed_donations($user = 0, $status = 'complete') {
105
+	if (empty($user)) {
106 106
 		$user = get_current_user_id();
107 107
 	}
108 108
 
109
-	if ( empty( $user ) ) {
109
+	if (empty($user)) {
110 110
 		return false;
111 111
 	}
112 112
 
113
-	$by_user_id = is_numeric( $user ) ? true : false;
113
+	$by_user_id = is_numeric($user) ? true : false;
114 114
 
115
-	$customer = new Give_Customer( $user, $by_user_id );
115
+	$customer = new Give_Customer($user, $by_user_id);
116 116
 
117
-	if ( empty( $customer->payment_ids ) ) {
117
+	if (empty($customer->payment_ids)) {
118 118
 		return false;
119 119
 	}
120 120
 
121 121
 	// Get all the items donated
122
-	$payment_ids    = array_reverse( explode( ',', $customer->payment_ids ) );
123
-	$limit_payments = apply_filters( 'give_users_completed_donations_payments', 50 );
124
-	if ( ! empty( $limit_payments ) ) {
125
-		$payment_ids = array_slice( $payment_ids, 0, $limit_payments );
122
+	$payment_ids    = array_reverse(explode(',', $customer->payment_ids));
123
+	$limit_payments = apply_filters('give_users_completed_donations_payments', 50);
124
+	if ( ! empty($limit_payments)) {
125
+		$payment_ids = array_slice($payment_ids, 0, $limit_payments);
126 126
 	}
127 127
 	$donation_data = array();
128
-	foreach ( $payment_ids as $payment_id ) {
129
-		$donation_data[] = give_get_payment_meta( $payment_id );
128
+	foreach ($payment_ids as $payment_id) {
129
+		$donation_data[] = give_get_payment_meta($payment_id);
130 130
 	}
131 131
 
132
-	if ( empty( $donation_data ) ) {
132
+	if (empty($donation_data)) {
133 133
 		return false;
134 134
 	}
135 135
 
136 136
 	// Grab only the post ids "form_id" of the forms donated on this order
137 137
 	$completed_donations_ids = array();
138
-	foreach ( $donation_data as $purchase_meta ) {
139
-		$completed_donations_ids[] = isset( $purchase_meta['form_id'] ) ? $purchase_meta['form_id'] : '';
138
+	foreach ($donation_data as $purchase_meta) {
139
+		$completed_donations_ids[] = isset($purchase_meta['form_id']) ? $purchase_meta['form_id'] : '';
140 140
 	}
141 141
 
142
-	if ( empty( $completed_donations_ids ) ) {
142
+	if (empty($completed_donations_ids)) {
143 143
 		return false;
144 144
 	}
145 145
 
146 146
 	// Only include each donation once
147
-	$form_ids = array_unique( $completed_donations_ids );
147
+	$form_ids = array_unique($completed_donations_ids);
148 148
 
149 149
 	// Make sure we still have some products and a first item
150
-	if ( empty( $form_ids ) || ! isset( $form_ids[0] ) ) {
150
+	if (empty($form_ids) || ! isset($form_ids[0])) {
151 151
 		return false;
152 152
 	}
153 153
 
154
-	$post_type = get_post_type( $form_ids[0] );
154
+	$post_type = get_post_type($form_ids[0]);
155 155
 
156
-	$args = apply_filters( 'give_get_users_completed_donations_args', array(
156
+	$args = apply_filters('give_get_users_completed_donations_args', array(
157 157
 		'include'        => $form_ids,
158 158
 		'post_type'      => $post_type,
159
-		'posts_per_page' => - 1,
160
-	) );
159
+		'posts_per_page' => -1,
160
+	));
161 161
 
162
-	return apply_filters( 'give_users_completed_donations_list', get_posts( $args ) );
162
+	return apply_filters('give_users_completed_donations_list', get_posts($args));
163 163
 }
164 164
 
165 165
 
@@ -175,12 +175,12 @@  discard block
 block discarded – undo
175 175
  *
176 176
  * @return      bool True if has donated, false other wise.
177 177
  */
178
-function give_has_purchases( $user_id = null ) {
179
-	if ( empty( $user_id ) ) {
178
+function give_has_purchases($user_id = null) {
179
+	if (empty($user_id)) {
180 180
 		$user_id = get_current_user_id();
181 181
 	}
182 182
 
183
-	if ( give_get_users_purchases( $user_id, 1 ) ) {
183
+	if (give_get_users_purchases($user_id, 1)) {
184 184
 		return true; // User has at least one donation
185 185
 	}
186 186
 
@@ -200,27 +200,27 @@  discard block
 block discarded – undo
200 200
  *
201 201
  * @return      array
202 202
  */
203
-function give_get_purchase_stats_by_user( $user = '' ) {
203
+function give_get_purchase_stats_by_user($user = '') {
204 204
 
205
-	if ( is_email( $user ) ) {
205
+	if (is_email($user)) {
206 206
 
207 207
 		$field = 'email';
208 208
 
209
-	} elseif ( is_numeric( $user ) ) {
209
+	} elseif (is_numeric($user)) {
210 210
 
211 211
 		$field = 'user_id';
212 212
 
213 213
 	}
214 214
 
215 215
 	$stats    = array();
216
-	$customer = Give()->customers->get_customer_by( $field, $user );
216
+	$customer = Give()->customers->get_customer_by($field, $user);
217 217
 
218
-	if ( $customer ) {
218
+	if ($customer) {
219 219
 
220
-		$customer = new Give_Customer( $customer->id );
220
+		$customer = new Give_Customer($customer->id);
221 221
 
222
-		$stats['purchases']   = absint( $customer->purchase_count );
223
-		$stats['total_spent'] = give_sanitize_amount( $customer->purchase_value );
222
+		$stats['purchases']   = absint($customer->purchase_count);
223
+		$stats['total_spent'] = give_sanitize_amount($customer->purchase_value);
224 224
 
225 225
 	}
226 226
 
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 	 *
230 230
 	 * @since 1.7
231 231
 	 */
232
-	$stats = (array) apply_filters( 'give_donation_stats_by_user', $stats, $user );
232
+	$stats = (array) apply_filters('give_donation_stats_by_user', $stats, $user);
233 233
 
234 234
 	return $stats;
235 235
 }
@@ -247,21 +247,21 @@  discard block
 block discarded – undo
247 247
  *
248 248
  * @return      int The total number of donations
249 249
  */
250
-function give_count_purchases_of_customer( $user = null ) {
250
+function give_count_purchases_of_customer($user = null) {
251 251
 
252 252
 	// Logged in?
253
-	if ( empty( $user ) ) {
253
+	if (empty($user)) {
254 254
 		$user = get_current_user_id();
255 255
 	}
256 256
 
257 257
 	// Email access?
258
-	if ( empty( $user ) && Give()->email_access->token_email ) {
258
+	if (empty($user) && Give()->email_access->token_email) {
259 259
 		$user = Give()->email_access->token_email;
260 260
 	}
261 261
 
262
-	$stats = ! empty( $user ) ? give_get_purchase_stats_by_user( $user ) : false;
262
+	$stats = ! empty($user) ? give_get_purchase_stats_by_user($user) : false;
263 263
 
264
-	return isset( $stats['purchases'] ) ? $stats['purchases'] : 0;
264
+	return isset($stats['purchases']) ? $stats['purchases'] : 0;
265 265
 }
266 266
 
267 267
 /**
@@ -274,9 +274,9 @@  discard block
 block discarded – undo
274 274
  *
275 275
  * @return      float The total amount the user has spent
276 276
  */
277
-function give_purchase_total_of_user( $user = null ) {
277
+function give_purchase_total_of_user($user = null) {
278 278
 
279
-	$stats = give_get_purchase_stats_by_user( $user );
279
+	$stats = give_get_purchase_stats_by_user($user);
280 280
 
281 281
 	return $stats['total_spent'];
282 282
 }
@@ -292,40 +292,40 @@  discard block
 block discarded – undo
292 292
  *
293 293
  * @return bool
294 294
  */
295
-function give_validate_username( $username, $form_id = 0 ) {
295
+function give_validate_username($username, $form_id = 0) {
296 296
 	$valid = true;
297 297
 
298 298
 	// Validate username.
299
-	if ( ! empty( $username ) ) {
299
+	if ( ! empty($username)) {
300 300
 
301 301
 		// Sanitize username.
302
-		$sanitized_user_name = sanitize_user( $username, false );
302
+		$sanitized_user_name = sanitize_user($username, false);
303 303
 
304 304
 		// We have an user name, check if it already exists.
305
-		if ( username_exists( $username ) ) {
305
+		if (username_exists($username)) {
306 306
 			// Username already registered.
307
-			give_set_error( 'username_unavailable', esc_html__( 'Username already taken.', 'give' ) );
307
+			give_set_error('username_unavailable', esc_html__('Username already taken.', 'give'));
308 308
 			$valid = false;
309 309
 
310 310
 			// Check if it's valid.
311
-		} elseif ( $sanitized_user_name !== $username ) {
311
+		} elseif ($sanitized_user_name !== $username) {
312 312
 			// Invalid username.
313
-			if ( is_multisite() ) {
314
-				give_set_error( 'username_invalid', esc_html__( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ) );
313
+			if (is_multisite()) {
314
+				give_set_error('username_invalid', esc_html__('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give'));
315 315
 				$valid = false;
316 316
 			} else {
317
-				give_set_error( 'username_invalid', esc_html__( 'Invalid username.', 'give' ) );
317
+				give_set_error('username_invalid', esc_html__('Invalid username.', 'give'));
318 318
 				$valid = false;
319 319
 			}
320 320
 		}
321 321
 	} else {
322 322
 		// Username is empty.
323
-		give_set_error( 'username_empty', esc_html__( 'Enter a username.', 'give' ) );
323
+		give_set_error('username_empty', esc_html__('Enter a username.', 'give'));
324 324
 		$valid = false;
325 325
 
326 326
 		// Check if guest checkout is disable for form.
327
-		if ( $form_id && give_logged_in_only( $form_id ) ) {
328
-			give_set_error( 'registration_required', esc_html__( 'You must register or login to complete your donation.', 'give' ) );
327
+		if ($form_id && give_logged_in_only($form_id)) {
328
+			give_set_error('registration_required', esc_html__('You must register or login to complete your donation.', 'give'));
329 329
 			$valid = false;
330 330
 		}
331 331
 	}
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 	 * @param string $username
340 340
 	 * @param bool   $form_id
341 341
 	 */
342
-	$valid = (bool) apply_filters( 'give_validate_username', $valid, $username, $form_id );
342
+	$valid = (bool) apply_filters('give_validate_username', $valid, $username, $form_id);
343 343
 
344 344
 	return $valid;
345 345
 }
@@ -355,22 +355,22 @@  discard block
 block discarded – undo
355 355
  *
356 356
  * @return bool
357 357
  */
358
-function give_validate_user_email( $email, $registering_new_user = false ) {
358
+function give_validate_user_email($email, $registering_new_user = false) {
359 359
 	$valid = true;
360 360
 
361
-	if ( empty( $email ) ) {
361
+	if (empty($email)) {
362 362
 		// No email.
363
-		give_set_error( 'email_empty', esc_html__( 'Enter an email.', 'give' ) );
363
+		give_set_error('email_empty', esc_html__('Enter an email.', 'give'));
364 364
 		$valid = false;
365 365
 
366
-	} elseif ( ! is_email( $email ) ) {
366
+	} elseif ( ! is_email($email)) {
367 367
 		// Validate email.
368
-		give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
368
+		give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
369 369
 		$valid = false;
370 370
 
371
-	} elseif ( $registering_new_user && email_exists( $email ) ) {
371
+	} elseif ($registering_new_user && email_exists($email)) {
372 372
 		// Check if email exists.
373
-		give_set_error( 'email_used', esc_html__( 'The email already active for another user.', 'give' ) );
373
+		give_set_error('email_used', esc_html__('The email already active for another user.', 'give'));
374 374
 		$valid = false;
375 375
 	}
376 376
 
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 	 * @param string $email
384 384
 	 * @param bool   $registering_new_user
385 385
 	 */
386
-	$valid = (bool) apply_filters( 'give_validate_user_email', $valid, $email, $registering_new_user );
386
+	$valid = (bool) apply_filters('give_validate_user_email', $valid, $email, $registering_new_user);
387 387
 
388 388
 	return $valid;
389 389
 }
@@ -399,25 +399,25 @@  discard block
 block discarded – undo
399 399
  *
400 400
  * @return bool
401 401
  */
402
-function give_validate_user_password( $password = '', $confirm_password = '', $registering_new_user = false ) {
402
+function give_validate_user_password($password = '', $confirm_password = '', $registering_new_user = false) {
403 403
 	$valid = true;
404 404
 
405
-	if ( $password && $confirm_password ) {
405
+	if ($password && $confirm_password) {
406 406
 		// Verify confirmation matches.
407
-		if ( $password != $confirm_password ) {
407
+		if ($password != $confirm_password) {
408 408
 			// Passwords do not match
409
-			give_set_error( 'password_mismatch', esc_html__( 'Passwords don\'t match.', 'give' ) );
409
+			give_set_error('password_mismatch', esc_html__('Passwords don\'t match.', 'give'));
410 410
 			$valid = false;
411 411
 		}
412
-	} elseif ( $registering_new_user ) {
412
+	} elseif ($registering_new_user) {
413 413
 		// Password or confirmation missing.
414
-		if ( ! $password ) {
414
+		if ( ! $password) {
415 415
 			// The password is invalid.
416
-			give_set_error( 'password_empty', esc_html__( 'Enter a password.', 'give' ) );
416
+			give_set_error('password_empty', esc_html__('Enter a password.', 'give'));
417 417
 			$valid = false;
418
-		} elseif ( ! $confirm_password ) {
418
+		} elseif ( ! $confirm_password) {
419 419
 			// Confirmation password is invalid.
420
-			give_set_error( 'confirmation_empty', esc_html__( 'Enter the password confirmation.', 'give' ) );
420
+			give_set_error('confirmation_empty', esc_html__('Enter the password confirmation.', 'give'));
421 421
 			$valid = false;
422 422
 		}
423 423
 	}
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 	 * @param string $confirm_password
433 433
 	 * @param bool   $registering_new_user
434 434
 	 */
435
-	$valid = (bool) apply_filters( 'give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user );
435
+	$valid = (bool) apply_filters('give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user);
436 436
 
437 437
 	return $valid;
438 438
 }
@@ -451,32 +451,32 @@  discard block
 block discarded – undo
451 451
  *
452 452
  * @return      void
453 453
  */
454
-function give_add_past_purchases_to_new_user( $user_id ) {
454
+function give_add_past_purchases_to_new_user($user_id) {
455 455
 
456
-	$email = get_the_author_meta( 'user_email', $user_id );
456
+	$email = get_the_author_meta('user_email', $user_id);
457 457
 
458
-	$payments = give_get_payments( array( 's' => $email ) );
458
+	$payments = give_get_payments(array('s' => $email));
459 459
 
460
-	if ( $payments ) {
461
-		foreach ( $payments as $payment ) {
462
-			if ( intval( give_get_payment_user_id( $payment->ID ) ) > 0 ) {
460
+	if ($payments) {
461
+		foreach ($payments as $payment) {
462
+			if (intval(give_get_payment_user_id($payment->ID)) > 0) {
463 463
 				continue;
464 464
 			} // This payment already associated with an account
465 465
 
466
-			$meta                    = give_get_payment_meta( $payment->ID );
467
-			$meta['user_info']       = maybe_unserialize( $meta['user_info'] );
466
+			$meta                    = give_get_payment_meta($payment->ID);
467
+			$meta['user_info']       = maybe_unserialize($meta['user_info']);
468 468
 			$meta['user_info']['id'] = $user_id;
469 469
 			$meta['user_info']       = $meta['user_info'];
470 470
 
471 471
 			// Store the updated user ID in the payment meta
472
-			give_update_payment_meta( $payment->ID, '_give_payment_meta', $meta );
473
-			give_update_payment_meta( $payment->ID, '_give_payment_user_id', $user_id );
472
+			give_update_payment_meta($payment->ID, '_give_payment_meta', $meta);
473
+			give_update_payment_meta($payment->ID, '_give_payment_user_id', $user_id);
474 474
 		}
475 475
 	}
476 476
 
477 477
 }
478 478
 
479
-add_action( 'user_register', 'give_add_past_purchases_to_new_user' );
479
+add_action('user_register', 'give_add_past_purchases_to_new_user');
480 480
 
481 481
 
482 482
 /**
@@ -502,34 +502,34 @@  discard block
 block discarded – undo
502 502
  *
503 503
  * @return        array The donor's address, if any
504 504
  */
505
-function give_get_donor_address( $user_id = 0 ) {
506
-	if ( empty( $user_id ) ) {
505
+function give_get_donor_address($user_id = 0) {
506
+	if (empty($user_id)) {
507 507
 		$user_id = get_current_user_id();
508 508
 	}
509 509
 
510
-	$address = get_user_meta( $user_id, '_give_user_address', true );
510
+	$address = get_user_meta($user_id, '_give_user_address', true);
511 511
 
512
-	if ( ! isset( $address['line1'] ) ) {
512
+	if ( ! isset($address['line1'])) {
513 513
 		$address['line1'] = '';
514 514
 	}
515 515
 
516
-	if ( ! isset( $address['line2'] ) ) {
516
+	if ( ! isset($address['line2'])) {
517 517
 		$address['line2'] = '';
518 518
 	}
519 519
 
520
-	if ( ! isset( $address['city'] ) ) {
520
+	if ( ! isset($address['city'])) {
521 521
 		$address['city'] = '';
522 522
 	}
523 523
 
524
-	if ( ! isset( $address['zip'] ) ) {
524
+	if ( ! isset($address['zip'])) {
525 525
 		$address['zip'] = '';
526 526
 	}
527 527
 
528
-	if ( ! isset( $address['country'] ) ) {
528
+	if ( ! isset($address['country'])) {
529 529
 		$address['country'] = '';
530 530
 	}
531 531
 
532
-	if ( ! isset( $address['state'] ) ) {
532
+	if ( ! isset($address['state'])) {
533 533
 		$address['state'] = '';
534 534
 	}
535 535
 
@@ -549,42 +549,42 @@  discard block
 block discarded – undo
549 549
  *
550 550
  * @return        void
551 551
  */
552
-function give_new_user_notification( $user_id = 0, $user_data = array() ) {
552
+function give_new_user_notification($user_id = 0, $user_data = array()) {
553 553
 
554
-	if ( empty( $user_id ) || empty( $user_data ) ) {
554
+	if (empty($user_id) || empty($user_data)) {
555 555
 		return;
556 556
 	}
557
-	$blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
557
+	$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
558 558
 
559 559
 	/* translators: %s: site name */
560
-	$message = sprintf( esc_attr__( 'New user registration on your site %s:', 'give' ), $blogname ) . "\r\n\r\n";
560
+	$message = sprintf(esc_attr__('New user registration on your site %s:', 'give'), $blogname)."\r\n\r\n";
561 561
 	/* translators: %s: user login */
562
-	$message .= sprintf( esc_attr__( 'Username: %s', 'give' ), $user_data['user_login'] ) . "\r\n\r\n";
562
+	$message .= sprintf(esc_attr__('Username: %s', 'give'), $user_data['user_login'])."\r\n\r\n";
563 563
 	/* translators: %s: user email */
564
-	$message .= sprintf( esc_attr__( 'E-mail: %s', 'give' ), $user_data['user_email'] ) . "\r\n";
564
+	$message .= sprintf(esc_attr__('E-mail: %s', 'give'), $user_data['user_email'])."\r\n";
565 565
 
566 566
 	@wp_mail(
567
-		get_option( 'admin_email' ),
567
+		get_option('admin_email'),
568 568
 		sprintf(
569 569
 			/* translators: %s: site name */
570
-			esc_attr__( '[%s] New User Registration', 'give' ),
570
+			esc_attr__('[%s] New User Registration', 'give'),
571 571
 			$blogname
572 572
 		),
573 573
 		$message
574 574
 	);
575 575
 
576 576
 	/* translators: %s: user login */
577
-	$message = sprintf( esc_attr__( 'Username: %s', 'give' ), $user_data['user_login'] ) . "\r\n";
577
+	$message = sprintf(esc_attr__('Username: %s', 'give'), $user_data['user_login'])."\r\n";
578 578
 	/* translators: %s: paswword */
579
-	$message .= sprintf( esc_attr__( 'Password: %s', 'give' ), esc_attr__( '[Password entered during donation]', 'give' ) ) . "\r\n";
579
+	$message .= sprintf(esc_attr__('Password: %s', 'give'), esc_attr__('[Password entered during donation]', 'give'))."\r\n";
580 580
 
581
-	$message .= '<a href="' . wp_login_url() . '"> ' . esc_attr__( 'Click Here to Login &raquo;', 'give' ) . '</a>' . "\r\n";
581
+	$message .= '<a href="'.wp_login_url().'"> '.esc_attr__('Click Here to Login &raquo;', 'give').'</a>'."\r\n";
582 582
 
583 583
 	wp_mail(
584 584
 		$user_data['user_email'],
585 585
 		sprintf(
586 586
 			/* translators: %s: site name */
587
-			esc_attr__( '[%s] Your username and password', 'give' ),
587
+			esc_attr__('[%s] Your username and password', 'give'),
588 588
 			$blogname
589 589
 		),
590 590
 		$message
@@ -592,4 +592,4 @@  discard block
 block discarded – undo
592 592
 
593 593
 }
594 594
 
595
-add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 );
595
+add_action('give_insert_user', 'give_new_user_notification', 10, 2);
Please login to merge, or discard this patch.
includes/process-donation.php 1 patch
Spacing   +239 added lines, -239 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_donation_form' );
164
-add_action( 'wp_ajax_give_process_donation', 'give_process_donation_form' );
165
-add_action( 'wp_ajax_nopriv_give_process_donation', 'give_process_donation_form' );
163
+add_action('give_purchase', 'give_process_donation_form');
164
+add_action('wp_ajax_give_process_donation', 'give_process_donation_form');
165
+add_action('wp_ajax_nopriv_give_process_donation', 'give_process_donation_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_donation_login', 'give_process_form_login' );
238
-add_action( 'wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login' );
237
+add_action('wp_ajax_give_process_donation_login', 'give_process_form_login');
238
+add_action('wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login');
239 239
 
240 240
 /**
241 241
  * Donation Form Validate Fields
@@ -247,55 +247,55 @@  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
-	if ( give_is_terms_enabled( $form_id ) ) {
274
+	if (give_is_terms_enabled($form_id)) {
275 275
 		give_purchase_form_validate_agree_to_terms();
276 276
 	}
277 277
 
278 278
 	// Stop processing donor registration, if donor registration is optional and donor can do guest checkout.
279 279
 	// If registration form username field is empty that means donor do not want to registration instead want guest checkout.
280 280
 	if (
281
-		! give_logged_in_only( $form_id )
282
-		&& isset( $_POST['give-purchase-var'] )
281
+		! give_logged_in_only($form_id)
282
+		&& isset($_POST['give-purchase-var'])
283 283
 		&& $_POST['give-purchase-var'] == 'needs-to-register'
284
-		&& empty( $_POST['give_user_login'] )
284
+		&& empty($_POST['give_user_login'])
285 285
 	) {
286
-		unset( $_POST['give-purchase-var'] );
286
+		unset($_POST['give-purchase-var']);
287 287
 	}
288 288
 
289
-	if ( is_user_logged_in() ) {
289
+	if (is_user_logged_in()) {
290 290
 		// Collect logged in user data
291 291
 		$valid_data['logged_in_user'] = give_purchase_form_validate_logged_in_user();
292
-	} elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' ) {
292
+	} elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register') {
293 293
 		// Set new user registration as required
294 294
 		$valid_data['need_new_user'] = true;
295 295
 		// Validate new user data
296 296
 		$valid_data['new_user_data'] = give_purchase_form_validate_new_user();
297 297
 		// Check if login validation is needed
298
-	} elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) {
298
+	} elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') {
299 299
 		// Set user login as required
300 300
 		$valid_data['need_user_login'] = true;
301 301
 		// Validate users login info
@@ -320,41 +320,41 @@  discard block
 block discarded – undo
320 320
  */
321 321
 function give_purchase_form_validate_gateway() {
322 322
 
323
-	$form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0;
324
-	$amount  = isset( $_REQUEST['give-amount'] ) ? give_sanitize_amount( $_REQUEST['give-amount'] ) : 0;
325
-	$gateway = give_get_default_gateway( $form_id );
323
+	$form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;
324
+	$amount  = isset($_REQUEST['give-amount']) ? give_sanitize_amount($_REQUEST['give-amount']) : 0;
325
+	$gateway = give_get_default_gateway($form_id);
326 326
 
327 327
 	// Check if a gateway value is present
328
-	if ( ! empty( $_REQUEST['give-gateway'] ) ) {
328
+	if ( ! empty($_REQUEST['give-gateway'])) {
329 329
 
330
-		$gateway = sanitize_text_field( $_REQUEST['give-gateway'] );
330
+		$gateway = sanitize_text_field($_REQUEST['give-gateway']);
331 331
 
332 332
 		// Is amount being donated in LIVE mode 0.00? If so, error:
333
-		if ( $amount == 0 && ! give_is_test_mode() ) {
333
+		if ($amount == 0 && ! give_is_test_mode()) {
334 334
 
335
-			give_set_error( 'invalid_donation_amount', esc_html__( 'Please insert a valid donation amount.', 'give' ) );
335
+			give_set_error('invalid_donation_amount', esc_html__('Please insert a valid donation amount.', 'give'));
336 336
 
337 337
 		} //Check for a minimum custom amount
338
-		elseif ( ! give_verify_minimum_price() ) {
338
+		elseif ( ! give_verify_minimum_price()) {
339 339
 			// translators: %s: minimum donation amount.
340 340
 			give_set_error(
341 341
 				'invalid_donation_minimum',
342 342
 				sprintf(
343 343
 					/* translators: %s: minimum donation amount */
344
-					esc_html__( 'This form has a minimum donation amount of %s.', 'give' ),
345
-					give_currency_filter( give_format_amount( give_get_form_minimum_price( $form_id ) ) )
344
+					esc_html__('This form has a minimum donation amount of %s.', 'give'),
345
+					give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id)))
346 346
 				)
347 347
 			);
348 348
 
349 349
 		} //Is this test mode zero donation? Let it through but set to manual gateway.
350
-		elseif ( $amount == 0 && give_is_test_mode() ) {
350
+		elseif ($amount == 0 && give_is_test_mode()) {
351 351
 
352 352
 			$gateway = 'manual';
353 353
 
354 354
 		} //Check if this gateway is active.
355
-		elseif ( ! give_is_gateway_active( $gateway ) ) {
355
+		elseif ( ! give_is_gateway_active($gateway)) {
356 356
 
357
-			give_set_error( 'invalid_gateway', esc_html__( 'The selected payment gateway is not enabled.', 'give' ) );
357
+			give_set_error('invalid_gateway', esc_html__('The selected payment gateway is not enabled.', 'give'));
358 358
 
359 359
 		}
360 360
 	}
@@ -372,23 +372,23 @@  discard block
 block discarded – undo
372 372
  */
373 373
 function give_verify_minimum_price() {
374 374
 
375
-	$amount          = give_sanitize_amount( $_REQUEST['give-amount'] );
376
-	$form_id         = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0;
377
-	$price_id        = isset( $_REQUEST['give-price-id'] ) ? $_REQUEST['give-price-id'] : 0;
378
-	$variable_prices = give_has_variable_prices( $form_id );
375
+	$amount          = give_sanitize_amount($_REQUEST['give-amount']);
376
+	$form_id         = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;
377
+	$price_id        = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : 0;
378
+	$variable_prices = give_has_variable_prices($form_id);
379 379
 
380
-	if ( $variable_prices && ! empty( $price_id ) ) {
380
+	if ($variable_prices && ! empty($price_id)) {
381 381
 
382
-		$price_level_amount = give_get_price_option_amount( $form_id, $price_id );
382
+		$price_level_amount = give_get_price_option_amount($form_id, $price_id);
383 383
 
384
-		if ( $price_level_amount == $amount ) {
384
+		if ($price_level_amount == $amount) {
385 385
 			return true;
386 386
 		}
387 387
 	}
388 388
 
389
-	$minimum = give_get_form_minimum_price( $form_id );
389
+	$minimum = give_get_form_minimum_price($form_id);
390 390
 
391
-	if ( $minimum > $amount ) {
391
+	if ($minimum > $amount) {
392 392
 		return false;
393 393
 	}
394 394
 
@@ -404,9 +404,9 @@  discard block
 block discarded – undo
404 404
  */
405 405
 function give_purchase_form_validate_agree_to_terms() {
406 406
 	// Validate agree to terms.
407
-	if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) {
407
+	if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) {
408 408
 		// User did not agree.
409
-		give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', esc_html__( 'You must agree to the terms and conditions.', 'give' ) ) );
409
+		give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', esc_html__('You must agree to the terms and conditions.', 'give')));
410 410
 	}
411 411
 }
412 412
 
@@ -420,43 +420,43 @@  discard block
 block discarded – undo
420 420
  *
421 421
  * @return      array
422 422
  */
423
-function give_get_required_fields( $form_id ) {
423
+function give_get_required_fields($form_id) {
424 424
 
425
-	$payment_mode = give_get_chosen_gateway( $form_id );
425
+	$payment_mode = give_get_chosen_gateway($form_id);
426 426
 
427 427
 	$required_fields = array(
428 428
 		'give_email' => array(
429 429
 			'error_id'      => 'invalid_email',
430
-			'error_message' => esc_html__( 'Please enter a valid email address.', 'give' ),
430
+			'error_message' => esc_html__('Please enter a valid email address.', 'give'),
431 431
 		),
432 432
 		'give_first' => array(
433 433
 			'error_id'      => 'invalid_first_name',
434
-			'error_message' => esc_html__( 'Please enter your first name.', 'give' ),
434
+			'error_message' => esc_html__('Please enter your first name.', 'give'),
435 435
 		),
436 436
 	);
437 437
 
438
-	$require_address = give_require_billing_address( $payment_mode );
438
+	$require_address = give_require_billing_address($payment_mode);
439 439
 
440
-	if ( $require_address ) {
441
-		$required_fields['card_address']    = array(
440
+	if ($require_address) {
441
+		$required_fields['card_address'] = array(
442 442
 			'error_id'      => 'invalid_card_address',
443
-			'error_message' => esc_html__( 'Please enter your primary billing address.', 'give' ),
443
+			'error_message' => esc_html__('Please enter your primary billing address.', 'give'),
444 444
 		);
445
-		$required_fields['card_zip']        = array(
445
+		$required_fields['card_zip'] = array(
446 446
 			'error_id'      => 'invalid_zip_code',
447
-			'error_message' => esc_html__( 'Please enter your zip / postal code.', 'give' ),
447
+			'error_message' => esc_html__('Please enter your zip / postal code.', 'give'),
448 448
 		);
449
-		$required_fields['card_city']       = array(
449
+		$required_fields['card_city'] = array(
450 450
 			'error_id'      => 'invalid_city',
451
-			'error_message' => esc_html__( 'Please enter your billing city.', 'give' ),
451
+			'error_message' => esc_html__('Please enter your billing city.', 'give'),
452 452
 		);
453 453
 		$required_fields['billing_country'] = array(
454 454
 			'error_id'      => 'invalid_country',
455
-			'error_message' => esc_html__( 'Please select your billing country.', 'give' ),
455
+			'error_message' => esc_html__('Please select your billing country.', 'give'),
456 456
 		);
457
-		$required_fields['card_state']      = array(
457
+		$required_fields['card_state'] = array(
458 458
 			'error_id'      => 'invalid_state',
459
-			'error_message' => esc_html__( 'Please enter billing state / province.', 'give' ),
459
+			'error_message' => esc_html__('Please enter billing state / province.', 'give'),
460 460
 		);
461 461
 	}
462 462
 
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
 	 *
466 466
 	 * @since 1.7
467 467
 	 */
468
-	$required_fields = apply_filters( 'give_donation_form_required_fields', $required_fields, $form_id );
468
+	$required_fields = apply_filters('give_donation_form_required_fields', $required_fields, $form_id);
469 469
 
470 470
 	return $required_fields;
471 471
 
@@ -480,16 +480,16 @@  discard block
 block discarded – undo
480 480
  *
481 481
  * @return mixed|void
482 482
  */
483
-function give_require_billing_address( $payment_mode ) {
483
+function give_require_billing_address($payment_mode) {
484 484
 
485 485
 	$return = false;
486 486
 
487
-	if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) {
487
+	if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) {
488 488
 		$return = true;
489 489
 	}
490 490
 
491 491
 	// Let payment gateways and other extensions determine if address fields should be required.
492
-	return apply_filters( 'give_require_billing_address', $return );
492
+	return apply_filters('give_require_billing_address', $return);
493 493
 
494 494
 }
495 495
 
@@ -503,42 +503,42 @@  discard block
 block discarded – undo
503 503
 function give_purchase_form_validate_logged_in_user() {
504 504
 	global $user_ID;
505 505
 
506
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
506
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
507 507
 
508 508
 	// Start empty array to collect valid user data.
509 509
 	$valid_user_data = array(
510 510
 		// Assume there will be errors.
511
-		'user_id' => - 1,
511
+		'user_id' => -1,
512 512
 	);
513 513
 
514 514
 	// Verify there is a user_ID.
515
-	if ( $user_ID > 0 ) {
515
+	if ($user_ID > 0) {
516 516
 		// Get the logged in user data.
517
-		$user_data = get_userdata( $user_ID );
517
+		$user_data = get_userdata($user_ID);
518 518
 
519 519
 		// Loop through required fields and show error messages.
520
-		foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) {
521
-			if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
522
-				give_set_error( $value['error_id'], $value['error_message'] );
520
+		foreach (give_get_required_fields($form_id) as $field_name => $value) {
521
+			if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) {
522
+				give_set_error($value['error_id'], $value['error_message']);
523 523
 			}
524 524
 		}
525 525
 
526 526
 		// Verify data.
527
-		if ( $user_data ) {
527
+		if ($user_data) {
528 528
 			// Collected logged in user data.
529 529
 			$valid_user_data = array(
530 530
 				'user_id'    => $user_ID,
531
-				'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email,
532
-				'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name,
533
-				'user_last'  => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name,
531
+				'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email,
532
+				'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name,
533
+				'user_last'  => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name,
534 534
 			);
535 535
 
536
-			if ( ! is_email( $valid_user_data['user_email'] ) ) {
537
-				give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
536
+			if ( ! is_email($valid_user_data['user_email'])) {
537
+				give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
538 538
 			}
539 539
 		} else {
540 540
 			// Set invalid user error.
541
-			give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) );
541
+			give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give'));
542 542
 		}
543 543
 	}
544 544
 
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
 	// Default user data.
558 558
 	$default_user_data = array(
559 559
 		'give-form-id'           => '',
560
-		'user_id'                => - 1, // Assume there will be errors.
560
+		'user_id'                => -1, // Assume there will be errors.
561 561
 		'user_first'             => '',
562 562
 		'user_last'              => '',
563 563
 		'give_user_login'        => false,
@@ -567,14 +567,14 @@  discard block
 block discarded – undo
567 567
 	);
568 568
 
569 569
 	// Get user data.
570
-	$user_data            = wp_parse_args( array_map( 'trim', give_clean( $_POST ) ), $default_user_data );
570
+	$user_data            = wp_parse_args(array_map('trim', give_clean($_POST)), $default_user_data);
571 571
 	$registering_new_user = false;
572
-	$form_id              = absint( $user_data['give-form-id'] );
572
+	$form_id              = absint($user_data['give-form-id']);
573 573
 
574 574
 	// Start an empty array to collect valid user data.
575 575
 	$valid_user_data = array(
576 576
 		// Assume there will be errors.
577
-		'user_id'    => - 1,
577
+		'user_id'    => -1,
578 578
 
579 579
 		// Get first name.
580 580
 		'user_first' => $user_data['give_first'],
@@ -584,25 +584,25 @@  discard block
 block discarded – undo
584 584
 	);
585 585
 
586 586
 	// Loop through required fields and show error messages.
587
-	foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) {
588
-		if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
589
-			give_set_error( $value['error_id'], $value['error_message'] );
587
+	foreach (give_get_required_fields($form_id) as $field_name => $value) {
588
+		if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) {
589
+			give_set_error($value['error_id'], $value['error_message']);
590 590
 		}
591 591
 	}
592 592
 
593 593
 	// Check if we have an username to register.
594
-	if ( give_validate_username( $user_data['give_user_login'] ) ) {
594
+	if (give_validate_username($user_data['give_user_login'])) {
595 595
 		$registering_new_user          = true;
596 596
 		$valid_user_data['user_login'] = $user_data['give_user_login'];
597 597
 	}
598 598
 
599 599
 	// Check if we have an email to verify.
600
-	if ( give_validate_user_email( $user_data['give_email'], $registering_new_user ) ) {
600
+	if (give_validate_user_email($user_data['give_email'], $registering_new_user)) {
601 601
 		$valid_user_data['user_email'] = $user_data['give_email'];
602 602
 	}
603 603
 
604 604
 	// Check password.
605
-	if ( give_validate_user_password( $user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user ) ) {
605
+	if (give_validate_user_password($user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user)) {
606 606
 		// All is good to go.
607 607
 		$valid_user_data['user_pass'] = $user_data['give_user_pass'];
608 608
 	}
@@ -622,36 +622,36 @@  discard block
 block discarded – undo
622 622
 	// Start an array to collect valid user data.
623 623
 	$valid_user_data = array(
624 624
 		// Assume there will be errors
625
-		'user_id' => - 1,
625
+		'user_id' => -1,
626 626
 	);
627 627
 
628 628
 	// Username.
629
-	if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) {
630
-		give_set_error( 'must_log_in', esc_html__( 'You must register or login to complete your donation.', 'give' ) );
629
+	if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') {
630
+		give_set_error('must_log_in', esc_html__('You must register or login to complete your donation.', 'give'));
631 631
 
632 632
 		return $valid_user_data;
633 633
 	}
634 634
 
635 635
 	// Get the user by login.
636
-	$user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) );
636
+	$user_data = get_user_by('login', strip_tags($_POST['give_user_login']));
637 637
 
638 638
 	// Check if user exists.
639
-	if ( $user_data ) {
639
+	if ($user_data) {
640 640
 		// Get password.
641
-		$user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false;
641
+		$user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false;
642 642
 
643 643
 		// Check user_pass.
644
-		if ( $user_pass ) {
644
+		if ($user_pass) {
645 645
 			// Check if password is valid.
646
-			if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) {
646
+			if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) {
647 647
 				// Incorrect password.
648 648
 				give_set_error(
649 649
 					'password_incorrect',
650 650
 					sprintf(
651 651
 						'%1$s <a href="%2$s">%3$s</a>',
652
-						esc_html__( 'The password you entered is incorrect.', 'give' ),
653
-						wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ),
654
-						esc_html__( 'Reset Password', 'give' )
652
+						esc_html__('The password you entered is incorrect.', 'give'),
653
+						wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"),
654
+						esc_html__('Reset Password', 'give')
655 655
 					)
656 656
 				);
657 657
 				// All is correct.
@@ -668,11 +668,11 @@  discard block
 block discarded – undo
668 668
 			}
669 669
 		} else {
670 670
 			// Empty password.
671
-			give_set_error( 'password_empty', esc_html__( 'Enter a password.', 'give' ) );
671
+			give_set_error('password_empty', esc_html__('Enter a password.', 'give'));
672 672
 		}
673 673
 	} else {
674 674
 		// No username.
675
-		give_set_error( 'username_incorrect', esc_html__( 'The username you entered does not exist.', 'give' ) );
675
+		give_set_error('username_incorrect', esc_html__('The username you entered does not exist.', 'give'));
676 676
 	}
677 677
 
678 678
 	return $valid_user_data;
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
  */
688 688
 function give_purchase_form_validate_guest_user() {
689 689
 
690
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
690
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
691 691
 
692 692
 	// Start an array to collect valid user data.
693 693
 	$valid_user_data = array(
@@ -696,38 +696,38 @@  discard block
 block discarded – undo
696 696
 	);
697 697
 
698 698
 	// Show error message if user must be logged in.
699
-	if ( give_logged_in_only( $form_id ) ) {
700
-		give_set_error( 'logged_in_only', esc_html__( 'You must be logged in to donate.', 'give' ) );
699
+	if (give_logged_in_only($form_id)) {
700
+		give_set_error('logged_in_only', esc_html__('You must be logged in to donate.', 'give'));
701 701
 	}
702 702
 
703 703
 	// Get the guest email.
704
-	$guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false;
704
+	$guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false;
705 705
 
706 706
 	// Check email.
707
-	if ( $guest_email && strlen( $guest_email ) > 0 ) {
707
+	if ($guest_email && strlen($guest_email) > 0) {
708 708
 		// Validate email.
709
-		if ( ! is_email( $guest_email ) ) {
709
+		if ( ! is_email($guest_email)) {
710 710
 			// Invalid email.
711
-			give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
711
+			give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
712 712
 		} else {
713 713
 			// All is good to go.
714 714
 			$valid_user_data['user_email'] = $guest_email;
715 715
 
716 716
 			// Get user_id from donor if exist.
717
-			$donor = new Give_Customer( $guest_email );
718
-			if ( $donor->id && $donor->user_id ) {
717
+			$donor = new Give_Customer($guest_email);
718
+			if ($donor->id && $donor->user_id) {
719 719
 				$valid_user_data['user_id'] = $donor->user_id;
720 720
 			}
721 721
 		}
722 722
 	} else {
723 723
 		// No email.
724
-		give_set_error( 'email_empty', esc_html__( 'Enter an email.', 'give' ) );
724
+		give_set_error('email_empty', esc_html__('Enter an email.', 'give'));
725 725
 	}
726 726
 
727 727
 	// Loop through required fields and show error messages.
728
-	foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) {
729
-		if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
730
-			give_set_error( $value['error_id'], $value['error_message'] );
728
+	foreach (give_get_required_fields($form_id) as $field_name => $value) {
729
+		if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) {
730
+			give_set_error($value['error_id'], $value['error_message']);
731 731
 		}
732 732
 	}
733 733
 
@@ -743,36 +743,36 @@  discard block
 block discarded – undo
743 743
  * @since   1.0
744 744
  * @return  integer
745 745
  */
746
-function give_register_and_login_new_user( $user_data = array() ) {
746
+function give_register_and_login_new_user($user_data = array()) {
747 747
 	// Verify the array.
748
-	if ( empty( $user_data ) ) {
749
-		return - 1;
748
+	if (empty($user_data)) {
749
+		return -1;
750 750
 	}
751 751
 
752
-	if ( give_get_errors() ) {
753
-		return - 1;
752
+	if (give_get_errors()) {
753
+		return -1;
754 754
 	}
755 755
 
756
-	$user_args = apply_filters( 'give_insert_user_args', array(
757
-		'user_login'      => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '',
758
-		'user_pass'       => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '',
759
-		'user_email'      => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '',
760
-		'first_name'      => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '',
761
-		'last_name'       => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '',
762
-		'user_registered' => date( 'Y-m-d H:i:s' ),
763
-		'role'            => get_option( 'default_role' ),
764
-	), $user_data );
756
+	$user_args = apply_filters('give_insert_user_args', array(
757
+		'user_login'      => isset($user_data['user_login']) ? $user_data['user_login'] : '',
758
+		'user_pass'       => isset($user_data['user_pass']) ? $user_data['user_pass'] : '',
759
+		'user_email'      => isset($user_data['user_email']) ? $user_data['user_email'] : '',
760
+		'first_name'      => isset($user_data['user_first']) ? $user_data['user_first'] : '',
761
+		'last_name'       => isset($user_data['user_last']) ? $user_data['user_last'] : '',
762
+		'user_registered' => date('Y-m-d H:i:s'),
763
+		'role'            => get_option('default_role'),
764
+	), $user_data);
765 765
 
766 766
 	// Insert new user.
767
-	$user_id = wp_insert_user( $user_args );
767
+	$user_id = wp_insert_user($user_args);
768 768
 
769 769
 	// Validate inserted user.
770
-	if ( is_wp_error( $user_id ) ) {
771
-		return - 1;
770
+	if (is_wp_error($user_id)) {
771
+		return -1;
772 772
 	}
773 773
 
774 774
 	// Allow themes and plugins to filter the user data.
775
-	$user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args );
775
+	$user_data = apply_filters('give_insert_user_data', $user_data, $user_args);
776 776
 
777 777
 	/**
778 778
 	 * Fires after inserting user.
@@ -782,10 +782,10 @@  discard block
 block discarded – undo
782 782
 	 * @param int   $user_id   User id.
783 783
 	 * @param array $user_data Array containing user data.
784 784
 	 */
785
-	do_action( 'give_insert_user', $user_id, $user_data );
785
+	do_action('give_insert_user', $user_id, $user_data);
786 786
 
787 787
 	// Login new user.
788
-	give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] );
788
+	give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']);
789 789
 
790 790
 	// Return user id.
791 791
 	return $user_id;
@@ -800,27 +800,27 @@  discard block
 block discarded – undo
800 800
  * @since   1.0
801 801
  * @return  array
802 802
  */
803
-function give_get_purchase_form_user( $valid_data = array() ) {
803
+function give_get_purchase_form_user($valid_data = array()) {
804 804
 
805 805
 	// Initialize user.
806 806
 	$user    = false;
807
-	$is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
807
+	$is_ajax = defined('DOING_AJAX') && DOING_AJAX;
808 808
 
809
-	if ( $is_ajax ) {
809
+	if ($is_ajax) {
810 810
 		// Do not create or login the user during the ajax submission (check for errors only).
811 811
 		return true;
812
-	} elseif ( is_user_logged_in() ) {
812
+	} elseif (is_user_logged_in()) {
813 813
 		// Set the valid user as the logged in collected data.
814 814
 		$user = $valid_data['logged_in_user'];
815
-	} elseif ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) {
815
+	} elseif ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) {
816 816
 		// New user registration.
817
-		if ( $valid_data['need_new_user'] === true ) {
817
+		if ($valid_data['need_new_user'] === true) {
818 818
 			// Set user.
819 819
 			$user = $valid_data['new_user_data'];
820 820
 			// Register and login new user.
821
-			$user['user_id'] = give_register_and_login_new_user( $user );
821
+			$user['user_id'] = give_register_and_login_new_user($user);
822 822
 			// User login
823
-		} elseif ( $valid_data['need_user_login'] === true && ! $is_ajax ) {
823
+		} elseif ($valid_data['need_user_login'] === true && ! $is_ajax) {
824 824
 
825 825
 			/*
826 826
 			 * The login form is now processed in the give_process_purchase_login() function.
@@ -833,48 +833,48 @@  discard block
 block discarded – undo
833 833
 			// Set user.
834 834
 			$user = $valid_data['login_user_data'];
835 835
 			// Login user.
836
-			give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] );
836
+			give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']);
837 837
 		}
838 838
 	}
839 839
 
840 840
 	// Check guest checkout.
841
-	if ( false === $user && false === give_logged_in_only( $_POST['give-form-id'] ) ) {
841
+	if (false === $user && false === give_logged_in_only($_POST['give-form-id'])) {
842 842
 		// Set user
843 843
 		$user = $valid_data['guest_user_data'];
844 844
 	}
845 845
 
846 846
 	// Verify we have an user.
847
-	if ( false === $user || empty( $user ) ) {
847
+	if (false === $user || empty($user)) {
848 848
 		// Return false.
849 849
 		return false;
850 850
 	}
851 851
 
852 852
 	// Get user first name.
853
-	if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) {
854
-		$user['user_first'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : '';
853
+	if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) {
854
+		$user['user_first'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : '';
855 855
 	}
856 856
 
857 857
 	// Get user last name.
858
-	if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) {
859
-		$user['user_last'] = isset( $_POST['give_last'] ) ? strip_tags( trim( $_POST['give_last'] ) ) : '';
858
+	if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) {
859
+		$user['user_last'] = isset($_POST['give_last']) ? strip_tags(trim($_POST['give_last'])) : '';
860 860
 	}
861 861
 
862 862
 	// Get the user's billing address details.
863 863
 	$user['address']            = array();
864
-	$user['address']['line1']   = ! empty( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : false;
865
-	$user['address']['line2']   = ! empty( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : false;
866
-	$user['address']['city']    = ! empty( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : false;
867
-	$user['address']['state']   = ! empty( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : false;
868
-	$user['address']['country'] = ! empty( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : false;
869
-	$user['address']['zip']     = ! empty( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : false;
870
-
871
-	if ( empty( $user['address']['country'] ) ) {
864
+	$user['address']['line1']   = ! empty($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : false;
865
+	$user['address']['line2']   = ! empty($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : false;
866
+	$user['address']['city']    = ! empty($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : false;
867
+	$user['address']['state']   = ! empty($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : false;
868
+	$user['address']['country'] = ! empty($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : false;
869
+	$user['address']['zip']     = ! empty($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : false;
870
+
871
+	if (empty($user['address']['country'])) {
872 872
 		$user['address'] = false;
873 873
 	} // Country will always be set if address fields are present.
874 874
 
875
-	if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) {
875
+	if ( ! empty($user['user_id']) && $user['user_id'] > 0 && ! empty($user['address'])) {
876 876
 		// Store the address in the user's meta so the donation form can be pre-populated with it on return purchases.
877
-		update_user_meta( $user['user_id'], '_give_user_address', $user['address'] );
877
+		update_user_meta($user['user_id'], '_give_user_address', $user['address']);
878 878
 	}
879 879
 
880 880
 	// Return valid user.
@@ -893,16 +893,16 @@  discard block
 block discarded – undo
893 893
 	$card_data = give_get_purchase_cc_info();
894 894
 
895 895
 	// Validate the card zip.
896
-	if ( ! empty( $card_data['card_zip'] ) ) {
897
-		if ( ! give_purchase_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) {
898
-			give_set_error( 'invalid_cc_zip', esc_html__( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) );
896
+	if ( ! empty($card_data['card_zip'])) {
897
+		if ( ! give_purchase_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) {
898
+			give_set_error('invalid_cc_zip', esc_html__('The zip / postal code you entered for your billing address is invalid.', 'give'));
899 899
 		}
900 900
 	}
901 901
 
902 902
 	// Ensure no spaces.
903
-	if ( ! empty( $card_data['card_number'] ) ) {
904
-		$card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); // no "+" signs
905
-		$card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces
903
+	if ( ! empty($card_data['card_number'])) {
904
+		$card_data['card_number'] = str_replace('+', '', $card_data['card_number']); // no "+" signs
905
+		$card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces
906 906
 	}
907 907
 
908 908
 	// This should validate card numbers at some point too.
@@ -918,17 +918,17 @@  discard block
 block discarded – undo
918 918
  */
919 919
 function give_get_purchase_cc_info() {
920 920
 	$cc_info                   = array();
921
-	$cc_info['card_name']      = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : '';
922
-	$cc_info['card_number']    = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : '';
923
-	$cc_info['card_cvc']       = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : '';
924
-	$cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : '';
925
-	$cc_info['card_exp_year']  = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : '';
926
-	$cc_info['card_address']   = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : '';
927
-	$cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : '';
928
-	$cc_info['card_city']      = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : '';
929
-	$cc_info['card_state']     = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : '';
930
-	$cc_info['card_country']   = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : '';
931
-	$cc_info['card_zip']       = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : '';
921
+	$cc_info['card_name']      = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : '';
922
+	$cc_info['card_number']    = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : '';
923
+	$cc_info['card_cvc']       = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : '';
924
+	$cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : '';
925
+	$cc_info['card_exp_year']  = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : '';
926
+	$cc_info['card_address']   = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : '';
927
+	$cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : '';
928
+	$cc_info['card_city']      = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : '';
929
+	$cc_info['card_state']     = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : '';
930
+	$cc_info['card_country']   = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : '';
931
+	$cc_info['card_zip']       = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : '';
932 932
 
933 933
 	// Return cc info
934 934
 	return $cc_info;
@@ -944,14 +944,14 @@  discard block
 block discarded – undo
944 944
  *
945 945
  * @return bool|mixed|void
946 946
  */
947
-function give_purchase_form_validate_cc_zip( $zip = 0, $country_code = '' ) {
947
+function give_purchase_form_validate_cc_zip($zip = 0, $country_code = '') {
948 948
 	$ret = false;
949 949
 
950
-	if ( empty( $zip ) || empty( $country_code ) ) {
950
+	if (empty($zip) || empty($country_code)) {
951 951
 		return $ret;
952 952
 	}
953 953
 
954
-	$country_code = strtoupper( $country_code );
954
+	$country_code = strtoupper($country_code);
955 955
 
956 956
 	$zip_regex = array(
957 957
 		'AD' => 'AD\d{3}',
@@ -1111,11 +1111,11 @@  discard block
 block discarded – undo
1111 1111
 		'ZM' => '\d{5}',
1112 1112
 	);
1113 1113
 
1114
-	if ( ! isset( $zip_regex[ $country_code ] ) || preg_match( '/' . $zip_regex[ $country_code ] . '/i', $zip ) ) {
1114
+	if ( ! isset($zip_regex[$country_code]) || preg_match('/'.$zip_regex[$country_code].'/i', $zip)) {
1115 1115
 		$ret = true;
1116 1116
 	}
1117 1117
 
1118
-	return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code );
1118
+	return apply_filters('give_is_zip_valid', $ret, $zip, $country_code);
1119 1119
 }
1120 1120
 
1121 1121
 
@@ -1129,36 +1129,36 @@  discard block
 block discarded – undo
1129 1129
  *
1130 1130
  * @return bool
1131 1131
  */
1132
-function give_validate_multi_donation_form_level( $valid_data, $data ) {
1132
+function give_validate_multi_donation_form_level($valid_data, $data) {
1133 1133
 	/* @var Give_Donate_Form $form */
1134
-	$form = new Give_Donate_Form( $data['give-form-id'] );
1134
+	$form = new Give_Donate_Form($data['give-form-id']);
1135 1135
 
1136 1136
 	$donation_level_matched = false;
1137 1137
 
1138
-	if ( $form->is_multi_type_donation_form() ) {
1138
+	if ($form->is_multi_type_donation_form()) {
1139 1139
 
1140 1140
 		// Bailout.
1141
-		if ( ! ( $variable_prices = $form->get_prices() ) ) {
1141
+		if ( ! ($variable_prices = $form->get_prices())) {
1142 1142
 			return false;
1143 1143
 		}
1144 1144
 
1145 1145
 		// Sanitize donation amount.
1146
-		$data['give-amount'] = give_sanitize_amount( $data['give-amount'] );
1146
+		$data['give-amount'] = give_sanitize_amount($data['give-amount']);
1147 1147
 
1148 1148
 		// Get number of decimals.
1149 1149
 		$default_decimals = give_get_price_decimals();
1150 1150
 
1151
-		if ( $data['give-amount'] === give_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ), $default_decimals ) ) {
1151
+		if ($data['give-amount'] === give_sanitize_amount(give_get_price_option_amount($data['give-form-id'], $data['give-price-id']), $default_decimals)) {
1152 1152
 			return true;
1153 1153
 		}
1154 1154
 
1155 1155
 		// Find correct donation level from all donation levels.
1156
-		foreach ( $variable_prices as $variable_price ) {
1156
+		foreach ($variable_prices as $variable_price) {
1157 1157
 			// Sanitize level amount.
1158
-			$variable_price['_give_amount'] = give_sanitize_amount( $variable_price['_give_amount'], $default_decimals );
1158
+			$variable_price['_give_amount'] = give_sanitize_amount($variable_price['_give_amount'], $default_decimals);
1159 1159
 
1160 1160
 			// Set first match donation level ID.
1161
-			if ( $data['give-amount'] === $variable_price['_give_amount'] ) {
1161
+			if ($data['give-amount'] === $variable_price['_give_amount']) {
1162 1162
 				$_POST['give-price-id'] = $variable_price['_give_id']['level_id'];
1163 1163
 				$donation_level_matched = true;
1164 1164
 				break;
@@ -1169,19 +1169,19 @@  discard block
 block discarded – undo
1169 1169
 		// If yes then set price id to custom if amount is greater then custom minimum amount (if any).
1170 1170
 		if (
1171 1171
 			! $donation_level_matched
1172
-			&& ( give_is_setting_enabled( get_post_meta( $data['give-form-id'], '_give_custom_amount', true ) ) )
1172
+			&& (give_is_setting_enabled(get_post_meta($data['give-form-id'], '_give_custom_amount', true)))
1173 1173
 		) {
1174 1174
 			// Sanitize custom minimum amount.
1175
-			$custom_minimum_amount = give_sanitize_amount( get_post_meta( $data['give-form-id'], '_give_custom_amount_minimum', true ), $default_decimals );
1175
+			$custom_minimum_amount = give_sanitize_amount(get_post_meta($data['give-form-id'], '_give_custom_amount_minimum', true), $default_decimals);
1176 1176
 
1177
-			if ( $data['give-amount'] >= $custom_minimum_amount ) {
1177
+			if ($data['give-amount'] >= $custom_minimum_amount) {
1178 1178
 				$_POST['give-price-id'] = 'custom';
1179 1179
 				$donation_level_matched = true;
1180 1180
 			}
1181 1181
 		}
1182 1182
 	}
1183 1183
 
1184
-	return ( $donation_level_matched ? true : false );
1184
+	return ($donation_level_matched ? true : false);
1185 1185
 }
1186 1186
 
1187
-add_action( 'give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2 );
1187
+add_action('give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2);
Please login to merge, or discard this patch.