Test Failed
Push — master ( 339236...7fe983 )
by Devin
09:29 queued 04:18
created
includes/admin/give-metabox-functions.php 1 patch
Spacing   +312 added lines, -312 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
9 9
  * @since       1.8
10 10
  */
11
-if ( ! defined( 'ABSPATH' ) ) {
11
+if ( ! defined('ABSPATH')) {
12 12
 	exit; // Exit if accessed directly
13 13
 }
14 14
 
@@ -22,8 +22,8 @@  discard block
 block discarded – undo
22 22
  *
23 23
  * @return bool|string
24 24
  */
25
-function give_is_field_callback_exist( $field ) {
26
-	return ( give_get_field_callback( $field ) ? true : false );
25
+function give_is_field_callback_exist($field) {
26
+	return (give_get_field_callback($field) ? true : false);
27 27
 }
28 28
 
29 29
 /**
@@ -35,12 +35,12 @@  discard block
 block discarded – undo
35 35
  *
36 36
  * @return bool|string
37 37
  */
38
-function give_get_field_callback( $field ) {
38
+function give_get_field_callback($field) {
39 39
 	$func_name_prefix = 'give';
40 40
 	$func_name        = '';
41 41
 
42 42
 	// Set callback function on basis of cmb2 field name.
43
-	switch ( $field['type'] ) {
43
+	switch ($field['type']) {
44 44
 		case 'radio_inline':
45 45
 			$func_name = "{$func_name_prefix}_radio";
46 46
 			break;
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
 		default:
77 77
 
78 78
 			if (
79
-				array_key_exists( 'callback', $field )
80
-				&& ! empty( $field['callback'] )
79
+				array_key_exists('callback', $field)
80
+				&& ! empty($field['callback'])
81 81
 			) {
82 82
 				$func_name = $field['callback'];
83 83
 			} else {
@@ -90,15 +90,15 @@  discard block
 block discarded – undo
90 90
 	 *
91 91
 	 * @since 1.8
92 92
 	 */
93
-	$func_name = apply_filters( 'give_get_field_callback', $func_name, $field );
93
+	$func_name = apply_filters('give_get_field_callback', $func_name, $field);
94 94
 
95 95
 	// Exit if not any function exist.
96 96
 	// Check if render callback exist or not.
97
-	if ( empty( $func_name ) ) {
97
+	if (empty($func_name)) {
98 98
 		return false;
99
-	} elseif ( is_string( $func_name ) && ! function_exists( "$func_name" ) ) {
99
+	} elseif (is_string($func_name) && ! function_exists("$func_name")) {
100 100
 		return false;
101
-	} elseif ( is_array( $func_name ) && ! method_exists( $func_name[0], "$func_name[1]" ) ) {
101
+	} elseif (is_array($func_name) && ! method_exists($func_name[0], "$func_name[1]")) {
102 102
 		return false;
103 103
 	}
104 104
 
@@ -114,35 +114,35 @@  discard block
 block discarded – undo
114 114
  *
115 115
  * @return bool
116 116
  */
117
-function give_render_field( $field ) {
117
+function give_render_field($field) {
118 118
 
119 119
 	// Check if render callback exist or not.
120
-	if ( ! ( $func_name = give_get_field_callback( $field ) ) ) {
120
+	if ( ! ($func_name = give_get_field_callback($field))) {
121 121
 		return false;
122 122
 	}
123 123
 
124 124
 	// CMB2 compatibility: Push all classes to attributes's class key
125
-	if ( empty( $field['class'] ) ) {
125
+	if (empty($field['class'])) {
126 126
 		$field['class'] = '';
127 127
 	}
128 128
 
129
-	if ( empty( $field['attributes']['class'] ) ) {
129
+	if (empty($field['attributes']['class'])) {
130 130
 		$field['attributes']['class'] = '';
131 131
 	}
132 132
 
133
-	$field['attributes']['class'] = trim( "give-field {$field['attributes']['class']} give-{$field['type']} {$field['class']}" );
134
-	unset( $field['class'] );
133
+	$field['attributes']['class'] = trim("give-field {$field['attributes']['class']} give-{$field['type']} {$field['class']}");
134
+	unset($field['class']);
135 135
 
136 136
 	// CMB2 compatibility: Set wrapper class if any.
137
-	if ( ! empty( $field['row_classes'] ) ) {
137
+	if ( ! empty($field['row_classes'])) {
138 138
 		$field['wrapper_class'] = $field['row_classes'];
139
-		unset( $field['row_classes'] );
139
+		unset($field['row_classes']);
140 140
 	}
141 141
 
142 142
 	// Set field params on basis of cmb2 field name.
143
-	switch ( $field['type'] ) {
143
+	switch ($field['type']) {
144 144
 		case 'radio_inline':
145
-			if ( empty( $field['wrapper_class'] ) ) {
145
+			if (empty($field['wrapper_class'])) {
146 146
 				$field['wrapper_class'] = '';
147 147
 			}
148 148
 			$field['wrapper_class'] .= ' give-inline-radio-fields';
@@ -155,15 +155,15 @@  discard block
 block discarded – undo
155 155
 		case 'text-small' :
156 156
 		case 'text_small' :
157 157
 			// CMB2 compatibility: Set field type to text.
158
-			$field['type'] = isset( $field['attributes']['type'] ) ? $field['attributes']['type'] : 'text';
158
+			$field['type'] = isset($field['attributes']['type']) ? $field['attributes']['type'] : 'text';
159 159
 
160 160
 			// CMB2 compatibility: Set data type to price.
161 161
 			if (
162
-				empty( $field['data_type'] )
163
-				&& ! empty( $field['attributes']['class'] )
162
+				empty($field['data_type'])
163
+				&& ! empty($field['attributes']['class'])
164 164
 				&& (
165
-					false !== strpos( $field['attributes']['class'], 'money' )
166
-					|| false !== strpos( $field['attributes']['class'], 'amount' )
165
+					false !== strpos($field['attributes']['class'], 'money')
166
+					|| false !== strpos($field['attributes']['class'], 'amount')
167 167
 				)
168 168
 			) {
169 169
 				$field['data_type'] = 'decimal';
@@ -182,22 +182,22 @@  discard block
 block discarded – undo
182 182
 		case 'give_default_radio_inline':
183 183
 			$field['type']    = 'radio';
184 184
 			$field['options'] = array(
185
-				'default' => __( 'Default' ),
185
+				'default' => __('Default'),
186 186
 			);
187 187
 			break;
188 188
 	}
189 189
 
190 190
 	// CMB2 compatibility: Add support to define field description by desc & description param.
191 191
 	// We encourage you to use description param.
192
-	$field['description'] = ( ! empty( $field['description'] )
192
+	$field['description'] = ( ! empty($field['description'])
193 193
 		? $field['description']
194
-		: ( ! empty( $field['desc'] ) ? $field['desc'] : '' ) );
194
+		: ( ! empty($field['desc']) ? $field['desc'] : ''));
195 195
 
196 196
 	// Call render function.
197
-	if ( is_array( $func_name ) ) {
198
-		$func_name[0]->{$func_name[1]}( $field );
197
+	if (is_array($func_name)) {
198
+		$func_name[0]->{$func_name[1]}($field);
199 199
 	} else {
200
-		$func_name( $field );
200
+		$func_name($field);
201 201
 	}
202 202
 
203 203
 	return true;
@@ -227,29 +227,29 @@  discard block
 block discarded – undo
227 227
  * }
228 228
  * @return void
229 229
  */
230
-function give_text_input( $field ) {
230
+function give_text_input($field) {
231 231
 	global $thepostid, $post;
232 232
 
233
-	$thepostid              = empty( $thepostid ) ? $post->ID : $thepostid;
234
-	$field['style']         = isset( $field['style'] ) ? $field['style'] : '';
235
-	$field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
236
-	$field['value']         = give_get_field_value( $field, $thepostid );
237
-	$field['type']          = isset( $field['type'] ) ? $field['type'] : 'text';
233
+	$thepostid              = empty($thepostid) ? $post->ID : $thepostid;
234
+	$field['style']         = isset($field['style']) ? $field['style'] : '';
235
+	$field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : '';
236
+	$field['value']         = give_get_field_value($field, $thepostid);
237
+	$field['type']          = isset($field['type']) ? $field['type'] : 'text';
238 238
 	$field['before_field']  = '';
239 239
 	$field['after_field']   = '';
240
-	$data_type              = empty( $field['data_type'] ) ? '' : $field['data_type'];
240
+	$data_type              = empty($field['data_type']) ? '' : $field['data_type'];
241 241
 
242
-	switch ( $data_type ) {
242
+	switch ($data_type) {
243 243
 		case 'price' :
244
-			$field['value'] = ( ! empty( $field['value'] ) ? give_format_amount( give_maybe_sanitize_amount( $field['value'] ), array( 'sanitize' => false ) ) : $field['value'] );
244
+			$field['value'] = ( ! empty($field['value']) ? give_format_amount(give_maybe_sanitize_amount($field['value']), array('sanitize' => false)) : $field['value']);
245 245
 
246
-			$field['before_field'] = ! empty( $field['before_field'] ) ? $field['before_field'] : ( give_get_option( 'currency_position', 'before' ) == 'before' ? '<span class="give-money-symbol give-money-symbol-before">' . give_currency_symbol() . '</span>' : '' );
247
-			$field['after_field']  = ! empty( $field['after_field'] ) ? $field['after_field'] : ( give_get_option( 'currency_position', 'before' ) == 'after' ? '<span class="give-money-symbol give-money-symbol-after">' . give_currency_symbol() . '</span>' : '' );
246
+			$field['before_field'] = ! empty($field['before_field']) ? $field['before_field'] : (give_get_option('currency_position', 'before') == 'before' ? '<span class="give-money-symbol give-money-symbol-before">'.give_currency_symbol().'</span>' : '');
247
+			$field['after_field']  = ! empty($field['after_field']) ? $field['after_field'] : (give_get_option('currency_position', 'before') == 'after' ? '<span class="give-money-symbol give-money-symbol-after">'.give_currency_symbol().'</span>' : '');
248 248
 			break;
249 249
 
250 250
 		case 'decimal' :
251 251
 			$field['attributes']['class'] .= ' give_input_decimal';
252
-			$field['value'] = ( ! empty( $field['value'] ) ? give_format_decimal( give_maybe_sanitize_amount( $field['value'] ), false, false ) : $field['value'] );
252
+			$field['value'] = ( ! empty($field['value']) ? give_format_decimal(give_maybe_sanitize_amount($field['value']), false, false) : $field['value']);
253 253
 			break;
254 254
 
255 255
 		default :
@@ -257,20 +257,20 @@  discard block
 block discarded – undo
257 257
 	}
258 258
 
259 259
 	?>
260
-	<p class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>">
261
-	<label for="<?php echo give_get_field_name( $field ); ?>"><?php echo wp_kses_post( $field['name'] ); ?></label>
260
+	<p class="give-field-wrap <?php echo esc_attr($field['id']); ?>_field <?php echo esc_attr($field['wrapper_class']); ?>">
261
+	<label for="<?php echo give_get_field_name($field); ?>"><?php echo wp_kses_post($field['name']); ?></label>
262 262
 	<?php echo $field['before_field']; ?>
263 263
 	<input
264
-			type="<?php echo esc_attr( $field['type'] ); ?>"
265
-			style="<?php echo esc_attr( $field['style'] ); ?>"
266
-			name="<?php echo give_get_field_name( $field ); ?>"
267
-			id="<?php echo esc_attr( $field['id'] ); ?>"
268
-			value="<?php echo esc_attr( $field['value'] ); ?>"
269
-		<?php echo give_get_custom_attributes( $field ); ?>
264
+			type="<?php echo esc_attr($field['type']); ?>"
265
+			style="<?php echo esc_attr($field['style']); ?>"
266
+			name="<?php echo give_get_field_name($field); ?>"
267
+			id="<?php echo esc_attr($field['id']); ?>"
268
+			value="<?php echo esc_attr($field['value']); ?>"
269
+		<?php echo give_get_custom_attributes($field); ?>
270 270
 	/>
271 271
 	<?php echo $field['after_field']; ?>
272 272
 	<?php
273
-	echo give_get_field_description( $field );
273
+	echo give_get_field_description($field);
274 274
 	echo '</p>';
275 275
 }
276 276
 
@@ -292,29 +292,29 @@  discard block
 block discarded – undo
292 292
  * }
293 293
  * @return void
294 294
  */
295
-function give_hidden_input( $field ) {
295
+function give_hidden_input($field) {
296 296
 	global $thepostid, $post;
297 297
 
298
-	$thepostid      = empty( $thepostid ) ? $post->ID : $thepostid;
299
-	$field['value'] = give_get_field_value( $field, $thepostid );
298
+	$thepostid      = empty($thepostid) ? $post->ID : $thepostid;
299
+	$field['value'] = give_get_field_value($field, $thepostid);
300 300
 
301 301
 	// Custom attribute handling
302 302
 	$custom_attributes = array();
303 303
 
304
-	if ( ! empty( $field['attributes'] ) && is_array( $field['attributes'] ) ) {
304
+	if ( ! empty($field['attributes']) && is_array($field['attributes'])) {
305 305
 
306
-		foreach ( $field['attributes'] as $attribute => $value ) {
307
-			$custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $value ) . '"';
306
+		foreach ($field['attributes'] as $attribute => $value) {
307
+			$custom_attributes[] = esc_attr($attribute).'="'.esc_attr($value).'"';
308 308
 		}
309 309
 	}
310 310
 	?>
311 311
 
312 312
 	<input
313 313
 			type="hidden"
314
-			name="<?php echo give_get_field_name( $field ); ?>"
315
-			id="<?php echo esc_attr( $field['id'] ); ?>"
316
-			value="<?php echo esc_attr( $field['value'] ); ?>"
317
-		<?php echo give_get_custom_attributes( $field ); ?>
314
+			name="<?php echo give_get_field_name($field); ?>"
315
+			id="<?php echo esc_attr($field['id']); ?>"
316
+			value="<?php echo esc_attr($field['value']); ?>"
317
+		<?php echo give_get_custom_attributes($field); ?>
318 318
 	/>
319 319
 	<?php
320 320
 }
@@ -340,27 +340,27 @@  discard block
 block discarded – undo
340 340
  * }
341 341
  * @return void
342 342
  */
343
-function give_textarea_input( $field ) {
343
+function give_textarea_input($field) {
344 344
 	global $thepostid, $post;
345 345
 
346
-	$thepostid              = empty( $thepostid ) ? $post->ID : $thepostid;
347
-	$field['style']         = isset( $field['style'] ) ? $field['style'] : '';
348
-	$field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
349
-	$field['value']         = give_get_field_value( $field, $thepostid );
346
+	$thepostid              = empty($thepostid) ? $post->ID : $thepostid;
347
+	$field['style']         = isset($field['style']) ? $field['style'] : '';
348
+	$field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : '';
349
+	$field['value']         = give_get_field_value($field, $thepostid);
350 350
 
351 351
 	?>
352
-	<p class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>">
353
-	<label for="<?php echo give_get_field_name( $field ); ?>"><?php echo wp_kses_post( $field['name'] ); ?></label>
352
+	<p class="give-field-wrap <?php echo esc_attr($field['id']); ?>_field <?php echo esc_attr($field['wrapper_class']); ?>">
353
+	<label for="<?php echo give_get_field_name($field); ?>"><?php echo wp_kses_post($field['name']); ?></label>
354 354
 	<textarea
355
-			style="<?php echo esc_attr( $field['style'] ); ?>"
356
-			name="<?php echo give_get_field_name( $field ); ?>"
357
-			id="<?php echo esc_attr( $field['id'] ); ?>"
355
+			style="<?php echo esc_attr($field['style']); ?>"
356
+			name="<?php echo give_get_field_name($field); ?>"
357
+			id="<?php echo esc_attr($field['id']); ?>"
358 358
 			rows="10"
359 359
 			cols="20"
360
-		<?php echo give_get_custom_attributes( $field ); ?>
361
-	><?php echo esc_textarea( $field['value'] ); ?></textarea>
360
+		<?php echo give_get_custom_attributes($field); ?>
361
+	><?php echo esc_textarea($field['value']); ?></textarea>
362 362
 	<?php
363
-	echo give_get_field_description( $field );
363
+	echo give_get_field_description($field);
364 364
 	echo '</p>';
365 365
 }
366 366
 
@@ -384,29 +384,29 @@  discard block
 block discarded – undo
384 384
  * }
385 385
  * @return void
386 386
  */
387
-function give_wysiwyg( $field ) {
387
+function give_wysiwyg($field) {
388 388
 	global $thepostid, $post;
389 389
 
390
-	$thepostid              = empty( $thepostid ) ? $post->ID : $thepostid;
391
-	$field['value']         = give_get_field_value( $field, $thepostid );
392
-	$field['style']         = isset( $field['style'] ) ? $field['style'] : '';
393
-	$field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
390
+	$thepostid              = empty($thepostid) ? $post->ID : $thepostid;
391
+	$field['value']         = give_get_field_value($field, $thepostid);
392
+	$field['style']         = isset($field['style']) ? $field['style'] : '';
393
+	$field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : '';
394 394
 
395
-	$field['unique_field_id'] = give_get_field_name( $field );
395
+	$field['unique_field_id'] = give_get_field_name($field);
396 396
 	$editor_attributes        = array(
397
-		'textarea_name' => isset( $field['repeatable_field_id'] ) ? $field['repeatable_field_id'] : $field['id'],
397
+		'textarea_name' => isset($field['repeatable_field_id']) ? $field['repeatable_field_id'] : $field['id'],
398 398
 		'textarea_rows' => '10',
399
-		'editor_css'    => esc_attr( $field['style'] ),
399
+		'editor_css'    => esc_attr($field['style']),
400 400
 		'editor_class'  => $field['attributes']['class'],
401 401
 	);
402
-	$data_wp_editor           = ' data-wp-editor="' . base64_encode( json_encode( array(
402
+	$data_wp_editor = ' data-wp-editor="'.base64_encode(json_encode(array(
403 403
 			$field['value'],
404 404
 			$field['unique_field_id'],
405 405
 			$editor_attributes,
406
-	) ) ) . '"';
407
-	$data_wp_editor           = isset( $field['repeatable_field_id'] ) ? $data_wp_editor : '';
406
+	))).'"';
407
+	$data_wp_editor = isset($field['repeatable_field_id']) ? $data_wp_editor : '';
408 408
 
409
-	echo '<div class="give-field-wrap ' . $field['unique_field_id'] . '_field ' . esc_attr( $field['wrapper_class'] ) . '"' . $data_wp_editor . '><label for="' . $field['unique_field_id'] . '">' . wp_kses_post( $field['name'] ) . '</label>';
409
+	echo '<div class="give-field-wrap '.$field['unique_field_id'].'_field '.esc_attr($field['wrapper_class']).'"'.$data_wp_editor.'><label for="'.$field['unique_field_id'].'">'.wp_kses_post($field['name']).'</label>';
410 410
 
411 411
 	wp_editor(
412 412
 		$field['value'],
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 		$editor_attributes
415 415
 	);
416 416
 
417
-	echo give_get_field_description( $field );
417
+	echo give_get_field_description($field);
418 418
 	echo '</div>';
419 419
 }
420 420
 
@@ -439,29 +439,29 @@  discard block
 block discarded – undo
439 439
  * }
440 440
  * @return void
441 441
  */
442
-function give_checkbox( $field ) {
442
+function give_checkbox($field) {
443 443
 	global $thepostid, $post;
444 444
 
445
-	$thepostid              = empty( $thepostid ) ? $post->ID : $thepostid;
446
-	$field['style']         = isset( $field['style'] ) ? $field['style'] : '';
447
-	$field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
448
-	$field['value']         = give_get_field_value( $field, $thepostid );
449
-	$field['cbvalue']       = isset( $field['cbvalue'] ) ? $field['cbvalue'] : 'on';
450
-	$field['name']          = isset( $field['name'] ) ? $field['name'] : $field['id'];
445
+	$thepostid              = empty($thepostid) ? $post->ID : $thepostid;
446
+	$field['style']         = isset($field['style']) ? $field['style'] : '';
447
+	$field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : '';
448
+	$field['value']         = give_get_field_value($field, $thepostid);
449
+	$field['cbvalue']       = isset($field['cbvalue']) ? $field['cbvalue'] : 'on';
450
+	$field['name']          = isset($field['name']) ? $field['name'] : $field['id'];
451 451
 	?>
452
-	<p class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>">
453
-	<label for="<?php echo give_get_field_name( $field ); ?>"><?php echo wp_kses_post( $field['name'] ); ?></label>
452
+	<p class="give-field-wrap <?php echo esc_attr($field['id']); ?>_field <?php echo esc_attr($field['wrapper_class']); ?>">
453
+	<label for="<?php echo give_get_field_name($field); ?>"><?php echo wp_kses_post($field['name']); ?></label>
454 454
 	<input
455 455
 			type="checkbox"
456
-			style="<?php echo esc_attr( $field['style'] ); ?>"
457
-			name="<?php echo give_get_field_name( $field ); ?>"
458
-			id="<?php echo esc_attr( $field['id'] ); ?>"
459
-			value="<?php echo esc_attr( $field['cbvalue'] ); ?>"
460
-		<?php echo checked( $field['value'], $field['cbvalue'], false ); ?>
461
-		<?php echo give_get_custom_attributes( $field ); ?>
456
+			style="<?php echo esc_attr($field['style']); ?>"
457
+			name="<?php echo give_get_field_name($field); ?>"
458
+			id="<?php echo esc_attr($field['id']); ?>"
459
+			value="<?php echo esc_attr($field['cbvalue']); ?>"
460
+		<?php echo checked($field['value'], $field['cbvalue'], false); ?>
461
+		<?php echo give_get_custom_attributes($field); ?>
462 462
 	/>
463 463
 	<?php
464
-	echo give_get_field_description( $field );
464
+	echo give_get_field_description($field);
465 465
 	echo '</p>';
466 466
 }
467 467
 
@@ -487,29 +487,29 @@  discard block
 block discarded – undo
487 487
  * }
488 488
  * @return void
489 489
  */
490
-function give_select( $field ) {
490
+function give_select($field) {
491 491
 	global $thepostid, $post;
492 492
 
493
-	$thepostid              = empty( $thepostid ) ? $post->ID : $thepostid;
494
-	$field['style']         = isset( $field['style'] ) ? $field['style'] : '';
495
-	$field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
496
-	$field['value']         = give_get_field_value( $field, $thepostid );
497
-	$field['name']          = isset( $field['name'] ) ? $field['name'] : $field['id'];
493
+	$thepostid              = empty($thepostid) ? $post->ID : $thepostid;
494
+	$field['style']         = isset($field['style']) ? $field['style'] : '';
495
+	$field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : '';
496
+	$field['value']         = give_get_field_value($field, $thepostid);
497
+	$field['name']          = isset($field['name']) ? $field['name'] : $field['id'];
498 498
 	?>
499
-	<p class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>">
500
-	<label for="<?php echo give_get_field_name( $field ); ?>"><?php echo wp_kses_post( $field['name'] ); ?></label>
499
+	<p class="give-field-wrap <?php echo esc_attr($field['id']); ?>_field <?php echo esc_attr($field['wrapper_class']); ?>">
500
+	<label for="<?php echo give_get_field_name($field); ?>"><?php echo wp_kses_post($field['name']); ?></label>
501 501
 	<select
502
-	id="<?php echo esc_attr( $field['id'] ); ?>"
503
-	name="<?php echo give_get_field_name( $field ); ?>"
504
-	style="<?php echo esc_attr( $field['style'] ) ?>"
505
-	<?php echo give_get_custom_attributes( $field ); ?>
502
+	id="<?php echo esc_attr($field['id']); ?>"
503
+	name="<?php echo give_get_field_name($field); ?>"
504
+	style="<?php echo esc_attr($field['style']) ?>"
505
+	<?php echo give_get_custom_attributes($field); ?>
506 506
 	>
507 507
 	<?php
508
-	foreach ( $field['options'] as $key => $value ) {
509
-		echo '<option value="' . esc_attr( $key ) . '" ' . selected( esc_attr( $field['value'] ), esc_attr( $key ), false ) . '>' . esc_html( $value ) . '</option>';
508
+	foreach ($field['options'] as $key => $value) {
509
+		echo '<option value="'.esc_attr($key).'" '.selected(esc_attr($field['value']), esc_attr($key), false).'>'.esc_html($value).'</option>';
510 510
 	}
511 511
 	echo '</select>';
512
-	echo give_get_field_description( $field );
512
+	echo give_get_field_description($field);
513 513
 	echo '</p>';
514 514
 }
515 515
 
@@ -536,32 +536,32 @@  discard block
 block discarded – undo
536 536
  * }
537 537
  * @return void
538 538
  */
539
-function give_radio( $field ) {
539
+function give_radio($field) {
540 540
 	global $thepostid, $post;
541 541
 
542
-	$thepostid              = empty( $thepostid ) ? $post->ID : $thepostid;
543
-	$field['style']         = isset( $field['style'] ) ? $field['style'] : '';
544
-	$field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
545
-	$field['value']         = give_get_field_value( $field, $thepostid );
546
-	$field['name']          = isset( $field['name'] ) ? $field['name'] : $field['id'];
542
+	$thepostid              = empty($thepostid) ? $post->ID : $thepostid;
543
+	$field['style']         = isset($field['style']) ? $field['style'] : '';
544
+	$field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : '';
545
+	$field['value']         = give_get_field_value($field, $thepostid);
546
+	$field['name']          = isset($field['name']) ? $field['name'] : $field['id'];
547 547
 
548
-	echo '<fieldset class="give-field-wrap ' . esc_attr( $field['id'] ) . '_field ' . esc_attr( $field['wrapper_class'] ) . '"><span class="give-field-label">' . wp_kses_post( $field['name'] ) . '</span><legend class="screen-reader-text">' . wp_kses_post( $field['name'] ) . '</legend><ul class="give-radios">';
548
+	echo '<fieldset class="give-field-wrap '.esc_attr($field['id']).'_field '.esc_attr($field['wrapper_class']).'"><span class="give-field-label">'.wp_kses_post($field['name']).'</span><legend class="screen-reader-text">'.wp_kses_post($field['name']).'</legend><ul class="give-radios">';
549 549
 
550
-	foreach ( $field['options'] as $key => $value ) {
550
+	foreach ($field['options'] as $key => $value) {
551 551
 
552 552
 		echo '<li><label><input
553
-				name="' . give_get_field_name( $field ) . '"
554
-				value="' . esc_attr( $key ) . '"
553
+				name="' . give_get_field_name($field).'"
554
+				value="' . esc_attr($key).'"
555 555
 				type="radio"
556
-				style="' . esc_attr( $field['style'] ) . '"
557
-				' . checked( esc_attr( $field['value'] ), esc_attr( $key ), false ) . ' '
558
-		     . give_get_custom_attributes( $field ) . '
559
-				/> ' . esc_html( $value ) . '</label>
556
+				style="' . esc_attr($field['style']).'"
557
+				' . checked(esc_attr($field['value']), esc_attr($key), false).' '
558
+		     . give_get_custom_attributes($field).'
559
+				/> ' . esc_html($value).'</label>
560 560
 		</li>';
561 561
 	}
562 562
 	echo '</ul>';
563 563
 
564
-	echo give_get_field_description( $field );
564
+	echo give_get_field_description($field);
565 565
 	echo '</fieldset>';
566 566
 }
567 567
 
@@ -585,27 +585,27 @@  discard block
 block discarded – undo
585 585
  * }
586 586
  * @return void
587 587
  */
588
-function give_colorpicker( $field ) {
588
+function give_colorpicker($field) {
589 589
 	global $thepostid, $post;
590 590
 
591
-	$thepostid              = empty( $thepostid ) ? $post->ID : $thepostid;
592
-	$field['style']         = isset( $field['style'] ) ? $field['style'] : '';
593
-	$field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
594
-	$field['value']         = give_get_field_value( $field, $thepostid );
595
-	$field['name']          = isset( $field['name'] ) ? $field['name'] : $field['id'];
591
+	$thepostid              = empty($thepostid) ? $post->ID : $thepostid;
592
+	$field['style']         = isset($field['style']) ? $field['style'] : '';
593
+	$field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : '';
594
+	$field['value']         = give_get_field_value($field, $thepostid);
595
+	$field['name']          = isset($field['name']) ? $field['name'] : $field['id'];
596 596
 	$field['type']          = 'text';
597 597
 	?>
598
-	<p class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>">
599
-	<label for="<?php echo give_get_field_name( $field ); ?>"><?php echo wp_kses_post( $field['name'] ); ?></label>
598
+	<p class="give-field-wrap <?php echo esc_attr($field['id']); ?>_field <?php echo esc_attr($field['wrapper_class']); ?>">
599
+	<label for="<?php echo give_get_field_name($field); ?>"><?php echo wp_kses_post($field['name']); ?></label>
600 600
 	<input
601
-			type="<?php echo esc_attr( $field['type'] ); ?>"
602
-			style="<?php echo esc_attr( $field['style'] ); ?>"
603
-			name="<?php echo give_get_field_name( $field ); ?>"
604
-			id="' . esc_attr( $field['id'] ) . '" value="<?php echo esc_attr( $field['value'] ); ?>"
605
-		<?php echo give_get_custom_attributes( $field ); ?>
601
+			type="<?php echo esc_attr($field['type']); ?>"
602
+			style="<?php echo esc_attr($field['style']); ?>"
603
+			name="<?php echo give_get_field_name($field); ?>"
604
+			id="' . esc_attr( $field['id'] ) . '" value="<?php echo esc_attr($field['value']); ?>"
605
+		<?php echo give_get_custom_attributes($field); ?>
606 606
 	/>
607 607
 	<?php
608
-	echo give_get_field_description( $field );
608
+	echo give_get_field_description($field);
609 609
 	echo '</p>';
610 610
 }
611 611
 
@@ -616,8 +616,8 @@  discard block
 block discarded – undo
616 616
  *
617 617
  * @param array $field
618 618
  */
619
-function give_file( $field ) {
620
-	give_media( $field );
619
+function give_file($field) {
620
+	give_media($field);
621 621
 }
622 622
 
623 623
 
@@ -628,40 +628,40 @@  discard block
 block discarded – undo
628 628
  *
629 629
  * @param array $field
630 630
  */
631
-function give_media( $field ) {
631
+function give_media($field) {
632 632
 	global $thepostid, $post;
633 633
 
634
-	$thepostid    = empty( $thepostid ) ? $post->ID : $thepostid;
635
-	$button_label = esc_html__( sprintf( 'Add or Upload %s', ( 'file' === $field['type'] ? 'File' : 'Image' ) ), 'give' );
634
+	$thepostid    = empty($thepostid) ? $post->ID : $thepostid;
635
+	$button_label = esc_html__(sprintf('Add or Upload %s', ('file' === $field['type'] ? 'File' : 'Image')), 'give');
636 636
 
637
-	$field['style']               = isset( $field['style'] ) ? $field['style'] : '';
638
-	$field['wrapper_class']       = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
639
-	$field['value']               = give_get_field_value( $field, $thepostid );
640
-	$field['name']                = isset( $field['name'] ) ? $field['name'] : $field['id'];
637
+	$field['style']               = isset($field['style']) ? $field['style'] : '';
638
+	$field['wrapper_class']       = isset($field['wrapper_class']) ? $field['wrapper_class'] : '';
639
+	$field['value']               = give_get_field_value($field, $thepostid);
640
+	$field['name']                = isset($field['name']) ? $field['name'] : $field['id'];
641 641
 	$field['attributes']['class'] = "{$field['attributes']['class']} give-text-medium";
642 642
 
643 643
 	// Allow developer to save attachment ID or attachment url as metadata.
644
-	$field['fvalue'] = isset( $field['fvalue'] ) ? $field['fvalue'] : 'url';
644
+	$field['fvalue'] = isset($field['fvalue']) ? $field['fvalue'] : 'url';
645 645
 
646
-	$allow_media_preview_tags = array( 'jpg', 'jpeg', 'png', 'gif', 'ico' );
647
-	$preview_image_src        = $field['value'] ? ( 'id' === $field['fvalue'] ? wp_get_attachment_url( $field['value'] ) : $field['value'] ) : '#';
648
-	$preview_image_extension  = $preview_image_src ? pathinfo( $preview_image_src, PATHINFO_EXTENSION ) : '';
649
-	$is_show_preview = in_array( $preview_image_extension, $allow_media_preview_tags );
646
+	$allow_media_preview_tags = array('jpg', 'jpeg', 'png', 'gif', 'ico');
647
+	$preview_image_src        = $field['value'] ? ('id' === $field['fvalue'] ? wp_get_attachment_url($field['value']) : $field['value']) : '#';
648
+	$preview_image_extension  = $preview_image_src ? pathinfo($preview_image_src, PATHINFO_EXTENSION) : '';
649
+	$is_show_preview = in_array($preview_image_extension, $allow_media_preview_tags);
650 650
 	?>
651
-	<fieldset class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>">
652
-		<label for="<?php echo give_get_field_name( $field ) ?>"><?php echo wp_kses_post( $field['name'] ); ?></label>
651
+	<fieldset class="give-field-wrap <?php echo esc_attr($field['id']); ?>_field <?php echo esc_attr($field['wrapper_class']); ?>">
652
+		<label for="<?php echo give_get_field_name($field) ?>"><?php echo wp_kses_post($field['name']); ?></label>
653 653
 		<input
654
-				name="<?php echo give_get_field_name( $field ); ?>"
655
-				id="<?php echo esc_attr( $field['id'] ); ?>"
654
+				name="<?php echo give_get_field_name($field); ?>"
655
+				id="<?php echo esc_attr($field['id']); ?>"
656 656
 				type="text"
657 657
 				value="<?php echo $field['value']; ?>"
658
-				style="<?php echo esc_attr( $field['style'] ); ?>"
659
-			<?php echo give_get_custom_attributes( $field ); ?>
658
+				style="<?php echo esc_attr($field['style']); ?>"
659
+			<?php echo give_get_custom_attributes($field); ?>
660 660
 		/>&nbsp;&nbsp;&nbsp;&nbsp;<input class="give-upload-button button" type="button" value="<?php echo $button_label; ?>" data-fvalue="<?php echo $field['fvalue']; ?>" data-field-type="<?php echo $field['type']; ?>">
661
-		<?php echo give_get_field_description( $field ); ?>
661
+		<?php echo give_get_field_description($field); ?>
662 662
 		<div class="give-image-thumb<?php echo ! $field['value'] || ! $is_show_preview ? ' give-hidden' : ''; ?>">
663 663
 			<span class="give-delete-image-thumb dashicons dashicons-no-alt"></span>
664
-			<img src="<?php echo $preview_image_src ; ?>" alt="">
664
+			<img src="<?php echo $preview_image_src; ?>" alt="">
665 665
 		</div>
666 666
 	</fieldset>
667 667
 	<?php
@@ -676,27 +676,27 @@  discard block
 block discarded – undo
676 676
  *
677 677
  * @return void
678 678
  */
679
-function give_default_gateway( $field ) {
679
+function give_default_gateway($field) {
680 680
 	global $thepostid, $post;
681 681
 
682 682
 	// get all active payment gateways.
683
-	$gateways         = give_get_enabled_payment_gateways( $thepostid );
683
+	$gateways         = give_get_enabled_payment_gateways($thepostid);
684 684
 	$field['options'] = array();
685 685
 
686 686
 	// Set field option value.
687
-	if ( ! empty( $gateways ) ) {
688
-		foreach ( $gateways as $key => $option ) {
689
-			$field['options'][ $key ] = $option['admin_label'];
687
+	if ( ! empty($gateways)) {
688
+		foreach ($gateways as $key => $option) {
689
+			$field['options'][$key] = $option['admin_label'];
690 690
 		}
691 691
 	}
692 692
 
693 693
 	// Add a field to the Give Form admin single post view of this field
694
-	if ( is_object( $post ) && 'give_forms' === $post->post_type ) {
695
-		$field['options'] = array_merge( array( 'global' => esc_html__( 'Global Default', 'give' ) ), $field['options'] );
694
+	if (is_object($post) && 'give_forms' === $post->post_type) {
695
+		$field['options'] = array_merge(array('global' => esc_html__('Global Default', 'give')), $field['options']);
696 696
 	}
697 697
 
698 698
 	// Render select field.
699
-	give_select( $field );
699
+	give_select($field);
700 700
 }
701 701
 
702 702
 /**
@@ -718,13 +718,13 @@  discard block
 block discarded – undo
718 718
  * @return void
719 719
  */
720 720
 
721
-function give_docs_link( $field ) {
722
-	$field['url']   = isset( $field['url'] ) ? $field['url'] : 'https://givewp.com/documentation';
723
-	$field['title'] = isset( $field['title'] ) ? $field['title'] : 'Documentation';
721
+function give_docs_link($field) {
722
+	$field['url']   = isset($field['url']) ? $field['url'] : 'https://givewp.com/documentation';
723
+	$field['title'] = isset($field['title']) ? $field['title'] : 'Documentation';
724 724
 
725
-	echo '<p class="give-docs-link"><a href="' . esc_url( $field['url'] )
725
+	echo '<p class="give-docs-link"><a href="'.esc_url($field['url'])
726 726
 	     . '" target="_blank">'
727
-	     . sprintf( esc_html__( 'Need Help? See docs on "%s"', 'give' ), $field['title'] )
727
+	     . sprintf(esc_html__('Need Help? See docs on "%s"', 'give'), $field['title'])
728 728
 	     . '<span class="dashicons dashicons-editor-help"></span></a></p>';
729 729
 }
730 730
 
@@ -740,13 +740,13 @@  discard block
 block discarded – undo
740 740
  *
741 741
  * @return mixed
742 742
  */
743
-function give_get_field_value( $field, $postid ) {
744
-	if ( isset( $field['attributes']['value'] ) ) {
743
+function give_get_field_value($field, $postid) {
744
+	if (isset($field['attributes']['value'])) {
745 745
 		return $field['attributes']['value'];
746 746
 	}
747 747
 
748 748
 	// Get value from db.
749
-	$field_value = give_get_meta( $postid, $field['id'], true );
749
+	$field_value = give_get_meta($postid, $field['id'], true);
750 750
 
751 751
 	/**
752 752
 	 * Filter the field value before apply default value.
@@ -755,10 +755,10 @@  discard block
 block discarded – undo
755 755
 	 *
756 756
 	 * @param mixed $field_value Field value.
757 757
 	 */
758
-	$field_value = apply_filters( "{$field['id']}_field_value", $field_value, $field, $postid );
758
+	$field_value = apply_filters("{$field['id']}_field_value", $field_value, $field, $postid);
759 759
 
760 760
 	// Set default value if no any data saved to db.
761
-	if ( ! $field_value && isset( $field['default'] ) ) {
761
+	if ( ! $field_value && isset($field['default'])) {
762 762
 		$field_value = $field['default'];
763 763
 	}
764 764
 
@@ -775,20 +775,20 @@  discard block
 block discarded – undo
775 775
  *
776 776
  * @return string
777 777
  */
778
-function give_get_field_description( $field ) {
778
+function give_get_field_description($field) {
779 779
 	$field_desc_html = '';
780 780
 	$description     = '';
781 781
 
782 782
 	// Check for both `description` and `desc`.
783
-	if ( isset( $field['description'] ) ) {
783
+	if (isset($field['description'])) {
784 784
 		$description = $field['description'];
785
-	} elseif ( isset( $field['desc'] ) ) {
785
+	} elseif (isset($field['desc'])) {
786 786
 		$description = $field['desc'];
787 787
 	}
788 788
 
789 789
 	// Set if there is a description.
790
-	if ( ! empty( $description ) ) {
791
-		$field_desc_html = '<span class="give-field-description">' . wp_kses_post( $description ) . '</span>';
790
+	if ( ! empty($description)) {
791
+		$field_desc_html = '<span class="give-field-description">'.wp_kses_post($description).'</span>';
792 792
 	}
793 793
 
794 794
 	return $field_desc_html;
@@ -804,18 +804,18 @@  discard block
 block discarded – undo
804 804
  *
805 805
  * @return string
806 806
  */
807
-function give_get_custom_attributes( $field ) {
807
+function give_get_custom_attributes($field) {
808 808
 	// Custom attribute handling
809 809
 	$custom_attributes = array();
810 810
 
811
-	if ( ! empty( $field['attributes'] ) && is_array( $field['attributes'] ) ) {
811
+	if ( ! empty($field['attributes']) && is_array($field['attributes'])) {
812 812
 
813
-		foreach ( $field['attributes'] as $attribute => $value ) {
814
-			$custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $value ) . '"';
813
+		foreach ($field['attributes'] as $attribute => $value) {
814
+			$custom_attributes[] = esc_attr($attribute).'="'.esc_attr($value).'"';
815 815
 		}
816 816
 	}
817 817
 
818
-	return implode( ' ', $custom_attributes );
818
+	return implode(' ', $custom_attributes);
819 819
 }
820 820
 
821 821
 /**
@@ -831,8 +831,8 @@  discard block
 block discarded – undo
831 831
  *
832 832
  * @return string
833 833
  */
834
-function give_get_repeater_field_value( $field, $field_group, $fields ) {
835
-	$field_value = ( isset( $field_group[ $field['id'] ] ) ? $field_group[ $field['id'] ] : '' );
834
+function give_get_repeater_field_value($field, $field_group, $fields) {
835
+	$field_value = (isset($field_group[$field['id']]) ? $field_group[$field['id']] : '');
836 836
 
837 837
 	/**
838 838
 	 * Filter the specific repeater field value
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
 	 *
842 842
 	 * @param string $field_id
843 843
 	 */
844
-	$field_value = apply_filters( "give_get_repeater_field_{$field['id']}_value", $field_value, $field, $field_group, $fields );
844
+	$field_value = apply_filters("give_get_repeater_field_{$field['id']}_value", $field_value, $field, $field_group, $fields);
845 845
 
846 846
 	/**
847 847
 	 * Filter the repeater field value
@@ -850,7 +850,7 @@  discard block
 block discarded – undo
850 850
 	 *
851 851
 	 * @param string $field_id
852 852
 	 */
853
-	$field_value = apply_filters( 'give_get_repeater_field_value', $field_value, $field, $field_group, $fields );
853
+	$field_value = apply_filters('give_get_repeater_field_value', $field_value, $field, $field_group, $fields);
854 854
 
855 855
 	return $field_value;
856 856
 }
@@ -868,7 +868,7 @@  discard block
 block discarded – undo
868 868
  *
869 869
  * @return string
870 870
  */
871
-function give_get_repeater_field_id( $field, $fields, $default = false ) {
871
+function give_get_repeater_field_id($field, $fields, $default = false) {
872 872
 	$row_placeholder = false !== $default ? $default : '{{row-count-placeholder}}';
873 873
 
874 874
 	// Get field id.
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
 	 *
882 882
 	 * @param string $field_id
883 883
 	 */
884
-	$field_id = apply_filters( "give_get_repeater_field_{$field['id']}_id", $field_id, $field, $fields, $default );
884
+	$field_id = apply_filters("give_get_repeater_field_{$field['id']}_id", $field_id, $field, $fields, $default);
885 885
 
886 886
 	/**
887 887
 	 * Filter the repeater field id
@@ -890,7 +890,7 @@  discard block
 block discarded – undo
890 890
 	 *
891 891
 	 * @param string $field_id
892 892
 	 */
893
-	$field_id = apply_filters( 'give_get_repeater_field_id', $field_id, $field, $fields, $default );
893
+	$field_id = apply_filters('give_get_repeater_field_id', $field_id, $field, $fields, $default);
894 894
 
895 895
 	return $field_id;
896 896
 }
@@ -905,8 +905,8 @@  discard block
 block discarded – undo
905 905
  *
906 906
  * @return string
907 907
  */
908
-function give_get_field_name( $field ) {
909
-	$field_name = esc_attr( empty( $field['repeat'] ) ? $field['id'] : $field['repeatable_field_id'] );
908
+function give_get_field_name($field) {
909
+	$field_name = esc_attr(empty($field['repeat']) ? $field['id'] : $field['repeatable_field_id']);
910 910
 
911 911
 	/**
912 912
 	 * Filter the field name.
@@ -915,7 +915,7 @@  discard block
 block discarded – undo
915 915
 	 *
916 916
 	 * @param string $field_name
917 917
 	 */
918
-	$field_name = apply_filters( 'give_get_field_name', $field_name, $field );
918
+	$field_name = apply_filters('give_get_field_name', $field_name, $field);
919 919
 
920 920
 	return $field_name;
921 921
 }
@@ -932,40 +932,40 @@  discard block
 block discarded – undo
932 932
  *
933 933
  * @return void
934 934
  */
935
-function _give_metabox_form_data_repeater_fields( $fields ) {
935
+function _give_metabox_form_data_repeater_fields($fields) {
936 936
 	global $thepostid, $post;
937 937
 
938 938
 	// Bailout.
939
-	if ( ! isset( $fields['fields'] ) || empty( $fields['fields'] ) ) {
939
+	if ( ! isset($fields['fields']) || empty($fields['fields'])) {
940 940
 		return;
941 941
 	}
942 942
 
943
-	$group_numbering = isset( $fields['options']['group_numbering'] ) ? (int) $fields['options']['group_numbering'] : 0;
944
-	$close_tabs      = isset( $fields['options']['close_tabs'] ) ? (int) $fields['options']['close_tabs'] : 0;
945
-	$wrapper_class   = isset( $fields['wrapper_class'] ) ? $fields['wrapper_class'] : '';
943
+	$group_numbering = isset($fields['options']['group_numbering']) ? (int) $fields['options']['group_numbering'] : 0;
944
+	$close_tabs      = isset($fields['options']['close_tabs']) ? (int) $fields['options']['close_tabs'] : 0;
945
+	$wrapper_class   = isset($fields['wrapper_class']) ? $fields['wrapper_class'] : '';
946 946
 	?>
947
-	<div class="give-repeatable-field-section <?php echo esc_attr( $wrapper_class ); ?>" id="<?php echo "{$fields['id']}_field"; ?>"
947
+	<div class="give-repeatable-field-section <?php echo esc_attr($wrapper_class); ?>" id="<?php echo "{$fields['id']}_field"; ?>"
948 948
 		 data-group-numbering="<?php echo $group_numbering; ?>" data-close-tabs="<?php echo $close_tabs; ?>">
949
-		<?php if ( ! empty( $fields['name'] ) ) : ?>
949
+		<?php if ( ! empty($fields['name'])) : ?>
950 950
 			<p class="give-repeater-field-name"><?php echo $fields['name']; ?></p>
951 951
 		<?php endif; ?>
952 952
 
953
-		<?php if ( ! empty( $fields['description'] ) ) : ?>
953
+		<?php if ( ! empty($fields['description'])) : ?>
954 954
 			<p class="give-repeater-field-description"><?php echo $fields['description']; ?></p>
955 955
 		<?php endif; ?>
956 956
 
957 957
 		<table class="give-repeatable-fields-section-wrapper" cellspacing="0">
958 958
 			<?php
959
-			$repeater_field_values = give_get_meta( $thepostid, $fields['id'], true );
960
-			$header_title          = isset( $fields['options']['header_title'] )
959
+			$repeater_field_values = give_get_meta($thepostid, $fields['id'], true);
960
+			$header_title          = isset($fields['options']['header_title'])
961 961
 				? $fields['options']['header_title']
962
-				: esc_attr__( 'Group', 'give' );
962
+				: esc_attr__('Group', 'give');
963 963
 
964 964
 			$add_default_donation_field = false;
965 965
 
966 966
 			// Check if level is not created or we have to add default level.
967
-			if ( is_array( $repeater_field_values ) && ( $fields_count = count( $repeater_field_values ) ) ) {
968
-				$repeater_field_values = array_values( $repeater_field_values );
967
+			if (is_array($repeater_field_values) && ($fields_count = count($repeater_field_values))) {
968
+				$repeater_field_values = array_values($repeater_field_values);
969 969
 			} else {
970 970
 				$fields_count               = 1;
971 971
 				$add_default_donation_field = true;
@@ -978,59 +978,59 @@  discard block
 block discarded – undo
978 978
 					<div class="give-row-head give-move">
979 979
 						<button type="button" class="handlediv button-link"><span class="toggle-indicator"></span>
980 980
 						</button>
981
-						<span class="give-remove" title="<?php esc_html_e( 'Remove Group', 'give' ); ?>">-</span>
981
+						<span class="give-remove" title="<?php esc_html_e('Remove Group', 'give'); ?>">-</span>
982 982
 						<h2>
983 983
 							<span data-header-title="<?php echo $header_title; ?>"><?php echo $header_title; ?></span>
984 984
 						</h2>
985 985
 					</div>
986 986
 					<div class="give-row-body">
987
-						<?php foreach ( $fields['fields'] as $field ) : ?>
988
-							<?php if ( ! give_is_field_callback_exist( $field ) ) {
987
+						<?php foreach ($fields['fields'] as $field) : ?>
988
+							<?php if ( ! give_is_field_callback_exist($field)) {
989 989
 								continue;
990 990
 } ?>
991 991
 							<?php
992 992
 							$field['repeat']              = true;
993
-							$field['repeatable_field_id'] = give_get_repeater_field_id( $field, $fields );
994
-							$field['id']                  = str_replace( array( '[', ']' ), array(
993
+							$field['repeatable_field_id'] = give_get_repeater_field_id($field, $fields);
994
+							$field['id']                  = str_replace(array('[', ']'), array(
995 995
 								'_',
996 996
 								'',
997
-							), $field['repeatable_field_id'] );
997
+							), $field['repeatable_field_id']);
998 998
 							?>
999
-							<?php give_render_field( $field ); ?>
999
+							<?php give_render_field($field); ?>
1000 1000
 						<?php endforeach; ?>
1001 1001
 					</div>
1002 1002
 				</td>
1003 1003
 			</tr>
1004 1004
 
1005
-			<?php if ( ! empty( $repeater_field_values ) ) : ?>
1005
+			<?php if ( ! empty($repeater_field_values)) : ?>
1006 1006
 				<!--Stored repeater field group-->
1007
-				<?php foreach ( $repeater_field_values as $index => $field_group ) : ?>
1007
+				<?php foreach ($repeater_field_values as $index => $field_group) : ?>
1008 1008
 					<tr class="give-row">
1009 1009
 						<td class="give-repeater-field-wrap give-column" colspan="2">
1010 1010
 							<div class="give-row-head give-move">
1011 1011
 								<button type="button" class="handlediv button-link">
1012 1012
 									<span class="toggle-indicator"></span></button>
1013
-								<span class="give-remove" title="<?php esc_html_e( 'Remove Group', 'give' ); ?>">-
1013
+								<span class="give-remove" title="<?php esc_html_e('Remove Group', 'give'); ?>">-
1014 1014
 								</span>
1015 1015
 								<h2>
1016 1016
 									<span data-header-title="<?php echo $header_title; ?>"><?php echo $header_title; ?></span>
1017 1017
 								</h2>
1018 1018
 							</div>
1019 1019
 							<div class="give-row-body">
1020
-								<?php foreach ( $fields['fields'] as $field ) : ?>
1021
-									<?php if ( ! give_is_field_callback_exist( $field ) ) {
1020
+								<?php foreach ($fields['fields'] as $field) : ?>
1021
+									<?php if ( ! give_is_field_callback_exist($field)) {
1022 1022
 										continue;
1023 1023
 } ?>
1024 1024
 									<?php
1025 1025
 									$field['repeat']              = true;
1026
-									$field['repeatable_field_id'] = give_get_repeater_field_id( $field, $fields, $index );
1027
-									$field['attributes']['value'] = give_get_repeater_field_value( $field, $field_group, $fields );
1028
-									$field['id']                  = str_replace( array( '[', ']' ), array(
1026
+									$field['repeatable_field_id'] = give_get_repeater_field_id($field, $fields, $index);
1027
+									$field['attributes']['value'] = give_get_repeater_field_value($field, $field_group, $fields);
1028
+									$field['id']                  = str_replace(array('[', ']'), array(
1029 1029
 										'_',
1030 1030
 										'',
1031
-									), $field['repeatable_field_id'] );
1031
+									), $field['repeatable_field_id']);
1032 1032
 									?>
1033
-									<?php give_render_field( $field ); ?>
1033
+									<?php give_render_field($field); ?>
1034 1034
 								<?php endforeach; ?>
1035 1035
 							</div>
1036 1036
 						</td>
@@ -1038,14 +1038,14 @@  discard block
 block discarded – undo
1038 1038
 				<?php endforeach;
1039 1039
 ; ?>
1040 1040
 
1041
-			<?php elseif ( $add_default_donation_field ) : ?>
1041
+			<?php elseif ($add_default_donation_field) : ?>
1042 1042
 				<!--Default repeater field group-->
1043 1043
 				<tr class="give-row">
1044 1044
 					<td class="give-repeater-field-wrap give-column" colspan="2">
1045 1045
 						<div class="give-row-head give-move">
1046 1046
 							<button type="button" class="handlediv button-link">
1047 1047
 								<span class="toggle-indicator"></span></button>
1048
-							<span class="give-remove" title="<?php esc_html_e( 'Remove Group', 'give' ); ?>">-
1048
+							<span class="give-remove" title="<?php esc_html_e('Remove Group', 'give'); ?>">-
1049 1049
 							</span>
1050 1050
 							<h2>
1051 1051
 								<span data-header-title="<?php echo $header_title; ?>"><?php echo $header_title; ?></span>
@@ -1053,19 +1053,19 @@  discard block
 block discarded – undo
1053 1053
 						</div>
1054 1054
 						<div class="give-row-body">
1055 1055
 							<?php
1056
-							foreach ( $fields['fields'] as $field ) :
1057
-								if ( ! give_is_field_callback_exist( $field ) ) {
1056
+							foreach ($fields['fields'] as $field) :
1057
+								if ( ! give_is_field_callback_exist($field)) {
1058 1058
 									continue;
1059 1059
 								}
1060 1060
 
1061 1061
 								$field['repeat']              = true;
1062
-								$field['repeatable_field_id'] = give_get_repeater_field_id( $field, $fields, 0 );
1063
-								$field['attributes']['value'] = apply_filters( "give_default_field_group_field_{$field['id']}_value", ( ! empty( $field['default'] ) ? $field['default'] : '' ), $field );
1064
-								$field['id']                  = str_replace( array( '[', ']' ), array(
1062
+								$field['repeatable_field_id'] = give_get_repeater_field_id($field, $fields, 0);
1063
+								$field['attributes']['value'] = apply_filters("give_default_field_group_field_{$field['id']}_value", ( ! empty($field['default']) ? $field['default'] : ''), $field);
1064
+								$field['id']                  = str_replace(array('[', ']'), array(
1065 1065
 									'_',
1066 1066
 									'',
1067
-								), $field['repeatable_field_id'] );
1068
-								give_render_field( $field );
1067
+								), $field['repeatable_field_id']);
1068
+								give_render_field($field);
1069 1069
 							endforeach;
1070 1070
 							?>
1071 1071
 						</div>
@@ -1076,9 +1076,9 @@  discard block
 block discarded – undo
1076 1076
 			<tfoot>
1077 1077
 			<tr>
1078 1078
 				<?php
1079
-				$add_row_btn_title = isset( $fields['options']['add_button'] )
1079
+				$add_row_btn_title = isset($fields['options']['add_button'])
1080 1080
 					? $add_row_btn_title = $fields['options']['add_button']
1081
-					: esc_html__( 'Add Row', 'give' );
1081
+					: esc_html__('Add Row', 'give');
1082 1082
 				?>
1083 1083
 				<td colspan="2" class="give-add-repeater-field-section-row-wrap">
1084 1084
 					<span class="button button-primary give-add-repeater-field-section-row"><?php echo $add_row_btn_title; ?></span>
@@ -1108,10 +1108,10 @@  discard block
 block discarded – undo
1108 1108
 	 *
1109 1109
 	 * @param string
1110 1110
 	 */
1111
-	$default_current_tab = apply_filters( "give_default_setting_tab_{$current_setting_page}", 'general' );
1111
+	$default_current_tab = apply_filters("give_default_setting_tab_{$current_setting_page}", 'general');
1112 1112
 
1113 1113
 	// Get current tab.
1114
-	$current_tab = empty( $_GET['tab'] ) ? $default_current_tab : urldecode( $_GET['tab'] );
1114
+	$current_tab = empty($_GET['tab']) ? $default_current_tab : urldecode($_GET['tab']);
1115 1115
 
1116 1116
 	// Output.
1117 1117
 	return $current_tab;
@@ -1135,10 +1135,10 @@  discard block
 block discarded – undo
1135 1135
 	 *
1136 1136
 	 * @param string
1137 1137
 	 */
1138
-	$default_current_section = apply_filters( "give_default_setting_tab_section_{$current_tab}", '' );
1138
+	$default_current_section = apply_filters("give_default_setting_tab_section_{$current_tab}", '');
1139 1139
 
1140 1140
 	// Get current section.
1141
-	$current_section = empty( $_REQUEST['section'] ) ? $default_current_section : urldecode( $_REQUEST['section'] );
1141
+	$current_section = empty($_REQUEST['section']) ? $default_current_section : urldecode($_REQUEST['section']);
1142 1142
 
1143 1143
 	// Output.
1144 1144
 	return $current_section;
@@ -1152,7 +1152,7 @@  discard block
 block discarded – undo
1152 1152
  */
1153 1153
 function give_get_current_setting_page() {
1154 1154
 	// Get current page.
1155
-	$setting_page = ! empty( $_GET['page'] ) ? urldecode( $_GET['page'] ) : '';
1155
+	$setting_page = ! empty($_GET['page']) ? urldecode($_GET['page']) : '';
1156 1156
 
1157 1157
 	// Output.
1158 1158
 	return $setting_page;
@@ -1172,13 +1172,13 @@  discard block
 block discarded – undo
1172 1172
  *
1173 1173
  * @return string
1174 1174
  */
1175
-function _give_display_content_field_value( $field_value, $field, $postid ) {
1176
-	$show_content = give_get_meta( $postid, '_give_content_option', true );
1175
+function _give_display_content_field_value($field_value, $field, $postid) {
1176
+	$show_content = give_get_meta($postid, '_give_content_option', true);
1177 1177
 
1178 1178
 	if (
1179
-		! give_get_meta( $postid, '_give_display_content', true )
1179
+		! give_get_meta($postid, '_give_display_content', true)
1180 1180
 		&& $show_content
1181
-		&& ( 'none' !== $show_content )
1181
+		&& ('none' !== $show_content)
1182 1182
 	) {
1183 1183
 		$field_value = 'enabled';
1184 1184
 	}
@@ -1186,7 +1186,7 @@  discard block
 block discarded – undo
1186 1186
 	return $field_value;
1187 1187
 }
1188 1188
 
1189
-add_filter( '_give_display_content_field_value', '_give_display_content_field_value', 10, 3 );
1189
+add_filter('_give_display_content_field_value', '_give_display_content_field_value', 10, 3);
1190 1190
 
1191 1191
 
1192 1192
 /**
@@ -1203,12 +1203,12 @@  discard block
 block discarded – undo
1203 1203
  *
1204 1204
  * @return string
1205 1205
  */
1206
-function _give_content_placement_field_value( $field_value, $field, $postid ) {
1207
-	$show_content = give_get_meta( $postid, '_give_content_option', true );
1206
+function _give_content_placement_field_value($field_value, $field, $postid) {
1207
+	$show_content = give_get_meta($postid, '_give_content_option', true);
1208 1208
 
1209 1209
 	if (
1210
-		! give_get_meta( $postid, '_give_content_placement', true )
1211
-		&& ( 'none' !== $show_content )
1210
+		! give_get_meta($postid, '_give_content_placement', true)
1211
+		&& ('none' !== $show_content)
1212 1212
 	) {
1213 1213
 		$field_value = $show_content;
1214 1214
 	}
@@ -1216,7 +1216,7 @@  discard block
 block discarded – undo
1216 1216
 	return $field_value;
1217 1217
 }
1218 1218
 
1219
-add_filter( '_give_content_placement_field_value', '_give_content_placement_field_value', 10, 3 );
1219
+add_filter('_give_content_placement_field_value', '_give_content_placement_field_value', 10, 3);
1220 1220
 
1221 1221
 
1222 1222
 /**
@@ -1232,17 +1232,17 @@  discard block
 block discarded – undo
1232 1232
  *
1233 1233
  * @return string
1234 1234
  */
1235
-function _give_terms_option_field_value( $field_value, $field, $postid ) {
1236
-	$term_option = give_get_meta( $postid, '_give_terms_option', true );
1235
+function _give_terms_option_field_value($field_value, $field, $postid) {
1236
+	$term_option = give_get_meta($postid, '_give_terms_option', true);
1237 1237
 
1238
-	if ( in_array( $term_option, array( 'none', 'yes' ) ) ) {
1239
-		$field_value = ( 'yes' === $term_option ? 'enabled' : 'disabled' );
1238
+	if (in_array($term_option, array('none', 'yes'))) {
1239
+		$field_value = ('yes' === $term_option ? 'enabled' : 'disabled');
1240 1240
 	}
1241 1241
 
1242 1242
 	return $field_value;
1243 1243
 }
1244 1244
 
1245
-add_filter( '_give_terms_option_field_value', '_give_terms_option_field_value', 10, 3 );
1245
+add_filter('_give_terms_option_field_value', '_give_terms_option_field_value', 10, 3);
1246 1246
 
1247 1247
 
1248 1248
 /**
@@ -1259,17 +1259,17 @@  discard block
 block discarded – undo
1259 1259
  *
1260 1260
  * @return string
1261 1261
  */
1262
-function _give_offline_donation_enable_billing_fields_single_field_value( $field_value, $field, $postid ) {
1263
-	$offline_donation = give_get_meta( $postid, '_give_offline_donation_enable_billing_fields_single', true );
1262
+function _give_offline_donation_enable_billing_fields_single_field_value($field_value, $field, $postid) {
1263
+	$offline_donation = give_get_meta($postid, '_give_offline_donation_enable_billing_fields_single', true);
1264 1264
 
1265
-	if ( 'on' === $offline_donation ) {
1265
+	if ('on' === $offline_donation) {
1266 1266
 		$field_value = 'enabled';
1267 1267
 	}
1268 1268
 
1269 1269
 	return $field_value;
1270 1270
 }
1271 1271
 
1272
-add_filter( '_give_offline_donation_enable_billing_fields_single_field_value', '_give_offline_donation_enable_billing_fields_single_field_value', 10, 3 );
1272
+add_filter('_give_offline_donation_enable_billing_fields_single_field_value', '_give_offline_donation_enable_billing_fields_single_field_value', 10, 3);
1273 1273
 
1274 1274
 
1275 1275
 /**
@@ -1285,17 +1285,17 @@  discard block
 block discarded – undo
1285 1285
  *
1286 1286
  * @return string
1287 1287
  */
1288
-function _give_custom_amount_field_value( $field_value, $field, $postid ) {
1289
-	$custom_amount = give_get_meta( $postid, '_give_custom_amount', true );
1288
+function _give_custom_amount_field_value($field_value, $field, $postid) {
1289
+	$custom_amount = give_get_meta($postid, '_give_custom_amount', true);
1290 1290
 
1291
-	if ( in_array( $custom_amount, array( 'yes', 'no' ) ) ) {
1292
-		$field_value = ( 'yes' === $custom_amount ? 'enabled' : 'disabled' );
1291
+	if (in_array($custom_amount, array('yes', 'no'))) {
1292
+		$field_value = ('yes' === $custom_amount ? 'enabled' : 'disabled');
1293 1293
 	}
1294 1294
 
1295 1295
 	return $field_value;
1296 1296
 }
1297 1297
 
1298
-add_filter( '_give_custom_amount_field_value', '_give_custom_amount_field_value', 10, 3 );
1298
+add_filter('_give_custom_amount_field_value', '_give_custom_amount_field_value', 10, 3);
1299 1299
 
1300 1300
 
1301 1301
 /**
@@ -1311,17 +1311,17 @@  discard block
 block discarded – undo
1311 1311
  *
1312 1312
  * @return string
1313 1313
  */
1314
-function _give_goal_option_field_value( $field_value, $field, $postid ) {
1315
-	$goal_option = give_get_meta( $postid, '_give_goal_option', true );
1314
+function _give_goal_option_field_value($field_value, $field, $postid) {
1315
+	$goal_option = give_get_meta($postid, '_give_goal_option', true);
1316 1316
 
1317
-	if ( in_array( $goal_option, array( 'yes', 'no' ) ) ) {
1318
-		$field_value = ( 'yes' === $goal_option ? 'enabled' : 'disabled' );
1317
+	if (in_array($goal_option, array('yes', 'no'))) {
1318
+		$field_value = ('yes' === $goal_option ? 'enabled' : 'disabled');
1319 1319
 	}
1320 1320
 
1321 1321
 	return $field_value;
1322 1322
 }
1323 1323
 
1324
-add_filter( '_give_goal_option_field_value', '_give_goal_option_field_value', 10, 3 );
1324
+add_filter('_give_goal_option_field_value', '_give_goal_option_field_value', 10, 3);
1325 1325
 
1326 1326
 /**
1327 1327
  * Set value for Donation Goal --> close Form.
@@ -1337,17 +1337,17 @@  discard block
 block discarded – undo
1337 1337
  *
1338 1338
  * @return string
1339 1339
  */
1340
-function _give_close_form_when_goal_achieved_value( $field_value, $field, $postid ) {
1341
-	$close_form = give_get_meta( $postid, '_give_close_form_when_goal_achieved', true );
1340
+function _give_close_form_when_goal_achieved_value($field_value, $field, $postid) {
1341
+	$close_form = give_get_meta($postid, '_give_close_form_when_goal_achieved', true);
1342 1342
 
1343
-	if ( in_array( $close_form, array( 'yes', 'no' ) ) ) {
1344
-		$field_value = ( 'yes' === $close_form ? 'enabled' : 'disabled' );
1343
+	if (in_array($close_form, array('yes', 'no'))) {
1344
+		$field_value = ('yes' === $close_form ? 'enabled' : 'disabled');
1345 1345
 	}
1346 1346
 
1347 1347
 	return $field_value;
1348 1348
 }
1349 1349
 
1350
-add_filter( '_give_close_form_when_goal_achieved_field_value', '_give_close_form_when_goal_achieved_value', 10, 3 );
1350
+add_filter('_give_close_form_when_goal_achieved_field_value', '_give_close_form_when_goal_achieved_value', 10, 3);
1351 1351
 
1352 1352
 
1353 1353
 /**
@@ -1363,17 +1363,17 @@  discard block
 block discarded – undo
1363 1363
  *
1364 1364
  * @return string
1365 1365
  */
1366
-function _give_logged_in_only_value( $field_value, $field, $postid ) {
1367
-	$guest_donation = give_get_meta( $postid, '_give_logged_in_only', true );
1366
+function _give_logged_in_only_value($field_value, $field, $postid) {
1367
+	$guest_donation = give_get_meta($postid, '_give_logged_in_only', true);
1368 1368
 
1369
-	if ( in_array( $guest_donation, array( 'yes', 'no' ) ) ) {
1370
-		$field_value = ( 'yes' === $guest_donation ? 'enabled' : 'disabled' );
1369
+	if (in_array($guest_donation, array('yes', 'no'))) {
1370
+		$field_value = ('yes' === $guest_donation ? 'enabled' : 'disabled');
1371 1371
 	}
1372 1372
 
1373 1373
 	return $field_value;
1374 1374
 }
1375 1375
 
1376
-add_filter( '_give_logged_in_only_field_value', '_give_logged_in_only_value', 10, 3 );
1376
+add_filter('_give_logged_in_only_field_value', '_give_logged_in_only_value', 10, 3);
1377 1377
 
1378 1378
 /**
1379 1379
  * Set value for Offline Donations --> Offline Donations.
@@ -1389,17 +1389,17 @@  discard block
 block discarded – undo
1389 1389
  *
1390 1390
  * @return string
1391 1391
  */
1392
-function _give_customize_offline_donations_value( $field_value, $field, $postid ) {
1393
-	$customize_offline_text = give_get_meta( $postid, '_give_customize_offline_donations', true );
1392
+function _give_customize_offline_donations_value($field_value, $field, $postid) {
1393
+	$customize_offline_text = give_get_meta($postid, '_give_customize_offline_donations', true);
1394 1394
 
1395
-	if ( in_array( $customize_offline_text, array( 'yes', 'no' ) ) ) {
1396
-		$field_value = ( 'yes' === $customize_offline_text ? 'enabled' : 'disabled' );
1395
+	if (in_array($customize_offline_text, array('yes', 'no'))) {
1396
+		$field_value = ('yes' === $customize_offline_text ? 'enabled' : 'disabled');
1397 1397
 	}
1398 1398
 
1399 1399
 	return $field_value;
1400 1400
 }
1401 1401
 
1402
-add_filter( '_give_customize_offline_donations_field_value', '_give_customize_offline_donations_value', 10, 3 );
1402
+add_filter('_give_customize_offline_donations_field_value', '_give_customize_offline_donations_value', 10, 3);
1403 1403
 
1404 1404
 
1405 1405
 /**
@@ -1414,14 +1414,14 @@  discard block
 block discarded – undo
1414 1414
  *
1415 1415
  * @return mixed
1416 1416
  */
1417
-function _give_set_multi_level_repeater_field_id( $field_id, $field, $fields, $default ) {
1417
+function _give_set_multi_level_repeater_field_id($field_id, $field, $fields, $default) {
1418 1418
 	$row_placeholder = false !== $default ? $default : '{{row-count-placeholder}}';
1419 1419
 	$field_id        = "{$fields['id']}[{$row_placeholder}][{$field['id']}][level_id]";
1420 1420
 
1421 1421
 	return $field_id;
1422 1422
 }
1423 1423
 
1424
-add_filter( 'give_get_repeater_field__give_id_id', '_give_set_multi_level_repeater_field_id', 10, 4 );
1424
+add_filter('give_get_repeater_field__give_id_id', '_give_set_multi_level_repeater_field_id', 10, 4);
1425 1425
 
1426 1426
 /**
1427 1427
  * Set repeater field value for multi donation form.
@@ -1435,13 +1435,13 @@  discard block
 block discarded – undo
1435 1435
  *
1436 1436
  * @return mixed
1437 1437
  */
1438
-function _give_set_multi_level_repeater_field_value( $field_value, $field, $field_group, $fields ) {
1439
-	$field_value = $field_group[ $field['id'] ]['level_id'];
1438
+function _give_set_multi_level_repeater_field_value($field_value, $field, $field_group, $fields) {
1439
+	$field_value = $field_group[$field['id']]['level_id'];
1440 1440
 
1441 1441
 	return $field_value;
1442 1442
 }
1443 1443
 
1444
-add_filter( 'give_get_repeater_field__give_id_value', '_give_set_multi_level_repeater_field_value', 10, 4 );
1444
+add_filter('give_get_repeater_field__give_id_value', '_give_set_multi_level_repeater_field_value', 10, 4);
1445 1445
 
1446 1446
 /**
1447 1447
  * Set default value for _give_id field.
@@ -1452,11 +1452,11 @@  discard block
 block discarded – undo
1452 1452
  *
1453 1453
  * @return string
1454 1454
  */
1455
-function _give_set_field_give_id_default_value( $field ) {
1455
+function _give_set_field_give_id_default_value($field) {
1456 1456
 	return 0;
1457 1457
 }
1458 1458
 
1459
-add_filter( 'give_default_field_group_field__give_id_value', '_give_set_field_give_id_default_value' );
1459
+add_filter('give_default_field_group_field__give_id_value', '_give_set_field_give_id_default_value');
1460 1460
 
1461 1461
 /**
1462 1462
  * Set default value for _give_default field.
@@ -1467,11 +1467,11 @@  discard block
 block discarded – undo
1467 1467
  *
1468 1468
  * @return string
1469 1469
  */
1470
-function _give_set_field_give_default_default_value( $field ) {
1470
+function _give_set_field_give_default_default_value($field) {
1471 1471
 	return 'default';
1472 1472
 }
1473 1473
 
1474
-add_filter( 'give_default_field_group_field__give_default_value', '_give_set_field_give_default_default_value' );
1474
+add_filter('give_default_field_group_field__give_default_value', '_give_set_field_give_default_default_value');
1475 1475
 
1476 1476
 /**
1477 1477
  * Set repeater field editor id for field type wysiwyg.
@@ -1483,12 +1483,12 @@  discard block
 block discarded – undo
1483 1483
  *
1484 1484
  * @return string
1485 1485
  */
1486
-function give_repeater_field_set_editor_id( $field_name, $field ) {
1487
-	if ( isset( $field['repeatable_field_id'] ) && 'wysiwyg' == $field['type'] ) {
1488
-		$field_name = '_give_repeater_' . uniqid() . '_wysiwyg';
1486
+function give_repeater_field_set_editor_id($field_name, $field) {
1487
+	if (isset($field['repeatable_field_id']) && 'wysiwyg' == $field['type']) {
1488
+		$field_name = '_give_repeater_'.uniqid().'_wysiwyg';
1489 1489
 	}
1490 1490
 
1491 1491
 	return $field_name;
1492 1492
 }
1493 1493
 
1494
-add_filter( 'give_get_field_name', 'give_repeater_field_set_editor_id', 10, 2 );
1494
+add_filter('give_get_field_name', 'give_repeater_field_set_editor_id', 10, 2);
Please login to merge, or discard this patch.
includes/admin/payments/class-payments-table.php 1 patch
Spacing   +202 added lines, -202 removed lines patch added patch discarded remove patch
@@ -10,13 +10,13 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
17 17
 // Load WP_List_Table if not loaded.
18
-if ( ! class_exists( 'WP_List_Table' ) ) {
19
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
18
+if ( ! class_exists('WP_List_Table')) {
19
+	require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
20 20
 }
21 21
 
22 22
 /**
@@ -134,15 +134,15 @@  discard block
 block discarded – undo
134 134
 	public function __construct() {
135 135
 
136 136
 		// Set parent defaults.
137
-		parent::__construct( array(
138
-			'singular' => give_get_forms_label_singular(),    // Singular name of the listed records.
139
-			'plural'   => give_get_forms_label_plural(),      // Plural name of the listed records.
140
-			'ajax'     => false,                              // Does this table support ajax?
141
-		) );
137
+		parent::__construct(array(
138
+			'singular' => give_get_forms_label_singular(), // Singular name of the listed records.
139
+			'plural'   => give_get_forms_label_plural(), // Plural name of the listed records.
140
+			'ajax'     => false, // Does this table support ajax?
141
+		));
142 142
 
143 143
 		$this->process_bulk_action();
144 144
 		$this->get_payment_counts();
145
-		$this->base_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' );
145
+		$this->base_url = admin_url('edit.php?post_type=give_forms&page=give-payment-history');
146 146
 	}
147 147
 
148 148
 	/**
@@ -151,55 +151,55 @@  discard block
 block discarded – undo
151 151
 	 * @return void
152 152
 	 */
153 153
 	public function advanced_filters() {
154
-		$start_date = isset( $_GET['start-date'] ) ? sanitize_text_field( $_GET['start-date'] ) : null;
155
-		$end_date   = isset( $_GET['end-date'] ) ? sanitize_text_field( $_GET['end-date'] ) : null;
156
-		$status     = isset( $_GET['status'] ) ? sanitize_text_field( $_GET['status'] ) : '';
157
-		$donor      = isset( $_GET['donor'] ) ? sanitize_text_field( $_GET['donor'] ) : '';
158
-		$search     = isset( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : '';
159
-		$form_id    = ! empty( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : 0;
154
+		$start_date = isset($_GET['start-date']) ? sanitize_text_field($_GET['start-date']) : null;
155
+		$end_date   = isset($_GET['end-date']) ? sanitize_text_field($_GET['end-date']) : null;
156
+		$status     = isset($_GET['status']) ? sanitize_text_field($_GET['status']) : '';
157
+		$donor      = isset($_GET['donor']) ? sanitize_text_field($_GET['donor']) : '';
158
+		$search     = isset($_GET['s']) ? sanitize_text_field($_GET['s']) : '';
159
+		$form_id    = ! empty($_GET['form_id']) ? absint($_GET['form_id']) : 0;
160 160
 		?>
161 161
 		<div id="give-payment-filters" class="give-filters">
162
-			<?php $this->search_box( esc_html__( 'Search', 'give' ), 'give-payments' ); ?>
162
+			<?php $this->search_box(esc_html__('Search', 'give'), 'give-payments'); ?>
163 163
 			<div id="give-payment-date-filters">
164 164
 				<div class="give-filter give-filter-half">
165 165
 					<label for="start-date"
166
-					       class="give-start-date-label"><?php esc_html_e( 'Start Date', 'give' ); ?></label>
166
+					       class="give-start-date-label"><?php esc_html_e('Start Date', 'give'); ?></label>
167 167
 					<input type="text" id="start-date" name="start-date" class="give_datepicker"
168 168
 					       value="<?php echo $start_date; ?>" placeholder="mm/dd/yyyy" />
169 169
 				</div>
170 170
 				<div class="give-filter give-filter-half">
171
-					<label for="end-date" class="give-end-date-label"><?php esc_html_e( 'End Date', 'give' ); ?></label>
171
+					<label for="end-date" class="give-end-date-label"><?php esc_html_e('End Date', 'give'); ?></label>
172 172
 					<input type="text" id="end-date" name="end-date" class="give_datepicker"
173 173
 					       value="<?php echo $end_date; ?>" placeholder="mm/dd/yyyy" />
174 174
 				</div>
175 175
 			</div>
176 176
 			<div id="give-payment-form-filter" class="give-filter">
177 177
 				<label for="give-donation-forms-filter"
178
-				       class="give-donation-forms-filter-label"><?php esc_html_e( 'Form', 'give' ); ?></label>
178
+				       class="give-donation-forms-filter-label"><?php esc_html_e('Form', 'give'); ?></label>
179 179
 				<?php
180 180
 				// Filter Donations by Donation Forms.
181
-				echo Give()->html->forms_dropdown( array(
181
+				echo Give()->html->forms_dropdown(array(
182 182
 					'name'     => 'form_id',
183 183
 					'id'       => 'give-donation-forms-filter',
184 184
 					'class'    => 'give-donation-forms-filter',
185 185
 					'selected' => $form_id, // Make sure to have $form_id set to 0, if there is no selection.
186 186
 					'chosen'   => true,
187
-					'number'   => - 1,
188
-				) );
187
+					'number'   => -1,
188
+				));
189 189
 				?>
190 190
 			</div>
191 191
 
192
-			<?php if ( ! empty( $status ) ) : ?>
193
-				<input type="hidden" name="status" value="<?php echo esc_attr( $status ); ?>" />
192
+			<?php if ( ! empty($status)) : ?>
193
+				<input type="hidden" name="status" value="<?php echo esc_attr($status); ?>" />
194 194
 			<?php endif; ?>
195 195
 
196 196
 			<div class="give-filter">
197
-				<?php submit_button( __( 'Apply', 'give' ), 'secondary', '', false ); ?>
197
+				<?php submit_button(__('Apply', 'give'), 'secondary', '', false); ?>
198 198
 				<?php
199 199
 				// Clear active filters button.
200
-				if ( ! empty( $start_date ) || ! empty( $end_date ) || ! empty( $donor ) || ! empty( $search ) || ! empty( $status ) || ! empty( $form_id ) ) : ?>
201
-					<a href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); ?>"
202
-					   class="button give-clear-filters-button"><?php esc_html_e( 'Clear Filters', 'give' ); ?></a>
200
+				if ( ! empty($start_date) || ! empty($end_date) || ! empty($donor) || ! empty($search) || ! empty($status) || ! empty($form_id)) : ?>
201
+					<a href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history'); ?>"
202
+					   class="button give-clear-filters-button"><?php esc_html_e('Clear Filters', 'give'); ?></a>
203 203
 				<?php endif; ?>
204 204
 			</div>
205 205
 		</div>
@@ -218,18 +218,18 @@  discard block
 block discarded – undo
218 218
 	 *
219 219
 	 * @return void
220 220
 	 */
221
-	public function search_box( $text, $input_id ) {
222
-		if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) {
221
+	public function search_box($text, $input_id) {
222
+		if (empty($_REQUEST['s']) && ! $this->has_items()) {
223 223
 			return;
224 224
 		}
225 225
 
226
-		$input_id = $input_id . '-search-input';
226
+		$input_id = $input_id.'-search-input';
227 227
 
228
-		if ( ! empty( $_REQUEST['orderby'] ) ) {
229
-			echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
228
+		if ( ! empty($_REQUEST['orderby'])) {
229
+			echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />';
230 230
 		}
231
-		if ( ! empty( $_REQUEST['order'] ) ) {
232
-			echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
231
+		if ( ! empty($_REQUEST['order'])) {
232
+			echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />';
233 233
 		}
234 234
 		?>
235 235
 		<div class="give-filter give-filter-search" role="search">
@@ -241,13 +241,13 @@  discard block
 block discarded – undo
241 241
 			 *
242 242
 			 * @since 1.7
243 243
 			 */
244
-			do_action( 'give_payment_history_search' );
244
+			do_action('give_payment_history_search');
245 245
 			?>
246 246
 			<label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label>
247 247
 			<input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" />
248
-			<?php submit_button( $text, 'button', false, false, array(
248
+			<?php submit_button($text, 'button', false, false, array(
249 249
 				'ID' => 'search-submit',
250
-			) ); ?><br />
250
+			)); ?><br />
251 251
 		</div>
252 252
 		<?php
253 253
 	}
@@ -261,52 +261,52 @@  discard block
 block discarded – undo
261 261
 	 */
262 262
 	public function get_views() {
263 263
 
264
-		$current = isset( $_GET['status'] ) ? $_GET['status'] : '';
264
+		$current = isset($_GET['status']) ? $_GET['status'] : '';
265 265
 		$views   = array();
266 266
 		$tabs    = array(
267 267
 			'all'        => array(
268 268
 				'total_count',
269
-				esc_html__( 'All', 'give' ),
269
+				esc_html__('All', 'give'),
270 270
 			),
271 271
 			'publish'    => array(
272 272
 				'complete_count',
273
-				esc_html__( 'Completed', 'give' ),
273
+				esc_html__('Completed', 'give'),
274 274
 			),
275 275
 			'pending'    => array(
276 276
 				'pending_count',
277
-				esc_html__( 'Pending', 'give' ),
277
+				esc_html__('Pending', 'give'),
278 278
 			),
279 279
 			'processing' => array(
280 280
 				'processing_count',
281
-				esc_html__( 'Processing', 'give' ),
281
+				esc_html__('Processing', 'give'),
282 282
 			),
283 283
 			'refunded'   => array(
284 284
 				'refunded_count',
285
-				esc_html__( 'Refunded', 'give' ),
285
+				esc_html__('Refunded', 'give'),
286 286
 			),
287 287
 			'revoked'    => array(
288 288
 				'revoked_count',
289
-				esc_html__( 'Revoked', 'give' ),
289
+				esc_html__('Revoked', 'give'),
290 290
 			),
291 291
 			'failed'     => array(
292 292
 				'failed_count',
293
-				esc_html__( 'Failed', 'give' ),
293
+				esc_html__('Failed', 'give'),
294 294
 			),
295 295
 			'cancelled'  => array(
296 296
 				'cancelled_count',
297
-				esc_html__( 'Cancelled', 'give' ),
297
+				esc_html__('Cancelled', 'give'),
298 298
 			),
299 299
 			'abandoned'  => array(
300 300
 				'abandoned_count',
301
-				esc_html__( 'Abandoned', 'give' ),
301
+				esc_html__('Abandoned', 'give'),
302 302
 			),
303 303
 			'preapproval'  => array(
304 304
 				'preapproval_count',
305
-				esc_html__( 'Preapproval Pending', 'give' ),
305
+				esc_html__('Preapproval Pending', 'give'),
306 306
 			),
307 307
 		);
308 308
 
309
-		foreach ( $tabs as $key => $tab ) {
309
+		foreach ($tabs as $key => $tab) {
310 310
 			$count_key = $tab[0];
311 311
 			$name      = $tab[1];
312 312
 			$count     = $this->$count_key;
@@ -321,19 +321,19 @@  discard block
 block discarded – undo
321 321
 			 * @param string $key   Current view tab value.
322 322
 			 * @param int    $count Number of donation inside the tab.
323 323
 			 */
324
-			if ( 'all' === $key || $key === $current || apply_filters( 'give_payments_table_show_all_status', 0 < $count, $key, $count ) ) {
324
+			if ('all' === $key || $key === $current || apply_filters('give_payments_table_show_all_status', 0 < $count, $key, $count)) {
325 325
 
326
-				$views[ $key ] = sprintf(
326
+				$views[$key] = sprintf(
327 327
 					'<a href="%s" %s >%s&nbsp;<span class="count">(%s)</span></a>',
328
-					esc_url( ( 'all' === (string) $key ) ? remove_query_arg( array( 'status', 'paged' ) ) : add_query_arg( array( 'status' => $key, 'paged' => false ) ) ),
329
-					( ( 'all' === $key && empty( $current ) ) ) ? 'class="current"' : ( $current == $key ) ? 'class="current"' : '',
328
+					esc_url(('all' === (string) $key) ? remove_query_arg(array('status', 'paged')) : add_query_arg(array('status' => $key, 'paged' => false))),
329
+					(('all' === $key && empty($current))) ? 'class="current"' : ($current == $key) ? 'class="current"' : '',
330 330
 					$name,
331 331
 					$count
332 332
 				);
333 333
 			}
334 334
 		}
335 335
 
336
-		return apply_filters( 'give_payments_table_views', $views );
336
+		return apply_filters('give_payments_table_views', $views);
337 337
 	}
338 338
 
339 339
 	/**
@@ -346,15 +346,15 @@  discard block
 block discarded – undo
346 346
 	public function get_columns() {
347 347
 		$columns = array(
348 348
 			'cb'            => '<input type="checkbox" />', // Render a checkbox instead of text.
349
-			'donation'      => esc_html__( 'Donation', 'give' ),
350
-			'donation_form' => esc_html__( 'Donation Form', 'give' ),
351
-			'status'        => esc_html__( 'Status', 'give' ),
352
-			'date'          => esc_html__( 'Date', 'give' ),
353
-			'amount'        => esc_html__( 'Amount', 'give' ),
354
-			'details'       => esc_html__( 'Details', 'give' ),
349
+			'donation'      => esc_html__('Donation', 'give'),
350
+			'donation_form' => esc_html__('Donation Form', 'give'),
351
+			'status'        => esc_html__('Status', 'give'),
352
+			'date'          => esc_html__('Date', 'give'),
353
+			'amount'        => esc_html__('Amount', 'give'),
354
+			'details'       => esc_html__('Details', 'give'),
355 355
 		);
356 356
 
357
-		return apply_filters( 'give_payments_table_columns', $columns );
357
+		return apply_filters('give_payments_table_columns', $columns);
358 358
 	}
359 359
 
360 360
 	/**
@@ -366,14 +366,14 @@  discard block
 block discarded – undo
366 366
 	 */
367 367
 	public function get_sortable_columns() {
368 368
 		$columns = array(
369
-			'donation'      => array( 'ID', true ),
370
-			'donation_form' => array( 'donation_form', false ),
371
-			'status'        => array( 'status', false ),
372
-			'amount'        => array( 'amount', false ),
373
-			'date'          => array( 'date', false ),
369
+			'donation'      => array('ID', true),
370
+			'donation_form' => array('donation_form', false),
371
+			'status'        => array('status', false),
372
+			'amount'        => array('amount', false),
373
+			'date'          => array('date', false),
374 374
 		);
375 375
 
376
-		return apply_filters( 'give_payments_table_sortable_columns', $columns );
376
+		return apply_filters('give_payments_table_sortable_columns', $columns);
377 377
 	}
378 378
 
379 379
 	/**
@@ -399,55 +399,55 @@  discard block
 block discarded – undo
399 399
 	 *
400 400
 	 * @return string Column Name
401 401
 	 */
402
-	public function column_default( $payment, $column_name ) {
402
+	public function column_default($payment, $column_name) {
403 403
 
404
-		$single_donation_url = esc_url( add_query_arg( 'id', $payment->ID, admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details' ) ) );
405
-		$row_actions         = $this->get_row_actions( $payment );
404
+		$single_donation_url = esc_url(add_query_arg('id', $payment->ID, admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details')));
405
+		$row_actions         = $this->get_row_actions($payment);
406 406
 
407
-		switch ( $column_name ) {
407
+		switch ($column_name) {
408 408
 			case 'donation' :
409
-				$value = sprintf( '<a href="%1$s" data-tooltip="%2$s">#%3$s</a>&nbsp;%4$s&nbsp;%5$s<br>', $single_donation_url, sprintf( esc_attr__( 'View Donation #%s', 'give' ), $payment->ID ), $payment->ID, esc_html__( 'by', 'give' ), $this->get_donor( $payment ) );
410
-				$value .= $this->get_donor_email( $payment );
411
-				$value .= $this->row_actions( $row_actions );
409
+				$value = sprintf('<a href="%1$s" data-tooltip="%2$s">#%3$s</a>&nbsp;%4$s&nbsp;%5$s<br>', $single_donation_url, sprintf(esc_attr__('View Donation #%s', 'give'), $payment->ID), $payment->ID, esc_html__('by', 'give'), $this->get_donor($payment));
410
+				$value .= $this->get_donor_email($payment);
411
+				$value .= $this->row_actions($row_actions);
412 412
 				break;
413 413
 
414 414
 			case 'amount' :
415
-				$amount = ! empty( $payment->total ) ? $payment->total : 0;
416
-				$value  = give_currency_filter( give_format_amount( $amount, array( 'sanitize' => false ) ), give_get_payment_currency_code( $payment->ID ) );
417
-				$value  .= sprintf( '<br><small>%1$s %2$s</small>', __( 'via', 'give' ), give_get_gateway_admin_label( $payment->gateway ) );
415
+				$amount = ! empty($payment->total) ? $payment->total : 0;
416
+				$value  = give_currency_filter(give_format_amount($amount, array('sanitize' => false)), give_get_payment_currency_code($payment->ID));
417
+				$value .= sprintf('<br><small>%1$s %2$s</small>', __('via', 'give'), give_get_gateway_admin_label($payment->gateway));
418 418
 				break;
419 419
 
420 420
 			case 'donation_form' :
421
-				$form_title = empty( $payment->form_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $payment->form_id ) : $payment->form_title;
422
-				$value      = '<a href="' . admin_url( 'post.php?post=' . $payment->form_id . '&action=edit' ) . '">' . $form_title . '</a>';
423
-				$level      = give_get_payment_form_title( $payment->meta, true );
421
+				$form_title = empty($payment->form_title) ? sprintf(__('Untitled (#%s)', 'give'), $payment->form_id) : $payment->form_title;
422
+				$value      = '<a href="'.admin_url('post.php?post='.$payment->form_id.'&action=edit').'">'.$form_title.'</a>';
423
+				$level      = give_get_payment_form_title($payment->meta, true);
424 424
 
425
-				if ( ! empty( $level ) ) {
425
+				if ( ! empty($level)) {
426 426
 					$value .= $level;
427 427
 				}
428 428
 
429 429
 				break;
430 430
 
431 431
 			case 'date' :
432
-				$date  = strtotime( $payment->date );
433
-				$value = date_i18n( give_date_format(), $date );
432
+				$date  = strtotime($payment->date);
433
+				$value = date_i18n(give_date_format(), $date);
434 434
 				break;
435 435
 
436 436
 			case 'status' :
437
-				$value = $this->get_payment_status( $payment );
437
+				$value = $this->get_payment_status($payment);
438 438
 				break;
439 439
 
440 440
 			case 'details' :
441
-				$value = sprintf( '<div class="give-payment-details-link-wrap"><a href="%1$s" class="give-payment-details-link button button-small" data-tooltip="%2$s" aria-label="%2$s"><span class="dashicons dashicons-visibility"></span></a></div>', $single_donation_url, sprintf( esc_attr__( 'View Donation #%s', 'give' ), $payment->ID ) );
441
+				$value = sprintf('<div class="give-payment-details-link-wrap"><a href="%1$s" class="give-payment-details-link button button-small" data-tooltip="%2$s" aria-label="%2$s"><span class="dashicons dashicons-visibility"></span></a></div>', $single_donation_url, sprintf(esc_attr__('View Donation #%s', 'give'), $payment->ID));
442 442
 				break;
443 443
 
444 444
 			default:
445
-				$value = isset( $payment->$column_name ) ? $payment->$column_name : '';
445
+				$value = isset($payment->$column_name) ? $payment->$column_name : '';
446 446
 				break;
447 447
 
448 448
 		}// End switch().
449 449
 
450
-		return apply_filters( 'give_payments_table_column', $value, $payment->ID, $column_name );
450
+		return apply_filters('give_payments_table_column', $value, $payment->ID, $column_name);
451 451
 	}
452 452
 
453 453
 	/**
@@ -460,17 +460,17 @@  discard block
 block discarded – undo
460 460
 	 *
461 461
 	 * @return string                Data shown in the Email column
462 462
 	 */
463
-	public function get_donor_email( $payment ) {
463
+	public function get_donor_email($payment) {
464 464
 
465
-		$email = give_get_payment_user_email( $payment->ID );
465
+		$email = give_get_payment_user_email($payment->ID);
466 466
 
467
-		if ( empty( $email ) ) {
468
-			$email = esc_html__( '(unknown)', 'give' );
467
+		if (empty($email)) {
468
+			$email = esc_html__('(unknown)', 'give');
469 469
 		}
470 470
 
471
-		$value = '<a href="mailto:' . $email . '" data-tooltip="' . esc_attr__( 'Email donor', 'give' ) . '">' . $email . '</a>';
471
+		$value = '<a href="mailto:'.$email.'" data-tooltip="'.esc_attr__('Email donor', 'give').'">'.$email.'</a>';
472 472
 
473
-		return apply_filters( 'give_payments_table_column', $value, $payment->ID, 'email' );
473
+		return apply_filters('give_payments_table_column', $value, $payment->ID, 'email');
474 474
 	}
475 475
 
476 476
 	/**
@@ -482,32 +482,32 @@  discard block
 block discarded – undo
482 482
 	 *
483 483
 	 * @return array $actions
484 484
 	 */
485
-	function get_row_actions( $payment ) {
485
+	function get_row_actions($payment) {
486 486
 
487 487
 		$actions = array();
488
-		$email   = give_get_payment_user_email( $payment->ID );
488
+		$email   = give_get_payment_user_email($payment->ID);
489 489
 
490 490
 		// Add search term string back to base URL.
491
-		$search_terms = ( isset( $_GET['s'] ) ? trim( $_GET['s'] ) : '' );
492
-		if ( ! empty( $search_terms ) ) {
493
-			$this->base_url = add_query_arg( 's', $search_terms, $this->base_url );
491
+		$search_terms = (isset($_GET['s']) ? trim($_GET['s']) : '');
492
+		if ( ! empty($search_terms)) {
493
+			$this->base_url = add_query_arg('s', $search_terms, $this->base_url);
494 494
 		}
495 495
 
496
-		if ( give_is_payment_complete( $payment->ID ) && ! empty( $email ) ) {
496
+		if (give_is_payment_complete($payment->ID) && ! empty($email)) {
497 497
 
498
-			$actions['email_links'] = sprintf( '<a class="resend-single-donation-receipt" href="%1$s" aria-label="%2$s">%3$s</a>', wp_nonce_url( add_query_arg( array(
498
+			$actions['email_links'] = sprintf('<a class="resend-single-donation-receipt" href="%1$s" aria-label="%2$s">%3$s</a>', wp_nonce_url(add_query_arg(array(
499 499
 				'give-action' => 'email_links',
500 500
 				'purchase_id' => $payment->ID,
501
-			), $this->base_url ), 'give_payment_nonce' ), sprintf( esc_attr__( 'Resend Donation %s Receipt', 'give' ), $payment->ID ), esc_html__( 'Resend Receipt', 'give' ) );
501
+			), $this->base_url), 'give_payment_nonce'), sprintf(esc_attr__('Resend Donation %s Receipt', 'give'), $payment->ID), esc_html__('Resend Receipt', 'give'));
502 502
 
503 503
 		}
504 504
 
505
-		$actions['delete'] = sprintf( '<a class="delete-single-donation" href="%1$s" aria-label="%2$s">%3$s</a>', wp_nonce_url( add_query_arg( array(
505
+		$actions['delete'] = sprintf('<a class="delete-single-donation" href="%1$s" aria-label="%2$s">%3$s</a>', wp_nonce_url(add_query_arg(array(
506 506
 			'give-action' => 'delete_payment',
507 507
 			'purchase_id' => $payment->ID,
508
-		), $this->base_url ), 'give_donation_nonce' ), sprintf( esc_attr__( 'Delete Donation %s', 'give' ), $payment->ID ), esc_html__( 'Delete', 'give' ) );
508
+		), $this->base_url), 'give_donation_nonce'), sprintf(esc_attr__('Delete Donation %s', 'give'), $payment->ID), esc_html__('Delete', 'give'));
509 509
 
510
-		return apply_filters( 'give_payment_row_actions', $actions, $payment );
510
+		return apply_filters('give_payment_row_actions', $actions, $payment);
511 511
 	}
512 512
 
513 513
 
@@ -521,14 +521,14 @@  discard block
 block discarded – undo
521 521
 	 *
522 522
 	 * @return string                Data shown in the Email column
523 523
 	 */
524
-	function get_payment_status( $payment ) {
525
-		$value = '<div class="give-donation-status status-' . sanitize_title( give_get_payment_status( $payment, true ) ) . '"><span class="give-donation-status-icon"></span> ' . give_get_payment_status( $payment, true ) . '</div>';
526
-		if ( $payment->mode == 'test' ) {
527
-			$value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="' . esc_attr__( 'This donation was made in test mode.', 'give' ) . '">' . esc_html__( 'Test', 'give' ) . '</span>';
524
+	function get_payment_status($payment) {
525
+		$value = '<div class="give-donation-status status-'.sanitize_title(give_get_payment_status($payment, true)).'"><span class="give-donation-status-icon"></span> '.give_get_payment_status($payment, true).'</div>';
526
+		if ($payment->mode == 'test') {
527
+			$value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="'.esc_attr__('This donation was made in test mode.', 'give').'">'.esc_html__('Test', 'give').'</span>';
528 528
 		}
529 529
 
530
-		if ( true === $payment->import && true === (bool) apply_filters( 'give_payment_show_importer_label', false ) ) {
531
-			$value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="' . esc_attr__( 'This donation was imported.', 'give' ) . '">' . esc_html__( 'Import', 'give' ) . '</span>';
530
+		if (true === $payment->import && true === (bool) apply_filters('give_payment_show_importer_label', false)) {
531
+			$value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="'.esc_attr__('This donation was imported.', 'give').'">'.esc_html__('Import', 'give').'</span>';
532 532
 		}
533 533
 
534 534
 		return $value;
@@ -544,8 +544,8 @@  discard block
 block discarded – undo
544 544
 	 *
545 545
 	 * @return string Displays a checkbox.
546 546
 	 */
547
-	public function column_cb( $payment ) {
548
-		return sprintf( '<input type="checkbox" name="%1$s[]" value="%2$s" />', 'payment', $payment->ID );
547
+	public function column_cb($payment) {
548
+		return sprintf('<input type="checkbox" name="%1$s[]" value="%2$s" />', 'payment', $payment->ID);
549 549
 	}
550 550
 
551 551
 	/**
@@ -558,8 +558,8 @@  discard block
 block discarded – undo
558 558
 	 *
559 559
 	 * @return string Displays a checkbox.
560 560
 	 */
561
-	public function get_payment_id( $payment ) {
562
-		return '<span class="give-payment-id">' . give_get_payment_number( $payment->ID ) . '</span>';
561
+	public function get_payment_id($payment) {
562
+		return '<span class="give-payment-id">'.give_get_payment_number($payment->ID).'</span>';
563 563
 	}
564 564
 
565 565
 	/**
@@ -572,32 +572,32 @@  discard block
 block discarded – undo
572 572
 	 *
573 573
 	 * @return string Data shown in the User column
574 574
 	 */
575
-	public function get_donor( $payment ) {
575
+	public function get_donor($payment) {
576 576
 
577
-		$donor_id           = give_get_payment_donor_id( $payment->ID );
578
-		$donor_billing_name = give_get_donor_name_by( $payment->ID, 'donation' );
579
-		$donor_name         = give_get_donor_name_by( $donor_id, 'donor' );
577
+		$donor_id           = give_get_payment_donor_id($payment->ID);
578
+		$donor_billing_name = give_get_donor_name_by($payment->ID, 'donation');
579
+		$donor_name         = give_get_donor_name_by($donor_id, 'donor');
580 580
 
581 581
 		$value = '';
582
-		if ( ! empty( $donor_id ) ) {
582
+		if ( ! empty($donor_id)) {
583 583
 
584 584
 			// Check whether the donor name and WP_User name is same or not.
585
-			if ( sanitize_title( $donor_billing_name ) != sanitize_title( $donor_name ) ) {
586
-				$value .= $donor_billing_name . ' (';
585
+			if (sanitize_title($donor_billing_name) != sanitize_title($donor_name)) {
586
+				$value .= $donor_billing_name.' (';
587 587
 			}
588 588
 
589
-			$value .= '<a href="' . esc_url( admin_url( "edit.php?post_type=give_forms&page=give-donors&view=overview&id=$donor_id" ) ) . '">' . $donor_name . '</a>';
589
+			$value .= '<a href="'.esc_url(admin_url("edit.php?post_type=give_forms&page=give-donors&view=overview&id=$donor_id")).'">'.$donor_name.'</a>';
590 590
 
591 591
 			// Check whether the donor name and WP_User name is same or not.
592
-			if ( sanitize_title( $donor_billing_name ) != sanitize_title( $donor_name ) ) {
592
+			if (sanitize_title($donor_billing_name) != sanitize_title($donor_name)) {
593 593
 				$value .= ')';
594 594
 			}
595 595
 		} else {
596
-			$email = give_get_payment_user_email( $payment->ID );
597
-			$value .= '<a href="' . esc_url( admin_url( "edit.php?post_type=give_forms&page=give-payment-history&s=$email" ) ) . '">' . esc_html__( '(donor missing)', 'give' ) . '</a>';
596
+			$email = give_get_payment_user_email($payment->ID);
597
+			$value .= '<a href="'.esc_url(admin_url("edit.php?post_type=give_forms&page=give-payment-history&s=$email")).'">'.esc_html__('(donor missing)', 'give').'</a>';
598 598
 		}
599 599
 
600
-		return apply_filters( 'give_payments_table_column', $value, $payment->ID, 'donor' );
600
+		return apply_filters('give_payments_table_column', $value, $payment->ID, 'donor');
601 601
 	}
602 602
 
603 603
 	/**
@@ -609,20 +609,20 @@  discard block
 block discarded – undo
609 609
 	 */
610 610
 	public function get_bulk_actions() {
611 611
 		$actions = array(
612
-			'delete'                 => __( 'Delete', 'give' ),
613
-			'set-status-publish'     => __( 'Set To Completed', 'give' ),
614
-			'set-status-pending'     => __( 'Set To Pending', 'give' ),
615
-			'set-status-processing'  => __( 'Set To Processing', 'give' ),
616
-			'set-status-refunded'    => __( 'Set To Refunded', 'give' ),
617
-			'set-status-revoked'     => __( 'Set To Revoked', 'give' ),
618
-			'set-status-failed'      => __( 'Set To Failed', 'give' ),
619
-			'set-status-cancelled'   => __( 'Set To Cancelled', 'give' ),
620
-			'set-status-abandoned'   => __( 'Set To Abandoned', 'give' ),
621
-			'set-status-preapproval' => __( 'Set To Preapproval', 'give' ),
622
-			'resend-receipt'         => __( 'Resend Email Receipts', 'give' ),
612
+			'delete'                 => __('Delete', 'give'),
613
+			'set-status-publish'     => __('Set To Completed', 'give'),
614
+			'set-status-pending'     => __('Set To Pending', 'give'),
615
+			'set-status-processing'  => __('Set To Processing', 'give'),
616
+			'set-status-refunded'    => __('Set To Refunded', 'give'),
617
+			'set-status-revoked'     => __('Set To Revoked', 'give'),
618
+			'set-status-failed'      => __('Set To Failed', 'give'),
619
+			'set-status-cancelled'   => __('Set To Cancelled', 'give'),
620
+			'set-status-abandoned'   => __('Set To Abandoned', 'give'),
621
+			'set-status-preapproval' => __('Set To Preapproval', 'give'),
622
+			'resend-receipt'         => __('Resend Email Receipts', 'give'),
623 623
 		);
624 624
 
625
-		return apply_filters( 'give_payments_table_bulk_actions', $actions );
625
+		return apply_filters('give_payments_table_bulk_actions', $actions);
626 626
 	}
627 627
 
628 628
 	/**
@@ -633,63 +633,63 @@  discard block
 block discarded – undo
633 633
 	 * @return void
634 634
 	 */
635 635
 	public function process_bulk_action() {
636
-		$ids    = isset( $_GET['payment'] ) ? $_GET['payment'] : false;
636
+		$ids    = isset($_GET['payment']) ? $_GET['payment'] : false;
637 637
 		$action = $this->current_action();
638 638
 
639
-		if ( ! is_array( $ids ) ) {
640
-			$ids = array( $ids );
639
+		if ( ! is_array($ids)) {
640
+			$ids = array($ids);
641 641
 		}
642 642
 
643
-		if ( empty( $action ) ) {
643
+		if (empty($action)) {
644 644
 			return;
645 645
 		}
646 646
 
647
-		foreach ( $ids as $id ) {
647
+		foreach ($ids as $id) {
648 648
 
649 649
 			// Detect when a bulk action is being triggered.
650
-			switch ( $this->current_action() ) {
650
+			switch ($this->current_action()) {
651 651
 
652 652
 				case'delete':
653
-					give_delete_donation( $id );
653
+					give_delete_donation($id);
654 654
 					break;
655 655
 
656 656
 				case 'set-status-publish':
657
-					give_update_payment_status( $id, 'publish' );
657
+					give_update_payment_status($id, 'publish');
658 658
 					break;
659 659
 
660 660
 				case 'set-status-pending':
661
-					give_update_payment_status( $id, 'pending' );
661
+					give_update_payment_status($id, 'pending');
662 662
 					break;
663 663
 
664 664
 				case 'set-status-processing':
665
-					give_update_payment_status( $id, 'processing' );
665
+					give_update_payment_status($id, 'processing');
666 666
 					break;
667 667
 
668 668
 				case 'set-status-refunded':
669
-					give_update_payment_status( $id, 'refunded' );
669
+					give_update_payment_status($id, 'refunded');
670 670
 					break;
671 671
 				case 'set-status-revoked':
672
-					give_update_payment_status( $id, 'revoked' );
672
+					give_update_payment_status($id, 'revoked');
673 673
 					break;
674 674
 
675 675
 				case 'set-status-failed':
676
-					give_update_payment_status( $id, 'failed' );
676
+					give_update_payment_status($id, 'failed');
677 677
 					break;
678 678
 
679 679
 				case 'set-status-cancelled':
680
-					give_update_payment_status( $id, 'cancelled' );
680
+					give_update_payment_status($id, 'cancelled');
681 681
 					break;
682 682
 
683 683
 				case 'set-status-abandoned':
684
-					give_update_payment_status( $id, 'abandoned' );
684
+					give_update_payment_status($id, 'abandoned');
685 685
 					break;
686 686
 
687 687
 				case 'set-status-preapproval':
688
-					give_update_payment_status( $id, 'preapproval' );
688
+					give_update_payment_status($id, 'preapproval');
689 689
 					break;
690 690
 
691 691
 				case 'resend-receipt':
692
-					give_email_donation_receipt( $id, false );
692
+					give_email_donation_receipt($id, false);
693 693
 					break;
694 694
 			}// End switch().
695 695
 
@@ -701,7 +701,7 @@  discard block
 block discarded – undo
701 701
 			 * @param int    $id             The ID of the payment.
702 702
 			 * @param string $current_action The action that is being triggered.
703 703
 			 */
704
-			do_action( 'give_payments_table_do_bulk_action', $id, $this->current_action() );
704
+			do_action('give_payments_table_do_bulk_action', $id, $this->current_action());
705 705
 		}// End foreach().
706 706
 
707 707
 	}
@@ -717,31 +717,31 @@  discard block
 block discarded – undo
717 717
 
718 718
 		$args = array();
719 719
 
720
-		if ( isset( $_GET['user'] ) ) {
721
-			$args['user'] = urldecode( $_GET['user'] );
722
-		} elseif ( isset( $_GET['donor'] ) ) {
723
-			$args['donor'] = absint( $_GET['donor'] );
724
-		} elseif ( isset( $_GET['s'] ) ) {
725
-			$is_user = strpos( $_GET['s'], strtolower( 'user:' ) ) !== false;
726
-			if ( $is_user ) {
727
-				$args['user'] = absint( trim( str_replace( 'user:', '', strtolower( $_GET['s'] ) ) ) );
728
-				unset( $args['s'] );
720
+		if (isset($_GET['user'])) {
721
+			$args['user'] = urldecode($_GET['user']);
722
+		} elseif (isset($_GET['donor'])) {
723
+			$args['donor'] = absint($_GET['donor']);
724
+		} elseif (isset($_GET['s'])) {
725
+			$is_user = strpos($_GET['s'], strtolower('user:')) !== false;
726
+			if ($is_user) {
727
+				$args['user'] = absint(trim(str_replace('user:', '', strtolower($_GET['s']))));
728
+				unset($args['s']);
729 729
 			} else {
730
-				$args['s'] = sanitize_text_field( $_GET['s'] );
730
+				$args['s'] = sanitize_text_field($_GET['s']);
731 731
 			}
732 732
 		}
733 733
 
734
-		if ( ! empty( $_GET['start-date'] ) ) {
735
-			$args['start-date'] = urldecode( $_GET['start-date'] );
734
+		if ( ! empty($_GET['start-date'])) {
735
+			$args['start-date'] = urldecode($_GET['start-date']);
736 736
 		}
737 737
 
738
-		if ( ! empty( $_GET['end-date'] ) ) {
739
-			$args['end-date'] = urldecode( $_GET['end-date'] );
738
+		if ( ! empty($_GET['end-date'])) {
739
+			$args['end-date'] = urldecode($_GET['end-date']);
740 740
 		}
741 741
 
742
-		$args['form_id'] = ! empty( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : null;
742
+		$args['form_id'] = ! empty($_GET['form_id']) ? absint($_GET['form_id']) : null;
743 743
 
744
-		$payment_count           = give_count_payments( $args );
744
+		$payment_count           = give_count_payments($args);
745 745
 		$this->complete_count    = $payment_count->publish;
746 746
 		$this->pending_count     = $payment_count->pending;
747 747
 		$this->processing_count  = $payment_count->processing;
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
 		$this->abandoned_count   = $payment_count->abandoned;
753 753
 		$this->preapproval_count = $payment_count->preapproval;
754 754
 
755
-		foreach ( $payment_count as $count ) {
755
+		foreach ($payment_count as $count) {
756 756
 			$this->total_count += $count;
757 757
 		}
758 758
 	}
@@ -767,28 +767,28 @@  discard block
 block discarded – undo
767 767
 	public function payments_data() {
768 768
 
769 769
 		$per_page   = $this->per_page;
770
-		$orderby    = isset( $_GET['orderby'] ) ? urldecode( $_GET['orderby'] ) : 'ID';
771
-		$order      = isset( $_GET['order'] ) ? $_GET['order'] : 'DESC';
772
-		$user       = isset( $_GET['user'] ) ? $_GET['user'] : null;
773
-		$donor      = isset( $_GET['donor'] ) ? $_GET['donor'] : null;
774
-		$status     = isset( $_GET['status'] ) ? $_GET['status'] : give_get_payment_status_keys();
775
-		$meta_key   = isset( $_GET['meta_key'] ) ? $_GET['meta_key'] : null;
776
-		$year       = isset( $_GET['year'] ) ? $_GET['year'] : null;
777
-		$month      = isset( $_GET['m'] ) ? $_GET['m'] : null;
778
-		$day        = isset( $_GET['day'] ) ? $_GET['day'] : null;
779
-		$search     = isset( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : null;
780
-		$start_date = isset( $_GET['start-date'] ) ? sanitize_text_field( $_GET['start-date'] ) : null;
781
-		$end_date   = isset( $_GET['end-date'] ) ? sanitize_text_field( $_GET['end-date'] ) : $start_date;
782
-		$form_id    = ! empty( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : null;
783
-
784
-		if ( ! empty( $search ) ) {
770
+		$orderby    = isset($_GET['orderby']) ? urldecode($_GET['orderby']) : 'ID';
771
+		$order      = isset($_GET['order']) ? $_GET['order'] : 'DESC';
772
+		$user       = isset($_GET['user']) ? $_GET['user'] : null;
773
+		$donor      = isset($_GET['donor']) ? $_GET['donor'] : null;
774
+		$status     = isset($_GET['status']) ? $_GET['status'] : give_get_payment_status_keys();
775
+		$meta_key   = isset($_GET['meta_key']) ? $_GET['meta_key'] : null;
776
+		$year       = isset($_GET['year']) ? $_GET['year'] : null;
777
+		$month      = isset($_GET['m']) ? $_GET['m'] : null;
778
+		$day        = isset($_GET['day']) ? $_GET['day'] : null;
779
+		$search     = isset($_GET['s']) ? sanitize_text_field($_GET['s']) : null;
780
+		$start_date = isset($_GET['start-date']) ? sanitize_text_field($_GET['start-date']) : null;
781
+		$end_date   = isset($_GET['end-date']) ? sanitize_text_field($_GET['end-date']) : $start_date;
782
+		$form_id    = ! empty($_GET['form_id']) ? absint($_GET['form_id']) : null;
783
+
784
+		if ( ! empty($search)) {
785 785
 			$status = 'any'; // Force all payment statuses when searching.
786 786
 		}
787 787
 
788 788
 		$args = array(
789 789
 			'output'     => 'payments',
790 790
 			'number'     => $per_page,
791
-			'page'       => isset( $_GET['paged'] ) ? $_GET['paged'] : null,
791
+			'page'       => isset($_GET['paged']) ? $_GET['paged'] : null,
792 792
 			'orderby'    => $orderby,
793 793
 			'order'      => $order,
794 794
 			'user'       => $user,
@@ -804,12 +804,12 @@  discard block
 block discarded – undo
804 804
 			'give_forms' => $form_id,
805 805
 		);
806 806
 
807
-		if ( is_string( $search ) && false !== strpos( $search, 'txn:' ) ) {
807
+		if (is_string($search) && false !== strpos($search, 'txn:')) {
808 808
 			$args['search_in_notes'] = true;
809
-			$args['s']               = trim( str_replace( 'txn:', '', $args['s'] ) );
809
+			$args['s']               = trim(str_replace('txn:', '', $args['s']));
810 810
 		}
811 811
 
812
-		$p_query = new Give_Payments_Query( $args );
812
+		$p_query = new Give_Payments_Query($args);
813 813
 
814 814
 		return $p_query->get_payments();
815 815
 
@@ -829,17 +829,17 @@  discard block
 block discarded – undo
829 829
 	 */
830 830
 	public function prepare_items() {
831 831
 
832
-		wp_reset_vars( array( 'action', 'payment', 'orderby', 'order', 's' ) );
832
+		wp_reset_vars(array('action', 'payment', 'orderby', 'order', 's'));
833 833
 
834 834
 		$columns  = $this->get_columns();
835 835
 		$hidden   = array(); // No hidden columns.
836 836
 		$sortable = $this->get_sortable_columns();
837 837
 		$data     = $this->payments_data();
838
-		$status   = isset( $_GET['status'] ) ? $_GET['status'] : 'any';
838
+		$status   = isset($_GET['status']) ? $_GET['status'] : 'any';
839 839
 
840
-		$this->_column_headers = array( $columns, $hidden, $sortable );
840
+		$this->_column_headers = array($columns, $hidden, $sortable);
841 841
 
842
-		switch ( $status ) {
842
+		switch ($status) {
843 843
 			case 'publish':
844 844
 				$total_items = $this->complete_count;
845 845
 				break;
@@ -872,20 +872,20 @@  discard block
 block discarded – undo
872 872
 				break;
873 873
 			default:
874 874
 				// Retrieve the count of the non-default-Give status.
875
-				$count       = wp_count_posts( 'give_payment' );
876
-				$total_items = isset( $count->{$status} ) ? $count->{$status} : 0;
875
+				$count       = wp_count_posts('give_payment');
876
+				$total_items = isset($count->{$status} ) ? $count->{$status} : 0;
877 877
 				break;
878 878
 		}
879 879
 
880 880
 		$this->items = $data;
881 881
 
882
-		$this->set_pagination_args( array(
882
+		$this->set_pagination_args(array(
883 883
 			'total_items' => $total_items,
884 884
 			// We have to calculate the total number of items.
885 885
 			'per_page'    => $this->per_page,
886 886
 			// We have to determine how many items to show on a page.
887
-			'total_pages' => ceil( $total_items / $this->per_page ),
887
+			'total_pages' => ceil($total_items / $this->per_page),
888 888
 			// We have to calculate the total number of pages.
889
-		) );
889
+		));
890 890
 	}
891 891
 }
Please login to merge, or discard this patch.
includes/admin/payments/view-payment-details.php 1 patch
Spacing   +143 added lines, -143 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
 
@@ -20,27 +20,27 @@  discard block
 block discarded – undo
20 20
  * @since 1.0
21 21
  * @return void
22 22
  */
23
-if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
24
-	wp_die( esc_html__( 'Donation ID not supplied. Please try again.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) );
23
+if ( ! isset($_GET['id']) || ! is_numeric($_GET['id'])) {
24
+	wp_die(esc_html__('Donation ID not supplied. Please try again.', 'give'), esc_html__('Error', 'give'), array('response' => 400));
25 25
 }
26 26
 
27 27
 // Setup the variables
28
-$payment_id = absint( $_GET['id'] );
29
-$payment    = new Give_Payment( $payment_id );
28
+$payment_id = absint($_GET['id']);
29
+$payment    = new Give_Payment($payment_id);
30 30
 
31 31
 // Sanity check... fail if donation ID is invalid
32 32
 $payment_exists = $payment->ID;
33
-if ( empty( $payment_exists ) ) {
34
-	wp_die( esc_html__( 'The specified ID does not belong to a donation. Please try again.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) );
33
+if (empty($payment_exists)) {
34
+	wp_die(esc_html__('The specified ID does not belong to a donation. Please try again.', 'give'), esc_html__('Error', 'give'), array('response' => 400));
35 35
 }
36 36
 
37 37
 $number         = $payment->number;
38 38
 $payment_meta   = $payment->get_meta();
39
-$transaction_id = esc_attr( $payment->transaction_id );
39
+$transaction_id = esc_attr($payment->transaction_id);
40 40
 $user_id        = $payment->user_id;
41 41
 $donor_id       = $payment->customer_id;
42
-$payment_date   = strtotime( $payment->date );
43
-$user_info      = give_get_payment_meta_user_info( $payment_id );
42
+$payment_date   = strtotime($payment->date);
43
+$user_info      = give_get_payment_meta_user_info($payment_id);
44 44
 $address        = $payment->address;
45 45
 $currency_code  = $payment->currency;
46 46
 $gateway        = $payment->gateway;
@@ -52,11 +52,11 @@  discard block
 block discarded – undo
52 52
 	<h1 id="transaction-details-heading"><?php
53 53
 		printf(
54 54
 			/* translators: %s: donation number */
55
-			esc_html__( 'Donation %s', 'give' ),
55
+			esc_html__('Donation %s', 'give'),
56 56
 			$number
57 57
 		);
58
-		if ( $payment_mode == 'test' ) {
59
-			echo '<span id="test-payment-label" class="give-item-label give-item-label-orange" data-tooltip="' . esc_attr__( 'This donation was made in test mode.', 'give' ) . '" data-tooltip-my-position="center left" data-tooltip-target-position="center right">' . esc_html__( 'Test Donation', 'give' ) . '</span>';
58
+		if ($payment_mode == 'test') {
59
+			echo '<span id="test-payment-label" class="give-item-label give-item-label-orange" data-tooltip="'.esc_attr__('This donation was made in test mode.', 'give').'" data-tooltip-my-position="center left" data-tooltip-target-position="center right">'.esc_html__('Test Donation', 'give').'</span>';
60 60
 		}
61 61
 		?></h1>
62 62
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 *
69 69
 	 * @param int $payment_id Payment id.
70 70
 	 */
71
-	do_action( 'give_view_order_details_before', $payment_id );
71
+	do_action('give_view_order_details_before', $payment_id);
72 72
 	?>
73 73
 	<form id="give-edit-order-form" method="post">
74 74
 		<?php
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 		 *
80 80
 		 * @param int $payment_id Payment id.
81 81
 		 */
82
-		do_action( 'give_view_order_details_form_top', $payment_id );
82
+		do_action('give_view_order_details_form_top', $payment_id);
83 83
 		?>
84 84
 		<div id="poststuff">
85 85
 			<div id="give-dashboard-widgets-wrap">
@@ -95,12 +95,12 @@  discard block
 block discarded – undo
95 95
 							 *
96 96
 							 * @param int $payment_id Payment id.
97 97
 							 */
98
-							do_action( 'give_view_order_details_sidebar_before', $payment_id );
98
+							do_action('give_view_order_details_sidebar_before', $payment_id);
99 99
 							?>
100 100
 
101 101
 							<div id="give-order-update" class="postbox give-order-data">
102 102
 
103
-								<h3 class="hndle"><?php esc_html_e( 'Update Donation', 'give' ); ?></h3>
103
+								<h3 class="hndle"><?php esc_html_e('Update Donation', 'give'); ?></h3>
104 104
 
105 105
 								<div class="inside">
106 106
 									<div class="give-admin-box">
@@ -113,33 +113,33 @@  discard block
 block discarded – undo
113 113
 										 *
114 114
 										 * @param int $payment_id Payment id.
115 115
 										 */
116
-										do_action( 'give_view_order_details_totals_before', $payment_id );
116
+										do_action('give_view_order_details_totals_before', $payment_id);
117 117
 										?>
118 118
 
119 119
 										<div class="give-admin-box-inside">
120 120
 											<p>
121
-												<label for="give-payment-status" class="strong"><?php esc_html_e( 'Status:', 'give' ); ?></label>&nbsp;
121
+												<label for="give-payment-status" class="strong"><?php esc_html_e('Status:', 'give'); ?></label>&nbsp;
122 122
 												<select id="give-payment-status" name="give-payment-status" class="medium-text">
123
-													<?php foreach ( give_get_payment_statuses() as $key => $status ) : ?>
124
-														<option value="<?php echo esc_attr( $key ); ?>"<?php selected( $payment->status, $key, true ); ?>><?php echo esc_html( $status ); ?></option>
123
+													<?php foreach (give_get_payment_statuses() as $key => $status) : ?>
124
+														<option value="<?php echo esc_attr($key); ?>"<?php selected($payment->status, $key, true); ?>><?php echo esc_html($status); ?></option>
125 125
 													<?php endforeach; ?>
126 126
 												</select>
127
-												<span class="give-donation-status status-<?php echo sanitize_title( $payment->status ); ?>"><span class="give-donation-status-icon"></span></span>
127
+												<span class="give-donation-status status-<?php echo sanitize_title($payment->status); ?>"><span class="give-donation-status-icon"></span></span>
128 128
 											</p>
129 129
 										</div>
130 130
 
131 131
 										<div class="give-admin-box-inside">
132 132
 											<p>
133
-												<label for="give-payment-date" class="strong"><?php esc_html_e( 'Date:', 'give' ); ?></label>&nbsp;
134
-												<input type="text" id="give-payment-date" name="give-payment-date" value="<?php echo esc_attr( date( 'm/d/Y', $payment_date ) ); ?>" class="medium-text give_datepicker"/>
133
+												<label for="give-payment-date" class="strong"><?php esc_html_e('Date:', 'give'); ?></label>&nbsp;
134
+												<input type="text" id="give-payment-date" name="give-payment-date" value="<?php echo esc_attr(date('m/d/Y', $payment_date)); ?>" class="medium-text give_datepicker"/>
135 135
 											</p>
136 136
 										</div>
137 137
 
138 138
 										<div class="give-admin-box-inside">
139 139
 											<p>
140
-												<label for="give-payment-time-hour" class="strong"><?php esc_html_e( 'Time:', 'give' ); ?></label>&nbsp;
141
-												<input type="number" step="1" max="24" id="give-payment-time-hour" name="give-payment-time-hour" value="<?php echo esc_attr( date_i18n( 'H', $payment_date ) ); ?>" class="small-text give-payment-time-hour"/>&nbsp;:&nbsp;
142
-												<input type="number" step="1" max="59" id="give-payment-time-min" name="give-payment-time-min" value="<?php echo esc_attr( date( 'i', $payment_date ) ); ?>" class="small-text give-payment-time-min"/>
140
+												<label for="give-payment-time-hour" class="strong"><?php esc_html_e('Time:', 'give'); ?></label>&nbsp;
141
+												<input type="number" step="1" max="24" id="give-payment-time-hour" name="give-payment-time-hour" value="<?php echo esc_attr(date_i18n('H', $payment_date)); ?>" class="small-text give-payment-time-hour"/>&nbsp;:&nbsp;
142
+												<input type="number" step="1" max="59" id="give-payment-time-min" name="give-payment-time-min" value="<?php echo esc_attr(date('i', $payment_date)); ?>" class="small-text give-payment-time-min"/>
143 143
 											</p>
144 144
 										</div>
145 145
 
@@ -153,13 +153,13 @@  discard block
 block discarded – undo
153 153
 										 *
154 154
 										 * @param int $payment_id Payment id.
155 155
 										 */
156
-										do_action( 'give_view_order_details_update_inner', $payment_id ); ?>
156
+										do_action('give_view_order_details_update_inner', $payment_id); ?>
157 157
 
158 158
 										<div class="give-order-payment give-admin-box-inside">
159 159
 											<p>
160
-												<label for="give-payment-total" class="strong"><?php esc_html_e( 'Total Donation:', 'give' ); ?></label>&nbsp;
161
-												<?php echo give_currency_symbol( $payment->currency ); ?>
162
-												&nbsp;<input id="give-payment-total" name="give-payment-total" type="text" class="small-text give-price-field" value="<?php echo esc_attr( give_format_decimal( give_get_payment_amount( $payment_id ), false, false ) ); ?>"/>
160
+												<label for="give-payment-total" class="strong"><?php esc_html_e('Total Donation:', 'give'); ?></label>&nbsp;
161
+												<?php echo give_currency_symbol($payment->currency); ?>
162
+												&nbsp;<input id="give-payment-total" name="give-payment-total" type="text" class="small-text give-price-field" value="<?php echo esc_attr(give_format_decimal(give_get_payment_amount($payment_id), false, false)); ?>"/>
163 163
 											</p>
164 164
 										</div>
165 165
 
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 										 *
172 172
 										 * @param int $payment_id Payment id.
173 173
 										 */
174
-										do_action( 'give_view_order_details_totals_after', $payment_id );
174
+										do_action('give_view_order_details_totals_after', $payment_id);
175 175
 										?>
176 176
 
177 177
 									</div>
@@ -189,17 +189,17 @@  discard block
 block discarded – undo
189 189
 									 *
190 190
 									 * @param int $payment_id Payment id.
191 191
 									 */
192
-									do_action( 'give_view_order_details_update_before', $payment_id );
192
+									do_action('give_view_order_details_update_before', $payment_id);
193 193
 									?>
194 194
 
195 195
 									<div id="major-publishing-actions">
196 196
 										<div id="publishing-action">
197
-											<input type="submit" class="button button-primary right" value="<?php esc_attr_e( 'Save Donation', 'give' ); ?>"/>
198
-											<?php if ( give_is_payment_complete( $payment_id ) ) : ?>
199
-												<a href="<?php echo esc_url( add_query_arg( array(
197
+											<input type="submit" class="button button-primary right" value="<?php esc_attr_e('Save Donation', 'give'); ?>"/>
198
+											<?php if (give_is_payment_complete($payment_id)) : ?>
199
+												<a href="<?php echo esc_url(add_query_arg(array(
200 200
 													'give-action' => 'email_links',
201 201
 													'purchase_id' => $payment_id,
202
-												) ) ); ?>" id="give-resend-receipt" class="button-secondary right"><?php esc_html_e( 'Resend Receipt', 'give' ); ?></a>
202
+												))); ?>" id="give-resend-receipt" class="button-secondary right"><?php esc_html_e('Resend Receipt', 'give'); ?></a>
203 203
 											<?php endif; ?>
204 204
 										</div>
205 205
 										<div class="clear"></div>
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 									 *
214 214
 									 * @param int $payment_id Payment id.
215 215
 									 */
216
-									do_action( 'give_view_order_details_update_after', $payment_id );
216
+									do_action('give_view_order_details_update_after', $payment_id);
217 217
 									?>
218 218
 
219 219
 								</div>
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 
225 225
 							<div id="give-order-details" class="postbox give-order-data">
226 226
 
227
-								<h3 class="hndle"><?php esc_html_e( 'Donation Meta', 'give' ); ?></h3>
227
+								<h3 class="hndle"><?php esc_html_e('Donation Meta', 'give'); ?></h3>
228 228
 
229 229
 								<div class="inside">
230 230
 									<div class="give-admin-box">
@@ -237,44 +237,44 @@  discard block
 block discarded – undo
237 237
 										 *
238 238
 										 * @param int $payment_id Payment id.
239 239
 										 */
240
-										do_action( 'give_view_order_details_payment_meta_before', $payment_id );
240
+										do_action('give_view_order_details_payment_meta_before', $payment_id);
241 241
 
242
-										$gateway = give_get_payment_gateway( $payment_id );
243
-										if ( $gateway ) : ?>
242
+										$gateway = give_get_payment_gateway($payment_id);
243
+										if ($gateway) : ?>
244 244
 											<div class="give-order-gateway give-admin-box-inside">
245 245
 												<p>
246
-													<strong><?php esc_html_e( 'Gateway:', 'give' ); ?></strong>&nbsp;
247
-													<?php echo give_get_gateway_admin_label( $gateway ); ?>
246
+													<strong><?php esc_html_e('Gateway:', 'give'); ?></strong>&nbsp;
247
+													<?php echo give_get_gateway_admin_label($gateway); ?>
248 248
 												</p>
249 249
 											</div>
250 250
 										<?php endif; ?>
251 251
 
252 252
 										<div class="give-order-payment-key give-admin-box-inside">
253 253
 											<p>
254
-												<strong><?php esc_html_e( 'Key:', 'give' ); ?></strong>&nbsp;
255
-												<?php echo give_get_payment_key( $payment_id ); ?>
254
+												<strong><?php esc_html_e('Key:', 'give'); ?></strong>&nbsp;
255
+												<?php echo give_get_payment_key($payment_id); ?>
256 256
 											</p>
257 257
 										</div>
258 258
 
259 259
 										<div class="give-order-ip give-admin-box-inside">
260 260
 											<p>
261
-												<strong><?php esc_html_e( 'IP:', 'give' ); ?></strong>&nbsp;
262
-												<?php echo esc_html( give_get_payment_user_ip( $payment_id ) ); ?>
261
+												<strong><?php esc_html_e('IP:', 'give'); ?></strong>&nbsp;
262
+												<?php echo esc_html(give_get_payment_user_ip($payment_id)); ?>
263 263
 											</p>
264 264
 										</div>
265 265
 
266
-										<?php if ( $transaction_id ) : ?>
266
+										<?php if ($transaction_id) : ?>
267 267
 											<div class="give-order-tx-id give-admin-box-inside">
268 268
 												<p>
269
-													<strong><?php esc_html_e( 'Donation ID:', 'give' ); ?></strong>&nbsp;
270
-													<?php echo apply_filters( "give_payment_details_transaction_id-{$gateway}", $transaction_id, $payment_id ); ?>
269
+													<strong><?php esc_html_e('Donation ID:', 'give'); ?></strong>&nbsp;
270
+													<?php echo apply_filters("give_payment_details_transaction_id-{$gateway}", $transaction_id, $payment_id); ?>
271 271
 												</p>
272 272
 											</div>
273 273
 										<?php endif; ?>
274 274
 
275 275
 										<div class="give-admin-box-inside">
276
-											<p><?php $purchase_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&donor=' . absint( give_get_payment_donor_id( $payment_id ) ) ); ?>
277
-												<a href="<?php echo $purchase_url; ?>"><?php esc_html_e( 'View all donations for this donor &raquo;', 'give' ); ?></a>
276
+											<p><?php $purchase_url = admin_url('edit.php?post_type=give_forms&page=give-payment-history&donor='.absint(give_get_payment_donor_id($payment_id))); ?>
277
+												<a href="<?php echo $purchase_url; ?>"><?php esc_html_e('View all donations for this donor &raquo;', 'give'); ?></a>
278 278
 											</p>
279 279
 										</div>
280 280
 
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 										 *
287 287
 										 * @param int $payment_id Payment id.
288 288
 										 */
289
-										do_action( 'give_view_order_details_payment_meta_after', $payment_id );
289
+										do_action('give_view_order_details_payment_meta_after', $payment_id);
290 290
 										?>
291 291
 
292 292
 									</div>
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 							 *
307 307
 							 * @param int $payment_id Payment id.
308 308
 							 */
309
-							do_action( 'give_view_order_details_sidebar_after', $payment_id );
309
+							do_action('give_view_order_details_sidebar_after', $payment_id);
310 310
 							?>
311 311
 
312 312
 						</div>
@@ -326,56 +326,56 @@  discard block
 block discarded – undo
326 326
 							 *
327 327
 							 * @param int $payment_id Payment id.
328 328
 							 */
329
-							do_action( 'give_view_order_details_main_before', $payment_id );
329
+							do_action('give_view_order_details_main_before', $payment_id);
330 330
 							?>
331 331
 
332 332
 							<?php $column_count = 'columns-3'; ?>
333 333
 							<div id="give-donation-overview" class="postbox <?php echo $column_count; ?>">
334
-								<h3 class="hndle"><?php esc_html_e( 'Donation Information', 'give' ); ?></h3>
334
+								<h3 class="hndle"><?php esc_html_e('Donation Information', 'give'); ?></h3>
335 335
 
336 336
 								<div class="inside">
337 337
 
338 338
 									<div class="column-container">
339 339
 										<div class="column">
340 340
 											<p>
341
-												<strong><?php esc_html_e( 'Donation Form ID:', 'give' ); ?></strong><br>
341
+												<strong><?php esc_html_e('Donation Form ID:', 'give'); ?></strong><br>
342 342
 												<?php
343
-												if ( $payment_meta['form_id'] ) :
343
+												if ($payment_meta['form_id']) :
344 344
 													printf(
345 345
 														'<a href="%1$s">#%2$s</a>',
346
-														admin_url( 'post.php?action=edit&post=' . $payment_meta['form_id'] ),
346
+														admin_url('post.php?action=edit&post='.$payment_meta['form_id']),
347 347
 														$payment_meta['form_id']
348 348
 													);
349 349
 												endif;
350 350
 												?>
351 351
 											</p>
352 352
 											<p>
353
-												<strong><?php esc_html_e( 'Donation Form Title:', 'give' ); ?></strong><br>
354
-												<?php echo Give()->html->forms_dropdown( array(
353
+												<strong><?php esc_html_e('Donation Form Title:', 'give'); ?></strong><br>
354
+												<?php echo Give()->html->forms_dropdown(array(
355 355
 													'selected' => $payment_meta['form_id'],
356 356
 													'name'   => 'give-payment-form-select',
357 357
 													'id'     => 'give-payment-form-select',
358 358
 													'chosen' => true,
359
-												) ); ?>
359
+												)); ?>
360 360
 											</p>
361 361
 										</div>
362 362
 										<div class="column">
363 363
 											<p>
364
-												<strong><?php esc_html_e( 'Donation Date:', 'give' ); ?></strong><br>
365
-												<?php echo date_i18n( give_date_format(), $payment_date ); ?>
364
+												<strong><?php esc_html_e('Donation Date:', 'give'); ?></strong><br>
365
+												<?php echo date_i18n(give_date_format(), $payment_date); ?>
366 366
 											</p>
367 367
 											<p>
368
-												<strong><?php esc_html_e( 'Donation Level:', 'give' ); ?></strong><br>
368
+												<strong><?php esc_html_e('Donation Level:', 'give'); ?></strong><br>
369 369
 												<span class="give-donation-level">
370 370
 													<?php
371
-													$var_prices = give_has_variable_prices( $payment_meta['form_id'] );
372
-													if ( empty( $var_prices ) ) {
373
-														esc_html_e( 'n/a', 'give' );
371
+													$var_prices = give_has_variable_prices($payment_meta['form_id']);
372
+													if (empty($var_prices)) {
373
+														esc_html_e('n/a', 'give');
374 374
 													} else {
375 375
 														$prices_atts = '';
376
-														if( $variable_prices = give_get_variable_prices( $payment_meta['form_id'] ) ) {
377
-															foreach ( $variable_prices as $variable_price ) {
378
-																$prices_atts[$variable_price['_give_id']['level_id']] = give_format_amount( $variable_price['_give_amount'], array( 'sanitize' => false ) );
376
+														if ($variable_prices = give_get_variable_prices($payment_meta['form_id'])) {
377
+															foreach ($variable_prices as $variable_price) {
378
+																$prices_atts[$variable_price['_give_id']['level_id']] = give_format_amount($variable_price['_give_amount'], array('sanitize' => false));
379 379
 															}
380 380
 														}
381 381
 														// Variable price dropdown options.
@@ -384,12 +384,12 @@  discard block
 block discarded – undo
384 384
 															'name'             => 'give-variable-price',
385 385
 															'chosen'           => true,
386 386
 															'show_option_all'  => '',
387
-															'show_option_none' => ( '' === get_post_meta( $payment_id, '_give_payment_price_id', true ) ? __( 'None', 'give' )  : '' ),
388
-															'select_atts'      => 'data-prices=' . esc_attr( json_encode( $prices_atts ) ),
387
+															'show_option_none' => ('' === get_post_meta($payment_id, '_give_payment_price_id', true) ? __('None', 'give') : ''),
388
+															'select_atts'      => 'data-prices='.esc_attr(json_encode($prices_atts)),
389 389
 															'selected'         => $payment_meta['price_id'],
390 390
 														);
391 391
 														// Render variable prices select tag html.
392
-														give_get_form_variable_price_dropdown( $variable_price_dropdown_option, true );
392
+														give_get_form_variable_price_dropdown($variable_price_dropdown_option, true);
393 393
 													}
394 394
 													?>
395 395
 												</span>
@@ -397,8 +397,8 @@  discard block
 block discarded – undo
397 397
 										</div>
398 398
 										<div class="column">
399 399
 											<p>
400
-												<strong><?php esc_html_e( 'Total Donation:', 'give' ); ?></strong><br>
401
-												<?php echo give_currency_filter( give_format_amount( $payment->total, array( 'sanitize' => false ) ), give_get_payment_currency_code( $payment->ID ) ); ?>
400
+												<strong><?php esc_html_e('Total Donation:', 'give'); ?></strong><br>
401
+												<?php echo give_currency_filter(give_format_amount($payment->total, array('sanitize' => false)), give_get_payment_currency_code($payment->ID)); ?>
402 402
 											</p>
403 403
 											<p>
404 404
 												<?php
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
 												 *
412 412
 												 * @param int $payment_id Payment id.
413 413
 												 */
414
-												do_action( 'give_donation_details_thead_before', $payment_id );
414
+												do_action('give_donation_details_thead_before', $payment_id);
415 415
 
416 416
 
417 417
 												/**
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
 												 *
424 424
 												 * @param int $payment_id Payment id.
425 425
 												 */
426
-												do_action( 'give_donation_details_thead_after', $payment_id );
426
+												do_action('give_donation_details_thead_after', $payment_id);
427 427
 
428 428
 												/**
429 429
 												 * Fires in order details page, in the donation-information metabox, before the body elements.
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
 												 *
435 435
 												 * @param int $payment_id Payment id.
436 436
 												 */
437
-												do_action( 'give_donation_details_tbody_before', $payment_id );
437
+												do_action('give_donation_details_tbody_before', $payment_id);
438 438
 
439 439
 												/**
440 440
 												 * Fires in order details page, in the donation-information metabox, after the body elements.
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 												 *
446 446
 												 * @param int $payment_id Payment id.
447 447
 												 */
448
-												do_action( 'give_donation_details_tbody_after', $payment_id );
448
+												do_action('give_donation_details_tbody_after', $payment_id);
449 449
 												?>
450 450
 											</p>
451 451
 										</div>
@@ -465,67 +465,67 @@  discard block
 block discarded – undo
465 465
 							 *
466 466
 							 * @param int $payment_id Payment id.
467 467
 							 */
468
-							do_action( 'give_view_order_details_files_after', $payment_id );
468
+							do_action('give_view_order_details_files_after', $payment_id);
469 469
 							?>
470 470
 
471 471
 							<div id="give-donor-details" class="postbox">
472
-								<h3 class="hndle"><?php esc_html_e( 'Donor Details', 'give' ); ?></h3>
472
+								<h3 class="hndle"><?php esc_html_e('Donor Details', 'give'); ?></h3>
473 473
 
474 474
 								<div class="inside">
475 475
 
476
-									<?php $donor = new Give_Donor( $donor_id ); ?>
476
+									<?php $donor = new Give_Donor($donor_id); ?>
477 477
 
478 478
 									<div class="column-container donor-info">
479 479
 										<div class="column">
480 480
 											<p>
481
-												<strong><?php esc_html_e( 'Donor ID:', 'give' ); ?></strong><br>
481
+												<strong><?php esc_html_e('Donor ID:', 'give'); ?></strong><br>
482 482
 												<?php
483
-												if ( ! empty( $donor->id ) ) {
483
+												if ( ! empty($donor->id)) {
484 484
 													printf(
485 485
 														'<a href="%1$s">#%2$s</a>',
486
-														admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ),
486
+														admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id),
487 487
 														$donor->id
488 488
 													);
489 489
 												}
490 490
 												?>
491 491
 											</p>
492 492
 											<p>
493
-												<strong><?php esc_html_e( 'Donor Since:', 'give' ); ?></strong><br>
494
-												<?php echo date_i18n( give_date_format(), strtotime( $donor->date_created ) ) ?>
493
+												<strong><?php esc_html_e('Donor Since:', 'give'); ?></strong><br>
494
+												<?php echo date_i18n(give_date_format(), strtotime($donor->date_created)) ?>
495 495
 											</p>
496 496
 										</div>
497 497
 										<div class="column">
498 498
 											<p>
499
-												<strong><?php esc_html_e( 'Donor Name:', 'give' ); ?></strong><br>
499
+												<strong><?php esc_html_e('Donor Name:', 'give'); ?></strong><br>
500 500
 												<?php
501
-                                                $donor_billing_name = give_get_donor_name_by( $payment_id, 'donation' );
502
-                                                $donor_name = give_get_donor_name_by( $donor_id, 'donor' );
501
+                                                $donor_billing_name = give_get_donor_name_by($payment_id, 'donation');
502
+                                                $donor_name = give_get_donor_name_by($donor_id, 'donor');
503 503
 
504 504
                                                 // Check whether the donor name and WP_User name is same or not.
505
-                                                if( sanitize_title( $donor_billing_name ) != sanitize_title( $donor_name ) ){
506
-                                                    echo $donor_billing_name . ' (<a href="' . esc_url( admin_url( "edit.php?post_type=give_forms&page=give-donors&view=overview&id=$donor_id" ) ) . '">' . $donor_name . '</a>)';
507
-                                                }else{
505
+                                                if (sanitize_title($donor_billing_name) != sanitize_title($donor_name)) {
506
+                                                    echo $donor_billing_name.' (<a href="'.esc_url(admin_url("edit.php?post_type=give_forms&page=give-donors&view=overview&id=$donor_id")).'">'.$donor_name.'</a>)';
507
+                                                } else {
508 508
                                                     echo $donor_name;
509 509
                                                 }
510 510
                                                 ?>
511 511
 											</p>
512 512
 											<p>
513
-												<strong><?php esc_html_e( 'Donor Email:', 'give' ); ?></strong><br>
513
+												<strong><?php esc_html_e('Donor Email:', 'give'); ?></strong><br>
514 514
 												<?php echo $donor->email; ?>
515 515
 											</p>
516 516
 										</div>
517 517
 										<div class="column">
518 518
 											<p>
519
-												<strong><?php esc_html_e( 'Change Donor:', 'give' ); ?></strong><br>
519
+												<strong><?php esc_html_e('Change Donor:', 'give'); ?></strong><br>
520 520
 												<?php
521
-												echo Give()->html->donor_dropdown( array(
521
+												echo Give()->html->donor_dropdown(array(
522 522
 													'selected' => $donor->id,
523 523
 													'name'     => 'donor-id',
524
-												) );
524
+												));
525 525
 												?>
526 526
 											</p>
527 527
 											<p>
528
-												<a href="#new" class="give-payment-new-donor"><?php esc_html_e( 'Create New Donor', 'give' ); ?></a>
528
+												<a href="#new" class="give-payment-new-donor"><?php esc_html_e('Create New Donor', 'give'); ?></a>
529 529
 											</p>
530 530
 										</div>
531 531
 									</div>
@@ -533,13 +533,13 @@  discard block
 block discarded – undo
533 533
 									<div class="column-container new-donor" style="display: none">
534 534
 										<div class="column">
535 535
 											<p>
536
-												<label for="give-new-donor-name"><?php esc_html_e( 'New Donor Name:', 'give' ); ?></label>
536
+												<label for="give-new-donor-name"><?php esc_html_e('New Donor Name:', 'give'); ?></label>
537 537
 												<input id="give-new-donor-name" type="text" name="give-new-donor-name" value="" class="medium-text"/>
538 538
 											</p>
539 539
 										</div>
540 540
 										<div class="column">
541 541
 											<p>
542
-												<label for="give-new-donor-email"><?php esc_html_e( 'New Donor Email:', 'give' ); ?></label>
542
+												<label for="give-new-donor-email"><?php esc_html_e('New Donor Email:', 'give'); ?></label>
543 543
 												<input id="give-new-donor-email" type="email" name="give-new-donor-email" value="" class="medium-text"/>
544 544
 											</p>
545 545
 										</div>
@@ -547,9 +547,9 @@  discard block
 block discarded – undo
547 547
 											<p>
548 548
 												<input type="hidden" name="give-current-donor" value="<?php echo $donor->id; ?>"/>
549 549
 												<input type="hidden" id="give-new-donor" name="give-new-donor" value="0"/>
550
-												<a href="#cancel" class="give-payment-new-donor-cancel give-delete"><?php esc_html_e( 'Cancel', 'give' ); ?></a>
550
+												<a href="#cancel" class="give-payment-new-donor-cancel give-delete"><?php esc_html_e('Cancel', 'give'); ?></a>
551 551
 												<br>
552
-												<em><?php esc_html_e( 'Click "Save Donation" to create new donor.', 'give' ); ?></em>
552
+												<em><?php esc_html_e('Click "Save Donation" to create new donor.', 'give'); ?></em>
553 553
 											</p>
554 554
 										</div>
555 555
 									</div>
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
 									 * @param array $payment_meta Payment meta.
566 566
 									 * @param array $user_info    User information.
567 567
 									 */
568
-									do_action( 'give_payment_personal_details_list', $payment_meta, $user_info );
568
+									do_action('give_payment_personal_details_list', $payment_meta, $user_info);
569 569
 
570 570
 									/**
571 571
 									 * Fires on the donation details page, in the donor-details metabox.
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
 									 *
575 575
 									 * @param int $payment_id Payment id.
576 576
 									 */
577
-									do_action( 'give_payment_view_details', $payment_id );
577
+									do_action('give_payment_view_details', $payment_id);
578 578
 									?>
579 579
 
580 580
 								</div>
@@ -590,11 +590,11 @@  discard block
 block discarded – undo
590 590
 							 *
591 591
 							 * @param int $payment_id Payment id.
592 592
 							 */
593
-							do_action( 'give_view_order_details_billing_before', $payment_id );
593
+							do_action('give_view_order_details_billing_before', $payment_id);
594 594
 							?>
595 595
 
596 596
 							<div id="give-billing-details" class="postbox">
597
-								<h3 class="hndle"><?php esc_html_e( 'Billing Address', 'give' ); ?></h3>
597
+								<h3 class="hndle"><?php esc_html_e('Billing Address', 'give'); ?></h3>
598 598
 
599 599
 								<div class="inside">
600 600
 
@@ -604,59 +604,59 @@  discard block
 block discarded – undo
604 604
 											<div class="data column-container">
605 605
 												<div class="column">
606 606
 													<div class="give-wrap-address-line1">
607
-														<label for="give-payment-address-line1" class="order-data-address"><?php esc_html_e( 'Address 1:', 'give' ); ?></label>
608
-														<input id="give-payment-address-line1" type="text" name="give-payment-address[0][line1]" value="<?php echo esc_attr( $address['line1'] ); ?>" class="medium-text"/>
607
+														<label for="give-payment-address-line1" class="order-data-address"><?php esc_html_e('Address 1:', 'give'); ?></label>
608
+														<input id="give-payment-address-line1" type="text" name="give-payment-address[0][line1]" value="<?php echo esc_attr($address['line1']); ?>" class="medium-text"/>
609 609
 													</div>
610 610
 													<div class="give-wrap-address-line2">
611
-														<label for="give-payment-address-line2" class="order-data-address-line"><?php esc_html_e( 'Address 2:', 'give' ); ?></label>
612
-														<input id="give-payment-address-line2" type="text" name="give-payment-address[0][line2]" value="<?php echo esc_attr( $address['line2'] ); ?>" class="medium-text"/>
611
+														<label for="give-payment-address-line2" class="order-data-address-line"><?php esc_html_e('Address 2:', 'give'); ?></label>
612
+														<input id="give-payment-address-line2" type="text" name="give-payment-address[0][line2]" value="<?php echo esc_attr($address['line2']); ?>" class="medium-text"/>
613 613
 													</div>
614 614
 												</div>
615 615
 												<div class="column">
616 616
 													<div class="give-wrap-address-city">
617
-														<label for="give-payment-address-city" class="order-data-address-line"><?php esc_html_e( 'City:', 'give' ); ?></label>
618
-														<input id="give-payment-address-city" type="text" name="give-payment-address[0][city]" value="<?php echo esc_attr( $address['city'] ); ?>" class="medium-text"/>
617
+														<label for="give-payment-address-city" class="order-data-address-line"><?php esc_html_e('City:', 'give'); ?></label>
618
+														<input id="give-payment-address-city" type="text" name="give-payment-address[0][city]" value="<?php echo esc_attr($address['city']); ?>" class="medium-text"/>
619 619
 													</div>
620 620
 													<div class="give-wrap-address-zip">
621
-														<label for="give-payment-address-zip" class="order-data-address-line"><?php esc_html_e( 'Zip / Postal Code:', 'give' ); ?></label>
622
-														<input id="give-payment-address-zip" type="text" name="give-payment-address[0][zip]" value="<?php echo esc_attr( $address['zip'] ); ?>" class="medium-text"/>
621
+														<label for="give-payment-address-zip" class="order-data-address-line"><?php esc_html_e('Zip / Postal Code:', 'give'); ?></label>
622
+														<input id="give-payment-address-zip" type="text" name="give-payment-address[0][zip]" value="<?php echo esc_attr($address['zip']); ?>" class="medium-text"/>
623 623
 
624 624
 													</div>
625 625
 												</div>
626 626
 												<div class="column">
627 627
 													<div id="give-order-address-country-wrap">
628
-														<label class="order-data-address-line"><?php esc_html_e( 'Country:', 'give' ); ?></label>
628
+														<label class="order-data-address-line"><?php esc_html_e('Country:', 'give'); ?></label>
629 629
 														<?php
630
-														echo Give()->html->select( array(
630
+														echo Give()->html->select(array(
631 631
 															'options'          => give_get_country_list(),
632 632
 															'name'             => 'give-payment-address[0][country]',
633 633
 															'selected'         => $address['country'],
634 634
 															'show_option_all'  => false,
635 635
 															'show_option_none' => false,
636 636
 															'chosen'           => true,
637
-															'placeholder'      => esc_attr__( 'Select a country', 'give' ),
638
-															'data'             => array( 'search-type' => 'no_ajax' ),
639
-														) );
637
+															'placeholder'      => esc_attr__('Select a country', 'give'),
638
+															'data'             => array('search-type' => 'no_ajax'),
639
+														));
640 640
 														?>
641 641
 													</div>
642 642
 													<div id="give-order-address-state-wrap">
643
-														<label for="give-payment-address-state" class="order-data-address-line"><?php esc_html_e( 'State / Province / County:', 'give' ); ?></label>
643
+														<label for="give-payment-address-state" class="order-data-address-line"><?php esc_html_e('State / Province / County:', 'give'); ?></label>
644 644
 														<?php
645
-														$states = give_get_states( $address['country'] );
646
-														if ( ! empty( $states ) ) {
647
-															echo Give()->html->select( array(
645
+														$states = give_get_states($address['country']);
646
+														if ( ! empty($states)) {
647
+															echo Give()->html->select(array(
648 648
 																'options'          => $states,
649 649
 																'name'             => 'give-payment-address[0][state]',
650 650
 																'selected'         => $address['state'],
651 651
 																'show_option_all'  => false,
652 652
 																'show_option_none' => false,
653 653
 																'chosen'           => true,
654
-																'placeholder'      => esc_attr__( 'Select a state', 'give' ),
655
-																'data'             => array( 'search-type' => 'no_ajax' ),
656
-															) );
654
+																'placeholder'      => esc_attr__('Select a state', 'give'),
655
+																'data'             => array('search-type' => 'no_ajax'),
656
+															));
657 657
 														} else {
658 658
 															?>
659
-															<input id="give-payment-address-state" type="text" name="give-payment-address[0][state]" value="<?php echo esc_attr( $address['state'] ); ?>" class="medium-text"/>
659
+															<input id="give-payment-address-state" type="text" name="give-payment-address[0][state]" value="<?php echo esc_attr($address['state']); ?>" class="medium-text"/>
660 660
 															<?php
661 661
 														} ?>
662 662
 													</div>
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
 									 *
677 677
 									 * @param int $payment_id Payment id.
678 678
 									 */
679
-									do_action( 'give_payment_billing_details', $payment_id );
679
+									do_action('give_payment_billing_details', $payment_id);
680 680
 									?>
681 681
 
682 682
 								</div>
@@ -692,32 +692,32 @@  discard block
 block discarded – undo
692 692
 							 *
693 693
 							 * @param int $payment_id Payment id.
694 694
 							 */
695
-							do_action( 'give_view_order_details_billing_after', $payment_id );
695
+							do_action('give_view_order_details_billing_after', $payment_id);
696 696
 							?>
697 697
 
698 698
 							<div id="give-payment-notes" class="postbox">
699
-								<h3 class="hndle"><?php esc_html_e( 'Donation Notes', 'give' ); ?></h3>
699
+								<h3 class="hndle"><?php esc_html_e('Donation Notes', 'give'); ?></h3>
700 700
 
701 701
 								<div class="inside">
702 702
 									<div id="give-payment-notes-inner">
703 703
 										<?php
704
-										$notes = give_get_payment_notes( $payment_id );
705
-										if ( ! empty( $notes ) ) {
704
+										$notes = give_get_payment_notes($payment_id);
705
+										if ( ! empty($notes)) {
706 706
 											$no_notes_display = ' style="display:none;"';
707
-											foreach ( $notes as $note ) :
707
+											foreach ($notes as $note) :
708 708
 
709
-												echo give_get_payment_note_html( $note, $payment_id );
709
+												echo give_get_payment_note_html($note, $payment_id);
710 710
 
711 711
 											endforeach;
712 712
 										} else {
713 713
 											$no_notes_display = '';
714 714
 										}
715
-										echo '<p class="give-no-payment-notes"' . $no_notes_display . '>' . esc_html__( 'No donation notes.', 'give' ) . '</p>'; ?>
715
+										echo '<p class="give-no-payment-notes"'.$no_notes_display.'>'.esc_html__('No donation notes.', 'give').'</p>'; ?>
716 716
 									</div>
717 717
 									<textarea name="give-payment-note" id="give-payment-note" class="large-text"></textarea>
718 718
 
719 719
 									<div class="give-clearfix">
720
-										<button id="give-add-payment-note" class="button button-secondary button-small" data-payment-id="<?php echo absint( $payment_id ); ?>"><?php esc_html_e( 'Add Note', 'give' ); ?></button>
720
+										<button id="give-add-payment-note" class="button button-secondary button-small" data-payment-id="<?php echo absint($payment_id); ?>"><?php esc_html_e('Add Note', 'give'); ?></button>
721 721
 									</div>
722 722
 
723 723
 								</div>
@@ -733,7 +733,7 @@  discard block
 block discarded – undo
733 733
 							 *
734 734
 							 * @param int $payment_id Payment id.
735 735
 							 */
736
-							do_action( 'give_view_order_details_main_after', $payment_id );
736
+							do_action('give_view_order_details_main_after', $payment_id);
737 737
 							?>
738 738
 
739 739
 						</div>
@@ -755,11 +755,11 @@  discard block
 block discarded – undo
755 755
 		 *
756 756
 		 * @param int $payment_id Payment id.
757 757
 		 */
758
-		do_action( 'give_view_order_details_form_bottom', $payment_id );
758
+		do_action('give_view_order_details_form_bottom', $payment_id);
759 759
 
760
-		wp_nonce_field( 'give_update_payment_details_nonce' );
760
+		wp_nonce_field('give_update_payment_details_nonce');
761 761
 		?>
762
-		<input type="hidden" name="give_payment_id" value="<?php echo esc_attr( $payment_id ); ?>"/>
762
+		<input type="hidden" name="give_payment_id" value="<?php echo esc_attr($payment_id); ?>"/>
763 763
 		<input type="hidden" name="give_action" value="update_payment_details"/>
764 764
 	</form>
765 765
 	<?php
@@ -770,6 +770,6 @@  discard block
 block discarded – undo
770 770
 	 *
771 771
 	 * @param int $payment_id Payment id.
772 772
 	 */
773
-	do_action( 'give_view_order_details_after', $payment_id );
773
+	do_action('give_view_order_details_after', $payment_id);
774 774
 	?>
775 775
 </div><!-- /.wrap -->
Please login to merge, or discard this patch.
includes/admin/donors/donor-actions.php 1 patch
Spacing   +194 added lines, -194 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -23,17 +23,17 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @return array|bool $output Response messages
25 25
  */
26
-function give_edit_donor( $args ) {
26
+function give_edit_donor($args) {
27 27
 
28
-	$donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' );
28
+	$donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments');
29 29
 
30
-	if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) {
31
-		wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array(
30
+	if ( ! is_admin() || ! current_user_can($donor_edit_role)) {
31
+		wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array(
32 32
 			'response' => 403,
33
-		) );
33
+		));
34 34
 	}
35 35
 
36
-	if ( empty( $args ) ) {
36
+	if (empty($args)) {
37 37
 		return false;
38 38
 	}
39 39
 
@@ -41,15 +41,15 @@  discard block
 block discarded – undo
41 41
 	$donor_id   = (int) $args['customerinfo']['id'];
42 42
 	$nonce      = $args['_wpnonce'];
43 43
 
44
-	if ( ! wp_verify_nonce( $nonce, 'edit-donor' ) ) {
45
-		wp_die( __( 'Cheatin&#8217; uh?', 'give' ), __( 'Error', 'give' ), array(
44
+	if ( ! wp_verify_nonce($nonce, 'edit-donor')) {
45
+		wp_die(__('Cheatin&#8217; uh?', 'give'), __('Error', 'give'), array(
46 46
 			'response' => 400,
47
-		) );
47
+		));
48 48
 	}
49 49
 
50
-	$donor = new Give_Donor( $donor_id );
50
+	$donor = new Give_Donor($donor_id);
51 51
 
52
-	if ( empty( $donor->id ) ) {
52
+	if (empty($donor->id)) {
53 53
 		return false;
54 54
 	}
55 55
 
@@ -58,70 +58,70 @@  discard block
 block discarded – undo
58 58
 		'user_id' => 0,
59 59
 	);
60 60
 
61
-	$donor_info = wp_parse_args( $donor_info, $defaults );
61
+	$donor_info = wp_parse_args($donor_info, $defaults);
62 62
 
63
-	if ( (int) $donor_info['user_id'] !== (int) $donor->user_id ) {
63
+	if ((int) $donor_info['user_id'] !== (int) $donor->user_id) {
64 64
 
65 65
 		// Make sure we don't already have this user attached to a donor.
66
-		if ( ! empty( $donor_info['user_id'] ) && false !== Give()->donors->get_donor_by( 'user_id', $donor_info['user_id'] ) ) {
67
-			give_set_error( 'give-invalid-donor-user_id', sprintf( __( 'The User ID #%d is already associated with a different donor.', 'give' ), $donor_info['user_id'] ) );
66
+		if ( ! empty($donor_info['user_id']) && false !== Give()->donors->get_donor_by('user_id', $donor_info['user_id'])) {
67
+			give_set_error('give-invalid-donor-user_id', sprintf(__('The User ID #%d is already associated with a different donor.', 'give'), $donor_info['user_id']));
68 68
 		}
69 69
 
70 70
 		// Make sure it's actually a user.
71
-		$user = get_user_by( 'id', $donor_info['user_id'] );
72
-		if ( ! empty( $donor_info['user_id'] ) && false === $user ) {
73
-			give_set_error( 'give-invalid-user_id', sprintf( __( 'The User ID #%d does not exist. Please assign an existing user.', 'give' ), $donor_info['user_id'] ) );
71
+		$user = get_user_by('id', $donor_info['user_id']);
72
+		if ( ! empty($donor_info['user_id']) && false === $user) {
73
+			give_set_error('give-invalid-user_id', sprintf(__('The User ID #%d does not exist. Please assign an existing user.', 'give'), $donor_info['user_id']));
74 74
 		}
75 75
 	}
76 76
 
77 77
 	// Record this for later.
78 78
 	$previous_user_id = $donor->user_id;
79 79
 
80
-	if ( give_get_errors() ) {
80
+	if (give_get_errors()) {
81 81
 		return false;
82 82
 	}
83 83
 
84 84
 	// Setup the donor address, if present.
85 85
 	$address = array();
86
-	if ( intval( $donor_info['user_id'] ) > 0 ) {
86
+	if (intval($donor_info['user_id']) > 0) {
87 87
 
88
-		$current_address = get_user_meta( $donor_info['user_id'], '_give_user_address', true );
88
+		$current_address = get_user_meta($donor_info['user_id'], '_give_user_address', true);
89 89
 
90
-		if ( false === $current_address ) {
91
-			$address['line1']   = isset( $donor_info['line1'] ) ? $donor_info['line1'] : '';
92
-			$address['line2']   = isset( $donor_info['line2'] ) ? $donor_info['line2'] : '';
93
-			$address['city']    = isset( $donor_info['city'] ) ? $donor_info['city'] : '';
94
-			$address['country'] = isset( $donor_info['country'] ) ? $donor_info['country'] : '';
95
-			$address['zip']     = isset( $donor_info['zip'] ) ? $donor_info['zip'] : '';
96
-			$address['state']   = isset( $donor_info['state'] ) ? $donor_info['state'] : '';
90
+		if (false === $current_address) {
91
+			$address['line1']   = isset($donor_info['line1']) ? $donor_info['line1'] : '';
92
+			$address['line2']   = isset($donor_info['line2']) ? $donor_info['line2'] : '';
93
+			$address['city']    = isset($donor_info['city']) ? $donor_info['city'] : '';
94
+			$address['country'] = isset($donor_info['country']) ? $donor_info['country'] : '';
95
+			$address['zip']     = isset($donor_info['zip']) ? $donor_info['zip'] : '';
96
+			$address['state']   = isset($donor_info['state']) ? $donor_info['state'] : '';
97 97
 		} else {
98
-			$current_address    = wp_parse_args( $current_address, array(
98
+			$current_address    = wp_parse_args($current_address, array(
99 99
 				'line1',
100 100
 				'line2',
101 101
 				'city',
102 102
 				'zip',
103 103
 				'state',
104 104
 				'country',
105
-			) );
106
-			$address['line1']   = isset( $donor_info['line1'] ) ? $donor_info['line1'] : $current_address['line1'];
107
-			$address['line2']   = isset( $donor_info['line2'] ) ? $donor_info['line2'] : $current_address['line2'];
108
-			$address['city']    = isset( $donor_info['city'] ) ? $donor_info['city'] : $current_address['city'];
109
-			$address['country'] = isset( $donor_info['country'] ) ? $donor_info['country'] : $current_address['country'];
110
-			$address['zip']     = isset( $donor_info['zip'] ) ? $donor_info['zip'] : $current_address['zip'];
111
-			$address['state']   = isset( $donor_info['state'] ) ? $donor_info['state'] : $current_address['state'];
105
+			));
106
+			$address['line1']   = isset($donor_info['line1']) ? $donor_info['line1'] : $current_address['line1'];
107
+			$address['line2']   = isset($donor_info['line2']) ? $donor_info['line2'] : $current_address['line2'];
108
+			$address['city']    = isset($donor_info['city']) ? $donor_info['city'] : $current_address['city'];
109
+			$address['country'] = isset($donor_info['country']) ? $donor_info['country'] : $current_address['country'];
110
+			$address['zip']     = isset($donor_info['zip']) ? $donor_info['zip'] : $current_address['zip'];
111
+			$address['state']   = isset($donor_info['state']) ? $donor_info['state'] : $current_address['state'];
112 112
 		}
113 113
 	}
114 114
 
115 115
 	// Sanitize the inputs
116 116
 	$donor_data            = array();
117
-	$donor_data['name']    = strip_tags( stripslashes( $donor_info['name'] ) );
117
+	$donor_data['name']    = strip_tags(stripslashes($donor_info['name']));
118 118
 	$donor_data['user_id'] = $donor_info['user_id'];
119 119
 
120
-	$donor_data = apply_filters( 'give_edit_donor_info', $donor_data, $donor_id );
121
-	$address    = apply_filters( 'give_edit_donor_address', $address, $donor_id );
120
+	$donor_data = apply_filters('give_edit_donor_info', $donor_data, $donor_id);
121
+	$address    = apply_filters('give_edit_donor_address', $address, $donor_id);
122 122
 
123
-	$donor_data = array_map( 'sanitize_text_field', $donor_data );
124
-	$address    = array_map( 'sanitize_text_field', $address );
123
+	$donor_data = array_map('sanitize_text_field', $donor_data);
124
+	$address    = array_map('sanitize_text_field', $address);
125 125
 
126 126
 	/**
127 127
 	 * Fires before editing a donor.
@@ -132,27 +132,27 @@  discard block
 block discarded – undo
132 132
 	 * @param array $donor_data The donor data.
133 133
 	 * @param array $address    The donor's address.
134 134
 	 */
135
-	do_action( 'give_pre_edit_donor', $donor_id, $donor_data, $address );
135
+	do_action('give_pre_edit_donor', $donor_id, $donor_data, $address);
136 136
 
137 137
 	$output = array();
138 138
 
139
-	if ( $donor->update( $donor_data ) ) {
139
+	if ($donor->update($donor_data)) {
140 140
 
141
-		if ( ! empty( $donor->user_id ) && $donor->user_id > 0 ) {
142
-			update_user_meta( $donor->user_id, '_give_user_address', $address );
141
+		if ( ! empty($donor->user_id) && $donor->user_id > 0) {
142
+			update_user_meta($donor->user_id, '_give_user_address', $address);
143 143
 		}
144 144
 
145 145
 		// Update some donation meta if we need to.
146
-		$payments_array = explode( ',', $donor->payment_ids );
146
+		$payments_array = explode(',', $donor->payment_ids);
147 147
 
148
-		if ( $donor->user_id != $previous_user_id ) {
149
-			foreach ( $payments_array as $payment_id ) {
150
-				give_update_payment_meta( $payment_id, '_give_payment_user_id', $donor->user_id );
148
+		if ($donor->user_id != $previous_user_id) {
149
+			foreach ($payments_array as $payment_id) {
150
+				give_update_payment_meta($payment_id, '_give_payment_user_id', $donor->user_id);
151 151
 			}
152 152
 		}
153 153
 
154 154
 		$output['success']       = true;
155
-		$donor_data              = array_merge( $donor_data, $address );
155
+		$donor_data              = array_merge($donor_data, $address);
156 156
 		$output['customer_info'] = $donor_data;
157 157
 
158 158
 	} else {
@@ -169,11 +169,11 @@  discard block
 block discarded – undo
169 169
 	 * @param int   $donor_id   The ID of the donor.
170 170
 	 * @param array $donor_data The donor data.
171 171
 	 */
172
-	do_action( 'give_post_edit_donor', $donor_id, $donor_data );
172
+	do_action('give_post_edit_donor', $donor_id, $donor_data);
173 173
 
174
-	if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
175
-		header( 'Content-Type: application/json' );
176
-		echo json_encode( $output );
174
+	if (defined('DOING_AJAX') && DOING_AJAX) {
175
+		header('Content-Type: application/json');
176
+		echo json_encode($output);
177 177
 		wp_die();
178 178
 	}
179 179
 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 
182 182
 }
183 183
 
184
-add_action( 'give_edit-donor', 'give_edit_donor', 10, 1 );
184
+add_action('give_edit-donor', 'give_edit_donor', 10, 1);
185 185
 
186 186
 /**
187 187
  * Save a donor note.
@@ -192,40 +192,40 @@  discard block
 block discarded – undo
192 192
  *
193 193
  * @return int         The Note ID that was saved, or 0 if nothing was saved.
194 194
  */
195
-function give_donor_save_note( $args ) {
195
+function give_donor_save_note($args) {
196 196
 
197
-	$donor_view_role = apply_filters( 'give_view_donors_role', 'view_give_reports' );
197
+	$donor_view_role = apply_filters('give_view_donors_role', 'view_give_reports');
198 198
 
199
-	if ( ! is_admin() || ! current_user_can( $donor_view_role ) ) {
200
-		wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array(
199
+	if ( ! is_admin() || ! current_user_can($donor_view_role)) {
200
+		wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array(
201 201
 			'response' => 403,
202
-		) );
202
+		));
203 203
 	}
204 204
 
205
-	if ( empty( $args ) ) {
205
+	if (empty($args)) {
206 206
 		return false;
207 207
 	}
208 208
 
209
-	$donor_note = trim( sanitize_text_field( $args['donor_note'] ) );
209
+	$donor_note = trim(sanitize_text_field($args['donor_note']));
210 210
 	$donor_id   = (int) $args['customer_id'];
211 211
 	$nonce      = $args['add_donor_note_nonce'];
212 212
 
213
-	if ( ! wp_verify_nonce( $nonce, 'add-donor-note' ) ) {
214
-		wp_die( __( 'Cheatin&#8217; uh?', 'give' ), __( 'Error', 'give' ), array(
213
+	if ( ! wp_verify_nonce($nonce, 'add-donor-note')) {
214
+		wp_die(__('Cheatin&#8217; uh?', 'give'), __('Error', 'give'), array(
215 215
 			'response' => 400,
216
-		) );
216
+		));
217 217
 	}
218 218
 
219
-	if ( empty( $donor_note ) ) {
220
-		give_set_error( 'empty-donor-note', __( 'A note is required.', 'give' ) );
219
+	if (empty($donor_note)) {
220
+		give_set_error('empty-donor-note', __('A note is required.', 'give'));
221 221
 	}
222 222
 
223
-	if ( give_get_errors() ) {
223
+	if (give_get_errors()) {
224 224
 		return false;
225 225
 	}
226 226
 
227
-	$donor    = new Give_Donor( $donor_id );
228
-	$new_note = $donor->add_note( $donor_note );
227
+	$donor    = new Give_Donor($donor_id);
228
+	$new_note = $donor->add_note($donor_note);
229 229
 
230 230
 	/**
231 231
 	 * Fires before inserting donor note.
@@ -235,22 +235,22 @@  discard block
 block discarded – undo
235 235
 	 * @param int    $donor_id The ID of the donor.
236 236
 	 * @param string $new_note Note content.
237 237
 	 */
238
-	do_action( 'give_pre_insert_donor_note', $donor_id, $new_note );
238
+	do_action('give_pre_insert_donor_note', $donor_id, $new_note);
239 239
 
240
-	if ( ! empty( $new_note ) && ! empty( $donor->id ) ) {
240
+	if ( ! empty($new_note) && ! empty($donor->id)) {
241 241
 
242 242
 		ob_start();
243 243
 		?>
244 244
 		<div class="donor-note-wrapper dashboard-comment-wrap comment-item">
245 245
 			<span class="note-content-wrap">
246
-				<?php echo stripslashes( $new_note ); ?>
246
+				<?php echo stripslashes($new_note); ?>
247 247
 			</span>
248 248
 		</div>
249 249
 		<?php
250 250
 		$output = ob_get_contents();
251 251
 		ob_end_clean();
252 252
 
253
-		if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
253
+		if (defined('DOING_AJAX') && DOING_AJAX) {
254 254
 			echo $output;
255 255
 			exit;
256 256
 		}
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 
264 264
 }
265 265
 
266
-add_action( 'give_add-donor-note', 'give_donor_save_note', 10, 1 );
266
+add_action('give_add-donor-note', 'give_donor_save_note', 10, 1);
267 267
 
268 268
 /**
269 269
  * Delete a donor.
@@ -274,41 +274,41 @@  discard block
 block discarded – undo
274 274
  *
275 275
  * @return int Whether it was a successful deletion.
276 276
  */
277
-function give_donor_delete( $args ) {
277
+function give_donor_delete($args) {
278 278
 
279
-	$donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' );
279
+	$donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments');
280 280
 
281
-	if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) {
282
-		wp_die( __( 'You do not have permission to delete donors.', 'give' ), __( 'Error', 'give' ), array(
281
+	if ( ! is_admin() || ! current_user_can($donor_edit_role)) {
282
+		wp_die(__('You do not have permission to delete donors.', 'give'), __('Error', 'give'), array(
283 283
 			'response' => 403,
284
-		) );
284
+		));
285 285
 	}
286 286
 
287
-	if ( empty( $args ) ) {
287
+	if (empty($args)) {
288 288
 		return false;
289 289
 	}
290 290
 
291 291
 	$donor_id    = (int) $args['customer_id'];
292
-	$confirm     = ! empty( $args['give-donor-delete-confirm'] ) ? true : false;
293
-	$remove_data = ! empty( $args['give-donor-delete-records'] ) ? true : false;
292
+	$confirm     = ! empty($args['give-donor-delete-confirm']) ? true : false;
293
+	$remove_data = ! empty($args['give-donor-delete-records']) ? true : false;
294 294
 	$nonce       = $args['_wpnonce'];
295 295
 
296
-	if ( ! wp_verify_nonce( $nonce, 'delete-donor' ) ) {
297
-		wp_die( __( 'Cheatin&#8217; uh?', 'give' ), __( 'Error', 'give' ), array(
296
+	if ( ! wp_verify_nonce($nonce, 'delete-donor')) {
297
+		wp_die(__('Cheatin&#8217; uh?', 'give'), __('Error', 'give'), array(
298 298
 			'response' => 400,
299
-		) );
299
+		));
300 300
 	}
301 301
 
302
-	if ( ! $confirm ) {
303
-		give_set_error( 'donor-delete-no-confirm', __( 'Please confirm you want to delete this donor.', 'give' ) );
302
+	if ( ! $confirm) {
303
+		give_set_error('donor-delete-no-confirm', __('Please confirm you want to delete this donor.', 'give'));
304 304
 	}
305 305
 
306
-	if ( give_get_errors() ) {
307
-		wp_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor_id ) );
306
+	if (give_get_errors()) {
307
+		wp_redirect(admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor_id));
308 308
 		exit;
309 309
 	}
310 310
 
311
-	$donor = new Give_Donor( $donor_id );
311
+	$donor = new Give_Donor($donor_id);
312 312
 
313 313
 	/**
314 314
 	 * Fires before deleting donor.
@@ -319,50 +319,50 @@  discard block
 block discarded – undo
319 319
 	 * @param bool $confirm     Delete confirmation.
320 320
 	 * @param bool $remove_data Records delete confirmation.
321 321
 	 */
322
-	do_action( 'give_pre_delete_donor', $donor_id, $confirm, $remove_data );
322
+	do_action('give_pre_delete_donor', $donor_id, $confirm, $remove_data);
323 323
 
324
-	if ( $donor->id > 0 ) {
324
+	if ($donor->id > 0) {
325 325
 
326
-		$payments_array = explode( ',', $donor->payment_ids );
327
-		$success        = Give()->donors->delete( $donor->id );
326
+		$payments_array = explode(',', $donor->payment_ids);
327
+		$success        = Give()->donors->delete($donor->id);
328 328
 
329
-		if ( $success ) {
329
+		if ($success) {
330 330
 
331
-			if ( $remove_data ) {
331
+			if ($remove_data) {
332 332
 
333 333
 				// Remove all donations, logs, etc
334
-				foreach ( $payments_array as $payment_id ) {
335
-					give_delete_donation( $payment_id );
334
+				foreach ($payments_array as $payment_id) {
335
+					give_delete_donation($payment_id);
336 336
 				}
337 337
 			} else {
338 338
 
339 339
 				// Just set the donations to customer_id of 0
340
-				foreach ( $payments_array as $payment_id ) {
341
-					give_update_payment_meta( $payment_id, '_give_payment_customer_id', 0 );
340
+				foreach ($payments_array as $payment_id) {
341
+					give_update_payment_meta($payment_id, '_give_payment_customer_id', 0);
342 342
 				}
343 343
 			}
344 344
 
345
-			$redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&give-message=donor-deleted' );
345
+			$redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&give-message=donor-deleted');
346 346
 
347 347
 		} else {
348 348
 
349
-			give_set_error( 'give-donor-delete-failed', esc_html__( 'Error deleting donor.', 'give' ) );
350
-			$redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $donor_id );
349
+			give_set_error('give-donor-delete-failed', esc_html__('Error deleting donor.', 'give'));
350
+			$redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$donor_id);
351 351
 
352 352
 		}
353 353
 	} else {
354 354
 
355
-		give_set_error( 'give-donor-delete-invalid-id', esc_html__( 'Invalid Donor ID.', 'give' ) );
356
-		$redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors' );
355
+		give_set_error('give-donor-delete-invalid-id', esc_html__('Invalid Donor ID.', 'give'));
356
+		$redirect = admin_url('edit.php?post_type=give_forms&page=give-donors');
357 357
 
358 358
 	}
359 359
 
360
-	wp_redirect( $redirect );
360
+	wp_redirect($redirect);
361 361
 	exit;
362 362
 
363 363
 }
364 364
 
365
-add_action( 'give_delete-donor', 'give_donor_delete', 10, 1 );
365
+add_action('give_delete-donor', 'give_donor_delete', 10, 1);
366 366
 
367 367
 /**
368 368
  * Disconnect a user ID from a donor
@@ -373,17 +373,17 @@  discard block
 block discarded – undo
373 373
  *
374 374
  * @return bool|array        If the disconnect was successful.
375 375
  */
376
-function give_disconnect_donor_user_id( $args ) {
376
+function give_disconnect_donor_user_id($args) {
377 377
 
378
-	$donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' );
378
+	$donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments');
379 379
 
380
-	if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) {
381
-		wp_die( __( 'You do not have permission to edit this donor.', 'give' ), __( 'Error', 'give' ), array(
380
+	if ( ! is_admin() || ! current_user_can($donor_edit_role)) {
381
+		wp_die(__('You do not have permission to edit this donor.', 'give'), __('Error', 'give'), array(
382 382
 			'response' => 403,
383
-		) );
383
+		));
384 384
 	}
385 385
 
386
-	if ( empty( $args ) ) {
386
+	if (empty($args)) {
387 387
 		return false;
388 388
 	}
389 389
 
@@ -391,14 +391,14 @@  discard block
 block discarded – undo
391 391
 
392 392
 	$nonce = $args['_wpnonce'];
393 393
 
394
-	if ( ! wp_verify_nonce( $nonce, 'edit-donor' ) ) {
395
-		wp_die( __( 'Cheatin&#8217; uh?', 'give' ), __( 'Error', 'give' ), array(
394
+	if ( ! wp_verify_nonce($nonce, 'edit-donor')) {
395
+		wp_die(__('Cheatin&#8217; uh?', 'give'), __('Error', 'give'), array(
396 396
 			'response' => 400,
397
-		) );
397
+		));
398 398
 	}
399 399
 
400
-	$donor = new Give_Donor( $donor_id );
401
-	if ( empty( $donor->id ) ) {
400
+	$donor = new Give_Donor($donor_id);
401
+	if (empty($donor->id)) {
402 402
 		return false;
403 403
 	}
404 404
 
@@ -412,18 +412,18 @@  discard block
 block discarded – undo
412 412
 	 * @param int $donor_id The ID of the donor.
413 413
 	 * @param int $user_id  The ID of the user.
414 414
 	 */
415
-	do_action( 'give_pre_donor_disconnect_user_id', $donor_id, $user_id );
415
+	do_action('give_pre_donor_disconnect_user_id', $donor_id, $user_id);
416 416
 
417 417
 	$output     = array();
418 418
 	$donor_args = array(
419 419
 		'user_id' => 0,
420 420
 	);
421 421
 
422
-	if ( $donor->update( $donor_args ) ) {
422
+	if ($donor->update($donor_args)) {
423 423
 		global $wpdb;
424 424
 
425
-		if ( ! empty( $donor->payment_ids ) ) {
426
-			$wpdb->query( "UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $donor->payment_ids )" );
425
+		if ( ! empty($donor->payment_ids)) {
426
+			$wpdb->query("UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $donor->payment_ids )");
427 427
 		}
428 428
 
429 429
 		$output['success'] = true;
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
 	} else {
432 432
 
433 433
 		$output['success'] = false;
434
-		give_set_error( 'give-disconnect-user-fail', __( 'Failed to disconnect user from donor.', 'give' ) );
434
+		give_set_error('give-disconnect-user-fail', __('Failed to disconnect user from donor.', 'give'));
435 435
 	}
436 436
 
437 437
 	/**
@@ -441,11 +441,11 @@  discard block
 block discarded – undo
441 441
 	 *
442 442
 	 * @param int $donor_id The ID of the donor.
443 443
 	 */
444
-	do_action( 'give_post_donor_disconnect_user_id', $donor_id );
444
+	do_action('give_post_donor_disconnect_user_id', $donor_id);
445 445
 
446
-	if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
447
-		header( 'Content-Type: application/json' );
448
-		echo json_encode( $output );
446
+	if (defined('DOING_AJAX') && DOING_AJAX) {
447
+		header('Content-Type: application/json');
448
+		echo json_encode($output);
449 449
 		wp_die();
450 450
 	}
451 451
 
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 
454 454
 }
455 455
 
456
-add_action( 'give_disconnect-userid', 'give_disconnect_donor_user_id', 10, 1 );
456
+add_action('give_disconnect-userid', 'give_disconnect_donor_user_id', 10, 1);
457 457
 
458 458
 /**
459 459
  * Add an email address to the donor from within the admin and log a donor note.
@@ -464,90 +464,90 @@  discard block
 block discarded – undo
464 464
  *
465 465
  * @return mixed        If DOING_AJAX echos out JSON, otherwise returns array of success (bool) and message (string).
466 466
  */
467
-function give_add_donor_email( $args ) {
467
+function give_add_donor_email($args) {
468 468
 	/**
469 469
 	 * Define variable
470 470
 	 *
471 471
 	 * @since 1.8.14
472 472
 	 */
473 473
 	$donor_id = '';
474
-	$donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' );
474
+	$donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments');
475 475
 
476
-	if ( ! is_admin() || ! current_user_can( $donor_edit_role ) ) {
477
-		wp_die( esc_html__( 'You do not have permission to edit this donor.', 'give' ), esc_html__( 'Error', 'give' ), array(
476
+	if ( ! is_admin() || ! current_user_can($donor_edit_role)) {
477
+		wp_die(esc_html__('You do not have permission to edit this donor.', 'give'), esc_html__('Error', 'give'), array(
478 478
 			'response' => 403,
479
-		) );
479
+		));
480 480
 	}
481 481
 
482 482
 	$output = array();
483
-	if ( empty( $args ) || empty( $args['email'] ) || empty( $args['customer_id'] ) ) {
483
+	if (empty($args) || empty($args['email']) || empty($args['customer_id'])) {
484 484
 		$output['success'] = false;
485
-		if ( empty( $args['email'] ) ) {
486
-			$output['message'] = __( 'Email address is required.', 'give' );
487
-		} elseif ( empty( $args['customer_id'] ) ) {
488
-			$output['message'] = __( 'Donor ID is required.', 'give' );
485
+		if (empty($args['email'])) {
486
+			$output['message'] = __('Email address is required.', 'give');
487
+		} elseif (empty($args['customer_id'])) {
488
+			$output['message'] = __('Donor ID is required.', 'give');
489 489
 		} else {
490
-			$output['message'] = __( 'An error has occurred. Please try again.', 'give' );
490
+			$output['message'] = __('An error has occurred. Please try again.', 'give');
491 491
 		}
492
-	} elseif ( ! wp_verify_nonce( $args['_wpnonce'], 'give_add_donor_email' ) ) {
492
+	} elseif ( ! wp_verify_nonce($args['_wpnonce'], 'give_add_donor_email')) {
493 493
 		$output = array(
494 494
 			'success' => false,
495
-			'message' => esc_html__( 'Nonce verification failed.', 'give' ),
495
+			'message' => esc_html__('Nonce verification failed.', 'give'),
496 496
 		);
497
-	} elseif ( ! is_email( $args['email'] ) ) {
497
+	} elseif ( ! is_email($args['email'])) {
498 498
 		$output = array(
499 499
 			'success' => false,
500
-			'message' => esc_html__( 'Invalid email.', 'give' ),
500
+			'message' => esc_html__('Invalid email.', 'give'),
501 501
 		);
502 502
 	} else {
503
-		$email    = sanitize_email( $args['email'] );
503
+		$email    = sanitize_email($args['email']);
504 504
 		$donor_id = (int) $args['customer_id'];
505 505
 		$primary  = 'true' === $args['primary'] ? true : false;
506
-		$donor    = new Give_Donor( $donor_id );
507
-		if ( false === $donor->add_email( $email, $primary ) ) {
508
-			if ( in_array( $email, $donor->emails ) ) {
506
+		$donor    = new Give_Donor($donor_id);
507
+		if (false === $donor->add_email($email, $primary)) {
508
+			if (in_array($email, $donor->emails)) {
509 509
 				$output = array(
510 510
 					'success' => false,
511
-					'message' => __( 'Email already associated with this donor.', 'give' ),
511
+					'message' => __('Email already associated with this donor.', 'give'),
512 512
 				);
513 513
 			} else {
514 514
 				$output = array(
515 515
 					'success' => false,
516
-					'message' => __( 'Email address is already associated with another donor.', 'give' ),
516
+					'message' => __('Email address is already associated with another donor.', 'give'),
517 517
 				);
518 518
 			}
519 519
 		} else {
520
-			$redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor_id . '&give-message=email-added' );
520
+			$redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor_id.'&give-message=email-added');
521 521
 			$output   = array(
522 522
 				'success'  => true,
523
-				'message'  => __( 'Email successfully added to donor.', 'give' ),
523
+				'message'  => __('Email successfully added to donor.', 'give'),
524 524
 				'redirect' => $redirect,
525 525
 			);
526 526
 
527 527
 			$user       = wp_get_current_user();
528
-			$user_login = ! empty( $user->user_login ) ? $user->user_login : __( 'System', 'give' );
529
-			$donor_note = sprintf( __( 'Email address %1$s added by %2$s', 'give' ), $email, $user_login );
530
-			$donor->add_note( $donor_note );
528
+			$user_login = ! empty($user->user_login) ? $user->user_login : __('System', 'give');
529
+			$donor_note = sprintf(__('Email address %1$s added by %2$s', 'give'), $email, $user_login);
530
+			$donor->add_note($donor_note);
531 531
 
532
-			if ( $primary ) {
533
-				$donor_note = sprintf( __( 'Email address %1$s set as primary by %2$s', 'give' ), $email, $user_login );
534
-				$donor->add_note( $donor_note );
532
+			if ($primary) {
533
+				$donor_note = sprintf(__('Email address %1$s set as primary by %2$s', 'give'), $email, $user_login);
534
+				$donor->add_note($donor_note);
535 535
 			}
536 536
 		}
537 537
 	}// End if().
538 538
 
539
-	do_action( 'give_post_add_donor_email', $donor_id, $args );
539
+	do_action('give_post_add_donor_email', $donor_id, $args);
540 540
 
541
-	if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
542
-		header( 'Content-Type: application/json' );
543
-		echo json_encode( $output );
541
+	if (defined('DOING_AJAX') && DOING_AJAX) {
542
+		header('Content-Type: application/json');
543
+		echo json_encode($output);
544 544
 		wp_die();
545 545
 	}
546 546
 
547 547
 	return $output;
548 548
 }
549 549
 
550
-add_action( 'give_add_donor_email', 'give_add_donor_email', 10, 1 );
550
+add_action('give_add_donor_email', 'give_add_donor_email', 10, 1);
551 551
 
552 552
 
553 553
 /**
@@ -557,39 +557,39 @@  discard block
 block discarded – undo
557 557
  * @return bool|null
558 558
  */
559 559
 function give_remove_donor_email() {
560
-	if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
560
+	if (empty($_GET['id']) || ! is_numeric($_GET['id'])) {
561 561
 		return false;
562 562
 	}
563
-	if ( empty( $_GET['email'] ) || ! is_email( $_GET['email'] ) ) {
563
+	if (empty($_GET['email']) || ! is_email($_GET['email'])) {
564 564
 		return false;
565 565
 	}
566
-	if ( empty( $_GET['_wpnonce'] ) ) {
566
+	if (empty($_GET['_wpnonce'])) {
567 567
 		return false;
568 568
 	}
569 569
 
570 570
 	$nonce = $_GET['_wpnonce'];
571
-	if ( ! wp_verify_nonce( $nonce, 'give-remove-donor-email' ) ) {
572
-		wp_die( esc_html__( 'Nonce verification failed', 'give' ), esc_html__( 'Error', 'give' ), array(
571
+	if ( ! wp_verify_nonce($nonce, 'give-remove-donor-email')) {
572
+		wp_die(esc_html__('Nonce verification failed', 'give'), esc_html__('Error', 'give'), array(
573 573
 			'response' => 403,
574
-		) );
574
+		));
575 575
 	}
576 576
 
577
-	$donor = new Give_Donor( $_GET['id'] );
578
-	if ( $donor->remove_email( $_GET['email'] ) ) {
579
-		$url        = add_query_arg( 'give-message', 'email-removed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) );
577
+	$donor = new Give_Donor($_GET['id']);
578
+	if ($donor->remove_email($_GET['email'])) {
579
+		$url        = add_query_arg('give-message', 'email-removed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id));
580 580
 		$user       = wp_get_current_user();
581
-		$user_login = ! empty( $user->user_login ) ? $user->user_login : __( 'System', 'give' );
582
-		$donor_note = sprintf( __( 'Email address %1$s removed by %2$s', 'give' ), $_GET['email'], $user_login );
583
-		$donor->add_note( $donor_note );
581
+		$user_login = ! empty($user->user_login) ? $user->user_login : __('System', 'give');
582
+		$donor_note = sprintf(__('Email address %1$s removed by %2$s', 'give'), $_GET['email'], $user_login);
583
+		$donor->add_note($donor_note);
584 584
 	} else {
585
-		$url = add_query_arg( 'give-message', 'email-remove-failed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) );
585
+		$url = add_query_arg('give-message', 'email-remove-failed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id));
586 586
 	}
587 587
 
588
-	wp_safe_redirect( $url );
588
+	wp_safe_redirect($url);
589 589
 	exit;
590 590
 }
591 591
 
592
-add_action( 'give_remove_donor_email', 'give_remove_donor_email', 10 );
592
+add_action('give_remove_donor_email', 'give_remove_donor_email', 10);
593 593
 
594 594
 
595 595
 /**
@@ -600,41 +600,41 @@  discard block
 block discarded – undo
600 600
  * @return bool|null
601 601
  */
602 602
 function give_set_donor_primary_email() {
603
-	if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
603
+	if (empty($_GET['id']) || ! is_numeric($_GET['id'])) {
604 604
 		return false;
605 605
 	}
606 606
 
607
-	if ( empty( $_GET['email'] ) || ! is_email( $_GET['email'] ) ) {
607
+	if (empty($_GET['email']) || ! is_email($_GET['email'])) {
608 608
 		return false;
609 609
 	}
610 610
 
611
-	if ( empty( $_GET['_wpnonce'] ) ) {
611
+	if (empty($_GET['_wpnonce'])) {
612 612
 		return false;
613 613
 	}
614 614
 
615 615
 	$nonce = $_GET['_wpnonce'];
616 616
 
617
-	if ( ! wp_verify_nonce( $nonce, 'give-set-donor-primary-email' ) ) {
618
-		wp_die( esc_html__( 'Nonce verification failed', 'give' ), esc_html__( 'Error', 'give' ), array(
617
+	if ( ! wp_verify_nonce($nonce, 'give-set-donor-primary-email')) {
618
+		wp_die(esc_html__('Nonce verification failed', 'give'), esc_html__('Error', 'give'), array(
619 619
 			'response' => 403,
620
-		) );
620
+		));
621 621
 	}
622 622
 
623
-	$donor = new Give_Donor( $_GET['id'] );
623
+	$donor = new Give_Donor($_GET['id']);
624 624
 
625
-	if ( $donor->set_primary_email( $_GET['email'] ) ) {
626
-		$url        = add_query_arg( 'give-message', 'primary-email-updated', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) );
625
+	if ($donor->set_primary_email($_GET['email'])) {
626
+		$url        = add_query_arg('give-message', 'primary-email-updated', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id));
627 627
 		$user       = wp_get_current_user();
628
-		$user_login = ! empty( $user->user_login ) ? $user->user_login : esc_html__( 'System', 'give' );
629
-		$donor_note = sprintf( __( 'Email address %1$s set as primary by %2$s', 'give' ), $_GET['email'], $user_login );
628
+		$user_login = ! empty($user->user_login) ? $user->user_login : esc_html__('System', 'give');
629
+		$donor_note = sprintf(__('Email address %1$s set as primary by %2$s', 'give'), $_GET['email'], $user_login);
630 630
 
631
-		$donor->add_note( $donor_note );
631
+		$donor->add_note($donor_note);
632 632
 	} else {
633
-		$url = add_query_arg( 'give-message', 'primary-email-failed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) );
633
+		$url = add_query_arg('give-message', 'primary-email-failed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id));
634 634
 	}
635 635
 
636
-	wp_safe_redirect( $url );
636
+	wp_safe_redirect($url);
637 637
 	exit;
638 638
 }
639 639
 
640
-add_action( 'give_set_donor_primary_email', 'give_set_donor_primary_email', 10 );
640
+add_action('give_set_donor_primary_email', 'give_set_donor_primary_email', 10);
Please login to merge, or discard this patch.
includes/admin/class-i18n-module.php 1 patch
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -65,18 +65,18 @@  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
-		foreach ( $args as $key => $arg ) {
75
+		foreach ($args as $key => $arg) {
76 76
 			$this->$key = $arg;
77 77
 		}
78 78
 
79
-		add_action( 'admin_init', array( $this, 'init' ) );
79
+		add_action('admin_init', array($this, 'init'));
80 80
 
81 81
 
82 82
 	}
@@ -87,19 +87,19 @@  discard block
 block discarded – undo
87 87
 	function init() {
88 88
 
89 89
 		// First get user's locale (4.7+).
90
-		$this->locale = function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
90
+		$this->locale = function_exists('get_user_locale') ? get_user_locale() : get_locale();
91 91
 
92 92
 		// This plugin is en_US native.
93
-		if ( 'en_US' === $this->locale ) {
93
+		if ('en_US' === $this->locale) {
94 94
 			return;
95 95
 		}
96 96
 
97 97
 		if (
98 98
 			! $this->hide_promo()
99
-			&& ( ! empty( $_GET['post_type'] ) && 'give_forms' === $_GET['post_type'] )
100
-			&& ( ! empty( $_GET['page'] ) && 'give-settings' === $_GET['page'] )
99
+			&& ( ! empty($_GET['post_type']) && 'give_forms' === $_GET['post_type'])
100
+			&& ( ! empty($_GET['page']) && 'give-settings' === $_GET['page'])
101 101
 		) {
102
-			add_action( $this->hook, array( $this, 'promo' ) );
102
+			add_action($this->hook, array($this, 'promo'));
103 103
 		}
104 104
 	}
105 105
 
@@ -112,11 +112,11 @@  discard block
 block discarded – undo
112 112
 	 * @return bool
113 113
 	 */
114 114
 	private function hide_promo() {
115
-		$hide_promo = Give_Cache::get( 'give_i18n_give_promo_hide', true );
116
-		if ( ! $hide_promo ) {
117
-			if ( filter_input( INPUT_GET, 'remove_i18n_promo', FILTER_VALIDATE_INT ) === 1 ) {
115
+		$hide_promo = Give_Cache::get('give_i18n_give_promo_hide', true);
116
+		if ( ! $hide_promo) {
117
+			if (filter_input(INPUT_GET, 'remove_i18n_promo', FILTER_VALIDATE_INT) === 1) {
118 118
 				// No expiration time, so this would normally not expire, but it wouldn't be copied to other sites etc.
119
-				Give_Cache::set( 'give_i18n_give_promo_hide', true, null, true );
119
+				Give_Cache::set('give_i18n_give_promo_hide', true, null, true);
120 120
 				$hide_promo = true;
121 121
 			}
122 122
 		}
@@ -135,20 +135,20 @@  discard block
 block discarded – undo
135 135
 		$message = false;
136 136
 
137 137
 		// Using a translation less than 90% complete.
138
-		if ( $this->translation_exists && $this->translation_loaded && $this->percent_translated < 90 ) {
139
-			$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' );
140
-		} elseif ( ! $this->translation_loaded && $this->translation_exists ) {
141
-			$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' );
142
-		} elseif ( ! $this->translation_exists ) {
143
-			$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' );
138
+		if ($this->translation_exists && $this->translation_loaded && $this->percent_translated < 90) {
139
+			$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');
140
+		} elseif ( ! $this->translation_loaded && $this->translation_exists) {
141
+			$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');
142
+		} elseif ( ! $this->translation_exists) {
143
+			$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');
144 144
 		}
145 145
 
146 146
 		// Links.
147
-		$registration_link = sprintf( '<a href="%1$s" target="_blank">%2$s</a>', 'https://wordpress.org/support/register.php', esc_html__( 'WordPress.org', 'give' ) );
148
-		$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' ) );
147
+		$registration_link = sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://wordpress.org/support/register.php', esc_html__('WordPress.org', 'give'));
148
+		$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'));
149 149
 
150 150
 		// Message.
151
-		$message = sprintf( $message, $this->locale_name, 'Give', $this->percent_translated, $registration_link, $translations_link );
151
+		$message = sprintf($message, $this->locale_name, 'Give', $this->percent_translated, $registration_link, $translations_link);
152 152
 
153 153
 		return $message;
154 154
 
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 		$this->translation_details();
163 163
 		$message = $this->promo_message();
164 164
 
165
-		if ( $message ) { ?>
165
+		if ($message) { ?>
166 166
 
167 167
 			<style>
168 168
 				/* Banner specific styles */
@@ -227,12 +227,12 @@  discard block
 block discarded – undo
227 227
 				                                                                                                                             style="font-size: 110px; text-decoration: none;"></span></a>
228 228
 
229 229
 				<div class="give-i18n-notice-content">
230
-					<a href="<?php echo esc_url( add_query_arg( array( 'remove_i18n_promo' => '1' ) ) ); ?>" class="dismiss"><span class="dashicons dashicons-dismiss"></span></a>
230
+					<a href="<?php echo esc_url(add_query_arg(array('remove_i18n_promo' => '1'))); ?>" class="dismiss"><span class="dashicons dashicons-dismiss"></span></a>
231 231
 
232
-					<h2 style="margin: 10px 0;"><?php printf( esc_html__( 'Help Translate Give to %s', 'give' ), $this->locale_name ); ?></h2>
232
+					<h2 style="margin: 10px 0;"><?php printf(esc_html__('Help Translate Give to %s', 'give'), $this->locale_name); ?></h2>
233 233
 					<p><?php echo $message; ?></p>
234 234
 					<p>
235
-						<a href="https://wordpress.org/support/register.php" target="_blank"><?php _e( 'Register now &raquo;', 'give' ); ?></a>
235
+						<a href="https://wordpress.org/support/register.php" target="_blank"><?php _e('Register now &raquo;', 'give'); ?></a>
236 236
 					</p>
237 237
 				</div>
238 238
 			</div>
@@ -249,11 +249,11 @@  discard block
 block discarded – undo
249 249
 	 */
250 250
 	private function find_or_initialize_translation_details() {
251 251
 
252
-		$set = Give_Cache::get( "give_i18n_give_{$this->locale}", true );
252
+		$set = Give_Cache::get("give_i18n_give_{$this->locale}", true);
253 253
 
254
-		if ( ! $set ) {
254
+		if ( ! $set) {
255 255
 			$set = $this->retrieve_translation_details();
256
-			Give_Cache::set( "give_i18n_give_{$this->locale}", $set, DAY_IN_SECONDS, true );
256
+			Give_Cache::set("give_i18n_give_{$this->locale}", $set, DAY_IN_SECONDS, true);
257 257
 		}
258 258
 
259 259
 		return $set;
@@ -267,10 +267,10 @@  discard block
 block discarded – undo
267 267
 	private function translation_details() {
268 268
 		$set = $this->find_or_initialize_translation_details();
269 269
 
270
-		$this->translation_exists = ! is_null( $set );
271
-		$this->translation_loaded = is_textdomain_loaded( 'give' );
270
+		$this->translation_exists = ! is_null($set);
271
+		$this->translation_loaded = is_textdomain_loaded('give');
272 272
 
273
-		$this->parse_translation_set( $set );
273
+		$this->parse_translation_set($set);
274 274
 	}
275 275
 
276 276
 	/**
@@ -282,26 +282,26 @@  discard block
 block discarded – undo
282 282
 	 */
283 283
 	private function retrieve_translation_details() {
284 284
 
285
-		$api_url = trailingslashit( $this->glotpress_url );
285
+		$api_url = trailingslashit($this->glotpress_url);
286 286
 
287
-		$resp = wp_remote_get( $api_url );
287
+		$resp = wp_remote_get($api_url);
288 288
 
289
-		if ( is_wp_error( $resp ) || wp_remote_retrieve_response_code( $resp ) === '404' ) {
289
+		if (is_wp_error($resp) || wp_remote_retrieve_response_code($resp) === '404') {
290 290
 			return null;
291 291
 		}
292 292
 
293
-		$body = wp_remote_retrieve_body( $resp );
294
-		unset( $resp );
293
+		$body = wp_remote_retrieve_body($resp);
294
+		unset($resp);
295 295
 
296
-		if ( $body ) {
297
-			$body = json_decode( $body );
296
+		if ($body) {
297
+			$body = json_decode($body);
298 298
 
299
-			foreach ( $body->translation_sets as $set ) {
300
-				if ( ! property_exists( $set, 'wp_locale' ) ) {
299
+			foreach ($body->translation_sets as $set) {
300
+				if ( ! property_exists($set, 'wp_locale')) {
301 301
 					continue;
302 302
 				}
303 303
 
304
-				if ( $this->locale == $set->wp_locale ) {
304
+				if ($this->locale == $set->wp_locale) {
305 305
 					return $set;
306 306
 				}
307 307
 			}
@@ -317,8 +317,8 @@  discard block
 block discarded – undo
317 317
 	 *
318 318
 	 * @access private
319 319
 	 */
320
-	private function parse_translation_set( $set ) {
321
-		if ( $this->translation_exists && is_object( $set ) ) {
320
+	private function parse_translation_set($set) {
321
+		if ($this->translation_exists && is_object($set)) {
322 322
 			$this->locale_name        = $set->name;
323 323
 			$this->percent_translated = $set->percent_translated;
324 324
 		} else {
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 	}
329 329
 }
330 330
 
331
-$give_i18n = new Give_i18n_Banner( array(
331
+$give_i18n = new Give_i18n_Banner(array(
332 332
 		'hook'          => 'admin_notices',
333 333
 		'glotpress_url' => 'https://translate.wordpress.org/api/projects/wp-plugins/give/stable/',
334
-	) );
334
+	));
Please login to merge, or discard this patch.
includes/admin/shortcodes/abstract-shortcode-generator.php 1 patch
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly.
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -62,11 +62,11 @@  discard block
 block discarded – undo
62 62
 	 *
63 63
 	 * @since 1.0
64 64
 	 */
65
-	public function __construct( $shortcode ) {
65
+	public function __construct($shortcode) {
66 66
 
67 67
 		$this->shortcode_tag = $shortcode;
68 68
 
69
-		add_action( 'admin_init', array( $this, 'init' ) );
69
+		add_action('admin_init', array($this, 'init'));
70 70
 
71 71
 	}
72 72
 
@@ -77,9 +77,9 @@  discard block
 block discarded – undo
77 77
 	 */
78 78
 	public function init() {
79 79
 
80
-		if ( $this->shortcode_tag ) {
80
+		if ($this->shortcode_tag) {
81 81
 
82
-			$this->self = get_class( $this );
82
+			$this->self = get_class($this);
83 83
 
84 84
 			$this->errors   = array();
85 85
 			$this->required = array();
@@ -88,18 +88,18 @@  discard block
 block discarded – undo
88 88
 			$fields = $this->get_fields();
89 89
 
90 90
 			$defaults = array(
91
-				'btn_close' => esc_html__( 'Close', 'give' ),
92
-				'btn_okay'  => esc_html__( 'Insert Shortcode', 'give' ),
91
+				'btn_close' => esc_html__('Close', 'give'),
92
+				'btn_okay'  => esc_html__('Insert Shortcode', 'give'),
93 93
 				'errors'    => $this->errors,
94 94
 				'fields'    => $fields,
95
-				'label'     => '[' . $this->shortcode_tag . ']',
95
+				'label'     => '['.$this->shortcode_tag.']',
96 96
 				'required'  => $this->required,
97
-				'title'     => esc_html__( 'Insert Shortcode', 'give' ),
97
+				'title'     => esc_html__('Insert Shortcode', 'give'),
98 98
 			);
99 99
 
100
-			if ( user_can_richedit() ) {
100
+			if (user_can_richedit()) {
101 101
 
102
-				Give_Shortcode_Button::$shortcodes[ $this->shortcode_tag ] = wp_parse_args( $this->shortcode, $defaults );
102
+				Give_Shortcode_Button::$shortcodes[$this->shortcode_tag] = wp_parse_args($this->shortcode, $defaults);
103 103
 
104 104
 			}
105 105
 		}
@@ -128,13 +128,13 @@  discard block
 block discarded – undo
128 128
 	 *
129 129
 	 * @since 1.0
130 130
 	 */
131
-	protected function generate_fields( $defined_fields ) {
131
+	protected function generate_fields($defined_fields) {
132 132
 
133 133
 		$fields = array();
134 134
 
135
-		if ( is_array( $defined_fields ) ) {
135
+		if (is_array($defined_fields)) {
136 136
 
137
-			foreach ( $defined_fields as $field ) {
137
+			foreach ($defined_fields as $field) {
138 138
 
139 139
 				$defaults = array(
140 140
 					'label'       => false,
@@ -145,14 +145,14 @@  discard block
 block discarded – undo
145 145
 					'type'        => '',
146 146
 				);
147 147
 
148
-				$field  = wp_parse_args( (array) $field, $defaults );
149
-				$method = 'generate_' . strtolower( $field['type'] );
148
+				$field  = wp_parse_args((array) $field, $defaults);
149
+				$method = 'generate_'.strtolower($field['type']);
150 150
 
151
-				if ( method_exists( $this, $method ) ) {
151
+				if (method_exists($this, $method)) {
152 152
 
153
-					$field = call_user_func( array( $this, $method ), $field );
153
+					$field = call_user_func(array($this, $method), $field);
154 154
 
155
-					if ( $field ) {
155
+					if ($field) {
156 156
 						$fields[] = $field;
157 157
 					}
158 158
 				}
@@ -172,23 +172,23 @@  discard block
 block discarded – undo
172 172
 	protected function get_fields() {
173 173
 
174 174
 		$defined_fields   = $this->define_fields();
175
-		$generated_fields = $this->generate_fields( $defined_fields );
175
+		$generated_fields = $this->generate_fields($defined_fields);
176 176
 
177 177
 		$errors = array();
178 178
 
179
-		if ( ! empty( $this->errors ) ) {
180
-			foreach ( $this->required as $name => $alert ) {
179
+		if ( ! empty($this->errors)) {
180
+			foreach ($this->required as $name => $alert) {
181 181
 				// Using WordPress function in place of array_column wp_list_pluck as it support older version as well.
182
-				if ( false === array_search( $name, give_list_pluck( $generated_fields, 'name' ) ) ) {
182
+				if (false === array_search($name, give_list_pluck($generated_fields, 'name'))) {
183 183
 
184
-					$errors[] = $this->errors[ $name ];
184
+					$errors[] = $this->errors[$name];
185 185
 				}
186 186
 			}
187 187
 
188 188
 			$this->errors = $errors;
189 189
 		}
190 190
 
191
-		if ( ! empty( $errors ) ) {
191
+		if ( ! empty($errors)) {
192 192
 
193 193
 			return $errors;
194 194
 		}
@@ -205,9 +205,9 @@  discard block
 block discarded – undo
205 205
 	 *
206 206
 	 * @since 1.0
207 207
 	 */
208
-	protected function generate_container( $field ) {
208
+	protected function generate_container($field) {
209 209
 
210
-		if ( array_key_exists( 'html', $field ) ) {
210
+		if (array_key_exists('html', $field)) {
211 211
 
212 212
 			return array(
213 213
 				'type' => $field['type'],
@@ -227,9 +227,9 @@  discard block
 block discarded – undo
227 227
 	 *
228 228
 	 * @since 1.0
229 229
 	 */
230
-	protected function generate_listbox( $field ) {
230
+	protected function generate_listbox($field) {
231 231
 
232
-		$listbox = shortcode_atts( array(
232
+		$listbox = shortcode_atts(array(
233 233
 			'label'    => '',
234 234
 			'minWidth' => '',
235 235
 			'name'     => false,
@@ -237,27 +237,27 @@  discard block
 block discarded – undo
237 237
 			'type'     => '',
238 238
 			'value'    => '',
239 239
 			'classes'  => ''
240
-		), $field );
240
+		), $field);
241 241
 
242
-		if ( $this->validate( $field ) ) {
242
+		if ($this->validate($field)) {
243 243
 
244 244
 			$new_listbox = array();
245 245
 
246
-			foreach ( $listbox as $key => $value ) {
246
+			foreach ($listbox as $key => $value) {
247 247
 
248
-				if ( $key == 'value' && empty( $value ) ) {
249
-					$new_listbox[ $key ] = $listbox['name'];
250
-				} else if ( $value ) {
251
-					$new_listbox[ $key ] = $value;
248
+				if ($key == 'value' && empty($value)) {
249
+					$new_listbox[$key] = $listbox['name'];
250
+				} else if ($value) {
251
+					$new_listbox[$key] = $value;
252 252
 				}
253 253
 			}
254 254
 
255 255
 			// do not reindex array!
256 256
 			$field['options'] = array(
257
-				                    '' => ( $field['placeholder'] ? $field['placeholder'] : esc_attr__( '- Select -', 'give' ) ),
257
+				                    '' => ($field['placeholder'] ? $field['placeholder'] : esc_attr__('- Select -', 'give')),
258 258
 			                    ) + $field['options'];
259 259
 
260
-			foreach ( $field['options'] as $value => $text ) {
260
+			foreach ($field['options'] as $value => $text) {
261 261
 				$new_listbox['values'][] = array(
262 262
 					'text'  => $text,
263 263
 					'value' => $value,
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 	 *
280 280
 	 * @since 1.0
281 281
 	 */
282
-	protected function generate_post( $field ) {
282
+	protected function generate_post($field) {
283 283
 
284 284
 		$args = array(
285 285
 			'post_type'      => 'post',
@@ -288,23 +288,23 @@  discard block
 block discarded – undo
288 288
 			'posts_per_page' => 30,
289 289
 		);
290 290
 
291
-		$args    = wp_parse_args( (array) $field['query_args'], $args );
292
-		$posts   = get_posts( $args );
291
+		$args    = wp_parse_args((array) $field['query_args'], $args);
292
+		$posts   = get_posts($args);
293 293
 		$options = array();
294 294
 
295
-		if ( $posts ) {
296
-			foreach ( $posts as $post ) {
297
-				$options[ absint( $post->ID ) ] = ( empty( $post->post_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $post->ID ) : $post->post_title );
295
+		if ($posts) {
296
+			foreach ($posts as $post) {
297
+				$options[absint($post->ID)] = (empty($post->post_title) ? sprintf(__('Untitled (#%s)', 'give'), $post->ID) : $post->post_title);
298 298
 			}
299 299
 
300 300
 			$field['type']    = 'listbox';
301 301
 			$field['options'] = $options;
302 302
 
303
-			return $this->generate_listbox( $field );
303
+			return $this->generate_listbox($field);
304 304
 		}
305 305
 
306 306
 		// perform validation here before returning false
307
-		$this->validate( $field );
307
+		$this->validate($field);
308 308
 
309 309
 		return false;
310 310
 	}
@@ -318,9 +318,9 @@  discard block
 block discarded – undo
318 318
 	 *
319 319
 	 * @since 1.0
320 320
 	 */
321
-	protected function generate_textbox( $field ) {
321
+	protected function generate_textbox($field) {
322 322
 
323
-		$textbox = shortcode_atts( array(
323
+		$textbox = shortcode_atts(array(
324 324
 			'label'     => '',
325 325
 			'maxLength' => '',
326 326
 			'minHeight' => '',
@@ -331,10 +331,10 @@  discard block
 block discarded – undo
331 331
 			'type'      => '',
332 332
 			'value'     => '',
333 333
 			'classes'   => ''
334
-		), $field );
334
+		), $field);
335 335
 
336
-		if ( $this->validate( $field ) ) {
337
-			return array_filter( $textbox, array( $this, 'return_textbox_value' ) );
336
+		if ($this->validate($field)) {
337
+			return array_filter($textbox, array($this, 'return_textbox_value'));
338 338
 		}
339 339
 
340 340
 		return false;
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 	 *
348 348
 	 * @return bool
349 349
 	 */
350
-	function return_textbox_value( $value ) {
350
+	function return_textbox_value($value) {
351 351
 		return $value !== '';
352 352
 	}
353 353
 
@@ -363,9 +363,9 @@  discard block
 block discarded – undo
363 363
 	 *
364 364
 	 * @since 1.0
365 365
 	 */
366
-	protected function validate( $field ) {
366
+	protected function validate($field) {
367 367
 
368
-		extract( shortcode_atts(
368
+		extract(shortcode_atts(
369 369
 				array(
370 370
 					'name'     => false,
371 371
 					'required' => false,
@@ -373,36 +373,36 @@  discard block
 block discarded – undo
373 373
 				), $field )
374 374
 		);
375 375
 
376
-		if ( $name ) {
376
+		if ($name) {
377 377
 
378
-			if ( isset( $required['error'] ) ) {
378
+			if (isset($required['error'])) {
379 379
 
380 380
 				$error = array(
381 381
 					'type' => 'container',
382 382
 					'html' => $required['error'],
383 383
 				);
384 384
 
385
-				$this->errors[ $name ] = $this->generate_container( $error );
385
+				$this->errors[$name] = $this->generate_container($error);
386 386
 			}
387 387
 
388
-			if ( ! ! $required || is_array( $required ) ) {
388
+			if ( ! ! $required || is_array($required)) {
389 389
 
390
-				$alert = esc_html__( 'Some of the shortcode options are required.', 'give' );
390
+				$alert = esc_html__('Some of the shortcode options are required.', 'give');
391 391
 
392
-				if ( isset( $required['alert'] ) ) {
392
+				if (isset($required['alert'])) {
393 393
 
394 394
 					$alert = $required['alert'];
395 395
 
396
-				} else if ( ! empty( $label ) ) {
396
+				} else if ( ! empty($label)) {
397 397
 
398 398
 					$alert = sprintf(
399 399
 					/* translators: %s: option label */
400
-						esc_html__( 'The "%s" option is required.', 'give' ),
401
-						str_replace( ':', '', $label )
400
+						esc_html__('The "%s" option is required.', 'give'),
401
+						str_replace(':', '', $label)
402 402
 					);
403 403
 				}
404 404
 
405
-				$this->required[ $name ] = $alert;
405
+				$this->required[$name] = $alert;
406 406
 			}
407 407
 
408 408
 			return true;
Please login to merge, or discard this patch.
includes/class-give-license-handler.php 1 patch
Spacing   +141 added lines, -141 removed lines patch added patch discarded remove patch
@@ -10,11 +10,11 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
17
-if ( ! class_exists( 'Give_License' ) ) :
17
+if ( ! class_exists('Give_License')) :
18 18
 
19 19
 	/**
20 20
 	 * Give_License Class
@@ -143,27 +143,27 @@  discard block
 block discarded – undo
143 143
 		 * @param string $_checkout_url
144 144
 		 * @param string $_account_url
145 145
 		 */
146
-		public function __construct( $_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null ) {
146
+		public function __construct($_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null) {
147 147
 
148 148
 			$give_options = give_get_settings();
149 149
 
150 150
 			$this->file             = $_file;
151 151
 			$this->item_name        = $_item_name;
152
-			$this->item_shortname   = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $this->item_name ) ) );
152
+			$this->item_shortname   = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($this->item_name)));
153 153
 			$this->version          = $_version;
154
-			$this->license          = isset( $give_options[ $this->item_shortname . '_license_key' ] ) ? trim( $give_options[ $this->item_shortname . '_license_key' ] ) : '';
155
-			$this->license_data     = get_option( $this->item_shortname . '_license_active' );
154
+			$this->license          = isset($give_options[$this->item_shortname.'_license_key']) ? trim($give_options[$this->item_shortname.'_license_key']) : '';
155
+			$this->license_data     = get_option($this->item_shortname.'_license_active');
156 156
 			$this->author           = $_author;
157
-			$this->api_url          = is_null( $_api_url ) ? $this->api_url : $_api_url;
158
-			$this->checkout_url     = is_null( $_checkout_url ) ? $this->checkout_url : $_checkout_url;
159
-			$this->account_url      = is_null( $_account_url ) ? $this->account_url : $_account_url;
157
+			$this->api_url          = is_null($_api_url) ? $this->api_url : $_api_url;
158
+			$this->checkout_url     = is_null($_checkout_url) ? $this->checkout_url : $_checkout_url;
159
+			$this->account_url      = is_null($_account_url) ? $this->account_url : $_account_url;
160 160
 			$this->auto_updater_obj = null;
161 161
 
162 162
 			// Add Setting for Give Add-on activation status.
163
-			$is_addon_activated = get_option( 'give_is_addon_activated' );
164
-			if( ! $is_addon_activated && is_object( $this ) && sizeof( $this ) > 0 ) {
165
-				update_option( 'give_is_addon_activated', true );
166
-				Give_Cache::set( 'give_cache_hide_license_notice_after_activation', true, DAY_IN_SECONDS );
163
+			$is_addon_activated = get_option('give_is_addon_activated');
164
+			if ( ! $is_addon_activated && is_object($this) && sizeof($this) > 0) {
165
+				update_option('give_is_addon_activated', true);
166
+				Give_Cache::set('give_cache_hide_license_notice_after_activation', true, DAY_IN_SECONDS);
167 167
 			}
168 168
 
169 169
 			// Setup hooks
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 		 */
185 185
 		private function includes() {
186 186
 
187
-			if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) {
187
+			if ( ! class_exists('EDD_SL_Plugin_Updater')) {
188 188
 				require_once 'admin/EDD_SL_Plugin_Updater.php';
189 189
 			}
190 190
 		}
@@ -202,30 +202,30 @@  discard block
 block discarded – undo
202 202
 		private function hooks() {
203 203
 
204 204
 			// Register settings.
205
-			add_filter( 'give_settings_licenses', array( $this, 'settings' ), 1 );
205
+			add_filter('give_settings_licenses', array($this, 'settings'), 1);
206 206
 
207 207
 			// Activate license key on settings save.
208
-			add_action( 'admin_init', array( $this, 'activate_license' ) );
208
+			add_action('admin_init', array($this, 'activate_license'));
209 209
 
210 210
 			// Deactivate license key.
211
-			add_action( 'admin_init', array( $this, 'deactivate_license' ) );
211
+			add_action('admin_init', array($this, 'deactivate_license'));
212 212
 
213 213
 			// Updater.
214
-			add_action( 'admin_init', array( $this, 'auto_updater' ), 0 );
215
-			add_action( 'admin_notices', array( $this, 'notices' ) );
214
+			add_action('admin_init', array($this, 'auto_updater'), 0);
215
+			add_action('admin_notices', array($this, 'notices'));
216 216
 
217 217
 			// Check license weekly.
218
-			Give_Cron::add_weekly_event( array( $this, 'weekly_license_check' ) );
219
-			add_action( 'give_validate_license_when_site_migrated', array( $this, 'weekly_license_check' ) );
218
+			Give_Cron::add_weekly_event(array($this, 'weekly_license_check'));
219
+			add_action('give_validate_license_when_site_migrated', array($this, 'weekly_license_check'));
220 220
 
221 221
 			// Check subscription weekly.
222
-			Give_Cron::add_weekly_event( array( $this, 'weekly_subscription_check' ) );
223
-			add_action( 'give_validate_license_when_site_migrated', array( $this, 'weekly_subscription_check' ) );
222
+			Give_Cron::add_weekly_event(array($this, 'weekly_subscription_check'));
223
+			add_action('give_validate_license_when_site_migrated', array($this, 'weekly_subscription_check'));
224 224
 
225 225
 			// Show addon notice on plugin page.
226
-			$plugin_name = explode( 'plugins/', $this->file );
227
-			$plugin_name = end( $plugin_name );
228
-			add_action( "after_plugin_row_{$plugin_name}", array( $this, 'plugin_page_notices' ), 10, 3 );
226
+			$plugin_name = explode('plugins/', $this->file);
227
+			$plugin_name = end($plugin_name);
228
+			add_action("after_plugin_row_{$plugin_name}", array($this, 'plugin_page_notices'), 10, 3);
229 229
 
230 230
 		}
231 231
 
@@ -265,16 +265,16 @@  discard block
 block discarded – undo
265 265
 		 *
266 266
 		 * @return array           License settings.
267 267
 		 */
268
-		public function settings( $settings ) {
268
+		public function settings($settings) {
269 269
 
270 270
 			$give_license_settings = array(
271 271
 				array(
272 272
 					'name'    => $this->item_name,
273
-					'id'      => $this->item_shortname . '_license_key',
273
+					'id'      => $this->item_shortname.'_license_key',
274 274
 					'desc'    => '',
275 275
 					'type'    => 'license_key',
276 276
 					'options' => array(
277
-						'license'      => get_option( $this->item_shortname . '_license_active' ),
277
+						'license'      => get_option($this->item_shortname.'_license_active'),
278 278
 						'shortname'    => $this->item_shortname,
279 279
 						'item_name'    => $this->item_name,
280 280
 						'api_url'      => $this->api_url,
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 				),
286 286
 			);
287 287
 
288
-			return array_merge( $settings, $give_license_settings );
288
+			return array_merge($settings, $give_license_settings);
289 289
 		}
290 290
 
291 291
 		/**
@@ -300,18 +300,18 @@  discard block
 block discarded – undo
300 300
 		 *
301 301
 		 * @return array           License settings content.
302 302
 		 */
303
-		public function license_settings_content( $settings ) {
303
+		public function license_settings_content($settings) {
304 304
 
305 305
 			$give_license_settings = array(
306 306
 				array(
307
-					'name' => __( 'Add-on Licenses', 'give' ),
307
+					'name' => __('Add-on Licenses', 'give'),
308 308
 					'desc' => '<hr>',
309 309
 					'type' => 'give_title',
310 310
 					'id'   => 'give_title',
311 311
 				),
312 312
 			);
313 313
 
314
-			return array_merge( $settings, $give_license_settings );
314
+			return array_merge($settings, $give_license_settings);
315 315
 		}
316 316
 
317 317
 		/**
@@ -326,56 +326,56 @@  discard block
 block discarded – undo
326 326
 		 */
327 327
 		public function activate_license() {
328 328
 			// Bailout.
329
-			if( ! $this->__is_user_can_edit_license() ) {
329
+			if ( ! $this->__is_user_can_edit_license()) {
330 330
 				return;
331 331
 			}
332 332
 
333 333
 			// Allow third party addon developers to handle license activation.
334
-			if ( $this->__is_third_party_addon() ) {
335
-				do_action( 'give_activate_license', $this );
334
+			if ($this->__is_third_party_addon()) {
335
+				do_action('give_activate_license', $this);
336 336
 
337 337
 				return;
338 338
 			}
339 339
 
340 340
 			// Delete previous license setting if a empty license key submitted.
341
-			if ( empty( $_POST[ $this->item_shortname . '_license_key' ] ) ) {
342
-				delete_option( $this->item_shortname . '_license_active' );
341
+			if (empty($_POST[$this->item_shortname.'_license_key'])) {
342
+				delete_option($this->item_shortname.'_license_active');
343 343
 
344 344
 				return;
345 345
 			}
346 346
 
347 347
 			// Do not simultaneously activate add-ons if the user want to deactivate a specific add-on.
348
-			foreach ( $_POST as $key => $value ) {
349
-				if ( false !== strpos( $key, 'license_key_deactivate' ) ) {
348
+			foreach ($_POST as $key => $value) {
349
+				if (false !== strpos($key, 'license_key_deactivate')) {
350 350
 					// Don't activate a key when deactivating a different key
351 351
 					return;
352 352
 				}
353 353
 			}
354 354
 
355 355
 			// Check if plugin previously installed.
356
-			if ( $this->is_valid_license() ) {
356
+			if ($this->is_valid_license()) {
357 357
 				return;
358 358
 			}
359 359
 
360 360
 			// Get license key.
361
-			$this->license = sanitize_text_field( $_POST[ $this->item_shortname . '_license_key' ] );
361
+			$this->license = sanitize_text_field($_POST[$this->item_shortname.'_license_key']);
362 362
 
363 363
 			// Delete previous license key from subscription if previously added.
364 364
 			$this->__remove_license_key_from_subscriptions();
365 365
 
366 366
 			// Make sure there are no api errors.
367
-			if ( ! ( $license_data = $this->get_license_info( 'activate_license' ) ) ) {
367
+			if ( ! ($license_data = $this->get_license_info('activate_license'))) {
368 368
 				return;
369 369
 			}
370 370
 
371 371
 			// Tell WordPress to look for updates.
372
-			set_site_transient( 'update_plugins', null );
372
+			set_site_transient('update_plugins', null);
373 373
 
374 374
 			// Add license data.
375
-			update_option( $this->item_shortname . '_license_active', $license_data );
375
+			update_option($this->item_shortname.'_license_active', $license_data);
376 376
 
377 377
 			// Add license key.
378
-			give_update_option( "{$this->item_shortname}_license_key", $this->license );
378
+			give_update_option("{$this->item_shortname}_license_key", $this->license);
379 379
 
380 380
 			// Check subscription for license key and store this to db (if any).
381 381
 			$this->__single_subscription_check();
@@ -393,33 +393,33 @@  discard block
 block discarded – undo
393 393
 		 */
394 394
 		public function deactivate_license() {
395 395
 			// Bailout.
396
-			if( ! $this->__is_user_can_edit_license() ) {
396
+			if ( ! $this->__is_user_can_edit_license()) {
397 397
 				return;
398 398
 			}
399 399
 
400 400
 			// Allow third party add-on developers to handle license deactivation.
401
-			if ( $this->__is_third_party_addon() ) {
402
-				do_action( 'give_deactivate_license', $this );
401
+			if ($this->__is_third_party_addon()) {
402
+				do_action('give_deactivate_license', $this);
403 403
 
404 404
 				return;
405 405
 			}
406 406
 
407 407
 			// Run on deactivate button press.
408
-			if ( isset( $_POST[ $this->item_shortname . '_license_key_deactivate' ] ) ) {
408
+			if (isset($_POST[$this->item_shortname.'_license_key_deactivate'])) {
409 409
 
410 410
 				// Make sure there are no api errors.
411
-				if ( ! ( $license_data = $this->get_license_info( 'deactivate_license' ) ) ) {
411
+				if ( ! ($license_data = $this->get_license_info('deactivate_license'))) {
412 412
 					return;
413 413
 				}
414 414
 
415 415
 				// Ensure deactivated successfully.
416
-				if ( isset( $license_data->success ) ) {
416
+				if (isset($license_data->success)) {
417 417
 
418 418
 					// Remove license data.
419
-					delete_option( $this->item_shortname . '_license_active' );
419
+					delete_option($this->item_shortname.'_license_active');
420 420
 
421 421
 					// Delete licence data.
422
-					give_delete_option( $this->item_shortname . '_license_key' );
422
+					give_delete_option($this->item_shortname.'_license_key');
423 423
 
424 424
 					// Remove license key from subscriptions if exist.
425 425
 					$this->__remove_license_key_from_subscriptions();
@@ -439,25 +439,25 @@  discard block
 block discarded – undo
439 439
 		public function weekly_license_check() {
440 440
 
441 441
 			if (
442
-				! empty( $_POST['give_settings'] ) ||
443
-				empty( $this->license )
442
+				! empty($_POST['give_settings']) ||
443
+				empty($this->license)
444 444
 			) {
445 445
 				return;
446 446
 			}
447 447
 
448 448
 			// Allow third party add-on developers to handle their license check.
449
-			if ( $this->__is_third_party_addon() ) {
450
-				do_action( 'give_weekly_license_check', $this );
449
+			if ($this->__is_third_party_addon()) {
450
+				do_action('give_weekly_license_check', $this);
451 451
 
452 452
 				return;
453 453
 			}
454 454
 
455 455
 			// Make sure there are no api errors.
456
-			if ( ! ( $license_data = $this->get_license_info( 'check_license' ) ) ) {
456
+			if ( ! ($license_data = $this->get_license_info('check_license'))) {
457 457
 				return;
458 458
 			}
459 459
 
460
-			update_option( $this->item_shortname . '_license_active', $license_data );
460
+			update_option($this->item_shortname.'_license_active', $license_data);
461 461
 
462 462
 			return;
463 463
 		}
@@ -473,21 +473,21 @@  discard block
 block discarded – undo
473 473
 		public function weekly_subscription_check() {
474 474
 			// Bailout.
475 475
 			if (
476
-				! empty( $_POST['give_settings'] ) ||
477
-				empty( $this->license )
476
+				! empty($_POST['give_settings']) ||
477
+				empty($this->license)
478 478
 			) {
479 479
 				return;
480 480
 			}
481 481
 
482 482
 			// Remove old subscription data.
483
-			if ( absint( get_option( '_give_subscriptions_edit_last', true ) ) < current_time( 'timestamp', 1 ) ) {
484
-				delete_option( 'give_subscriptions' );
485
-				update_option( '_give_subscriptions_edit_last', strtotime( '+ 1 day', current_time( 'timestamp', 1 ) ) );
483
+			if (absint(get_option('_give_subscriptions_edit_last', true)) < current_time('timestamp', 1)) {
484
+				delete_option('give_subscriptions');
485
+				update_option('_give_subscriptions_edit_last', strtotime('+ 1 day', current_time('timestamp', 1)));
486 486
 			}
487 487
 
488 488
 			// Allow third party add-on developers to handle their subscription check.
489
-			if ( $this->__is_third_party_addon() ) {
490
-				do_action( 'give_weekly_subscription_check', $this );
489
+			if ($this->__is_third_party_addon()) {
490
+				do_action('give_weekly_subscription_check', $this);
491 491
 
492 492
 				return;
493 493
 			}
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
 		 * @return void
505 505
 		 */
506 506
 		private function __single_subscription_check() {
507
-			if ( empty( $this->license ) ) {
507
+			if (empty($this->license)) {
508 508
 				return;
509 509
 			}
510 510
 
@@ -512,29 +512,29 @@  discard block
 block discarded – undo
512 512
 			// Do not get confused with edd_action check_subscription.
513 513
 			// By default edd software licensing api does not have api to check subscription.
514 514
 			// This is a custom feature to check subscriptions.
515
-			if ( ! ( $subscription_data = $this->get_license_info( 'check_subscription', true ) ) ) {
515
+			if ( ! ($subscription_data = $this->get_license_info('check_subscription', true))) {
516 516
 				return;
517 517
 			}
518 518
 
519 519
 
520
-			if ( ! empty( $subscription_data['success'] ) && absint( $subscription_data['success'] ) ) {
521
-				$subscriptions = get_option( 'give_subscriptions', array() );
520
+			if ( ! empty($subscription_data['success']) && absint($subscription_data['success'])) {
521
+				$subscriptions = get_option('give_subscriptions', array());
522 522
 
523 523
 				// Update subscription data only if subscription does not exist already.
524
-				$subscriptions[ $subscription_data['id'] ]            = $subscription_data;
524
+				$subscriptions[$subscription_data['id']] = $subscription_data;
525 525
 
526 526
 
527 527
 				// Initiate default set of license for subscription.
528
-				if( ! isset( $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) {
529
-					$subscriptions[ $subscription_data['id']]['licenses'] = array();
528
+				if ( ! isset($subscriptions[$subscription_data['id']]['licenses'])) {
529
+					$subscriptions[$subscription_data['id']]['licenses'] = array();
530 530
 				}
531 531
 
532 532
 				// Store licenses for subscription.
533
-				if ( ! in_array( $this->license, $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) {
534
-					$subscriptions[ $subscription_data['id']]['licenses'][] = $this->license;
533
+				if ( ! in_array($this->license, $subscriptions[$subscription_data['id']]['licenses'])) {
534
+					$subscriptions[$subscription_data['id']]['licenses'][] = $this->license;
535 535
 				}
536 536
 
537
-				update_option( 'give_subscriptions', $subscriptions );
537
+				update_option('give_subscriptions', $subscriptions);
538 538
 			}
539 539
 		}
540 540
 
@@ -548,12 +548,12 @@  discard block
 block discarded – undo
548 548
 		 */
549 549
 		public function notices() {
550 550
 
551
-			if ( ! current_user_can( 'manage_give_settings' ) ) {
551
+			if ( ! current_user_can('manage_give_settings')) {
552 552
 				return;
553 553
 			}
554 554
 
555 555
 			// Do not show licenses notices on license tab.
556
-			if ( 'licenses' === give_get_current_setting_tab() ) {
556
+			if ('licenses' === give_get_current_setting_tab()) {
557 557
 				return;
558 558
 			}
559 559
 
@@ -562,118 +562,118 @@  discard block
 block discarded – undo
562 562
 			static $addon_license_key_in_subscriptions;
563 563
 
564 564
 			// Set default value.
565
-			$addon_license_key_in_subscriptions = ! empty( $addon_license_key_in_subscriptions ) ? $addon_license_key_in_subscriptions : array();
565
+			$addon_license_key_in_subscriptions = ! empty($addon_license_key_in_subscriptions) ? $addon_license_key_in_subscriptions : array();
566 566
 			$messages                           = array();
567 567
 
568 568
 			// Check whether admin has Give Add-on activated since 24 hours?
569
-			$is_license_notice_hidden = Give_Cache::get( 'give_cache_hide_license_notice_after_activation' );
569
+			$is_license_notice_hidden = Give_Cache::get('give_cache_hide_license_notice_after_activation');
570 570
 
571 571
 			// Display Invalid License notice, if its more than 24 hours since first Give Add-on activation.
572 572
 			if (
573
-				empty( $this->license )
574
-				&& empty( $showed_invalid_message )
575
-				&& ( false === $is_license_notice_hidden )
573
+				empty($this->license)
574
+				&& empty($showed_invalid_message)
575
+				&& (false === $is_license_notice_hidden)
576 576
 			) {
577 577
 
578
-				Give()->notices->register_notice( array(
578
+				Give()->notices->register_notice(array(
579 579
 					'id'               => 'give-invalid-license',
580 580
 					'type'             => 'error',
581 581
 					'description'      => sprintf(
582
-						__( 'You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give' ),
583
-						admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' )
582
+						__('You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give'),
583
+						admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses')
584 584
 					),
585 585
 					'dismissible_type' => 'user',
586 586
 					'dismiss_interval' => 'shortly',
587
-				) );
587
+				));
588 588
 
589 589
 				$showed_invalid_message = true;
590 590
 
591 591
 			}
592 592
 
593 593
 			// Get subscriptions.
594
-			$subscriptions = get_option( 'give_subscriptions' );
594
+			$subscriptions = get_option('give_subscriptions');
595 595
 
596 596
 			// Show subscription messages.
597
-			if ( ! empty( $subscriptions ) && ! $showed_subscriptions_message ) {
597
+			if ( ! empty($subscriptions) && ! $showed_subscriptions_message) {
598 598
 
599
-				foreach ( $subscriptions as $subscription ) {
599
+				foreach ($subscriptions as $subscription) {
600 600
 					// Subscription expires timestamp.
601
-					$subscription_expires = strtotime( $subscription['expires'] );
601
+					$subscription_expires = strtotime($subscription['expires']);
602 602
 
603 603
 					// Start showing subscriptions message before one week of renewal date.
604
-					if ( strtotime( '- 7 days', $subscription_expires ) > current_time( 'timestamp', 1 ) ) {
604
+					if (strtotime('- 7 days', $subscription_expires) > current_time('timestamp', 1)) {
605 605
 						continue;
606 606
 					}
607 607
 
608 608
 					// Check if subscription message already exist in messages.
609
-					if ( array_key_exists( $subscription['id'], $messages ) ) {
609
+					if (array_key_exists($subscription['id'], $messages)) {
610 610
 						continue;
611 611
 					}
612 612
 
613 613
 					// Check if license already expired.
614
-					if ( strtotime( $subscription['expires'] ) < current_time( 'timestamp', 1 ) ) {
615
-						Give()->notices->register_notice( array(
614
+					if (strtotime($subscription['expires']) < current_time('timestamp', 1)) {
615
+						Give()->notices->register_notice(array(
616 616
 							'id'               => "give-expired-subscription-{$subscription['id']}",
617 617
 							'type'             => 'error',
618 618
 							'description'      => sprintf(
619
-								__( 'Your Give add-on license expired for payment <a href="%1$s" target="_blank">#%2$d</a>. <a href="%3$s" target="_blank">Click to renew an existing license</a> or %4$s.', 'give' ),
620
-								urldecode( $subscription['invoice_url'] ),
619
+								__('Your Give add-on license expired for payment <a href="%1$s" target="_blank">#%2$d</a>. <a href="%3$s" target="_blank">Click to renew an existing license</a> or %4$s.', 'give'),
620
+								urldecode($subscription['invoice_url']),
621 621
 								$subscription['payment_id'],
622 622
 								"{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired",
623 623
 								Give()->notices->get_dismiss_link(array(
624
-									'title' => __( 'Click here if already renewed', 'give' ),
624
+									'title' => __('Click here if already renewed', 'give'),
625 625
 									'dismissible_type'      => 'user',
626 626
 									'dismiss_interval'      => 'permanent',
627 627
 								))
628 628
 							),
629 629
 							'dismissible_type' => 'user',
630 630
 							'dismiss_interval' => 'shortly',
631
-						) );
631
+						));
632 632
 					} else {
633
-						Give()->notices->register_notice( array(
633
+						Give()->notices->register_notice(array(
634 634
 							'id'               => "give-expires-subscription-{$subscription['id']}",
635 635
 							'type'             => 'error',
636 636
 							'description'      => sprintf(
637
-								__( 'Your Give add-on license will expire in %1$s for payment <a href="%2$s" target="_blank">#%3$d</a>. <a href="%4$s" target="_blank">Click to renew an existing license</a> or %5$s.', 'give' ),
638
-								human_time_diff( current_time( 'timestamp', 1 ), strtotime( $subscription['expires'] ) ),
639
-								urldecode( $subscription['invoice_url'] ),
637
+								__('Your Give add-on license will expire in %1$s for payment <a href="%2$s" target="_blank">#%3$d</a>. <a href="%4$s" target="_blank">Click to renew an existing license</a> or %5$s.', 'give'),
638
+								human_time_diff(current_time('timestamp', 1), strtotime($subscription['expires'])),
639
+								urldecode($subscription['invoice_url']),
640 640
 								$subscription['payment_id'],
641 641
 								"{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired",
642 642
 								Give()->notices->get_dismiss_link(array(
643
-									'title' => __( 'Click here if already renewed', 'give' ),
643
+									'title' => __('Click here if already renewed', 'give'),
644 644
 									'dismissible_type'      => 'user',
645 645
 									'dismiss_interval'      => 'permanent',
646 646
 								))
647 647
 							),
648 648
 							'dismissible_type' => 'user',
649 649
 							'dismiss_interval' => 'shortly',
650
-						) );
650
+						));
651 651
 					}
652 652
 
653 653
 					// Stop validation for these license keys.
654
-					$addon_license_key_in_subscriptions = array_merge( $addon_license_key_in_subscriptions, $subscription['licenses'] );
654
+					$addon_license_key_in_subscriptions = array_merge($addon_license_key_in_subscriptions, $subscription['licenses']);
655 655
 				}// End foreach().
656 656
 				$showed_subscriptions_message = true;
657 657
 			}// End if().
658 658
 
659 659
 			// Show Non Subscription Give Add-on messages.
660 660
 			if (
661
-				! in_array( $this->license, $addon_license_key_in_subscriptions )
662
-				&& ! empty( $this->license )
663
-				&& empty( $showed_invalid_message )
661
+				! in_array($this->license, $addon_license_key_in_subscriptions)
662
+				&& ! empty($this->license)
663
+				&& empty($showed_invalid_message)
664 664
 				&& ! $this->is_valid_license()
665 665
 			) {
666 666
 
667
-				Give()->notices->register_notice( array(
667
+				Give()->notices->register_notice(array(
668 668
 					'id'               => 'give-invalid-license',
669 669
 					'type'             => 'error',
670 670
 					'description'      => sprintf(
671
-						__( 'You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give' ),
672
-						admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' )
671
+						__('You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give'),
672
+						admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses')
673 673
 					),
674 674
 					'dismissible_type' => 'user',
675 675
 					'dismiss_interval' => 'shortly',
676
-				) );
676
+				));
677 677
 
678 678
 				$showed_invalid_message = true;
679 679
 
@@ -689,7 +689,7 @@  discard block
 block discarded – undo
689 689
 		 * @return bool
690 690
 		 */
691 691
 		public function is_valid_license() {
692
-			if ( apply_filters( 'give_is_valid_license', ( is_object( $this->license_data ) && ! empty( $this->license_data ) && property_exists( $this->license_data, 'license' ) && 'valid' === $this->license_data->license ) ) ) {
692
+			if (apply_filters('give_is_valid_license', (is_object($this->license_data) && ! empty($this->license_data) && property_exists($this->license_data, 'license') && 'valid' === $this->license_data->license))) {
693 693
 				return true;
694 694
 			}
695 695
 
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
 		 * @return bool
706 706
 		 */
707 707
 		private function __is_third_party_addon() {
708
-			return ( false === strpos( $this->api_url, 'givewp.com/' ) );
708
+			return (false === strpos($this->api_url, 'givewp.com/'));
709 709
 		}
710 710
 
711 711
 		/**
@@ -720,25 +720,25 @@  discard block
 block discarded – undo
720 720
 		 * @return bool
721 721
 		 */
722 722
 		private function __remove_license_key_from_subscriptions() {
723
-			$subscriptions = get_option( 'give_subscriptions', array() );
723
+			$subscriptions = get_option('give_subscriptions', array());
724 724
 
725 725
 			// Bailout.
726
-			if ( empty( $this->license ) ) {
726
+			if (empty($this->license)) {
727 727
 				return false;
728 728
 			}
729 729
 
730
-			if ( ! empty( $subscriptions ) ) {
731
-				foreach ( $subscriptions as $subscription_id => $subscription ) {
732
-					$license_index = array_search( $this->license, $subscription['licenses'] );
733
-					if ( false !== $license_index ) {
730
+			if ( ! empty($subscriptions)) {
731
+				foreach ($subscriptions as $subscription_id => $subscription) {
732
+					$license_index = array_search($this->license, $subscription['licenses']);
733
+					if (false !== $license_index) {
734 734
 						// Remove license key.
735
-						unset( $subscriptions[ $subscription_id ]['licenses'][ $license_index ] );
735
+						unset($subscriptions[$subscription_id]['licenses'][$license_index]);
736 736
 
737 737
 						// Rearrange license keys.
738
-						$subscriptions[ $subscription_id ]['licenses'] = array_values( $subscriptions[ $subscription_id ]['licenses'] );
738
+						$subscriptions[$subscription_id]['licenses'] = array_values($subscriptions[$subscription_id]['licenses']);
739 739
 
740 740
 						// Update subscription information.
741
-						update_option( 'give_subscriptions', $subscriptions );
741
+						update_option('give_subscriptions', $subscriptions);
742 742
 						break;
743 743
 					}
744 744
 				}
@@ -752,17 +752,17 @@  discard block
 block discarded – undo
752 752
 		 *
753 753
 		 * @return bool
754 754
 		 */
755
-		public function plugin_page_notices( $plugin_file, $plugin_data, $status ) {
755
+		public function plugin_page_notices($plugin_file, $plugin_data, $status) {
756 756
 			// Bailout.
757
-			if ( $this->is_valid_license() ) {
757
+			if ($this->is_valid_license()) {
758 758
 				return false;
759 759
 			}
760 760
 
761 761
 			$update_notice_wrap = '<tr class="give-addon-notice-tr active"><td colspan="3" class="colspanchange"><div class="notice inline notice-warning notice-alt give-invalid-license"><p><span class="dashicons dashicons-info"></span> %s</p></div></td></tr>';
762 762
 			$message            = $this->license_state_message();
763 763
 
764
-			if ( ! empty( $message['message'] ) ) {
765
-				echo sprintf( $update_notice_wrap, $message['message'] );
764
+			if ( ! empty($message['message'])) {
765
+				echo sprintf($update_notice_wrap, $message['message']);
766 766
 			}
767 767
 		}
768 768
 
@@ -777,11 +777,11 @@  discard block
 block discarded – undo
777 777
 		public function license_state_message() {
778 778
 			$message_data = array();
779 779
 
780
-			if ( ! $this->is_valid_license() ) {
780
+			if ( ! $this->is_valid_license()) {
781 781
 
782 782
 				$message_data['message'] = sprintf(
783 783
 					'Please <a href="%1$s">activate your license</a> to receive updates and support for the %2$s add-on.',
784
-					esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' ) ),
784
+					esc_url(admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses')),
785 785
 					$this->item_name
786 786
 				);
787 787
 			}
@@ -796,18 +796,18 @@  discard block
 block discarded – undo
796 796
 		 * @since 1.8.9
797 797
 		 * @access private
798 798
 		 */
799
-		private function __is_user_can_edit_license(){
799
+		private function __is_user_can_edit_license() {
800 800
 			// Bailout.
801 801
 			if (
802
-				empty( $_POST[ $this->item_shortname . '_license_key' ] ) ||
803
-				! current_user_can( 'manage_give_settings' )
802
+				empty($_POST[$this->item_shortname.'_license_key']) ||
803
+				! current_user_can('manage_give_settings')
804 804
 			) {
805 805
 				return false;
806 806
 			}
807 807
 
808 808
 			// Security check.
809
-			if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) {
810
-				wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
809
+			if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) {
810
+				wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'), array('response' => 403));
811 811
 			}
812 812
 
813 813
 			return true;
@@ -825,8 +825,8 @@  discard block
 block discarded – undo
825 825
 		 *
826 826
 		 * @return mixed
827 827
 		 */
828
-		public function get_license_info( $edd_action = '', $response_in_array = false ) {
829
-			if( empty( $edd_action ) ) {
828
+		public function get_license_info($edd_action = '', $response_in_array = false) {
829
+			if (empty($edd_action)) {
830 830
 				return false;
831 831
 			}
832 832
 
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
 			$api_params = array(
835 835
 				'edd_action' => $edd_action, // never change from "edd_" to "give_"!
836 836
 				'license'    => $this->license,
837
-				'item_name'  => urlencode( $this->item_name ),
837
+				'item_name'  => urlencode($this->item_name),
838 838
 				'url'        => home_url(),
839 839
 			);
840 840
 
@@ -849,11 +849,11 @@  discard block
 block discarded – undo
849 849
 			);
850 850
 
851 851
 			// Make sure there are no errors.
852
-			if ( is_wp_error( $response ) ) {
852
+			if (is_wp_error($response)) {
853 853
 				return false;
854 854
 			}
855 855
 
856
-			return json_decode( wp_remote_retrieve_body( $response ), $response_in_array );
856
+			return json_decode(wp_remote_retrieve_body($response), $response_in_array);
857 857
 		}
858 858
 	}
859 859
 
Please login to merge, or discard this patch.
includes/formatting.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -107,9 +107,9 @@
 block discarded – undo
107 107
 	// Handle sanitize database values.
108 108
 	$number_parts = explode( '.', $number );
109 109
 	$is_db_sanitize_val = ( 2 === count( $number_parts ) &&
110
-	                        is_numeric( $number_parts[0] ) &&
111
-	                        is_numeric( $number_parts[1] ) &&
112
-	                        ( 6 === strlen( $number_parts[1] ) ) );
110
+							is_numeric( $number_parts[0] ) &&
111
+							is_numeric( $number_parts[1] ) &&
112
+							( 6 === strlen( $number_parts[1] ) ) );
113 113
 
114 114
 	if( $is_db_sanitize_val ) {
115 115
 		// Sanitize database value.
Please login to merge, or discard this patch.
Spacing   +148 added lines, -151 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  * @return mixed
24 24
  */
25 25
 function give_get_price_decimals() {
26
-	return apply_filters( 'give_sanitize_amount_decimals', give_get_option( 'number_decimals', 0 ) );
26
+	return apply_filters('give_sanitize_amount_decimals', give_get_option('number_decimals', 0));
27 27
 }
28 28
 
29 29
 /**
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
  */
36 36
 function give_get_price_thousand_separator() {
37 37
 	$give_options       = give_get_settings();
38
-	$thousand_separator = isset( $give_options['thousands_separator'] ) ? $give_options['thousands_separator'] : ',';
39
-	$thousand_separator = empty( $thousand_separator ) ? ' ' : $thousand_separator;
38
+	$thousand_separator = isset($give_options['thousands_separator']) ? $give_options['thousands_separator'] : ',';
39
+	$thousand_separator = empty($thousand_separator) ? ' ' : $thousand_separator;
40 40
 
41 41
 	return $thousand_separator;
42 42
 }
@@ -55,11 +55,10 @@  discard block
 block discarded – undo
55 55
 	);
56 56
 
57 57
 	$thousand_separator = give_get_price_thousand_separator();
58
-	$default_decimal_separator = in_array( $thousand_separator, $default_decimal_separators ) ?
59
-		$default_decimal_separators[$thousand_separator] :
60
-		'.';
58
+	$default_decimal_separator = in_array($thousand_separator, $default_decimal_separators) ?
59
+		$default_decimal_separators[$thousand_separator] : '.';
61 60
 
62
-	$decimal_separator = give_get_option( 'decimal_separator', $default_decimal_separator );
61
+	$decimal_separator = give_get_option('decimal_separator', $default_decimal_separator);
63 62
 
64 63
 	return $decimal_separator;
65 64
 }
@@ -74,8 +73,8 @@  discard block
 block discarded – undo
74 73
  *
75 74
  * @return string $amount Newly sanitized amount
76 75
  */
77
-function give_sanitize_amount_for_db( $number ) {
78
-	return give_maybe_sanitize_amount( $number, 6 );
76
+function give_sanitize_amount_for_db($number) {
77
+	return give_maybe_sanitize_amount($number, 6);
79 78
 }
80 79
 
81 80
 /**
@@ -89,41 +88,41 @@  discard block
 block discarded – undo
89 88
  *
90 89
  * @return string $amount Newly sanitized amount
91 90
  */
92
-function give_maybe_sanitize_amount( $number, $dp = false, $trim_zeros = false ) {
91
+function give_maybe_sanitize_amount($number, $dp = false, $trim_zeros = false) {
93 92
 	$thousand_separator = give_get_price_thousand_separator();
94 93
 	$decimal_separator  = give_get_price_decimal_separator();
95 94
 
96 95
 	// Bailout.
97
-	if( empty( $number ) || ( ! is_numeric( $number ) && ! is_string( $number ) ) ) {
96
+	if (empty($number) || ( ! is_numeric($number) && ! is_string($number))) {
98 97
 		return $number;
99 98
 	}elseif (
100
-		( false == strpos( $number, $thousand_separator ) ) &&
101
-		( false === strpos( $number, $decimal_separator ) )
99
+		(false == strpos($number, $thousand_separator)) &&
100
+		(false === strpos($number, $decimal_separator))
102 101
 	) {
103
-		return number_format( $number, ( is_bool( $dp ) ? give_get_price_decimals() : $dp ), '.', '' );
102
+		return number_format($number, (is_bool($dp) ? give_get_price_decimals() : $dp), '.', '');
104 103
 	}
105 104
 
106 105
 	// Handle thousand separator as '.'
107 106
 	// Handle sanitize database values.
108
-	$number_parts = explode( '.', $number );
109
-	$is_db_sanitize_val = ( 2 === count( $number_parts ) &&
110
-	                        is_numeric( $number_parts[0] ) &&
111
-	                        is_numeric( $number_parts[1] ) &&
112
-	                        ( 6 === strlen( $number_parts[1] ) ) );
107
+	$number_parts = explode('.', $number);
108
+	$is_db_sanitize_val = (2 === count($number_parts) &&
109
+	                        is_numeric($number_parts[0]) &&
110
+	                        is_numeric($number_parts[1]) &&
111
+	                        (6 === strlen($number_parts[1])));
113 112
 
114
-	if( $is_db_sanitize_val ) {
113
+	if ($is_db_sanitize_val) {
115 114
 		// Sanitize database value.
116
-		return number_format( $number, ( is_bool( $dp ) ? give_get_price_decimals() : $dp ), '.', '' );
115
+		return number_format($number, (is_bool($dp) ? give_get_price_decimals() : $dp), '.', '');
117 116
 
118 117
 	} elseif (
119 118
 		'.' === $thousand_separator &&
120
-		false !== strpos( $number, $thousand_separator )
121
-	){
119
+		false !== strpos($number, $thousand_separator)
120
+	) {
122 121
 		// Fix point thousand separator value.
123
-		$number = str_replace( '.', '', $number );
122
+		$number = str_replace('.', '', $number);
124 123
 	}
125 124
 
126
-	return give_sanitize_amount( $number, $dp, $trim_zeros );
125
+	return give_sanitize_amount($number, $dp, $trim_zeros);
127 126
 }
128 127
 
129 128
 /**
@@ -139,67 +138,67 @@  discard block
 block discarded – undo
139 138
  *
140 139
  * @return string $amount Newly sanitized amount
141 140
  */
142
-function give_sanitize_amount( $number, $dp = false, $trim_zeros = false ) {
141
+function give_sanitize_amount($number, $dp = false, $trim_zeros = false) {
143 142
 
144 143
 	// Bailout.
145
-	if ( empty( $number ) || ( ! is_numeric( $number ) && ! is_string( $number ) ) ) {
144
+	if (empty($number) || ( ! is_numeric($number) && ! is_string($number))) {
146 145
 		return $number;
147 146
 	}
148 147
 
149 148
 	// Remove slash from amount.
150 149
 	// If thousand or decimal separator is set to ' then in $_POST or $_GET param we will get an escaped number.
151 150
 	// To prevent notices and warning remove slash from amount/number.
152
-	$number = wp_unslash( $number );
151
+	$number = wp_unslash($number);
153 152
 
154 153
 	$thousand_separator = give_get_price_thousand_separator();
155 154
 
156 155
 	$locale   = localeconv();
157
-	$decimals = array( give_get_price_decimal_separator(), $locale['decimal_point'], $locale['mon_decimal_point'] );
156
+	$decimals = array(give_get_price_decimal_separator(), $locale['decimal_point'], $locale['mon_decimal_point']);
158 157
 
159 158
 	// Remove locale from string
160
-	if ( ! is_float( $number ) ) {
161
-		$number = str_replace( $decimals, '.', $number );
159
+	if ( ! is_float($number)) {
160
+		$number = str_replace($decimals, '.', $number);
162 161
 	}
163 162
 
164 163
 	// Remove thousand amount formatting if amount has.
165 164
 	// This condition use to add backward compatibility to version before 1.6, because before version 1.6 we were saving formatted amount to db.
166 165
 	// Do not replace thousand separator from price if it is same as decimal separator, because it will be already replace by above code.
167
-	if ( ! in_array( $thousand_separator, $decimals ) && ( false !== strpos( $number, $thousand_separator ) ) ) {
168
-		$number = str_replace( $thousand_separator, '', $number );
169
-	} elseif ( in_array( $thousand_separator, $decimals ) ) {
170
-		$number = preg_replace( '/\.(?=.*\.)/', '', $number );
166
+	if ( ! in_array($thousand_separator, $decimals) && (false !== strpos($number, $thousand_separator))) {
167
+		$number = str_replace($thousand_separator, '', $number);
168
+	} elseif (in_array($thousand_separator, $decimals)) {
169
+		$number = preg_replace('/\.(?=.*\.)/', '', $number);
171 170
 	}
172 171
 
173 172
 	// Remove non numeric entity before decimal separator.
174
-	$number     = preg_replace( '/[^0-9\.]/', '', $number );
173
+	$number     = preg_replace('/[^0-9\.]/', '', $number);
175 174
 	$default_dp = give_get_price_decimals();
176 175
 
177 176
 	// Reset negative amount to zero.
178
-	if ( 0 > $number ) {
179
-		$number = number_format( 0, $default_dp, '.' );
177
+	if (0 > $number) {
178
+		$number = number_format(0, $default_dp, '.');
180 179
 	}
181 180
 
182 181
 	// If number does not have decimal then add number of decimals to it.
183 182
 	if (
184
-		false === strpos( $number, '.' )
185
-		|| ( $default_dp > strlen( substr( $number, strpos( $number, '.' ) + 1 ) ) )
183
+		false === strpos($number, '.')
184
+		|| ($default_dp > strlen(substr($number, strpos($number, '.') + 1)))
186 185
 	) {
187
-		$number = number_format( $number, $default_dp, '.', '' );
186
+		$number = number_format($number, $default_dp, '.', '');
188 187
 	}
189 188
 
190 189
 	// Format number by custom number of decimals.
191
-	if ( false !== $dp ) {
192
-		$dp     = intval( is_bool( $dp ) ? $default_dp : $dp );
193
-		$dp     = apply_filters( 'give_sanitize_amount_decimals', $dp, $number );
194
-		$number = number_format( floatval( $number ), $dp, '.', '' );
190
+	if (false !== $dp) {
191
+		$dp     = intval(is_bool($dp) ? $default_dp : $dp);
192
+		$dp     = apply_filters('give_sanitize_amount_decimals', $dp, $number);
193
+		$number = number_format(floatval($number), $dp, '.', '');
195 194
 	}
196 195
 
197 196
 	// Trim zeros.
198
-	if ( $trim_zeros && strstr( $number, '.' ) ) {
199
-		$number = rtrim( rtrim( $number, '0' ), '.' );
197
+	if ($trim_zeros && strstr($number, '.')) {
198
+		$number = rtrim(rtrim($number, '0'), '.');
200 199
 	}
201 200
 
202
-	return apply_filters( 'give_sanitize_amount', $number );
201
+	return apply_filters('give_sanitize_amount', $number);
203 202
 }
204 203
 
205 204
 /**
@@ -212,10 +211,10 @@  discard block
 block discarded – undo
212 211
  *
213 212
  * @return string $amount   Newly formatted amount or Price Not Available
214 213
  */
215
-function give_format_amount( $amount, $args = array() ) {
214
+function give_format_amount($amount, $args = array()) {
216 215
 	// Backward compatibility.
217
-	if( is_bool( $args ) ) {
218
-		$args = array( 'decimal' => $args );
216
+	if (is_bool($args)) {
217
+		$args = array('decimal' => $args);
219 218
 	}
220 219
 
221 220
 	$default_args = array(
@@ -224,60 +223,59 @@  discard block
 block discarded – undo
224 223
 		'currency' => give_get_currency(),
225 224
 	);
226 225
 
227
-	$args = wp_parse_args( $args, $default_args );
226
+	$args = wp_parse_args($args, $default_args);
228 227
 
229 228
 	$formatted     = 0;
230 229
 	$thousands_sep = give_get_price_thousand_separator();
231 230
 	$decimal_sep   = give_get_price_decimal_separator();
232
-	$decimals      = ! empty( $args['decimal'] ) ? give_get_price_decimals() : 0;
231
+	$decimals      = ! empty($args['decimal']) ? give_get_price_decimals() : 0;
233 232
 	$currency      = $args['currency'];
234 233
 
235
-	if ( ! empty( $amount ) ) {
234
+	if ( ! empty($amount)) {
236 235
 		// Sanitize amount before formatting.
237
-		$amount = ! empty( $args['sanitize'] ) ?
238
-			give_maybe_sanitize_amount( $amount, $decimals ) :
239
-			number_format( $amount, $decimals, '.', '' );
236
+		$amount = ! empty($args['sanitize']) ?
237
+			give_maybe_sanitize_amount($amount, $decimals) : number_format($amount, $decimals, '.', '');
240 238
 
241
-		switch ( $currency ) {
239
+		switch ($currency) {
242 240
 			case 'INR':
243 241
 				$decimal_amount = '';
244 242
 
245 243
 				// Extract decimals from amount
246
-				if ( ( $pos = strpos( $amount, '.' ) ) !== false ) {
247
-					if ( ! empty( $decimals ) ) {
248
-						$decimal_amount = substr( round( substr( $amount, $pos ), $decimals ), 1 );
249
-						$amount         = substr( $amount, 0, $pos );
250
-
251
-						if ( ! $decimal_amount ) {
252
-							$decimal_amount = substr( '.0000000000', 0, ( $decimals + 1 ) );
253
-						} elseif ( ( $decimals + 1 ) > strlen( $decimal_amount ) ) {
254
-							$decimal_amount = substr( "{$decimal_amount}000000000", 0, ( $decimals + 1 ) );
244
+				if (($pos = strpos($amount, '.')) !== false) {
245
+					if ( ! empty($decimals)) {
246
+						$decimal_amount = substr(round(substr($amount, $pos), $decimals), 1);
247
+						$amount         = substr($amount, 0, $pos);
248
+
249
+						if ( ! $decimal_amount) {
250
+							$decimal_amount = substr('.0000000000', 0, ($decimals + 1));
251
+						} elseif (($decimals + 1) > strlen($decimal_amount)) {
252
+							$decimal_amount = substr("{$decimal_amount}000000000", 0, ($decimals + 1));
255 253
 						}
256 254
 
257 255
 					} else {
258
-						$amount = number_format( $amount, $decimals, $decimal_sep, '' );
256
+						$amount = number_format($amount, $decimals, $decimal_sep, '');
259 257
 					}
260 258
 				}
261 259
 
262 260
 				// Extract last 3 from amount
263
-				$result = substr( $amount, - 3 );
264
-				$amount = substr( $amount, 0, - 3 );
261
+				$result = substr($amount, - 3);
262
+				$amount = substr($amount, 0, - 3);
265 263
 
266 264
 				// Apply digits 2 by 2
267
-				while ( strlen( $amount ) > 0 ) {
268
-					$result = substr( $amount, - 2 ) . $thousands_sep . $result;
269
-					$amount = substr( $amount, 0, - 2 );
265
+				while (strlen($amount) > 0) {
266
+					$result = substr($amount, - 2).$thousands_sep.$result;
267
+					$amount = substr($amount, 0, - 2);
270 268
 				}
271 269
 
272
-				$formatted = $result . $decimal_amount;
270
+				$formatted = $result.$decimal_amount;
273 271
 				break;
274 272
 
275 273
 			default:
276
-				$formatted = number_format( $amount, $decimals, $decimal_sep, $thousands_sep );
274
+				$formatted = number_format($amount, $decimals, $decimal_sep, $thousands_sep);
277 275
 		}
278 276
 	}
279 277
 
280
-	return apply_filters( 'give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $currency, $args );
278
+	return apply_filters('give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $currency, $args);
281 279
 }
282 280
 
283 281
 
@@ -295,51 +293,51 @@  discard block
 block discarded – undo
295 293
  *
296 294
  * @return float|string  formatted amount number with large number names.
297 295
  */
298
-function give_human_format_large_amount( $amount, $args = array() ) {
296
+function give_human_format_large_amount($amount, $args = array()) {
299 297
 	$default_args = array(
300 298
 		'currency' => give_get_currency(),
301 299
 	);
302 300
 
303
-	$args = wp_parse_args( $args, $default_args );
301
+	$args = wp_parse_args($args, $default_args);
304 302
 
305 303
 	// Get thousand separator.
306 304
 	$thousands_sep = give_get_price_thousand_separator();
307 305
 
308 306
 	// Sanitize amount.
309
-	$sanitize_amount = give_maybe_sanitize_amount( $amount );
307
+	$sanitize_amount = give_maybe_sanitize_amount($amount);
310 308
 
311 309
 	// Explode amount to calculate name of large numbers.
312
-	$amount_array = explode( $thousands_sep, $amount );
310
+	$amount_array = explode($thousands_sep, $amount);
313 311
 
314 312
 	// Calculate amount parts count.
315
-	$amount_count_parts = count( $amount_array );
313
+	$amount_count_parts = count($amount_array);
316 314
 
317 315
 	// Human format amount (default).
318 316
 	$human_format_amount = $amount;
319 317
 
320
-	switch ( $args['currency'] ) {
318
+	switch ($args['currency']) {
321 319
 		case 'INR':
322 320
 			// Calculate large number formatted amount.
323
-			if ( 4 < $amount_count_parts ) {
324
-				$human_format_amount = sprintf( esc_html__( '%s arab', 'give' ), round( ( $sanitize_amount / 1000000000 ), 2 ) );
325
-			} elseif ( 3 < $amount_count_parts ) {
326
-				$human_format_amount = sprintf( esc_html__( '%s crore', 'give' ), round( ( $sanitize_amount / 10000000 ), 2 ) );
327
-			} elseif ( 2 < $amount_count_parts ) {
328
-				$human_format_amount = sprintf( esc_html__( '%s lakh', 'give' ), round( ( $sanitize_amount / 100000 ), 2 ) );
321
+			if (4 < $amount_count_parts) {
322
+				$human_format_amount = sprintf(esc_html__('%s arab', 'give'), round(($sanitize_amount / 1000000000), 2));
323
+			} elseif (3 < $amount_count_parts) {
324
+				$human_format_amount = sprintf(esc_html__('%s crore', 'give'), round(($sanitize_amount / 10000000), 2));
325
+			} elseif (2 < $amount_count_parts) {
326
+				$human_format_amount = sprintf(esc_html__('%s lakh', 'give'), round(($sanitize_amount / 100000), 2));
329 327
 			}
330 328
 			break;
331 329
 		default:
332 330
 			// Calculate large number formatted amount.
333
-			if ( 4 < $amount_count_parts ) {
334
-				$human_format_amount = sprintf( esc_html__( '%s trillion', 'give' ), round( ( $sanitize_amount / 1000000000000 ), 2 ) );
335
-			} elseif ( 3 < $amount_count_parts ) {
336
-				$human_format_amount = sprintf( esc_html__( '%s billion', 'give' ), round( ( $sanitize_amount / 1000000000 ), 2 ) );
337
-			} elseif ( 2 < $amount_count_parts ) {
338
-				$human_format_amount = sprintf( esc_html__( '%s million', 'give' ), round( ( $sanitize_amount / 1000000 ), 2 ) );
331
+			if (4 < $amount_count_parts) {
332
+				$human_format_amount = sprintf(esc_html__('%s trillion', 'give'), round(($sanitize_amount / 1000000000000), 2));
333
+			} elseif (3 < $amount_count_parts) {
334
+				$human_format_amount = sprintf(esc_html__('%s billion', 'give'), round(($sanitize_amount / 1000000000), 2));
335
+			} elseif (2 < $amount_count_parts) {
336
+				$human_format_amount = sprintf(esc_html__('%s million', 'give'), round(($sanitize_amount / 1000000), 2));
339 337
 			}
340 338
 	}
341 339
 
342
-	return apply_filters( 'give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount );
340
+	return apply_filters('give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount);
343 341
 }
344 342
 
345 343
 /**
@@ -353,17 +351,16 @@  discard block
 block discarded – undo
353 351
  *
354 352
  * @return string $amount Newly formatted amount or Price Not Available
355 353
  */
356
-function give_format_decimal( $amount, $dp = false, $sanitize = true ) {
354
+function give_format_decimal($amount, $dp = false, $sanitize = true) {
357 355
 	$decimal_separator = give_get_price_decimal_separator();
358 356
 	$formatted_amount  = $sanitize ?
359
-		give_maybe_sanitize_amount( $amount, $dp ) :
360
-		number_format( $amount, ( is_bool( $dp ) ? give_get_price_decimals() : $dp ), '.', '' );
357
+		give_maybe_sanitize_amount($amount, $dp) : number_format($amount, (is_bool($dp) ? give_get_price_decimals() : $dp), '.', '');
361 358
 
362
-	if ( false !== strpos( $formatted_amount, '.' ) ) {
363
-		$formatted_amount = str_replace( '.', $decimal_separator, $formatted_amount );
359
+	if (false !== strpos($formatted_amount, '.')) {
360
+		$formatted_amount = str_replace('.', $decimal_separator, $formatted_amount);
364 361
 	}
365 362
 
366
-	return apply_filters( 'give_format_decimal', $formatted_amount, $amount, $decimal_separator );
363
+	return apply_filters('give_format_decimal', $formatted_amount, $amount, $decimal_separator);
367 364
 }
368 365
 
369 366
 /**
@@ -377,24 +374,24 @@  discard block
 block discarded – undo
377 374
  *
378 375
  * @return mixed|string
379 376
  */
380
-function give_currency_filter( $price = '', $currency = '', $decode_currency = false ) {
377
+function give_currency_filter($price = '', $currency = '', $decode_currency = false) {
381 378
 
382
-	if ( empty( $currency ) || ! array_key_exists( (string) $currency, give_get_currencies() ) ) {
379
+	if (empty($currency) || ! array_key_exists((string) $currency, give_get_currencies())) {
383 380
 		$currency = give_get_currency();
384 381
 	}
385 382
 
386
-	$position = give_get_option( 'currency_position', 'before' );
383
+	$position = give_get_option('currency_position', 'before');
387 384
 
388 385
 	$negative = $price < 0;
389 386
 
390
-	if ( $negative ) {
387
+	if ($negative) {
391 388
 		// Remove proceeding "-".
392
-		$price = substr( $price, 1 );
389
+		$price = substr($price, 1);
393 390
 	}
394 391
 
395
-	$symbol = give_currency_symbol( $currency, $decode_currency );
392
+	$symbol = give_currency_symbol($currency, $decode_currency);
396 393
 
397
-	switch ( $currency ) :
394
+	switch ($currency) :
398 395
 		case 'GBP' :
399 396
 		case 'BRL' :
400 397
 		case 'EUR' :
@@ -423,13 +420,13 @@  discard block
 block discarded – undo
423 420
 		case 'MAD' :
424 421
 		case 'KRW' :
425 422
 		case 'ZAR' :
426
-			$formatted = ( 'before' === $position ? $symbol . $price : $price . $symbol );
423
+			$formatted = ('before' === $position ? $symbol.$price : $price.$symbol);
427 424
 			break;
428 425
 		case 'NOK' :
429
-			$formatted = ( 'before' === $position ? $symbol . ' ' . $price : $price . ' ' . $symbol );
426
+			$formatted = ('before' === $position ? $symbol.' '.$price : $price.' '.$symbol);
430 427
 			break;
431 428
 		default :
432
-			$formatted = ( 'before' === $position ? $currency . ' ' . $price : $price . ' ' . $currency );
429
+			$formatted = ('before' === $position ? $currency.' '.$price : $price.' '.$currency);
433 430
 			break;
434 431
 	endswitch;
435 432
 
@@ -444,11 +441,11 @@  discard block
 block discarded – undo
444 441
 	 *           and if currency is USD and currency position is after then
445 442
 	 *           filter name will be give_usd_currency_filter_after
446 443
 	 */
447
-	$formatted = apply_filters( 'give_' . strtolower( $currency ) . "_currency_filter_{$position}", $formatted, $currency, $price );
444
+	$formatted = apply_filters('give_'.strtolower($currency)."_currency_filter_{$position}", $formatted, $currency, $price);
448 445
 
449
-	if ( $negative ) {
446
+	if ($negative) {
450 447
 		// Prepend the minus sign before the currency sign.
451
-		$formatted = '-' . $formatted;
448
+		$formatted = '-'.$formatted;
452 449
 	}
453 450
 
454 451
 	return $formatted;
@@ -464,21 +461,21 @@  discard block
 block discarded – undo
464 461
  */
465 462
 function give_currency_decimal_filter() {
466 463
 
467
-	remove_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' );
464
+	remove_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter');
468 465
 
469 466
 	// Set default number of decimals.
470 467
 	$decimals = give_get_price_decimals();
471 468
 
472
-	add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' );
469
+	add_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter');
473 470
 
474 471
 	// Get number of decimals with backward compatibility ( version < 1.6 )
475
-	if ( 1 <= func_num_args() ) {
476
-		$decimals = ( false === func_get_arg( 0 ) ? $decimals : absint( func_get_arg( 0 ) ) );
472
+	if (1 <= func_num_args()) {
473
+		$decimals = (false === func_get_arg(0) ? $decimals : absint(func_get_arg(0)));
477 474
 	}
478 475
 
479 476
 	$currency = give_get_currency();
480 477
 
481
-	switch ( $currency ) {
478
+	switch ($currency) {
482 479
 		case 'RIAL' :
483 480
 		case 'JPY' :
484 481
 		case 'TWD' :
@@ -488,11 +485,11 @@  discard block
 block discarded – undo
488 485
 			break;
489 486
 	}
490 487
 
491
-	return apply_filters( 'give_currency_decimal_count', $decimals, $currency );
488
+	return apply_filters('give_currency_decimal_count', $decimals, $currency);
492 489
 }
493 490
 
494
-add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' );
495
-add_filter( 'give_format_amount_decimals', 'give_currency_decimal_filter' );
491
+add_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter');
492
+add_filter('give_format_amount_decimals', 'give_currency_decimal_filter');
496 493
 
497 494
 
498 495
 /**
@@ -504,7 +501,7 @@  discard block
 block discarded – undo
504 501
  *
505 502
  * @return string                  Date format string
506 503
  */
507
-function give_date_format( $date_context = '' ) {
504
+function give_date_format($date_context = '') {
508 505
 	/**
509 506
 	 * Filter the date context
510 507
 	 *
@@ -525,19 +522,19 @@  discard block
 block discarded – undo
525 522
 	 *
526 523
 	 *    }
527 524
 	 */
528
-	$date_format_contexts = apply_filters( 'give_date_format_contexts', array() );
525
+	$date_format_contexts = apply_filters('give_date_format_contexts', array());
529 526
 
530 527
 	// Set date format to default date format.
531
-	$date_format = get_option( 'date_format' );
528
+	$date_format = get_option('date_format');
532 529
 
533 530
 	// Update date format if we have non empty date format context array and non empty date format string for that context.
534
-	if ( $date_context && ! empty( $date_format_contexts ) && array_key_exists( $date_context, $date_format_contexts ) ) {
535
-		$date_format = ! empty( $date_format_contexts[ $date_context ] )
536
-			? $date_format_contexts[ $date_context ]
531
+	if ($date_context && ! empty($date_format_contexts) && array_key_exists($date_context, $date_format_contexts)) {
532
+		$date_format = ! empty($date_format_contexts[$date_context])
533
+			? $date_format_contexts[$date_context]
537 534
 			: $date_format;
538 535
 	}
539 536
 
540
-	return apply_filters( 'give_date_format', $date_format );
537
+	return apply_filters('give_date_format', $date_format);
541 538
 }
542 539
 
543 540
 /**
@@ -551,8 +548,8 @@  discard block
 block discarded – undo
551 548
  *
552 549
  * @return string
553 550
  */
554
-function give_get_cache_key( $action, $query_args ) {
555
-	return Give_Cache::get_key( $action, $query_args );
551
+function give_get_cache_key($action, $query_args) {
552
+	return Give_Cache::get_key($action, $query_args);
556 553
 }
557 554
 
558 555
 /**
@@ -565,11 +562,11 @@  discard block
 block discarded – undo
565 562
  *
566 563
  * @return string|array
567 564
  */
568
-function give_clean( $var ) {
569
-	if ( is_array( $var ) ) {
570
-		return array_map( 'give_clean', $var );
565
+function give_clean($var) {
566
+	if (is_array($var)) {
567
+		return array_map('give_clean', $var);
571 568
 	} else {
572
-		return is_scalar( $var ) ? sanitize_text_field( $var ) : $var;
569
+		return is_scalar($var) ? sanitize_text_field($var) : $var;
573 570
 	}
574 571
 }
575 572
 
@@ -582,10 +579,10 @@  discard block
 block discarded – undo
582 579
  *
583 580
  * @return int
584 581
  */
585
-function give_let_to_num( $size ) {
586
-	$l   = substr( $size, - 1 );
587
-	$ret = substr( $size, 0, - 1 );
588
-	switch ( strtoupper( $l ) ) {
582
+function give_let_to_num($size) {
583
+	$l   = substr($size, - 1);
584
+	$ret = substr($size, 0, - 1);
585
+	switch (strtoupper($l)) {
589 586
 		case 'P':
590 587
 			$ret *= 1024;
591 588
 		case 'T':
@@ -610,19 +607,19 @@  discard block
 block discarded – undo
610 607
  * @param int   $action
611 608
  * @param array $wp_die_args
612 609
  */
613
-function give_validate_nonce( $nonce, $action = - 1, $wp_die_args = array() ) {
610
+function give_validate_nonce($nonce, $action = - 1, $wp_die_args = array()) {
614 611
 
615 612
 	$default_wp_die_args = array(
616
-		'message' => esc_html__( 'Nonce verification has failed.', 'give' ),
617
-		'title'   => esc_html__( 'Error', 'give' ),
613
+		'message' => esc_html__('Nonce verification has failed.', 'give'),
614
+		'title'   => esc_html__('Error', 'give'),
618 615
 		'args'    => array(
619 616
 			'response' => 403,
620 617
 		),
621 618
 	);
622 619
 
623
-	$wp_die_args = wp_parse_args( $wp_die_args, $default_wp_die_args );
620
+	$wp_die_args = wp_parse_args($wp_die_args, $default_wp_die_args);
624 621
 
625
-	if ( ! wp_verify_nonce( $nonce, $action ) ) {
622
+	if ( ! wp_verify_nonce($nonce, $action)) {
626 623
 		wp_die(
627 624
 			$wp_die_args['message'],
628 625
 			$wp_die_args['title'],
@@ -644,23 +641,23 @@  discard block
 block discarded – undo
644 641
  *
645 642
  * @return mixed
646 643
  */
647
-function give_check_variable( $variable, $conditional = '', $default = false ) {
644
+function give_check_variable($variable, $conditional = '', $default = false) {
648 645
 
649
-	switch ( $conditional ) {
646
+	switch ($conditional) {
650 647
 		case 'isset_empty':
651
-			$variable = ( isset( $variable ) && ! empty( $variable ) ) ? $variable : $default;
648
+			$variable = (isset($variable) && ! empty($variable)) ? $variable : $default;
652 649
 			break;
653 650
 
654 651
 		case 'empty':
655
-			$variable = ! empty( $variable ) ? $variable : $default;
652
+			$variable = ! empty($variable) ? $variable : $default;
656 653
 			break;
657 654
 
658 655
 		case 'null':
659
-			$variable = ! is_null( $variable ) ? $variable : $default;
656
+			$variable = ! is_null($variable) ? $variable : $default;
660 657
 			break;
661 658
 
662 659
 		default:
663
-			$variable = isset( $variable ) ? $variable : $default;
660
+			$variable = isset($variable) ? $variable : $default;
664 661
 
665 662
 	}
666 663
 
Please login to merge, or discard this patch.
includes/payments/actions.php 1 patch
Spacing   +57 added lines, -57 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
 
@@ -28,21 +28,21 @@  discard block
 block discarded – undo
28 28
  *
29 29
  * @return void
30 30
  */
31
-function give_complete_purchase( $payment_id, $new_status, $old_status ) {
31
+function give_complete_purchase($payment_id, $new_status, $old_status) {
32 32
 
33 33
 	// Make sure that payments are only completed once.
34
-	if ( $old_status == 'publish' || $old_status == 'complete' ) {
34
+	if ($old_status == 'publish' || $old_status == 'complete') {
35 35
 		return;
36 36
 	}
37 37
 
38 38
 	// Make sure the payment completion is only processed when new status is complete.
39
-	if ( $new_status != 'publish' && $new_status != 'complete' ) {
39
+	if ($new_status != 'publish' && $new_status != 'complete') {
40 40
 		return;
41 41
 	}
42 42
 
43
-	$payment = new Give_Payment( $payment_id );
43
+	$payment = new Give_Payment($payment_id);
44 44
 
45
-	$creation_date  = get_post_field( 'post_date', $payment_id, 'raw' );
45
+	$creation_date  = get_post_field('post_date', $payment_id, 'raw');
46 46
 	$payment_meta   = $payment->payment_meta;
47 47
 	$completed_date = $payment->completed_date;
48 48
 	$user_info      = $payment->user_info;
@@ -58,12 +58,12 @@  discard block
 block discarded – undo
58 58
 	 *
59 59
 	 * @param int $payment_id The ID of the payment.
60 60
 	 */
61
-	do_action( 'give_pre_complete_donation', $payment_id );
61
+	do_action('give_pre_complete_donation', $payment_id);
62 62
 
63 63
 	// Ensure these actions only run once, ever.
64
-	if ( empty( $completed_date ) ) {
64
+	if (empty($completed_date)) {
65 65
 
66
-		give_record_donation_in_log( $form_id, $payment_id, $price_id, $creation_date );
66
+		give_record_donation_in_log($form_id, $payment_id, $price_id, $creation_date);
67 67
 
68 68
 		/**
69 69
 		 * Fires after logging donation record.
@@ -74,29 +74,29 @@  discard block
 block discarded – undo
74 74
 		 * @param int $payment_id The ID number of the payment.
75 75
 		 * @param array $payment_meta The payment meta.
76 76
 		 */
77
-		do_action( 'give_complete_form_donation', $form_id, $payment_id, $payment_meta );
77
+		do_action('give_complete_form_donation', $form_id, $payment_id, $payment_meta);
78 78
 
79 79
 	}
80 80
 
81 81
 	// Increase the earnings for this form ID.
82
-	give_increase_earnings( $form_id, $amount );
83
-	give_increase_donation_count( $form_id );
82
+	give_increase_earnings($form_id, $amount);
83
+	give_increase_donation_count($form_id);
84 84
 
85 85
 	// @todo: Refresh only range related stat cache
86 86
 	give_delete_donation_stats();
87 87
 
88 88
 	// Increase the donor's donation stats.
89
-	$donor = new Give_Donor( $donor_id );
89
+	$donor = new Give_Donor($donor_id);
90 90
 	$donor->increase_purchase_count();
91
-	$donor->increase_value( $amount );
91
+	$donor->increase_value($amount);
92 92
 
93
-	give_increase_total_earnings( $amount );
93
+	give_increase_total_earnings($amount);
94 94
 
95 95
 	// Ensure this action only runs once ever.
96
-	if ( empty( $completed_date ) ) {
96
+	if (empty($completed_date)) {
97 97
 
98 98
 		// Save the completed date.
99
-		$payment->completed_date = current_time( 'mysql' );
99
+		$payment->completed_date = current_time('mysql');
100 100
 		$payment->save();
101 101
 
102 102
 		/**
@@ -106,12 +106,12 @@  discard block
 block discarded – undo
106 106
 		 *
107 107
 		 * @param int $payment_id The ID of the payment.
108 108
 		 */
109
-		do_action( 'give_complete_donation', $payment_id );
109
+		do_action('give_complete_donation', $payment_id);
110 110
 	}
111 111
 
112 112
 }
113 113
 
114
-add_action( 'give_update_payment_status', 'give_complete_purchase', 100, 3 );
114
+add_action('give_update_payment_status', 'give_complete_purchase', 100, 3);
115 115
 
116 116
 
117 117
 /**
@@ -125,20 +125,20 @@  discard block
 block discarded – undo
125 125
  *
126 126
  * @return void
127 127
  */
128
-function give_record_status_change( $payment_id, $new_status, $old_status ) {
128
+function give_record_status_change($payment_id, $new_status, $old_status) {
129 129
 
130 130
 	// Get the list of statuses so that status in the payment note can be translated.
131 131
 	$stati      = give_get_payment_statuses();
132
-	$old_status = isset( $stati[ $old_status ] ) ? $stati[ $old_status ] : $old_status;
133
-	$new_status = isset( $stati[ $new_status ] ) ? $stati[ $new_status ] : $new_status;
132
+	$old_status = isset($stati[$old_status]) ? $stati[$old_status] : $old_status;
133
+	$new_status = isset($stati[$new_status]) ? $stati[$new_status] : $new_status;
134 134
 
135 135
 	// translators: 1: old status 2: new status.
136
-	$status_change = sprintf( esc_html__( 'Status changed from %1$s to %2$s.', 'give' ), $old_status, $new_status );
136
+	$status_change = sprintf(esc_html__('Status changed from %1$s to %2$s.', 'give'), $old_status, $new_status);
137 137
 
138
-	give_insert_payment_note( $payment_id, $status_change );
138
+	give_insert_payment_note($payment_id, $status_change);
139 139
 }
140 140
 
141
-add_action( 'give_update_payment_status', 'give_record_status_change', 100, 3 );
141
+add_action('give_update_payment_status', 'give_record_status_change', 100, 3);
142 142
 
143 143
 
144 144
 /**
@@ -154,25 +154,25 @@  discard block
 block discarded – undo
154 154
  *
155 155
  * @return void
156 156
  */
157
-function give_update_old_payments_with_totals( $data ) {
158
-	if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_upgrade_payments_nonce' ) ) {
157
+function give_update_old_payments_with_totals($data) {
158
+	if ( ! wp_verify_nonce($data['_wpnonce'], 'give_upgrade_payments_nonce')) {
159 159
 		return;
160 160
 	}
161 161
 
162
-	if ( get_option( 'give_payment_totals_upgraded' ) ) {
162
+	if (get_option('give_payment_totals_upgraded')) {
163 163
 		return;
164 164
 	}
165 165
 
166
-	$payments = give_get_payments( array(
166
+	$payments = give_get_payments(array(
167 167
 		'offset' => 0,
168
-		'number' => - 1,
168
+		'number' => -1,
169 169
 		'mode'   => 'all',
170
-	) );
170
+	));
171 171
 
172
-	if ( $payments ) {
173
-		foreach ( $payments as $payment ) {
172
+	if ($payments) {
173
+		foreach ($payments as $payment) {
174 174
 
175
-			$payment = new Give_Payment( $payment->ID );
175
+			$payment = new Give_Payment($payment->ID);
176 176
 			$meta    = $payment->get_meta();
177 177
 
178 178
 			$payment->total = $meta['amount'];
@@ -181,10 +181,10 @@  discard block
 block discarded – undo
181 181
 		}
182 182
 	}
183 183
 
184
-	add_option( 'give_payment_totals_upgraded', 1 );
184
+	add_option('give_payment_totals_upgraded', 1);
185 185
 }
186 186
 
187
-add_action( 'give_upgrade_payments', 'give_update_old_payments_with_totals' );
187
+add_action('give_upgrade_payments', 'give_update_old_payments_with_totals');
188 188
 
189 189
 /**
190 190
  * Mark Abandoned Donations
@@ -198,17 +198,17 @@  discard block
 block discarded – undo
198 198
 function give_mark_abandoned_donations() {
199 199
 	$args = array(
200 200
 		'status' => 'pending',
201
-		'number' => - 1,
201
+		'number' => -1,
202 202
 		'output' => 'give_payments',
203 203
 	);
204 204
 
205
-	add_filter( 'posts_where', 'give_filter_where_older_than_week' );
205
+	add_filter('posts_where', 'give_filter_where_older_than_week');
206 206
 
207
-	$payments = give_get_payments( $args );
207
+	$payments = give_get_payments($args);
208 208
 
209
-	remove_filter( 'posts_where', 'give_filter_where_older_than_week' );
209
+	remove_filter('posts_where', 'give_filter_where_older_than_week');
210 210
 
211
-	if ( $payments ) {
211
+	if ($payments) {
212 212
 		/**
213 213
 		 * Filter payment gateways:  Used to set payment gateways which can be skip while transferring pending payment to abandon.
214 214
 		 *
@@ -216,13 +216,13 @@  discard block
 block discarded – undo
216 216
 		 *
217 217
 		 * @param array $skip_payment_gateways Array of payment gateways
218 218
 		 */
219
-		$skip_payment_gateways = apply_filters( 'give_mark_abandoned_donation_gateways', array( 'offline' ) );
219
+		$skip_payment_gateways = apply_filters('give_mark_abandoned_donation_gateways', array('offline'));
220 220
 
221
-		foreach ( $payments as $payment ) {
222
-			$gateway = give_get_payment_gateway( $payment );
221
+		foreach ($payments as $payment) {
222
+			$gateway = give_get_payment_gateway($payment);
223 223
 
224 224
 			// Skip payment gateways.
225
-			if ( in_array( $gateway, $skip_payment_gateways ) ) {
225
+			if (in_array($gateway, $skip_payment_gateways)) {
226 226
 				continue;
227 227
 			}
228 228
 
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 	}
233 233
 }
234 234
 
235
-Give_Cron::add_weekly_event( 'give_mark_abandoned_donations' );
235
+Give_Cron::add_weekly_event('give_mark_abandoned_donations');
236 236
 
237 237
 
238 238
 /**
@@ -244,15 +244,15 @@  discard block
 block discarded – undo
244 244
  *
245 245
  * @return void
246 246
  */
247
-function give_refresh_thismonth_stat_transients( $payment_ID ) {
247
+function give_refresh_thismonth_stat_transients($payment_ID) {
248 248
 	// Monthly stats.
249
-	Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) );
249
+	Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats'));
250 250
 
251 251
 	// @todo: Refresh only range related stat cache
252 252
 	give_delete_donation_stats();
253 253
 }
254 254
 
255
-add_action( 'save_post_give_payment', 'give_refresh_thismonth_stat_transients' );
255
+add_action('save_post_give_payment', 'give_refresh_thismonth_stat_transients');
256 256
 
257 257
 /*
258 258
  * Add meta in payment that store page id and page url.
@@ -264,18 +264,18 @@  discard block
 block discarded – undo
264 264
  *
265 265
  * @param {integer} $payment_id Payment id for which the meta value should be updated.
266 266
  */
267
-function give_payment_save_page_data( $payment_id ) {
268
-	$page_url = ( ! empty( $_REQUEST['give-current-url'] ) ? esc_url( $_REQUEST['give-current-url'] ) : false );
267
+function give_payment_save_page_data($payment_id) {
268
+	$page_url = ( ! empty($_REQUEST['give-current-url']) ? esc_url($_REQUEST['give-current-url']) : false);
269 269
 	// Check $page_url is not empty.
270
-	if ( $page_url ) {
271
-		update_post_meta( $payment_id, '_give_current_url', $page_url );
272
-		$page_id = url_to_postid( $page_url );
270
+	if ($page_url) {
271
+		update_post_meta($payment_id, '_give_current_url', $page_url);
272
+		$page_id = url_to_postid($page_url);
273 273
 		// Check $page_id is not empty.
274
-		if ( $page_id ) {
275
-			update_post_meta( $payment_id, '_give_current_page_id', $page_id );
274
+		if ($page_id) {
275
+			update_post_meta($payment_id, '_give_current_page_id', $page_id);
276 276
 		}
277 277
 	}
278 278
 }
279 279
 
280 280
 // Fire when payment is save.
281
-add_action( 'give_insert_payment', 'give_payment_save_page_data' );
282 281
\ No newline at end of file
282
+add_action('give_insert_payment', 'give_payment_save_page_data');
283 283
\ No newline at end of file
Please login to merge, or discard this patch.