Test Failed
Pull Request — master (#1988)
by Ravinder
05:25
created
includes/formatting.php 1 patch
Spacing   +146 added lines, -149 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  * @return mixed
24 24
  */
25 25
 function give_get_price_decimals() {
26
-	return apply_filters( 'give_sanitize_amount_decimals', give_get_option( 'number_decimals', 0 ) );
26
+	return apply_filters('give_sanitize_amount_decimals', give_get_option('number_decimals', 0));
27 27
 }
28 28
 
29 29
 /**
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
  */
36 36
 function give_get_price_thousand_separator() {
37 37
 	$give_options       = give_get_settings();
38
-	$thousand_separator = isset( $give_options['thousands_separator'] ) ? $give_options['thousands_separator'] : ',';
39
-	$thousand_separator = empty( $thousand_separator ) ? ' ' : $thousand_separator;
38
+	$thousand_separator = isset($give_options['thousands_separator']) ? $give_options['thousands_separator'] : ',';
39
+	$thousand_separator = empty($thousand_separator) ? ' ' : $thousand_separator;
40 40
 
41 41
 	return $thousand_separator;
42 42
 }
@@ -55,11 +55,10 @@  discard block
 block discarded – undo
55 55
 	);
56 56
 
57 57
 	$thousand_separator = give_get_price_thousand_separator();
58
-	$default_decimal_separator = in_array( $thousand_separator, $default_decimal_separators ) ?
59
-		$default_decimal_separators[$thousand_separator] :
60
-		'.';
58
+	$default_decimal_separator = in_array($thousand_separator, $default_decimal_separators) ?
59
+		$default_decimal_separators[$thousand_separator] : '.';
61 60
 
62
-	$decimal_separator = give_get_option( 'decimal_separator', $default_decimal_separator );
61
+	$decimal_separator = give_get_option('decimal_separator', $default_decimal_separator);
63 62
 
64 63
 	return $decimal_separator;
65 64
 }
@@ -74,8 +73,8 @@  discard block
 block discarded – undo
74 73
  *
75 74
  * @return string $amount Newly sanitized amount
76 75
  */
77
-function give_sanitize_amount_for_db( $number ) {
78
-	return give_maybe_sanitize_amount( $number, 6 );
76
+function give_sanitize_amount_for_db($number) {
77
+	return give_maybe_sanitize_amount($number, 6);
79 78
 }
80 79
 
81 80
 /**
@@ -89,40 +88,40 @@  discard block
 block discarded – undo
89 88
  *
90 89
  * @return string $amount Newly sanitized amount
91 90
  */
92
-function give_maybe_sanitize_amount( $number, $dp = false, $trim_zeros = false ) {
91
+function give_maybe_sanitize_amount($number, $dp = false, $trim_zeros = false) {
93 92
 	$thousand_separator = give_get_price_thousand_separator();
94 93
 	$decimal_separator  = give_get_price_decimal_separator();
95 94
 
96 95
 	// Bailout.
97
-	if( empty( $number ) || ( ! is_numeric( $number ) && ! is_string( $number ) ) ) {
96
+	if (empty($number) || ( ! is_numeric($number) && ! is_string($number))) {
98 97
 		return $number;
99 98
 	}elseif (
100
-		( false == strpos( $number, $thousand_separator ) ) &&
101
-		( false === strpos( $number, $decimal_separator ) )
99
+		(false == strpos($number, $thousand_separator)) &&
100
+		(false === strpos($number, $decimal_separator))
102 101
 	) {
103
-		return number_format( $number, ( is_bool( $dp ) ? give_get_price_decimals() : $dp ), '.', '' );
102
+		return number_format($number, (is_bool($dp) ? give_get_price_decimals() : $dp), '.', '');
104 103
 	}
105 104
 
106 105
 	// Handle thousand separator as '.'
107 106
 	// Handle sanitize database values.
108
-	$number_parts = explode( '.', $number );
109
-	$is_db_sanitize_val = ( 2 === count( $number_parts ) && ( 6 === strlen( $number_parts[1] ) ) );
107
+	$number_parts = explode('.', $number);
108
+	$is_db_sanitize_val = (2 === count($number_parts) && (6 === strlen($number_parts[1])));
110 109
 
111
-	if( $is_db_sanitize_val ) {
110
+	if ($is_db_sanitize_val) {
112 111
 		// Sanitize database value.
113
-		return number_format( $number, ( is_bool( $dp ) ? give_get_price_decimals() : $dp ), '.', '' );
112
+		return number_format($number, (is_bool($dp) ? give_get_price_decimals() : $dp), '.', '');
114 113
 
115 114
 	} elseif (
116 115
 		'.' === $thousand_separator &&
117
-		false !== strpos( $number, $thousand_separator )
118
-	){
116
+		false !== strpos($number, $thousand_separator)
117
+	) {
119 118
 		// Fix point thousand separator value.
120
-		if( ! $is_db_sanitize_val ) {
121
-			$number = str_replace( '.', '', $number );
119
+		if ( ! $is_db_sanitize_val) {
120
+			$number = str_replace('.', '', $number);
122 121
 		}
123 122
 	}
124 123
 
125
-	return give_sanitize_amount( $number, $dp, $trim_zeros );
124
+	return give_sanitize_amount($number, $dp, $trim_zeros);
126 125
 }
127 126
 
128 127
 /**
@@ -138,67 +137,67 @@  discard block
 block discarded – undo
138 137
  *
139 138
  * @return string $amount Newly sanitized amount
140 139
  */
141
-function give_sanitize_amount( $number, $dp = false, $trim_zeros = false ) {
140
+function give_sanitize_amount($number, $dp = false, $trim_zeros = false) {
142 141
 
143 142
 	// Bailout.
144
-	if ( empty( $number ) || ( ! is_numeric( $number ) && ! is_string( $number ) ) ) {
143
+	if (empty($number) || ( ! is_numeric($number) && ! is_string($number))) {
145 144
 		return $number;
146 145
 	}
147 146
 
148 147
 	// Remove slash from amount.
149 148
 	// If thousand or decimal separator is set to ' then in $_POST or $_GET param we will get an escaped number.
150 149
 	// To prevent notices and warning remove slash from amount/number.
151
-	$number = wp_unslash( $number );
150
+	$number = wp_unslash($number);
152 151
 
153 152
 	$thousand_separator = give_get_price_thousand_separator();
154 153
 
155 154
 	$locale   = localeconv();
156
-	$decimals = array( give_get_price_decimal_separator(), $locale['decimal_point'], $locale['mon_decimal_point'] );
155
+	$decimals = array(give_get_price_decimal_separator(), $locale['decimal_point'], $locale['mon_decimal_point']);
157 156
 
158 157
 	// Remove locale from string
159
-	if ( ! is_float( $number ) ) {
160
-		$number = str_replace( $decimals, '.', $number );
158
+	if ( ! is_float($number)) {
159
+		$number = str_replace($decimals, '.', $number);
161 160
 	}
162 161
 
163 162
 	// Remove thousand amount formatting if amount has.
164 163
 	// This condition use to add backward compatibility to version before 1.6, because before version 1.6 we were saving formatted amount to db.
165 164
 	// Do not replace thousand separator from price if it is same as decimal separator, because it will be already replace by above code.
166
-	if ( ! in_array( $thousand_separator, $decimals ) && ( false !== strpos( $number, $thousand_separator ) ) ) {
167
-		$number = str_replace( $thousand_separator, '', $number );
168
-	} elseif ( in_array( $thousand_separator, $decimals ) ) {
169
-		$number = preg_replace( '/\.(?=.*\.)/', '', $number );
165
+	if ( ! in_array($thousand_separator, $decimals) && (false !== strpos($number, $thousand_separator))) {
166
+		$number = str_replace($thousand_separator, '', $number);
167
+	} elseif (in_array($thousand_separator, $decimals)) {
168
+		$number = preg_replace('/\.(?=.*\.)/', '', $number);
170 169
 	}
171 170
 
172 171
 	// Remove non numeric entity before decimal separator.
173
-	$number     = preg_replace( '/[^0-9\.]/', '', $number );
172
+	$number     = preg_replace('/[^0-9\.]/', '', $number);
174 173
 	$default_dp = give_get_price_decimals();
175 174
 
176 175
 	// Reset negative amount to zero.
177
-	if ( 0 > $number ) {
178
-		$number = number_format( 0, $default_dp, '.' );
176
+	if (0 > $number) {
177
+		$number = number_format(0, $default_dp, '.');
179 178
 	}
180 179
 
181 180
 	// If number does not have decimal then add number of decimals to it.
182 181
 	if (
183
-		false === strpos( $number, '.' )
184
-		|| ( $default_dp > strlen( substr( $number, strpos( $number, '.' ) + 1 ) ) )
182
+		false === strpos($number, '.')
183
+		|| ($default_dp > strlen(substr($number, strpos($number, '.') + 1)))
185 184
 	) {
186
-		$number = number_format( $number, $default_dp, '.', '' );
185
+		$number = number_format($number, $default_dp, '.', '');
187 186
 	}
188 187
 
189 188
 	// Format number by custom number of decimals.
190
-	if ( false !== $dp ) {
191
-		$dp     = intval( is_bool( $dp ) ? $default_dp : $dp );
192
-		$dp     = apply_filters( 'give_sanitize_amount_decimals', $dp, $number );
193
-		$number = number_format( floatval( $number ), $dp, '.', '' );
189
+	if (false !== $dp) {
190
+		$dp     = intval(is_bool($dp) ? $default_dp : $dp);
191
+		$dp     = apply_filters('give_sanitize_amount_decimals', $dp, $number);
192
+		$number = number_format(floatval($number), $dp, '.', '');
194 193
 	}
195 194
 
196 195
 	// Trim zeros.
197
-	if ( $trim_zeros && strstr( $number, '.' ) ) {
198
-		$number = rtrim( rtrim( $number, '0' ), '.' );
196
+	if ($trim_zeros && strstr($number, '.')) {
197
+		$number = rtrim(rtrim($number, '0'), '.');
199 198
 	}
200 199
 
201
-	return apply_filters( 'give_sanitize_amount', $number );
200
+	return apply_filters('give_sanitize_amount', $number);
202 201
 }
203 202
 
204 203
 /**
@@ -211,10 +210,10 @@  discard block
 block discarded – undo
211 210
  *
212 211
  * @return string $amount   Newly formatted amount or Price Not Available
213 212
  */
214
-function give_format_amount( $amount, $args = array() ) {
213
+function give_format_amount($amount, $args = array()) {
215 214
 	// Backward compatibility.
216
-	if( is_bool( $args ) ) {
217
-		$args = array( 'decimal' => $args );
215
+	if (is_bool($args)) {
216
+		$args = array('decimal' => $args);
218 217
 	}
219 218
 
220 219
 	$default_args = array(
@@ -223,60 +222,59 @@  discard block
 block discarded – undo
223 222
 		'currency' => give_get_currency(),
224 223
 	);
225 224
 
226
-	$args = wp_parse_args( $args, $default_args );
225
+	$args = wp_parse_args($args, $default_args);
227 226
 
228 227
 	$formatted     = 0;
229 228
 	$thousands_sep = give_get_price_thousand_separator();
230 229
 	$decimal_sep   = give_get_price_decimal_separator();
231
-	$decimals      = ! empty( $args['decimal'] ) ? give_get_price_decimals() : 0;
230
+	$decimals      = ! empty($args['decimal']) ? give_get_price_decimals() : 0;
232 231
 	$currency      = $args['currency'];
233 232
 
234
-	if ( ! empty( $amount ) ) {
233
+	if ( ! empty($amount)) {
235 234
 		// Sanitize amount before formatting.
236
-		$amount = ! empty( $args['sanitize'] ) ?
237
-			give_maybe_sanitize_amount( $amount, $decimals ) :
238
-			number_format( $amount, $decimals, '.', '' );
235
+		$amount = ! empty($args['sanitize']) ?
236
+			give_maybe_sanitize_amount($amount, $decimals) : number_format($amount, $decimals, '.', '');
239 237
 
240
-		switch ( $currency ) {
238
+		switch ($currency) {
241 239
 			case 'INR':
242 240
 				$decimal_amount = '';
243 241
 
244 242
 				// Extract decimals from amount
245
-				if ( ( $pos = strpos( $amount, '.' ) ) !== false ) {
246
-					if ( ! empty( $decimals ) ) {
247
-						$decimal_amount = substr( round( substr( $amount, $pos ), $decimals ), 1 );
248
-						$amount         = substr( $amount, 0, $pos );
249
-
250
-						if ( ! $decimal_amount ) {
251
-							$decimal_amount = substr( '.0000000000', 0, ( $decimals + 1 ) );
252
-						} elseif ( ( $decimals + 1 ) > strlen( $decimal_amount ) ) {
253
-							$decimal_amount = substr( "{$decimal_amount}000000000", 0, ( $decimals + 1 ) );
243
+				if (($pos = strpos($amount, '.')) !== false) {
244
+					if ( ! empty($decimals)) {
245
+						$decimal_amount = substr(round(substr($amount, $pos), $decimals), 1);
246
+						$amount         = substr($amount, 0, $pos);
247
+
248
+						if ( ! $decimal_amount) {
249
+							$decimal_amount = substr('.0000000000', 0, ($decimals + 1));
250
+						} elseif (($decimals + 1) > strlen($decimal_amount)) {
251
+							$decimal_amount = substr("{$decimal_amount}000000000", 0, ($decimals + 1));
254 252
 						}
255 253
 
256 254
 					} else {
257
-						$amount = number_format( $amount, $decimals, $decimal_sep, '' );
255
+						$amount = number_format($amount, $decimals, $decimal_sep, '');
258 256
 					}
259 257
 				}
260 258
 
261 259
 				// Extract last 3 from amount
262
-				$result = substr( $amount, - 3 );
263
-				$amount = substr( $amount, 0, - 3 );
260
+				$result = substr($amount, - 3);
261
+				$amount = substr($amount, 0, - 3);
264 262
 
265 263
 				// Apply digits 2 by 2
266
-				while ( strlen( $amount ) > 0 ) {
267
-					$result = substr( $amount, - 2 ) . $thousands_sep . $result;
268
-					$amount = substr( $amount, 0, - 2 );
264
+				while (strlen($amount) > 0) {
265
+					$result = substr($amount, - 2).$thousands_sep.$result;
266
+					$amount = substr($amount, 0, - 2);
269 267
 				}
270 268
 
271
-				$formatted = $result . $decimal_amount;
269
+				$formatted = $result.$decimal_amount;
272 270
 				break;
273 271
 
274 272
 			default:
275
-				$formatted = number_format( $amount, $decimals, $decimal_sep, $thousands_sep );
273
+				$formatted = number_format($amount, $decimals, $decimal_sep, $thousands_sep);
276 274
 		}
277 275
 	}
278 276
 
279
-	return apply_filters( 'give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $currency, $args );
277
+	return apply_filters('give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $currency, $args);
280 278
 }
281 279
 
282 280
 
@@ -294,51 +292,51 @@  discard block
 block discarded – undo
294 292
  *
295 293
  * @return float|string  formatted amount number with large number names.
296 294
  */
297
-function give_human_format_large_amount( $amount, $args = array() ) {
295
+function give_human_format_large_amount($amount, $args = array()) {
298 296
 	$default_args = array(
299 297
 		'currency' => give_get_currency(),
300 298
 	);
301 299
 
302
-	$args = wp_parse_args( $args, $default_args );
300
+	$args = wp_parse_args($args, $default_args);
303 301
 
304 302
 	// Get thousand separator.
305 303
 	$thousands_sep = give_get_price_thousand_separator();
306 304
 
307 305
 	// Sanitize amount.
308
-	$sanitize_amount = give_maybe_sanitize_amount( $amount );
306
+	$sanitize_amount = give_maybe_sanitize_amount($amount);
309 307
 
310 308
 	// Explode amount to calculate name of large numbers.
311
-	$amount_array = explode( $thousands_sep, $amount );
309
+	$amount_array = explode($thousands_sep, $amount);
312 310
 
313 311
 	// Calculate amount parts count.
314
-	$amount_count_parts = count( $amount_array );
312
+	$amount_count_parts = count($amount_array);
315 313
 
316 314
 	// Human format amount (default).
317 315
 	$human_format_amount = $amount;
318 316
 
319
-	switch ( $args['currency'] ) {
317
+	switch ($args['currency']) {
320 318
 		case 'INR':
321 319
 			// Calculate large number formatted amount.
322
-			if ( 4 < $amount_count_parts ) {
323
-				$human_format_amount = sprintf( esc_html__( '%s arab', 'give' ), round( ( $sanitize_amount / 1000000000 ), 2 ) );
324
-			} elseif ( 3 < $amount_count_parts ) {
325
-				$human_format_amount = sprintf( esc_html__( '%s crore', 'give' ), round( ( $sanitize_amount / 10000000 ), 2 ) );
326
-			} elseif ( 2 < $amount_count_parts ) {
327
-				$human_format_amount = sprintf( esc_html__( '%s lakh', 'give' ), round( ( $sanitize_amount / 100000 ), 2 ) );
320
+			if (4 < $amount_count_parts) {
321
+				$human_format_amount = sprintf(esc_html__('%s arab', 'give'), round(($sanitize_amount / 1000000000), 2));
322
+			} elseif (3 < $amount_count_parts) {
323
+				$human_format_amount = sprintf(esc_html__('%s crore', 'give'), round(($sanitize_amount / 10000000), 2));
324
+			} elseif (2 < $amount_count_parts) {
325
+				$human_format_amount = sprintf(esc_html__('%s lakh', 'give'), round(($sanitize_amount / 100000), 2));
328 326
 			}
329 327
 			break;
330 328
 		default:
331 329
 			// Calculate large number formatted amount.
332
-			if ( 4 < $amount_count_parts ) {
333
-				$human_format_amount = sprintf( esc_html__( '%s trillion', 'give' ), round( ( $sanitize_amount / 1000000000000 ), 2 ) );
334
-			} elseif ( 3 < $amount_count_parts ) {
335
-				$human_format_amount = sprintf( esc_html__( '%s billion', 'give' ), round( ( $sanitize_amount / 1000000000 ), 2 ) );
336
-			} elseif ( 2 < $amount_count_parts ) {
337
-				$human_format_amount = sprintf( esc_html__( '%s million', 'give' ), round( ( $sanitize_amount / 1000000 ), 2 ) );
330
+			if (4 < $amount_count_parts) {
331
+				$human_format_amount = sprintf(esc_html__('%s trillion', 'give'), round(($sanitize_amount / 1000000000000), 2));
332
+			} elseif (3 < $amount_count_parts) {
333
+				$human_format_amount = sprintf(esc_html__('%s billion', 'give'), round(($sanitize_amount / 1000000000), 2));
334
+			} elseif (2 < $amount_count_parts) {
335
+				$human_format_amount = sprintf(esc_html__('%s million', 'give'), round(($sanitize_amount / 1000000), 2));
338 336
 			}
339 337
 	}
340 338
 
341
-	return apply_filters( 'give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount );
339
+	return apply_filters('give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount);
342 340
 }
343 341
 
344 342
 /**
@@ -352,17 +350,16 @@  discard block
 block discarded – undo
352 350
  *
353 351
  * @return string $amount Newly formatted amount or Price Not Available
354 352
  */
355
-function give_format_decimal( $amount, $dp = false, $sanitize = true ) {
353
+function give_format_decimal($amount, $dp = false, $sanitize = true) {
356 354
 	$decimal_separator = give_get_price_decimal_separator();
357 355
 	$formatted_amount  = $sanitize ?
358
-		give_maybe_sanitize_amount( $amount, $dp ) :
359
-		number_format( $amount, ( is_bool( $dp ) ? give_get_price_decimals() : $dp ), '.', '' );
356
+		give_maybe_sanitize_amount($amount, $dp) : number_format($amount, (is_bool($dp) ? give_get_price_decimals() : $dp), '.', '');
360 357
 
361
-	if ( false !== strpos( $formatted_amount, '.' ) ) {
362
-		$formatted_amount = str_replace( '.', $decimal_separator, $formatted_amount );
358
+	if (false !== strpos($formatted_amount, '.')) {
359
+		$formatted_amount = str_replace('.', $decimal_separator, $formatted_amount);
363 360
 	}
364 361
 
365
-	return apply_filters( 'give_format_decimal', $formatted_amount, $amount, $decimal_separator );
362
+	return apply_filters('give_format_decimal', $formatted_amount, $amount, $decimal_separator);
366 363
 }
367 364
 
368 365
 /**
@@ -376,24 +373,24 @@  discard block
 block discarded – undo
376 373
  *
377 374
  * @return mixed|string
378 375
  */
379
-function give_currency_filter( $price = '', $currency = '', $decode_currency = false ) {
376
+function give_currency_filter($price = '', $currency = '', $decode_currency = false) {
380 377
 
381
-	if ( empty( $currency ) || ! array_key_exists( (string) $currency, give_get_currencies() ) ) {
378
+	if (empty($currency) || ! array_key_exists((string) $currency, give_get_currencies())) {
382 379
 		$currency = give_get_currency();
383 380
 	}
384 381
 
385
-	$position = give_get_option( 'currency_position', 'before' );
382
+	$position = give_get_option('currency_position', 'before');
386 383
 
387 384
 	$negative = $price < 0;
388 385
 
389
-	if ( $negative ) {
386
+	if ($negative) {
390 387
 		// Remove proceeding "-".
391
-		$price = substr( $price, 1 );
388
+		$price = substr($price, 1);
392 389
 	}
393 390
 
394
-	$symbol = give_currency_symbol( $currency, $decode_currency );
391
+	$symbol = give_currency_symbol($currency, $decode_currency);
395 392
 
396
-	switch ( $currency ) :
393
+	switch ($currency) :
397 394
 		case 'GBP' :
398 395
 		case 'BRL' :
399 396
 		case 'EUR' :
@@ -422,13 +419,13 @@  discard block
 block discarded – undo
422 419
 		case 'MAD' :
423 420
 		case 'KRW' :
424 421
 		case 'ZAR' :
425
-			$formatted = ( 'before' === $position ? $symbol . $price : $price . $symbol );
422
+			$formatted = ('before' === $position ? $symbol.$price : $price.$symbol);
426 423
 			break;
427 424
 		case 'NOK' :
428
-			$formatted = ( 'before' === $position ? $symbol . ' ' . $price : $price . ' ' . $symbol );
425
+			$formatted = ('before' === $position ? $symbol.' '.$price : $price.' '.$symbol);
429 426
 			break;
430 427
 		default :
431
-			$formatted = ( 'before' === $position ? $currency . ' ' . $price : $price . ' ' . $currency );
428
+			$formatted = ('before' === $position ? $currency.' '.$price : $price.' '.$currency);
432 429
 			break;
433 430
 	endswitch;
434 431
 
@@ -443,11 +440,11 @@  discard block
 block discarded – undo
443 440
 	 *           and if currency is USD and currency position is after then
444 441
 	 *           filter name will be give_usd_currency_filter_after
445 442
 	 */
446
-	$formatted = apply_filters( 'give_' . strtolower( $currency ) . "_currency_filter_{$position}", $formatted, $currency, $price );
443
+	$formatted = apply_filters('give_'.strtolower($currency)."_currency_filter_{$position}", $formatted, $currency, $price);
447 444
 
448
-	if ( $negative ) {
445
+	if ($negative) {
449 446
 		// Prepend the minus sign before the currency sign.
450
-		$formatted = '-' . $formatted;
447
+		$formatted = '-'.$formatted;
451 448
 	}
452 449
 
453 450
 	return $formatted;
@@ -463,21 +460,21 @@  discard block
 block discarded – undo
463 460
  */
464 461
 function give_currency_decimal_filter() {
465 462
 
466
-	remove_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' );
463
+	remove_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter');
467 464
 
468 465
 	// Set default number of decimals.
469 466
 	$decimals = give_get_price_decimals();
470 467
 
471
-	add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' );
468
+	add_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter');
472 469
 
473 470
 	// Get number of decimals with backward compatibility ( version < 1.6 )
474
-	if ( 1 <= func_num_args() ) {
475
-		$decimals = ( false === func_get_arg( 0 ) ? $decimals : absint( func_get_arg( 0 ) ) );
471
+	if (1 <= func_num_args()) {
472
+		$decimals = (false === func_get_arg(0) ? $decimals : absint(func_get_arg(0)));
476 473
 	}
477 474
 
478 475
 	$currency = give_get_currency();
479 476
 
480
-	switch ( $currency ) {
477
+	switch ($currency) {
481 478
 		case 'RIAL' :
482 479
 		case 'JPY' :
483 480
 		case 'TWD' :
@@ -487,11 +484,11 @@  discard block
 block discarded – undo
487 484
 			break;
488 485
 	}
489 486
 
490
-	return apply_filters( 'give_currency_decimal_count', $decimals, $currency );
487
+	return apply_filters('give_currency_decimal_count', $decimals, $currency);
491 488
 }
492 489
 
493
-add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' );
494
-add_filter( 'give_format_amount_decimals', 'give_currency_decimal_filter' );
490
+add_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter');
491
+add_filter('give_format_amount_decimals', 'give_currency_decimal_filter');
495 492
 
496 493
 
497 494
 /**
@@ -503,7 +500,7 @@  discard block
 block discarded – undo
503 500
  *
504 501
  * @return string                  Date format string
505 502
  */
506
-function give_date_format( $date_context = '' ) {
503
+function give_date_format($date_context = '') {
507 504
 	/**
508 505
 	 * Filter the date context
509 506
 	 *
@@ -524,19 +521,19 @@  discard block
 block discarded – undo
524 521
 	 *
525 522
 	 *    }
526 523
 	 */
527
-	$date_format_contexts = apply_filters( 'give_date_format_contexts', array() );
524
+	$date_format_contexts = apply_filters('give_date_format_contexts', array());
528 525
 
529 526
 	// Set date format to default date format.
530
-	$date_format = get_option( 'date_format' );
527
+	$date_format = get_option('date_format');
531 528
 
532 529
 	// Update date format if we have non empty date format context array and non empty date format string for that context.
533
-	if ( $date_context && ! empty( $date_format_contexts ) && array_key_exists( $date_context, $date_format_contexts ) ) {
534
-		$date_format = ! empty( $date_format_contexts[ $date_context ] )
535
-			? $date_format_contexts[ $date_context ]
530
+	if ($date_context && ! empty($date_format_contexts) && array_key_exists($date_context, $date_format_contexts)) {
531
+		$date_format = ! empty($date_format_contexts[$date_context])
532
+			? $date_format_contexts[$date_context]
536 533
 			: $date_format;
537 534
 	}
538 535
 
539
-	return apply_filters( 'give_date_format', $date_format );
536
+	return apply_filters('give_date_format', $date_format);
540 537
 }
541 538
 
542 539
 /**
@@ -550,8 +547,8 @@  discard block
 block discarded – undo
550 547
  *
551 548
  * @return string
552 549
  */
553
-function give_get_cache_key( $action, $query_args ) {
554
-	return Give_Cache::get_key( $action, $query_args );
550
+function give_get_cache_key($action, $query_args) {
551
+	return Give_Cache::get_key($action, $query_args);
555 552
 }
556 553
 
557 554
 /**
@@ -564,11 +561,11 @@  discard block
 block discarded – undo
564 561
  *
565 562
  * @return string|array
566 563
  */
567
-function give_clean( $var ) {
568
-	if ( is_array( $var ) ) {
569
-		return array_map( 'give_clean', $var );
564
+function give_clean($var) {
565
+	if (is_array($var)) {
566
+		return array_map('give_clean', $var);
570 567
 	} else {
571
-		return is_scalar( $var ) ? sanitize_text_field( $var ) : $var;
568
+		return is_scalar($var) ? sanitize_text_field($var) : $var;
572 569
 	}
573 570
 }
574 571
 
@@ -581,10 +578,10 @@  discard block
 block discarded – undo
581 578
  *
582 579
  * @return int
583 580
  */
584
-function give_let_to_num( $size ) {
585
-	$l   = substr( $size, - 1 );
586
-	$ret = substr( $size, 0, - 1 );
587
-	switch ( strtoupper( $l ) ) {
581
+function give_let_to_num($size) {
582
+	$l   = substr($size, - 1);
583
+	$ret = substr($size, 0, - 1);
584
+	switch (strtoupper($l)) {
588 585
 		case 'P':
589 586
 			$ret *= 1024;
590 587
 		case 'T':
@@ -609,19 +606,19 @@  discard block
 block discarded – undo
609 606
  * @param int   $action
610 607
  * @param array $wp_die_args
611 608
  */
612
-function give_validate_nonce( $nonce, $action = - 1, $wp_die_args = array() ) {
609
+function give_validate_nonce($nonce, $action = - 1, $wp_die_args = array()) {
613 610
 
614 611
 	$default_wp_die_args = array(
615
-		'message' => esc_html__( 'Nonce verification has failed.', 'give' ),
616
-		'title'   => esc_html__( 'Error', 'give' ),
612
+		'message' => esc_html__('Nonce verification has failed.', 'give'),
613
+		'title'   => esc_html__('Error', 'give'),
617 614
 		'args'    => array(
618 615
 			'response' => 403,
619 616
 		),
620 617
 	);
621 618
 
622
-	$wp_die_args = wp_parse_args( $wp_die_args, $default_wp_die_args );
619
+	$wp_die_args = wp_parse_args($wp_die_args, $default_wp_die_args);
623 620
 
624
-	if ( ! wp_verify_nonce( $nonce, $action ) ) {
621
+	if ( ! wp_verify_nonce($nonce, $action)) {
625 622
 		wp_die(
626 623
 			$wp_die_args['message'],
627 624
 			$wp_die_args['title'],
@@ -643,23 +640,23 @@  discard block
 block discarded – undo
643 640
  *
644 641
  * @return mixed
645 642
  */
646
-function give_check_variable( $variable, $conditional = '', $default = false ) {
643
+function give_check_variable($variable, $conditional = '', $default = false) {
647 644
 
648
-	switch ( $conditional ) {
645
+	switch ($conditional) {
649 646
 		case 'isset_empty':
650
-			$variable = ( isset( $variable ) && ! empty( $variable ) ) ? $variable : $default;
647
+			$variable = (isset($variable) && ! empty($variable)) ? $variable : $default;
651 648
 			break;
652 649
 
653 650
 		case 'empty':
654
-			$variable = ! empty( $variable ) ? $variable : $default;
651
+			$variable = ! empty($variable) ? $variable : $default;
655 652
 			break;
656 653
 
657 654
 		case 'null':
658
-			$variable = ! is_null( $variable ) ? $variable : $default;
655
+			$variable = ! is_null($variable) ? $variable : $default;
659 656
 			break;
660 657
 
661 658
 		default:
662
-			$variable = isset( $variable ) ? $variable : $default;
659
+			$variable = isset($variable) ? $variable : $default;
663 660
 
664 661
 	}
665 662
 
Please login to merge, or discard this patch.
includes/post-types.php 1 patch
Spacing   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -23,36 +23,36 @@  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
-	$give_forms_slug = defined( 'GIVE_SLUG' ) ? GIVE_SLUG : 'donations';
29
+	$give_forms_slug = defined('GIVE_SLUG') ? GIVE_SLUG : 'donations';
30 30
 	// Support for old 'GIVE_FORMS_SLUG' constant
31
-	if ( defined( 'GIVE_FORMS_SLUG' ) ) {
31
+	if (defined('GIVE_FORMS_SLUG')) {
32 32
 		$give_forms_slug = GIVE_FORMS_SLUG;
33 33
 	}
34 34
 
35
-	$give_forms_rewrite = defined( 'GIVE_DISABLE_FORMS_REWRITE' ) && GIVE_DISABLE_FORMS_REWRITE ? false : array(
35
+	$give_forms_rewrite = defined('GIVE_DISABLE_FORMS_REWRITE') && GIVE_DISABLE_FORMS_REWRITE ? false : array(
36 36
 		'slug'       => $give_forms_slug,
37 37
 		'with_front' => false,
38 38
 	);
39 39
 
40
-	$give_forms_labels = apply_filters( 'give_forms_labels', array(
41
-		'name'               => __( 'Donation Forms', 'give' ),
42
-		'singular_name'      => __( 'Form', 'give' ),
43
-		'add_new'            => __( 'Add Form', 'give' ),
44
-		'add_new_item'       => __( 'Add New Donation Form', 'give' ),
45
-		'edit_item'          => __( 'Edit Donation Form', 'give' ),
46
-		'new_item'           => __( 'New Form', 'give' ),
47
-		'all_items'          => __( 'All Forms', 'give' ),
48
-		'view_item'          => __( 'View Form', 'give' ),
49
-		'search_items'       => __( 'Search Forms', 'give' ),
50
-		'not_found'          => __( 'No forms found.', 'give' ),
51
-		'not_found_in_trash' => __( 'No forms found in Trash.', 'give' ),
40
+	$give_forms_labels = apply_filters('give_forms_labels', array(
41
+		'name'               => __('Donation Forms', 'give'),
42
+		'singular_name'      => __('Form', 'give'),
43
+		'add_new'            => __('Add Form', 'give'),
44
+		'add_new_item'       => __('Add New Donation Form', 'give'),
45
+		'edit_item'          => __('Edit Donation Form', 'give'),
46
+		'new_item'           => __('New Form', 'give'),
47
+		'all_items'          => __('All Forms', 'give'),
48
+		'view_item'          => __('View Form', 'give'),
49
+		'search_items'       => __('Search Forms', 'give'),
50
+		'not_found'          => __('No forms found.', 'give'),
51
+		'not_found_in_trash' => __('No forms found in Trash.', 'give'),
52 52
 		'parent_item_colon'  => '',
53
-		'menu_name'          => apply_filters( 'give_menu_name', __( 'Donations', 'give' ) ),
54
-		'name_admin_bar'     => apply_filters( 'give_name_admin_bar_name', __( 'Donation Form', 'give' ) ),
55
-	) );
53
+		'menu_name'          => apply_filters('give_menu_name', __('Donations', 'give')),
54
+		'name_admin_bar'     => apply_filters('give_name_admin_bar_name', __('Donation Form', 'give')),
55
+	));
56 56
 
57 57
 	// Default give_forms supports.
58 58
 	$give_form_supports = array(
@@ -64,14 +64,14 @@  discard block
 block discarded – undo
64 64
 	);
65 65
 
66 66
 	// Has the user disabled the excerpt?
67
-	if ( ! give_is_setting_enabled( give_get_option( 'forms_excerpt' ) ) ) {
68
-		unset( $give_form_supports[2] );
67
+	if ( ! give_is_setting_enabled(give_get_option('forms_excerpt'))) {
68
+		unset($give_form_supports[2]);
69 69
 	}
70 70
 
71 71
 	// Has user disabled the featured image?
72
-	if ( ! give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) {
73
-		unset( $give_form_supports[1] );
74
-		remove_action( 'give_before_single_form_summary', 'give_show_form_images' );
72
+	if ( ! give_is_setting_enabled(give_get_option('form_featured_img'))) {
73
+		unset($give_form_supports[1]);
74
+		remove_action('give_before_single_form_summary', 'give_show_form_images');
75 75
 	}
76 76
 
77 77
 	$give_forms_args = array(
@@ -86,42 +86,42 @@  discard block
 block discarded – undo
86 86
 		'has_archive'        => $give_forms_archives,
87 87
 		'menu_icon'          => 'dashicons-give',
88 88
 		'hierarchical'       => false,
89
-		'supports'           => apply_filters( 'give_forms_supports', $give_form_supports ),
89
+		'supports'           => apply_filters('give_forms_supports', $give_form_supports),
90 90
 	);
91
-	register_post_type( 'give_forms', apply_filters( 'give_forms_post_type_args', $give_forms_args ) );
91
+	register_post_type('give_forms', apply_filters('give_forms_post_type_args', $give_forms_args));
92 92
 
93 93
 	/** Donation Post Type */
94 94
 	$payment_labels = array(
95
-		'name'               => _x( 'Donations', 'post type general name', 'give' ),
96
-		'singular_name'      => _x( 'Donation', 'post type singular name', 'give' ),
97
-		'add_new'            => __( 'Add New', 'give' ),
98
-		'add_new_item'       => __( 'Add New Donation', 'give' ),
99
-		'edit_item'          => __( 'Edit Donation', 'give' ),
100
-		'new_item'           => __( 'New Donation', 'give' ),
101
-		'all_items'          => __( 'All Donations', 'give' ),
102
-		'view_item'          => __( 'View Donation', 'give' ),
103
-		'search_items'       => __( 'Search Donations', 'give' ),
104
-		'not_found'          => __( 'No donations found.', 'give' ),
105
-		'not_found_in_trash' => __( 'No donations found in Trash.', 'give' ),
95
+		'name'               => _x('Donations', 'post type general name', 'give'),
96
+		'singular_name'      => _x('Donation', 'post type singular name', 'give'),
97
+		'add_new'            => __('Add New', 'give'),
98
+		'add_new_item'       => __('Add New Donation', 'give'),
99
+		'edit_item'          => __('Edit Donation', 'give'),
100
+		'new_item'           => __('New Donation', 'give'),
101
+		'all_items'          => __('All Donations', 'give'),
102
+		'view_item'          => __('View Donation', 'give'),
103
+		'search_items'       => __('Search Donations', 'give'),
104
+		'not_found'          => __('No donations found.', 'give'),
105
+		'not_found_in_trash' => __('No donations found in Trash.', 'give'),
106 106
 		'parent_item_colon'  => '',
107
-		'menu_name'          => __( 'Donations', 'give' ),
107
+		'menu_name'          => __('Donations', 'give'),
108 108
 	);
109 109
 
110 110
 	$payment_args = array(
111
-		'labels'          => apply_filters( 'give_payment_labels', $payment_labels ),
111
+		'labels'          => apply_filters('give_payment_labels', $payment_labels),
112 112
 		'public'          => false,
113 113
 		'query_var'       => false,
114 114
 		'rewrite'         => false,
115 115
 		'map_meta_cap'    => true,
116 116
 		'capability_type' => 'give_payment',
117
-		'supports'        => array( 'title' ),
117
+		'supports'        => array('title'),
118 118
 		'can_export'      => true,
119 119
 	);
120
-	register_post_type( 'give_payment', $payment_args );
120
+	register_post_type('give_payment', $payment_args);
121 121
 
122 122
 }
123 123
 
124
-add_action( 'init', 'give_setup_post_types', 1 );
124
+add_action('init', 'give_setup_post_types', 1);
125 125
 
126 126
 
127 127
 /**
@@ -134,30 +134,30 @@  discard block
 block discarded – undo
134 134
  */
135 135
 function give_setup_taxonomies() {
136 136
 
137
-	$slug = defined( 'GIVE_FORMS_SLUG' ) ? GIVE_FORMS_SLUG : 'donations';
137
+	$slug = defined('GIVE_FORMS_SLUG') ? GIVE_FORMS_SLUG : 'donations';
138 138
 
139 139
 	/** Categories */
140 140
 	$category_labels = array(
141
-		'name'              => _x( 'Form Categories', 'taxonomy general name', 'give' ),
142
-		'singular_name'     => _x( 'Category', 'taxonomy singular name', 'give' ),
143
-		'search_items'      => __( 'Search Categories', 'give' ),
144
-		'all_items'         => __( 'All Categories', 'give' ),
145
-		'parent_item'       => __( 'Parent Category', 'give' ),
146
-		'parent_item_colon' => __( 'Parent Category:', 'give' ),
147
-		'edit_item'         => __( 'Edit Category', 'give' ),
148
-		'update_item'       => __( 'Update Category', 'give' ),
149
-		'add_new_item'      => __( 'Add New Category', 'give' ),
150
-		'new_item_name'     => __( 'New Category Name', 'give' ),
151
-		'menu_name'         => __( 'Categories', 'give' ),
141
+		'name'              => _x('Form Categories', 'taxonomy general name', 'give'),
142
+		'singular_name'     => _x('Category', 'taxonomy singular name', 'give'),
143
+		'search_items'      => __('Search Categories', 'give'),
144
+		'all_items'         => __('All Categories', 'give'),
145
+		'parent_item'       => __('Parent Category', 'give'),
146
+		'parent_item_colon' => __('Parent Category:', 'give'),
147
+		'edit_item'         => __('Edit Category', 'give'),
148
+		'update_item'       => __('Update Category', 'give'),
149
+		'add_new_item'      => __('Add New Category', 'give'),
150
+		'new_item_name'     => __('New Category Name', 'give'),
151
+		'menu_name'         => __('Categories', 'give'),
152 152
 	);
153 153
 
154
-	$category_args = apply_filters( 'give_forms_category_args', array(
154
+	$category_args = apply_filters('give_forms_category_args', array(
155 155
 			'hierarchical' => true,
156
-			'labels'       => apply_filters( 'give_forms_category_labels', $category_labels ),
156
+			'labels'       => apply_filters('give_forms_category_labels', $category_labels),
157 157
 			'show_ui'      => true,
158 158
 			'query_var'    => 'give_forms_category',
159 159
 			'rewrite'      => array(
160
-				'slug'         => $slug . '/category',
160
+				'slug'         => $slug.'/category',
161 161
 				'with_front'   => false,
162 162
 				'hierarchical' => true,
163 163
 			),
@@ -171,33 +171,33 @@  discard block
 block discarded – undo
171 171
 	);
172 172
 
173 173
 	// Does the user want categories?
174
-	if ( give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ) ) {
175
-		register_taxonomy( 'give_forms_category', array( 'give_forms' ), $category_args );
176
-		register_taxonomy_for_object_type( 'give_forms_category', 'give_forms' );
174
+	if (give_is_setting_enabled(give_get_option('categories', 'disabled'))) {
175
+		register_taxonomy('give_forms_category', array('give_forms'), $category_args);
176
+		register_taxonomy_for_object_type('give_forms_category', 'give_forms');
177 177
 	}
178 178
 
179 179
 	/** Tags */
180 180
 	$tag_labels = array(
181
-		'name'                  => _x( 'Form Tags', 'taxonomy general name', 'give' ),
182
-		'singular_name'         => _x( 'Tag', 'taxonomy singular name', 'give' ),
183
-		'search_items'          => __( 'Search Tags', 'give' ),
184
-		'all_items'             => __( 'All Tags', 'give' ),
185
-		'parent_item'           => __( 'Parent Tag', 'give' ),
186
-		'parent_item_colon'     => __( 'Parent Tag:', 'give' ),
187
-		'edit_item'             => __( 'Edit Tag', 'give' ),
188
-		'update_item'           => __( 'Update Tag', 'give' ),
189
-		'add_new_item'          => __( 'Add New Tag', 'give' ),
190
-		'new_item_name'         => __( 'New Tag Name', 'give' ),
191
-		'menu_name'             => __( 'Tags', 'give' ),
192
-		'choose_from_most_used' => __( 'Choose from most used tags.', 'give' ),
181
+		'name'                  => _x('Form Tags', 'taxonomy general name', 'give'),
182
+		'singular_name'         => _x('Tag', 'taxonomy singular name', 'give'),
183
+		'search_items'          => __('Search Tags', 'give'),
184
+		'all_items'             => __('All Tags', 'give'),
185
+		'parent_item'           => __('Parent Tag', 'give'),
186
+		'parent_item_colon'     => __('Parent Tag:', 'give'),
187
+		'edit_item'             => __('Edit Tag', 'give'),
188
+		'update_item'           => __('Update Tag', 'give'),
189
+		'add_new_item'          => __('Add New Tag', 'give'),
190
+		'new_item_name'         => __('New Tag Name', 'give'),
191
+		'menu_name'             => __('Tags', 'give'),
192
+		'choose_from_most_used' => __('Choose from most used tags.', 'give'),
193 193
 	);
194 194
 
195
-	$tag_args = apply_filters( 'give_forms_tag_args', array(
195
+	$tag_args = apply_filters('give_forms_tag_args', array(
196 196
 			'hierarchical' => false,
197
-			'labels'       => apply_filters( 'give_forms_tag_labels', $tag_labels ),
197
+			'labels'       => apply_filters('give_forms_tag_labels', $tag_labels),
198 198
 			'show_ui'      => true,
199 199
 			'query_var'    => 'give_forms_tag',
200
-			'rewrite'      => array( 'slug' => $slug . '/tag', 'with_front' => false, 'hierarchical' => true ),
200
+			'rewrite'      => array('slug' => $slug.'/tag', 'with_front' => false, 'hierarchical' => true),
201 201
 			'capabilities' => array(
202 202
 				'manage_terms' => 'manage_give_form_terms',
203 203
 				'edit_terms'   => 'edit_give_form_terms',
@@ -207,14 +207,14 @@  discard block
 block discarded – undo
207 207
 		)
208 208
 	);
209 209
 
210
-	if ( give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) ) ) {
211
-		register_taxonomy( 'give_forms_tag', array( 'give_forms' ), $tag_args );
212
-		register_taxonomy_for_object_type( 'give_forms_tag', 'give_forms' );
210
+	if (give_is_setting_enabled(give_get_option('tags', 'disabled'))) {
211
+		register_taxonomy('give_forms_tag', array('give_forms'), $tag_args);
212
+		register_taxonomy_for_object_type('give_forms_tag', 'give_forms');
213 213
 	}
214 214
 
215 215
 }
216 216
 
217
-add_action( 'init', 'give_setup_taxonomies', 0 );
217
+add_action('init', 'give_setup_taxonomies', 0);
218 218
 
219 219
 
220 220
 /**
@@ -225,11 +225,11 @@  discard block
 block discarded – undo
225 225
  */
226 226
 function give_get_default_form_labels() {
227 227
 	$defaults = array(
228
-		'singular' => __( 'Form', 'give' ),
229
-		'plural'   => __( 'Forms', 'give' ),
228
+		'singular' => __('Form', 'give'),
229
+		'plural'   => __('Forms', 'give'),
230 230
 	);
231 231
 
232
-	return apply_filters( 'give_default_form_name', $defaults );
232
+	return apply_filters('give_default_form_name', $defaults);
233 233
 }
234 234
 
235 235
 /**
@@ -241,10 +241,10 @@  discard block
 block discarded – undo
241 241
  *
242 242
  * @return string $defaults['singular'] Singular label
243 243
  */
244
-function give_get_forms_label_singular( $lowercase = false ) {
244
+function give_get_forms_label_singular($lowercase = false) {
245 245
 	$defaults = give_get_default_form_labels();
246 246
 
247
-	return ( $lowercase ) ? strtolower( $defaults['singular'] ) : $defaults['singular'];
247
+	return ($lowercase) ? strtolower($defaults['singular']) : $defaults['singular'];
248 248
 }
249 249
 
250 250
 /**
@@ -253,10 +253,10 @@  discard block
 block discarded – undo
253 253
  * @since 1.0
254 254
  * @return string $defaults['plural'] Plural label
255 255
  */
256
-function give_get_forms_label_plural( $lowercase = false ) {
256
+function give_get_forms_label_plural($lowercase = false) {
257 257
 	$defaults = give_get_default_form_labels();
258 258
 
259
-	return ( $lowercase ) ? strtolower( $defaults['plural'] ) : $defaults['plural'];
259
+	return ($lowercase) ? strtolower($defaults['plural']) : $defaults['plural'];
260 260
 }
261 261
 
262 262
 /**
@@ -268,24 +268,24 @@  discard block
 block discarded – undo
268 268
  *
269 269
  * @return string $title New placeholder text
270 270
  */
271
-function give_change_default_title( $title ) {
271
+function give_change_default_title($title) {
272 272
 	// If a frontend plugin uses this filter (check extensions before changing this function)
273
-	if ( ! is_admin() ) {
274
-		$title = __( 'Enter form title here', 'give' );
273
+	if ( ! is_admin()) {
274
+		$title = __('Enter form title here', 'give');
275 275
 
276 276
 		return $title;
277 277
 	}
278 278
 
279 279
 	$screen = get_current_screen();
280 280
 
281
-	if ( 'give_forms' == $screen->post_type ) {
282
-		$title = __( 'Enter form title here', 'give' );
281
+	if ('give_forms' == $screen->post_type) {
282
+		$title = __('Enter form title here', 'give');
283 283
 	}
284 284
 
285 285
 	return $title;
286 286
 }
287 287
 
288
-add_filter( 'enter_title_here', 'give_change_default_title' );
288
+add_filter('enter_title_here', 'give_change_default_title');
289 289
 
290 290
 /**
291 291
  * Registers Custom Post Statuses which are used by the Payments
@@ -295,67 +295,67 @@  discard block
 block discarded – undo
295 295
  */
296 296
 function give_register_post_type_statuses() {
297 297
 	// Payment Statuses
298
-	register_post_status( 'refunded', array(
299
-		'label'                     => __( 'Refunded', 'give' ),
298
+	register_post_status('refunded', array(
299
+		'label'                     => __('Refunded', 'give'),
300 300
 		'public'                    => true,
301 301
 		'exclude_from_search'       => false,
302 302
 		'show_in_admin_all_list'    => true,
303 303
 		'show_in_admin_status_list' => true,
304
-		'label_count'               => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give' ),
305
-	) );
306
-	register_post_status( 'failed', array(
307
-		'label'                     => __( 'Failed', 'give' ),
304
+		'label_count'               => _n_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give'),
305
+	));
306
+	register_post_status('failed', array(
307
+		'label'                     => __('Failed', 'give'),
308 308
 		'public'                    => true,
309 309
 		'exclude_from_search'       => false,
310 310
 		'show_in_admin_all_list'    => true,
311 311
 		'show_in_admin_status_list' => true,
312
-		'label_count'               => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give' ),
313
-	) );
314
-	register_post_status( 'revoked', array(
315
-		'label'                     => __( 'Revoked', 'give' ),
312
+		'label_count'               => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give'),
313
+	));
314
+	register_post_status('revoked', array(
315
+		'label'                     => __('Revoked', 'give'),
316 316
 		'public'                    => true,
317 317
 		'exclude_from_search'       => false,
318 318
 		'show_in_admin_all_list'    => true,
319 319
 		'show_in_admin_status_list' => true,
320
-		'label_count'               => _n_noop( 'Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give' ),
321
-	) );
322
-	register_post_status( 'cancelled', array(
323
-		'label'                     => __( 'Cancelled', 'give' ),
320
+		'label_count'               => _n_noop('Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give'),
321
+	));
322
+	register_post_status('cancelled', array(
323
+		'label'                     => __('Cancelled', 'give'),
324 324
 		'public'                    => true,
325 325
 		'exclude_from_search'       => false,
326 326
 		'show_in_admin_all_list'    => true,
327 327
 		'show_in_admin_status_list' => true,
328
-		'label_count'               => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'give' ),
329
-	) );
330
-	register_post_status( 'abandoned', array(
331
-		'label'                     => __( 'Abandoned', 'give' ),
328
+		'label_count'               => _n_noop('Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'give'),
329
+	));
330
+	register_post_status('abandoned', array(
331
+		'label'                     => __('Abandoned', 'give'),
332 332
 		'public'                    => true,
333 333
 		'exclude_from_search'       => false,
334 334
 		'show_in_admin_all_list'    => true,
335 335
 		'show_in_admin_status_list' => true,
336
-		'label_count'               => _n_noop( 'Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give' ),
337
-	) );
338
-	register_post_status( 'processing', array(
339
-		'label'                     => _x( 'Processing', 'Processing payment status', 'give' ),
336
+		'label_count'               => _n_noop('Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give'),
337
+	));
338
+	register_post_status('processing', array(
339
+		'label'                     => _x('Processing', 'Processing payment status', 'give'),
340 340
 		'public'                    => true,
341 341
 		'exclude_from_search'       => false,
342 342
 		'show_in_admin_all_list'    => true,
343 343
 		'show_in_admin_status_list' => true,
344
-		'label_count'               => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'give' )
345
-	)  );
344
+		'label_count'               => _n_noop('Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'give')
345
+	));
346 346
 
347
-	register_post_status( 'preapproval', array(
348
-		'label'                     => _x( 'Preapproval', 'Preapproval payment status', 'give' ),
347
+	register_post_status('preapproval', array(
348
+		'label'                     => _x('Preapproval', 'Preapproval payment status', 'give'),
349 349
 		'public'                    => true,
350 350
 		'exclude_from_search'       => false,
351 351
 		'show_in_admin_all_list'    => true,
352 352
 		'show_in_admin_status_list' => true,
353
-		'label_count'               => _n_noop( 'Preapproval <span class="count">(%s)</span>', 'Preapproval <span class="count">(%s)</span>', 'give' ),
354
-	) );
353
+		'label_count'               => _n_noop('Preapproval <span class="count">(%s)</span>', 'Preapproval <span class="count">(%s)</span>', 'give'),
354
+	));
355 355
 
356 356
 }
357 357
 
358
-add_action( 'init', 'give_register_post_type_statuses' );
358
+add_action('init', 'give_register_post_type_statuses');
359 359
 
360 360
 /**
361 361
  * Updated Messages
@@ -368,27 +368,27 @@  discard block
 block discarded – undo
368 368
  *
369 369
  * @return array $messages New post updated messages
370 370
  */
371
-function give_updated_messages( $messages ) {
371
+function give_updated_messages($messages) {
372 372
 	global $post, $post_ID;
373 373
 
374
-	if ( ! give_is_setting_enabled( give_get_option( 'forms_singular' ) ) ) {
374
+	if ( ! give_is_setting_enabled(give_get_option('forms_singular'))) {
375 375
 
376 376
 		$messages['give_forms'] = array(
377
-			1 => __( 'Form updated.', 'give' ),
378
-			4 => __( 'Form updated.', 'give' ),
379
-			6 => __( 'Form published.', 'give' ),
380
-			7 => __( 'Form saved.', 'give' ),
381
-			8 => __( 'Form submitted.', 'give' ),
377
+			1 => __('Form updated.', 'give'),
378
+			4 => __('Form updated.', 'give'),
379
+			6 => __('Form published.', 'give'),
380
+			7 => __('Form saved.', 'give'),
381
+			8 => __('Form submitted.', 'give'),
382 382
 		);
383 383
 
384 384
 	} else {
385 385
 
386 386
 		$messages['give_forms'] = array(
387
-			1 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form updated.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ),
388
-			4 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form updated.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ),
389
-			6 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form published.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ),
390
-			7 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form saved.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ),
391
-			8 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form submitted.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ),
387
+			1 => sprintf('%1$s <a href="%2$s">%3$s</a>', __('Form updated.', 'give'), get_permalink($post_ID), __('View Form', 'give')),
388
+			4 => sprintf('%1$s <a href="%2$s">%3$s</a>', __('Form updated.', 'give'), get_permalink($post_ID), __('View Form', 'give')),
389
+			6 => sprintf('%1$s <a href="%2$s">%3$s</a>', __('Form published.', 'give'), get_permalink($post_ID), __('View Form', 'give')),
390
+			7 => sprintf('%1$s <a href="%2$s">%3$s</a>', __('Form saved.', 'give'), get_permalink($post_ID), __('View Form', 'give')),
391
+			8 => sprintf('%1$s <a href="%2$s">%3$s</a>', __('Form submitted.', 'give'), get_permalink($post_ID), __('View Form', 'give')),
392 392
 		);
393 393
 
394 394
 	}
@@ -396,24 +396,24 @@  discard block
 block discarded – undo
396 396
 	return $messages;
397 397
 }
398 398
 
399
-add_filter( 'post_updated_messages', 'give_updated_messages' );
399
+add_filter('post_updated_messages', 'give_updated_messages');
400 400
 
401 401
 /**
402 402
  * Ensure post thumbnail support is turned on
403 403
  */
404 404
 function give_add_thumbnail_support() {
405
-	if ( ! give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) {
405
+	if ( ! give_is_setting_enabled(give_get_option('form_featured_img'))) {
406 406
 		return;
407 407
 	}
408 408
 
409
-	if ( ! current_theme_supports( 'post-thumbnails' ) ) {
410
-		add_theme_support( 'post-thumbnails' );
409
+	if ( ! current_theme_supports('post-thumbnails')) {
410
+		add_theme_support('post-thumbnails');
411 411
 	}
412 412
 
413
-	add_post_type_support( 'give_forms', 'thumbnail' );
413
+	add_post_type_support('give_forms', 'thumbnail');
414 414
 }
415 415
 
416
-add_action( 'after_setup_theme', 'give_add_thumbnail_support', 10 );
416
+add_action('after_setup_theme', 'give_add_thumbnail_support', 10);
417 417
 
418 418
 /**
419 419
  * Give Sidebars
@@ -424,21 +424,21 @@  discard block
 block discarded – undo
424 424
 
425 425
 	// Single Give Forms (disabled if single turned off in settings)
426 426
 	if (
427
-		give_is_setting_enabled( give_get_option( 'forms_singular' ) )
428
-		&& give_is_setting_enabled( give_get_option( 'form_sidebar' ) )
427
+		give_is_setting_enabled(give_get_option('forms_singular'))
428
+		&& give_is_setting_enabled(give_get_option('form_sidebar'))
429 429
 	) {
430 430
 
431
-		register_sidebar( apply_filters( 'give_forms_single_sidebar', array(
432
-			'name'          => __( 'Give Single Form Sidebar', 'give' ),
431
+		register_sidebar(apply_filters('give_forms_single_sidebar', array(
432
+			'name'          => __('Give Single Form Sidebar', 'give'),
433 433
 			'id'            => 'give-forms-sidebar',
434
-			'description'   => __( 'Widgets in this area will be shown on the single Give forms aside area. This sidebar will not display for embedded forms.', 'give' ),
434
+			'description'   => __('Widgets in this area will be shown on the single Give forms aside area. This sidebar will not display for embedded forms.', 'give'),
435 435
 			'before_widget' => '<div id="%1$s" class="widget %2$s">',
436 436
 			'after_widget'  => '</div>',
437 437
 			'before_title'  => '<h3 class="widgettitle widget-title">',
438 438
 			'after_title'   => '</h3>',
439
-		) ) );
439
+		)));
440 440
 
441 441
 	}
442 442
 }
443 443
 
444
-add_action( 'widgets_init', 'give_widgets_init', 999 );
444
+add_action('widgets_init', 'give_widgets_init', 999);
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-delete-test-transactions.php 1 patch
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly.
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -55,22 +55,22 @@  discard block
 block discarded – undo
55 55
 	public function get_data() {
56 56
 		global $wpdb;
57 57
 
58
-		$items = $this->get_stored_data( 'give_temp_delete_test_ids' );
58
+		$items = $this->get_stored_data('give_temp_delete_test_ids');
59 59
 
60
-		if ( ! is_array( $items ) ) {
60
+		if ( ! is_array($items)) {
61 61
 			return false;
62 62
 		}
63 63
 
64
-		$offset     = ( $this->step - 1 ) * $this->per_step;
65
-		$step_items = array_slice( $items, $offset, $this->per_step );
64
+		$offset     = ($this->step - 1) * $this->per_step;
65
+		$step_items = array_slice($items, $offset, $this->per_step);
66 66
 
67
-		if ( $step_items ) {
67
+		if ($step_items) {
68 68
 
69 69
 			$step_ids = array(
70 70
 				'other' => array(),
71 71
 			);
72 72
 
73
-			foreach ( $step_items as $item ) {
73
+			foreach ($step_items as $item) {
74 74
 
75 75
 				$step_ids['other'][] = $item['id'];
76 76
 
@@ -78,31 +78,31 @@  discard block
 block discarded – undo
78 78
 
79 79
 			$sql = array();
80 80
 
81
-			foreach ( $step_ids as $type => $ids ) {
81
+			foreach ($step_ids as $type => $ids) {
82 82
 
83
-				if ( empty( $ids ) ) {
83
+				if (empty($ids)) {
84 84
 					continue;
85 85
 				}
86 86
 
87 87
 				$parent_query = '';
88 88
 
89
-				switch ( $type ) {
89
+				switch ($type) {
90 90
 					case 'other':
91 91
 
92
-						$temp_ids = implode( ',', $ids );
92
+						$temp_ids = implode(',', $ids);
93 93
 
94 94
 						// Get all the test logs of the donations ids.
95 95
 						$parent_query = "SELECT DISTINCT post_id as id FROM $wpdb->postmeta WHERE meta_key = '_give_log_payment_id' AND meta_value IN ( $temp_ids )";
96
-						$parent_ids   = $wpdb->get_results( $parent_query, 'ARRAY_A' );
96
+						$parent_ids   = $wpdb->get_results($parent_query, 'ARRAY_A');
97 97
 
98 98
 						// List of all test logs.
99
-						if ( $parent_ids ) {
100
-							foreach ( $parent_ids as $parent_id ) {
99
+						if ($parent_ids) {
100
+							foreach ($parent_ids as $parent_id) {
101 101
 								// Adding all the test log in post ids that are going to get deleted.
102 102
 								$ids[] = $parent_id['id'];
103 103
 							}
104 104
 						}
105
-						$ids = implode( ',', $ids );
105
+						$ids = implode(',', $ids);
106 106
 
107 107
 						$sql[] = "DELETE FROM $wpdb->posts WHERE id IN ($ids)";
108 108
 						$sql[] = "DELETE FROM $wpdb->postmeta WHERE post_id IN ($ids)";
@@ -113,11 +113,11 @@  discard block
 block discarded – undo
113 113
 
114 114
 			}
115 115
 
116
-			if ( ! empty( $sql ) ) {
117
-				foreach ( $sql as $query ) {
118
-					$wpdb->query( $query );
116
+			if ( ! empty($sql)) {
117
+				foreach ($sql as $query) {
118
+					$wpdb->query($query);
119 119
 				}
120
-				do_action( 'give_delete_log_cache' );
120
+				do_action('give_delete_log_cache');
121 121
 			}
122 122
 
123 123
 			return true;
@@ -134,16 +134,16 @@  discard block
 block discarded – undo
134 134
 	 */
135 135
 	public function get_percentage_complete() {
136 136
 
137
-		$items = $this->get_stored_data( 'give_temp_delete_test_ids', false );
138
-		$total = count( $items );
137
+		$items = $this->get_stored_data('give_temp_delete_test_ids', false);
138
+		$total = count($items);
139 139
 
140 140
 		$percentage = 100;
141 141
 
142
-		if ( $total > 0 ) {
143
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
142
+		if ($total > 0) {
143
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
144 144
 		}
145 145
 
146
-		if ( $percentage > 100 ) {
146
+		if ($percentage > 100) {
147 147
 			$percentage = 100;
148 148
 		}
149 149
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	 *
158 158
 	 * @param array $request The Form Data passed into the batch processing
159 159
 	 */
160
-	public function set_properties( $request ) {
160
+	public function set_properties($request) {
161 161
 	}
162 162
 
163 163
 	/**
@@ -168,29 +168,29 @@  discard block
 block discarded – undo
168 168
 	 */
169 169
 	public function process_step() {
170 170
 
171
-		if ( ! $this->can_export() ) {
172
-			wp_die( __( 'You do not have permission to delete test transactions.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
171
+		if ( ! $this->can_export()) {
172
+			wp_die(__('You do not have permission to delete test transactions.', 'give'), __('Error', 'give'), array('response' => 403));
173 173
 		}
174 174
 
175 175
 		$had_data = $this->get_data();
176 176
 
177
-		if ( $had_data ) {
177
+		if ($had_data) {
178 178
 			$this->done = false;
179 179
 
180 180
 			return true;
181 181
 		} else {
182
-			update_option( 'give_earnings_total', give_get_total_earnings( true ) );
183
-			Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) );
182
+			update_option('give_earnings_total', give_get_total_earnings(true));
183
+			Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats'));
184 184
 
185
-			$this->delete_data( 'give_temp_delete_test_ids' );
185
+			$this->delete_data('give_temp_delete_test_ids');
186 186
 
187 187
 			// Reset the sequential order numbers
188
-			if ( give_get_option( 'enable_sequential' ) ) {
189
-				delete_option( 'give_last_payment_number' );
188
+			if (give_get_option('enable_sequential')) {
189
+				delete_option('give_last_payment_number');
190 190
 			}
191 191
 
192 192
 			$this->done    = true;
193
-			$this->message = __( 'Test transactions successfully deleted.', 'give' );
193
+			$this->message = __('Test transactions successfully deleted.', 'give');
194 194
 
195 195
 			return false;
196 196
 		}
@@ -200,10 +200,10 @@  discard block
 block discarded – undo
200 200
 	 * Headers
201 201
 	 */
202 202
 	public function headers() {
203
-		ignore_user_abort( true );
203
+		ignore_user_abort(true);
204 204
 
205
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
206
-			set_time_limit( 0 );
205
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
206
+			set_time_limit(0);
207 207
 		}
208 208
 	}
209 209
 
@@ -227,27 +227,27 @@  discard block
 block discarded – undo
227 227
 	 */
228 228
 	public function pre_fetch() {
229 229
 
230
-		if ( $this->step == 1 ) {
231
-			$this->delete_data( 'give_temp_delete_test_ids' );
230
+		if ($this->step == 1) {
231
+			$this->delete_data('give_temp_delete_test_ids');
232 232
 		}
233 233
 
234
-		$items = get_option( 'give_temp_delete_test_ids', false );
234
+		$items = get_option('give_temp_delete_test_ids', false);
235 235
 
236
-		if ( false === $items ) {
236
+		if (false === $items) {
237 237
 			$items = array();
238 238
 
239
-			$args = apply_filters( 'give_tools_reset_stats_total_args', array(
239
+			$args = apply_filters('give_tools_reset_stats_total_args', array(
240 240
 				'post_status' => 'any',
241
-				'number'      => - 1,
241
+				'number'      => -1,
242 242
 				'meta_key'    => '_give_payment_mode',
243 243
 				'meta_value'  => 'test'
244
-			) );
244
+			));
245 245
 
246
-			$posts    = new Give_Payments_Query( $args );
246
+			$posts    = new Give_Payments_Query($args);
247 247
 			$payments = $posts->get_payments();
248 248
 
249 249
 			/* @var Give_Payment $payment */
250
-			foreach ( $payments as $payment ) {
250
+			foreach ($payments as $payment) {
251 251
 				$items[] = array(
252 252
 					'id'   => (int) $payment->ID,
253 253
 					'type' => 'give_payment',
@@ -256,9 +256,9 @@  discard block
 block discarded – undo
256 256
 			
257 257
 			// Allow filtering of items to remove with an unassociative array for each item.
258 258
 			// The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method.
259
-			$items = apply_filters( 'give_delete_test_items', $items );
259
+			$items = apply_filters('give_delete_test_items', $items);
260 260
 
261
-			$this->store_data( 'give_temp_delete_test_ids', $items );
261
+			$this->store_data('give_temp_delete_test_ids', $items);
262 262
 		}
263 263
 
264 264
 	}
@@ -272,11 +272,11 @@  discard block
 block discarded – undo
272 272
 	 *
273 273
 	 * @return mixed       Returns the data from the database
274 274
 	 */
275
-	private function get_stored_data( $key ) {
275
+	private function get_stored_data($key) {
276 276
 		global $wpdb;
277
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
277
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
278 278
 
279
-		return empty( $value ) ? false : maybe_unserialize( $value );
279
+		return empty($value) ? false : maybe_unserialize($value);
280 280
 	}
281 281
 
282 282
 	/**
@@ -289,10 +289,10 @@  discard block
 block discarded – undo
289 289
 	 *
290 290
 	 * @return void
291 291
 	 */
292
-	private function store_data( $key, $value ) {
292
+	private function store_data($key, $value) {
293 293
 		global $wpdb;
294 294
 
295
-		$value = maybe_serialize( $value );
295
+		$value = maybe_serialize($value);
296 296
 
297 297
 		$data = array(
298 298
 			'option_name'  => $key,
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 			'%s',
307 307
 		);
308 308
 
309
-		$wpdb->replace( $wpdb->options, $data, $formats );
309
+		$wpdb->replace($wpdb->options, $data, $formats);
310 310
 	}
311 311
 
312 312
 	/**
@@ -318,9 +318,9 @@  discard block
 block discarded – undo
318 318
 	 *
319 319
 	 * @return void
320 320
 	 */
321
-	private function delete_data( $key ) {
321
+	private function delete_data($key) {
322 322
 		global $wpdb;
323
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
323
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
324 324
 	}
325 325
 
326 326
 }
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-delete-test-donors.php 1 patch
Spacing   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly.
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -109,32 +109,32 @@  discard block
 block discarded – undo
109 109
 		$donor_ids    = array();
110 110
 
111 111
 		// Check if the ajax request if running for the first time.
112
-		if ( 1 === (int) $this->step ) {
112
+		if (1 === (int) $this->step) {
113 113
 			// Delete all the donation ids.
114
-			$this->delete_option( $this->donation_key );
114
+			$this->delete_option($this->donation_key);
115 115
 			// Delete all the donor ids.
116
-			$this->delete_option( $this->donor_key );
116
+			$this->delete_option($this->donor_key);
117 117
 
118 118
 			// Delete all the step and set to 'count' which if the first step in the process of deleting the donors.
119
-			$this->update_option( $this->step_key, 'count' );
119
+			$this->update_option($this->step_key, 'count');
120 120
 
121 121
 			// Delete tha page count of the step.
122
-			$this->update_option( $this->step_on_key, '0' );
122
+			$this->update_option($this->step_on_key, '0');
123 123
 		} else {
124 124
 			// Get the old donors list.
125
-			$donor_ids = $this->get_option( $this->donor_key );
125
+			$donor_ids = $this->get_option($this->donor_key);
126 126
 
127 127
 			// Get the old donation list.
128
-			$donation_ids = $this->get_option( $this->donation_key );
128
+			$donation_ids = $this->get_option($this->donation_key);
129 129
 		}
130 130
 
131 131
 		// Get the step and check for it if it's on the first step( 'count' ) or not.
132 132
 		$step = (int) $this->get_step();
133
-		if ( 1 === $step ) {
133
+		if (1 === $step) {
134 134
 			/**
135 135
 			 * Will add or update the donation and donor data by running wp query.
136 136
 			 */
137
-			$this->count( $step, $donation_ids, $donor_ids );
137
+			$this->count($step, $donation_ids, $donor_ids);
138 138
 		}
139 139
 	}
140 140
 
@@ -145,17 +145,17 @@  discard block
 block discarded – undo
145 145
 	 * @param array  $donation_ids Contain the list of all the donation id's that has being add before this
146 146
 	 * @param array  $donor_ids    Contain the list of all the donors id's that has being add before this
147 147
 	 */
148
-	private function count( $step, $donation_ids = array(), $donor_ids = array() ) {
148
+	private function count($step, $donation_ids = array(), $donor_ids = array()) {
149 149
 
150 150
 		// Get the Page count by default it's zero.
151 151
 		$paged = (int) $this->get_step_page();
152 152
 		// Incresed the page count by one.
153
-		++ $paged;
153
+		++$paged;
154 154
 
155 155
 		/**
156 156
 		 * Filter add to alter the argument before the wp quest run
157 157
 		 */
158
-		$args = apply_filters( 'give_tools_reset_stats_total_args', array(
158
+		$args = apply_filters('give_tools_reset_stats_total_args', array(
159 159
 			'post_type'      => 'give_payment',
160 160
 			'post_status'    => 'any',
161 161
 			'posts_per_page' => $this->per_step,
@@ -163,16 +163,16 @@  discard block
 block discarded – undo
163 163
 			// ONLY TEST MODE TRANSACTIONS!!!
164 164
 			'meta_key'       => '_give_payment_mode',
165 165
 			'meta_value'     => 'test',
166
-		) );
166
+		));
167 167
 
168 168
 		// Reset the post data.
169 169
 		wp_reset_postdata();
170 170
 		// Getting the new donation.
171
-		$donation_posts = new WP_Query( $args );
171
+		$donation_posts = new WP_Query($args);
172 172
 
173 173
 		// The Loop.
174
-		if ( $donation_posts->have_posts() ) {
175
-			while ( $donation_posts->have_posts() ) {
174
+		if ($donation_posts->have_posts()) {
175
+			while ($donation_posts->have_posts()) {
176 176
 				$donation_posts->the_post();
177 177
 				global $post;
178 178
 				// Add the donation id in side the array.
@@ -191,23 +191,23 @@  discard block
 block discarded – undo
191 191
 		$max_num_pages = (int) $donation_posts->max_num_pages;
192 192
 
193 193
 		// Check current page is less then max number of page or not
194
-		if ( $paged < $max_num_pages ) {
194
+		if ($paged < $max_num_pages) {
195 195
 			// Update the curretn page virable for the next step
196
-			$this->update_option( $this->step_on_key, $paged );
196
+			$this->update_option($this->step_on_key, $paged);
197 197
 
198 198
 			// Calculating percentage.
199 199
 			$page_remain          = $max_num_pages - $paged;
200
-			$this->total_step     = (int) $max_num_pages + ( $total_donation / $this->per_step ) + ( ( $page_remain * 2 ) * count( $donor_ids ) );
200
+			$this->total_step     = (int) $max_num_pages + ($total_donation / $this->per_step) + (($page_remain * 2) * count($donor_ids));
201 201
 			$this->step_completed = $paged;
202 202
 		} else {
203
-			$donation_ids_count = count( $donor_ids );
204
-			$this->update_option( $this->step_key, 'donation' );
205
-			$this->update_option( $this->step_on_key, '0' );
203
+			$donation_ids_count = count($donor_ids);
204
+			$this->update_option($this->step_key, 'donation');
205
+			$this->update_option($this->step_on_key, '0');
206 206
 		}
207 207
 
208
-		$donor_ids = array_unique( $donor_ids );
209
-		$this->update_option( $this->donor_key, $donor_ids );
210
-		$this->update_option( $this->donation_key, $donation_ids );
208
+		$donor_ids = array_unique($donor_ids);
209
+		$this->update_option($this->donor_key, $donor_ids);
210
+		$this->update_option($this->donation_key, $donation_ids);
211 211
 
212 212
 		wp_reset_postdata();
213 213
 	}
@@ -219,34 +219,34 @@  discard block
 block discarded – undo
219 219
 	 * @return int
220 220
 	 */
221 221
 	public function get_percentage_complete() {
222
-		return ceil( ( 100 * $this->step_completed ) / $this->total_step );
222
+		return ceil((100 * $this->step_completed) / $this->total_step);
223 223
 	}
224 224
 
225 225
 	public function process_step() {
226 226
 
227
-		if ( ! $this->can_export() ) {
228
-			wp_die( __( 'You do not have permission to delete test transactions.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
227
+		if ( ! $this->can_export()) {
228
+			wp_die(__('You do not have permission to delete test transactions.', 'give'), __('Error', 'give'), array('response' => 403));
229 229
 		}
230 230
 
231 231
 		$had_data = $this->get_data();
232 232
 
233
-		if ( $had_data ) {
233
+		if ($had_data) {
234 234
 			$this->done = false;
235 235
 
236 236
 			return true;
237 237
 		} else {
238
-			update_option( 'give_earnings_total', give_get_total_earnings( true ) );
239
-			Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) );
238
+			update_option('give_earnings_total', give_get_total_earnings(true));
239
+			Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats'));
240 240
 
241
-			$this->delete_option( $this->donation_key );
241
+			$this->delete_option($this->donation_key);
242 242
 
243 243
 			// Reset the sequential order numbers
244
-			if ( give_get_option( 'enable_sequential' ) ) {
245
-				delete_option( 'give_last_payment_number' );
244
+			if (give_get_option('enable_sequential')) {
245
+				delete_option('give_last_payment_number');
246 246
 			}
247 247
 
248 248
 			$this->done    = true;
249
-			$this->message = __( 'Test donor and transactions successfully deleted.', 'give' );
249
+			$this->message = __('Test donor and transactions successfully deleted.', 'give');
250 250
 
251 251
 			return false;
252 252
 		}
@@ -264,12 +264,12 @@  discard block
 block discarded – undo
264 264
 	public function get_data() {
265 265
 
266 266
 		// Get the donation id's.
267
-		$donation_ids = $this->get_option( $this->donation_key );
267
+		$donation_ids = $this->get_option($this->donation_key);
268 268
 
269 269
 		/**
270 270
 		 * Return false id not test donation is found.
271 271
 		 */
272
-		if ( empty( $donation_ids ) ) {
272
+		if (empty($donation_ids)) {
273 273
 			$this->is_empty   = true;
274 274
 			$this->total_step = 1;
275 275
 
@@ -280,81 +280,81 @@  discard block
 block discarded – undo
280 280
 		$step = (int) $this->get_step();
281 281
 
282 282
 		// get teh donor ids.
283
-		$donor_ids = $this->get_option( $this->donor_key );
283
+		$donor_ids = $this->get_option($this->donor_key);
284 284
 
285 285
 		// In step to we delete all the donation in loop.
286
-		if ( 2 === $step ) {
286
+		if (2 === $step) {
287 287
 			$pass_to_donor = false;
288 288
 			$page          = (int) $this->get_step_page();
289
-			$page ++;
290
-			$count = count( $donation_ids );
289
+			$page++;
290
+			$count = count($donation_ids);
291 291
 
292
-			$this->total_step     = ( ( count( $donation_ids ) / $this->per_step ) * 2 ) + count( $donor_ids );
292
+			$this->total_step     = ((count($donation_ids) / $this->per_step) * 2) + count($donor_ids);
293 293
 			$this->step_completed = $page;
294 294
 
295 295
 
296
-			if ( $count > $this->per_step ) {
296
+			if ($count > $this->per_step) {
297 297
 
298
-				$this->update_option( $this->step_on_key, $page );
299
-				$donation_ids = $this->get_delete_ids( $donation_ids, $page );
300
-				$current_page = (int) ceil( $count / $this->per_step );
298
+				$this->update_option($this->step_on_key, $page);
299
+				$donation_ids = $this->get_delete_ids($donation_ids, $page);
300
+				$current_page = (int) ceil($count / $this->per_step);
301 301
 
302
-				if ( $page === $current_page ) {
302
+				if ($page === $current_page) {
303 303
 					$pass_to_donor = true;
304 304
 				}
305 305
 			} else {
306 306
 				$pass_to_donor = true;
307 307
 			}
308 308
 
309
-			if ( true === $pass_to_donor ) {
310
-				$this->update_option( $this->step_key, 'donor' );
311
-				$this->update_option( $this->step_on_key, '0' );
309
+			if (true === $pass_to_donor) {
310
+				$this->update_option($this->step_key, 'donor');
311
+				$this->update_option($this->step_on_key, '0');
312 312
 			}
313 313
 
314 314
 			global $wpdb;
315
-			foreach ( $donation_ids as $item ) {
315
+			foreach ($donation_ids as $item) {
316 316
 
317 317
 				// will delete the payment log first.
318
-				$parent_query = $wpdb->prepare( "SELECT post_id as id FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %d", '_give_log_payment_id', (int) $item );
319
-				$log_id       = $wpdb->get_row( $parent_query, ARRAY_A );
318
+				$parent_query = $wpdb->prepare("SELECT post_id as id FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %d", '_give_log_payment_id', (int) $item);
319
+				$log_id       = $wpdb->get_row($parent_query, ARRAY_A);
320 320
 				// Check if payment has it log or not if yes then delete it.
321
-				if ( ! empty( $log_id['id'] ) ) {
321
+				if ( ! empty($log_id['id'])) {
322 322
 					// Deleting the payment log.
323
-					wp_delete_post( $log_id['id'], true );
323
+					wp_delete_post($log_id['id'], true);
324 324
 				}
325 325
 
326 326
 				// Delete the main payment.
327
-				wp_delete_post( $item, true );
327
+				wp_delete_post($item, true);
328 328
 			}
329
-			do_action( 'give_delete_log_cache' );
329
+			do_action('give_delete_log_cache');
330 330
 		}
331 331
 
332 332
 
333 333
 		// Here we delete all the donor
334
-		if ( 3 === $step ) {
334
+		if (3 === $step) {
335 335
 			$page  = (int) $this->get_step_page();
336
-			$count = count( $donor_ids );
336
+			$count = count($donor_ids);
337 337
 
338
-			$this->total_step     = ( ( count( $donation_ids ) / $this->per_step ) * 2 ) + count( $donor_ids );
339
-			$this->step_completed = $page + ( count( $donation_ids ) / $this->per_step );
338
+			$this->total_step     = ((count($donation_ids) / $this->per_step) * 2) + count($donor_ids);
339
+			$this->step_completed = $page + (count($donation_ids) / $this->per_step);
340 340
 
341
-			$args = apply_filters( 'give_tools_reset_stats_total_args', array(
341
+			$args = apply_filters('give_tools_reset_stats_total_args', array(
342 342
 				'post_type'      => 'give_payment',
343 343
 				'post_status'    => 'any',
344 344
 				'posts_per_page' => 1,
345 345
 				'meta_key'       => '_give_payment_mode',
346 346
 				'meta_value'     => 'live',
347
-				'author'         => $donor_ids[ $page ],
348
-			) );
347
+				'author'         => $donor_ids[$page],
348
+			));
349 349
 
350
-			$donation_posts = get_posts( $args );
351
-			if ( empty( $donation_posts ) ) {
352
-				Give()->donors->delete_by_user_id( $donor_ids[ $page ] );
350
+			$donation_posts = get_posts($args);
351
+			if (empty($donation_posts)) {
352
+				Give()->donors->delete_by_user_id($donor_ids[$page]);
353 353
 			}
354 354
 
355
-			$page ++;
356
-			$this->update_option( $this->step_on_key, $page );
357
-			if ( $count === $page ) {
355
+			$page++;
356
+			$this->update_option($this->step_on_key, $page);
357
+			if ($count === $page) {
358 358
 				$this->is_empty = false;
359 359
 
360 360
 				return false;
@@ -366,24 +366,24 @@  discard block
 block discarded – undo
366 366
 		return true;
367 367
 	}
368 368
 
369
-	public function get_delete_ids( $donation_ids, $page ) {
370
-		$index            = $page --;
371
-		$count            = count( $donation_ids );
369
+	public function get_delete_ids($donation_ids, $page) {
370
+		$index            = $page--;
371
+		$count            = count($donation_ids);
372 372
 		$temp             = 0;
373 373
 		$current_page     = 0;
374 374
 		$post_delete      = $this->per_step;
375 375
 		$page_donation_id = array();
376 376
 
377
-		foreach ( $donation_ids as $item ) {
378
-			$temp ++;
379
-			$page_donation_id[ $current_page ][] = $item;
380
-			if ( $temp === $post_delete ) {
381
-				$current_page ++;
377
+		foreach ($donation_ids as $item) {
378
+			$temp++;
379
+			$page_donation_id[$current_page][] = $item;
380
+			if ($temp === $post_delete) {
381
+				$current_page++;
382 382
 				$temp = 0;
383 383
 			}
384 384
 		}
385 385
 
386
-		return $page_donation_id[ $page ];
386
+		return $page_donation_id[$page];
387 387
 	}
388 388
 
389 389
 	/**
@@ -395,8 +395,8 @@  discard block
 block discarded – undo
395 395
 	 *
396 396
 	 * @return mixed       Returns the data from the database
397 397
 	 */
398
-	public function get_option( $key, $defalut_value = false ) {
399
-		return get_option( $key, $defalut_value );
398
+	public function get_option($key, $defalut_value = false) {
399
+		return get_option($key, $defalut_value);
400 400
 	}
401 401
 
402 402
 	/**
@@ -409,8 +409,8 @@  discard block
 block discarded – undo
409 409
 	 *
410 410
 	 * @return void
411 411
 	 */
412
-	public function update_option( $key, $value ) {
413
-		update_option( $key, $value, false );
412
+	public function update_option($key, $value) {
413
+		update_option($key, $value, false);
414 414
 	}
415 415
 
416 416
 	/**
@@ -422,8 +422,8 @@  discard block
 block discarded – undo
422 422
 	 *
423 423
 	 * @return void
424 424
 	 */
425
-	public function delete_option( $key ) {
426
-		delete_option( $key );
425
+	public function delete_option($key) {
426
+		delete_option($key);
427 427
 	}
428 428
 
429 429
 	/**
@@ -434,12 +434,12 @@  discard block
 block discarded – undo
434 434
 	 * @return int|string
435 435
 	 */
436 436
 	private function get_step() {
437
-		$step_key = (string) $this->get_option( $this->step_key, false );
438
-		if ( 'count' === $step_key ) {
437
+		$step_key = (string) $this->get_option($this->step_key, false);
438
+		if ('count' === $step_key) {
439 439
 			return 1;
440
-		} elseif ( 'donation' === $step_key ) {
440
+		} elseif ('donation' === $step_key) {
441 441
 			return 2;
442
-		} elseif ( 'donor' === $step_key ) {
442
+		} elseif ('donor' === $step_key) {
443 443
 			return 3;
444 444
 		} else {
445 445
 			return $step_key;
@@ -450,6 +450,6 @@  discard block
 block discarded – undo
450 450
 	 * Get the current $page value in the ajax.
451 451
 	 */
452 452
 	private function get_step_page() {
453
-		return $this->get_option( $this->step_on_key, false );
453
+		return $this->get_option($this->step_on_key, false);
454 454
 	}
455 455
 }
Please login to merge, or discard this patch.
includes/admin/tools/logs/class-sales-logs-list-table.php 1 patch
Spacing   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -9,13 +9,13 @@  discard block
 block discarded – undo
9 9
  */
10 10
 
11 11
 // Exit if accessed directly.
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit;
14 14
 }
15 15
 
16 16
 // Load WP_List_Table if not loaded.
17
-if ( ! class_exists( 'WP_List_Table' ) ) {
18
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
17
+if ( ! class_exists('WP_List_Table')) {
18
+	require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
19 19
 }
20 20
 
21 21
 /**
@@ -44,13 +44,13 @@  discard block
 block discarded – undo
44 44
 		global $status, $page;
45 45
 
46 46
 		// Set parent defaults
47
-		parent::__construct( array(
48
-			'singular' => give_get_forms_label_singular(),    // Singular name of the listed records
49
-			'plural'   => give_get_forms_label_plural(),        // Plural name of the listed records
50
-			'ajax'     => false,// Does this table support ajax?
51
-		) );
47
+		parent::__construct(array(
48
+			'singular' => give_get_forms_label_singular(), // Singular name of the listed records
49
+			'plural'   => give_get_forms_label_plural(), // Plural name of the listed records
50
+			'ajax'     => false, // Does this table support ajax?
51
+		));
52 52
 
53
-		add_action( 'give_log_view_actions', array( $this, 'give_forms_filter' ) );
53
+		add_action('give_log_view_actions', array($this, 'give_forms_filter'));
54 54
 	}
55 55
 
56 56
 	/**
@@ -64,41 +64,41 @@  discard block
 block discarded – undo
64 64
 	 *
65 65
 	 * @return string Column Name
66 66
 	 */
67
-	public function column_default( $item, $column_name ) {
67
+	public function column_default($item, $column_name) {
68 68
 
69
-		$payment = give_get_payment_by( 'id', $item['payment_id'] );
69
+		$payment = give_get_payment_by('id', $item['payment_id']);
70 70
 
71
-		switch ( $column_name ) {
71
+		switch ($column_name) {
72 72
 			case 'form' :
73
-				$form_title = get_the_title( $item[ $column_name ] );
74
-				$form_title = empty( $form_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $item[ $column_name ] ) : $form_title;
75
-				return '<a href="' . esc_url( add_query_arg( 'form', $item[ $column_name ] ) ) . '" >' . $form_title . '</a>';
73
+				$form_title = get_the_title($item[$column_name]);
74
+				$form_title = empty($form_title) ? sprintf(__('Untitled (#%s)', 'give'), $item[$column_name]) : $form_title;
75
+				return '<a href="'.esc_url(add_query_arg('form', $item[$column_name])).'" >'.$form_title.'</a>';
76 76
 
77 77
 			case 'donor_id' :
78 78
 				return sprintf(
79 79
 					'<a href="%s">%s</a>',
80
-					admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&donor=' . absint( $item['donor_id'] ) ),
80
+					admin_url('edit.php?post_type=give_forms&page=give-payment-history&donor='.absint($item['donor_id'])),
81 81
 					$item['donor_name']
82 82
 				);
83 83
 
84 84
 			case 'amount' :
85
-				return give_currency_filter( give_format_amount( $item['amount'], array( 'sanitize' => false ) ) );
85
+				return give_currency_filter(give_format_amount($item['amount'], array('sanitize' => false)));
86 86
 
87 87
 			case 'status' :
88 88
 
89
-				$value = '<div class="give-donation-status status-' . sanitize_title( give_get_payment_status( $payment, true ) ) . '"><span class="give-donation-status-icon"></span> ' . give_get_payment_status( $payment, true ) . '</div>';
89
+				$value = '<div class="give-donation-status status-'.sanitize_title(give_get_payment_status($payment, true)).'"><span class="give-donation-status-icon"></span> '.give_get_payment_status($payment, true).'</div>';
90 90
 
91
-				if ( $payment->mode == 'test' ) {
92
-					$value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="' . esc_attr__( 'This donation was made in test mode.', 'give' ) . '">' . __( 'Test', 'give' ) . '</span>';
91
+				if ($payment->mode == 'test') {
92
+					$value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="'.esc_attr__('This donation was made in test mode.', 'give').'">'.__('Test', 'give').'</span>';
93 93
 				}
94 94
 
95 95
 				return $value;
96 96
 
97 97
 			case 'payment_id' :
98
-				return '<a href="' . admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $item['payment_id'] ) . '">' . give_get_payment_number( $item['payment_id'] ) . '</a>';
98
+				return '<a href="'.admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id='.$item['payment_id']).'">'.give_get_payment_number($item['payment_id']).'</a>';
99 99
 
100 100
 			default:
101
-				return $item[ $column_name ];
101
+				return $item[$column_name];
102 102
 		}
103 103
 	}
104 104
 
@@ -111,13 +111,13 @@  discard block
 block discarded – undo
111 111
 	 */
112 112
 	public function get_columns() {
113 113
 		$columns = array(
114
-			'ID'         => __( 'Log ID', 'give' ),
115
-			'donor_id'   => __( 'Donor', 'give' ),
116
-			'form'       => __( 'Form', 'give' ),
117
-			'amount'     => __( 'Donation Amount', 'give' ),
118
-			'status'     => __( 'Status', 'give' ),
119
-			'payment_id' => __( 'Donation ID', 'give' ),
120
-			'date'       => __( 'Date', 'give' ),
114
+			'ID'         => __('Log ID', 'give'),
115
+			'donor_id'   => __('Donor', 'give'),
116
+			'form'       => __('Form', 'give'),
117
+			'amount'     => __('Donation Amount', 'give'),
118
+			'status'     => __('Status', 'give'),
119
+			'payment_id' => __('Donation ID', 'give'),
120
+			'date'       => __('Date', 'give'),
121 121
 		);
122 122
 
123 123
 		return $columns;
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	 * @return int Current page number
132 132
 	 */
133 133
 	public function get_paged() {
134
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
134
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
135 135
 	}
136 136
 
137 137
 	/**
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	 * @return mixed int If User ID, string If Email/Login
143 143
 	 */
144 144
 	public function get_filtered_user() {
145
-		return isset( $_GET['user'] ) ? absint( $_GET['user'] ) : false;
145
+		return isset($_GET['user']) ? absint($_GET['user']) : false;
146 146
 	}
147 147
 
148 148
 	/**
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	 * @return int Download ID
154 154
 	 */
155 155
 	public function get_filtered_give_form() {
156
-		return ! empty( $_GET['form'] ) ? absint( $_GET['form'] ) : false;
156
+		return ! empty($_GET['form']) ? absint($_GET['form']) : false;
157 157
 	}
158 158
 
159 159
 	/**
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 	 * @return string|bool string If search is present, false otherwise
165 165
 	 */
166 166
 	public function get_search() {
167
-		return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false;
167
+		return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false;
168 168
 	}
169 169
 
170 170
 
@@ -180,20 +180,20 @@  discard block
 block discarded – undo
180 180
 	 *
181 181
 	 * @param string $which
182 182
 	 */
183
-	protected function display_tablenav( $which ) {
183
+	protected function display_tablenav($which) {
184 184
 
185
-		if ( 'top' === $which ) {
186
-			wp_nonce_field( 'bulk-' . $this->_args['plural'] );
185
+		if ('top' === $which) {
186
+			wp_nonce_field('bulk-'.$this->_args['plural']);
187 187
 		}
188 188
 		?>
189
-		<div class="tablenav <?php echo esc_attr( $which ); ?>">
189
+		<div class="tablenav <?php echo esc_attr($which); ?>">
190 190
 
191 191
 			<div class="alignleft actions bulkactions">
192
-				<?php $this->bulk_actions( $which ); ?>
192
+				<?php $this->bulk_actions($which); ?>
193 193
 			</div>
194 194
 			<?php
195
-			$this->extra_tablenav( $which );
196
-			$this->pagination( $which );
195
+			$this->extra_tablenav($which);
196
+			$this->pagination($which);
197 197
 			?>
198 198
 
199 199
 			<br class="clear"/>
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 
218 218
 		$meta_query = array();
219 219
 
220
-		if ( $user ) {
220
+		if ($user) {
221 221
 			// Show only logs from a specific user.
222 222
 			$meta_query[] = array(
223 223
 				'key'   => '_give_log_user_id',
@@ -226,8 +226,8 @@  discard block
 block discarded – undo
226 226
 		}
227 227
 
228 228
 		$search = $this->get_search();
229
-		if ( $search ) {
230
-			if ( is_email( $search ) ) {
229
+		if ($search) {
230
+			if (is_email($search)) {
231 231
 				// This is an email search. We use this to ensure it works for guest users and logged-in users.
232 232
 				$key     = '_give_log_user_info';
233 233
 				$compare = 'LIKE';
@@ -236,32 +236,32 @@  discard block
 block discarded – undo
236 236
 				$key     = '_give_log_user_id';
237 237
 				$compare = 'LIKE';
238 238
 
239
-				if ( ! is_numeric( $search ) ) {
239
+				if ( ! is_numeric($search)) {
240 240
 					// Searching for user by username
241
-					$user = get_user_by( 'login', $search );
241
+					$user = get_user_by('login', $search);
242 242
 
243
-					if ( $user ) {
243
+					if ($user) {
244 244
 						// Found one, set meta value to user's ID.
245 245
 						$search = $user->ID;
246 246
 					} else {
247 247
 						// No user found so let's do a real search query.
248
-						$users = new WP_User_Query( array(
248
+						$users = new WP_User_Query(array(
249 249
 							'search'         => $search,
250
-							'search_columns' => array( 'user_url', 'user_nicename' ),
250
+							'search_columns' => array('user_url', 'user_nicename'),
251 251
 							'number'         => 1,
252 252
 							'fields'         => 'ids',
253
-						) );
253
+						));
254 254
 
255 255
 						$found_user = $users->get_results();
256 256
 
257
-						if ( $found_user ) {
257
+						if ($found_user) {
258 258
 							$search = $found_user[0];
259 259
 						}
260 260
 					}
261 261
 				}
262 262
 			}
263 263
 
264
-			if ( ! $this->file_search ) {
264
+			if ( ! $this->file_search) {
265 265
 				// Meta query only works for non file name search.
266 266
 				$meta_query[] = array(
267 267
 					'key'     => $key,
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 	 * @since  1.0
283 283
 	 * @return void
284 284
 	 */
285
-	function bulk_actions( $which = '' ) {
285
+	function bulk_actions($which = '') {
286 286
 		give_log_views();
287 287
 	}
288 288
 
@@ -294,24 +294,24 @@  discard block
 block discarded – undo
294 294
 	 * @return void
295 295
 	 */
296 296
 	public function give_forms_filter() {
297
-		$give_forms = get_posts( array(
297
+		$give_forms = get_posts(array(
298 298
 			'post_type'              => 'give_forms',
299 299
 			'post_status'            => 'any',
300
-			'posts_per_page'         => - 1,
300
+			'posts_per_page'         => -1,
301 301
 			'orderby'                => 'title',
302 302
 			'order'                  => 'ASC',
303 303
 			'fields'                 => 'ids',
304 304
 			'update_post_meta_cache' => false,
305 305
 			'update_post_term_cache' => false,
306
-		) );
306
+		));
307 307
 
308
-		if ( $give_forms ) {
308
+		if ($give_forms) {
309 309
 			echo '<select name="form" id="give-log-form-filter">';
310
-			echo '<option value="0">' . __( 'All', 'give' ) . '</option>';
311
-			foreach ( $give_forms as $form ) {
312
-				$form_title = get_the_title( $form );
313
-				$form_title = empty( $form_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $form ) : $form_title;
314
-				echo '<option value="' . $form . '"' . selected( $form, $this->get_filtered_give_form() ) . '>' . esc_html( $form_title ) . '</option>';
310
+			echo '<option value="0">'.__('All', 'give').'</option>';
311
+			foreach ($give_forms as $form) {
312
+				$form_title = get_the_title($form);
313
+				$form_title = empty($form_title) ? sprintf(__('Untitled (#%s)', 'give'), $form) : $form_title;
314
+				echo '<option value="'.$form.'"'.selected($form, $this->get_filtered_give_form()).'>'.esc_html($form_title).'</option>';
315 315
 			}
316 316
 			echo '</select>';
317 317
 		}
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 
332 332
 		$logs_data = array();
333 333
 		$paged     = $this->get_paged();
334
-		$give_form = empty( $_GET['s'] ) ? $this->get_filtered_give_form() : null;
334
+		$give_form = empty($_GET['s']) ? $this->get_filtered_give_form() : null;
335 335
 		$user      = $this->get_filtered_user();
336 336
 
337 337
 		$log_query = array(
@@ -342,37 +342,37 @@  discard block
 block discarded – undo
342 342
 			'posts_per_page' => $this->per_page,
343 343
 		);
344 344
 
345
-		$cache_key = Give_Cache::get_key( 'get_logs', $log_query );
345
+		$cache_key = Give_Cache::get_key('get_logs', $log_query);
346 346
 
347 347
 		// Return result from cache if exist.
348
-		if ( ! ( $logs_data = Give_Cache::get( $cache_key ) ) ) {
349
-			$logs = $give_logs->get_connected_logs( $log_query );
348
+		if ( ! ($logs_data = Give_Cache::get($cache_key))) {
349
+			$logs = $give_logs->get_connected_logs($log_query);
350 350
 
351
-			if ( $logs ) {
352
-				foreach ( $logs as $log ) {
353
-					$payment_id = give_get_meta( $log->ID, '_give_log_payment_id', true );
351
+			if ($logs) {
352
+				foreach ($logs as $log) {
353
+					$payment_id = give_get_meta($log->ID, '_give_log_payment_id', true);
354 354
 
355 355
 					// Make sure this payment hasn't been deleted.
356
-					if ( get_post( $payment_id ) ) :
357
-						$user_info      = give_get_payment_meta_user_info( $payment_id );
358
-						$payment_amount = give_get_payment_amount( $payment_id );
356
+					if (get_post($payment_id)) :
357
+						$user_info      = give_get_payment_meta_user_info($payment_id);
358
+						$payment_amount = give_get_payment_amount($payment_id);
359 359
 
360 360
 						$logs_data[] = array(
361
-							'ID'         => '<span class="give-item-label give-item-label-gray">' . $log->ID . '</span>',
361
+							'ID'         => '<span class="give-item-label give-item-label-gray">'.$log->ID.'</span>',
362 362
 							'payment_id' => $payment_id,
363 363
 							'form'       => $log->post_parent,
364 364
 							'amount'     => $payment_amount,
365
-							'donor_id'   => give_get_payment_donor_id( $payment_id ),
366
-							'donor_name' => trim( "{$user_info['first_name']} {$user_info['last_name']}" ),
367
-							'date'       => get_post_field( 'post_date', $payment_id ),
365
+							'donor_id'   => give_get_payment_donor_id($payment_id),
366
+							'donor_name' => trim("{$user_info['first_name']} {$user_info['last_name']}"),
367
+							'date'       => get_post_field('post_date', $payment_id),
368 368
 						);
369 369
 
370 370
 					endif;
371 371
 				}
372 372
 
373 373
 				// Cache results.
374
-				if ( ! empty( $logs_data ) ) {
375
-					Give_Cache::set( $cache_key, $logs_data );
374
+				if ( ! empty($logs_data)) {
375
+					Give_Cache::set($cache_key, $logs_data);
376 376
 				}
377 377
 			}
378 378
 		}
@@ -400,15 +400,15 @@  discard block
 block discarded – undo
400 400
 		$columns               = $this->get_columns();
401 401
 		$hidden                = array();
402 402
 		$sortable              = $this->get_sortable_columns();
403
-		$this->_column_headers = array( $columns, $hidden, $sortable );
403
+		$this->_column_headers = array($columns, $hidden, $sortable);
404 404
 		$current_page          = $this->get_pagenum();
405 405
 		$this->items           = $this->get_logs();
406
-		$total_items           = $give_logs->get_log_count( $this->get_filtered_give_form(), 'sale', $this->get_meta_query() );
406
+		$total_items           = $give_logs->get_log_count($this->get_filtered_give_form(), 'sale', $this->get_meta_query());
407 407
 
408
-		$this->set_pagination_args( array(
408
+		$this->set_pagination_args(array(
409 409
 				'total_items' => $total_items,
410 410
 				'per_page'    => $this->per_page,
411
-				'total_pages' => ceil( $total_items / $this->per_page ),
411
+				'total_pages' => ceil($total_items / $this->per_page),
412 412
 			)
413 413
 		);
414 414
 	}
Please login to merge, or discard this patch.
includes/admin/reports/class-donor-reports-table.php 1 patch
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -10,13 +10,13 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
17 17
 // Load WP_List_Table if not loaded
18
-if ( ! class_exists( 'WP_List_Table' ) ) {
19
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
18
+if ( ! class_exists('WP_List_Table')) {
19
+	require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
20 20
 }
21 21
 
22 22
 /**
@@ -62,11 +62,11 @@  discard block
 block discarded – undo
62 62
 		global $status, $page;
63 63
 
64 64
 		// Set parent defaults
65
-		parent::__construct( array(
66
-			'singular' => esc_html__( 'Donor', 'give' ),     // Singular name of the listed records
67
-			'plural'   => esc_html__( 'Donors', 'give' ),    // Plural name of the listed records
68
-			'ajax'     => false,// Does this table support ajax?
69
-		) );
65
+		parent::__construct(array(
66
+			'singular' => esc_html__('Donor', 'give'), // Singular name of the listed records
67
+			'plural'   => esc_html__('Donors', 'give'), // Plural name of the listed records
68
+			'ajax'     => false, // Does this table support ajax?
69
+		));
70 70
 
71 71
 	}
72 72
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	 *
84 84
 	 * @return false
85 85
 	 */
86
-	public function search_box( $text, $input_id ) {
86
+	public function search_box($text, $input_id) {
87 87
 		return false;
88 88
 	}
89 89
 
@@ -98,20 +98,20 @@  discard block
 block discarded – undo
98 98
 	 *
99 99
 	 * @return void
100 100
 	 */
101
-	public function give_search_box( $text, $input_id ) {
102
-		$input_id = $input_id . '-search-input';
101
+	public function give_search_box($text, $input_id) {
102
+		$input_id = $input_id.'-search-input';
103 103
 
104
-		if ( ! empty( $_REQUEST['orderby'] ) ) {
105
-			echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
104
+		if ( ! empty($_REQUEST['orderby'])) {
105
+			echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />';
106 106
 		}
107
-		if ( ! empty( $_REQUEST['order'] ) ) {
108
-			echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
107
+		if ( ! empty($_REQUEST['order'])) {
108
+			echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />';
109 109
 		}
110 110
 		?>
111 111
 		<p class="search-box donor-search" role="search">
112 112
 			<label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label>
113 113
 			<input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" />
114
-			<?php submit_button( $text, 'button', false, false, array( 'ID' => 'search-submit' ) ); ?>
114
+			<?php submit_button($text, 'button', false, false, array('ID' => 'search-submit')); ?>
115 115
 		</p>
116 116
 	<?php
117 117
 	}
@@ -124,33 +124,33 @@  discard block
 block discarded – undo
124 124
 	 *
125 125
 	 * @param string $which
126 126
 	 */
127
-	protected function display_tablenav( $which ) {
127
+	protected function display_tablenav($which) {
128 128
 
129
-		if ( 'top' === $which ) {
130
-			wp_nonce_field( 'bulk-' . $this->_args['plural'] );
129
+		if ('top' === $which) {
130
+			wp_nonce_field('bulk-'.$this->_args['plural']);
131 131
 		}
132 132
 		?>
133
-		<div class="tablenav give-clearfix <?php echo esc_attr( $which ); ?>">
133
+		<div class="tablenav give-clearfix <?php echo esc_attr($which); ?>">
134 134
 
135
-			<?php if ( 'top' === $which ) { ?>
135
+			<?php if ('top' === $which) { ?>
136 136
 				<h3 class="alignleft reports-earnings-title">
137
-					<span><?php esc_html_e( 'Donors Report', 'give' ); ?></span>
137
+					<span><?php esc_html_e('Donors Report', 'give'); ?></span>
138 138
 				</h3>
139 139
 			<?php } ?>
140 140
 
141 141
 			<div class="alignright tablenav-right">
142 142
 				<div class="actions bulkactions">
143 143
 					<?php
144
-					if ( 'top' === $which ) {
145
-						$this->give_search_box( esc_html__( 'Search Donors', 'give' ), 'give-donors-report-search' );
144
+					if ('top' === $which) {
145
+						$this->give_search_box(esc_html__('Search Donors', 'give'), 'give-donors-report-search');
146 146
 					}
147 147
 
148
-					$this->bulk_actions( $which ); ?>
148
+					$this->bulk_actions($which); ?>
149 149
 
150 150
 				</div>
151 151
 				<?php
152
-				$this->extra_tablenav( $which );
153
-				$this->pagination( $which );
152
+				$this->extra_tablenav($which);
153
+				$this->pagination($which);
154 154
 				?>
155 155
 			</div>
156 156
 
@@ -172,35 +172,35 @@  discard block
 block discarded – undo
172 172
 	 *
173 173
 	 * @return string Column Name
174 174
 	 */
175
-	public function column_default( $item, $column_name ) {
175
+	public function column_default($item, $column_name) {
176 176
 
177
-		switch ( $column_name ) {
177
+		switch ($column_name) {
178 178
 
179 179
 			case 'name' :
180
-				$name = '#' . $item['id'] . ' ';
181
-				$name .= ! empty( $item['name'] ) ? $item['name'] : '<em>' . esc_html__( 'Unnamed Donor', 'give' ) . '</em>';
182
-				$view_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $item['id'] );
183
-				$value    = '<a href="' . esc_url( $view_url ) . '">' . $name . '</a>';
180
+				$name = '#'.$item['id'].' ';
181
+				$name .= ! empty($item['name']) ? $item['name'] : '<em>'.esc_html__('Unnamed Donor', 'give').'</em>';
182
+				$view_url = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$item['id']);
183
+				$value    = '<a href="'.esc_url($view_url).'">'.$name.'</a>';
184 184
 				break;
185 185
 
186 186
 			case 'num_donations' :
187 187
 				$value = sprintf(
188 188
 					'<a href="%s">%s</a>',
189
-					admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&donor=' . absint( $item['id'] ) ),
190
-						esc_html( $item['num_donations'] )
189
+					admin_url('edit.php?post_type=give_forms&page=give-payment-history&donor='.absint($item['id'])),
190
+						esc_html($item['num_donations'])
191 191
 					);
192 192
 				break;
193 193
 
194 194
 			case 'amount_spent' :
195
-				$value = give_currency_filter( give_format_amount( $item[ $column_name ], array( 'sanitize' => false ) ) );
195
+				$value = give_currency_filter(give_format_amount($item[$column_name], array('sanitize' => false)));
196 196
 				break;
197 197
 
198 198
 			default:
199
-				$value = isset( $item[ $column_name ] ) ? $item[ $column_name ] : null;
199
+				$value = isset($item[$column_name]) ? $item[$column_name] : null;
200 200
 				break;
201 201
 		}
202 202
 
203
-		return apply_filters( "give_report_column_{$column_name}", $value, $item['id'] );
203
+		return apply_filters("give_report_column_{$column_name}", $value, $item['id']);
204 204
 	}
205 205
 
206 206
 	/**
@@ -212,13 +212,13 @@  discard block
 block discarded – undo
212 212
 	 */
213 213
 	public function get_columns() {
214 214
 		$columns = array(
215
-			'name'          => __( 'Name', 'give' ),
216
-			'email'         => __( 'Email', 'give' ),
217
-			'num_donations' => __( 'Donations', 'give' ),
218
-			'amount_spent'  => __( 'Total Donated', 'give' ),
215
+			'name'          => __('Name', 'give'),
216
+			'email'         => __('Email', 'give'),
217
+			'num_donations' => __('Donations', 'give'),
218
+			'amount_spent'  => __('Total Donated', 'give'),
219 219
 		);
220 220
 
221
-		return apply_filters( 'give_report_donor_columns', $columns );
221
+		return apply_filters('give_report_donor_columns', $columns);
222 222
 
223 223
 	}
224 224
 
@@ -231,10 +231,10 @@  discard block
 block discarded – undo
231 231
 	 */
232 232
 	public function get_sortable_columns() {
233 233
 		return array(
234
-			'id'            => array( 'id', true ),
235
-			'name'          => array( 'name', true ),
236
-			'num_donations' => array( 'purchase_count', false ),
237
-			'amount_spent'  => array( 'purchase_value', false ),
234
+			'id'            => array('id', true),
235
+			'name'          => array('name', true),
236
+			'num_donations' => array('purchase_count', false),
237
+			'amount_spent'  => array('purchase_value', false),
238 238
 		);
239 239
 	}
240 240
 
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 	 * @since  1.0
246 246
 	 * @return void
247 247
 	 */
248
-	public function bulk_actions( $which = '' ) {
248
+	public function bulk_actions($which = '') {
249 249
 
250 250
 	}
251 251
 
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 	 * @return int Current page number
258 258
 	 */
259 259
 	public function get_paged() {
260
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
260
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
261 261
 	}
262 262
 
263 263
 	/**
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 	 * @return mixed string If search is present, false otherwise
269 269
 	 */
270 270
 	public function get_search() {
271
-		return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false;
271
+		return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false;
272 272
 	}
273 273
 
274 274
 	/**
@@ -287,15 +287,15 @@  discard block
 block discarded – undo
287 287
 
288 288
 		// Get donor query.
289 289
 		$args   = $this->get_donor_query();
290
-		$donors = Give()->donors->get_donors( $args );
290
+		$donors = Give()->donors->get_donors($args);
291 291
 
292
-		if ( $donors ) {
292
+		if ($donors) {
293 293
 
294
-			$this->count = count( $donors );
294
+			$this->count = count($donors);
295 295
 
296
-			foreach ( $donors as $donor ) {
296
+			foreach ($donors as $donor) {
297 297
 
298
-				$user_id = ! empty( $donor->user_id ) ? absint( $donor->user_id ) : 0;
298
+				$user_id = ! empty($donor->user_id) ? absint($donor->user_id) : 0;
299 299
 
300 300
 				$data[] = array(
301 301
 					'id'            => $donor->id,
@@ -323,9 +323,9 @@  discard block
 block discarded – undo
323 323
 
324 324
 		$_donor_query['number'] = -1;
325 325
 		$_donor_query['offset'] = 0;
326
-		$donors = Give()->donors->get_donors( $_donor_query );
326
+		$donors = Give()->donors->get_donors($_donor_query);
327 327
 
328
-		return count( $donors );
328
+		return count($donors);
329 329
 	}
330 330
 
331 331
 	/**
@@ -337,10 +337,10 @@  discard block
 block discarded – undo
337 337
 	 */
338 338
 	public function get_donor_query() {
339 339
 		$paged   = $this->get_paged();
340
-		$offset  = $this->per_page * ( $paged - 1 );
340
+		$offset  = $this->per_page * ($paged - 1);
341 341
 		$search  = $this->get_search();
342
-		$order   = isset( $_GET['order'] ) ? sanitize_text_field( $_GET['order'] ) : 'DESC';
343
-		$orderby = isset( $_GET['orderby'] ) ? sanitize_text_field( $_GET['orderby'] ) : 'id';
342
+		$order   = isset($_GET['order']) ? sanitize_text_field($_GET['order']) : 'DESC';
343
+		$orderby = isset($_GET['orderby']) ? sanitize_text_field($_GET['orderby']) : 'id';
344 344
 
345 345
 		$args = array(
346 346
 			'number'  => $this->per_page,
@@ -349,10 +349,10 @@  discard block
 block discarded – undo
349 349
 			'orderby' => $orderby,
350 350
 		);
351 351
 
352
-		if( $search ) {
353
-			if ( is_email( $search ) ) {
352
+		if ($search) {
353
+			if (is_email($search)) {
354 354
 				$args['email'] = $search;
355
-			} elseif ( is_numeric( $search ) ) {
355
+			} elseif (is_numeric($search)) {
356 356
 				$args['id'] = $search;
357 357
 			} else {
358 358
 				$args['name'] = $search;
@@ -379,16 +379,16 @@  discard block
 block discarded – undo
379 379
 		$hidden   = array(); // No hidden columns
380 380
 		$sortable = $this->get_sortable_columns();
381 381
 
382
-		$this->_column_headers = array( $columns, $hidden, $sortable );
382
+		$this->_column_headers = array($columns, $hidden, $sortable);
383 383
 
384 384
 		$this->items = $this->reports_data();
385 385
 
386 386
 		$this->total = $this->get_donor_count();
387 387
 
388
-		$this->set_pagination_args( array(
388
+		$this->set_pagination_args(array(
389 389
 			'total_items' => $this->total,
390 390
 			'per_page'    => $this->per_page,
391
-			'total_pages' => ceil( $this->total / $this->per_page ),
392
-		) );
391
+			'total_pages' => ceil($this->total / $this->per_page),
392
+		));
393 393
 	}
394 394
 }
Please login to merge, or discard this patch.
includes/admin/upgrades/class-give-updates.php 1 patch
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -70,24 +70,24 @@  discard block
 block discarded – undo
70 70
 	 *
71 71
 	 * @param array $args
72 72
 	 */
73
-	public function register( $args ) {
73
+	public function register($args) {
74 74
 		$args_default = array(
75 75
 			'id'       => '',
76 76
 			'version'  => '',
77 77
 			'callback' => '',
78 78
 		);
79 79
 
80
-		$args = wp_parse_args( $args, $args_default );
80
+		$args = wp_parse_args($args, $args_default);
81 81
 
82 82
 		// You can only register database upgrade.
83 83
 		$args['type'] = 'database';
84 84
 
85 85
 		// Bailout.
86
-		if ( empty( $args['id'] ) || empty( $args['version'] ) || empty( $args['callback'] ) || ! is_callable( $args['callback'] ) ) {
86
+		if (empty($args['id']) || empty($args['version']) || empty($args['callback']) || ! is_callable($args['callback'])) {
87 87
 			return;
88 88
 		}
89 89
 
90
-		$this->updates[ $args['type'] ][] = $args;
90
+		$this->updates[$args['type']][] = $args;
91 91
 	}
92 92
 
93 93
 
@@ -102,32 +102,32 @@  discard block
 block discarded – undo
102 102
 	 *
103 103
 	 * @return array
104 104
 	 */
105
-	public function get_updates( $update_type = '', $status = 'all' ) {
105
+	public function get_updates($update_type = '', $status = 'all') {
106 106
 		// return all updates.
107
-		if ( empty( $update_type ) ) {
107
+		if (empty($update_type)) {
108 108
 			return $this->updates;
109 109
 		}
110 110
 
111 111
 		// Get specific update.
112
-		$updates = ! empty( $this->updates[ $update_type ] ) ? $this->updates[ $update_type ] : array();
112
+		$updates = ! empty($this->updates[$update_type]) ? $this->updates[$update_type] : array();
113 113
 
114 114
 		// Bailout.
115
-		if ( empty( $updates ) ) {
115
+		if (empty($updates)) {
116 116
 			return $updates;
117 117
 		}
118 118
 
119
-		switch ( $status ) {
119
+		switch ($status) {
120 120
 			case 'new':
121 121
 				// Remove already completed updates.
122 122
 				$completed_updates = give_get_completed_upgrades();
123 123
 
124
-				if ( ! empty( $completed_updates ) ) {
125
-					foreach ( $updates as $index => $update ) {
126
-						if ( in_array( $update['id'], $completed_updates ) ) {
127
-							unset( $updates[ $index ] );
124
+				if ( ! empty($completed_updates)) {
125
+					foreach ($updates as $index => $update) {
126
+						if (in_array($update['id'], $completed_updates)) {
127
+							unset($updates[$index]);
128 128
 						}
129 129
 					}
130
-					$updates = array_values( $updates );
130
+					$updates = array_values($updates);
131 131
 				}
132 132
 
133 133
 				break;
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	 * @return static
145 145
 	 */
146 146
 	static function get_instance() {
147
-		if ( is_null( self::$instance ) ) {
147
+		if (is_null(self::$instance)) {
148 148
 			self::$instance = new self();
149 149
 		}
150 150
 
@@ -162,16 +162,16 @@  discard block
 block discarded – undo
162 162
 		/**
163 163
 		 * Setup hooks.
164 164
 		 */
165
-		add_action( 'init', array( $this, '__register_upgrade' ), 9999 );
166
-		add_action( 'admin_init', array( $this, '__change_donations_label' ), 9999 );
167
-		add_action( 'admin_menu', array( $this, '__register_menu' ), 9999 );
168
-		add_action( 'give_set_upgrade_completed', array( $this, '__flush_resume_updates' ), 9999 );
169
-		add_action( 'wp_ajax_give_do_ajax_updates', array( $this, '__give_ajax_updates' ) );
165
+		add_action('init', array($this, '__register_upgrade'), 9999);
166
+		add_action('admin_init', array($this, '__change_donations_label'), 9999);
167
+		add_action('admin_menu', array($this, '__register_menu'), 9999);
168
+		add_action('give_set_upgrade_completed', array($this, '__flush_resume_updates'), 9999);
169
+		add_action('wp_ajax_give_do_ajax_updates', array($this, '__give_ajax_updates'));
170 170
 
171 171
 		/**
172 172
 		 * Load file
173 173
 		 */
174
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php';
174
+		require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php';
175 175
 	}
176 176
 
177 177
 	/**
@@ -184,12 +184,12 @@  discard block
 block discarded – undo
184 184
 		$addons         = give_get_plugins();
185 185
 		$plugin_updates = get_plugin_updates();
186 186
 
187
-		foreach ( $addons as $key => $info ) {
188
-			if ( 'active' != $info['Status'] || 'add-on' != $info['Type'] || empty( $plugin_updates[ $key ] ) ) {
187
+		foreach ($addons as $key => $info) {
188
+			if ('active' != $info['Status'] || 'add-on' != $info['Type'] || empty($plugin_updates[$key])) {
189 189
 				continue;
190 190
 			}
191 191
 
192
-			$this->updates['plugin'][] = array_merge( $info, (array) $plugin_updates[ $key ] );
192
+			$this->updates['plugin'][] = array_merge($info, (array) $plugin_updates[$key]);
193 193
 		}
194 194
 	}
195 195
 
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 	 * @access public
202 202
 	 */
203 203
 	public function __register_upgrade() {
204
-		if ( ! is_admin() ) {
204
+		if ( ! is_admin()) {
205 205
 			return;
206 206
 		}
207 207
 
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 		 *
211 211
 		 * @since 1.8.12
212 212
 		 */
213
-		do_action( 'give_register_updates', $this );
213
+		do_action('give_register_updates', $this);
214 214
 	}
215 215
 
216 216
 	/**
@@ -224,17 +224,17 @@  discard block
 block discarded – undo
224 224
 		global $submenu;
225 225
 
226 226
 		// Bailout.
227
-		if ( empty( $menu ) || ! $this->get_update_count() ) {
227
+		if (empty($menu) || ! $this->get_update_count()) {
228 228
 			return;
229 229
 		}
230 230
 
231
-		foreach ( $menu as $index => $menu_item ) {
232
-			if ( 'edit.php?post_type=give_forms' !== $menu_item[2] ) {
231
+		foreach ($menu as $index => $menu_item) {
232
+			if ('edit.php?post_type=give_forms' !== $menu_item[2]) {
233 233
 				continue;
234 234
 			}
235 235
 
236
-			$menu[ $index ][0] = sprintf(
237
-				__( 'Donations <span class="update-plugins count-%1$d"><span class="plugin-count">%1$d</span></span>', 'give' ),
236
+			$menu[$index][0] = sprintf(
237
+				__('Donations <span class="update-plugins count-%1$d"><span class="plugin-count">%1$d</span></span>', 'give'),
238 238
 				$this->get_update_count()
239 239
 			);
240 240
 
@@ -256,15 +256,15 @@  discard block
 block discarded – undo
256 256
 		// Bailout.
257 257
 		if ( ! $this->get_update_count()) {
258 258
 			// Show complete update message if still on update setting page.
259
-			if ( isset($_GET['page']) && 'give-updates' === $_GET['page'] ) {
259
+			if (isset($_GET['page']) && 'give-updates' === $_GET['page']) {
260 260
 				// Upgrades
261 261
 				add_submenu_page(
262 262
 					'edit.php?post_type=give_forms',
263
-					esc_html__( 'Give Updates Complete', 'give' ),
264
-					__( 'Updates', 'give' ),
263
+					esc_html__('Give Updates Complete', 'give'),
264
+					__('Updates', 'give'),
265 265
 					'manage_give_settings',
266 266
 					'give-updates',
267
-					array( $this, 'render_complete_page' )
267
+					array($this, 'render_complete_page')
268 268
 				);
269 269
 			}
270 270
 
@@ -274,15 +274,15 @@  discard block
 block discarded – undo
274 274
 		// Upgrades
275 275
 		add_submenu_page(
276 276
 			'edit.php?post_type=give_forms',
277
-			esc_html__( 'Give Updates', 'give' ),
277
+			esc_html__('Give Updates', 'give'),
278 278
 			sprintf(
279 279
 				'%1$s <span class="update-plugins count-%2$d"><span class="plugin-count">%2$d</span></span>',
280
-				__( 'Updates', 'give' ),
280
+				__('Updates', 'give'),
281 281
 				$this->get_update_count()
282 282
 			),
283 283
 			'manage_give_settings',
284 284
 			'give-updates',
285
-			array( $this, 'render_page' )
285
+			array($this, 'render_page')
286 286
 		);
287 287
 	}
288 288
 
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 	 * @return int
295 295
 	 */
296 296
 	public function get_db_update_count() {
297
-		return count( $this->get_updates( 'database', 'new' ) );
297
+		return count($this->get_updates('database', 'new'));
298 298
 	}
299 299
 
300 300
 	/**
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 	 * @access public
305 305
 	 */
306 306
 	public function render_complete_page() {
307
-		include_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/views/upgrades-complete.php';
307
+		include_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/views/upgrades-complete.php';
308 308
 	}
309 309
 
310 310
 	/**
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 	 * @access public
315 315
 	 */
316 316
 	public function render_page() {
317
-		include_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/views/upgrades.php';
317
+		include_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/views/upgrades.php';
318 318
 	}
319 319
 
320 320
 	/**
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 	 * @return int
326 326
 	 */
327 327
 	public function get_plugin_update_count() {
328
-		return count( $this->get_updates( 'plugin' ) );
328
+		return count($this->get_updates('plugin'));
329 329
 	}
330 330
 
331 331
 	/**
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 		$db_update_count     = $this->get_db_update_count();
341 341
 		$plugin_update_count = $this->get_plugin_update_count();
342 342
 
343
-		return ( $db_update_count + $plugin_update_count );
343
+		return ($db_update_count + $plugin_update_count);
344 344
 	}
345 345
 
346 346
 
@@ -351,12 +351,12 @@  discard block
 block discarded – undo
351 351
 	 * @access public
352 352
 	 */
353 353
 	public function __flush_resume_updates() {
354
-		delete_option( 'give_doing_upgrade' );
355
-		update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) );
354
+		delete_option('give_doing_upgrade');
355
+		update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION));
356 356
 
357 357
 		// Reset counter.
358 358
 		$this->step = $this->percentage = 0;
359
-		++ $this->update;
359
+		++$this->update;
360 360
 	}
361 361
 
362 362
 	/**
@@ -367,24 +367,24 @@  discard block
 block discarded – undo
367 367
 	 */
368 368
 	public function __give_ajax_updates() {
369 369
 		// Check permission.
370
-		if ( ! current_user_can( 'manage_give_settings' ) ) {
370
+		if ( ! current_user_can('manage_give_settings')) {
371 371
 			$this->send_ajax_response(
372 372
 				array(
373
-					'message' => esc_html__( 'You do not have permission to do Give upgrades.', 'give' ),
373
+					'message' => esc_html__('You do not have permission to do Give upgrades.', 'give'),
374 374
 				),
375 375
 				'error'
376 376
 			);
377 377
 		}
378 378
 
379 379
 		// Set params.
380
-		$this->step   = absint( $_POST['step'] );
381
-		$this->update = absint( $_POST['update'] );
380
+		$this->step   = absint($_POST['step']);
381
+		$this->update = absint($_POST['update']);
382 382
 
383 383
 		// Bailout: step and update must be positive and greater then zero.
384
-		if ( ! $this->step ) {
384
+		if ( ! $this->step) {
385 385
 			$this->send_ajax_response(
386 386
 				array(
387
-					'message'    => __( 'Please reload this page  and try again', 'give' ),
387
+					'message'    => __('Please reload this page  and try again', 'give'),
388 388
 					'heading'    => '',
389 389
 					'percentage' => 0,
390 390
 				),
@@ -393,14 +393,14 @@  discard block
 block discarded – undo
393 393
 		}
394 394
 
395 395
 		// Get updates.
396
-		$updates = $this->get_updates( 'database', 'new' );
396
+		$updates = $this->get_updates('database', 'new');
397 397
 
398 398
 		// Bailout if we do not have nay updates.
399
-		if ( empty( $updates ) ) {
399
+		if (empty($updates)) {
400 400
 			$this->send_ajax_response(
401 401
 				array(
402
-					'message'    => __( 'The database is already up to date.', 'give' ),
403
-					'heading'    => __( 'Updates Completed.', 'give' ),
402
+					'message'    => __('The database is already up to date.', 'give'),
403
+					'heading'    => __('Updates Completed.', 'give'),
404 404
 					'percentage' => 0,
405 405
 				),
406 406
 				'success'
@@ -408,26 +408,26 @@  discard block
 block discarded – undo
408 408
 		}
409 409
 
410 410
 		// Process update.
411
-		foreach ( $updates as $index => $update ) {
411
+		foreach ($updates as $index => $update) {
412 412
 			// Check if update depend upon any other update.
413
-			if ( ! empty( $update['depend'] ) && ! give_has_upgrade_completed( $update['depend'] ) ) {
413
+			if ( ! empty($update['depend']) && ! give_has_upgrade_completed($update['depend'])) {
414 414
 				continue;
415 415
 			}
416 416
 
417 417
 			// Run update.
418
-			if ( is_array( $update['callback'] ) ) {
418
+			if (is_array($update['callback'])) {
419 419
 				$update['callback'][0]->$update['callback'][1]();
420 420
 			} else {
421 421
 				$update['callback']();
422 422
 			}
423 423
 
424 424
 			// Check if current update completed or not.
425
-			if ( give_has_upgrade_completed( $update['id'] ) ) {
426
-				if ( 1 === count( $updates ) ) {
425
+			if (give_has_upgrade_completed($update['id'])) {
426
+				if (1 === count($updates)) {
427 427
 					$this->send_ajax_response(
428 428
 						array(
429
-							'message'    => __( 'Database updated successfully.', 'give' ),
430
-							'heading'    => __( 'Updates Completed.', 'give' ),
429
+							'message'    => __('Database updated successfully.', 'give'),
430
+							'heading'    => __('Updates Completed.', 'give'),
431 431
 							'percentage' => 0,
432 432
 						),
433 433
 						'success'
@@ -437,16 +437,16 @@  discard block
 block discarded – undo
437 437
 
438 438
 			$doing_upgrade_args = array(
439 439
 				'update_info' => $update,
440
-				'step'        => ++ $this->step,
440
+				'step'        => ++$this->step,
441 441
 				'update'      => $this->update,
442
-				'heading'     => sprintf( 'Update %s of {update_count}', $this->update ),
442
+				'heading'     => sprintf('Update %s of {update_count}', $this->update),
443 443
 				'percentage'  => $this->percentage,
444 444
 			);
445 445
 
446 446
 			// Cache upgrade.
447
-			update_option( 'give_doing_upgrade', $doing_upgrade_args );
447
+			update_option('give_doing_upgrade', $doing_upgrade_args);
448 448
 
449
-			$this->send_ajax_response( $doing_upgrade_args );
449
+			$this->send_ajax_response($doing_upgrade_args);
450 450
 		}// End foreach().
451 451
 	}
452 452
 
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
 	 * @param        $data
460 460
 	 * @param string $type
461 461
 	 */
462
-	public function send_ajax_response( $data, $type = '' ) {
462
+	public function send_ajax_response($data, $type = '') {
463 463
 		$default = array(
464 464
 			'message'    => '',
465 465
 			'heading'    => '',
@@ -469,21 +469,21 @@  discard block
 block discarded – undo
469 469
 		);
470 470
 
471 471
 		// Set data.
472
-		$data = wp_parse_args( $data, $default );
472
+		$data = wp_parse_args($data, $default);
473 473
 
474
-		switch ( $type ) {
474
+		switch ($type) {
475 475
 			case 'success':
476
-				wp_send_json_success( $data );
476
+				wp_send_json_success($data);
477 477
 				break;
478 478
 
479 479
 			case 'error':
480
-				wp_send_json_error( $data );
480
+				wp_send_json_error($data);
481 481
 				break;
482 482
 
483 483
 			default:
484
-				wp_send_json( array(
484
+				wp_send_json(array(
485 485
 					'data' => $data,
486
-				) );
486
+				));
487 487
 				break;
488 488
 		}
489 489
 	}
@@ -500,8 +500,8 @@  discard block
 block discarded – undo
500 500
 	public function resume_updates() {
501 501
 		$status = false;
502 502
 
503
-		if ( $update = get_option( 'give_doing_upgrade' ) ) {
504
-			$status = ! empty( $update['step'] ) ? $update['step'] : $status;
503
+		if ($update = get_option('give_doing_upgrade')) {
504
+			$status = ! empty($update['step']) ? $update['step'] : $status;
505 505
 		}
506 506
 
507 507
 		return $status;
@@ -517,12 +517,12 @@  discard block
 block discarded – undo
517 517
 	 * @param $total
518 518
 	 * @param $current_total
519 519
 	 */
520
-	public function set_percentage( $total, $current_total ) {
520
+	public function set_percentage($total, $current_total) {
521 521
 		// Set percentage.
522
-		$this->percentage = $total ? ( ( $current_total ) / $total ) * 100 : 0;
522
+		$this->percentage = $total ? (($current_total) / $total) * 100 : 0;
523 523
 
524 524
 		// Verify percentage.
525
-		$this->percentage = ( 100 < $this->percentage ) ? 100 : $this->percentage;
525
+		$this->percentage = (100 < $this->percentage) ? 100 : $this->percentage;
526 526
 	}
527 527
 }
528 528
 
Please login to merge, or discard this patch.
includes/admin/donors/donors.php 1 patch
Spacing   +164 added lines, -164 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,9 +24,9 @@  discard block
 block discarded – undo
24 24
  */
25 25
 function give_donors_page() {
26 26
 	$default_views  = give_donor_views();
27
-	$requested_view = isset( $_GET['view'] ) ? sanitize_text_field( $_GET['view'] ) : 'donors';
28
-	if ( array_key_exists( $requested_view, $default_views ) && function_exists( $default_views[ $requested_view ] ) ) {
29
-		give_render_donor_view( $requested_view, $default_views );
27
+	$requested_view = isset($_GET['view']) ? sanitize_text_field($_GET['view']) : 'donors';
28
+	if (array_key_exists($requested_view, $default_views) && function_exists($default_views[$requested_view])) {
29
+		give_render_donor_view($requested_view, $default_views);
30 30
 	} else {
31 31
 		give_donors_list();
32 32
 	}
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 
43 43
 	$views = array();
44 44
 
45
-	return apply_filters( 'give_donor_views', $views );
45
+	return apply_filters('give_donor_views', $views);
46 46
 
47 47
 }
48 48
 
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 
57 57
 	$tabs = array();
58 58
 
59
-	return apply_filters( 'give_donor_tabs', $tabs );
59
+	return apply_filters('give_donor_tabs', $tabs);
60 60
 
61 61
 }
62 62
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
  * @return void
68 68
  */
69 69
 function give_donors_list() {
70
-	include dirname( __FILE__ ) . '/class-donor-table.php';
70
+	include dirname(__FILE__).'/class-donor-table.php';
71 71
 
72 72
 	$donors_table = new Give_Donor_List_Table();
73 73
 	$donors_table->prepare_items();
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
 		 *
81 81
 		 * @since 1.0
82 82
 		 */
83
-		do_action( 'give_donors_table_top' );
83
+		do_action('give_donors_table_top');
84 84
 		?>
85
-		<form id="give-donors-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors' ); ?>">
85
+		<form id="give-donors-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors'); ?>">
86 86
 			<?php
87
-			$donors_table->search_box( esc_html__( 'Search Donors', 'give' ), 'give-donors' );
87
+			$donors_table->search_box(esc_html__('Search Donors', 'give'), 'give-donors');
88 88
 			$donors_table->display();
89 89
 			?>
90 90
 			<input type="hidden" name="post_type" value="give_forms" />
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 		 *
98 98
 		 * @since 1.0
99 99
 		 */
100
-		do_action( 'give_donors_table_bottom' );
100
+		do_action('give_donors_table_bottom');
101 101
 		?>
102 102
 	</div>
103 103
 	<?php
@@ -113,27 +113,27 @@  discard block
 block discarded – undo
113 113
  *
114 114
  * @return void
115 115
  */
116
-function give_render_donor_view( $view, $callbacks ) {
116
+function give_render_donor_view($view, $callbacks) {
117 117
 
118 118
 	$render = true;
119 119
 
120
-	$donor_view_role = apply_filters( 'give_view_donors_role', 'view_give_reports' );
120
+	$donor_view_role = apply_filters('give_view_donors_role', 'view_give_reports');
121 121
 
122
-	if ( ! current_user_can( $donor_view_role ) ) {
123
-		give_set_error( 'give-no-access', __( 'You are not permitted to view this data.', 'give' ) );
122
+	if ( ! current_user_can($donor_view_role)) {
123
+		give_set_error('give-no-access', __('You are not permitted to view this data.', 'give'));
124 124
 		$render = false;
125 125
 	}
126 126
 
127
-	if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
128
-		give_set_error( 'give-invalid_donor', __( 'Invalid Donor ID.', 'give' ) );
127
+	if ( ! isset($_GET['id']) || ! is_numeric($_GET['id'])) {
128
+		give_set_error('give-invalid_donor', __('Invalid Donor ID.', 'give'));
129 129
 		$render = false;
130 130
 	}
131 131
 
132 132
 	$donor_id = (int) $_GET['id'];
133
-	$donor    = new Give_Donor( $donor_id );
133
+	$donor    = new Give_Donor($donor_id);
134 134
 
135
-	if ( empty( $donor->id ) ) {
136
-		give_set_error( 'give-invalid_donor', __( 'Invalid Donor ID.', 'give' ) );
135
+	if (empty($donor->id)) {
136
+		give_set_error('give-invalid_donor', __('Invalid Donor ID.', 'give'));
137 137
 		$render = false;
138 138
 	}
139 139
 
@@ -142,34 +142,34 @@  discard block
 block discarded – undo
142 142
 
143 143
 	<div class='wrap'>
144 144
 
145
-		<?php if ( give_get_errors() ) : ?>
145
+		<?php if (give_get_errors()) : ?>
146 146
 			<div class="error settings-error">
147
-				<?php Give()->notices->render_frontend_notices( 0 ); ?>
147
+				<?php Give()->notices->render_frontend_notices(0); ?>
148 148
 			</div>
149 149
 		<?php endif; ?>
150 150
 
151
-		<h1 class="screen-reader-text"><?php esc_html_e( 'Donor', 'give' ); ?></h1>
151
+		<h1 class="screen-reader-text"><?php esc_html_e('Donor', 'give'); ?></h1>
152 152
 
153
-		<?php if ( $donor && $render ) : ?>
153
+		<?php if ($donor && $render) : ?>
154 154
 
155 155
 			<h2 class="nav-tab-wrapper">
156 156
 			<?php
157
-			foreach ( $donor_tabs as $key => $tab ) :
157
+			foreach ($donor_tabs as $key => $tab) :
158 158
 				$active = $key === $view ? true : false;
159 159
 				$class = $active ? 'nav-tab nav-tab-active' : 'nav-tab';
160 160
 				printf(
161
-					'<a href="%1$s" class="%2$s"><span class="dashicons %3$s"></span>%4$s</a>' . "\n",
162
-					esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=' . $key . '&id=' . $donor->id ) ),
163
-					esc_attr( $class ),
164
-					sanitize_html_class( $tab['dashicon'] ),
165
-					esc_html( $tab['title'] )
161
+					'<a href="%1$s" class="%2$s"><span class="dashicons %3$s"></span>%4$s</a>'."\n",
162
+					esc_url(admin_url('edit.php?post_type=give_forms&page=give-donors&view='.$key.'&id='.$donor->id)),
163
+					esc_attr($class),
164
+					sanitize_html_class($tab['dashicon']),
165
+					esc_html($tab['title'])
166 166
 				);
167 167
 			endforeach;
168 168
 			?>
169 169
 			</h2>
170 170
 
171 171
 			<div id="give-donor-card-wrapper">
172
-				<?php $callbacks[ $view ]( $donor ) ?>
172
+				<?php $callbacks[$view]($donor) ?>
173 173
 			</div>
174 174
 
175 175
 		<?php endif; ?>
@@ -189,9 +189,9 @@  discard block
 block discarded – undo
189 189
  *
190 190
  * @return void
191 191
  */
192
-function give_donor_view( $donor ) {
192
+function give_donor_view($donor) {
193 193
 
194
-	$donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' );
194
+	$donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments');
195 195
 
196 196
 	/**
197 197
 	 * Fires in donor profile screen, above the donor card.
@@ -200,32 +200,32 @@  discard block
 block discarded – undo
200 200
 	 *
201 201
 	 * @param object $donor The donor object being displayed.
202 202
 	 */
203
-	do_action( 'give_donor_card_top', $donor );
203
+	do_action('give_donor_card_top', $donor);
204 204
 	?>
205 205
 
206 206
 	<div id="donor-summary" class="info-wrapper donor-section postbox">
207 207
 
208
-		<form id="edit-donor-info" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ); ?>">
208
+		<form id="edit-donor-info" method="post" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id); ?>">
209 209
 
210 210
 			<div class="donor-info">
211 211
 
212 212
 				<div class="donor-bio-header clearfix">
213 213
 
214 214
 					<div class="avatar-wrap left" id="donor-avatar">
215
-						<?php echo get_avatar( $donor->email ); ?>
215
+						<?php echo get_avatar($donor->email); ?>
216 216
 					</div>
217 217
 
218 218
 					<div id="donor-name-wrap" class="left">
219 219
 						<span class="donor-id">#<?php echo $donor->id; ?></span>
220
-						<span class="donor-name info-item edit-item"><input size="15" data-key="name" name="customerinfo[name]" type="text" value="<?php echo esc_attr( $donor->name ); ?>" placeholder="<?php esc_attr_e( 'Donor Name', 'give' ); ?>" /></span>
220
+						<span class="donor-name info-item edit-item"><input size="15" data-key="name" name="customerinfo[name]" type="text" value="<?php echo esc_attr($donor->name); ?>" placeholder="<?php esc_attr_e('Donor Name', 'give'); ?>" /></span>
221 221
 						<span class="donor-name info-item editable"><span data-key="name"><?php echo $donor->name; ?></span></span>
222 222
 					</div>
223 223
 					<p class="donor-since info-item">
224
-						<?php esc_html_e( 'Donor since', 'give' ); ?>
225
-						<?php echo date_i18n( give_date_format(), strtotime( $donor->date_created ) ) ?>
224
+						<?php esc_html_e('Donor since', 'give'); ?>
225
+						<?php echo date_i18n(give_date_format(), strtotime($donor->date_created)) ?>
226 226
 					</p>
227
-					<?php if ( current_user_can( $donor_edit_role ) ) : ?>
228
-						<a href="#" id="edit-donor" class="button info-item editable donor-edit-link"><?php esc_html_e( 'Edit Donor', 'give' ); ?></a>
227
+					<?php if (current_user_can($donor_edit_role)) : ?>
228
+						<a href="#" id="edit-donor" class="button info-item editable donor-edit-link"><?php esc_html_e('Edit Donor', 'give'); ?></a>
229 229
 					<?php endif; ?>
230 230
 				</div>
231 231
 				<!-- /donor-bio-header -->
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 					<table class="widefat">
236 236
 						<tbody>
237 237
 						<tr class="alternate">
238
-							<th scope="col"><label for="tablecell"><?php esc_html_e( 'User:', 'give' ); ?></label></th>
238
+							<th scope="col"><label for="tablecell"><?php esc_html_e('User:', 'give'); ?></label></th>
239 239
 							<td>
240 240
 								<span class="donor-user-id info-item edit-item">
241 241
 									<?php
@@ -252,37 +252,37 @@  discard block
 block discarded – undo
252 252
 										'data'  => $data_atts,
253 253
 									);
254 254
 
255
-									if ( ! empty( $user_id ) ) {
256
-										$userdata           = get_userdata( $user_id );
255
+									if ( ! empty($user_id)) {
256
+										$userdata = get_userdata($user_id);
257 257
 										$user_args['selected'] = $user_id;
258 258
 									}
259 259
 
260
-									echo Give()->html->ajax_user_search( $user_args );
260
+									echo Give()->html->ajax_user_search($user_args);
261 261
 									?>
262 262
 								</span>
263 263
 
264 264
 								<span class="donor-user-id info-item editable">
265
-									<?php if ( ! empty( $userdata ) ) { ?>
266
-										<span data-key="user_id">#<?php echo $donor->user_id . ' - ' . $userdata->display_name; ?></span>
265
+									<?php if ( ! empty($userdata)) { ?>
266
+										<span data-key="user_id">#<?php echo $donor->user_id.' - '.$userdata->display_name; ?></span>
267 267
 									<?php } else { ?>
268
-										<span data-key="user_id"><?php esc_html_e( 'None', 'give' ); ?></span>
268
+										<span data-key="user_id"><?php esc_html_e('None', 'give'); ?></span>
269 269
 									<?php } ?>
270
-									<?php if ( current_user_can( $donor_edit_role ) && intval( $donor->user_id ) > 0 ) { ?>
271
-										<span class="disconnect-user"> - <a id="disconnect-donor" href="#disconnect" aria-label="<?php esc_attr_e( 'Disconnects the current user ID from this donor record.', 'give' ); ?>"><?php esc_html_e( 'Disconnect User', 'give' ); ?></a></span>
270
+									<?php if (current_user_can($donor_edit_role) && intval($donor->user_id) > 0) { ?>
271
+										<span class="disconnect-user"> - <a id="disconnect-donor" href="#disconnect" aria-label="<?php esc_attr_e('Disconnects the current user ID from this donor record.', 'give'); ?>"><?php esc_html_e('Disconnect User', 'give'); ?></a></span>
272 272
 									<?php } ?>
273 273
 								</span>
274 274
 							</td>
275 275
 						</tr>
276
-						<?php if ( isset( $donor->user_id ) && $donor->user_id > 0 ) : ?>
276
+						<?php if (isset($donor->user_id) && $donor->user_id > 0) : ?>
277 277
 
278 278
 							<tr>
279
-								<th scope="col"><?php esc_html_e( 'Address:', 'give' ); ?></th>
279
+								<th scope="col"><?php esc_html_e('Address:', 'give'); ?></th>
280 280
 								<td class="row-title">
281 281
 
282 282
 									<div class="donor-address-wrapper">
283 283
 
284 284
 										<?php
285
-										$address  = get_user_meta( $donor->user_id, '_give_user_address', true );
285
+										$address  = get_user_meta($donor->user_id, '_give_user_address', true);
286 286
 										$defaults = array(
287 287
 											'line1'   => '',
288 288
 											'line2'   => '',
@@ -292,10 +292,10 @@  discard block
 block discarded – undo
292 292
 											'zip'     => '',
293 293
 										);
294 294
 
295
-										$address = wp_parse_args( $address, $defaults );
295
+										$address = wp_parse_args($address, $defaults);
296 296
 										?>
297 297
 
298
-										<?php if ( ! empty( $address ) ) { ?>
298
+										<?php if ( ! empty($address)) { ?>
299 299
 											<span class="donor-address info-item editable">
300 300
 												<span class="info-item" data-key="line1"><?php echo $address['line1']; ?></span>
301 301
 												<span class="info-item" data-key="line2"><?php echo $address['line2']; ?></span>
@@ -306,43 +306,43 @@  discard block
 block discarded – undo
306 306
 											</span>
307 307
 										<?php } ?>
308 308
 										<span class="donor-address info-item edit-item">
309
-											<input class="info-item" type="text" data-key="line1" name="customerinfo[line1]" placeholder="<?php esc_attr_e( 'Address 1', 'give' ); ?>" value="<?php echo $address['line1']; ?>" />
310
-											<input class="info-item" type="text" data-key="line2" name="customerinfo[line2]" placeholder="<?php esc_attr_e( 'Address 2', 'give' ); ?>" value="<?php echo $address['line2']; ?>" />
311
-											<input class="info-item" type="text" data-key="city" name="customerinfo[city]" placeholder="<?php esc_attr_e( 'City', 'give' ); ?>" value="<?php echo $address['city']; ?>" />
309
+											<input class="info-item" type="text" data-key="line1" name="customerinfo[line1]" placeholder="<?php esc_attr_e('Address 1', 'give'); ?>" value="<?php echo $address['line1']; ?>" />
310
+											<input class="info-item" type="text" data-key="line2" name="customerinfo[line2]" placeholder="<?php esc_attr_e('Address 2', 'give'); ?>" value="<?php echo $address['line2']; ?>" />
311
+											<input class="info-item" type="text" data-key="city" name="customerinfo[city]" placeholder="<?php esc_attr_e('City', 'give'); ?>" value="<?php echo $address['city']; ?>" />
312 312
 											<select data-key="country" name="customerinfo[country]" id="billing_country" class="billing_country give-select edit-item">
313 313
 												<?php
314 314
 
315 315
 												$selected_country = $address['country'];
316 316
 
317 317
 												$countries = give_get_country_list();
318
-												foreach ( $countries as $country_code => $country ) {
319
-													echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>';
318
+												foreach ($countries as $country_code => $country) {
319
+													echo '<option value="'.esc_attr($country_code).'"'.selected($country_code, $selected_country, false).'>'.$country.'</option>';
320 320
 												}
321 321
 												?>
322 322
 											</select>
323 323
 											<?php
324 324
 											$selected_state = give_get_state();
325
-											$states         = give_get_states( $selected_country );
325
+											$states         = give_get_states($selected_country);
326 326
 
327
-											$selected_state = isset( $address['state'] ) ? $address['state'] : $selected_state;
327
+											$selected_state = isset($address['state']) ? $address['state'] : $selected_state;
328 328
 
329
-											if ( ! empty( $states ) ) {
329
+											if ( ! empty($states)) {
330 330
 												?>
331 331
 												<select data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-select info-item">
332 332
 													<?php
333
-													foreach ( $states as $state_code => $state ) {
334
-														echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>';
333
+													foreach ($states as $state_code => $state) {
334
+														echo '<option value="'.$state_code.'"'.selected($state_code, $selected_state, false).'>'.$state.'</option>';
335 335
 													}
336 336
 													?>
337 337
 												</select>
338 338
 												<?php
339 339
 											} else {
340 340
 												?>
341
-												<input type="text" size="6" data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-input info-item" placeholder="<?php esc_attr_e( 'State / Province / County', 'give' ); ?>" />
341
+												<input type="text" size="6" data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-input info-item" placeholder="<?php esc_attr_e('State / Province / County', 'give'); ?>" />
342 342
 												<?php
343 343
 											}
344 344
 											?>
345
-											<input class="info-item" type="text" data-key="zip" name="customerinfo[zip]" placeholder="<?php esc_attr_e( 'Zip / Postal Code', 'give' ); ?>" value="<?php echo $address['zip']; ?>" />
345
+											<input class="info-item" type="text" data-key="zip" name="customerinfo[zip]" placeholder="<?php esc_attr_e('Zip / Postal Code', 'give'); ?>" value="<?php echo $address['zip']; ?>" />
346 346
 										</span>
347 347
 
348 348
 									</div>
@@ -358,10 +358,10 @@  discard block
 block discarded – undo
358 358
 
359 359
 			<span id="donor-edit-actions" class="edit-item">
360 360
 				<input type="hidden" data-key="id" name="customerinfo[id]" value="<?php echo $donor->id; ?>" />
361
-				<?php wp_nonce_field( 'edit-donor', '_wpnonce', false, true ); ?>
361
+				<?php wp_nonce_field('edit-donor', '_wpnonce', false, true); ?>
362 362
 				<input type="hidden" name="give_action" value="edit-donor" />
363
-				<input type="submit" id="give-edit-donor-save" class="button-secondary" value="<?php esc_attr_e( 'Update Donor', 'give' ); ?>" />
364
-				<a id="give-edit-donor-cancel" href="" class="delete"><?php esc_html_e( 'Cancel', 'give' ); ?></a>
363
+				<input type="submit" id="give-edit-donor-save" class="button-secondary" value="<?php esc_attr_e('Update Donor', 'give'); ?>" />
364
+				<a id="give-edit-donor-cancel" href="" class="delete"><?php esc_html_e('Cancel', 'give'); ?></a>
365 365
 			</span>
366 366
 
367 367
 		</form>
@@ -376,24 +376,24 @@  discard block
 block discarded – undo
376 376
 	 *
377 377
 	 * @param object $donor The donor object being displayed.
378 378
 	 */
379
-	do_action( 'give_donor_before_stats', $donor );
379
+	do_action('give_donor_before_stats', $donor);
380 380
 	?>
381 381
 
382 382
 	<div id="donor-stats-wrapper" class="donor-section postbox clear">
383 383
 		<ul>
384 384
 			<li>
385
-				<a href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&donor=' . absint( $donor->id ) ); ?>">
385
+				<a href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history&donor='.absint($donor->id)); ?>">
386 386
 					<span class="dashicons dashicons-heart"></span>
387 387
 					<?php
388 388
 					// Completed Donations
389
-					$completed_donations_text = sprintf( _n( '%d Completed Donation', '%d Completed Donations', $donor->purchase_count, 'give' ), $donor->purchase_count );
390
-					echo apply_filters( 'give_donor_completed_donations', $completed_donations_text, $donor );
389
+					$completed_donations_text = sprintf(_n('%d Completed Donation', '%d Completed Donations', $donor->purchase_count, 'give'), $donor->purchase_count);
390
+					echo apply_filters('give_donor_completed_donations', $completed_donations_text, $donor);
391 391
 					?>
392 392
 				</a>
393 393
 			</li>
394 394
 			<li>
395 395
 				<span class="dashicons dashicons-chart-area"></span>
396
-				<?php echo give_currency_filter( give_format_amount( $donor->purchase_value, array( 'sanitize' => false ) ) ); ?> <?php esc_html_e( 'Lifetime Donations', 'give' ); ?>
396
+				<?php echo give_currency_filter(give_format_amount($donor->purchase_value, array('sanitize' => false))); ?> <?php esc_html_e('Lifetime Donations', 'give'); ?>
397 397
 			</li>
398 398
 			<?php
399 399
 			/**
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 			 *
406 406
 			 * @param object $donor The donor object being displayed.
407 407
 			 */
408
-			do_action( 'give_donor_stats_list', $donor );
408
+			do_action('give_donor_stats_list', $donor);
409 409
 			?>
410 410
 		</ul>
411 411
 	</div>
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 	 *
419 419
 	 * @param object $donor The donor object being displayed.
420 420
 	 */
421
-	do_action( 'give_donor_before_tables_wrapper', $donor );
421
+	do_action('give_donor_before_tables_wrapper', $donor);
422 422
 	?>
423 423
 
424 424
 	<div id="donor-tables-wrapper" class="donor-section">
@@ -431,46 +431,46 @@  discard block
 block discarded – undo
431 431
 		 *
432 432
 		 * @param object $donor The donor object being displayed.
433 433
 		 */
434
-		do_action( 'give_donor_before_tables', $donor );
434
+		do_action('give_donor_before_tables', $donor);
435 435
 		?>
436 436
 
437
-		<h3><?php _e( 'Donor Emails', 'give' ); ?></h3>
437
+		<h3><?php _e('Donor Emails', 'give'); ?></h3>
438 438
 
439 439
 		<table class="wp-list-table widefat striped emails">
440 440
 			<thead>
441 441
 				<tr>
442
-					<th><?php _e( 'Email', 'give' ); ?></th>
443
-					<th><?php _e( 'Actions', 'give' ); ?></th>
442
+					<th><?php _e('Email', 'give'); ?></th>
443
+					<th><?php _e('Actions', 'give'); ?></th>
444 444
 				</tr>
445 445
 			</thead>
446 446
 
447 447
 			<tbody>
448
-				<?php if ( ! empty( $donor->emails ) ) { ?>
448
+				<?php if ( ! empty($donor->emails)) { ?>
449 449
 
450
-					<?php foreach ( $donor->emails as $key => $email ) : ?>
450
+					<?php foreach ($donor->emails as $key => $email) : ?>
451 451
 						<tr data-key="<?php echo $key; ?>">
452 452
 							<td>
453 453
 								<?php echo $email; ?>
454
-								<?php if ( 'primary' === $key ) : ?>
454
+								<?php if ('primary' === $key) : ?>
455 455
 									<span class="dashicons dashicons-star-filled primary-email-icon"></span>
456 456
 								<?php endif; ?>
457 457
 							</td>
458 458
 							<td>
459
-								<?php if ( 'primary' !== $key ) : ?>
459
+								<?php if ('primary' !== $key) : ?>
460 460
 									<?php
461
-									$base_url    = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id );
462
-									$promote_url = wp_nonce_url( add_query_arg( array(
463
-										'email' => rawurlencode( $email ),
461
+									$base_url    = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id);
462
+									$promote_url = wp_nonce_url(add_query_arg(array(
463
+										'email' => rawurlencode($email),
464 464
 										'give_action' => 'set_donor_primary_email',
465
-									), $base_url ), 'give-set-donor-primary-email' );
466
-									$remove_url  = wp_nonce_url( add_query_arg( array(
467
-										'email' => rawurlencode( $email ),
465
+									), $base_url), 'give-set-donor-primary-email');
466
+									$remove_url = wp_nonce_url(add_query_arg(array(
467
+										'email' => rawurlencode($email),
468 468
 										'give_action' => 'remove_donor_email',
469
-									), $base_url ), 'give-remove-donor-email' );
469
+									), $base_url), 'give-remove-donor-email');
470 470
 									?>
471
-									<a href="<?php echo $promote_url; ?>"><?php _e( 'Make Primary', 'give' ); ?></a>
471
+									<a href="<?php echo $promote_url; ?>"><?php _e('Make Primary', 'give'); ?></a>
472 472
 									&nbsp;|&nbsp;
473
-									<a href="<?php echo $remove_url; ?>" class="delete"><?php _e( 'Remove', 'give' ); ?></a>
473
+									<a href="<?php echo $remove_url; ?>" class="delete"><?php _e('Remove', 'give'); ?></a>
474 474
 								<?php endif; ?>
475 475
 							</td>
476 476
 						</tr>
@@ -480,59 +480,59 @@  discard block
 block discarded – undo
480 480
 						<td colspan="2" class="add-donor-email-td">
481 481
 							<div class="add-donor-email-wrapper">
482 482
 								<input type="hidden" name="donor-id" value="<?php echo $donor->id; ?>" />
483
-								<?php wp_nonce_field( 'give_add_donor_email', 'add_email_nonce', false, true ); ?>
484
-								<input type="email" name="additional-email" value="" placeholder="<?php _e( 'Email Address', 'give' ); ?>" />&nbsp;
485
-								<input type="checkbox" name="make-additional-primary" value="1" id="make-additional-primary" />&nbsp;<label for="make-additional-primary"><?php _e( 'Make Primary', 'give' ); ?></label>
486
-								<button class="button-secondary give-add-donor-email" id="add-donor-email"><?php _e( 'Add Email', 'give' ); ?></button>
483
+								<?php wp_nonce_field('give_add_donor_email', 'add_email_nonce', false, true); ?>
484
+								<input type="email" name="additional-email" value="" placeholder="<?php _e('Email Address', 'give'); ?>" />&nbsp;
485
+								<input type="checkbox" name="make-additional-primary" value="1" id="make-additional-primary" />&nbsp;<label for="make-additional-primary"><?php _e('Make Primary', 'give'); ?></label>
486
+								<button class="button-secondary give-add-donor-email" id="add-donor-email"><?php _e('Add Email', 'give'); ?></button>
487 487
 								<span class="spinner"></span>
488 488
 							</div>
489 489
 							<div class="notice-wrap"></div>
490 490
 						</td>
491 491
 					</tr>
492 492
 				<?php } else { ?>
493
-					<tr><td colspan="2"><?php _e( 'No Emails Found', 'give' ); ?></td></tr>
493
+					<tr><td colspan="2"><?php _e('No Emails Found', 'give'); ?></td></tr>
494 494
 				<?php }// End if().
495 495
 	?>
496 496
 			</tbody>
497 497
 		</table>
498 498
 
499
-		<h3><?php esc_html_e( 'Recent Donations', 'give' ); ?></h3>
499
+		<h3><?php esc_html_e('Recent Donations', 'give'); ?></h3>
500 500
 		<?php
501
-		$payment_ids = explode( ',', $donor->payment_ids );
502
-		$payments    = give_get_payments( array(
501
+		$payment_ids = explode(',', $donor->payment_ids);
502
+		$payments    = give_get_payments(array(
503 503
 			'post__in' => $payment_ids,
504
-		) );
505
-		$payments    = array_slice( $payments, 0, 10 );
504
+		));
505
+		$payments    = array_slice($payments, 0, 10);
506 506
 		?>
507 507
 		<table class="wp-list-table widefat striped payments">
508 508
 			<thead>
509 509
 			<tr>
510
-				<th scope="col"><?php esc_html_e( 'ID', 'give' ); ?></th>
511
-				<th scope="col"><?php esc_html_e( 'Amount', 'give' ); ?></th>
512
-				<th scope="col"><?php esc_html_e( 'Date', 'give' ); ?></th>
513
-				<th scope="col"><?php esc_html_e( 'Status', 'give' ); ?></th>
514
-				<th scope="col"><?php esc_html_e( 'Actions', 'give' ); ?></th>
510
+				<th scope="col"><?php esc_html_e('ID', 'give'); ?></th>
511
+				<th scope="col"><?php esc_html_e('Amount', 'give'); ?></th>
512
+				<th scope="col"><?php esc_html_e('Date', 'give'); ?></th>
513
+				<th scope="col"><?php esc_html_e('Status', 'give'); ?></th>
514
+				<th scope="col"><?php esc_html_e('Actions', 'give'); ?></th>
515 515
 			</tr>
516 516
 			</thead>
517 517
 			<tbody>
518
-			<?php if ( ! empty( $payments ) ) { ?>
519
-				<?php foreach ( $payments as $payment ) : ?>
518
+			<?php if ( ! empty($payments)) { ?>
519
+				<?php foreach ($payments as $payment) : ?>
520 520
 					<tr>
521 521
 						<td><?php echo $payment->ID; ?></td>
522
-						<td><?php echo give_payment_amount( $payment->ID ); ?></td>
523
-						<td><?php echo date_i18n( give_date_format(), strtotime( $payment->post_date ) ); ?></td>
524
-						<td><?php echo give_get_payment_status( $payment, true ); ?></td>
522
+						<td><?php echo give_payment_amount($payment->ID); ?></td>
523
+						<td><?php echo date_i18n(give_date_format(), strtotime($payment->post_date)); ?></td>
524
+						<td><?php echo give_get_payment_status($payment, true); ?></td>
525 525
 						<td>
526 526
 							<?php
527 527
 							printf(
528 528
 								'<a href="%1$s" aria-label="%2$s">%3$s</a>',
529
-								admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $payment->ID ),
529
+								admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id='.$payment->ID),
530 530
 								sprintf(
531 531
 									/* translators: %s: Donation ID */
532
-									esc_attr__( 'View Donation %s.', 'give' ),
532
+									esc_attr__('View Donation %s.', 'give'),
533 533
 									$payment->ID
534 534
 								),
535
-								esc_html__( 'View Donation', 'give' )
535
+								esc_html__('View Donation', 'give')
536 536
 							);
537 537
 							?>
538 538
 
@@ -547,47 +547,47 @@  discard block
 block discarded – undo
547 547
 							 * @param object $donor The donor object being displayed.
548 548
 							 * @param object $payment  The payment object being displayed.
549 549
 							 */
550
-							do_action( 'give_donor_recent_purchases_actions', $donor, $payment );
550
+							do_action('give_donor_recent_purchases_actions', $donor, $payment);
551 551
 							?>
552 552
 						</td>
553 553
 					</tr>
554 554
 				<?php endforeach; ?>
555 555
 			<?php } else { ?>
556 556
 				<tr>
557
-					<td colspan="5"><?php esc_html_e( 'No donations found.', 'give' ); ?></td>
557
+					<td colspan="5"><?php esc_html_e('No donations found.', 'give'); ?></td>
558 558
 				</tr>
559 559
 			<?php }// End if().
560 560
 	?>
561 561
 			</tbody>
562 562
 		</table>
563 563
 
564
-		<h3><?php esc_html_e( 'Completed Forms', 'give' ); ?></h3>
564
+		<h3><?php esc_html_e('Completed Forms', 'give'); ?></h3>
565 565
 		<?php
566
-		$donations = give_get_users_completed_donations( $donor->email );
566
+		$donations = give_get_users_completed_donations($donor->email);
567 567
 		?>
568 568
 		<table class="wp-list-table widefat striped donations">
569 569
 			<thead>
570 570
 			<tr>
571
-				<th scope="col"><?php esc_html_e( 'Form', 'give' ); ?></th>
572
-				<th scope="col" width="120px"><?php esc_html_e( 'Actions', 'give' ); ?></th>
571
+				<th scope="col"><?php esc_html_e('Form', 'give'); ?></th>
572
+				<th scope="col" width="120px"><?php esc_html_e('Actions', 'give'); ?></th>
573 573
 			</tr>
574 574
 			</thead>
575 575
 			<tbody>
576
-			<?php if ( ! empty( $donations ) ) { ?>
577
-				<?php foreach ( $donations as $donation ) : ?>
576
+			<?php if ( ! empty($donations)) { ?>
577
+				<?php foreach ($donations as $donation) : ?>
578 578
 					<tr>
579 579
 						<td><?php echo $donation->post_title; ?></td>
580 580
 						<td>
581 581
 							<?php
582 582
 							printf(
583 583
 								'<a href="%1$s" aria-label="%2$s">%3$s</a>',
584
-								esc_url( admin_url( 'post.php?action=edit&post=' . $donation->ID ) ),
584
+								esc_url(admin_url('post.php?action=edit&post='.$donation->ID)),
585 585
 								sprintf(
586 586
 									/* translators: %s: form name */
587
-									esc_attr__( 'View Form %s.', 'give' ),
587
+									esc_attr__('View Form %s.', 'give'),
588 588
 									$donation->post_title
589 589
 								),
590
-								esc_html__( 'View Form', 'give' )
590
+								esc_html__('View Form', 'give')
591 591
 							);
592 592
 							?>
593 593
 						</td>
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
 				<?php endforeach; ?>
596 596
 			<?php } else { ?>
597 597
 				<tr>
598
-					<td colspan="2"><?php esc_html_e( 'No completed donations found.', 'give' ); ?></td>
598
+					<td colspan="2"><?php esc_html_e('No completed donations found.', 'give'); ?></td>
599 599
 				</tr>
600 600
 			<?php } ?>
601 601
 			</tbody>
@@ -609,7 +609,7 @@  discard block
 block discarded – undo
609 609
 		 *
610 610
 		 * @param object $donor The donor object being displayed.
611 611
 		 */
612
-		do_action( 'give_donor_after_tables', $donor );
612
+		do_action('give_donor_after_tables', $donor);
613 613
 		?>
614 614
 
615 615
 	</div>
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
 	 *
623 623
 	 * @param object $donor The donor object being displayed.
624 624
 	 */
625
-	do_action( 'give_donor_card_bottom', $donor );
625
+	do_action('give_donor_card_bottom', $donor);
626 626
 
627 627
 }
628 628
 
@@ -635,30 +635,30 @@  discard block
 block discarded – undo
635 635
  *
636 636
  * @return void
637 637
  */
638
-function give_donor_notes_view( $donor ) {
638
+function give_donor_notes_view($donor) {
639 639
 
640
-	$paged          = isset( $_GET['paged'] ) && is_numeric( $_GET['paged'] ) ? $_GET['paged'] : 1;
641
-	$paged          = absint( $paged );
640
+	$paged          = isset($_GET['paged']) && is_numeric($_GET['paged']) ? $_GET['paged'] : 1;
641
+	$paged          = absint($paged);
642 642
 	$note_count     = $donor->get_notes_count();
643
-	$per_page       = apply_filters( 'give_donor_notes_per_page', 20 );
644
-	$total_pages    = ceil( $note_count / $per_page );
645
-	$donor_notes = $donor->get_notes( $per_page, $paged );
643
+	$per_page       = apply_filters('give_donor_notes_per_page', 20);
644
+	$total_pages    = ceil($note_count / $per_page);
645
+	$donor_notes = $donor->get_notes($per_page, $paged);
646 646
 	?>
647 647
 
648 648
 	<div id="donor-notes-wrapper">
649 649
 		<div class="donor-notes-header">
650
-			<?php echo get_avatar( $donor->email, 30 ); ?> <span><?php echo $donor->name; ?></span>
650
+			<?php echo get_avatar($donor->email, 30); ?> <span><?php echo $donor->name; ?></span>
651 651
 		</div>
652
-		<h3><?php esc_html_e( 'Notes', 'give' ); ?></h3>
652
+		<h3><?php esc_html_e('Notes', 'give'); ?></h3>
653 653
 
654
-		<?php if ( 1 == $paged ) : ?>
654
+		<?php if (1 == $paged) : ?>
655 655
 			<div style="display: block; margin-bottom: 55px;">
656
-				<form id="give-add-donor-note" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=notes&id=' . $donor->id ); ?>">
656
+				<form id="give-add-donor-note" method="post" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=notes&id='.$donor->id); ?>">
657 657
 					<textarea id="donor-note" name="donor_note" class="donor-note-input" rows="10"></textarea>
658 658
 					<br />
659 659
 					<input type="hidden" id="donor-id" name="customer_id" value="<?php echo $donor->id; ?>" />
660 660
 					<input type="hidden" name="give_action" value="add-donor-note" />
661
-					<?php wp_nonce_field( 'add-donor-note', 'add_donor_note_nonce', true, true ); ?>
661
+					<?php wp_nonce_field('add-donor-note', 'add_donor_note_nonce', true, true); ?>
662 662
 					<input id="add-donor-note" class="right button-primary" type="submit" value="Add Note" />
663 663
 				</form>
664 664
 			</div>
@@ -673,26 +673,26 @@  discard block
 block discarded – undo
673 673
 			'show_all' => true,
674 674
 		);
675 675
 
676
-		echo paginate_links( $pagination_args );
676
+		echo paginate_links($pagination_args);
677 677
 		?>
678 678
 
679 679
 		<div id="give-donor-notes" class="postbox">
680
-			<?php if ( count( $donor_notes ) > 0 ) { ?>
681
-				<?php foreach ( $donor_notes as $key => $note ) : ?>
680
+			<?php if (count($donor_notes) > 0) { ?>
681
+				<?php foreach ($donor_notes as $key => $note) : ?>
682 682
 					<div class="donor-note-wrapper dashboard-comment-wrap comment-item">
683 683
 					<span class="note-content-wrap">
684
-						<?php echo stripslashes( $note ); ?>
684
+						<?php echo stripslashes($note); ?>
685 685
 					</span>
686 686
 					</div>
687 687
 				<?php endforeach; ?>
688 688
 			<?php } else { ?>
689 689
 				<div class="give-no-donor-notes">
690
-					<?php esc_html_e( 'No donor notes found.', 'give' ); ?>
690
+					<?php esc_html_e('No donor notes found.', 'give'); ?>
691 691
 				</div>
692 692
 			<?php } ?>
693 693
 		</div>
694 694
 
695
-		<?php echo paginate_links( $pagination_args ); ?>
695
+		<?php echo paginate_links($pagination_args); ?>
696 696
 
697 697
 	</div>
698 698
 
@@ -708,9 +708,9 @@  discard block
 block discarded – undo
708 708
  *
709 709
  * @return void
710 710
  */
711
-function give_donor_delete_view( $donor ) {
711
+function give_donor_delete_view($donor) {
712 712
 
713
-	$donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' );
713
+	$donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments');
714 714
 
715 715
 	/**
716 716
 	 * Fires in donor delete screen, above the content.
@@ -719,15 +719,15 @@  discard block
 block discarded – undo
719 719
 	 *
720 720
 	 * @param object $donor The donor object being displayed.
721 721
 	 */
722
-	do_action( 'give_donor_delete_top', $donor );
722
+	do_action('give_donor_delete_top', $donor);
723 723
 	?>
724 724
 
725 725
 	<div class="info-wrapper donor-section">
726 726
 
727
-		<form id="delete-donor" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $donor->id ); ?>">
727
+		<form id="delete-donor" method="post" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$donor->id); ?>">
728 728
 
729 729
 			<div class="donor-notes-header">
730
-				<?php echo get_avatar( $donor->email, 30 ); ?> <span><?php echo $donor->name; ?></span>
730
+				<?php echo get_avatar($donor->email, 30); ?> <span><?php echo $donor->name; ?></span>
731 731
 			</div>
732 732
 
733 733
 
@@ -735,20 +735,20 @@  discard block
 block discarded – undo
735 735
 
736 736
 				<span class="delete-donor-options">
737 737
 					<p>
738
-						<?php echo Give()->html->checkbox( array(
738
+						<?php echo Give()->html->checkbox(array(
739 739
 							'name' => 'give-donor-delete-confirm',
740
-						) ); ?>
741
-						<label for="give-donor-delete-confirm"><?php esc_html_e( 'Are you sure you want to delete this donor?', 'give' ); ?></label>
740
+						)); ?>
741
+						<label for="give-donor-delete-confirm"><?php esc_html_e('Are you sure you want to delete this donor?', 'give'); ?></label>
742 742
 					</p>
743 743
 
744 744
 					<p>
745
-						<?php echo Give()->html->checkbox( array(
745
+						<?php echo Give()->html->checkbox(array(
746 746
 							'name'    => 'give-donor-delete-records',
747 747
 							'options' => array(
748 748
 								'disabled' => true,
749 749
 							),
750
-						) ); ?>
751
-						<label for="give-donor-delete-records"><?php esc_html_e( 'Delete all associated donations and records?', 'give' ); ?></label>
750
+						)); ?>
751
+						<label for="give-donor-delete-records"><?php esc_html_e('Delete all associated donations and records?', 'give'); ?></label>
752 752
 					</p>
753 753
 
754 754
 					<?php
@@ -761,16 +761,16 @@  discard block
 block discarded – undo
761 761
 					 *
762 762
 					 * @param object $donor The donor object being displayed.
763 763
 					 */
764
-					do_action( 'give_donor_delete_inputs', $donor );
764
+					do_action('give_donor_delete_inputs', $donor);
765 765
 					?>
766 766
 				</span>
767 767
 
768 768
 				<span id="donor-edit-actions">
769 769
 					<input type="hidden" name="customer_id" value="<?php echo $donor->id; ?>" />
770
-					<?php wp_nonce_field( 'delete-donor', '_wpnonce', false, true ); ?>
770
+					<?php wp_nonce_field('delete-donor', '_wpnonce', false, true); ?>
771 771
 					<input type="hidden" name="give_action" value="delete-donor" />
772
-					<input type="submit" disabled="disabled" id="give-delete-donor" class="button-primary" value="<?php esc_attr_e( 'Delete Donor', 'give' ); ?>" />
773
-					<a id="give-delete-donor-cancel" href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ); ?>" class="delete"><?php esc_html_e( 'Cancel', 'give' ); ?></a>
772
+					<input type="submit" disabled="disabled" id="give-delete-donor" class="button-primary" value="<?php esc_attr_e('Delete Donor', 'give'); ?>" />
773
+					<a id="give-delete-donor-cancel" href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id); ?>" class="delete"><?php esc_html_e('Cancel', 'give'); ?></a>
774 774
 				</span>
775 775
 
776 776
 			</div>
@@ -786,5 +786,5 @@  discard block
 block discarded – undo
786 786
 	 *
787 787
 	 * @param object $donor The donor object being displayed.
788 788
 	 */
789
-	do_action( 'give_donor_delete_bottom', $donor );
789
+	do_action('give_donor_delete_bottom', $donor);
790 790
 }
Please login to merge, or discard this patch.
includes/admin/donors/class-donor-table.php 1 patch
Spacing   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -12,13 +12,13 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly.
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
19 19
 // Load WP_List_Table if not loaded
20
-if ( ! class_exists( 'WP_List_Table' ) ) {
21
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
20
+if ( ! class_exists('WP_List_Table')) {
21
+	require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
22 22
 }
23 23
 
24 24
 /**
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
 	public function __construct() {
62 62
 
63 63
 		// Set parent defaults
64
-		parent::__construct( array(
65
-			'singular' => __( 'Donor', 'give' ),     // Singular name of the listed records.
66
-			'plural'   => __( 'Donors', 'give' ),    // Plural name of the listed records.
67
-			'ajax'     => false,// Does this table support ajax?.
68
-		) );
64
+		parent::__construct(array(
65
+			'singular' => __('Donor', 'give'), // Singular name of the listed records.
66
+			'plural'   => __('Donors', 'give'), // Plural name of the listed records.
67
+			'ajax'     => false, // Does this table support ajax?.
68
+		));
69 69
 
70 70
 	}
71 71
 
@@ -80,22 +80,22 @@  discard block
 block discarded – undo
80 80
 	 *
81 81
 	 * @return void
82 82
 	 */
83
-	public function search_box( $text, $input_id ) {
84
-		$input_id = $input_id . '-search-input';
83
+	public function search_box($text, $input_id) {
84
+		$input_id = $input_id.'-search-input';
85 85
 
86
-		if ( ! empty( $_REQUEST['orderby'] ) ) {
87
-			echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
86
+		if ( ! empty($_REQUEST['orderby'])) {
87
+			echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />';
88 88
 		}
89
-		if ( ! empty( $_REQUEST['order'] ) ) {
90
-			echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
89
+		if ( ! empty($_REQUEST['order'])) {
90
+			echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />';
91 91
 		}
92 92
 		?>
93 93
 		<p class="search-box" role="search">
94 94
 			<label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label>
95 95
 			<input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>"/>
96
-			<?php submit_button( $text, 'button', false, false, array(
96
+			<?php submit_button($text, 'button', false, false, array(
97 97
 				'ID' => 'search-submit',
98
-			) ); ?>
98
+			)); ?>
99 99
 		</p>
100 100
 		<?php
101 101
 	}
@@ -111,31 +111,31 @@  discard block
 block discarded – undo
111 111
 	 *
112 112
 	 * @return string Column Name.
113 113
 	 */
114
-	public function column_default( $donor, $column_name ) {
115
-		switch ( $column_name ) {
114
+	public function column_default($donor, $column_name) {
115
+		switch ($column_name) {
116 116
 
117 117
 			case 'num_donations' :
118 118
 				$value = sprintf(
119 119
 					'<a href="%s">%s</a>',
120
-					admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&donor=' . absint( $donor['id'] ) ),
121
-					esc_html( $donor['num_donations'] )
120
+					admin_url('edit.php?post_type=give_forms&page=give-payment-history&donor='.absint($donor['id'])),
121
+					esc_html($donor['num_donations'])
122 122
 				);
123 123
 				break;
124 124
 
125 125
 			case 'amount_spent' :
126
-				$value = give_currency_filter( give_format_amount( $donor[ $column_name ], array( 'sanitize' => false ) ) );
126
+				$value = give_currency_filter(give_format_amount($donor[$column_name], array('sanitize' => false)));
127 127
 				break;
128 128
 
129 129
 			case 'date_created' :
130
-				$value = date_i18n( give_date_format(), strtotime( $donor['date_created'] ) );
130
+				$value = date_i18n(give_date_format(), strtotime($donor['date_created']));
131 131
 				break;
132 132
 
133 133
 			default:
134
-				$value = isset( $donor[ $column_name ] ) ? $donor[ $column_name ] : null;
134
+				$value = isset($donor[$column_name]) ? $donor[$column_name] : null;
135 135
 				break;
136 136
 		}
137 137
 
138
-		return apply_filters( "give_report_column_{$column_name}", $value, $donor['id'] );
138
+		return apply_filters("give_report_column_{$column_name}", $value, $donor['id']);
139 139
 
140 140
 	}
141 141
 
@@ -146,13 +146,13 @@  discard block
 block discarded – undo
146 146
 	 *
147 147
 	 * @return string
148 148
 	 */
149
-	public function column_name( $donor ) {
150
-		$name     = '#' . $donor['id'] . ' ';
151
-		$name     .= ! empty( $donor['name'] ) ? $donor['name'] : '<em>' . esc_html__( 'Unnamed Donor', 'give' ) . '</em>';
152
-		$view_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor['id'] );
153
-		$actions  = $this->get_row_actions( $donor );
149
+	public function column_name($donor) {
150
+		$name     = '#'.$donor['id'].' ';
151
+		$name .= ! empty($donor['name']) ? $donor['name'] : '<em>'.esc_html__('Unnamed Donor', 'give').'</em>';
152
+		$view_url = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor['id']);
153
+		$actions  = $this->get_row_actions($donor);
154 154
 
155
-		return '<a href="' . esc_url( $view_url ) . '">' . $name . '</a>' . $this->row_actions( $actions );
155
+		return '<a href="'.esc_url($view_url).'">'.$name.'</a>'.$this->row_actions($actions);
156 156
 	}
157 157
 
158 158
 	/**
@@ -164,14 +164,14 @@  discard block
 block discarded – undo
164 164
 	 */
165 165
 	public function get_columns() {
166 166
 		$columns = array(
167
-			'name'          => __( 'Name', 'give' ),
168
-			'email'         => __( 'Email', 'give' ),
169
-			'num_donations' => __( 'Donations', 'give' ),
170
-			'amount_spent'  => __( 'Total Donated', 'give' ),
171
-			'date_created'  => __( 'Date Created', 'give' ),
167
+			'name'          => __('Name', 'give'),
168
+			'email'         => __('Email', 'give'),
169
+			'num_donations' => __('Donations', 'give'),
170
+			'amount_spent'  => __('Total Donated', 'give'),
171
+			'date_created'  => __('Date Created', 'give'),
172 172
 		);
173 173
 
174
-		return apply_filters( 'give_list_donors_columns', $columns );
174
+		return apply_filters('give_list_donors_columns', $columns);
175 175
 
176 176
 	}
177 177
 
@@ -185,13 +185,13 @@  discard block
 block discarded – undo
185 185
 	public function get_sortable_columns() {
186 186
 
187 187
 		$columns = array(
188
-			'date_created'  => array( 'date_created', true ),
189
-			'name'          => array( 'name', true ),
190
-			'num_donations' => array( 'purchase_count', false ),
191
-			'amount_spent'  => array( 'purchase_value', false ),
188
+			'date_created'  => array('date_created', true),
189
+			'name'          => array('name', true),
190
+			'num_donations' => array('purchase_count', false),
191
+			'amount_spent'  => array('purchase_value', false),
192 192
 		);
193 193
 
194
-		return apply_filters( 'give_list_donors_sortable_columns', $columns );
194
+		return apply_filters('give_list_donors_sortable_columns', $columns);
195 195
 	}
196 196
 
197 197
 	/**
@@ -204,19 +204,19 @@  discard block
 block discarded – undo
204 204
 	 *
205 205
 	 * @return array An array of action links.
206 206
 	 */
207
-	public function get_row_actions( $donor ) {
207
+	public function get_row_actions($donor) {
208 208
 
209 209
 		$actions = array(
210 210
 
211
-			'view' => sprintf( '<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor['id'] ), sprintf( esc_attr__( 'View "%s"', 'give' ), $donor['name'] ), __( 'View Donor', 'give' ) ),
211
+			'view' => sprintf('<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor['id']), sprintf(esc_attr__('View "%s"', 'give'), $donor['name']), __('View Donor', 'give')),
212 212
 
213
-			'notes' => sprintf( '<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=notes&id=' . $donor['id'] ), sprintf( esc_attr__( 'Notes for "%s"', 'give' ), $donor['name'] ), __( 'Notes', 'give' ) ),
213
+			'notes' => sprintf('<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url('edit.php?post_type=give_forms&page=give-donors&view=notes&id='.$donor['id']), sprintf(esc_attr__('Notes for "%s"', 'give'), $donor['name']), __('Notes', 'give')),
214 214
 
215
-			'delete' => sprintf( '<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $donor['id'] ), sprintf( esc_attr__( 'Delete "%s"', 'give' ), $donor['name'] ), __( 'Delete', 'give' ) ),
215
+			'delete' => sprintf('<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$donor['id']), sprintf(esc_attr__('Delete "%s"', 'give'), $donor['name']), __('Delete', 'give')),
216 216
 
217 217
 		);
218 218
 
219
-		return apply_filters( 'give_donor_row_actions', $actions, $donor );
219
+		return apply_filters('give_donor_row_actions', $actions, $donor);
220 220
 
221 221
 	}
222 222
 
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 	 * @since  1.0
231 231
 	 * @return void
232 232
 	 */
233
-	public function bulk_actions( $which = '' ) {
233
+	public function bulk_actions($which = '') {
234 234
 		// These aren't really bulk actions but this outputs the markup in the right place.
235 235
 	}
236 236
 
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 	 * @return int Current page number.
243 243
 	 */
244 244
 	public function get_paged() {
245
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
245
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
246 246
 	}
247 247
 
248 248
 	/**
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 	 * @return mixed string If search is present, false otherwise.
254 254
 	 */
255 255
 	public function get_search() {
256
-		return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false;
256
+		return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false;
257 257
 	}
258 258
 
259 259
 	/**
@@ -270,13 +270,13 @@  discard block
 block discarded – undo
270 270
 
271 271
 		// Get donor query.
272 272
 		$args   = $this->get_donor_query();
273
-		$donors = Give()->donors->get_donors( $args );
273
+		$donors = Give()->donors->get_donors($args);
274 274
 
275
-		if ( $donors ) {
275
+		if ($donors) {
276 276
 
277
-			foreach ( $donors as $donor ) {
277
+			foreach ($donors as $donor) {
278 278
 
279
-				$user_id = ! empty( $donor->user_id ) ? intval( $donor->user_id ) : 0;
279
+				$user_id = ! empty($donor->user_id) ? intval($donor->user_id) : 0;
280 280
 
281 281
 				$data[] = array(
282 282
 					'id'            => $donor->id,
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 			}
291 291
 		}
292 292
 
293
-		return apply_filters( 'give_donors_column_query_data', $data );
293
+		return apply_filters('give_donors_column_query_data', $data);
294 294
 	}
295 295
 
296 296
 	/**
@@ -305,9 +305,9 @@  discard block
 block discarded – undo
305 305
 
306 306
 		$_donor_query['number'] = - 1;
307 307
 		$_donor_query['offset'] = 0;
308
-		$donors                 = Give()->donors->get_donors( $_donor_query );
308
+		$donors                 = Give()->donors->get_donors($_donor_query);
309 309
 
310
-		return count( $donors );
310
+		return count($donors);
311 311
 	}
312 312
 
313 313
 	/**
@@ -319,10 +319,10 @@  discard block
 block discarded – undo
319 319
 	 */
320 320
 	public function get_donor_query() {
321 321
 		$paged   = $this->get_paged();
322
-		$offset  = $this->per_page * ( $paged - 1 );
322
+		$offset  = $this->per_page * ($paged - 1);
323 323
 		$search  = $this->get_search();
324
-		$order   = isset( $_GET['order'] ) ? sanitize_text_field( $_GET['order'] ) : 'DESC';
325
-		$orderby = isset( $_GET['orderby'] ) ? sanitize_text_field( $_GET['orderby'] ) : 'id';
324
+		$order   = isset($_GET['order']) ? sanitize_text_field($_GET['order']) : 'DESC';
325
+		$orderby = isset($_GET['orderby']) ? sanitize_text_field($_GET['orderby']) : 'id';
326 326
 
327 327
 		$args = array(
328 328
 			'number'  => $this->per_page,
@@ -331,10 +331,10 @@  discard block
 block discarded – undo
331 331
 			'orderby' => $orderby,
332 332
 		);
333 333
 
334
-		if ( $search ) {
335
-			if ( is_email( $search ) ) {
334
+		if ($search) {
335
+			if (is_email($search)) {
336 336
 				$args['email'] = $search;
337
-			} elseif ( is_numeric( $search ) ) {
337
+			} elseif (is_numeric($search)) {
338 338
 				$args['id'] = $search;
339 339
 			} else {
340 340
 				$args['name'] = $search;
@@ -357,16 +357,16 @@  discard block
 block discarded – undo
357 357
 		$hidden   = array(); // No hidden columns.
358 358
 		$sortable = $this->get_sortable_columns();
359 359
 
360
-		$this->_column_headers = array( $columns, $hidden, $sortable );
360
+		$this->_column_headers = array($columns, $hidden, $sortable);
361 361
 
362 362
 		$this->items = $this->donor_data();
363 363
 
364 364
 		$this->total = $this->get_donor_count();
365 365
 
366
-		$this->set_pagination_args( array(
366
+		$this->set_pagination_args(array(
367 367
 			'total_items' => $this->total,
368 368
 			'per_page'    => $this->per_page,
369
-			'total_pages' => ceil( $this->total / $this->per_page ),
370
-		) );
369
+			'total_pages' => ceil($this->total / $this->per_page),
370
+		));
371 371
 	}
372 372
 }
Please login to merge, or discard this patch.