Test Failed
Pull Request — master (#2482)
by Devin
05:37
created
includes/formatting.php 1 patch
Spacing   +171 added lines, -175 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,37 +23,37 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @return mixed
25 25
  */
26
-function give_get_currency_formatting_settings( $id_or_currency_code = null ) {
26
+function give_get_currency_formatting_settings($id_or_currency_code = null) {
27 27
 	$give_options = give_get_settings();
28 28
 	$setting      = array();
29 29
 
30
-	if ( ! empty( $id_or_currency_code ) ) {
31
-		$currencies = give_get_currencies( 'all' );
30
+	if ( ! empty($id_or_currency_code)) {
31
+		$currencies = give_get_currencies('all');
32 32
 
33 33
 		// Set default formatting setting only if currency not set as global currency.
34 34
 		if (
35
-			is_string( $id_or_currency_code ) &&
36
-			! empty( $give_options['currency'] ) &&
35
+			is_string($id_or_currency_code) &&
36
+			! empty($give_options['currency']) &&
37 37
 			$id_or_currency_code !== $give_options['currency'] &&
38
-			array_key_exists( $id_or_currency_code, $currencies )
38
+			array_key_exists($id_or_currency_code, $currencies)
39 39
 		) {
40
-			$setting = $currencies[ $id_or_currency_code ]['setting'];
41
-		} elseif ( is_numeric( $id_or_currency_code ) && 'give_payment' === get_post_type( $id_or_currency_code ) ) {
42
-			$donation_meta = give_get_meta( $id_or_currency_code, '_give_payment_meta', true );
40
+			$setting = $currencies[$id_or_currency_code]['setting'];
41
+		} elseif (is_numeric($id_or_currency_code) && 'give_payment' === get_post_type($id_or_currency_code)) {
42
+			$donation_meta = give_get_meta($id_or_currency_code, '_give_payment_meta', true);
43 43
 
44 44
 			if (
45
-				! empty( $donation_meta['currency'] ) &&
45
+				! empty($donation_meta['currency']) &&
46 46
 				$give_options['currency'] !== $donation_meta['currency']
47 47
 			) {
48
-				$setting = $currencies[ $donation_meta['currency'] ]['setting'];
48
+				$setting = $currencies[$donation_meta['currency']]['setting'];
49 49
 			}
50 50
 		}
51 51
 	}
52 52
 
53
-	if ( empty( $setting ) ) {
53
+	if (empty($setting)) {
54 54
 		// Set thousand separator.
55
-		$thousand_separator = isset( $give_options['thousands_separator'] ) ? $give_options['thousands_separator'] : ',';
56
-		$thousand_separator = empty( $thousand_separator ) ? ' ' : $thousand_separator;
55
+		$thousand_separator = isset($give_options['thousands_separator']) ? $give_options['thousands_separator'] : ',';
56
+		$thousand_separator = empty($thousand_separator) ? ' ' : $thousand_separator;
57 57
 
58 58
 		// Set decimal separator.
59 59
 		$default_decimal_separators = array(
@@ -61,17 +61,16 @@  discard block
 block discarded – undo
61 61
 			',' => '.',
62 62
 		);
63 63
 
64
-		$default_decimal_separator = in_array( $thousand_separator, $default_decimal_separators ) ?
65
-			$default_decimal_separators[ $thousand_separator ] :
66
-			'.';
64
+		$default_decimal_separator = in_array($thousand_separator, $default_decimal_separators) ?
65
+			$default_decimal_separators[$thousand_separator] : '.';
67 66
 
68
-		$decimal_separator = ! empty( $give_options['decimal_separator'] ) ? $give_options['decimal_separator'] : $default_decimal_separator;
67
+		$decimal_separator = ! empty($give_options['decimal_separator']) ? $give_options['decimal_separator'] : $default_decimal_separator;
69 68
 
70 69
 		$setting = array(
71
-			'currency_position'   => give_get_option( 'currency_position', 'before' ),
70
+			'currency_position'   => give_get_option('currency_position', 'before'),
72 71
 			'thousands_separator' => $thousand_separator,
73 72
 			'decimal_separator'   => $decimal_separator,
74
-			'number_decimals'     => give_get_option( 'number_decimals', 0 ),
73
+			'number_decimals'     => give_get_option('number_decimals', 0),
75 74
 		);
76 75
 	}
77 76
 
@@ -80,7 +79,7 @@  discard block
 block discarded – undo
80 79
 	 *
81 80
 	 * @since 1.8.15
82 81
 	 */
83
-	return apply_filters( 'give_get_currency_formatting_settings', $setting, $id_or_currency_code );
82
+	return apply_filters('give_get_currency_formatting_settings', $setting, $id_or_currency_code);
84 83
 }
85 84
 
86 85
 /**
@@ -92,16 +91,16 @@  discard block
 block discarded – undo
92 91
  *
93 92
  * @return mixed
94 93
  */
95
-function give_get_price_decimals( $id_or_currency_code = null ) {
94
+function give_get_price_decimals($id_or_currency_code = null) {
96 95
 	// Set currency on basis of donation id.
97
-	if ( empty( $id_or_currency_code ) ) {
96
+	if (empty($id_or_currency_code)) {
98 97
 		$id_or_currency_code = give_get_currency();
99 98
 	}
100 99
 
101 100
 	$number_of_decimals = 0;
102 101
 
103
-	if ( ! give_is_zero_based_currency( $id_or_currency_code ) ) {
104
-		$setting            = give_get_currency_formatting_settings( $id_or_currency_code );
102
+	if ( ! give_is_zero_based_currency($id_or_currency_code)) {
103
+		$setting            = give_get_currency_formatting_settings($id_or_currency_code);
105 104
 		$number_of_decimals = $setting['number_decimals'];
106 105
 	}
107 106
 
@@ -110,7 +109,7 @@  discard block
 block discarded – undo
110 109
 	 *
111 110
 	 * @since 1.6
112 111
 	 */
113
-	return apply_filters( 'give_sanitize_amount_decimals', $number_of_decimals, $id_or_currency_code );
112
+	return apply_filters('give_sanitize_amount_decimals', $number_of_decimals, $id_or_currency_code);
114 113
 }
115 114
 
116 115
 /**
@@ -122,15 +121,15 @@  discard block
 block discarded – undo
122 121
  *
123 122
  * @return mixed
124 123
  */
125
-function give_get_price_thousand_separator( $id_or_currency_code = null ) {
126
-	$setting = give_get_currency_formatting_settings( $id_or_currency_code );
124
+function give_get_price_thousand_separator($id_or_currency_code = null) {
125
+	$setting = give_get_currency_formatting_settings($id_or_currency_code);
127 126
 
128 127
 	/**
129 128
 	 * Filter the thousand separator
130 129
 	 *
131 130
 	 * @since 1.6
132 131
 	 */
133
-	return apply_filters( 'give_get_price_thousand_separator', $setting['thousands_separator'], $id_or_currency_code );
132
+	return apply_filters('give_get_price_thousand_separator', $setting['thousands_separator'], $id_or_currency_code);
134 133
 }
135 134
 
136 135
 /**
@@ -142,15 +141,15 @@  discard block
 block discarded – undo
142 141
  *
143 142
  * @return mixed
144 143
  */
145
-function give_get_price_decimal_separator( $id_or_currency_code = null ) {
146
-	$setting = give_get_currency_formatting_settings( $id_or_currency_code );
144
+function give_get_price_decimal_separator($id_or_currency_code = null) {
145
+	$setting = give_get_currency_formatting_settings($id_or_currency_code);
147 146
 
148 147
 	/**
149 148
 	 * Filter the thousand separator
150 149
 	 *
151 150
 	 * @since 1.6
152 151
 	 */
153
-	return apply_filters( 'give_get_price_decimal_separator', $setting['decimal_separator'], $id_or_currency_code );
152
+	return apply_filters('give_get_price_decimal_separator', $setting['decimal_separator'], $id_or_currency_code);
154 153
 }
155 154
 
156 155
 
@@ -163,8 +162,8 @@  discard block
 block discarded – undo
163 162
  *
164 163
  * @return string $amount Newly sanitized amount
165 164
  */
166
-function give_sanitize_amount_for_db( $number ) {
167
-	return give_maybe_sanitize_amount( $number, array( 'number_decimals' => 6 ) );
165
+function give_sanitize_amount_for_db($number) {
166
+	return give_maybe_sanitize_amount($number, array('number_decimals' => 6));
168 167
 }
169 168
 
170 169
 /**
@@ -177,19 +176,19 @@  discard block
 block discarded – undo
177 176
  *
178 177
  * @return string $amount Newly sanitized amount
179 178
  */
180
-function give_maybe_sanitize_amount( $number, $args = array() ) {
179
+function give_maybe_sanitize_amount($number, $args = array()) {
181 180
 	// Bailout.
182
-	if ( empty( $number ) || ( ! is_numeric( $number ) && ! is_string( $number ) ) ) {
181
+	if (empty($number) || ( ! is_numeric($number) && ! is_string($number))) {
183 182
 		return $number;
184 183
 	}
185 184
 
186 185
 	$func_args = func_get_args();
187 186
 
188 187
 	// Backward compatibility.
189
-	if ( isset( $func_args[1] ) && ( is_bool( $func_args[1] ) || is_numeric( $func_args[1] ) ) ) {
188
+	if (isset($func_args[1]) && (is_bool($func_args[1]) || is_numeric($func_args[1]))) {
190 189
 		$args = array(
191 190
 			'number_decimals' => $func_args[1],
192
-			'trim_zeros'      => isset( $func_args[2] ) ? $func_args[2] : false,
191
+			'trim_zeros'      => isset($func_args[2]) ? $func_args[2] : false,
193 192
 		);
194 193
 	}
195 194
 
@@ -202,23 +201,22 @@  discard block
 block discarded – undo
202 201
 		)
203 202
 	);
204 203
 
205
-	$thousand_separator = give_get_price_thousand_separator( $args['currency'] );
206
-	$decimal_separator  = give_get_price_decimal_separator( $args['currency'] );
207
-	$number_decimals    = is_bool( $args['number_decimals'] ) ?
208
-		give_get_price_decimals() :
209
-		$args['number_decimals'];
204
+	$thousand_separator = give_get_price_thousand_separator($args['currency']);
205
+	$decimal_separator  = give_get_price_decimal_separator($args['currency']);
206
+	$number_decimals    = is_bool($args['number_decimals']) ?
207
+		give_get_price_decimals() : $args['number_decimals'];
210 208
 
211 209
 	// Explode number by . decimal separator.
212
-	$number_parts = explode( '.', $number );
210
+	$number_parts = explode('.', $number);
213 211
 
214 212
 	// Remove currency symbols from number if any.
215
-	$number = trim( str_replace( give_currency_symbols( true ), '', $number ) );
213
+	$number = trim(str_replace(give_currency_symbols(true), '', $number));
216 214
 
217 215
 	if (
218 216
 		// Non formatted number.
219 217
 		(
220
-			( false === strpos( $number, $thousand_separator ) ) &&
221
-			( false === strpos( $number, $decimal_separator ) )
218
+			(false === strpos($number, $thousand_separator)) &&
219
+			(false === strpos($number, $decimal_separator))
222 220
 		) ||
223 221
 
224 222
 		// Decimal formatted number.
@@ -228,35 +226,35 @@  discard block
 block discarded – undo
228 226
 		(
229 227
 			$number_decimals &&
230 228
 			'.' === $thousand_separator &&
231
-			false !== strpos( $number, $thousand_separator ) &&
232
-			false === strpos( $number, $decimal_separator ) &&
233
-			2 === count( $number_parts ) &&
234
-			( $number_decimals >= strlen( $number_parts[1] ) )
229
+			false !== strpos($number, $thousand_separator) &&
230
+			false === strpos($number, $decimal_separator) &&
231
+			2 === count($number_parts) &&
232
+			($number_decimals >= strlen($number_parts[1]))
235 233
 		)
236 234
 	) {
237
-		return number_format( $number, $number_decimals, '.', '' );
235
+		return number_format($number, $number_decimals, '.', '');
238 236
 	}
239 237
 
240 238
 	// Handle thousand separator as '.'
241 239
 	// Handle sanitize database values.
242
-	$is_db_sanitize_val = ( 2 === count( $number_parts ) &&
243
-							is_numeric( $number_parts[0] ) &&
244
-							is_numeric( $number_parts[1] ) &&
245
-							( 6 === strlen( $number_parts[1] ) ) );
240
+	$is_db_sanitize_val = (2 === count($number_parts) &&
241
+							is_numeric($number_parts[0]) &&
242
+							is_numeric($number_parts[1]) &&
243
+							(6 === strlen($number_parts[1])));
246 244
 
247
-	if ( $is_db_sanitize_val ) {
245
+	if ($is_db_sanitize_val) {
248 246
 		// Sanitize database value.
249
-		return number_format( $number, $number_decimals, '.', '' );
247
+		return number_format($number, $number_decimals, '.', '');
250 248
 
251 249
 	} elseif (
252 250
 		'.' === $thousand_separator &&
253
-		false !== strpos( $number, $thousand_separator )
251
+		false !== strpos($number, $thousand_separator)
254 252
 	) {
255 253
 		// Fix point thousand separator value.
256
-		$number = str_replace( '.', '', $number );
254
+		$number = str_replace('.', '', $number);
257 255
 	}
258 256
 
259
-	return give_sanitize_amount( $number, $args );
257
+	return give_sanitize_amount($number, $args);
260 258
 }
261 259
 
262 260
 /**
@@ -273,10 +271,10 @@  discard block
 block discarded – undo
273 271
  *
274 272
  * @return string $amount Newly sanitized amount
275 273
  */
276
-function give_sanitize_amount( $number, $args = array() ) {
274
+function give_sanitize_amount($number, $args = array()) {
277 275
 
278 276
 	// Bailout.
279
-	if ( empty( $number ) || ( ! is_numeric( $number ) && ! is_string( $number ) ) ) {
277
+	if (empty($number) || ( ! is_numeric($number) && ! is_string($number))) {
280 278
 		return $number;
281 279
 	}
282 280
 
@@ -284,10 +282,10 @@  discard block
 block discarded – undo
284 282
 	$func_args = func_get_args();
285 283
 
286 284
 	// Backward compatibility.
287
-	if ( isset( $func_args[1] ) && ( is_bool( $func_args[1] ) || is_numeric( $func_args[1] ) ) ) {
285
+	if (isset($func_args[1]) && (is_bool($func_args[1]) || is_numeric($func_args[1]))) {
288 286
 		$args = array(
289 287
 			'number_decimals' => $func_args[1],
290
-			'trim_zeros'      => isset( $func_args[2] ) ? $func_args[2] : false,
288
+			'trim_zeros'      => isset($func_args[2]) ? $func_args[2] : false,
291 289
 		);
292 290
 	}
293 291
 
@@ -303,58 +301,58 @@  discard block
 block discarded – undo
303 301
 	// Remove slash from amount.
304 302
 	// If thousand or decimal separator is set to ' then in $_POST or $_GET param we will get an escaped number.
305 303
 	// To prevent notices and warning remove slash from amount/number.
306
-	$number = wp_unslash( $number );
304
+	$number = wp_unslash($number);
307 305
 
308
-	$thousand_separator = give_get_price_thousand_separator( $args['currency'] );
306
+	$thousand_separator = give_get_price_thousand_separator($args['currency']);
309 307
 
310 308
 	$locale   = localeconv();
311 309
 	$decimals = array(
312
-		give_get_price_decimal_separator( $args['currency'] ),
310
+		give_get_price_decimal_separator($args['currency']),
313 311
 		$locale['decimal_point'],
314 312
 		$locale['mon_decimal_point'],
315 313
 	);
316 314
 
317 315
 	// Remove locale from string
318
-	if ( ! is_float( $number ) ) {
319
-		$number = str_replace( $decimals, '.', $number );
316
+	if ( ! is_float($number)) {
317
+		$number = str_replace($decimals, '.', $number);
320 318
 	}
321 319
 
322 320
 	// Remove thousand amount formatting if amount has.
323 321
 	// This condition use to add backward compatibility to version before 1.6, because before version 1.6 we were saving formatted amount to db.
324 322
 	// Do not replace thousand separator from price if it is same as decimal separator, because it will be already replace by above code.
325
-	if ( ! in_array( $thousand_separator, $decimals ) && ( false !== strpos( $number, $thousand_separator ) ) ) {
326
-		$number = str_replace( $thousand_separator, '', $number );
327
-	} elseif ( in_array( $thousand_separator, $decimals ) ) {
328
-		$number = preg_replace( '/\.(?=.*\.)/', '', $number );
323
+	if ( ! in_array($thousand_separator, $decimals) && (false !== strpos($number, $thousand_separator))) {
324
+		$number = str_replace($thousand_separator, '', $number);
325
+	} elseif (in_array($thousand_separator, $decimals)) {
326
+		$number = preg_replace('/\.(?=.*\.)/', '', $number);
329 327
 	}
330 328
 
331 329
 	// Remove non numeric entity before decimal separator.
332
-	$number     = preg_replace( '/[^0-9\.]/', '', $number );
333
-	$default_dp = give_get_price_decimals( $args['currency'] );
330
+	$number     = preg_replace('/[^0-9\.]/', '', $number);
331
+	$default_dp = give_get_price_decimals($args['currency']);
334 332
 
335 333
 	// Reset negative amount to zero.
336
-	if ( 0 > $number ) {
337
-		$number = number_format( 0, $default_dp, '.' );
334
+	if (0 > $number) {
335
+		$number = number_format(0, $default_dp, '.');
338 336
 	}
339 337
 
340 338
 	// If number does not have decimal then add number of decimals to it.
341 339
 	if (
342
-		false === strpos( $number, '.' )
343
-		|| ( $default_dp > strlen( substr( $number, strpos( $number, '.' ) + 1 ) ) )
340
+		false === strpos($number, '.')
341
+		|| ($default_dp > strlen(substr($number, strpos($number, '.') + 1)))
344 342
 	) {
345
-		$number = number_format( $number, $default_dp, '.', '' );
343
+		$number = number_format($number, $default_dp, '.', '');
346 344
 	}
347 345
 
348 346
 	// Format number by custom number of decimals.
349
-	if ( false !== $args['number_decimals'] ) {
350
-		$dp     = intval( is_bool( $args['number_decimals'] ) ? $default_dp : $args['number_decimals'] );
351
-		$dp     = apply_filters( 'give_sanitize_amount_decimals', $dp, $number );
352
-		$number = number_format( floatval( $number ), $dp, '.', '' );
347
+	if (false !== $args['number_decimals']) {
348
+		$dp     = intval(is_bool($args['number_decimals']) ? $default_dp : $args['number_decimals']);
349
+		$dp     = apply_filters('give_sanitize_amount_decimals', $dp, $number);
350
+		$number = number_format(floatval($number), $dp, '.', '');
353 351
 	}
354 352
 
355 353
 	// Trim zeros.
356
-	if ( $args['trim_zeros'] && strstr( $number, '.' ) ) {
357
-		$number = rtrim( rtrim( $number, '0' ), '.' );
354
+	if ($args['trim_zeros'] && strstr($number, '.')) {
355
+		$number = rtrim(rtrim($number, '0'), '.');
358 356
 	}
359 357
 
360 358
 	/**
@@ -362,7 +360,7 @@  discard block
 block discarded – undo
362 360
 	 *
363 361
 	 * @since 1.0
364 362
 	 */
365
-	return apply_filters( 'give_sanitize_amount', $number );
363
+	return apply_filters('give_sanitize_amount', $number);
366 364
 }
367 365
 
368 366
 /**
@@ -375,9 +373,9 @@  discard block
 block discarded – undo
375 373
  *
376 374
  * @return string $amount   Newly formatted amount or Price Not Available
377 375
  */
378
-function give_format_amount( $amount, $args = array() ) {
376
+function give_format_amount($amount, $args = array()) {
379 377
 	// Backward compatibility.
380
-	if ( is_bool( $args ) ) {
378
+	if (is_bool($args)) {
381 379
 		$args = array(
382 380
 			'decimal' => $args,
383 381
 		);
@@ -390,61 +388,60 @@  discard block
 block discarded – undo
390 388
 		'currency'    => '',
391 389
 	);
392 390
 
393
-	$args = wp_parse_args( $args, $default_args );
391
+	$args = wp_parse_args($args, $default_args);
394 392
 
395 393
 	// Set Currency based on donation id, if required.
396
-	if ( $args['donation_id'] && empty( $args['currency'] ) ) {
397
-		$donation_meta    = give_get_meta( $args['donation_id'], '_give_payment_meta', true );
394
+	if ($args['donation_id'] && empty($args['currency'])) {
395
+		$donation_meta    = give_get_meta($args['donation_id'], '_give_payment_meta', true);
398 396
 		$args['currency'] = $donation_meta['currency'];
399 397
 	}
400 398
 
401 399
 	$formatted     = 0;
402
-	$currency      = ! empty( $args['currency'] ) ? $args['currency'] : give_get_currency( $args['donation_id'] );
403
-	$thousands_sep = give_get_price_thousand_separator( $currency );
404
-	$decimal_sep   = give_get_price_decimal_separator( $currency );
405
-	$decimals      = ! empty( $args['decimal'] ) ? give_get_price_decimals( $currency ) : 0;
400
+	$currency      = ! empty($args['currency']) ? $args['currency'] : give_get_currency($args['donation_id']);
401
+	$thousands_sep = give_get_price_thousand_separator($currency);
402
+	$decimal_sep   = give_get_price_decimal_separator($currency);
403
+	$decimals      = ! empty($args['decimal']) ? give_get_price_decimals($currency) : 0;
406 404
 
407
-	if ( ! empty( $amount ) ) {
405
+	if ( ! empty($amount)) {
408 406
 		// Sanitize amount before formatting.
409
-		$amount = ! empty( $args['sanitize'] ) ?
410
-			give_maybe_sanitize_amount( $amount, array( 'number_decimals' => $decimals, 'currency' => $currency ) ) :
411
-			number_format( $amount, $decimals, '.', '' );
407
+		$amount = ! empty($args['sanitize']) ?
408
+			give_maybe_sanitize_amount($amount, array('number_decimals' => $decimals, 'currency' => $currency)) : number_format($amount, $decimals, '.', '');
412 409
 
413
-		switch ( $currency ) {
410
+		switch ($currency) {
414 411
 			case 'INR':
415 412
 				$decimal_amount = '';
416 413
 
417 414
 				// Extract decimals from amount
418
-				if ( ( $pos = strpos( $amount, '.' ) ) !== false ) {
419
-					if ( ! empty( $decimals ) ) {
420
-						$decimal_amount = substr( round( substr( $amount, $pos ), $decimals ), 1 );
421
-						$amount         = substr( $amount, 0, $pos );
422
-
423
-						if ( ! $decimal_amount ) {
424
-							$decimal_amount = substr( "{$decimal_sep}0000000000", 0, ( $decimals + 1 ) );
425
-						} elseif ( ( $decimals + 1 ) > strlen( $decimal_amount ) ) {
426
-							$decimal_amount = substr( "{$decimal_amount}000000000", 0, ( $decimals + 1 ) );
415
+				if (($pos = strpos($amount, '.')) !== false) {
416
+					if ( ! empty($decimals)) {
417
+						$decimal_amount = substr(round(substr($amount, $pos), $decimals), 1);
418
+						$amount         = substr($amount, 0, $pos);
419
+
420
+						if ( ! $decimal_amount) {
421
+							$decimal_amount = substr("{$decimal_sep}0000000000", 0, ($decimals + 1));
422
+						} elseif (($decimals + 1) > strlen($decimal_amount)) {
423
+							$decimal_amount = substr("{$decimal_amount}000000000", 0, ($decimals + 1));
427 424
 						}
428 425
 					} else {
429
-						$amount = number_format( $amount, $decimals, $decimal_sep, '' );
426
+						$amount = number_format($amount, $decimals, $decimal_sep, '');
430 427
 					}
431 428
 				}
432 429
 
433 430
 				// Extract last 3 from amount
434
-				$result = substr( $amount, - 3 );
435
-				$amount = substr( $amount, 0, - 3 );
431
+				$result = substr($amount, - 3);
432
+				$amount = substr($amount, 0, - 3);
436 433
 
437 434
 				// Apply digits 2 by 2
438
-				while ( strlen( $amount ) > 0 ) {
439
-					$result = substr( $amount, - 2 ) . $thousands_sep . $result;
440
-					$amount = substr( $amount, 0, - 2 );
435
+				while (strlen($amount) > 0) {
436
+					$result = substr($amount, - 2).$thousands_sep.$result;
437
+					$amount = substr($amount, 0, - 2);
441 438
 				}
442 439
 
443
-				$formatted = $result . $decimal_amount;
440
+				$formatted = $result.$decimal_amount;
444 441
 				break;
445 442
 
446 443
 			default:
447
-				$formatted = number_format( $amount, $decimals, $decimal_sep, $thousands_sep );
444
+				$formatted = number_format($amount, $decimals, $decimal_sep, $thousands_sep);
448 445
 		}
449 446
 	}
450 447
 
@@ -453,7 +450,7 @@  discard block
 block discarded – undo
453 450
 	 *
454 451
 	 * @since 1.0
455 452
 	 */
456
-	return apply_filters( 'give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $currency, $args );
453
+	return apply_filters('give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $currency, $args);
457 454
 }
458 455
 
459 456
 
@@ -471,17 +468,17 @@  discard block
 block discarded – undo
471 468
  *
472 469
  * @return string  formatted amount number with large number names.
473 470
  */
474
-function give_human_format_large_amount( $amount, $args = array() ) {
471
+function give_human_format_large_amount($amount, $args = array()) {
475 472
 	// Sanitize amount.
476
-	$sanitize_amount = give_maybe_sanitize_amount( $amount );
473
+	$sanitize_amount = give_maybe_sanitize_amount($amount);
477 474
 
478 475
 	// Bailout.
479
-	if ( ! floatval( $sanitize_amount ) ) {
476
+	if ( ! floatval($sanitize_amount)) {
480 477
 		return '0';
481 478
 	};
482 479
 
483 480
 	// Set default currency;
484
-	if ( empty( $args['currency'] ) ) {
481
+	if (empty($args['currency'])) {
485 482
 		$args['currency'] = give_get_currency();
486 483
 	}
487 484
 
@@ -489,37 +486,37 @@  discard block
 block discarded – undo
489 486
 	$thousands_sep = give_get_price_thousand_separator();
490 487
 
491 488
 	// Explode amount to calculate name of large numbers.
492
-	$amount_array = explode( $thousands_sep, $amount );
489
+	$amount_array = explode($thousands_sep, $amount);
493 490
 
494 491
 	// Calculate amount parts count.
495
-	$amount_count_parts = count( $amount_array );
492
+	$amount_count_parts = count($amount_array);
496 493
 
497 494
 	// Human format amount (default).
498 495
 	$human_format_amount = $amount;
499 496
 
500
-	switch ( $args['currency'] ) {
497
+	switch ($args['currency']) {
501 498
 		case 'INR':
502 499
 			// Calculate large number formatted amount.
503
-			if ( 4 < $amount_count_parts ) {
504
-				$human_format_amount = sprintf( esc_html__( '%s arab', 'give' ), round( ( $sanitize_amount / 1000000000 ), 2 ) );
505
-			} elseif ( 3 < $amount_count_parts ) {
506
-				$human_format_amount = sprintf( esc_html__( '%s crore', 'give' ), round( ( $sanitize_amount / 10000000 ), 2 ) );
507
-			} elseif ( 2 < $amount_count_parts ) {
508
-				$human_format_amount = sprintf( esc_html__( '%s lakh', 'give' ), round( ( $sanitize_amount / 100000 ), 2 ) );
500
+			if (4 < $amount_count_parts) {
501
+				$human_format_amount = sprintf(esc_html__('%s arab', 'give'), round(($sanitize_amount / 1000000000), 2));
502
+			} elseif (3 < $amount_count_parts) {
503
+				$human_format_amount = sprintf(esc_html__('%s crore', 'give'), round(($sanitize_amount / 10000000), 2));
504
+			} elseif (2 < $amount_count_parts) {
505
+				$human_format_amount = sprintf(esc_html__('%s lakh', 'give'), round(($sanitize_amount / 100000), 2));
509 506
 			}
510 507
 			break;
511 508
 		default:
512 509
 			// Calculate large number formatted amount.
513
-			if ( 4 < $amount_count_parts ) {
514
-				$human_format_amount = sprintf( esc_html__( '%s trillion', 'give' ), round( ( $sanitize_amount / 1000000000000 ), 2 ) );
515
-			} elseif ( 3 < $amount_count_parts ) {
516
-				$human_format_amount = sprintf( esc_html__( '%s billion', 'give' ), round( ( $sanitize_amount / 1000000000 ), 2 ) );
517
-			} elseif ( 2 < $amount_count_parts ) {
518
-				$human_format_amount = sprintf( esc_html__( '%s million', 'give' ), round( ( $sanitize_amount / 1000000 ), 2 ) );
510
+			if (4 < $amount_count_parts) {
511
+				$human_format_amount = sprintf(esc_html__('%s trillion', 'give'), round(($sanitize_amount / 1000000000000), 2));
512
+			} elseif (3 < $amount_count_parts) {
513
+				$human_format_amount = sprintf(esc_html__('%s billion', 'give'), round(($sanitize_amount / 1000000000), 2));
514
+			} elseif (2 < $amount_count_parts) {
515
+				$human_format_amount = sprintf(esc_html__('%s million', 'give'), round(($sanitize_amount / 1000000), 2));
519 516
 			}
520 517
 	}
521 518
 
522
-	return apply_filters( 'give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount );
519
+	return apply_filters('give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount);
523 520
 }
524 521
 
525 522
 /**
@@ -533,17 +530,16 @@  discard block
 block discarded – undo
533 530
  *
534 531
  * @return string $amount Newly formatted amount or Price Not Available
535 532
  */
536
-function give_format_decimal( $amount, $dp = false, $sanitize = true ) {
533
+function give_format_decimal($amount, $dp = false, $sanitize = true) {
537 534
 	$decimal_separator = give_get_price_decimal_separator();
538 535
 	$formatted_amount  = $sanitize ?
539
-		give_maybe_sanitize_amount( $amount, array( 'number_decimals' => $dp ) ) :
540
-		number_format( $amount, ( is_bool( $dp ) ? give_get_price_decimals() : $dp ), '.', '' );
536
+		give_maybe_sanitize_amount($amount, array('number_decimals' => $dp)) : number_format($amount, (is_bool($dp) ? give_get_price_decimals() : $dp), '.', '');
541 537
 
542
-	if ( false !== strpos( $formatted_amount, '.' ) ) {
543
-		$formatted_amount = str_replace( '.', $decimal_separator, $formatted_amount );
538
+	if (false !== strpos($formatted_amount, '.')) {
539
+		$formatted_amount = str_replace('.', $decimal_separator, $formatted_amount);
544 540
 	}
545 541
 
546
-	return apply_filters( 'give_format_decimal', $formatted_amount, $amount, $decimal_separator );
542
+	return apply_filters('give_format_decimal', $formatted_amount, $amount, $decimal_separator);
547 543
 }
548 544
 
549 545
 /**
@@ -555,7 +551,7 @@  discard block
 block discarded – undo
555 551
  *
556 552
  * @return string                  Date format string
557 553
  */
558
-function give_date_format( $date_context = '' ) {
554
+function give_date_format($date_context = '') {
559 555
 	/**
560 556
 	 * Filter the date context
561 557
 	 *
@@ -576,19 +572,19 @@  discard block
 block discarded – undo
576 572
 	 *
577 573
 	 *    }
578 574
 	 */
579
-	$date_format_contexts = apply_filters( 'give_date_format_contexts', array() );
575
+	$date_format_contexts = apply_filters('give_date_format_contexts', array());
580 576
 
581 577
 	// Set date format to default date format.
582
-	$date_format = get_option( 'date_format' );
578
+	$date_format = get_option('date_format');
583 579
 
584 580
 	// Update date format if we have non empty date format context array and non empty date format string for that context.
585
-	if ( $date_context && ! empty( $date_format_contexts ) && array_key_exists( $date_context, $date_format_contexts ) ) {
586
-		$date_format = ! empty( $date_format_contexts[ $date_context ] )
587
-			? $date_format_contexts[ $date_context ]
581
+	if ($date_context && ! empty($date_format_contexts) && array_key_exists($date_context, $date_format_contexts)) {
582
+		$date_format = ! empty($date_format_contexts[$date_context])
583
+			? $date_format_contexts[$date_context]
588 584
 			: $date_format;
589 585
 	}
590 586
 
591
-	return apply_filters( 'give_date_format', $date_format );
587
+	return apply_filters('give_date_format', $date_format);
592 588
 }
593 589
 
594 590
 /**
@@ -602,8 +598,8 @@  discard block
 block discarded – undo
602 598
  *
603 599
  * @return string
604 600
  */
605
-function give_get_cache_key( $action, $query_args ) {
606
-	return Give_Cache::get_key( $action, $query_args );
601
+function give_get_cache_key($action, $query_args) {
602
+	return Give_Cache::get_key($action, $query_args);
607 603
 }
608 604
 
609 605
 /**
@@ -616,11 +612,11 @@  discard block
 block discarded – undo
616 612
  *
617 613
  * @return string|array
618 614
  */
619
-function give_clean( $var ) {
620
-	if ( is_array( $var ) ) {
621
-		return array_map( 'give_clean', $var );
615
+function give_clean($var) {
616
+	if (is_array($var)) {
617
+		return array_map('give_clean', $var);
622 618
 	} else {
623
-		return is_scalar( $var ) ? sanitize_text_field( $var ) : $var;
619
+		return is_scalar($var) ? sanitize_text_field($var) : $var;
624 620
 	}
625 621
 }
626 622
 
@@ -633,10 +629,10 @@  discard block
 block discarded – undo
633 629
  *
634 630
  * @return int
635 631
  */
636
-function give_let_to_num( $size ) {
637
-	$l   = substr( $size, - 1 );
638
-	$ret = substr( $size, 0, - 1 );
639
-	switch ( strtoupper( $l ) ) {
632
+function give_let_to_num($size) {
633
+	$l   = substr($size, - 1);
634
+	$ret = substr($size, 0, - 1);
635
+	switch (strtoupper($l)) {
640 636
 		case 'P':
641 637
 			$ret *= 1024;
642 638
 		case 'T':
@@ -661,19 +657,19 @@  discard block
 block discarded – undo
661 657
  * @param int   $action
662 658
  * @param array $wp_die_args
663 659
  */
664
-function give_validate_nonce( $nonce, $action = - 1, $wp_die_args = array() ) {
660
+function give_validate_nonce($nonce, $action = - 1, $wp_die_args = array()) {
665 661
 
666 662
 	$default_wp_die_args = array(
667
-		'message' => esc_html__( 'Nonce verification has failed.', 'give' ),
668
-		'title'   => esc_html__( 'Error', 'give' ),
663
+		'message' => esc_html__('Nonce verification has failed.', 'give'),
664
+		'title'   => esc_html__('Error', 'give'),
669 665
 		'args'    => array(
670 666
 			'response' => 403,
671 667
 		),
672 668
 	);
673 669
 
674
-	$wp_die_args = wp_parse_args( $wp_die_args, $default_wp_die_args );
670
+	$wp_die_args = wp_parse_args($wp_die_args, $default_wp_die_args);
675 671
 
676
-	if ( ! wp_verify_nonce( $nonce, $action ) ) {
672
+	if ( ! wp_verify_nonce($nonce, $action)) {
677 673
 		wp_die(
678 674
 			$wp_die_args['message'],
679 675
 			$wp_die_args['title'],
@@ -695,23 +691,23 @@  discard block
 block discarded – undo
695 691
  *
696 692
  * @return mixed
697 693
  */
698
-function give_check_variable( $variable, $conditional = '', $default = false ) {
694
+function give_check_variable($variable, $conditional = '', $default = false) {
699 695
 
700
-	switch ( $conditional ) {
696
+	switch ($conditional) {
701 697
 		case 'isset_empty':
702
-			$variable = ( isset( $variable ) && ! empty( $variable ) ) ? $variable : $default;
698
+			$variable = (isset($variable) && ! empty($variable)) ? $variable : $default;
703 699
 			break;
704 700
 
705 701
 		case 'empty':
706
-			$variable = ! empty( $variable ) ? $variable : $default;
702
+			$variable = ! empty($variable) ? $variable : $default;
707 703
 			break;
708 704
 
709 705
 		case 'null':
710
-			$variable = ! is_null( $variable ) ? $variable : $default;
706
+			$variable = ! is_null($variable) ? $variable : $default;
711 707
 			break;
712 708
 
713 709
 		default:
714
-			$variable = isset( $variable ) ? $variable : $default;
710
+			$variable = isset($variable) ? $variable : $default;
715 711
 
716 712
 	}
717 713
 
Please login to merge, or discard this patch.
includes/post-types.php 1 patch
Spacing   +160 added lines, -160 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,49 +23,49 @@  discard block
 block discarded – undo
23 23
 function give_setup_post_types() {
24 24
 
25 25
 	// Give Forms single post and archive options.
26
-	$give_forms_singular = give_is_setting_enabled( give_get_option( 'forms_singular' ) );
27
-	$give_forms_archives = give_is_setting_enabled( give_get_option( 'forms_archives' ) );
26
+	$give_forms_singular = give_is_setting_enabled(give_get_option('forms_singular'));
27
+	$give_forms_archives = give_is_setting_enabled(give_get_option('forms_archives'));
28 28
 
29 29
 	// Enable/Disable give_forms links if form is saving.
30
-	if ( Give_Admin_Settings::is_saving_settings() ) {
31
-		if ( isset( $_POST['forms_singular'] ) ) {
32
-			$give_forms_singular = give_is_setting_enabled( give_clean( $_POST['forms_singular'] ) );
30
+	if (Give_Admin_Settings::is_saving_settings()) {
31
+		if (isset($_POST['forms_singular'])) {
32
+			$give_forms_singular = give_is_setting_enabled(give_clean($_POST['forms_singular']));
33 33
 			flush_rewrite_rules();
34 34
 		}
35 35
 
36
-		if ( isset( $_POST['forms_archives'] ) ) {
37
-			$give_forms_archives = give_is_setting_enabled( give_clean( $_POST['forms_archives'] ) );
36
+		if (isset($_POST['forms_archives'])) {
37
+			$give_forms_archives = give_is_setting_enabled(give_clean($_POST['forms_archives']));
38 38
 			flush_rewrite_rules();
39 39
 		}
40 40
 	}
41 41
 
42
-	$give_forms_slug = defined( 'GIVE_SLUG' ) ? GIVE_SLUG : 'donations';
42
+	$give_forms_slug = defined('GIVE_SLUG') ? GIVE_SLUG : 'donations';
43 43
 	// Support for old 'GIVE_FORMS_SLUG' constant
44
-	if ( defined( 'GIVE_FORMS_SLUG' ) ) {
44
+	if (defined('GIVE_FORMS_SLUG')) {
45 45
 		$give_forms_slug = GIVE_FORMS_SLUG;
46 46
 	}
47 47
 
48
-	$give_forms_rewrite = defined( 'GIVE_DISABLE_FORMS_REWRITE' ) && GIVE_DISABLE_FORMS_REWRITE ? false : array(
48
+	$give_forms_rewrite = defined('GIVE_DISABLE_FORMS_REWRITE') && GIVE_DISABLE_FORMS_REWRITE ? false : array(
49 49
 		'slug'       => $give_forms_slug,
50 50
 		'with_front' => false,
51 51
 	);
52 52
 
53
-	$give_forms_labels = apply_filters( 'give_forms_labels', array(
54
-		'name'               => __( 'Donation Forms', 'give' ),
55
-		'singular_name'      => __( 'Form', 'give' ),
56
-		'add_new'            => __( 'Add Form', 'give' ),
57
-		'add_new_item'       => __( 'Add New Donation Form', 'give' ),
58
-		'edit_item'          => __( 'Edit Donation Form', 'give' ),
59
-		'new_item'           => __( 'New Form', 'give' ),
60
-		'all_items'          => __( 'All Forms', 'give' ),
61
-		'view_item'          => __( 'View Form', 'give' ),
62
-		'search_items'       => __( 'Search Forms', 'give' ),
63
-		'not_found'          => __( 'No forms found.', 'give' ),
64
-		'not_found_in_trash' => __( 'No forms found in Trash.', 'give' ),
53
+	$give_forms_labels = apply_filters('give_forms_labels', array(
54
+		'name'               => __('Donation Forms', 'give'),
55
+		'singular_name'      => __('Form', 'give'),
56
+		'add_new'            => __('Add Form', 'give'),
57
+		'add_new_item'       => __('Add New Donation Form', 'give'),
58
+		'edit_item'          => __('Edit Donation Form', 'give'),
59
+		'new_item'           => __('New Form', 'give'),
60
+		'all_items'          => __('All Forms', 'give'),
61
+		'view_item'          => __('View Form', 'give'),
62
+		'search_items'       => __('Search Forms', 'give'),
63
+		'not_found'          => __('No forms found.', 'give'),
64
+		'not_found_in_trash' => __('No forms found in Trash.', 'give'),
65 65
 		'parent_item_colon'  => '',
66
-		'menu_name'          => apply_filters( 'give_menu_name', __( 'Donations', 'give' ) ),
67
-		'name_admin_bar'     => apply_filters( 'give_name_admin_bar_name', __( 'Donation Form', 'give' ) ),
68
-	) );
66
+		'menu_name'          => apply_filters('give_menu_name', __('Donations', 'give')),
67
+		'name_admin_bar'     => apply_filters('give_name_admin_bar_name', __('Donation Form', 'give')),
68
+	));
69 69
 
70 70
 	// Default give_forms supports.
71 71
 	$give_form_supports = array(
@@ -77,14 +77,14 @@  discard block
 block discarded – undo
77 77
 	);
78 78
 
79 79
 	// Has the user disabled the excerpt?
80
-	if ( ! give_is_setting_enabled( give_get_option( 'forms_excerpt' ) ) ) {
81
-		unset( $give_form_supports[2] );
80
+	if ( ! give_is_setting_enabled(give_get_option('forms_excerpt'))) {
81
+		unset($give_form_supports[2]);
82 82
 	}
83 83
 
84 84
 	// Has user disabled the featured image?
85
-	if ( ! give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) {
86
-		unset( $give_form_supports[1] );
87
-		remove_action( 'give_before_single_form_summary', 'give_show_form_images' );
85
+	if ( ! give_is_setting_enabled(give_get_option('form_featured_img'))) {
86
+		unset($give_form_supports[1]);
87
+		remove_action('give_before_single_form_summary', 'give_show_form_images');
88 88
 	}
89 89
 
90 90
 	$give_forms_args = array(
@@ -99,42 +99,42 @@  discard block
 block discarded – undo
99 99
 		'has_archive'        => $give_forms_archives,
100 100
 		'menu_icon'          => 'dashicons-give',
101 101
 		'hierarchical'       => false,
102
-		'supports'           => apply_filters( 'give_forms_supports', $give_form_supports ),
102
+		'supports'           => apply_filters('give_forms_supports', $give_form_supports),
103 103
 	);
104
-	register_post_type( 'give_forms', apply_filters( 'give_forms_post_type_args', $give_forms_args ) );
104
+	register_post_type('give_forms', apply_filters('give_forms_post_type_args', $give_forms_args));
105 105
 
106 106
 	/** Donation Post Type */
107 107
 	$payment_labels = array(
108
-		'name'               => _x( 'Donations', 'post type general name', 'give' ),
109
-		'singular_name'      => _x( 'Donation', 'post type singular name', 'give' ),
110
-		'add_new'            => __( 'Add New', 'give' ),
111
-		'add_new_item'       => __( 'Add New Donation', 'give' ),
112
-		'edit_item'          => __( 'Edit Donation', 'give' ),
113
-		'new_item'           => __( 'New Donation', 'give' ),
114
-		'all_items'          => __( 'All Donations', 'give' ),
115
-		'view_item'          => __( 'View Donation', 'give' ),
116
-		'search_items'       => __( 'Search Donations', 'give' ),
117
-		'not_found'          => __( 'No donations found.', 'give' ),
118
-		'not_found_in_trash' => __( 'No donations found in Trash.', 'give' ),
108
+		'name'               => _x('Donations', 'post type general name', 'give'),
109
+		'singular_name'      => _x('Donation', 'post type singular name', 'give'),
110
+		'add_new'            => __('Add New', 'give'),
111
+		'add_new_item'       => __('Add New Donation', 'give'),
112
+		'edit_item'          => __('Edit Donation', 'give'),
113
+		'new_item'           => __('New Donation', 'give'),
114
+		'all_items'          => __('All Donations', 'give'),
115
+		'view_item'          => __('View Donation', 'give'),
116
+		'search_items'       => __('Search Donations', 'give'),
117
+		'not_found'          => __('No donations found.', 'give'),
118
+		'not_found_in_trash' => __('No donations found in Trash.', 'give'),
119 119
 		'parent_item_colon'  => '',
120
-		'menu_name'          => __( 'Donations', 'give' ),
120
+		'menu_name'          => __('Donations', 'give'),
121 121
 	);
122 122
 
123 123
 	$payment_args = array(
124
-		'labels'          => apply_filters( 'give_payment_labels', $payment_labels ),
124
+		'labels'          => apply_filters('give_payment_labels', $payment_labels),
125 125
 		'public'          => false,
126 126
 		'query_var'       => false,
127 127
 		'rewrite'         => false,
128 128
 		'map_meta_cap'    => true,
129 129
 		'capability_type' => 'give_payment',
130
-		'supports'        => array( 'title' ),
130
+		'supports'        => array('title'),
131 131
 		'can_export'      => true,
132 132
 	);
133
-	register_post_type( 'give_payment', $payment_args );
133
+	register_post_type('give_payment', $payment_args);
134 134
 
135 135
 }
136 136
 
137
-add_action( 'init', 'give_setup_post_types', 1 );
137
+add_action('init', 'give_setup_post_types', 1);
138 138
 
139 139
 
140 140
 /**
@@ -147,30 +147,30 @@  discard block
 block discarded – undo
147 147
  */
148 148
 function give_setup_taxonomies() {
149 149
 
150
-	$slug = defined( 'GIVE_FORMS_SLUG' ) ? GIVE_FORMS_SLUG : 'donations';
150
+	$slug = defined('GIVE_FORMS_SLUG') ? GIVE_FORMS_SLUG : 'donations';
151 151
 
152 152
 	/** Categories */
153 153
 	$category_labels = array(
154
-		'name'              => _x( 'Form Categories', 'taxonomy general name', 'give' ),
155
-		'singular_name'     => _x( 'Category', 'taxonomy singular name', 'give' ),
156
-		'search_items'      => __( 'Search Categories', 'give' ),
157
-		'all_items'         => __( 'All Categories', 'give' ),
158
-		'parent_item'       => __( 'Parent Category', 'give' ),
159
-		'parent_item_colon' => __( 'Parent Category:', 'give' ),
160
-		'edit_item'         => __( 'Edit Category', 'give' ),
161
-		'update_item'       => __( 'Update Category', 'give' ),
162
-		'add_new_item'      => __( 'Add New Category', 'give' ),
163
-		'new_item_name'     => __( 'New Category Name', 'give' ),
164
-		'menu_name'         => __( 'Categories', 'give' ),
154
+		'name'              => _x('Form Categories', 'taxonomy general name', 'give'),
155
+		'singular_name'     => _x('Category', 'taxonomy singular name', 'give'),
156
+		'search_items'      => __('Search Categories', 'give'),
157
+		'all_items'         => __('All Categories', 'give'),
158
+		'parent_item'       => __('Parent Category', 'give'),
159
+		'parent_item_colon' => __('Parent Category:', 'give'),
160
+		'edit_item'         => __('Edit Category', 'give'),
161
+		'update_item'       => __('Update Category', 'give'),
162
+		'add_new_item'      => __('Add New Category', 'give'),
163
+		'new_item_name'     => __('New Category Name', 'give'),
164
+		'menu_name'         => __('Categories', 'give'),
165 165
 	);
166 166
 
167
-	$category_args = apply_filters( 'give_forms_category_args', array(
167
+	$category_args = apply_filters('give_forms_category_args', array(
168 168
 			'hierarchical' => true,
169
-			'labels'       => apply_filters( 'give_forms_category_labels', $category_labels ),
169
+			'labels'       => apply_filters('give_forms_category_labels', $category_labels),
170 170
 			'show_ui'      => true,
171 171
 			'query_var'    => 'give_forms_category',
172 172
 			'rewrite'      => array(
173
-				'slug'         => $slug . '/category',
173
+				'slug'         => $slug.'/category',
174 174
 				'with_front'   => false,
175 175
 				'hierarchical' => true,
176 176
 			),
@@ -185,26 +185,26 @@  discard block
 block discarded – undo
185 185
 
186 186
 	/** Tags */
187 187
 	$tag_labels = array(
188
-		'name'                  => _x( 'Form Tags', 'taxonomy general name', 'give' ),
189
-		'singular_name'         => _x( 'Tag', 'taxonomy singular name', 'give' ),
190
-		'search_items'          => __( 'Search Tags', 'give' ),
191
-		'all_items'             => __( 'All Tags', 'give' ),
192
-		'parent_item'           => __( 'Parent Tag', 'give' ),
193
-		'parent_item_colon'     => __( 'Parent Tag:', 'give' ),
194
-		'edit_item'             => __( 'Edit Tag', 'give' ),
195
-		'update_item'           => __( 'Update Tag', 'give' ),
196
-		'add_new_item'          => __( 'Add New Tag', 'give' ),
197
-		'new_item_name'         => __( 'New Tag Name', 'give' ),
198
-		'menu_name'             => __( 'Tags', 'give' ),
199
-		'choose_from_most_used' => __( 'Choose from most used tags.', 'give' ),
188
+		'name'                  => _x('Form Tags', 'taxonomy general name', 'give'),
189
+		'singular_name'         => _x('Tag', 'taxonomy singular name', 'give'),
190
+		'search_items'          => __('Search Tags', 'give'),
191
+		'all_items'             => __('All Tags', 'give'),
192
+		'parent_item'           => __('Parent Tag', 'give'),
193
+		'parent_item_colon'     => __('Parent Tag:', 'give'),
194
+		'edit_item'             => __('Edit Tag', 'give'),
195
+		'update_item'           => __('Update Tag', 'give'),
196
+		'add_new_item'          => __('Add New Tag', 'give'),
197
+		'new_item_name'         => __('New Tag Name', 'give'),
198
+		'menu_name'             => __('Tags', 'give'),
199
+		'choose_from_most_used' => __('Choose from most used tags.', 'give'),
200 200
 	);
201 201
 
202
-	$tag_args = apply_filters( 'give_forms_tag_args', array(
202
+	$tag_args = apply_filters('give_forms_tag_args', array(
203 203
 			'hierarchical' => false,
204
-			'labels'       => apply_filters( 'give_forms_tag_labels', $tag_labels ),
204
+			'labels'       => apply_filters('give_forms_tag_labels', $tag_labels),
205 205
 			'show_ui'      => true,
206 206
 			'query_var'    => 'give_forms_tag',
207
-			'rewrite'      => array( 'slug' => $slug . '/tag', 'with_front' => false, 'hierarchical' => true ),
207
+			'rewrite'      => array('slug' => $slug.'/tag', 'with_front' => false, 'hierarchical' => true),
208 208
 			'capabilities' => array(
209 209
 				'manage_terms' => 'manage_give_form_terms',
210 210
 				'edit_terms'   => 'edit_give_form_terms',
@@ -215,36 +215,36 @@  discard block
 block discarded – undo
215 215
 	);
216 216
 
217 217
 	// Does the user want category?
218
-	$enable_category = give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) );
218
+	$enable_category = give_is_setting_enabled(give_get_option('categories', 'disabled'));
219 219
 
220 220
 	// Does the user want tag?
221
-	$enable_tag = give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) );
221
+	$enable_tag = give_is_setting_enabled(give_get_option('tags', 'disabled'));
222 222
 
223 223
 	// Enable/Disable category and tag if form is saving.
224
-	if ( Give_Admin_Settings::is_saving_settings() ) {
225
-		if ( isset( $_POST['categories'] ) ) {
226
-			$enable_category = give_is_setting_enabled( give_clean( $_POST['categories'] ) );
224
+	if (Give_Admin_Settings::is_saving_settings()) {
225
+		if (isset($_POST['categories'])) {
226
+			$enable_category = give_is_setting_enabled(give_clean($_POST['categories']));
227 227
 			flush_rewrite_rules();
228 228
 		}
229 229
 
230
-		if ( isset( $_POST['tags'] ) ) {
231
-			$enable_tag = give_is_setting_enabled( give_clean( $_POST['tags'] ) );
230
+		if (isset($_POST['tags'])) {
231
+			$enable_tag = give_is_setting_enabled(give_clean($_POST['tags']));
232 232
 			flush_rewrite_rules();
233 233
 		}
234 234
 	}
235 235
 
236
-	if ( $enable_category ) {
237
-		register_taxonomy( 'give_forms_category', array( 'give_forms' ), $category_args );
238
-		register_taxonomy_for_object_type( 'give_forms_category', 'give_forms' );
236
+	if ($enable_category) {
237
+		register_taxonomy('give_forms_category', array('give_forms'), $category_args);
238
+		register_taxonomy_for_object_type('give_forms_category', 'give_forms');
239 239
 	}
240 240
 
241
-	if ( $enable_tag ) {
242
-		register_taxonomy( 'give_forms_tag', array( 'give_forms' ), $tag_args );
243
-		register_taxonomy_for_object_type( 'give_forms_tag', 'give_forms' );
241
+	if ($enable_tag) {
242
+		register_taxonomy('give_forms_tag', array('give_forms'), $tag_args);
243
+		register_taxonomy_for_object_type('give_forms_tag', 'give_forms');
244 244
 	}
245 245
 }
246 246
 
247
-add_action( 'init', 'give_setup_taxonomies', 0 );
247
+add_action('init', 'give_setup_taxonomies', 0);
248 248
 
249 249
 
250 250
 /**
@@ -255,11 +255,11 @@  discard block
 block discarded – undo
255 255
  */
256 256
 function give_get_default_form_labels() {
257 257
 	$defaults = array(
258
-		'singular' => __( 'Form', 'give' ),
259
-		'plural'   => __( 'Forms', 'give' ),
258
+		'singular' => __('Form', 'give'),
259
+		'plural'   => __('Forms', 'give'),
260 260
 	);
261 261
 
262
-	return apply_filters( 'give_default_form_name', $defaults );
262
+	return apply_filters('give_default_form_name', $defaults);
263 263
 }
264 264
 
265 265
 /**
@@ -271,10 +271,10 @@  discard block
 block discarded – undo
271 271
  *
272 272
  * @return string $defaults['singular'] Singular label
273 273
  */
274
-function give_get_forms_label_singular( $lowercase = false ) {
274
+function give_get_forms_label_singular($lowercase = false) {
275 275
 	$defaults = give_get_default_form_labels();
276 276
 
277
-	return ( $lowercase ) ? strtolower( $defaults['singular'] ) : $defaults['singular'];
277
+	return ($lowercase) ? strtolower($defaults['singular']) : $defaults['singular'];
278 278
 }
279 279
 
280 280
 /**
@@ -283,10 +283,10 @@  discard block
 block discarded – undo
283 283
  * @since 1.0
284 284
  * @return string $defaults['plural'] Plural label
285 285
  */
286
-function give_get_forms_label_plural( $lowercase = false ) {
286
+function give_get_forms_label_plural($lowercase = false) {
287 287
 	$defaults = give_get_default_form_labels();
288 288
 
289
-	return ( $lowercase ) ? strtolower( $defaults['plural'] ) : $defaults['plural'];
289
+	return ($lowercase) ? strtolower($defaults['plural']) : $defaults['plural'];
290 290
 }
291 291
 
292 292
 /**
@@ -298,24 +298,24 @@  discard block
 block discarded – undo
298 298
  *
299 299
  * @return string $title New placeholder text
300 300
  */
301
-function give_change_default_title( $title ) {
301
+function give_change_default_title($title) {
302 302
 	// If a frontend plugin uses this filter (check extensions before changing this function)
303
-	if ( ! is_admin() ) {
304
-		$title = __( 'Enter form title here', 'give' );
303
+	if ( ! is_admin()) {
304
+		$title = __('Enter form title here', 'give');
305 305
 
306 306
 		return $title;
307 307
 	}
308 308
 
309 309
 	$screen = get_current_screen();
310 310
 
311
-	if ( 'give_forms' == $screen->post_type ) {
312
-		$title = __( 'Enter form title here', 'give' );
311
+	if ('give_forms' == $screen->post_type) {
312
+		$title = __('Enter form title here', 'give');
313 313
 	}
314 314
 
315 315
 	return $title;
316 316
 }
317 317
 
318
-add_filter( 'enter_title_here', 'give_change_default_title' );
318
+add_filter('enter_title_here', 'give_change_default_title');
319 319
 
320 320
 /**
321 321
  * Registers Custom Post Statuses which are used by the Payments
@@ -325,67 +325,67 @@  discard block
 block discarded – undo
325 325
  */
326 326
 function give_register_post_type_statuses() {
327 327
 	// Payment Statuses
328
-	register_post_status( 'refunded', array(
329
-		'label'                     => __( 'Refunded', 'give' ),
328
+	register_post_status('refunded', array(
329
+		'label'                     => __('Refunded', 'give'),
330 330
 		'public'                    => true,
331 331
 		'exclude_from_search'       => false,
332 332
 		'show_in_admin_all_list'    => true,
333 333
 		'show_in_admin_status_list' => true,
334
-		'label_count'               => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give' ),
335
-	) );
336
-	register_post_status( 'failed', array(
337
-		'label'                     => __( 'Failed', 'give' ),
334
+		'label_count'               => _n_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give'),
335
+	));
336
+	register_post_status('failed', array(
337
+		'label'                     => __('Failed', 'give'),
338 338
 		'public'                    => true,
339 339
 		'exclude_from_search'       => false,
340 340
 		'show_in_admin_all_list'    => true,
341 341
 		'show_in_admin_status_list' => true,
342
-		'label_count'               => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give' ),
343
-	) );
344
-	register_post_status( 'revoked', array(
345
-		'label'                     => __( 'Revoked', 'give' ),
342
+		'label_count'               => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give'),
343
+	));
344
+	register_post_status('revoked', array(
345
+		'label'                     => __('Revoked', 'give'),
346 346
 		'public'                    => true,
347 347
 		'exclude_from_search'       => false,
348 348
 		'show_in_admin_all_list'    => true,
349 349
 		'show_in_admin_status_list' => true,
350
-		'label_count'               => _n_noop( 'Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give' ),
351
-	) );
352
-	register_post_status( 'cancelled', array(
353
-		'label'                     => __( 'Cancelled', 'give' ),
350
+		'label_count'               => _n_noop('Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give'),
351
+	));
352
+	register_post_status('cancelled', array(
353
+		'label'                     => __('Cancelled', 'give'),
354 354
 		'public'                    => true,
355 355
 		'exclude_from_search'       => false,
356 356
 		'show_in_admin_all_list'    => true,
357 357
 		'show_in_admin_status_list' => true,
358
-		'label_count'               => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'give' ),
359
-	) );
360
-	register_post_status( 'abandoned', array(
361
-		'label'                     => __( 'Abandoned', 'give' ),
358
+		'label_count'               => _n_noop('Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'give'),
359
+	));
360
+	register_post_status('abandoned', array(
361
+		'label'                     => __('Abandoned', 'give'),
362 362
 		'public'                    => true,
363 363
 		'exclude_from_search'       => false,
364 364
 		'show_in_admin_all_list'    => true,
365 365
 		'show_in_admin_status_list' => true,
366
-		'label_count'               => _n_noop( 'Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give' ),
367
-	) );
368
-	register_post_status( 'processing', array(
369
-		'label'                     => _x( 'Processing', 'Processing payment status', 'give' ),
366
+		'label_count'               => _n_noop('Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give'),
367
+	));
368
+	register_post_status('processing', array(
369
+		'label'                     => _x('Processing', 'Processing payment status', 'give'),
370 370
 		'public'                    => true,
371 371
 		'exclude_from_search'       => false,
372 372
 		'show_in_admin_all_list'    => true,
373 373
 		'show_in_admin_status_list' => true,
374
-		'label_count'               => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'give' )
375
-	)  );
374
+		'label_count'               => _n_noop('Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'give')
375
+	));
376 376
 
377
-	register_post_status( 'preapproval', array(
378
-		'label'                     => _x( 'Preapproval', 'Preapproval payment status', 'give' ),
377
+	register_post_status('preapproval', array(
378
+		'label'                     => _x('Preapproval', 'Preapproval payment status', 'give'),
379 379
 		'public'                    => true,
380 380
 		'exclude_from_search'       => false,
381 381
 		'show_in_admin_all_list'    => true,
382 382
 		'show_in_admin_status_list' => true,
383
-		'label_count'               => _n_noop( 'Preapproval <span class="count">(%s)</span>', 'Preapproval <span class="count">(%s)</span>', 'give' ),
384
-	) );
383
+		'label_count'               => _n_noop('Preapproval <span class="count">(%s)</span>', 'Preapproval <span class="count">(%s)</span>', 'give'),
384
+	));
385 385
 
386 386
 }
387 387
 
388
-add_action( 'init', 'give_register_post_type_statuses' );
388
+add_action('init', 'give_register_post_type_statuses');
389 389
 
390 390
 /**
391 391
  * Updated Messages
@@ -398,27 +398,27 @@  discard block
 block discarded – undo
398 398
  *
399 399
  * @return array $messages New post updated messages
400 400
  */
401
-function give_updated_messages( $messages ) {
401
+function give_updated_messages($messages) {
402 402
 	global $post, $post_ID;
403 403
 
404
-	if ( ! give_is_setting_enabled( give_get_option( 'forms_singular' ) ) ) {
404
+	if ( ! give_is_setting_enabled(give_get_option('forms_singular'))) {
405 405
 
406 406
 		$messages['give_forms'] = array(
407
-			1 => __( 'Form updated.', 'give' ),
408
-			4 => __( 'Form updated.', 'give' ),
409
-			6 => __( 'Form published.', 'give' ),
410
-			7 => __( 'Form saved.', 'give' ),
411
-			8 => __( 'Form submitted.', 'give' ),
407
+			1 => __('Form updated.', 'give'),
408
+			4 => __('Form updated.', 'give'),
409
+			6 => __('Form published.', 'give'),
410
+			7 => __('Form saved.', 'give'),
411
+			8 => __('Form submitted.', 'give'),
412 412
 		);
413 413
 
414 414
 	} else {
415 415
 
416 416
 		$messages['give_forms'] = array(
417
-			1 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form updated.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ),
418
-			4 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form updated.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ),
419
-			6 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form published.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ),
420
-			7 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form saved.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ),
421
-			8 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form submitted.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ),
417
+			1 => sprintf('%1$s <a href="%2$s">%3$s</a>', __('Form updated.', 'give'), get_permalink($post_ID), __('View Form', 'give')),
418
+			4 => sprintf('%1$s <a href="%2$s">%3$s</a>', __('Form updated.', 'give'), get_permalink($post_ID), __('View Form', 'give')),
419
+			6 => sprintf('%1$s <a href="%2$s">%3$s</a>', __('Form published.', 'give'), get_permalink($post_ID), __('View Form', 'give')),
420
+			7 => sprintf('%1$s <a href="%2$s">%3$s</a>', __('Form saved.', 'give'), get_permalink($post_ID), __('View Form', 'give')),
421
+			8 => sprintf('%1$s <a href="%2$s">%3$s</a>', __('Form submitted.', 'give'), get_permalink($post_ID), __('View Form', 'give')),
422 422
 		);
423 423
 
424 424
 	}
@@ -426,24 +426,24 @@  discard block
 block discarded – undo
426 426
 	return $messages;
427 427
 }
428 428
 
429
-add_filter( 'post_updated_messages', 'give_updated_messages' );
429
+add_filter('post_updated_messages', 'give_updated_messages');
430 430
 
431 431
 /**
432 432
  * Ensure post thumbnail support is turned on
433 433
  */
434 434
 function give_add_thumbnail_support() {
435
-	if ( ! give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) {
435
+	if ( ! give_is_setting_enabled(give_get_option('form_featured_img'))) {
436 436
 		return;
437 437
 	}
438 438
 
439
-	if ( ! current_theme_supports( 'post-thumbnails' ) ) {
440
-		add_theme_support( 'post-thumbnails' );
439
+	if ( ! current_theme_supports('post-thumbnails')) {
440
+		add_theme_support('post-thumbnails');
441 441
 	}
442 442
 
443
-	add_post_type_support( 'give_forms', 'thumbnail' );
443
+	add_post_type_support('give_forms', 'thumbnail');
444 444
 }
445 445
 
446
-add_action( 'after_setup_theme', 'give_add_thumbnail_support', 10 );
446
+add_action('after_setup_theme', 'give_add_thumbnail_support', 10);
447 447
 
448 448
 /**
449 449
  * Give Sidebars
@@ -454,21 +454,21 @@  discard block
 block discarded – undo
454 454
 
455 455
 	// Single Give Forms (disabled if single turned off in settings)
456 456
 	if (
457
-		give_is_setting_enabled( give_get_option( 'forms_singular' ) )
458
-		&& give_is_setting_enabled( give_get_option( 'form_sidebar' ) )
457
+		give_is_setting_enabled(give_get_option('forms_singular'))
458
+		&& give_is_setting_enabled(give_get_option('form_sidebar'))
459 459
 	) {
460 460
 
461
-		register_sidebar( apply_filters( 'give_forms_single_sidebar', array(
462
-			'name'          => __( 'Give Single Form Sidebar', 'give' ),
461
+		register_sidebar(apply_filters('give_forms_single_sidebar', array(
462
+			'name'          => __('Give Single Form Sidebar', 'give'),
463 463
 			'id'            => 'give-forms-sidebar',
464
-			'description'   => __( 'Widgets in this area will be shown on the single Give forms aside area. This sidebar will not display for embedded forms.', 'give' ),
464
+			'description'   => __('Widgets in this area will be shown on the single Give forms aside area. This sidebar will not display for embedded forms.', 'give'),
465 465
 			'before_widget' => '<div id="%1$s" class="widget %2$s">',
466 466
 			'after_widget'  => '</div>',
467 467
 			'before_title'  => '<h3 class="widgettitle widget-title">',
468 468
 			'after_title'   => '</h3>',
469
-		) ) );
469
+		)));
470 470
 
471 471
 	}
472 472
 }
473 473
 
474
-add_action( 'widgets_init', 'give_widgets_init', 999 );
474
+add_action('widgets_init', 'give_widgets_init', 999);
Please login to merge, or discard this patch.
includes/emails/template.php 1 patch
Spacing   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
  *
42 42
  * @return string $message Fully formatted message
43 43
  */
44
-function give_email_template_tags( $message, $payment_data, $payment_id, $admin_notice = false ) {
45
-	return give_do_email_tags( $message, $payment_id );
44
+function give_email_template_tags($message, $payment_data, $payment_id, $admin_notice = false) {
45
+	return give_do_email_tags($message, $payment_id);
46 46
 }
47 47
 
48 48
 /**
@@ -56,45 +56,45 @@  discard block
 block discarded – undo
56 56
  *
57 57
  * @return string $message Fully formatted message
58 58
  */
59
-function give_email_preview_template_tags( $message ) {
59
+function give_email_preview_template_tags($message) {
60 60
 
61
-	$price = give_currency_filter( give_format_amount( 10.50, array( 'sanitize' => false ) ) );
61
+	$price = give_currency_filter(give_format_amount(10.50, array('sanitize' => false)));
62 62
 
63 63
 	$gateway = 'PayPal';
64 64
 
65
-	$receipt_id = strtolower( md5( uniqid() ) );
65
+	$receipt_id = strtolower(md5(uniqid()));
66 66
 
67
-	$payment_id = rand( 1, 100 );
68
-	$receipt_link_url = esc_url( add_query_arg( array( 'payment_key' => $receipt_id ), give_get_history_page_uri() ) );
67
+	$payment_id = rand(1, 100);
68
+	$receipt_link_url = esc_url(add_query_arg(array('payment_key' => $receipt_id), give_get_history_page_uri()));
69 69
 
70 70
 	$receipt_link     = sprintf(
71 71
 		'<a href="%1$s">%2$s</a>',
72 72
 		$receipt_link_url,
73
-		esc_html__( 'View the receipt in your browser &raquo;', 'give' )
73
+		esc_html__('View the receipt in your browser &raquo;', 'give')
74 74
 	);
75 75
 
76 76
 	// Set user.
77 77
 	$user = wp_get_current_user();
78 78
 
79
-	$message = str_replace( '{name}', $user->display_name, $message );
80
-	$message = str_replace( '{fullname}', $user->display_name, $message );
81
-	$message = str_replace( '{username}', $user->user_login, $message );
82
-	$message = str_replace( '{user_email}', $user->user_email, $message );
83
-	$message = str_replace( '{billing_address}', "123 Test Street, Unit 222\nSomewhere Town, CA, 92101", $message );
84
-	$message = str_replace( '{date}', date( give_date_format(), current_time( 'timestamp' ) ), $message );
85
-	$message = str_replace( '{amount}', $price, $message );
86
-	$message = str_replace( '{price}', $price, $message );
87
-	$message = str_replace( '{donation}', esc_html__( 'Sample Donation Form Title', 'give' ), $message );
88
-	$message = str_replace( '{form_title}', esc_html__( 'Sample Donation Form Title - Sample Donation Level', 'give' ), $message );
89
-	$message = str_replace( '{receipt_id}', $receipt_id, $message );
90
-	$message = str_replace( '{payment_method}', $gateway, $message );
91
-	$message = str_replace( '{sitename}', get_bloginfo( 'name' ), $message );
92
-	$message = str_replace( '{payment_id}', $payment_id, $message );
93
-	$message = str_replace( '{receipt_link}', $receipt_link, $message );
94
-	$message = str_replace( '{receipt_link_url}', $receipt_link_url, $message );
95
-	$message = str_replace( '{pdf_receipt}', '<a href="#">Download Receipt</a>', $message );
96
-
97
-	return wpautop( apply_filters( 'give_email_preview_template_tags', $message ) );
79
+	$message = str_replace('{name}', $user->display_name, $message);
80
+	$message = str_replace('{fullname}', $user->display_name, $message);
81
+	$message = str_replace('{username}', $user->user_login, $message);
82
+	$message = str_replace('{user_email}', $user->user_email, $message);
83
+	$message = str_replace('{billing_address}', "123 Test Street, Unit 222\nSomewhere Town, CA, 92101", $message);
84
+	$message = str_replace('{date}', date(give_date_format(), current_time('timestamp')), $message);
85
+	$message = str_replace('{amount}', $price, $message);
86
+	$message = str_replace('{price}', $price, $message);
87
+	$message = str_replace('{donation}', esc_html__('Sample Donation Form Title', 'give'), $message);
88
+	$message = str_replace('{form_title}', esc_html__('Sample Donation Form Title - Sample Donation Level', 'give'), $message);
89
+	$message = str_replace('{receipt_id}', $receipt_id, $message);
90
+	$message = str_replace('{payment_method}', $gateway, $message);
91
+	$message = str_replace('{sitename}', get_bloginfo('name'), $message);
92
+	$message = str_replace('{payment_id}', $payment_id, $message);
93
+	$message = str_replace('{receipt_link}', $receipt_link, $message);
94
+	$message = str_replace('{receipt_link_url}', $receipt_link_url, $message);
95
+	$message = str_replace('{pdf_receipt}', '<a href="#">Download Receipt</a>', $message);
96
+
97
+	return wpautop(apply_filters('give_email_preview_template_tags', $message));
98 98
 }
99 99
 
100 100
 /**
@@ -106,23 +106,23 @@  discard block
 block discarded – undo
106 106
  * @since  1.0
107 107
  * @return array|bool
108 108
  */
109
-function give_email_template_preview( $array ) {
109
+function give_email_template_preview($array) {
110 110
 
111
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
111
+	if ( ! current_user_can('manage_give_settings')) {
112 112
 		return false;
113 113
 	}
114 114
 	$custom_field = array(
115
-		'name' => esc_html__( 'Preview Email', 'give' ),
116
-		'desc' => esc_html__( 'Click the buttons to preview or send test emails.', 'give' ),
115
+		'name' => esc_html__('Preview Email', 'give'),
116
+		'desc' => esc_html__('Click the buttons to preview or send test emails.', 'give'),
117 117
 		'id'   => 'give_email_preview_buttons',
118 118
 		'type' => 'email_preview_buttons',
119 119
 	);
120 120
 
121
-	return give_settings_array_insert( $array, 'donation_subject', array( $custom_field ) );
121
+	return give_settings_array_insert($array, 'donation_subject', array($custom_field));
122 122
 
123 123
 }
124 124
 
125
-add_filter( 'give_settings_emails', 'give_email_template_preview' );
125
+add_filter('give_settings_emails', 'give_email_template_preview');
126 126
 
127 127
 /**
128 128
  * Output Email Template Preview Buttons.
@@ -134,14 +134,14 @@  discard block
 block discarded – undo
134 134
 function give_email_preview_buttons_callback() {
135 135
 	ob_start();
136 136
 	?>
137
-	<a href="<?php echo esc_url( add_query_arg( array( 'give_action' => 'preview_email' ), home_url() ) ); ?>" class="button-secondary"
138
-	   target="_blank"><?php esc_html_e( 'Preview Donation Receipt', 'give' ); ?></a>
139
-	<a href="<?php echo wp_nonce_url( add_query_arg( array(
137
+	<a href="<?php echo esc_url(add_query_arg(array('give_action' => 'preview_email'), home_url())); ?>" class="button-secondary"
138
+	   target="_blank"><?php esc_html_e('Preview Donation Receipt', 'give'); ?></a>
139
+	<a href="<?php echo wp_nonce_url(add_query_arg(array(
140 140
 		'give_action'  => 'send_test_email',
141 141
 		'give-message' => 'sent-test-email',
142 142
 		'tag'          => 'emails',
143
-	) ), 'give-test-email' ); ?>" aria-label="<?php esc_attr_e( 'Send demo donation receipt to the emails listed below.', 'give' ); ?>"
144
-	   class="button-secondary"><?php esc_html_e( 'Send Test Email', 'give' ); ?></a>
143
+	)), 'give-test-email'); ?>" aria-label="<?php esc_attr_e('Send demo donation receipt to the emails listed below.', 'give'); ?>"
144
+	   class="button-secondary"><?php esc_html_e('Send Test Email', 'give'); ?></a>
145 145
 	<?php
146 146
 	echo ob_get_clean();
147 147
 }
@@ -154,46 +154,46 @@  discard block
 block discarded – undo
154 154
  */
155 155
 function give_display_email_template_preview() {
156 156
 
157
-	if ( empty( $_GET['give_action'] ) ) {
157
+	if (empty($_GET['give_action'])) {
158 158
 		return;
159 159
 	}
160 160
 
161
-	if ( 'preview_email' !== $_GET['give_action'] ) {
161
+	if ('preview_email' !== $_GET['give_action']) {
162 162
 		return;
163 163
 	}
164 164
 
165
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
165
+	if ( ! current_user_can('manage_give_settings')) {
166 166
 		return;
167 167
 	}
168 168
 
169 169
 
170
-	Give()->emails->heading = esc_html__( 'Donation Receipt', 'give' );
170
+	Give()->emails->heading = esc_html__('Donation Receipt', 'give');
171 171
 
172
-	$payment_id = (int) isset( $_GET['preview_id'] ) ? $_GET['preview_id'] : '';
172
+	$payment_id = (int) isset($_GET['preview_id']) ? $_GET['preview_id'] : '';
173 173
 
174 174
 	echo give_get_preview_email_header();
175 175
 
176 176
 	//Are we previewing an actual payment?
177
-	if ( ! empty( $payment_id ) ) {
177
+	if ( ! empty($payment_id)) {
178 178
 
179
-		$content = give_get_email_body_content( $payment_id );
179
+		$content = give_get_email_body_content($payment_id);
180 180
 
181
-		$preview_content = give_do_email_tags( $content, $payment_id );
181
+		$preview_content = give_do_email_tags($content, $payment_id);
182 182
 
183 183
 	} else {
184 184
 
185 185
 		//No payment ID, use sample preview content
186
-		$preview_content = give_email_preview_template_tags( give_get_email_body_content( 0, array() ) );
186
+		$preview_content = give_email_preview_template_tags(give_get_email_body_content(0, array()));
187 187
 	}
188 188
 
189 189
 
190
-	echo Give()->emails->build_email( $preview_content );
190
+	echo Give()->emails->build_email($preview_content);
191 191
 
192 192
 	exit;
193 193
 
194 194
 }
195 195
 
196
-add_action( 'init', 'give_display_email_template_preview' );
196
+add_action('init', 'give_display_email_template_preview');
197 197
 
198 198
 /**
199 199
  * Email Template Body.
@@ -205,18 +205,18 @@  discard block
 block discarded – undo
205 205
  *
206 206
  * @return string $email_body Body of the email
207 207
  */
208
-function give_get_email_body_content( $payment_id = 0, $payment_data = array() ) {
208
+function give_get_email_body_content($payment_id = 0, $payment_data = array()) {
209 209
 
210 210
 	$default_email_body = give_get_default_donation_receipt_email();
211 211
 
212
-	$email_content = give_get_option( 'donation_receipt' );
213
-	$email_content = ( $email_content ) ? stripslashes( $email_content ) : $default_email_body;
212
+	$email_content = give_get_option('donation_receipt');
213
+	$email_content = ($email_content) ? stripslashes($email_content) : $default_email_body;
214 214
 
215
-	$email_body = wpautop( $email_content );
215
+	$email_body = wpautop($email_content);
216 216
 
217
-	$email_body = apply_filters( 'give_donation_receipt_' . Give()->emails->get_template(), $email_body, $payment_id, $payment_data );
217
+	$email_body = apply_filters('give_donation_receipt_'.Give()->emails->get_template(), $email_body, $payment_id, $payment_data);
218 218
 
219
-	return apply_filters( 'give_donation_receipt', $email_body, $payment_id, $payment_data );
219
+	return apply_filters('give_donation_receipt', $email_body, $payment_id, $payment_data);
220 220
 }
221 221
 
222 222
 /**
@@ -229,35 +229,35 @@  discard block
 block discarded – undo
229 229
  *
230 230
  * @return string $email_body Body of the email
231 231
  */
232
-function give_get_donation_notification_body_content( $payment_id = 0, $payment_data = array() ) {
232
+function give_get_donation_notification_body_content($payment_id = 0, $payment_data = array()) {
233 233
 
234
-	$payment = new Give_Payment( $payment_id );
234
+	$payment = new Give_Payment($payment_id);
235 235
 
236
-	if ( $payment->user_id > 0 ) {
237
-		$user_data = get_userdata( $payment->user_id );
236
+	if ($payment->user_id > 0) {
237
+		$user_data = get_userdata($payment->user_id);
238 238
 		$name      = $user_data->display_name;
239
-	} elseif ( ! empty( $payment->first_name ) && ! empty( $payment->last_name ) ) {
240
-		$name = $payment->first_name . ' ' . $payment->last_name;
239
+	} elseif ( ! empty($payment->first_name) && ! empty($payment->last_name)) {
240
+		$name = $payment->first_name.' '.$payment->last_name;
241 241
 	} else {
242 242
 		$name = $payment->email;
243 243
 	}
244 244
 
245
-	$gateway = give_get_gateway_admin_label( $payment->gateway );
245
+	$gateway = give_get_gateway_admin_label($payment->gateway);
246 246
 
247
-	$default_email_body = esc_html__( 'Hello', 'give' ) . "\n\n";
248
-	$default_email_body .= esc_html__( 'A donation has been made.', 'give' ) . "\n\n";
249
-	$default_email_body .= esc_html__( 'Donation:', 'give' ) . "\n\n";
250
-	$default_email_body .= esc_html__( 'Donor:', 'give' ) . ' ' . html_entity_decode( $name, ENT_COMPAT, 'UTF-8' ) . "\n";
251
-	$default_email_body .= esc_html__( 'Amount:', 'give' ) . ' ' . html_entity_decode( give_currency_filter( give_format_amount( $payment->total, array( 'sanitize' => false ) ) ), ENT_COMPAT, 'UTF-8' ) . "\n";
252
-	$default_email_body .= esc_html__( 'Payment Method:', 'give' ) . ' ' . $gateway . "\n\n";
253
-	$default_email_body .= esc_html__( 'Thank you', 'give' );
247
+	$default_email_body = esc_html__('Hello', 'give')."\n\n";
248
+	$default_email_body .= esc_html__('A donation has been made.', 'give')."\n\n";
249
+	$default_email_body .= esc_html__('Donation:', 'give')."\n\n";
250
+	$default_email_body .= esc_html__('Donor:', 'give').' '.html_entity_decode($name, ENT_COMPAT, 'UTF-8')."\n";
251
+	$default_email_body .= esc_html__('Amount:', 'give').' '.html_entity_decode(give_currency_filter(give_format_amount($payment->total, array('sanitize' => false))), ENT_COMPAT, 'UTF-8')."\n";
252
+	$default_email_body .= esc_html__('Payment Method:', 'give').' '.$gateway."\n\n";
253
+	$default_email_body .= esc_html__('Thank you', 'give');
254 254
 
255
-	$message = give_get_option( 'donation_notification' );
256
-	$message = isset( $message ) ? stripslashes( $message ) : $default_email_body;
255
+	$message = give_get_option('donation_notification');
256
+	$message = isset($message) ? stripslashes($message) : $default_email_body;
257 257
 
258
-	$email_body = give_do_email_tags( $message, $payment_id );
258
+	$email_body = give_do_email_tags($message, $payment_id);
259 259
 
260
-	return apply_filters( 'give_donation_notification', wpautop( $email_body ), $payment_id, $payment_data );
260
+	return apply_filters('give_donation_notification', wpautop($email_body), $payment_id, $payment_data);
261 261
 }
262 262
 
263 263
 /**
@@ -270,19 +270,19 @@  discard block
 block discarded – undo
270 270
  * @since  1.0
271 271
  */
272 272
 function give_render_receipt_in_browser() {
273
-	if ( ! isset( $_GET['payment_key'] ) ) {
274
-		wp_die( esc_html__( 'Missing donation payment key.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) );
273
+	if ( ! isset($_GET['payment_key'])) {
274
+		wp_die(esc_html__('Missing donation payment key.', 'give'), esc_html__('Error', 'give'), array('response' => 400));
275 275
 	}
276 276
 
277
-	$key = urlencode( $_GET['payment_key'] );
277
+	$key = urlencode($_GET['payment_key']);
278 278
 
279 279
 	ob_start();
280 280
 	//Disallows caching of the page
281
-	header( "Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . " GMT" );
282
-	header( "Cache-Control: no-store, no-cache, must-revalidate" ); // HTTP/1.1
283
-	header( "Cache-Control: post-check=0, pre-check=0", false );
284
-	header( "Pragma: no-cache" ); // HTTP/1.0
285
-	header( "Expires: Sat, 23 Oct 1977 05:00:00 PST" ); // Date in the past
281
+	header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
282
+	header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
283
+	header("Cache-Control: post-check=0, pre-check=0", false);
284
+	header("Pragma: no-cache"); // HTTP/1.0
285
+	header("Expires: Sat, 23 Oct 1977 05:00:00 PST"); // Date in the past
286 286
 	?>
287 287
 	<!DOCTYPE html>
288 288
 	<html lang="en">
@@ -293,10 +293,10 @@  discard block
 block discarded – undo
293 293
 		 *
294 294
 		 * @since 1.0
295 295
 		 */
296
-		do_action( 'give_receipt_head' );
296
+		do_action('give_receipt_head');
297 297
 		?>
298 298
 	</head>
299
-	<body class="<?php echo apply_filters( 'give_receipt_page_body_class', 'give_receipt_page' ); ?>">
299
+	<body class="<?php echo apply_filters('give_receipt_page_body_class', 'give_receipt_page'); ?>">
300 300
 
301 301
 	<div id="give_receipt_wrapper">
302 302
 		<?php
@@ -305,16 +305,16 @@  discard block
 block discarded – undo
305 305
 		 *
306 306
 		 * @since 1.0
307 307
 		 */
308
-		do_action( 'give_render_receipt_in_browser_before' );
308
+		do_action('give_render_receipt_in_browser_before');
309 309
 
310
-		echo do_shortcode( '[give_receipt payment_key=' . $key . ']' );
310
+		echo do_shortcode('[give_receipt payment_key='.$key.']');
311 311
 
312 312
 		/**
313 313
 		 * Fires in the receipt template after the content.
314 314
 		 *
315 315
 		 * @since 1.0
316 316
 		 */
317
-		do_action( 'give_render_receipt_in_browser_after' );
317
+		do_action('give_render_receipt_in_browser_after');
318 318
 		?>
319 319
 	</div>
320 320
 
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 	 *
325 325
 	 * @since 1.0
326 326
 	 */
327
-	do_action( 'give_receipt_footer' );
327
+	do_action('give_receipt_footer');
328 328
 	?>
329 329
 	</body>
330 330
 	</html>
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 	die();
334 334
 }
335 335
 
336
-add_action( 'give_view_receipt', 'give_render_receipt_in_browser' );
336
+add_action('give_view_receipt', 'give_render_receipt_in_browser');
337 337
 
338 338
 
339 339
 /**
@@ -348,29 +348,29 @@  discard block
 block discarded – undo
348 348
 
349 349
 	//Payment receipt switcher
350 350
 	$payment_count = give_count_payments()->publish;
351
-	$payment_id    = (int) isset( $_GET['preview_id'] ) ? $_GET['preview_id'] : '';
351
+	$payment_id    = (int) isset($_GET['preview_id']) ? $_GET['preview_id'] : '';
352 352
 
353
-	if ( $payment_count <= 0 ) {
353
+	if ($payment_count <= 0) {
354 354
 		return false;
355 355
 	}
356 356
 
357 357
 	//Get payments.
358
-	$payments = new Give_Payments_Query( array(
358
+	$payments = new Give_Payments_Query(array(
359 359
 		'number' => 100,
360
-	) );
360
+	));
361 361
 	$payments = $payments->get_payments();
362 362
 	$options  = array();
363 363
 
364 364
 	//Provide nice human readable options.
365
-	if ( $payments ) {
366
-		$options[0] = esc_html__( '- Select a donation -', 'give' );
367
-		foreach ( $payments as $payment ) {
365
+	if ($payments) {
366
+		$options[0] = esc_html__('- Select a donation -', 'give');
367
+		foreach ($payments as $payment) {
368 368
 
369
-			$options[ $payment->ID ] = esc_html( '#' . $payment->ID . ' - ' . $payment->email . ' - ' . $payment->form_title );
369
+			$options[$payment->ID] = esc_html('#'.$payment->ID.' - '.$payment->email.' - '.$payment->form_title);
370 370
 
371 371
 		}
372 372
 	} else {
373
-		$options[0] = esc_html__( 'No donations found.', 'give' );
373
+		$options[0] = esc_html__('No donations found.', 'give');
374 374
 	}
375 375
 
376 376
 	//Start constructing HTML output.
@@ -383,16 +383,16 @@  discard block
 block discarded – undo
383 383
 			        var selected_trans = transactions.options[transactions.selectedIndex];
384 384
 				        console.log(selected_trans);
385 385
 				        if (selected_trans){
386
-				            var url_string = "' . get_bloginfo( 'url' ) . '?give_action=preview_email&preview_id=" + selected_trans.value;
386
+				            var url_string = "' . get_bloginfo('url').'?give_action=preview_email&preview_id=" + selected_trans.value;
387 387
 				                window.location = url_string;
388 388
 				        }
389 389
 				    }
390 390
 			    </script>';
391 391
 
392
-	$transaction_header .= '<label for="give_preview_email_payment_id" style="font-size:12px;color:#333;margin:0 4px 0 0;">' . esc_html__( 'Preview email with a donation:', 'give' ) . '</label>';
392
+	$transaction_header .= '<label for="give_preview_email_payment_id" style="font-size:12px;color:#333;margin:0 4px 0 0;">'.esc_html__('Preview email with a donation:', 'give').'</label>';
393 393
 
394 394
 	//The select field with 100 latest transactions
395
-	$transaction_header .= Give()->html->select( array(
395
+	$transaction_header .= Give()->html->select(array(
396 396
 		'name'             => 'preview_email_payment_id',
397 397
 		'selected'         => $payment_id,
398 398
 		'id'               => 'give_preview_email_payment_id',
@@ -402,12 +402,12 @@  discard block
 block discarded – undo
402 402
 		'select_atts'      => 'onchange="change_preview()">',
403 403
 		'show_option_all'  => false,
404 404
 		'show_option_none' => false,
405
-	) );
405
+	));
406 406
 
407 407
 	//Closing tag
408 408
 	$transaction_header .= '</div>';
409 409
 
410
-	return apply_filters( 'give_preview_email_receipt_header', $transaction_header );
410
+	return apply_filters('give_preview_email_receipt_header', $transaction_header);
411 411
 
412 412
 }
413 413
 
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
 function give_receipt_head_content() {
422 422
 
423 423
 	//Title.
424
-	$output = '<title>' . esc_html__( 'Donation Receipt', 'give' ) . '</title>';
424
+	$output = '<title>'.esc_html__('Donation Receipt', 'give').'</title>';
425 425
 
426 426
 	//Meta.
427 427
 	$output .= '<meta charset="utf-8"/>
@@ -435,10 +435,10 @@  discard block
 block discarded – undo
435 435
 		<meta name="robots" content="noindex, nofollow"/>';
436 436
 
437 437
 	//CSS
438
-	$output .= '<link rel="stylesheet" href="' . give_get_stylesheet_uri() . '?ver=' . GIVE_VERSION . '">';
438
+	$output .= '<link rel="stylesheet" href="'.give_get_stylesheet_uri().'?ver='.GIVE_VERSION.'">';
439 439
 
440
-	echo apply_filters( 'give_receipt_head_content', $output );
440
+	echo apply_filters('give_receipt_head_content', $output);
441 441
 
442 442
 }
443 443
 
444
-add_action( 'give_receipt_head', 'give_receipt_head_content' );
445 444
\ No newline at end of file
445
+add_action('give_receipt_head', 'give_receipt_head_content');
446 446
\ No newline at end of file
Please login to merge, or discard this patch.
includes/emails/class-give-email-tags.php 1 patch
Spacing   +112 added lines, -112 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  */
24 24
 
25 25
 // Exit if accessed directly.
26
-if ( ! defined( 'ABSPATH' ) ) {
26
+if ( ! defined('ABSPATH')) {
27 27
 	exit;
28 28
 }
29 29
 
@@ -55,9 +55,9 @@  discard block
 block discarded – undo
55 55
 	 * @param string   $description Email tag description text
56 56
 	 * @param callable $func        Hook to run when email tag is found
57 57
 	 */
58
-	public function add( $tag, $description, $func ) {
59
-		if ( is_callable( $func ) ) {
60
-			$this->tags[ $tag ] = array(
58
+	public function add($tag, $description, $func) {
59
+		if (is_callable($func)) {
60
+			$this->tags[$tag] = array(
61 61
 				'tag'         => $tag,
62 62
 				'description' => $description,
63 63
 				'func'        => $func,
@@ -72,8 +72,8 @@  discard block
 block discarded – undo
72 72
 	 *
73 73
 	 * @param string $tag Email tag to remove hook from
74 74
 	 */
75
-	public function remove( $tag ) {
76
-		unset( $this->tags[ $tag ] );
75
+	public function remove($tag) {
76
+		unset($this->tags[$tag]);
77 77
 	}
78 78
 
79 79
 	/**
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
 	 *
86 86
 	 * @return bool
87 87
 	 */
88
-	public function email_tag_exists( $tag ) {
89
-		return array_key_exists( $tag, $this->tags );
88
+	public function email_tag_exists($tag) {
89
+		return array_key_exists($tag, $this->tags);
90 90
 	}
91 91
 
92 92
 	/**
@@ -110,16 +110,16 @@  discard block
 block discarded – undo
110 110
 	 *
111 111
 	 * @return string Content with email tags filtered out.
112 112
 	 */
113
-	public function do_tags( $content, $payment_id ) {
113
+	public function do_tags($content, $payment_id) {
114 114
 
115 115
 		// Check if there is at least one tag added.
116
-		if ( empty( $this->tags ) || ! is_array( $this->tags ) ) {
116
+		if (empty($this->tags) || ! is_array($this->tags)) {
117 117
 			return $content;
118 118
 		}
119 119
 
120 120
 		$this->payment_id = $payment_id;
121 121
 
122
-		$new_content = preg_replace_callback( "/{([A-z0-9\-\_]+)}/s", array( $this, 'do_tag' ), $content );
122
+		$new_content = preg_replace_callback("/{([A-z0-9\-\_]+)}/s", array($this, 'do_tag'), $content);
123 123
 
124 124
 		$this->payment_id = null;
125 125
 
@@ -135,17 +135,17 @@  discard block
 block discarded – undo
135 135
 	 *
136 136
 	 * @return mixed
137 137
 	 */
138
-	public function do_tag( $m ) {
138
+	public function do_tag($m) {
139 139
 
140 140
 		// Get tag
141 141
 		$tag = $m[1];
142 142
 
143 143
 		// Return tag if tag not set
144
-		if ( ! $this->email_tag_exists( $tag ) ) {
144
+		if ( ! $this->email_tag_exists($tag)) {
145 145
 			return $m[0];
146 146
 		}
147 147
 
148
-		return call_user_func( $this->tags[ $tag ]['func'], $this->payment_id, $tag );
148
+		return call_user_func($this->tags[$tag]['func'], $this->payment_id, $tag);
149 149
 	}
150 150
 
151 151
 }
@@ -159,8 +159,8 @@  discard block
 block discarded – undo
159 159
  * @param string   $description Description of the email tag added
160 160
  * @param callable $func        Hook to run when email tag is found
161 161
  */
162
-function give_add_email_tag( $tag, $description, $func ) {
163
-	Give()->email_tags->add( $tag, $description, $func );
162
+function give_add_email_tag($tag, $description, $func) {
163
+	Give()->email_tags->add($tag, $description, $func);
164 164
 }
165 165
 
166 166
 /**
@@ -170,8 +170,8 @@  discard block
 block discarded – undo
170 170
  *
171 171
  * @param string $tag Email tag to remove hook from
172 172
  */
173
-function give_remove_email_tag( $tag ) {
174
-	Give()->email_tags->remove( $tag );
173
+function give_remove_email_tag($tag) {
174
+	Give()->email_tags->remove($tag);
175 175
 }
176 176
 
177 177
 /**
@@ -183,8 +183,8 @@  discard block
 block discarded – undo
183 183
  *
184 184
  * @return bool
185 185
  */
186
-function give_email_tag_exists( $tag ) {
187
-	return Give()->email_tags->email_tag_exists( $tag );
186
+function give_email_tag_exists($tag) {
187
+	return Give()->email_tags->email_tag_exists($tag);
188 188
 }
189 189
 
190 190
 /**
@@ -211,9 +211,9 @@  discard block
 block discarded – undo
211 211
 	$email_tags = give_get_email_tags();
212 212
 
213 213
 	ob_start();
214
-	if ( count( $email_tags ) > 0 ) : ?>
214
+	if (count($email_tags) > 0) : ?>
215 215
 		<div class="give-email-tags-wrap">
216
-			<?php foreach ( $email_tags as $email_tag ) : ?>
216
+			<?php foreach ($email_tags as $email_tag) : ?>
217 217
 				<span class="give_<?php echo $email_tag['tag']; ?>_tag">
218 218
 					<code>{<?php echo $email_tag['tag']; ?>}</code> - <?php echo $email_tag['description']; ?>
219 219
 				</span>
@@ -235,12 +235,12 @@  discard block
 block discarded – undo
235 235
  *
236 236
  * @return string Content with email tags filtered out.
237 237
  */
238
-function give_do_email_tags( $content, $payment_id ) {
238
+function give_do_email_tags($content, $payment_id) {
239 239
 
240 240
 	// Replace all tags
241
-	$content = Give()->email_tags->do_tags( $content, $payment_id );
241
+	$content = Give()->email_tags->do_tags($content, $payment_id);
242 242
 
243
-	$content = apply_filters( 'give_email_template_tags', $content, give_get_payment_meta( $payment_id ), $payment_id );
243
+	$content = apply_filters('give_email_template_tags', $content, give_get_payment_meta($payment_id), $payment_id);
244 244
 
245 245
 	// Return content
246 246
 	return $content;
@@ -259,10 +259,10 @@  discard block
 block discarded – undo
259 259
 	 *
260 260
 	 * @since 1.0
261 261
 	 */
262
-	do_action( 'give_add_email_tags' );
262
+	do_action('give_add_email_tags');
263 263
 }
264 264
 
265
-add_action( 'init', 'give_load_email_tags', - 999 );
265
+add_action('init', 'give_load_email_tags', - 999);
266 266
 
267 267
 
268 268
 /**
@@ -276,97 +276,97 @@  discard block
 block discarded – undo
276 276
 	$email_tags = array(
277 277
 		array(
278 278
 			'tag'         => 'donation',
279
-			'description' => __( 'The donation form name, and the donation level (if applicable).', 'give' ),
279
+			'description' => __('The donation form name, and the donation level (if applicable).', 'give'),
280 280
 			'function'    => 'give_email_tag_donation',
281 281
 		),
282 282
 		array(
283 283
 			'tag'         => 'form_title',
284
-			'description' => __( 'The donation form name.', 'give' ),
284
+			'description' => __('The donation form name.', 'give'),
285 285
 			'function'    => 'give_email_tag_form_title',
286 286
 		),
287 287
 		array(
288 288
 			'tag'         => 'amount',
289
-			'description' => __( 'The total donation amount with currency sign.', 'give' ),
289
+			'description' => __('The total donation amount with currency sign.', 'give'),
290 290
 			'function'    => 'give_email_tag_amount',
291 291
 		),
292 292
 		array(
293 293
 			'tag'         => 'price',
294
-			'description' => __( 'The total donation amount with currency sign.', 'give' ),
294
+			'description' => __('The total donation amount with currency sign.', 'give'),
295 295
 			'function'    => 'give_email_tag_price',
296 296
 		),
297 297
 		array(
298 298
 			'tag'         => 'name',
299
-			'description' => __( 'The donor\'s first name.', 'give' ),
299
+			'description' => __('The donor\'s first name.', 'give'),
300 300
 			'function'    => 'give_email_tag_first_name',
301 301
 		),
302 302
 		array(
303 303
 			'tag'         => 'fullname',
304
-			'description' => __( 'The donor\'s full name, first and last.', 'give' ),
304
+			'description' => __('The donor\'s full name, first and last.', 'give'),
305 305
 			'function'    => 'give_email_tag_fullname',
306 306
 		),
307 307
 		array(
308 308
 			'tag'         => 'username',
309
-			'description' => __( 'The donor\'s user name on the site, if they registered an account.', 'give' ),
309
+			'description' => __('The donor\'s user name on the site, if they registered an account.', 'give'),
310 310
 			'function'    => 'give_email_tag_username',
311 311
 		),
312 312
 		array(
313 313
 			'tag'         => 'user_email',
314
-			'description' => __( 'The donor\'s email address.', 'give' ),
314
+			'description' => __('The donor\'s email address.', 'give'),
315 315
 			'function'    => 'give_email_tag_user_email',
316 316
 		),
317 317
 		array(
318 318
 			'tag'         => 'billing_address',
319
-			'description' => __( 'The donor\'s billing address.', 'give' ),
319
+			'description' => __('The donor\'s billing address.', 'give'),
320 320
 			'function'    => 'give_email_tag_billing_address',
321 321
 		),
322 322
 		array(
323 323
 			'tag'         => 'date',
324
-			'description' => __( 'The date of the donation.', 'give' ),
324
+			'description' => __('The date of the donation.', 'give'),
325 325
 			'function'    => 'give_email_tag_date',
326 326
 		),
327 327
 		array(
328 328
 			'tag'         => 'payment_id',
329
-			'description' => __( 'The unique ID number for this donation.', 'give' ),
329
+			'description' => __('The unique ID number for this donation.', 'give'),
330 330
 			'function'    => 'give_email_tag_payment_id',
331 331
 		),
332 332
 		array(
333 333
 			'tag'         => 'receipt_id',
334
-			'description' => __( 'The unique ID number for this donation receipt.', 'give' ),
334
+			'description' => __('The unique ID number for this donation receipt.', 'give'),
335 335
 			'function'    => 'give_email_tag_receipt_id',
336 336
 		),
337 337
 		array(
338 338
 			'tag'         => 'payment_method',
339
-			'description' => __( 'The method of payment used for this donation.', 'give' ),
339
+			'description' => __('The method of payment used for this donation.', 'give'),
340 340
 			'function'    => 'give_email_tag_payment_method',
341 341
 		),
342 342
 		array(
343 343
 			'tag'         => 'sitename',
344
-			'description' => __( 'The name of your site.', 'give' ),
344
+			'description' => __('The name of your site.', 'give'),
345 345
 			'function'    => 'give_email_tag_sitename',
346 346
 		),
347 347
 		array(
348 348
 			'tag'         => 'receipt_link',
349
-			'description' => __( 'The donation receipt direct link, to view the receipt on the website.', 'give' ),
349
+			'description' => __('The donation receipt direct link, to view the receipt on the website.', 'give'),
350 350
 			'function'    => 'give_email_tag_receipt_link',
351 351
 		),
352 352
 		array(
353 353
 			'tag'         => 'receipt_link_url',
354
-			'description' => __( 'The donation receipt direct URL, to view the receipt on the website.', 'give' ),
354
+			'description' => __('The donation receipt direct URL, to view the receipt on the website.', 'give'),
355 355
 			'function'    => 'give_email_tag_receipt_link_url',
356 356
 		),
357 357
 	);
358 358
 
359 359
 	// Apply give_email_tags filter
360
-	$email_tags = apply_filters( 'give_email_tags', $email_tags );
360
+	$email_tags = apply_filters('give_email_tags', $email_tags);
361 361
 
362 362
 	// Add email tags
363
-	foreach ( $email_tags as $email_tag ) {
364
-		give_add_email_tag( $email_tag['tag'], $email_tag['description'], $email_tag['function'] );
363
+	foreach ($email_tags as $email_tag) {
364
+		give_add_email_tag($email_tag['tag'], $email_tag['description'], $email_tag['function']);
365 365
 	}
366 366
 
367 367
 }
368 368
 
369
-add_action( 'give_add_email_tags', 'give_setup_email_tags' );
369
+add_action('give_add_email_tags', 'give_setup_email_tags');
370 370
 
371 371
 
372 372
 /**
@@ -378,15 +378,15 @@  discard block
 block discarded – undo
378 378
  *
379 379
  * @return string name
380 380
  */
381
-function give_email_tag_first_name( $payment_id ) {
382
-	$payment   = new Give_Payment( $payment_id );
381
+function give_email_tag_first_name($payment_id) {
382
+	$payment   = new Give_Payment($payment_id);
383 383
 	$user_info = $payment->user_info;
384 384
 
385
-	if ( empty( $user_info ) ) {
385
+	if (empty($user_info)) {
386 386
 		return '';
387 387
 	}
388 388
 
389
-	$email_name = give_get_email_names( $user_info );
389
+	$email_name = give_get_email_names($user_info);
390 390
 
391 391
 	return $email_name['name'];
392 392
 }
@@ -400,15 +400,15 @@  discard block
 block discarded – undo
400 400
  *
401 401
  * @return string fullname
402 402
  */
403
-function give_email_tag_fullname( $payment_id ) {
404
-	$payment   = new Give_Payment( $payment_id );
403
+function give_email_tag_fullname($payment_id) {
404
+	$payment   = new Give_Payment($payment_id);
405 405
 	$user_info = $payment->user_info;
406 406
 
407
-	if ( empty( $user_info ) ) {
407
+	if (empty($user_info)) {
408 408
 		return '';
409 409
 	}
410 410
 
411
-	$email_name = give_get_email_names( $user_info );
411
+	$email_name = give_get_email_names($user_info);
412 412
 
413 413
 	return $email_name['fullname'];
414 414
 }
@@ -422,15 +422,15 @@  discard block
 block discarded – undo
422 422
  *
423 423
  * @return string username.
424 424
  */
425
-function give_email_tag_username( $payment_id ) {
426
-	$payment   = new Give_Payment( $payment_id );
425
+function give_email_tag_username($payment_id) {
426
+	$payment   = new Give_Payment($payment_id);
427 427
 	$user_info = $payment->user_info;
428 428
 
429
-	if ( empty( $user_info ) ) {
429
+	if (empty($user_info)) {
430 430
 		return '';
431 431
 	}
432 432
 
433
-	$email_name = give_get_email_names( $user_info );
433
+	$email_name = give_get_email_names($user_info);
434 434
 
435 435
 	return $email_name['username'];
436 436
 }
@@ -444,8 +444,8 @@  discard block
 block discarded – undo
444 444
  *
445 445
  * @return string user_email
446 446
  */
447
-function give_email_tag_user_email( $payment_id ) {
448
-	$payment = new Give_Payment( $payment_id );
447
+function give_email_tag_user_email($payment_id) {
448
+	$payment = new Give_Payment($payment_id);
449 449
 
450 450
 	return $payment->email;
451 451
 }
@@ -459,9 +459,9 @@  discard block
 block discarded – undo
459 459
  *
460 460
  * @return string billing_address
461 461
  */
462
-function give_email_tag_billing_address( $payment_id ) {
463
-	$user_info    = give_get_payment_meta_user_info( $payment_id );
464
-	$user_address = ! empty( $user_info['address'] ) ? $user_info['address'] : array(
462
+function give_email_tag_billing_address($payment_id) {
463
+	$user_info    = give_get_payment_meta_user_info($payment_id);
464
+	$user_address = ! empty($user_info['address']) ? $user_info['address'] : array(
465 465
 		'line1'   => '',
466 466
 		'line2'   => '',
467 467
 		'city'    => '',
@@ -471,24 +471,24 @@  discard block
 block discarded – undo
471 471
 	);
472 472
 
473 473
 	$return = $user_address['line1'];
474
-	if ( ! empty( $user_address['line2'] ) ) {
475
-		$return .= ', ' . $user_address['line2'];
474
+	if ( ! empty($user_address['line2'])) {
475
+		$return .= ', '.$user_address['line2'];
476 476
 	}
477
-	if ( ! empty( $user_address['city'] ) ) {
478
-		$return .= "\n" . $user_address['city'];
477
+	if ( ! empty($user_address['city'])) {
478
+		$return .= "\n".$user_address['city'];
479 479
 	}
480
-	if ( ! empty( $user_address['state'] ) ) {
481
-		$return .= ', ' . $user_address['state'];
480
+	if ( ! empty($user_address['state'])) {
481
+		$return .= ', '.$user_address['state'];
482 482
 	}
483
-	if ( ! empty( $user_address['zip'] ) ) {
484
-		$return .= ' ' . $user_address['zip'];
483
+	if ( ! empty($user_address['zip'])) {
484
+		$return .= ' '.$user_address['zip'];
485 485
 	}
486
-	if ( ! empty( $user_address['country'] ) ) {
487
-		$return .= "\n" . give_get_country_name_by_key( $user_address['country'] );
486
+	if ( ! empty($user_address['country'])) {
487
+		$return .= "\n".give_get_country_name_by_key($user_address['country']);
488 488
 	}
489 489
 
490
-	if ( empty( $return ) ) {
491
-		$return = __( 'None provided', 'give' );
490
+	if (empty($return)) {
491
+		$return = __('None provided', 'give');
492 492
 	}
493 493
 
494 494
 	return apply_filters('give_email_tag_billing_address', $return, $payment_id);
@@ -504,10 +504,10 @@  discard block
 block discarded – undo
504 504
  *
505 505
  * @return string date
506 506
  */
507
-function give_email_tag_date( $payment_id ) {
508
-	$payment = new Give_Payment( $payment_id );
507
+function give_email_tag_date($payment_id) {
508
+	$payment = new Give_Payment($payment_id);
509 509
 
510
-	return date_i18n( give_date_format(), strtotime( $payment->date ) );
510
+	return date_i18n(give_date_format(), strtotime($payment->date));
511 511
 }
512 512
 
513 513
 /**
@@ -519,11 +519,11 @@  discard block
 block discarded – undo
519 519
  *
520 520
  * @return string amount
521 521
  */
522
-function give_email_tag_amount( $payment_id ) {
523
-	$payment     = new Give_Payment( $payment_id );
524
-	$give_amount = give_currency_filter( give_format_amount( $payment->total, array( 'sanitize' => false ) ), $payment->currency );
522
+function give_email_tag_amount($payment_id) {
523
+	$payment     = new Give_Payment($payment_id);
524
+	$give_amount = give_currency_filter(give_format_amount($payment->total, array('sanitize' => false)), $payment->currency);
525 525
 
526
-	return html_entity_decode( $give_amount, ENT_COMPAT, 'UTF-8' );
526
+	return html_entity_decode($give_amount, ENT_COMPAT, 'UTF-8');
527 527
 }
528 528
 
529 529
 /**
@@ -535,8 +535,8 @@  discard block
 block discarded – undo
535 535
  *
536 536
  * @return string price
537 537
  */
538
-function give_email_tag_price( $payment_id ) {
539
-	return give_email_tag_amount( $payment_id );
538
+function give_email_tag_price($payment_id) {
539
+	return give_email_tag_amount($payment_id);
540 540
 }
541 541
 
542 542
 /**
@@ -548,8 +548,8 @@  discard block
 block discarded – undo
548 548
  *
549 549
  * @return int payment_id
550 550
  */
551
-function give_email_tag_payment_id( $payment_id ) {
552
-	$payment = new Give_Payment( $payment_id );
551
+function give_email_tag_payment_id($payment_id) {
552
+	$payment = new Give_Payment($payment_id);
553 553
 
554 554
 	return $payment->number;
555 555
 }
@@ -563,8 +563,8 @@  discard block
 block discarded – undo
563 563
  *
564 564
  * @return string receipt_id
565 565
  */
566
-function give_email_tag_receipt_id( $payment_id ) {
567
-	$payment = new Give_Payment( $payment_id );
566
+function give_email_tag_receipt_id($payment_id) {
567
+	$payment = new Give_Payment($payment_id);
568 568
 
569 569
 	return $payment->key;
570 570
 }
@@ -578,14 +578,14 @@  discard block
 block discarded – undo
578 578
  *
579 579
  * @return string $form_title
580 580
  */
581
-function give_email_tag_donation( $payment_id ) {
582
-	$payment      = new Give_Payment( $payment_id );
581
+function give_email_tag_donation($payment_id) {
582
+	$payment      = new Give_Payment($payment_id);
583 583
 	$payment_meta = $payment->payment_meta;
584
-	$level_title  = give_has_variable_prices( $payment->form_id );
584
+	$level_title  = give_has_variable_prices($payment->form_id);
585 585
 	$separator    = $level_title ? '-' : '';
586
-	$form_title   = strip_tags( give_get_payment_form_title( $payment_meta, false, $separator ) );
586
+	$form_title   = strip_tags(give_get_payment_form_title($payment_meta, false, $separator));
587 587
 
588
-	return ! empty( $form_title ) ? $form_title : '';
588
+	return ! empty($form_title) ? $form_title : '';
589 589
 
590 590
 }
591 591
 
@@ -598,11 +598,11 @@  discard block
 block discarded – undo
598 598
  *
599 599
  * @return string $form_title
600 600
  */
601
-function give_email_tag_form_title( $payment_id ) {
602
-	$payment      = new Give_Payment( $payment_id );
601
+function give_email_tag_form_title($payment_id) {
602
+	$payment      = new Give_Payment($payment_id);
603 603
 	$payment_meta = $payment->payment_meta;
604 604
 
605
-	return isset( $payment_meta['form_title'] ) ? strip_tags( $payment_meta['form_title'] ) : '';
605
+	return isset($payment_meta['form_title']) ? strip_tags($payment_meta['form_title']) : '';
606 606
 
607 607
 }
608 608
 
@@ -615,10 +615,10 @@  discard block
 block discarded – undo
615 615
  *
616 616
  * @return string gateway
617 617
  */
618
-function give_email_tag_payment_method( $payment_id ) {
619
-	$payment = new Give_Payment( $payment_id );
618
+function give_email_tag_payment_method($payment_id) {
619
+	$payment = new Give_Payment($payment_id);
620 620
 
621
-	return give_get_gateway_checkout_label( $payment->gateway );
621
+	return give_get_gateway_checkout_label($payment->gateway);
622 622
 }
623 623
 
624 624
 /**
@@ -630,8 +630,8 @@  discard block
 block discarded – undo
630 630
  *
631 631
  * @return string sitename
632 632
  */
633
-function give_email_tag_sitename( $payment_id ) {
634
-	return wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES );
633
+function give_email_tag_sitename($payment_id) {
634
+	return wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
635 635
 }
636 636
 
637 637
 /**
@@ -643,18 +643,18 @@  discard block
 block discarded – undo
643 643
  *
644 644
  * @return string receipt_link
645 645
  */
646
-function give_email_tag_receipt_link( $payment_id ) {
646
+function give_email_tag_receipt_link($payment_id) {
647 647
 
648
-	$receipt_url = esc_url( add_query_arg( array(
649
-		'payment_key' => give_get_payment_key( $payment_id ),
650
-	), give_get_history_page_uri() ) );
648
+	$receipt_url = esc_url(add_query_arg(array(
649
+		'payment_key' => give_get_payment_key($payment_id),
650
+	), give_get_history_page_uri()));
651 651
 	$formatted   = sprintf(
652 652
 		'<a href="%1$s">%2$s</a>',
653 653
 		$receipt_url,
654
-		__( 'View it in your browser &raquo;', 'give' )
654
+		__('View it in your browser &raquo;', 'give')
655 655
 	);
656 656
 
657
-	if ( give_get_option( 'email_template' ) !== 'none' ) {
657
+	if (give_get_option('email_template') !== 'none') {
658 658
 		return $formatted;
659 659
 	} else {
660 660
 		return $receipt_url;
@@ -673,12 +673,12 @@  discard block
 block discarded – undo
673 673
  *
674 674
  * @return string receipt_url
675 675
  */
676
-function give_email_tag_receipt_link_url( $payment_id ) {
676
+function give_email_tag_receipt_link_url($payment_id) {
677 677
 
678
-	$receipt_url = esc_url( add_query_arg( array(
679
-		'payment_key' => give_get_payment_key( $payment_id ),
678
+	$receipt_url = esc_url(add_query_arg(array(
679
+		'payment_key' => give_get_payment_key($payment_id),
680 680
 		'give_action' => 'view_receipt',
681
-	), home_url() ) );
681
+	), home_url()));
682 682
 
683 683
 	return $receipt_url;
684 684
 
Please login to merge, or discard this patch.
includes/class-give-donate-form.php 1 patch
Spacing   +115 added lines, -115 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
 
@@ -337,11 +337,11 @@  discard block
 block discarded – undo
337 337
 	 * @param  bool  $_id   Post id. Default is false.
338 338
 	 * @param  array $_args Arguments passed.
339 339
 	 */
340
-	public function __construct( $_id = false, $_args = array() ) {
340
+	public function __construct($_id = false, $_args = array()) {
341 341
 
342
-		$donation_form = WP_Post::get_instance( $_id );
342
+		$donation_form = WP_Post::get_instance($_id);
343 343
 
344
-		return $this->setup_donation_form( $donation_form );
344
+		return $this->setup_donation_form($donation_form);
345 345
 	}
346 346
 
347 347
 	/**
@@ -354,23 +354,23 @@  discard block
 block discarded – undo
354 354
 	 *
355 355
 	 * @return bool                   If the setup was successful or not.
356 356
 	 */
357
-	private function setup_donation_form( $donation_form ) {
357
+	private function setup_donation_form($donation_form) {
358 358
 
359
-		if ( ! is_object( $donation_form ) ) {
359
+		if ( ! is_object($donation_form)) {
360 360
 			return false;
361 361
 		}
362 362
 
363
-		if ( ! is_a( $donation_form, 'WP_Post' ) ) {
363
+		if ( ! is_a($donation_form, 'WP_Post')) {
364 364
 			return false;
365 365
 		}
366 366
 
367
-		if ( 'give_forms' !== $donation_form->post_type ) {
367
+		if ('give_forms' !== $donation_form->post_type) {
368 368
 			return false;
369 369
 		}
370 370
 
371
-		foreach ( $donation_form as $key => $value ) {
371
+		foreach ($donation_form as $key => $value) {
372 372
 
373
-			switch ( $key ) {
373
+			switch ($key) {
374 374
 
375 375
 				default:
376 376
 					$this->$key = $value;
@@ -394,16 +394,16 @@  discard block
 block discarded – undo
394 394
 	 *
395 395
 	 * @return mixed
396 396
 	 */
397
-	public function __get( $key ) {
397
+	public function __get($key) {
398 398
 
399
-		if ( method_exists( $this, 'get_' . $key ) ) {
399
+		if (method_exists($this, 'get_'.$key)) {
400 400
 
401
-			return call_user_func( array( $this, 'get_' . $key ) );
401
+			return call_user_func(array($this, 'get_'.$key));
402 402
 
403 403
 		} else {
404 404
 
405 405
 			/* translators: %s: property key */
406
-			return new WP_Error( 'give-form-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) );
406
+			return new WP_Error('give-form-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key));
407 407
 
408 408
 		}
409 409
 
@@ -419,30 +419,30 @@  discard block
 block discarded – undo
419 419
 	 *
420 420
 	 * @return bool|int    False if data isn't passed and class not instantiated for creation, or New Form ID.
421 421
 	 */
422
-	public function create( $data = array() ) {
422
+	public function create($data = array()) {
423 423
 
424
-		if ( $this->id != 0 ) {
424
+		if ($this->id != 0) {
425 425
 			return false;
426 426
 		}
427 427
 
428 428
 		$defaults = array(
429 429
 			'post_type'   => 'give_forms',
430 430
 			'post_status' => 'draft',
431
-			'post_title'  => __( 'New Donation Form', 'give' ),
431
+			'post_title'  => __('New Donation Form', 'give'),
432 432
 		);
433 433
 
434
-		$args = wp_parse_args( $data, $defaults );
434
+		$args = wp_parse_args($data, $defaults);
435 435
 
436 436
 		/**
437 437
 		 * Fired before a donation form is created
438 438
 		 *
439 439
 		 * @param array $args The post object arguments used for creation.
440 440
 		 */
441
-		do_action( 'give_form_pre_create', $args );
441
+		do_action('give_form_pre_create', $args);
442 442
 
443
-		$id = wp_insert_post( $args, true );
443
+		$id = wp_insert_post($args, true);
444 444
 
445
-		$donation_form = WP_Post::get_instance( $id );
445
+		$donation_form = WP_Post::get_instance($id);
446 446
 
447 447
 		/**
448 448
 		 * Fired after a donation form is created
@@ -450,9 +450,9 @@  discard block
 block discarded – undo
450 450
 		 * @param int   $id   The post ID of the created item.
451 451
 		 * @param array $args The post object arguments used for creation.
452 452
 		 */
453
-		do_action( 'give_form_post_create', $id, $args );
453
+		do_action('give_form_post_create', $id, $args);
454 454
 
455
-		return $this->setup_donation_form( $donation_form );
455
+		return $this->setup_donation_form($donation_form);
456 456
 
457 457
 	}
458 458
 
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
 	 * @return string Donation form name.
478 478
 	 */
479 479
 	public function get_name() {
480
-		return get_the_title( $this->ID );
480
+		return get_the_title($this->ID);
481 481
 	}
482 482
 
483 483
 	/**
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
 	 */
491 491
 	public function get_price() {
492 492
 
493
-		if ( ! isset( $this->price ) ) {
493
+		if ( ! isset($this->price)) {
494 494
 
495 495
 			$this->price = give_maybe_sanitize_amount(
496 496
 				give_get_meta(
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
 				)
501 501
 			);
502 502
 
503
-			if ( ! $this->price ) {
503
+			if ( ! $this->price) {
504 504
 				$this->price = 0;
505 505
 			}
506 506
 
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
 		 * @param string     $price The donation form price.
515 515
 		 * @param string|int $id    The form ID.
516 516
 		 */
517
-		return apply_filters( 'give_get_set_price', $this->price, $this->ID );
517
+		return apply_filters('give_get_set_price', $this->price, $this->ID);
518 518
 	}
519 519
 
520 520
 	/**
@@ -527,18 +527,18 @@  discard block
 block discarded – undo
527 527
 	 */
528 528
 	public function get_minimum_price() {
529 529
 
530
-		if ( ! isset( $this->minimum_price ) ) {
530
+		if ( ! isset($this->minimum_price)) {
531 531
 
532
-			$allow_custom_amount = give_get_meta( $this->ID, '_give_custom_amount', true );
533
-			$this->minimum_price = give_get_meta( $this->ID, '_give_custom_amount_minimum', true );
532
+			$allow_custom_amount = give_get_meta($this->ID, '_give_custom_amount', true);
533
+			$this->minimum_price = give_get_meta($this->ID, '_give_custom_amount_minimum', true);
534 534
 
535
-			if ( ! give_is_setting_enabled( $allow_custom_amount ) ) {
535
+			if ( ! give_is_setting_enabled($allow_custom_amount)) {
536 536
 				$this->minimum_price = 0;
537 537
 			}
538 538
 
539 539
 		}
540 540
 
541
-		return apply_filters( 'give_get_set_minimum_price', $this->minimum_price, $this->ID );
541
+		return apply_filters('give_get_set_minimum_price', $this->minimum_price, $this->ID);
542 542
 	}
543 543
 
544 544
 	/**
@@ -551,9 +551,9 @@  discard block
 block discarded – undo
551 551
 	 */
552 552
 	public function get_prices() {
553 553
 
554
-		if ( ! isset( $this->prices ) ) {
554
+		if ( ! isset($this->prices)) {
555 555
 
556
-			$this->prices = give_get_meta( $this->ID, '_give_donation_levels', true );
556
+			$this->prices = give_get_meta($this->ID, '_give_donation_levels', true);
557 557
 
558 558
 		}
559 559
 
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
 		 * @param array      $prices The array of mulit-level prices.
566 566
 		 * @param int|string $ID     The ID of the form.
567 567
 		 */
568
-		return apply_filters( 'give_get_donation_levels', $this->prices, $this->ID );
568
+		return apply_filters('give_get_donation_levels', $this->prices, $this->ID);
569 569
 
570 570
 	}
571 571
 
@@ -579,17 +579,17 @@  discard block
 block discarded – undo
579 579
 	 */
580 580
 	public function get_goal() {
581 581
 
582
-		if ( ! isset( $this->goal ) ) {
582
+		if ( ! isset($this->goal)) {
583 583
 
584
-			$this->goal = give_get_meta( $this->ID, '_give_set_goal', true );
584
+			$this->goal = give_get_meta($this->ID, '_give_set_goal', true);
585 585
 
586
-			if ( ! $this->goal ) {
586
+			if ( ! $this->goal) {
587 587
 				$this->goal = 0;
588 588
 			}
589 589
 
590 590
 		}
591 591
 
592
-		return apply_filters( 'give_get_set_goal', $this->goal, $this->ID );
592
+		return apply_filters('give_get_set_goal', $this->goal, $this->ID);
593 593
 
594 594
 	}
595 595
 
@@ -603,10 +603,10 @@  discard block
 block discarded – undo
603 603
 	 */
604 604
 	public function is_single_price_mode() {
605 605
 
606
-		$option = give_get_meta( $this->ID, '_give_price_option', true );
606
+		$option = give_get_meta($this->ID, '_give_price_option', true);
607 607
 		$ret    = 0;
608 608
 
609
-		if ( empty( $option ) || $option === 'set' ) {
609
+		if (empty($option) || $option === 'set') {
610 610
 			$ret = 1;
611 611
 		}
612 612
 
@@ -618,7 +618,7 @@  discard block
 block discarded – undo
618 618
 		 * @param bool       $ret Is donation form in single price mode?
619 619
 		 * @param int|string $ID The ID of the donation form.
620 620
 		 */
621
-		return (bool) apply_filters( 'give_single_price_option_mode', $ret, $this->ID );
621
+		return (bool) apply_filters('give_single_price_option_mode', $ret, $this->ID);
622 622
 
623 623
 	}
624 624
 
@@ -632,10 +632,10 @@  discard block
 block discarded – undo
632 632
 	 */
633 633
 	public function is_custom_price_mode() {
634 634
 
635
-		$option = give_get_meta( $this->ID, '_give_custom_amount', true );
635
+		$option = give_get_meta($this->ID, '_give_custom_amount', true);
636 636
 		$ret    = 0;
637 637
 
638
-		if ( give_is_setting_enabled( $option ) ) {
638
+		if (give_is_setting_enabled($option)) {
639 639
 			$ret = 1;
640 640
 		}
641 641
 
@@ -647,7 +647,7 @@  discard block
 block discarded – undo
647 647
 		 * @param bool       $ret Is donation form in custom price mode?
648 648
 		 * @param int|string $ID  The ID of the donation form.
649 649
 		 */
650
-		return (bool) apply_filters( 'give_custom_price_option_mode', $ret, $this->ID );
650
+		return (bool) apply_filters('give_custom_price_option_mode', $ret, $this->ID);
651 651
 
652 652
 	}
653 653
 
@@ -663,10 +663,10 @@  discard block
 block discarded – undo
663 663
 	 */
664 664
 	public function has_variable_prices() {
665 665
 
666
-		$option = give_get_meta( $this->ID, '_give_price_option', true );
666
+		$option = give_get_meta($this->ID, '_give_price_option', true);
667 667
 		$ret    = 0;
668 668
 
669
-		if ( $option === 'multi' ) {
669
+		if ($option === 'multi') {
670 670
 			$ret = 1;
671 671
 		}
672 672
 
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
 		 * @param bool       $ret Does donation form have variable prices?
677 677
 		 * @param int|string $ID  The ID of the donation form.
678 678
 		 */
679
-		return (bool) apply_filters( 'give_has_variable_prices', $ret, $this->ID );
679
+		return (bool) apply_filters('give_has_variable_prices', $ret, $this->ID);
680 680
 
681 681
 	}
682 682
 
@@ -690,17 +690,17 @@  discard block
 block discarded – undo
690 690
 	 */
691 691
 	public function get_type() {
692 692
 
693
-		if ( ! isset( $this->type ) ) {
693
+		if ( ! isset($this->type)) {
694 694
 
695
-			$this->type = give_get_meta( $this->ID, '_give_price_option', true );
695
+			$this->type = give_get_meta($this->ID, '_give_price_option', true);
696 696
 
697
-			if ( empty( $this->type ) ) {
697
+			if (empty($this->type)) {
698 698
 				$this->type = 'set';
699 699
 			}
700 700
 
701 701
 		}
702 702
 
703
-		return apply_filters( 'give_get_form_type', $this->type, $this->ID );
703
+		return apply_filters('give_get_form_type', $this->type, $this->ID);
704 704
 
705 705
 	}
706 706
 
@@ -716,23 +716,23 @@  discard block
 block discarded – undo
716 716
 	 *
717 717
 	 * @return string
718 718
 	 */
719
-	public function get_form_classes( $args ) {
719
+	public function get_form_classes($args) {
720 720
 
721
-		$float_labels_option = give_is_float_labels_enabled( $args )
721
+		$float_labels_option = give_is_float_labels_enabled($args)
722 722
 			? 'float-labels-enabled'
723 723
 			: '';
724 724
 
725
-		$form_classes_array = apply_filters( 'give_form_classes', array(
725
+		$form_classes_array = apply_filters('give_form_classes', array(
726 726
 			'give-form',
727
-			'give-form-' . $this->ID,
728
-			'give-form-type-' . $this->get_type(),
727
+			'give-form-'.$this->ID,
728
+			'give-form-type-'.$this->get_type(),
729 729
 			$float_labels_option,
730
-		), $this->ID, $args );
730
+		), $this->ID, $args);
731 731
 
732 732
 		// Remove empty class names.
733
-		$form_classes_array = array_filter( $form_classes_array );
733
+		$form_classes_array = array_filter($form_classes_array);
734 734
 
735
-		return implode( ' ', $form_classes_array );
735
+		return implode(' ', $form_classes_array);
736 736
 
737 737
 	}
738 738
 
@@ -747,22 +747,22 @@  discard block
 block discarded – undo
747 747
 	 *
748 748
 	 * @return string
749 749
 	 */
750
-	public function get_form_wrap_classes( $args ) {
750
+	public function get_form_wrap_classes($args) {
751 751
 		$custom_class = array(
752 752
 			'give-form-wrap',
753 753
 		);
754 754
 
755
-		if ( $this->is_close_donation_form() ) {
755
+		if ($this->is_close_donation_form()) {
756 756
 			$custom_class[] = 'give-form-closed';
757
-		} else{
758
-			$display_option = ( isset( $args['display_style'] ) && ! empty( $args['display_style'] ) )
757
+		} else {
758
+			$display_option = (isset($args['display_style']) && ! empty($args['display_style']))
759 759
 				? $args['display_style']
760
-				: give_get_meta( $this->ID, '_give_payment_display', true );
760
+				: give_get_meta($this->ID, '_give_payment_display', true);
761 761
 
762 762
 			$custom_class[] = "give-display-{$display_option}";
763 763
 
764 764
 			// If admin want to show only button for form then user inbuilt modal functionality.
765
-			if ( 'button' === $display_option ) {
765
+			if ('button' === $display_option) {
766 766
 				$custom_class[] = 'give-display-button-only';
767 767
 			}
768 768
 		}
@@ -773,10 +773,10 @@  discard block
 block discarded – undo
773 773
 		 *
774 774
 		 * @since 1.0
775 775
 		 */
776
-		$form_wrap_classes_array = (array) apply_filters( 'give_form_wrap_classes', $custom_class, $this->ID, $args );
776
+		$form_wrap_classes_array = (array) apply_filters('give_form_wrap_classes', $custom_class, $this->ID, $args);
777 777
 
778 778
 
779
-		return implode( ' ', $form_wrap_classes_array );
779
+		return implode(' ', $form_wrap_classes_array);
780 780
 
781 781
 	}
782 782
 
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
 	public function is_set_type_donation_form() {
792 792
 		$form_type = $this->get_type();
793 793
 
794
-		return ( 'set' === $form_type ? true : false );
794
+		return ('set' === $form_type ? true : false);
795 795
 	}
796 796
 
797 797
 	/**
@@ -805,7 +805,7 @@  discard block
 block discarded – undo
805 805
 	public function is_multi_type_donation_form() {
806 806
 		$form_type = $this->get_type();
807 807
 
808
-		return ( 'multi' === $form_type ? true : false );
808
+		return ('multi' === $form_type ? true : false);
809 809
 
810 810
 	}
811 811
 
@@ -819,15 +819,15 @@  discard block
 block discarded – undo
819 819
 	 */
820 820
 	public function get_sales() {
821 821
 
822
-		if ( ! isset( $this->sales ) ) {
822
+		if ( ! isset($this->sales)) {
823 823
 
824
-			if ( '' == give_get_meta( $this->ID, '_give_form_sales', true ) ) {
825
-				add_post_meta( $this->ID, '_give_form_sales', 0 );
824
+			if ('' == give_get_meta($this->ID, '_give_form_sales', true)) {
825
+				add_post_meta($this->ID, '_give_form_sales', 0);
826 826
 			} // End if
827 827
 
828
-			$this->sales = give_get_meta( $this->ID, '_give_form_sales', true );
828
+			$this->sales = give_get_meta($this->ID, '_give_form_sales', true);
829 829
 
830
-			if ( $this->sales < 0 ) {
830
+			if ($this->sales < 0) {
831 831
 				// Never let sales be less than zero.
832 832
 				$this->sales = 0;
833 833
 			}
@@ -848,13 +848,13 @@  discard block
 block discarded – undo
848 848
 	 *
849 849
 	 * @return int|false     New number of total sales.
850 850
 	 */
851
-	public function increase_sales( $quantity = 1 ) {
851
+	public function increase_sales($quantity = 1) {
852 852
 
853
-		$sales       = give_get_form_sales_stats( $this->ID );
854
-		$quantity    = absint( $quantity );
853
+		$sales       = give_get_form_sales_stats($this->ID);
854
+		$quantity    = absint($quantity);
855 855
 		$total_sales = $sales + $quantity;
856 856
 
857
-		if ( $this->update_meta( '_give_form_sales', $total_sales ) ) {
857
+		if ($this->update_meta('_give_form_sales', $total_sales)) {
858 858
 
859 859
 			$this->sales = $total_sales;
860 860
 
@@ -875,17 +875,17 @@  discard block
 block discarded – undo
875 875
 	 *
876 876
 	 * @return int|false     New number of total sales.
877 877
 	 */
878
-	public function decrease_sales( $quantity = 1 ) {
878
+	public function decrease_sales($quantity = 1) {
879 879
 
880
-		$sales = give_get_form_sales_stats( $this->ID );
880
+		$sales = give_get_form_sales_stats($this->ID);
881 881
 
882 882
 		// Only decrease if not already zero
883
-		if ( $sales > 0 ) {
883
+		if ($sales > 0) {
884 884
 
885
-			$quantity    = absint( $quantity );
885
+			$quantity    = absint($quantity);
886 886
 			$total_sales = $sales - $quantity;
887 887
 
888
-			if ( $this->update_meta( '_give_form_sales', $total_sales ) ) {
888
+			if ($this->update_meta('_give_form_sales', $total_sales)) {
889 889
 
890 890
 				$this->sales = $sales;
891 891
 
@@ -909,15 +909,15 @@  discard block
 block discarded – undo
909 909
 	 */
910 910
 	public function get_earnings() {
911 911
 
912
-		if ( ! isset( $this->earnings ) ) {
912
+		if ( ! isset($this->earnings)) {
913 913
 
914
-			if ( '' == give_get_meta( $this->ID, '_give_form_earnings', true ) ) {
915
-				add_post_meta( $this->ID, '_give_form_earnings', 0 );
914
+			if ('' == give_get_meta($this->ID, '_give_form_earnings', true)) {
915
+				add_post_meta($this->ID, '_give_form_earnings', 0);
916 916
 			}
917 917
 
918
-			$this->earnings = give_get_meta( $this->ID, '_give_form_earnings', true );
918
+			$this->earnings = give_get_meta($this->ID, '_give_form_earnings', true);
919 919
 
920
-			if ( $this->earnings < 0 ) {
920
+			if ($this->earnings < 0) {
921 921
 				// Never let earnings be less than zero
922 922
 				$this->earnings = 0;
923 923
 			}
@@ -938,12 +938,12 @@  discard block
 block discarded – undo
938 938
 	 *
939 939
 	 * @return float|false
940 940
 	 */
941
-	public function increase_earnings( $amount = 0 ) {
941
+	public function increase_earnings($amount = 0) {
942 942
 
943
-		$earnings   = give_get_form_earnings_stats( $this->ID );
943
+		$earnings   = give_get_form_earnings_stats($this->ID);
944 944
 		$new_amount = $earnings + (float) $amount;
945 945
 
946
-		if ( $this->update_meta( '_give_form_earnings', $new_amount ) ) {
946
+		if ($this->update_meta('_give_form_earnings', $new_amount)) {
947 947
 
948 948
 			$this->earnings = $new_amount;
949 949
 
@@ -965,16 +965,16 @@  discard block
 block discarded – undo
965 965
 	 *
966 966
 	 * @return float|false
967 967
 	 */
968
-	public function decrease_earnings( $amount ) {
968
+	public function decrease_earnings($amount) {
969 969
 
970
-		$earnings = give_get_form_earnings_stats( $this->ID );
970
+		$earnings = give_get_form_earnings_stats($this->ID);
971 971
 
972
-		if ( $earnings > 0 ) {
972
+		if ($earnings > 0) {
973 973
 			// Only decrease if greater than zero
974 974
 			$new_amount = $earnings - (float) $amount;
975 975
 
976 976
 
977
-			if ( $this->update_meta( '_give_form_earnings', $new_amount ) ) {
977
+			if ($this->update_meta('_give_form_earnings', $new_amount)) {
978 978
 
979 979
 				$this->earnings = $new_amount;
980 980
 
@@ -998,22 +998,22 @@  discard block
 block discarded – undo
998 998
 	 *
999 999
 	 * @return bool
1000 1000
 	 */
1001
-	public function is_free( $price_id = false ) {
1001
+	public function is_free($price_id = false) {
1002 1002
 
1003 1003
 		$is_free          = false;
1004
-		$variable_pricing = give_has_variable_prices( $this->ID );
1004
+		$variable_pricing = give_has_variable_prices($this->ID);
1005 1005
 
1006
-		if ( $variable_pricing && ! is_null( $price_id ) && $price_id !== false ) {
1007
-			$price = give_get_price_option_amount( $this->ID, $price_id );
1008
-		} elseif ( ! $variable_pricing ) {
1009
-			$price = give_get_meta( $this->ID, '_give_set_price', true );
1006
+		if ($variable_pricing && ! is_null($price_id) && $price_id !== false) {
1007
+			$price = give_get_price_option_amount($this->ID, $price_id);
1008
+		} elseif ( ! $variable_pricing) {
1009
+			$price = give_get_meta($this->ID, '_give_set_price', true);
1010 1010
 		}
1011 1011
 
1012
-		if ( isset( $price ) && (float) $price == 0 ) {
1012
+		if (isset($price) && (float) $price == 0) {
1013 1013
 			$is_free = true;
1014 1014
 		}
1015 1015
 
1016
-		return (bool) apply_filters( 'give_is_free_donation', $is_free, $this->ID, $price_id );
1016
+		return (bool) apply_filters('give_is_free_donation', $is_free, $this->ID, $price_id);
1017 1017
 
1018 1018
 	}
1019 1019
 
@@ -1040,9 +1040,9 @@  discard block
 block discarded – undo
1040 1040
 		$is_close_form = apply_filters(
1041 1041
 			'give_is_close_donation_form',
1042 1042
 			(
1043
-			give_is_setting_enabled( give_get_meta( $this->ID, '_give_goal_option', true ) ) )
1044
-			&& give_is_setting_enabled( give_get_meta( $this->ID, '_give_close_form_when_goal_achieved', true ) )
1045
-			&& ( $this->get_goal() <= $this->get_earnings()
1043
+			give_is_setting_enabled(give_get_meta($this->ID, '_give_goal_option', true)) )
1044
+			&& give_is_setting_enabled(give_get_meta($this->ID, '_give_close_form_when_goal_achieved', true))
1045
+			&& ($this->get_goal() <= $this->get_earnings()
1046 1046
 			),
1047 1047
 			$this->ID
1048 1048
 		);
@@ -1061,29 +1061,29 @@  discard block
 block discarded – undo
1061 1061
 	 *
1062 1062
 	 * @return bool                            The result of the update query.
1063 1063
 	 */
1064
-	private function update_meta( $meta_key = '', $meta_value = '' ) {
1064
+	private function update_meta($meta_key = '', $meta_value = '') {
1065 1065
 
1066 1066
 		/* @var WPDB $wpdb */
1067 1067
 		global $wpdb;
1068 1068
 
1069
-		if ( empty( $meta_key ) ) {
1069
+		if (empty($meta_key)) {
1070 1070
 			return false;
1071 1071
 		}
1072 1072
 
1073 1073
 		// Make sure if it needs to be serialized, we do
1074
-		$meta_value = maybe_serialize( $meta_value );
1074
+		$meta_value = maybe_serialize($meta_value);
1075 1075
 
1076
-		if ( is_numeric( $meta_value ) ) {
1077
-			$value_type = is_float( $meta_value ) ? '%f' : '%d';
1076
+		if (is_numeric($meta_value)) {
1077
+			$value_type = is_float($meta_value) ? '%f' : '%d';
1078 1078
 		} else {
1079 1079
 			$value_type = "'%s'";
1080 1080
 		}
1081 1081
 
1082
-		$sql = $wpdb->prepare( "UPDATE $wpdb->postmeta SET meta_value = $value_type WHERE post_id = $this->ID AND meta_key = '%s'", $meta_value, $meta_key );
1082
+		$sql = $wpdb->prepare("UPDATE $wpdb->postmeta SET meta_value = $value_type WHERE post_id = $this->ID AND meta_key = '%s'", $meta_value, $meta_key);
1083 1083
 
1084
-		if ( $wpdb->query( $sql ) ) {
1084
+		if ($wpdb->query($sql)) {
1085 1085
 
1086
-			clean_post_cache( $this->ID );
1086
+			clean_post_cache($this->ID);
1087 1087
 
1088 1088
 			return true;
1089 1089
 
Please login to merge, or discard this patch.
includes/gateways/paypal-standard.php 1 patch
Spacing   +156 added lines, -156 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  * @since       1.0
10 10
  */
11 11
 
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit;
14 14
 }
15 15
 
@@ -22,10 +22,10 @@  discard block
 block discarded – undo
22 22
  *
23 23
  * @return bool
24 24
  */
25
-function give_paypal_standard_billing_fields( $form_id ) {
25
+function give_paypal_standard_billing_fields($form_id) {
26 26
 
27
-	if ( give_is_setting_enabled( give_get_option( 'paypal_standard_billing_details' ) ) ) {
28
-		give_default_cc_address_fields( $form_id );
27
+	if (give_is_setting_enabled(give_get_option('paypal_standard_billing_details'))) {
28
+		give_default_cc_address_fields($form_id);
29 29
 
30 30
 		return true;
31 31
 	}
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 
35 35
 }
36 36
 
37
-add_action( 'give_paypal_cc_form', 'give_paypal_standard_billing_fields' );
37
+add_action('give_paypal_cc_form', 'give_paypal_standard_billing_fields');
38 38
 
39 39
 /**
40 40
  * Process PayPal Payment.
@@ -45,28 +45,28 @@  discard block
 block discarded – undo
45 45
  *
46 46
  * @return void
47 47
  */
48
-function give_process_paypal_payment( $payment_data ) {
48
+function give_process_paypal_payment($payment_data) {
49 49
 
50 50
 	// Validate nonce.
51
-	give_validate_nonce( $payment_data['gateway_nonce'], 'give-gateway' );
51
+	give_validate_nonce($payment_data['gateway_nonce'], 'give-gateway');
52 52
 
53
-	$payment_id = give_create_payment( $payment_data );
53
+	$payment_id = give_create_payment($payment_data);
54 54
 
55 55
 	// Check payment.
56
-	if ( empty( $payment_id ) ) {
56
+	if (empty($payment_id)) {
57 57
 		// Record the error.
58
-		give_record_gateway_error( __( 'Payment Error', 'give' ), sprintf( /* translators: %s: payment data */
59
-			__( 'Payment creation failed before sending donor to PayPal. Payment data: %s', 'give' ), json_encode( $payment_data ) ), $payment_id );
58
+		give_record_gateway_error(__('Payment Error', 'give'), sprintf( /* translators: %s: payment data */
59
+			__('Payment creation failed before sending donor to PayPal. Payment data: %s', 'give'), json_encode($payment_data) ), $payment_id);
60 60
 		// Problems? Send back.
61
-		give_send_back_to_checkout( '?payment-mode=' . $payment_data['post_data']['give-gateway'] );
61
+		give_send_back_to_checkout('?payment-mode='.$payment_data['post_data']['give-gateway']);
62 62
 	}
63 63
 
64 64
 	// Redirect to PayPal.
65
-	wp_redirect( give_build_paypal_url( $payment_id, $payment_data ) );
65
+	wp_redirect(give_build_paypal_url($payment_id, $payment_data));
66 66
 	exit;
67 67
 }
68 68
 
69
-add_action( 'give_gateway_paypal', 'give_process_paypal_payment' );
69
+add_action('give_gateway_paypal', 'give_process_paypal_payment');
70 70
 
71 71
 /**
72 72
  * Listens for a PayPal IPN requests and then sends to the processing function.
@@ -77,17 +77,17 @@  discard block
 block discarded – undo
77 77
 function give_listen_for_paypal_ipn() {
78 78
 
79 79
 	// Regular PayPal IPN.
80
-	if ( isset( $_GET['give-listener'] ) && 'IPN' === $_GET['give-listener'] ) {
80
+	if (isset($_GET['give-listener']) && 'IPN' === $_GET['give-listener']) {
81 81
 		/**
82 82
 		 * Fires while verifying PayPal IPN
83 83
 		 *
84 84
 		 * @since 1.0
85 85
 		 */
86
-		do_action( 'give_verify_paypal_ipn' );
86
+		do_action('give_verify_paypal_ipn');
87 87
 	}
88 88
 }
89 89
 
90
-add_action( 'init', 'give_listen_for_paypal_ipn' );
90
+add_action('init', 'give_listen_for_paypal_ipn');
91 91
 
92 92
 /**
93 93
  * Process PayPal IPN
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 function give_process_paypal_ipn() {
99 99
 
100 100
 	// Check the request method is POST.
101
-	if ( isset( $_SERVER['REQUEST_METHOD'] ) && 'POST' !== $_SERVER['REQUEST_METHOD'] ) {
101
+	if (isset($_SERVER['REQUEST_METHOD']) && 'POST' !== $_SERVER['REQUEST_METHOD']) {
102 102
 		return;
103 103
 	}
104 104
 
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
 	$post_data = '';
107 107
 
108 108
 	// Fallback just in case post_max_size is lower than needed.
109
-	if ( ini_get( 'allow_url_fopen' ) ) {
110
-		$post_data = file_get_contents( 'php://input' );
109
+	if (ini_get('allow_url_fopen')) {
110
+		$post_data = file_get_contents('php://input');
111 111
 	} else {
112 112
 		// If allow_url_fopen is not enabled, then make sure that post_max_size is large enough.
113
-		ini_set( 'post_max_size', '12M' );
113
+		ini_set('post_max_size', '12M');
114 114
 	}
115 115
 	// Start the encoded data collection with notification command.
116 116
 	$encoded_data = 'cmd=_notify-validate';
@@ -119,41 +119,41 @@  discard block
 block discarded – undo
119 119
 	$arg_separator = give_get_php_arg_separator_output();
120 120
 
121 121
 	// Verify there is a post_data.
122
-	if ( $post_data || strlen( $post_data ) > 0 ) {
122
+	if ($post_data || strlen($post_data) > 0) {
123 123
 		// Append the data.
124
-		$encoded_data .= $arg_separator . $post_data;
124
+		$encoded_data .= $arg_separator.$post_data;
125 125
 	} else {
126 126
 		// Check if POST is empty.
127
-		if ( empty( $_POST ) ) {
127
+		if (empty($_POST)) {
128 128
 			// Nothing to do.
129 129
 			return;
130 130
 		} else {
131 131
 			// Loop through each POST.
132
-			foreach ( $_POST as $key => $value ) {
132
+			foreach ($_POST as $key => $value) {
133 133
 				// Encode the value and append the data.
134
-				$encoded_data .= $arg_separator . "$key=" . urlencode( $value );
134
+				$encoded_data .= $arg_separator."$key=".urlencode($value);
135 135
 			}
136 136
 		}
137 137
 	}
138 138
 
139 139
 	// Convert collected post data to an array.
140
-	parse_str( $encoded_data, $encoded_data_array );
140
+	parse_str($encoded_data, $encoded_data_array);
141 141
 
142
-	foreach ( $encoded_data_array as $key => $value ) {
142
+	foreach ($encoded_data_array as $key => $value) {
143 143
 
144
-		if ( false !== strpos( $key, 'amp;' ) ) {
145
-			$new_key = str_replace( '&amp;', '&', $key );
146
-			$new_key = str_replace( 'amp;', '&', $new_key );
144
+		if (false !== strpos($key, 'amp;')) {
145
+			$new_key = str_replace('&amp;', '&', $key);
146
+			$new_key = str_replace('amp;', '&', $new_key);
147 147
 
148
-			unset( $encoded_data_array[ $key ] );
149
-			$encoded_data_array[ $new_key ] = $value;
148
+			unset($encoded_data_array[$key]);
149
+			$encoded_data_array[$new_key] = $value;
150 150
 		}
151 151
 	}
152 152
 
153 153
 	$api_response = false;
154 154
 
155 155
 	// Validate IPN request w/ PayPal if user hasn't disabled this security measure.
156
-	if ( give_is_setting_enabled( give_get_option( 'paypal_verification' ) ) ) {
156
+	if (give_is_setting_enabled(give_get_option('paypal_verification'))) {
157 157
 
158 158
 		$remote_post_vars = array(
159 159
 			'method'      => 'POST',
@@ -173,25 +173,25 @@  discard block
 block discarded – undo
173 173
 		);
174 174
 
175 175
 		// Validate the IPN.
176
-		$api_response = wp_remote_post( give_get_paypal_redirect(), $remote_post_vars );
176
+		$api_response = wp_remote_post(give_get_paypal_redirect(), $remote_post_vars);
177 177
 
178
-		if ( is_wp_error( $api_response ) ) {
179
-			give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */
180
-				__( 'Invalid IPN verification response. IPN data: %s', 'give' ), json_encode( $api_response ) ) );
178
+		if (is_wp_error($api_response)) {
179
+			give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */
180
+				__('Invalid IPN verification response. IPN data: %s', 'give'), json_encode($api_response) ));
181 181
 
182 182
 			return; // Something went wrong.
183 183
 		}
184 184
 
185
-		if ( 'VERIFIED' !== $api_response['body'] ) {
186
-			give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */
187
-				__( 'Invalid IPN verification response. IPN data: %s', 'give' ), json_encode( $api_response ) ) );
185
+		if ('VERIFIED' !== $api_response['body']) {
186
+			give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */
187
+				__('Invalid IPN verification response. IPN data: %s', 'give'), json_encode($api_response) ));
188 188
 
189 189
 			return; // Response not okay.
190 190
 		}
191 191
 	}// End if().
192 192
 
193 193
 	// Check if $post_data_array has been populated.
194
-	if ( ! is_array( $encoded_data_array ) && ! empty( $encoded_data_array ) ) {
194
+	if ( ! is_array($encoded_data_array) && ! empty($encoded_data_array)) {
195 195
 		return;
196 196
 	}
197 197
 
@@ -200,28 +200,28 @@  discard block
 block discarded – undo
200 200
 		'payment_status' => '',
201 201
 	);
202 202
 
203
-	$encoded_data_array = wp_parse_args( $encoded_data_array, $defaults );
203
+	$encoded_data_array = wp_parse_args($encoded_data_array, $defaults);
204 204
 
205
-	$payment_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0;
205
+	$payment_id = isset($encoded_data_array['custom']) ? absint($encoded_data_array['custom']) : 0;
206 206
 	$txn_type   = $encoded_data_array['txn_type'];
207 207
 
208 208
 	// Check for PayPal IPN Notifications and update data based on it.
209
-	$current_timestamp = current_time( 'timestamp' );
209
+	$current_timestamp = current_time('timestamp');
210 210
 	$paypal_ipn_vars   = array(
211
-		'auth_status'    => isset( $api_response['body'] ) ? $api_response['body'] : 'N/A',
212
-		'transaction_id' => isset( $encoded_data_array['txn_id'] ) ? $encoded_data_array['txn_id'] : 'N/A',
211
+		'auth_status'    => isset($api_response['body']) ? $api_response['body'] : 'N/A',
212
+		'transaction_id' => isset($encoded_data_array['txn_id']) ? $encoded_data_array['txn_id'] : 'N/A',
213 213
 		'payment_id'     => $payment_id,
214 214
 	);
215
-	update_option( 'give_last_paypal_ipn_received', $paypal_ipn_vars );
216
-	give_insert_payment_note( $payment_id, sprintf(
217
-			__( 'IPN received on %s at %s', 'give' ),
218
-			date_i18n( 'm/d/Y', $current_timestamp ),
219
-			date_i18n( 'H:i', $current_timestamp )
215
+	update_option('give_last_paypal_ipn_received', $paypal_ipn_vars);
216
+	give_insert_payment_note($payment_id, sprintf(
217
+			__('IPN received on %s at %s', 'give'),
218
+			date_i18n('m/d/Y', $current_timestamp),
219
+			date_i18n('H:i', $current_timestamp)
220 220
 		)
221 221
 	);
222
-	give_update_meta( $payment_id, 'give_last_paypal_ipn_received', $current_timestamp );
222
+	give_update_meta($payment_id, 'give_last_paypal_ipn_received', $current_timestamp);
223 223
 
224
-	if ( has_action( 'give_paypal_' . $txn_type ) ) {
224
+	if (has_action('give_paypal_'.$txn_type)) {
225 225
 		/**
226 226
 		 * Fires while processing PayPal IPN $txn_type.
227 227
 		 *
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 		 * @param array $encoded_data_array Encoded data.
233 233
 		 * @param int   $payment_id         Payment id.
234 234
 		 */
235
-		do_action( "give_paypal_{$txn_type}", $encoded_data_array, $payment_id );
235
+		do_action("give_paypal_{$txn_type}", $encoded_data_array, $payment_id);
236 236
 	} else {
237 237
 		/**
238 238
 		 * Fires while process PayPal IPN.
@@ -244,12 +244,12 @@  discard block
 block discarded – undo
244 244
 		 * @param array $encoded_data_array Encoded data.
245 245
 		 * @param int   $payment_id         Payment id.
246 246
 		 */
247
-		do_action( 'give_paypal_web_accept', $encoded_data_array, $payment_id );
247
+		do_action('give_paypal_web_accept', $encoded_data_array, $payment_id);
248 248
 	}
249 249
 	exit;
250 250
 }
251 251
 
252
-add_action( 'give_verify_paypal_ipn', 'give_process_paypal_ipn' );
252
+add_action('give_verify_paypal_ipn', 'give_process_paypal_ipn');
253 253
 
254 254
 /**
255 255
  * Process web accept (one time) payment IPNs.
@@ -261,99 +261,99 @@  discard block
 block discarded – undo
261 261
  *
262 262
  * @return void
263 263
  */
264
-function give_process_paypal_web_accept( $data, $payment_id ) {
264
+function give_process_paypal_web_accept($data, $payment_id) {
265 265
 
266 266
 	// Only allow through these transaction types.
267
-	if ( 'web_accept' !== $data['txn_type'] && 'cart' !== $data['txn_type'] && 'refunded' !== strtolower( $data['payment_status'] ) ) {
267
+	if ('web_accept' !== $data['txn_type'] && 'cart' !== $data['txn_type'] && 'refunded' !== strtolower($data['payment_status'])) {
268 268
 		return;
269 269
 	}
270 270
 
271 271
 	// Need $payment_id to continue.
272
-	if ( empty( $payment_id ) ) {
272
+	if (empty($payment_id)) {
273 273
 		return;
274 274
 	}
275 275
 
276 276
 	// Collect donation payment details.
277 277
 	$paypal_amount  = $data['mc_gross'];
278
-	$payment_status = strtolower( $data['payment_status'] );
279
-	$currency_code  = strtolower( $data['mc_currency'] );
280
-	$business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] );
281
-	$payment_meta   = give_get_payment_meta( $payment_id );
278
+	$payment_status = strtolower($data['payment_status']);
279
+	$currency_code  = strtolower($data['mc_currency']);
280
+	$business_email = isset($data['business']) && is_email($data['business']) ? trim($data['business']) : trim($data['receiver_email']);
281
+	$payment_meta   = give_get_payment_meta($payment_id);
282 282
 
283 283
 	// Must be a PayPal standard IPN.
284
-	if ( 'paypal' !== give_get_payment_gateway( $payment_id ) ) {
284
+	if ('paypal' !== give_get_payment_gateway($payment_id)) {
285 285
 		return;
286 286
 	}
287 287
 
288 288
 	// Verify payment recipient.
289
-	if ( strcasecmp( $business_email, trim( give_get_option( 'paypal_email' ) ) ) !== 0 ) {
289
+	if (strcasecmp($business_email, trim(give_get_option('paypal_email'))) !== 0) {
290 290
 
291
-		give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */
292
-			__( 'Invalid business email in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id );
293
-		give_update_payment_status( $payment_id, 'failed' );
294
-		give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid PayPal business email.', 'give' ) );
291
+		give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */
292
+			__('Invalid business email in IPN response. IPN data: %s', 'give'), json_encode($data) ), $payment_id);
293
+		give_update_payment_status($payment_id, 'failed');
294
+		give_insert_payment_note($payment_id, __('Payment failed due to invalid PayPal business email.', 'give'));
295 295
 
296 296
 		return;
297 297
 	}
298 298
 
299 299
 	// Verify payment currency.
300
-	if ( $currency_code !== strtolower( $payment_meta['currency'] ) ) {
300
+	if ($currency_code !== strtolower($payment_meta['currency'])) {
301 301
 
302
-		give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */
303
-			__( 'Invalid currency in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id );
304
-		give_update_payment_status( $payment_id, 'failed' );
305
-		give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid currency in PayPal IPN.', 'give' ) );
302
+		give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */
303
+			__('Invalid currency in IPN response. IPN data: %s', 'give'), json_encode($data) ), $payment_id);
304
+		give_update_payment_status($payment_id, 'failed');
305
+		give_insert_payment_note($payment_id, __('Payment failed due to invalid currency in PayPal IPN.', 'give'));
306 306
 
307 307
 		return;
308 308
 	}
309 309
 
310 310
 	// Process refunds & reversed.
311
-	if ( 'refunded' === $payment_status || 'reversed' === $payment_status ) {
312
-		give_process_paypal_refund( $data, $payment_id );
311
+	if ('refunded' === $payment_status || 'reversed' === $payment_status) {
312
+		give_process_paypal_refund($data, $payment_id);
313 313
 
314 314
 		return;
315 315
 	}
316 316
 
317 317
 	// Only complete payments once.
318
-	if ( 'publish' === get_post_status( $payment_id ) ) {
318
+	if ('publish' === get_post_status($payment_id)) {
319 319
 		return;
320 320
 	}
321 321
 
322 322
 	// Retrieve the total donation amount (before PayPal).
323
-	$payment_amount = give_donation_amount( $payment_id );
323
+	$payment_amount = give_donation_amount($payment_id);
324 324
 
325 325
 	// Check that the donation PP and local db amounts match.
326
-	if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) {
326
+	if (number_format((float) $paypal_amount, 2) < number_format((float) $payment_amount, 2)) {
327 327
 		// The prices don't match
328
-		give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */
329
-			__( 'Invalid payment amount in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id );
330
-		give_update_payment_status( $payment_id, 'failed' );
331
-		give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid amount in PayPal IPN.', 'give' ) );
328
+		give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */
329
+			__('Invalid payment amount in IPN response. IPN data: %s', 'give'), json_encode($data) ), $payment_id);
330
+		give_update_payment_status($payment_id, 'failed');
331
+		give_insert_payment_note($payment_id, __('Payment failed due to invalid amount in PayPal IPN.', 'give'));
332 332
 
333 333
 		return;
334 334
 	}
335 335
 
336 336
 	// Process completed donations.
337
-	if ( 'completed' === $payment_status || give_is_test_mode() ) {
337
+	if ('completed' === $payment_status || give_is_test_mode()) {
338 338
 
339
-		give_insert_payment_note( $payment_id, sprintf( /* translators: %s: Paypal transaction ID */
340
-			__( 'PayPal Transaction ID: %s', 'give' ), $data['txn_id'] ) );
341
-		give_set_payment_transaction_id( $payment_id, $data['txn_id'] );
342
-		give_update_payment_status( $payment_id, 'publish' );
339
+		give_insert_payment_note($payment_id, sprintf( /* translators: %s: Paypal transaction ID */
340
+			__('PayPal Transaction ID: %s', 'give'), $data['txn_id'] ));
341
+		give_set_payment_transaction_id($payment_id, $data['txn_id']);
342
+		give_update_payment_status($payment_id, 'publish');
343 343
 
344
-	} elseif ( 'pending' === $payment_status && isset( $data['pending_reason'] ) ) {
344
+	} elseif ('pending' === $payment_status && isset($data['pending_reason'])) {
345 345
 
346 346
 		// Look for possible pending reasons, such as an echeck.
347
-		$note = give_paypal_get_pending_donation_note( strtolower( $data['pending_reason'] ) );
347
+		$note = give_paypal_get_pending_donation_note(strtolower($data['pending_reason']));
348 348
 
349
-		if ( ! empty( $note ) ) {
350
-			give_insert_payment_note( $payment_id, $note );
349
+		if ( ! empty($note)) {
350
+			give_insert_payment_note($payment_id, $note);
351 351
 		}
352 352
 	}
353 353
 
354 354
 }
355 355
 
356
-add_action( 'give_paypal_web_accept', 'give_process_paypal_web_accept', 10, 2 );
356
+add_action('give_paypal_web_accept', 'give_process_paypal_web_accept', 10, 2);
357 357
 
358 358
 /**
359 359
  * Process PayPal IPN Refunds
@@ -365,35 +365,35 @@  discard block
 block discarded – undo
365 365
  *
366 366
  * @return void
367 367
  */
368
-function give_process_paypal_refund( $data, $payment_id = 0 ) {
368
+function give_process_paypal_refund($data, $payment_id = 0) {
369 369
 
370 370
 	// Collect payment details.
371
-	if ( empty( $payment_id ) ) {
371
+	if (empty($payment_id)) {
372 372
 		return;
373 373
 	}
374 374
 
375 375
 	// Only refund payments once.
376
-	if ( 'refunded' === get_post_status( $payment_id ) ) {
376
+	if ('refunded' === get_post_status($payment_id)) {
377 377
 		return;
378 378
 	}
379 379
 
380
-	$payment_amount = give_donation_amount( $payment_id );
380
+	$payment_amount = give_donation_amount($payment_id);
381 381
 	$refund_amount  = $data['payment_gross'] * - 1;
382 382
 
383
-	if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) {
383
+	if (number_format((float) $refund_amount, 2) < number_format((float) $payment_amount, 2)) {
384 384
 
385
-		give_insert_payment_note( $payment_id, sprintf( /* translators: %s: Paypal parent transaction ID */
386
-			__( 'Partial PayPal refund processed: %s', 'give' ), $data['parent_txn_id'] ) );
385
+		give_insert_payment_note($payment_id, sprintf( /* translators: %s: Paypal parent transaction ID */
386
+			__('Partial PayPal refund processed: %s', 'give'), $data['parent_txn_id'] ));
387 387
 
388 388
 		return; // This is a partial refund
389 389
 
390 390
 	}
391 391
 
392
-	give_insert_payment_note( $payment_id, sprintf( /* translators: 1: Paypal parent transaction ID 2. Paypal reason code */
393
-		__( 'PayPal Payment #%1$s Refunded for reason: %2$s', 'give' ), $data['parent_txn_id'], $data['reason_code'] ) );
394
-	give_insert_payment_note( $payment_id, sprintf( /* translators: %s: Paypal transaction ID */
395
-		__( 'PayPal Refund Transaction ID: %s', 'give' ), $data['txn_id'] ) );
396
-	give_update_payment_status( $payment_id, 'refunded' );
392
+	give_insert_payment_note($payment_id, sprintf( /* translators: 1: Paypal parent transaction ID 2. Paypal reason code */
393
+		__('PayPal Payment #%1$s Refunded for reason: %2$s', 'give'), $data['parent_txn_id'], $data['reason_code'] ));
394
+	give_insert_payment_note($payment_id, sprintf( /* translators: %s: Paypal transaction ID */
395
+		__('PayPal Refund Transaction ID: %s', 'give'), $data['txn_id'] ));
396
+	give_update_payment_status($payment_id, 'refunded');
397 397
 }
398 398
 
399 399
 /**
@@ -405,24 +405,24 @@  discard block
 block discarded – undo
405 405
  *
406 406
  * @return string
407 407
  */
408
-function give_get_paypal_redirect( $ssl_check = false ) {
408
+function give_get_paypal_redirect($ssl_check = false) {
409 409
 
410
-	if ( is_ssl() || ! $ssl_check ) {
410
+	if (is_ssl() || ! $ssl_check) {
411 411
 		$protocol = 'https://';
412 412
 	} else {
413 413
 		$protocol = 'http://';
414 414
 	}
415 415
 
416 416
 	// Check the current payment mode
417
-	if ( give_is_test_mode() ) {
417
+	if (give_is_test_mode()) {
418 418
 		// Test mode
419
-		$paypal_uri = $protocol . 'www.sandbox.paypal.com/cgi-bin/webscr';
419
+		$paypal_uri = $protocol.'www.sandbox.paypal.com/cgi-bin/webscr';
420 420
 	} else {
421 421
 		// Live mode
422
-		$paypal_uri = $protocol . 'www.paypal.com/cgi-bin/webscr';
422
+		$paypal_uri = $protocol.'www.paypal.com/cgi-bin/webscr';
423 423
 	}
424 424
 
425
-	return apply_filters( 'give_paypal_uri', $paypal_uri );
425
+	return apply_filters('give_paypal_uri', $paypal_uri);
426 426
 }
427 427
 
428 428
 /**
@@ -432,9 +432,9 @@  discard block
 block discarded – undo
432 432
  * @return string
433 433
  */
434 434
 function give_get_paypal_page_style() {
435
-	$page_style = trim( give_get_option( 'paypal_page_style', 'PayPal' ) );
435
+	$page_style = trim(give_get_option('paypal_page_style', 'PayPal'));
436 436
 
437
-	return apply_filters( 'give_paypal_page_style', $page_style );
437
+	return apply_filters('give_paypal_page_style', $page_style);
438 438
 }
439 439
 
440 440
 /**
@@ -448,26 +448,26 @@  discard block
 block discarded – undo
448 448
  *
449 449
  * @return string
450 450
  */
451
-function give_paypal_success_page_content( $content ) {
451
+function give_paypal_success_page_content($content) {
452 452
 
453
-	if ( ! isset( $_GET['payment-id'] ) && ! give_get_purchase_session() ) {
453
+	if ( ! isset($_GET['payment-id']) && ! give_get_purchase_session()) {
454 454
 		return $content;
455 455
 	}
456 456
 
457
-	$payment_id = isset( $_GET['payment-id'] ) ? absint( $_GET['payment-id'] ) : false;
457
+	$payment_id = isset($_GET['payment-id']) ? absint($_GET['payment-id']) : false;
458 458
 
459
-	if ( ! $payment_id ) {
459
+	if ( ! $payment_id) {
460 460
 		$session    = give_get_purchase_session();
461
-		$payment_id = give_get_purchase_id_by_key( $session['purchase_key'] );
461
+		$payment_id = give_get_purchase_id_by_key($session['purchase_key']);
462 462
 	}
463 463
 
464
-	$payment = get_post( $payment_id );
465
-	if ( $payment && 'pending' === $payment->post_status ) {
464
+	$payment = get_post($payment_id);
465
+	if ($payment && 'pending' === $payment->post_status) {
466 466
 
467 467
 		// Payment is still pending so show processing indicator to fix the race condition.
468 468
 		ob_start();
469 469
 
470
-		give_get_template_part( 'payment', 'processing' );
470
+		give_get_template_part('payment', 'processing');
471 471
 
472 472
 		$content = ob_get_clean();
473 473
 
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
 
478 478
 }
479 479
 
480
-add_filter( 'give_payment_confirm_paypal', 'give_paypal_success_page_content' );
480
+add_filter('give_payment_confirm_paypal', 'give_paypal_success_page_content');
481 481
 
482 482
 /**
483 483
  * Given a transaction ID, generate a link to the PayPal transaction ID details
@@ -489,16 +489,16 @@  discard block
 block discarded – undo
489 489
  *
490 490
  * @return string                 A link to the PayPal transaction details
491 491
  */
492
-function give_paypal_link_transaction_id( $transaction_id, $payment_id ) {
492
+function give_paypal_link_transaction_id($transaction_id, $payment_id) {
493 493
 
494 494
 	$paypal_base_url = 'https://history.paypal.com/cgi-bin/webscr?cmd=_history-details-from-hub&id=';
495
-	$transaction_url = '<a href="' . esc_url( $paypal_base_url . $transaction_id ) . '" target="_blank">' . $transaction_id . '</a>';
495
+	$transaction_url = '<a href="'.esc_url($paypal_base_url.$transaction_id).'" target="_blank">'.$transaction_id.'</a>';
496 496
 
497
-	return apply_filters( 'give_paypal_link_payment_details_transaction_id', $transaction_url );
497
+	return apply_filters('give_paypal_link_payment_details_transaction_id', $transaction_url);
498 498
 
499 499
 }
500 500
 
501
-add_filter( 'give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2 );
501
+add_filter('give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2);
502 502
 
503 503
 
504 504
 /**
@@ -510,64 +510,64 @@  discard block
 block discarded – undo
510 510
  *
511 511
  * @return string
512 512
  */
513
-function give_paypal_get_pending_donation_note( $pending_reason ) {
513
+function give_paypal_get_pending_donation_note($pending_reason) {
514 514
 
515 515
 	$note = '';
516 516
 
517
-	switch ( $pending_reason ) {
517
+	switch ($pending_reason) {
518 518
 
519 519
 		case 'echeck' :
520 520
 
521
-			$note = __( 'Payment made via eCheck and will clear automatically in 5-8 days.', 'give' );
521
+			$note = __('Payment made via eCheck and will clear automatically in 5-8 days.', 'give');
522 522
 
523 523
 			break;
524 524
 
525 525
 		case 'address' :
526 526
 
527
-			$note = __( 'Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give' );
527
+			$note = __('Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give');
528 528
 
529 529
 			break;
530 530
 
531 531
 		case 'intl' :
532 532
 
533
-			$note = __( 'Payment must be accepted manually through PayPal due to international account regulations.', 'give' );
533
+			$note = __('Payment must be accepted manually through PayPal due to international account regulations.', 'give');
534 534
 
535 535
 			break;
536 536
 
537 537
 		case 'multi-currency' :
538 538
 
539
-			$note = __( 'Payment received in non-shop currency and must be accepted manually through PayPal.', 'give' );
539
+			$note = __('Payment received in non-shop currency and must be accepted manually through PayPal.', 'give');
540 540
 
541 541
 			break;
542 542
 
543 543
 		case 'paymentreview' :
544 544
 		case 'regulatory_review' :
545 545
 
546
-			$note = __( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give' );
546
+			$note = __('Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give');
547 547
 
548 548
 			break;
549 549
 
550 550
 		case 'unilateral' :
551 551
 
552
-			$note = __( 'Payment was sent to non-confirmed or non-registered email address.', 'give' );
552
+			$note = __('Payment was sent to non-confirmed or non-registered email address.', 'give');
553 553
 
554 554
 			break;
555 555
 
556 556
 		case 'upgrade' :
557 557
 
558
-			$note = __( 'PayPal account must be upgraded before this payment can be accepted.', 'give' );
558
+			$note = __('PayPal account must be upgraded before this payment can be accepted.', 'give');
559 559
 
560 560
 			break;
561 561
 
562 562
 		case 'verify' :
563 563
 
564
-			$note = __( 'PayPal account is not verified. Verify account in order to accept this donation.', 'give' );
564
+			$note = __('PayPal account is not verified. Verify account in order to accept this donation.', 'give');
565 565
 
566 566
 			break;
567 567
 
568 568
 		case 'other' :
569 569
 
570
-			$note = __( 'Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give' );
570
+			$note = __('Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give');
571 571
 
572 572
 			break;
573 573
 
@@ -585,49 +585,49 @@  discard block
 block discarded – undo
585 585
  *
586 586
  * @return mixed|string
587 587
  */
588
-function give_build_paypal_url( $payment_id, $payment_data ) {
588
+function give_build_paypal_url($payment_id, $payment_data) {
589 589
 	// Only send to PayPal if the pending payment is created successfully.
590
-	$listener_url = add_query_arg( 'give-listener', 'IPN', home_url( 'index.php' ) );
590
+	$listener_url = add_query_arg('give-listener', 'IPN', home_url('index.php'));
591 591
 
592 592
 	// Get the success url.
593
-	$return_url = add_query_arg( array(
593
+	$return_url = add_query_arg(array(
594 594
 		'payment-confirmation' => 'paypal',
595 595
 		'payment-id'           => $payment_id,
596 596
 
597
-	), get_permalink( give_get_option( 'success_page' ) ) );
597
+	), get_permalink(give_get_option('success_page')));
598 598
 
599 599
 	// Get the PayPal redirect uri.
600
-	$paypal_redirect = trailingslashit( give_get_paypal_redirect() ) . '?';
600
+	$paypal_redirect = trailingslashit(give_get_paypal_redirect()).'?';
601 601
 
602 602
 	// Item name.
603
-	$item_name = give_payment_gateway_item_title( $payment_data );
603
+	$item_name = give_payment_gateway_item_title($payment_data);
604 604
 
605 605
 	// Setup PayPal API params.
606 606
 	$paypal_args = array(
607
-		'business'      => give_get_option( 'paypal_email', false ),
607
+		'business'      => give_get_option('paypal_email', false),
608 608
 		'first_name'    => $payment_data['user_info']['first_name'],
609 609
 		'last_name'     => $payment_data['user_info']['last_name'],
610 610
 		'email'         => $payment_data['user_email'],
611 611
 		'invoice'       => $payment_data['purchase_key'],
612 612
 		'amount'        => $payment_data['price'],
613
-		'item_name'     => stripslashes( $item_name ),
613
+		'item_name'     => stripslashes($item_name),
614 614
 		'no_shipping'   => '1',
615 615
 		'shipping'      => '0',
616 616
 		'no_note'       => '1',
617
-		'currency_code' => give_get_currency( $payment_id, $payment_data ),
618
-		'charset'       => get_bloginfo( 'charset' ),
617
+		'currency_code' => give_get_currency($payment_id, $payment_data),
618
+		'charset'       => get_bloginfo('charset'),
619 619
 		'custom'        => $payment_id,
620 620
 		'rm'            => '2',
621 621
 		'return'        => $return_url,
622
-		'cancel_return' => give_get_failed_transaction_uri( '?payment-id=' . $payment_id ),
622
+		'cancel_return' => give_get_failed_transaction_uri('?payment-id='.$payment_id),
623 623
 		'notify_url'    => $listener_url,
624 624
 		'page_style'    => give_get_paypal_page_style(),
625
-		'cbt'           => get_bloginfo( 'name' ),
625
+		'cbt'           => get_bloginfo('name'),
626 626
 		'bn'            => 'givewp_SP',
627 627
 	);
628 628
 
629 629
 	// Add user address if present.
630
-	if ( ! empty( $payment_data['user_info']['address'] ) ) {
630
+	if ( ! empty($payment_data['user_info']['address'])) {
631 631
 		$default_address = array(
632 632
 			'line1'   => '',
633 633
 			'line2'   => '',
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
 			'country' => '',
638 638
 		);
639 639
 
640
-		$address = wp_parse_args( $payment_data['user_info']['address'], $default_address );
640
+		$address = wp_parse_args($payment_data['user_info']['address'], $default_address);
641 641
 
642 642
 		$paypal_args['address1'] = $address['line1'];
643 643
 		$paypal_args['address2'] = $address['line2'];
@@ -658,13 +658,13 @@  discard block
 block discarded – undo
658 658
 	 *
659 659
 	 * @since 1.8
660 660
 	 */
661
-	$paypal_args = apply_filters( 'give_paypal_redirect_args', $paypal_args, $payment_data );
661
+	$paypal_args = apply_filters('give_paypal_redirect_args', $paypal_args, $payment_data);
662 662
 
663 663
 	// Build query.
664
-	$paypal_redirect .= http_build_query( $paypal_args );
664
+	$paypal_redirect .= http_build_query($paypal_args);
665 665
 
666 666
 	// Fix for some sites that encode the entities.
667
-	$paypal_redirect = str_replace( '&amp;', '&', $paypal_redirect );
667
+	$paypal_redirect = str_replace('&amp;', '&', $paypal_redirect);
668 668
 
669 669
 	return $paypal_redirect;
670 670
 }
@@ -679,7 +679,7 @@  discard block
 block discarded – undo
679 679
 function give_get_paypal_button_type() {
680 680
 	// paypal_button_type can be donation or standard.
681 681
 	$paypal_button_type = '_donations';
682
-	if ( 'standard' === give_get_option( 'paypal_button_type' ) ) {
682
+	if ('standard' === give_get_option('paypal_button_type')) {
683 683
 		$paypal_button_type = '_xclick';
684 684
 	}
685 685
 
Please login to merge, or discard this patch.
includes/gateways/functions.php 1 patch
Spacing   +66 added lines, -66 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
 
@@ -24,16 +24,16 @@  discard block
 block discarded – undo
24 24
 	// Default, built-in gateways
25 25
 	$gateways = array(
26 26
 		'paypal' => array(
27
-			'admin_label'    => __( 'PayPal Standard', 'give' ),
28
-			'checkout_label' => __( 'PayPal', 'give' ),
27
+			'admin_label'    => __('PayPal Standard', 'give'),
28
+			'checkout_label' => __('PayPal', 'give'),
29 29
 		),
30 30
 		'manual' => array(
31
-			'admin_label'    => __( 'Test Donation', 'give' ),
32
-			'checkout_label' => __( 'Test Donation', 'give' )
31
+			'admin_label'    => __('Test Donation', 'give'),
32
+			'checkout_label' => __('Test Donation', 'give')
33 33
 		),
34 34
 	);
35 35
 
36
-	return apply_filters( 'give_payment_gateways', $gateways );
36
+	return apply_filters('give_payment_gateways', $gateways);
37 37
 
38 38
 }
39 39
 
@@ -46,24 +46,24 @@  discard block
 block discarded – undo
46 46
  *
47 47
  * @return array $gateway_list All the available gateways
48 48
  */
49
-function give_get_enabled_payment_gateways( $form_id = 0 ) {
49
+function give_get_enabled_payment_gateways($form_id = 0) {
50 50
 
51 51
 	$gateways = give_get_payment_gateways();
52 52
 
53
-	$enabled = isset( $_POST['gateways'] ) ? $_POST['gateways'] : give_get_option( 'gateways' );
53
+	$enabled = isset($_POST['gateways']) ? $_POST['gateways'] : give_get_option('gateways');
54 54
 
55 55
 	$gateway_list = array();
56 56
 
57
-	foreach ( $gateways as $key => $gateway ) {
58
-		if ( isset( $enabled[ $key ] ) && $enabled[ $key ] == 1 ) {
59
-			$gateway_list[ $key ] = $gateway;
57
+	foreach ($gateways as $key => $gateway) {
58
+		if (isset($enabled[$key]) && $enabled[$key] == 1) {
59
+			$gateway_list[$key] = $gateway;
60 60
 		}
61 61
 	}
62 62
 
63 63
 	// Set order of payment gateway in list.
64
-	$gateway_list = give_get_ordered_payment_gateways( $gateway_list );
64
+	$gateway_list = give_get_ordered_payment_gateways($gateway_list);
65 65
 
66
-	return apply_filters( 'give_enabled_payment_gateways', $gateway_list, $form_id );
66
+	return apply_filters('give_enabled_payment_gateways', $gateway_list, $form_id);
67 67
 }
68 68
 
69 69
 /**
@@ -75,12 +75,12 @@  discard block
 block discarded – undo
75 75
  *
76 76
  * @return boolean true if enabled, false otherwise
77 77
  */
78
-function give_is_gateway_active( $gateway ) {
78
+function give_is_gateway_active($gateway) {
79 79
 	$gateways = give_get_enabled_payment_gateways();
80 80
 
81
-	$ret = array_key_exists( $gateway, $gateways );
81
+	$ret = array_key_exists($gateway, $gateways);
82 82
 
83
-	return apply_filters( 'give_is_gateway_active', $ret, $gateway, $gateways );
83
+	return apply_filters('give_is_gateway_active', $ret, $gateway, $gateways);
84 84
 }
85 85
 
86 86
 /**
@@ -92,23 +92,23 @@  discard block
 block discarded – undo
92 92
  *
93 93
  * @return string Gateway ID
94 94
  */
95
-function give_get_default_gateway( $form_id ) {
95
+function give_get_default_gateway($form_id) {
96 96
 
97 97
 	$give_options = give_get_settings();
98
-	$default      = isset( $give_options['default_gateway'] ) && give_is_gateway_active( $give_options['default_gateway'] ) ? $give_options['default_gateway'] : 'paypal';
99
-	$form_default = give_get_meta( $form_id, '_give_default_gateway', true );
98
+	$default      = isset($give_options['default_gateway']) && give_is_gateway_active($give_options['default_gateway']) ? $give_options['default_gateway'] : 'paypal';
99
+	$form_default = give_get_meta($form_id, '_give_default_gateway', true);
100 100
 
101 101
 	// Single Form settings varies compared to the Global default settings.
102
-	if ( ! empty( $form_default ) &&
102
+	if ( ! empty($form_default) &&
103 103
 		 $form_id !== null &&
104 104
 		 $default !== $form_default &&
105 105
 		 $form_default !== 'global' &&
106
-		 give_is_gateway_active( $form_default )
106
+		 give_is_gateway_active($form_default)
107 107
 	) {
108 108
 		$default = $form_default;
109 109
 	}
110 110
 
111
-	return apply_filters( 'give_default_gateway', $default );
111
+	return apply_filters('give_default_gateway', $default);
112 112
 }
113 113
 
114 114
 /**
@@ -120,18 +120,18 @@  discard block
 block discarded – undo
120 120
  *
121 121
  * @return string Gateway admin label
122 122
  */
123
-function give_get_gateway_admin_label( $gateway ) {
123
+function give_get_gateway_admin_label($gateway) {
124 124
 	$gateways = give_get_payment_gateways();
125
-	$label    = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway;
126
-	$payment  = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : false;
125
+	$label    = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway;
126
+	$payment  = isset($_GET['id']) ? absint($_GET['id']) : false;
127 127
 
128
-	if ( $gateway == 'manual' && $payment ) {
129
-		if ( give_donation_amount( $payment ) == 0 ) {
130
-			$label = __( 'Test Donation', 'give' );
128
+	if ($gateway == 'manual' && $payment) {
129
+		if (give_donation_amount($payment) == 0) {
130
+			$label = __('Test Donation', 'give');
131 131
 		}
132 132
 	}
133 133
 
134
-	return apply_filters( 'give_gateway_admin_label', $label, $gateway );
134
+	return apply_filters('give_gateway_admin_label', $label, $gateway);
135 135
 }
136 136
 
137 137
 /**
@@ -143,15 +143,15 @@  discard block
 block discarded – undo
143 143
  *
144 144
  * @return string Checkout label for the gateway
145 145
  */
146
-function give_get_gateway_checkout_label( $gateway ) {
146
+function give_get_gateway_checkout_label($gateway) {
147 147
 	$gateways = give_get_payment_gateways();
148
-	$label    = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway;
148
+	$label    = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway;
149 149
 
150
-	if ( $gateway == 'manual' ) {
151
-		$label = __( 'Test Donation', 'give' );
150
+	if ($gateway == 'manual') {
151
+		$label = __('Test Donation', 'give');
152 152
 	}
153 153
 
154
-	return apply_filters( 'give_gateway_checkout_label', $label, $gateway );
154
+	return apply_filters('give_gateway_checkout_label', $label, $gateway);
155 155
 }
156 156
 
157 157
 /**
@@ -163,11 +163,11 @@  discard block
 block discarded – undo
163 163
  *
164 164
  * @return array Options the gateway supports
165 165
  */
166
-function give_get_gateway_supports( $gateway ) {
166
+function give_get_gateway_supports($gateway) {
167 167
 	$gateways = give_get_enabled_payment_gateways();
168
-	$supports = isset( $gateways[ $gateway ]['supports'] ) ? $gateways[ $gateway ]['supports'] : array();
168
+	$supports = isset($gateways[$gateway]['supports']) ? $gateways[$gateway]['supports'] : array();
169 169
 
170
-	return apply_filters( 'give_gateway_supports', $supports, $gateway );
170
+	return apply_filters('give_gateway_supports', $supports, $gateway);
171 171
 }
172 172
 
173 173
 /**
@@ -180,9 +180,9 @@  discard block
 block discarded – undo
180 180
  *
181 181
  * @return void
182 182
  */
183
-function give_send_to_gateway( $gateway, $payment_data ) {
183
+function give_send_to_gateway($gateway, $payment_data) {
184 184
 
185
-	$payment_data['gateway_nonce'] = wp_create_nonce( 'give-gateway' );
185
+	$payment_data['gateway_nonce'] = wp_create_nonce('give-gateway');
186 186
 
187 187
 	/**
188 188
 	 * Fires while loading payment gateway via AJAX.
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 	 *
194 194
 	 * @param array $payment_data All the payment data to be sent to the gateway.
195 195
 	 */
196
-	do_action( "give_gateway_{$gateway}", $payment_data );
196
+	do_action("give_gateway_{$gateway}", $payment_data);
197 197
 }
198 198
 
199 199
 
@@ -207,34 +207,34 @@  discard block
 block discarded – undo
207 207
  *
208 208
  * @return string $enabled_gateway The slug of the gateway
209 209
  */
210
-function give_get_chosen_gateway( $form_id ) {
210
+function give_get_chosen_gateway($form_id) {
211 211
 
212
-	$request_form_id = isset( $_REQUEST['give_form_id'] ) ? $_REQUEST['give_form_id'] : 0;
212
+	$request_form_id = isset($_REQUEST['give_form_id']) ? $_REQUEST['give_form_id'] : 0;
213 213
 
214 214
 	// Back to check if 'form-id' is present.
215
-	if ( empty( $request_form_id ) ) {
216
-		$request_form_id = isset( $_REQUEST['form-id'] ) ? $_REQUEST['form-id'] : 0;
215
+	if (empty($request_form_id)) {
216
+		$request_form_id = isset($_REQUEST['form-id']) ? $_REQUEST['form-id'] : 0;
217 217
 	}
218 218
 
219
-	$request_payment_mode = isset( $_REQUEST['payment-mode'] ) ? $_REQUEST['payment-mode'] : '';
219
+	$request_payment_mode = isset($_REQUEST['payment-mode']) ? $_REQUEST['payment-mode'] : '';
220 220
 	$chosen               = false;
221 221
 
222 222
 	// If both 'payment-mode' and 'form-id' then set for only this form.
223
-	if ( ! empty( $request_form_id ) && $form_id == $request_form_id ) {
223
+	if ( ! empty($request_form_id) && $form_id == $request_form_id) {
224 224
 		$chosen = $request_payment_mode;
225
-	} elseif ( empty( $request_form_id ) && $request_payment_mode ) {
225
+	} elseif (empty($request_form_id) && $request_payment_mode) {
226 226
 		// If no 'form-id' but there is 'payment-mode'.
227 227
 		$chosen = $request_payment_mode;
228 228
 	}
229 229
 
230 230
 	// Get the enable gateway based of chosen var.
231
-	if ( $chosen && give_is_gateway_active( $chosen ) ) {
232
-		$enabled_gateway = urldecode( $chosen );
231
+	if ($chosen && give_is_gateway_active($chosen)) {
232
+		$enabled_gateway = urldecode($chosen);
233 233
 	} else {
234
-		$enabled_gateway = give_get_default_gateway( $form_id );
234
+		$enabled_gateway = give_get_default_gateway($form_id);
235 235
 	}
236 236
 
237
-	return apply_filters( 'give_chosen_gateway', $enabled_gateway );
237
+	return apply_filters('give_chosen_gateway', $enabled_gateway);
238 238
 
239 239
 }
240 240
 
@@ -252,8 +252,8 @@  discard block
 block discarded – undo
252 252
  *
253 253
  * @return int ID of the new log entry
254 254
  */
255
-function give_record_gateway_error( $title = '', $message = '', $parent = 0 ) {
256
-	return give_record_log( $title, $message, $parent, 'gateway_error' );
255
+function give_record_gateway_error($title = '', $message = '', $parent = 0) {
256
+	return give_record_log($title, $message, $parent, 'gateway_error');
257 257
 }
258 258
 
259 259
 /**
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
  *
267 267
  * @return int
268 268
  */
269
-function give_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) {
269
+function give_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') {
270 270
 
271 271
 	$ret  = 0;
272 272
 	$args = array(
@@ -278,9 +278,9 @@  discard block
 block discarded – undo
278 278
 		'fields'      => 'ids',
279 279
 	);
280 280
 
281
-	$payments = new WP_Query( $args );
281
+	$payments = new WP_Query($args);
282 282
 
283
-	if ( $payments ) {
283
+	if ($payments) {
284 284
 		$ret = $payments->post_count;
285 285
 	}
286 286
 
@@ -297,27 +297,27 @@  discard block
 block discarded – undo
297 297
  *
298 298
  * @return array $gateways All the available gateways
299 299
  */
300
-function give_get_ordered_payment_gateways( $gateways ) {
300
+function give_get_ordered_payment_gateways($gateways) {
301 301
 
302 302
 	// Get gateways setting.
303
-	$gateways_setting = isset( $_POST['gateways'] ) ? $_POST['gateways'] : give_get_option( 'gateways' );
303
+	$gateways_setting = isset($_POST['gateways']) ? $_POST['gateways'] : give_get_option('gateways');
304 304
 
305 305
 	// Return from here if we do not have gateways setting.
306
-	if ( empty( $gateways_setting ) ) {
306
+	if (empty($gateways_setting)) {
307 307
 		return $gateways;
308 308
 	}
309 309
 
310 310
 	// Reverse array to order payment gateways.
311
-	$gateways_setting = array_reverse( $gateways_setting );
311
+	$gateways_setting = array_reverse($gateways_setting);
312 312
 
313 313
 	// Reorder gateways array
314
-	foreach ( $gateways_setting as $gateway_key => $value ) {
314
+	foreach ($gateways_setting as $gateway_key => $value) {
315 315
 
316
-		$new_gateway_value = isset( $gateways[ $gateway_key ] ) ? $gateways[ $gateway_key ] : '';
317
-		unset( $gateways[ $gateway_key ] );
316
+		$new_gateway_value = isset($gateways[$gateway_key]) ? $gateways[$gateway_key] : '';
317
+		unset($gateways[$gateway_key]);
318 318
 
319
-		if ( ! empty( $new_gateway_value ) ) {
320
-			$gateways = array_merge( array( $gateway_key => $new_gateway_value ), $gateways );
319
+		if ( ! empty($new_gateway_value)) {
320
+			$gateways = array_merge(array($gateway_key => $new_gateway_value), $gateways);
321 321
 		}
322 322
 	}
323 323
 
@@ -328,5 +328,5 @@  discard block
 block discarded – undo
328 328
 	 *
329 329
 	 * @param array $gateways All the available gateways
330 330
 	 */
331
-	return apply_filters( 'give_payment_gateways_order', $gateways );
331
+	return apply_filters('give_payment_gateways_order', $gateways);
332 332
 }
333 333
\ No newline at end of file
Please login to merge, or discard this patch.
includes/gateways/offline-donations.php 1 patch
Spacing   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -18,17 +18,17 @@  discard block
 block discarded – undo
18 18
  *
19 19
  * @return array
20 20
  */
21
-function give_offline_register_gateway( $gateways ) {
21
+function give_offline_register_gateway($gateways) {
22 22
 	// Format: ID => Name
23 23
 	$gateways['offline'] = array(
24
-		'admin_label'    => esc_attr__( 'Offline Donation', 'give' ),
25
-		'checkout_label' => esc_attr__( 'Offline Donation', 'give' )
24
+		'admin_label'    => esc_attr__('Offline Donation', 'give'),
25
+		'checkout_label' => esc_attr__('Offline Donation', 'give')
26 26
 	);
27 27
 
28 28
 	return $gateways;
29 29
 }
30 30
 
31
-add_filter( 'give_payment_gateways', 'give_offline_register_gateway', 1 );
31
+add_filter('give_payment_gateways', 'give_offline_register_gateway', 1);
32 32
 
33 33
 
34 34
 /**
@@ -40,9 +40,9 @@  discard block
 block discarded – undo
40 40
  *
41 41
  * @return void
42 42
  */
43
-function give_offline_payment_cc_form( $form_id ) {
43
+function give_offline_payment_cc_form($form_id) {
44 44
 	// Get offline payment instruction.
45
-	$offline_instructions = give_get_offline_payment_instruction( $form_id, true );
45
+	$offline_instructions = give_get_offline_payment_instruction($form_id, true);
46 46
 
47 47
 	ob_start();
48 48
 
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
 	 *
54 54
 	 * @param int $form_id Give form id.
55 55
 	 */
56
-	do_action( 'give_before_offline_info_fields', $form_id );
56
+	do_action('give_before_offline_info_fields', $form_id);
57 57
 	?>
58 58
     <fieldset id="give_offline_payment_info">
59
-		<?php echo stripslashes( $offline_instructions ); ?>
59
+		<?php echo stripslashes($offline_instructions); ?>
60 60
     </fieldset>
61 61
 	<?php
62 62
 	/**
@@ -66,35 +66,35 @@  discard block
 block discarded – undo
66 66
 	 *
67 67
 	 * @param int $form_id Give form id.
68 68
 	 */
69
-	do_action( 'give_after_offline_info_fields', $form_id );
69
+	do_action('give_after_offline_info_fields', $form_id);
70 70
 
71 71
 	echo ob_get_clean();
72 72
 }
73 73
 
74
-add_action( 'give_offline_cc_form', 'give_offline_payment_cc_form' );
74
+add_action('give_offline_cc_form', 'give_offline_payment_cc_form');
75 75
 
76 76
 /**
77 77
  * Give Offline Billing Field
78 78
  *
79 79
  * @param $form_id
80 80
  */
81
-function give_offline_billing_fields( $form_id ) {
81
+function give_offline_billing_fields($form_id) {
82 82
 	//Enable Default CC fields (billing info)
83
-	$post_offline_cc_fields        = give_get_meta( $form_id, '_give_offline_donation_enable_billing_fields_single', true );
84
-	$post_offline_customize_option = give_get_meta( $form_id, '_give_customize_offline_donations', true );
83
+	$post_offline_cc_fields        = give_get_meta($form_id, '_give_offline_donation_enable_billing_fields_single', true);
84
+	$post_offline_customize_option = give_get_meta($form_id, '_give_customize_offline_donations', true);
85 85
 
86
-	$global_offline_cc_fields = give_get_option( 'give_offline_donation_enable_billing_fields' );
86
+	$global_offline_cc_fields = give_get_option('give_offline_donation_enable_billing_fields');
87 87
 
88 88
 	//Output CC Address fields if global option is on and user hasn't elected to customize this form's offline donation options
89 89
 	if (
90
-		( give_is_setting_enabled( $post_offline_customize_option, 'global' ) && give_is_setting_enabled( $global_offline_cc_fields ) )
91
-		|| ( give_is_setting_enabled( $post_offline_customize_option, 'enabled' ) && give_is_setting_enabled( $post_offline_cc_fields ) )
90
+		(give_is_setting_enabled($post_offline_customize_option, 'global') && give_is_setting_enabled($global_offline_cc_fields))
91
+		|| (give_is_setting_enabled($post_offline_customize_option, 'enabled') && give_is_setting_enabled($post_offline_cc_fields))
92 92
 	) {
93
-		give_default_cc_address_fields( $form_id );
93
+		give_default_cc_address_fields($form_id);
94 94
 	}
95 95
 }
96 96
 
97
-add_action( 'give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1 );
97
+add_action('give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1);
98 98
 
99 99
 /**
100 100
  * Process the payment
@@ -105,18 +105,18 @@  discard block
 block discarded – undo
105 105
  *
106 106
  * @return void
107 107
  */
108
-function give_offline_process_payment( $purchase_data ) {
108
+function give_offline_process_payment($purchase_data) {
109 109
 
110 110
 	// Setup the payment details.
111 111
 	$payment_data = array(
112 112
 		'price'           => $purchase_data['price'],
113 113
 		'give_form_title' => $purchase_data['post_data']['give-form-title'],
114
-		'give_form_id'    => intval( $purchase_data['post_data']['give-form-id'] ),
115
-		'give_price_id'   => isset( $purchase_data['post_data']['give-price-id'] ) ? $purchase_data['post_data']['give-price-id'] : '',
114
+		'give_form_id'    => intval($purchase_data['post_data']['give-form-id']),
115
+		'give_price_id'   => isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : '',
116 116
 		'date'            => $purchase_data['date'],
117 117
 		'user_email'      => $purchase_data['user_email'],
118 118
 		'purchase_key'    => $purchase_data['purchase_key'],
119
-		'currency'        => give_get_currency( $purchase_data['post_data']['give-form-id'], $purchase_data ),
119
+		'currency'        => give_get_currency($purchase_data['post_data']['give-form-id'], $purchase_data),
120 120
 		'user_info'       => $purchase_data['user_info'],
121 121
 		'status'          => 'pending',
122 122
 		'gateway'         => 'offline'
@@ -124,20 +124,20 @@  discard block
 block discarded – undo
124 124
 
125 125
 
126 126
 	// record the pending payment
127
-	$payment = give_insert_payment( $payment_data );
127
+	$payment = give_insert_payment($payment_data);
128 128
 
129
-	if ( $payment ) {
130
-		give_offline_send_admin_notice( $payment );
131
-		give_offline_send_donor_instructions( $payment );
129
+	if ($payment) {
130
+		give_offline_send_admin_notice($payment);
131
+		give_offline_send_donor_instructions($payment);
132 132
 		give_send_to_success_page();
133 133
 	} else {
134 134
 		// if errors are present, send the user back to the donation form so they can be corrected
135
-		give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] );
135
+		give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']);
136 136
 	}
137 137
 
138 138
 }
139 139
 
140
-add_action( 'give_gateway_offline', 'give_offline_process_payment' );
140
+add_action('give_gateway_offline', 'give_offline_process_payment');
141 141
 
142 142
 
143 143
 /**
@@ -150,59 +150,59 @@  discard block
 block discarded – undo
150 150
  * @since       1.0
151 151
  * @return void
152 152
  */
153
-function give_offline_send_donor_instructions( $payment_id = 0 ) {
153
+function give_offline_send_donor_instructions($payment_id = 0) {
154 154
 
155
-	$payment_data                      = give_get_payment_meta( $payment_id );
156
-	$post_offline_customization_option = give_get_meta( $payment_data['form_id'], '_give_customize_offline_donations', true );
155
+	$payment_data                      = give_get_payment_meta($payment_id);
156
+	$post_offline_customization_option = give_get_meta($payment_data['form_id'], '_give_customize_offline_donations', true);
157 157
 
158 158
 	//Customize email content depending on whether the single form has been customized
159
-	$email_content = give_get_option( 'global_offline_donation_email' );
159
+	$email_content = give_get_option('global_offline_donation_email');
160 160
 
161
-	if ( give_is_setting_enabled( $post_offline_customization_option, 'enabled' ) ) {
162
-		$email_content = give_get_meta( $payment_data['form_id'], '_give_offline_donation_email', true );
161
+	if (give_is_setting_enabled($post_offline_customization_option, 'enabled')) {
162
+		$email_content = give_get_meta($payment_data['form_id'], '_give_offline_donation_email', true);
163 163
 	}
164 164
 
165
-	$from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) );
165
+	$from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES));
166 166
 
167 167
 	/**
168 168
 	 * Filters the from name.
169 169
 	 *
170 170
 	 * @since 1.7
171 171
 	 */
172
-	$from_name = apply_filters( 'give_donation_from_name', $from_name, $payment_id, $payment_data );
172
+	$from_name = apply_filters('give_donation_from_name', $from_name, $payment_id, $payment_data);
173 173
 
174
-	$from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) );
174
+	$from_email = give_get_option('from_email', get_bloginfo('admin_email'));
175 175
 
176 176
 	/**
177 177
 	 * Filters the from email.
178 178
 	 *
179 179
 	 * @since 1.7
180 180
 	 */
181
-	$from_email = apply_filters( 'give_donation_from_address', $from_email, $payment_id, $payment_data );
181
+	$from_email = apply_filters('give_donation_from_address', $from_email, $payment_id, $payment_data);
182 182
 
183
-	$to_email = give_get_payment_user_email( $payment_id );
183
+	$to_email = give_get_payment_user_email($payment_id);
184 184
 
185
-	$subject = give_get_option( 'offline_donation_subject', __( 'Offline Donation Instructions', 'give' ) );
186
-	if ( give_is_setting_enabled( $post_offline_customization_option, 'enabled' ) ) {
187
-		$subject = give_get_meta( $payment_data['form_id'], '_give_offline_donation_subject', true );
185
+	$subject = give_get_option('offline_donation_subject', __('Offline Donation Instructions', 'give'));
186
+	if (give_is_setting_enabled($post_offline_customization_option, 'enabled')) {
187
+		$subject = give_get_meta($payment_data['form_id'], '_give_offline_donation_subject', true);
188 188
 	}
189 189
 
190
-	$subject = apply_filters( 'give_offline_donation_subject', wp_strip_all_tags( $subject ), $payment_id );
191
-	$subject = give_do_email_tags( $subject, $payment_id );
190
+	$subject = apply_filters('give_offline_donation_subject', wp_strip_all_tags($subject), $payment_id);
191
+	$subject = give_do_email_tags($subject, $payment_id);
192 192
 
193
-	$attachments = apply_filters( 'give_offline_donation_attachments', array(), $payment_id, $payment_data );
194
-	$message     = give_do_email_tags( $email_content, $payment_id );
193
+	$attachments = apply_filters('give_offline_donation_attachments', array(), $payment_id, $payment_data);
194
+	$message     = give_do_email_tags($email_content, $payment_id);
195 195
 
196 196
 	$emails = Give()->emails;
197 197
 
198
-	$emails->__set( 'from_name', $from_name );
199
-	$emails->__set( 'from_email', $from_email );
200
-	$emails->__set( 'heading', __( 'Offline Donation Instructions', 'give' ) );
198
+	$emails->__set('from_name', $from_name);
199
+	$emails->__set('from_email', $from_email);
200
+	$emails->__set('heading', __('Offline Donation Instructions', 'give'));
201 201
 
202
-	$headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data );
203
-	$emails->__set( 'headers', $headers );
202
+	$headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data);
203
+	$emails->__set('headers', $headers);
204 204
 
205
-	$emails->send( $to_email, $subject, $message, $attachments );
205
+	$emails->send($to_email, $subject, $message, $attachments);
206 206
 
207 207
 }
208 208
 
@@ -219,54 +219,54 @@  discard block
 block discarded – undo
219 219
  * @return void
220 220
  *
221 221
  */
222
-function give_offline_send_admin_notice( $payment_id = 0 ) {
222
+function give_offline_send_admin_notice($payment_id = 0) {
223 223
 
224 224
 	/* Send an email notification to the admin */
225 225
 	$admin_email = give_get_admin_notice_emails();
226
-	$user_info   = give_get_payment_meta_user_info( $payment_id );
226
+	$user_info   = give_get_payment_meta_user_info($payment_id);
227 227
 
228
-	if ( isset( $user_info['id'] ) && $user_info['id'] > 0 ) {
229
-		$user_data = get_userdata( $user_info['id'] );
228
+	if (isset($user_info['id']) && $user_info['id'] > 0) {
229
+		$user_data = get_userdata($user_info['id']);
230 230
 		$name      = $user_data->display_name;
231
-	} elseif ( isset( $user_info['first_name'] ) && isset( $user_info['last_name'] ) ) {
232
-		$name = $user_info['first_name'] . ' ' . $user_info['last_name'];
231
+	} elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) {
232
+		$name = $user_info['first_name'].' '.$user_info['last_name'];
233 233
 	} else {
234 234
 		$name = $user_info['email'];
235 235
 	}
236 236
 
237
-	$amount = give_donation_amount( $payment_id );
237
+	$amount = give_donation_amount($payment_id);
238 238
 
239
-	$admin_subject = apply_filters( 'give_offline_admin_donation_notification_subject', __( 'New Pending Donation', 'give' ), $payment_id );
239
+	$admin_subject = apply_filters('give_offline_admin_donation_notification_subject', __('New Pending Donation', 'give'), $payment_id);
240 240
 
241
-	$admin_message = __( 'Dear Admin,', 'give' ) . "\n\n";
242
-	$admin_message .= sprintf(__( 'A new offline donation has been made on your website for %s.', 'give' ), $amount) . "\n\n";
243
-	$admin_message .= __( 'The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give' ) . "\n\n";
241
+	$admin_message = __('Dear Admin,', 'give')."\n\n";
242
+	$admin_message .= sprintf(__('A new offline donation has been made on your website for %s.', 'give'), $amount)."\n\n";
243
+	$admin_message .= __('The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give')."\n\n";
244 244
 
245 245
 
246
-	$admin_message .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n";
247
-	$admin_message .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n\n";
246
+	$admin_message .= '<strong>'.__('Donor:', 'give').'</strong> {fullname}'."\n";
247
+	$admin_message .= '<strong>'.__('Amount:', 'give').'</strong> {amount}'."\n\n";
248 248
 
249 249
 	$admin_message .= sprintf(
250 250
 		                  '<a href="%1$s">%2$s</a>',
251
-		                  admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $payment_id ),
252
-		                  __( 'View Donation Details &raquo;', 'give' )
253
-	                  ) . "\n\n";
251
+		                  admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id='.$payment_id),
252
+		                  __('View Donation Details &raquo;', 'give')
253
+	                  )."\n\n";
254 254
 
255
-	$admin_message = apply_filters( 'give_offline_admin_donation_notification', $admin_message, $payment_id );
256
-	$admin_message = give_do_email_tags( $admin_message, $payment_id );
255
+	$admin_message = apply_filters('give_offline_admin_donation_notification', $admin_message, $payment_id);
256
+	$admin_message = give_do_email_tags($admin_message, $payment_id);
257 257
 
258
-	$attachments   = apply_filters( 'give_offline_admin_donation_notification_attachments', array(), $payment_id );
259
-	$admin_headers = apply_filters( 'give_offline_admin_donation_notification_headers', array(), $payment_id );
258
+	$attachments   = apply_filters('give_offline_admin_donation_notification_attachments', array(), $payment_id);
259
+	$admin_headers = apply_filters('give_offline_admin_donation_notification_headers', array(), $payment_id);
260 260
 
261 261
 	//Send Email
262 262
 	$emails = Give()->emails;
263
-	$emails->__set( 'heading', __( 'New Offline Donation', 'give' ) );
263
+	$emails->__set('heading', __('New Offline Donation', 'give'));
264 264
 
265
-	if ( ! empty( $admin_headers ) ) {
266
-		$emails->__set( 'headers', $admin_headers );
265
+	if ( ! empty($admin_headers)) {
266
+		$emails->__set('headers', $admin_headers);
267 267
 	}
268 268
 
269
-	$emails->send( $admin_email, $admin_subject, $admin_message, $attachments );
269
+	$emails->send($admin_email, $admin_subject, $admin_message, $attachments);
270 270
 
271 271
 }
272 272
 
@@ -278,20 +278,20 @@  discard block
 block discarded – undo
278 278
  *
279 279
  * @return array
280 280
  */
281
-function give_offline_add_settings( $settings ) {
281
+function give_offline_add_settings($settings) {
282 282
 
283 283
 	// Bailout: Do not show offline gateways setting in to metabox if its disabled globally.
284
-	if ( in_array( 'offline', (array) give_get_option( 'gateways' ) ) ) {
284
+	if (in_array('offline', (array) give_get_option('gateways'))) {
285 285
 		return $settings;
286 286
 	}
287 287
 
288 288
 	//Vars
289 289
 	$prefix = '_give_';
290 290
 
291
-	$is_gateway_active = give_is_gateway_active( 'offline' );
291
+	$is_gateway_active = give_is_gateway_active('offline');
292 292
 
293 293
 	//this gateway isn't active
294
-	if ( ! $is_gateway_active ) {
294
+	if ( ! $is_gateway_active) {
295 295
 		//return settings and bounce
296 296
 		return $settings;
297 297
 	}
@@ -300,34 +300,34 @@  discard block
 block discarded – undo
300 300
 	$check_settings = array(
301 301
 
302 302
 		array(
303
-			'name'    => __( 'Offline Donations', 'give' ),
304
-			'desc'    => __( 'Do you want to customize the donation instructions for this form?', 'give' ),
305
-			'id'      => $prefix . 'customize_offline_donations',
303
+			'name'    => __('Offline Donations', 'give'),
304
+			'desc'    => __('Do you want to customize the donation instructions for this form?', 'give'),
305
+			'id'      => $prefix.'customize_offline_donations',
306 306
 			'type'    => 'radio_inline',
307 307
 			'default' => 'global',
308
-			'options' => apply_filters( 'give_forms_content_options_select', array(
309
-					'global'   => __( 'Global Option', 'give' ),
310
-					'enabled'  => __( 'Customize', 'give' ),
311
-					'disabled' => __( 'Disable', 'give' ),
308
+			'options' => apply_filters('give_forms_content_options_select', array(
309
+					'global'   => __('Global Option', 'give'),
310
+					'enabled'  => __('Customize', 'give'),
311
+					'disabled' => __('Disable', 'give'),
312 312
 				)
313 313
 			),
314 314
 		),
315 315
 		array(
316
-			'name'        => __( 'Billing Fields', 'give' ),
317
-			'desc'        => __( 'This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give' ),
318
-			'id'          => $prefix . 'offline_donation_enable_billing_fields_single',
316
+			'name'        => __('Billing Fields', 'give'),
317
+			'desc'        => __('This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give'),
318
+			'id'          => $prefix.'offline_donation_enable_billing_fields_single',
319 319
 			'row_classes' => 'give-subfield give-hidden',
320 320
 			'type'        => 'radio_inline',
321 321
 			'default'     => 'disabled',
322 322
 			'options'     => array(
323
-				'enabled'  => __( 'Enabled', 'give' ),
324
-				'disabled' => __( 'Disabled', 'give' ),
323
+				'enabled'  => __('Enabled', 'give'),
324
+				'disabled' => __('Disabled', 'give'),
325 325
 			),
326 326
 		),
327 327
 		array(
328
-			'id'          => $prefix . 'offline_checkout_notes',
329
-			'name'        => __( 'Donation Instructions', 'give' ),
330
-			'desc'        => __( 'Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ),
328
+			'id'          => $prefix.'offline_checkout_notes',
329
+			'name'        => __('Donation Instructions', 'give'),
330
+			'desc'        => __('Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give'),
331 331
 			'default'     => give_get_default_offline_donation_content(),
332 332
 			'type'        => 'wysiwyg',
333 333
 			'row_classes' => 'give-subfield give-hidden',
@@ -336,17 +336,17 @@  discard block
 block discarded – undo
336 336
 			),
337 337
 		),
338 338
 		array(
339
-			'id'          => $prefix . 'offline_donation_subject',
340
-			'name'        => __( 'Email Subject', 'give' ),
341
-			'desc'        => __( 'Enter the subject line for the donation receipt email.', 'give' ),
342
-			'default'     => __( '{form_title} - Offline Donation Instructions', 'give' ),
339
+			'id'          => $prefix.'offline_donation_subject',
340
+			'name'        => __('Email Subject', 'give'),
341
+			'desc'        => __('Enter the subject line for the donation receipt email.', 'give'),
342
+			'default'     => __('{form_title} - Offline Donation Instructions', 'give'),
343 343
 			'row_classes' => 'give-subfield give-hidden',
344 344
 			'type'        => 'text',
345 345
 		),
346 346
 		array(
347
-			'id'          => $prefix . 'offline_donation_email',
348
-			'name'        => __( 'Email Instructions', 'give' ),
349
-			'desc'        => __( 'Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ) . ' ' . __( 'Available template tags:', 'give' ) . give_get_emails_tags_list(),
347
+			'id'          => $prefix.'offline_donation_email',
348
+			'name'        => __('Email Instructions', 'give'),
349
+			'desc'        => __('Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give').' '.__('Available template tags:', 'give').give_get_emails_tags_list(),
350 350
 			'default'     => give_get_default_offline_donation_email_content(),
351 351
 			'type'        => 'wysiwyg',
352 352
 			'row_classes' => 'give-subfield give-hidden',
@@ -358,14 +358,14 @@  discard block
 block discarded – undo
358 358
 			'name'  => 'offline_docs',
359 359
 			'type'  => 'docs_link',
360 360
 			'url'   => 'http://docs.givewp.com/settings-gateway-offline-donations',
361
-			'title' => __( 'Offline Donations', 'give' ),
361
+			'title' => __('Offline Donations', 'give'),
362 362
 		),
363 363
 	);
364 364
 
365
-	return array_merge( $settings, $check_settings );
365
+	return array_merge($settings, $check_settings);
366 366
 }
367 367
 
368
-add_filter( 'give_forms_offline_donations_metabox_fields', 'give_offline_add_settings' );
368
+add_filter('give_forms_offline_donations_metabox_fields', 'give_offline_add_settings');
369 369
 
370 370
 
371 371
 /**
@@ -377,32 +377,32 @@  discard block
 block discarded – undo
377 377
  */
378 378
 function give_get_default_offline_donation_content() {
379 379
 
380
-	$sitename = get_bloginfo( 'sitename' );
380
+	$sitename = get_bloginfo('sitename');
381 381
 
382
-	$default_text = '<p>' . __( 'In order to make an offline donation we ask that you please follow these instructions', 'give' ) . ': </p>';
382
+	$default_text = '<p>'.__('In order to make an offline donation we ask that you please follow these instructions', 'give').': </p>';
383 383
 	$default_text .= '<ol>';
384 384
 	$default_text .= '<li>';
385 385
 	$default_text .= sprintf(
386 386
 	/* translators: %s: site name */
387
-		__( 'Make a check payable to "%s"', 'give' ),
387
+		__('Make a check payable to "%s"', 'give'),
388 388
 		$sitename
389 389
 	);
390 390
 	$default_text .= '</li>';
391 391
 	$default_text .= '<li>';
392 392
 	$default_text .= sprintf(
393 393
 	/* translators: %s: site name */
394
-		__( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ),
394
+		__('On the memo line of the check, please indicate that the donation is for "%s"', 'give'),
395 395
 		$sitename
396 396
 	);
397 397
 	$default_text .= '</li>';
398
-	$default_text .= '<li>' . __( 'Please mail your check to:', 'give' ) . '</li>';
398
+	$default_text .= '<li>'.__('Please mail your check to:', 'give').'</li>';
399 399
 	$default_text .= '</ol>';
400
-	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>' . $sitename . '</em><br>';
400
+	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>'.$sitename.'</em><br>';
401 401
 	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>111 Not A Real St.</em><br>';
402 402
 	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>Anytown, CA 12345 </em><br>';
403
-	$default_text .= '<p>' . __( 'All contributions will be gratefully acknowledged and are tax deductible.', 'give' ) . '</p>';
403
+	$default_text .= '<p>'.__('All contributions will be gratefully acknowledged and are tax deductible.', 'give').'</p>';
404 404
 
405
-	return apply_filters( 'give_default_offline_donation_content', $default_text );
405
+	return apply_filters('give_default_offline_donation_content', $default_text);
406 406
 
407 407
 }
408 408
 
@@ -415,34 +415,34 @@  discard block
 block discarded – undo
415 415
  */
416 416
 function give_get_default_offline_donation_email_content() {
417 417
 
418
-	$sitename     = get_bloginfo( 'sitename' );
419
-	$default_text = '<p>' . __( 'Dear {name},', 'give' ) . '</p>';
420
-	$default_text .= '<p>' . __( 'Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions:', 'give' ) . '</p>';
418
+	$sitename     = get_bloginfo('sitename');
419
+	$default_text = '<p>'.__('Dear {name},', 'give').'</p>';
420
+	$default_text .= '<p>'.__('Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions:', 'give').'</p>';
421 421
 	$default_text .= '<ol>';
422 422
 	$default_text .= '<li>';
423 423
 	$default_text .= sprintf(
424 424
 	/* translators: %s: site name */
425
-		__( 'Make a check payable to "%s"', 'give' ),
425
+		__('Make a check payable to "%s"', 'give'),
426 426
 		$sitename
427 427
 	);
428 428
 	$default_text .= '</li>';
429 429
 	$default_text .= '<li>';
430 430
 	$default_text .= sprintf(
431 431
 	/* translators: %s: site name */
432
-		__( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ),
432
+		__('On the memo line of the check, please indicate that the donation is for "%s"', 'give'),
433 433
 		$sitename
434 434
 	);
435 435
 	$default_text .= '</li>';
436
-	$default_text .= '<li>' . __( 'Please mail your check to:', 'give' ) . '</li>';
436
+	$default_text .= '<li>'.__('Please mail your check to:', 'give').'</li>';
437 437
 	$default_text .= '</ol>';
438
-	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>' . $sitename . '</em><br>';
438
+	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>'.$sitename.'</em><br>';
439 439
 	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>111 Not A Real St.</em><br>';
440 440
 	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>Anytown, CA 12345 </em><br>';
441
-	$default_text .= '<p>' . __( 'Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give' ) . '</p>';
442
-	$default_text .= '<p>' . __( 'Sincerely,', 'give' ) . '</p>';
443
-	$default_text .= '<p>' . $sitename . '</p>';
441
+	$default_text .= '<p>'.__('Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give').'</p>';
442
+	$default_text .= '<p>'.__('Sincerely,', 'give').'</p>';
443
+	$default_text .= '<p>'.$sitename.'</p>';
444 444
 
445
-	return apply_filters( 'give_default_offline_donation_content', $default_text );
445
+	return apply_filters('give_default_offline_donation_content', $default_text);
446 446
 
447 447
 }
448 448
 
@@ -456,17 +456,17 @@  discard block
 block discarded – undo
456 456
  *
457 457
  * @return string
458 458
  */
459
-function give_offline_donation_receipt_status_notice( $notice, $id ) {
460
-	$payment = new Give_Payment( $id );
459
+function give_offline_donation_receipt_status_notice($notice, $id) {
460
+	$payment = new Give_Payment($id);
461 461
 
462
-	if ( 'offline' !== $payment->gateway || $payment->is_completed() ) {
462
+	if ('offline' !== $payment->gateway || $payment->is_completed()) {
463 463
 		return $notice;
464 464
 	}
465 465
 
466
-	return Give()->notices->print_frontend_notice( __( 'Payment Pending: Please follow the instructions below to complete your donation.', 'give' ), false, 'warning' );
466
+	return Give()->notices->print_frontend_notice(__('Payment Pending: Please follow the instructions below to complete your donation.', 'give'), false, 'warning');
467 467
 }
468 468
 
469
-add_filter( 'give_receipt_status_notice', 'give_offline_donation_receipt_status_notice', 10, 2 );
469
+add_filter('give_receipt_status_notice', 'give_offline_donation_receipt_status_notice', 10, 2);
470 470
 
471 471
 /**
472 472
  * Get offline payment instructions.
@@ -478,27 +478,27 @@  discard block
 block discarded – undo
478 478
  *
479 479
  * @return string
480 480
  */
481
-function give_get_offline_payment_instruction( $form_id, $wpautop = false ) {
481
+function give_get_offline_payment_instruction($form_id, $wpautop = false) {
482 482
 	// Bailout.
483
-	if ( ! $form_id ) {
483
+	if ( ! $form_id) {
484 484
 		return '';
485 485
 	}
486 486
 
487
-	$post_offline_customization_option = give_get_meta( $form_id, '_give_customize_offline_donations', true );
488
-	$post_offline_instructions         = give_get_meta( $form_id, '_give_offline_checkout_notes', true );
489
-	$global_offline_instruction        = give_get_option( 'global_offline_donation_content' );
487
+	$post_offline_customization_option = give_get_meta($form_id, '_give_customize_offline_donations', true);
488
+	$post_offline_instructions         = give_get_meta($form_id, '_give_offline_checkout_notes', true);
489
+	$global_offline_instruction        = give_get_option('global_offline_donation_content');
490 490
 	$offline_instructions              = $global_offline_instruction;
491 491
 
492
-	if ( give_is_setting_enabled( $post_offline_customization_option ) ) {
492
+	if (give_is_setting_enabled($post_offline_customization_option)) {
493 493
 		$offline_instructions = $post_offline_instructions;
494 494
 	}
495 495
 
496
-	$settings_url = admin_url( 'post.php?post=' . $form_id . '&action=edit&message=1' );
496
+	$settings_url = admin_url('post.php?post='.$form_id.'&action=edit&message=1');
497 497
 
498 498
 	/* translators: %s: form settings url */
499
-	$offline_instructions = ! empty( $offline_instructions ) ? $offline_instructions : sprintf( __( 'Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give' ), $settings_url );
499
+	$offline_instructions = ! empty($offline_instructions) ? $offline_instructions : sprintf(__('Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give'), $settings_url);
500 500
 
501
-	return ( $wpautop ? wpautop( $offline_instructions ) : $offline_instructions );
501
+	return ($wpautop ? wpautop($offline_instructions) : $offline_instructions);
502 502
 }
503 503
 
504 504
 
@@ -512,24 +512,24 @@  discard block
 block discarded – undo
512 512
  *
513 513
  * @return array
514 514
  */
515
-function give_filter_offline_gateway( $gateway_list, $form_id ) {
515
+function give_filter_offline_gateway($gateway_list, $form_id) {
516 516
 	if (
517 517
 		// Show offline payment gateway if enable for new donation form.
518
-		( false === strpos( $_SERVER['REQUEST_URI'], '/wp-admin/post-new.php?post_type=give_forms' ) )
518
+		(false === strpos($_SERVER['REQUEST_URI'], '/wp-admin/post-new.php?post_type=give_forms'))
519 519
 		&& $form_id
520
-		&& ! give_is_setting_enabled( give_get_meta( $form_id, '_give_customize_offline_donations', true ), array(
520
+		&& ! give_is_setting_enabled(give_get_meta($form_id, '_give_customize_offline_donations', true), array(
521 521
 			'enabled',
522 522
 			'global',
523
-		) )
523
+		))
524 524
 	) {
525
-		unset( $gateway_list['offline'] );
525
+		unset($gateway_list['offline']);
526 526
 	}
527 527
 
528 528
 	// Output.
529 529
 	return $gateway_list;
530 530
 }
531 531
 
532
-add_filter( 'give_enabled_payment_gateways', 'give_filter_offline_gateway', 10, 2 );
532
+add_filter('give_enabled_payment_gateways', 'give_filter_offline_gateway', 10, 2);
533 533
 
534 534
 /**
535 535
  * Set default gateway to global default payment gateway
@@ -543,10 +543,10 @@  discard block
 block discarded – undo
543 543
  *
544 544
  * @return void
545 545
  */
546
-function _give_customize_offline_donations_on_save_callback( $meta_key, $meta_value, $postid ) {
547
-	if ( ! give_is_setting_enabled( $meta_value, array( 'global', 'enabled' ) ) && ( 'offline' === give_get_meta( $postid, '_give_default_gateway', true ) ) ) {
548
-		give_update_meta( $postid, '_give_default_gateway', 'global' );
546
+function _give_customize_offline_donations_on_save_callback($meta_key, $meta_value, $postid) {
547
+	if ( ! give_is_setting_enabled($meta_value, array('global', 'enabled')) && ('offline' === give_get_meta($postid, '_give_default_gateway', true))) {
548
+		give_update_meta($postid, '_give_default_gateway', 'global');
549 549
 	}
550 550
 }
551 551
 
552
-add_filter( 'give_save__give_customize_offline_donations', '_give_customize_offline_donations_on_save_callback', 10, 3 );
552
+add_filter('give_save__give_customize_offline_donations', '_give_customize_offline_donations_on_save_callback', 10, 3);
Please login to merge, or discard this patch.
includes/class-give-roles.php 1 patch
Spacing   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
 	 * @access public
36 36
 	 */
37 37
 	public function __construct() {
38
-		add_filter( 'give_map_meta_cap', array( $this, 'meta_caps' ), 10, 4 );
39
-		add_filter( 'woocommerce_disable_admin_bar', array( $this, 'manage_admin_dashboard' ), 10 );
40
-		add_filter( 'woocommerce_prevent_admin_access', array( $this, 'manage_admin_dashboard'), 10 );
38
+		add_filter('give_map_meta_cap', array($this, 'meta_caps'), 10, 4);
39
+		add_filter('woocommerce_disable_admin_bar', array($this, 'manage_admin_dashboard'), 10);
40
+		add_filter('woocommerce_prevent_admin_access', array($this, 'manage_admin_dashboard'), 10);
41 41
 	}
42 42
 
43 43
 	/**
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	 * @return void
52 52
 	 */
53 53
 	public function add_roles() {
54
-		add_role( 'give_manager', __( 'Give Manager', 'give' ), array(
54
+		add_role('give_manager', __('Give Manager', 'give'), array(
55 55
 			'read'                   => true,
56 56
 			'edit_posts'             => true,
57 57
 			'delete_posts'           => true,
@@ -80,25 +80,25 @@  discard block
 block discarded – undo
80 80
 			'publish_posts'          => true,
81 81
 			'read_private_pages'     => true,
82 82
 			'read_private_posts'     => true,
83
-		) );
83
+		));
84 84
 
85
-		add_role( 'give_accountant', __( 'Give Accountant', 'give' ), array(
85
+		add_role('give_accountant', __('Give Accountant', 'give'), array(
86 86
 			'read'         => true,
87 87
 			'edit_posts'   => false,
88 88
 			'delete_posts' => false
89
-		) );
89
+		));
90 90
 
91
-		add_role( 'give_worker', __( 'Give Worker', 'give' ), array(
91
+		add_role('give_worker', __('Give Worker', 'give'), array(
92 92
 			'read'         => true,
93 93
 			'edit_posts'   => true,
94 94
 			'edit_pages'   => true,
95 95
 			'upload_files' => true,
96 96
 			'delete_posts' => false,
97
-		) );
97
+		));
98 98
 
99
-		add_role( 'give_donor', __( 'Give Donor', 'give' ), array(
99
+		add_role('give_donor', __('Give Donor', 'give'), array(
100 100
 			'read' => true,
101
-		) );
101
+		));
102 102
 
103 103
 	}
104 104
 
@@ -117,41 +117,41 @@  discard block
 block discarded – undo
117 117
 	public function add_caps() {
118 118
 		global $wp_roles;
119 119
 
120
-		if ( class_exists( 'WP_Roles' ) ) {
121
-			if ( ! isset( $wp_roles ) ) {
120
+		if (class_exists('WP_Roles')) {
121
+			if ( ! isset($wp_roles)) {
122 122
 				$wp_roles = new WP_Roles();
123 123
 			}
124 124
 		}
125 125
 
126
-		if ( is_object( $wp_roles ) ) {
127
-			$wp_roles->add_cap( 'give_manager', 'view_give_reports' );
128
-			$wp_roles->add_cap( 'give_manager', 'view_give_sensitive_data' );
129
-			$wp_roles->add_cap( 'give_manager', 'export_give_reports' );
130
-			$wp_roles->add_cap( 'give_manager', 'manage_give_settings' );
126
+		if (is_object($wp_roles)) {
127
+			$wp_roles->add_cap('give_manager', 'view_give_reports');
128
+			$wp_roles->add_cap('give_manager', 'view_give_sensitive_data');
129
+			$wp_roles->add_cap('give_manager', 'export_give_reports');
130
+			$wp_roles->add_cap('give_manager', 'manage_give_settings');
131 131
 
132
-			$wp_roles->add_cap( 'administrator', 'view_give_reports' );
133
-			$wp_roles->add_cap( 'administrator', 'view_give_sensitive_data' );
134
-			$wp_roles->add_cap( 'administrator', 'export_give_reports' );
135
-			$wp_roles->add_cap( 'administrator', 'manage_give_settings' );
136
-			$wp_roles->add_cap( 'administrator', 'view_give_payments' );
132
+			$wp_roles->add_cap('administrator', 'view_give_reports');
133
+			$wp_roles->add_cap('administrator', 'view_give_sensitive_data');
134
+			$wp_roles->add_cap('administrator', 'export_give_reports');
135
+			$wp_roles->add_cap('administrator', 'manage_give_settings');
136
+			$wp_roles->add_cap('administrator', 'view_give_payments');
137 137
 
138 138
 			// Add the main post type capabilities.
139 139
 			$capabilities = $this->get_core_caps();
140
-			foreach ( $capabilities as $cap_group ) {
141
-				foreach ( $cap_group as $cap ) {
142
-					$wp_roles->add_cap( 'administrator', $cap );
143
-					$wp_roles->add_cap( 'give_manager', $cap );
144
-					$wp_roles->add_cap( 'give_worker', $cap );
140
+			foreach ($capabilities as $cap_group) {
141
+				foreach ($cap_group as $cap) {
142
+					$wp_roles->add_cap('administrator', $cap);
143
+					$wp_roles->add_cap('give_manager', $cap);
144
+					$wp_roles->add_cap('give_worker', $cap);
145 145
 				}
146 146
 			}
147 147
 
148 148
 			// Add Capabilities to Give Accountant User Role.
149
-			$wp_roles->add_cap( 'give_accountant', 'edit_give_forms' );
150
-			$wp_roles->add_cap( 'give_accountant', 'read_private_give_forms' );
151
-			$wp_roles->add_cap( 'give_accountant', 'view_give_reports' );
152
-			$wp_roles->add_cap( 'give_accountant', 'export_give_reports' );
153
-			$wp_roles->add_cap( 'give_accountant', 'edit_give_payments' );
154
-			$wp_roles->add_cap( 'give_accountant', 'view_give_payments' );
149
+			$wp_roles->add_cap('give_accountant', 'edit_give_forms');
150
+			$wp_roles->add_cap('give_accountant', 'read_private_give_forms');
151
+			$wp_roles->add_cap('give_accountant', 'view_give_reports');
152
+			$wp_roles->add_cap('give_accountant', 'export_give_reports');
153
+			$wp_roles->add_cap('give_accountant', 'edit_give_payments');
154
+			$wp_roles->add_cap('give_accountant', 'view_give_payments');
155 155
 
156 156
 		}
157 157
 	}
@@ -169,10 +169,10 @@  discard block
 block discarded – undo
169 169
 	public function get_core_caps() {
170 170
 		$capabilities = array();
171 171
 
172
-		$capability_types = array( 'give_form', 'give_payment' );
172
+		$capability_types = array('give_form', 'give_payment');
173 173
 
174
-		foreach ( $capability_types as $capability_type ) {
175
-			$capabilities[ $capability_type ] = array(
174
+		foreach ($capability_types as $capability_type) {
175
+			$capabilities[$capability_type] = array(
176 176
 				// Post type.
177 177
 				"edit_{$capability_type}",
178 178
 				"read_{$capability_type}",
@@ -218,22 +218,22 @@  discard block
 block discarded – undo
218 218
 	 *
219 219
 	 * @return array  $caps    Meta capabilities.
220 220
 	 */
221
-	public function meta_caps( $caps, $cap, $user_id, $args ) {
221
+	public function meta_caps($caps, $cap, $user_id, $args) {
222 222
 
223
-		switch ( $cap ) {
223
+		switch ($cap) {
224 224
 
225 225
 			case 'view_give_form_stats' :
226 226
 
227
-				if ( empty( $args[0] ) ) {
227
+				if (empty($args[0])) {
228 228
 					break;
229 229
 				}
230 230
 
231
-				$form = get_post( $args[0] );
232
-				if ( empty( $form ) ) {
231
+				$form = get_post($args[0]);
232
+				if (empty($form)) {
233 233
 					break;
234 234
 				}
235 235
 
236
-				if ( user_can( $user_id, 'view_give_reports' ) || $user_id == $form->post_author ) {
236
+				if (user_can($user_id, 'view_give_reports') || $user_id == $form->post_author) {
237 237
 					$caps = array();
238 238
 				}
239 239
 
@@ -260,44 +260,44 @@  discard block
 block discarded – undo
260 260
 
261 261
 		global $wp_roles;
262 262
 
263
-		if ( class_exists( 'WP_Roles' ) ) {
264
-			if ( ! isset( $wp_roles ) ) {
263
+		if (class_exists('WP_Roles')) {
264
+			if ( ! isset($wp_roles)) {
265 265
 				$wp_roles = new WP_Roles();
266 266
 			}
267 267
 		}
268 268
 
269
-		if ( is_object( $wp_roles ) ) {
269
+		if (is_object($wp_roles)) {
270 270
 			// Give Manager Capabilities.
271
-			$wp_roles->remove_cap( 'give_manager', 'view_give_reports' );
272
-			$wp_roles->remove_cap( 'give_manager', 'view_give_sensitive_data' );
273
-			$wp_roles->remove_cap( 'give_manager', 'export_give_reports' );
274
-			$wp_roles->remove_cap( 'give_manager', 'manage_give_settings' );
271
+			$wp_roles->remove_cap('give_manager', 'view_give_reports');
272
+			$wp_roles->remove_cap('give_manager', 'view_give_sensitive_data');
273
+			$wp_roles->remove_cap('give_manager', 'export_give_reports');
274
+			$wp_roles->remove_cap('give_manager', 'manage_give_settings');
275 275
 
276 276
 			// Site Administrator Capabilities.
277
-			$wp_roles->remove_cap( 'administrator', 'view_give_reports' );
278
-			$wp_roles->remove_cap( 'administrator', 'view_give_sensitive_data' );
279
-			$wp_roles->remove_cap( 'administrator', 'export_give_reports' );
280
-			$wp_roles->remove_cap( 'administrator', 'manage_give_settings' );
281
-			$wp_roles->remove_cap( 'administrator', 'view_give_payments' );
277
+			$wp_roles->remove_cap('administrator', 'view_give_reports');
278
+			$wp_roles->remove_cap('administrator', 'view_give_sensitive_data');
279
+			$wp_roles->remove_cap('administrator', 'export_give_reports');
280
+			$wp_roles->remove_cap('administrator', 'manage_give_settings');
281
+			$wp_roles->remove_cap('administrator', 'view_give_payments');
282 282
 
283 283
 			// Remove the Main Post Type Capabilities.
284 284
 			$capabilities = $this->get_core_caps();
285 285
 
286
-			foreach ( $capabilities as $cap_group ) {
287
-				foreach ( $cap_group as $cap ) {
288
-					$wp_roles->remove_cap( 'give_manager', $cap );
289
-					$wp_roles->remove_cap( 'administrator', $cap );
290
-					$wp_roles->remove_cap( 'give_worker', $cap );
286
+			foreach ($capabilities as $cap_group) {
287
+				foreach ($cap_group as $cap) {
288
+					$wp_roles->remove_cap('give_manager', $cap);
289
+					$wp_roles->remove_cap('administrator', $cap);
290
+					$wp_roles->remove_cap('give_worker', $cap);
291 291
 				}
292 292
 			}
293 293
 
294 294
 			// Remove Capabilities from Give Accountant User Role.
295
-			$wp_roles->remove_cap( 'give_accountant', 'edit_give_forms' );
296
-			$wp_roles->remove_cap( 'give_accountant', 'read_private_give_forms' );
297
-			$wp_roles->remove_cap( 'give_accountant', 'view_give_reports' );
298
-			$wp_roles->remove_cap( 'give_accountant', 'export_give_reports' );
299
-			$wp_roles->remove_cap( 'give_accountant', 'edit_give_payments' );
300
-			$wp_roles->remove_cap( 'give_accountant', 'view_give_payments' );
295
+			$wp_roles->remove_cap('give_accountant', 'edit_give_forms');
296
+			$wp_roles->remove_cap('give_accountant', 'read_private_give_forms');
297
+			$wp_roles->remove_cap('give_accountant', 'view_give_reports');
298
+			$wp_roles->remove_cap('give_accountant', 'export_give_reports');
299
+			$wp_roles->remove_cap('give_accountant', 'edit_give_payments');
300
+			$wp_roles->remove_cap('give_accountant', 'view_give_payments');
301 301
 
302 302
 		}
303 303
 	}
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 		$current_user = wp_get_current_user();
318 318
 
319 319
 		// If user with "Give Accountant" user role is logged-in .
320
-		if ( 0 !== $current_user->ID && in_array( 'give_accountant', (array) $current_user->roles, true ) ) {
320
+		if (0 !== $current_user->ID && in_array('give_accountant', (array) $current_user->roles, true)) {
321 321
 
322 322
 			// Return false, means no prevention.
323 323
 			return false;
Please login to merge, or discard this patch.