Test Failed
Pull Request — master (#3152)
by Devin
07:21
created
templates/emails/body-default.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
  * @version     1.0
7 7
  */
8 8
 
9
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
9
+if ( ! defined('ABSPATH')) exit; // Exit if accessed directly.
10 10
 
11 11
 // {email} is replaced by the content entered in Donations > Settings > Emails
12 12
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,10 @@
 block discarded – undo
6 6
  * @version     1.0
7 7
  */
8 8
 
9
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
9
+if ( ! defined( 'ABSPATH' ) ) {
10
+	exit;
11
+}
12
+// Exit if accessed directly.
10 13
 
11 14
 // {email} is replaced by the content entered in Donations > Settings > Emails
12 15
 
Please login to merge, or discard this patch.
templates/emails/footer.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
  * @version     1.0
7 7
  */
8 8
 
9
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
9
+if ( ! defined('ABSPATH')) exit; // Exit if accessed directly.
10 10
 
11 11
 // This is the footer used if no others are available
12 12
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,10 @@
 block discarded – undo
6 6
  * @version     1.0
7 7
  */
8 8
 
9
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
9
+if ( ! defined( 'ABSPATH' ) ) {
10
+	exit;
11
+}
12
+// Exit if accessed directly.
10 13
 
11 14
 // This is the footer used if no others are available
12 15
 
Please login to merge, or discard this patch.
templates/emails/body.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
  * @version     1.0
7 7
  */
8 8
 
9
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
9
+if ( ! defined('ABSPATH')) exit; // Exit if accessed directly.
10 10
 
11 11
 // {email} is replaced by the content entered in Donations > Settings > Emails
12 12
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,10 @@
 block discarded – undo
6 6
  * @version     1.0
7 7
  */
8 8
 
9
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
9
+if ( ! defined( 'ABSPATH' ) ) {
10
+	exit;
11
+}
12
+// Exit if accessed directly.
10 13
 
11 14
 // {email} is replaced by the content entered in Donations > Settings > Emails
12 15
 
Please login to merge, or discard this patch.
includes/plugin-compatibility.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,8 +39,8 @@
 block discarded – undo
39 39
 	}
40 40
 
41 41
 	if ( ( is_plugin_active( 'wordpress-seo/wp-seo.php' )
42
-	       || is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' ) )
43
-	     && class_exists( 'WPSEO_Sitemaps_Cache' )
42
+		   || is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' ) )
43
+		 && class_exists( 'WPSEO_Sitemaps_Cache' )
44 44
 	) {
45 45
 
46 46
 		$forms_singular_option = give_get_option( 'forms_singular' );
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -19,10 +19,10 @@  discard block
 block discarded – undo
19 19
  * @return void
20 20
  */
21 21
 function give_disable_mandrill_nl2br() {
22
-	add_filter( 'mandrill_nl2br', '__return_false' );
22
+	add_filter('mandrill_nl2br', '__return_false');
23 23
 }
24 24
 
25
-add_action( 'give_email_send_before', 'give_disable_mandrill_nl2br' );
25
+add_action('give_email_send_before', 'give_disable_mandrill_nl2br');
26 26
 
27 27
 
28 28
 /**
@@ -34,30 +34,30 @@  discard block
 block discarded – undo
34 34
  */
35 35
 function give_clear_seo_sitemap_cache_on_settings_change() {
36 36
 	// Load required file if the fn 'is_plugin_active' doesn't exists.
37
-	if ( ! function_exists( 'is_plugin_active' ) ) {
38
-		require_once ABSPATH . 'wp-admin/includes/plugin.php';
37
+	if ( ! function_exists('is_plugin_active')) {
38
+		require_once ABSPATH.'wp-admin/includes/plugin.php';
39 39
 	}
40 40
 
41
-	if ( ( is_plugin_active( 'wordpress-seo/wp-seo.php' )
42
-	       || is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' ) )
43
-	     && class_exists( 'WPSEO_Sitemaps_Cache' )
41
+	if ((is_plugin_active('wordpress-seo/wp-seo.php')
42
+	       || is_plugin_active('wordpress-seo-premium/wp-seo-premium.php'))
43
+	     && class_exists('WPSEO_Sitemaps_Cache')
44 44
 	) {
45 45
 
46
-		$forms_singular_option = give_get_option( 'forms_singular' );
47
-		$forms_archive_option  = give_get_option( 'forms_singular' );
46
+		$forms_singular_option = give_get_option('forms_singular');
47
+		$forms_archive_option  = give_get_option('forms_singular');
48 48
 
49 49
 		// If there is change detected for Single Form View and Form Archives options then proceed.
50 50
 		if (
51
-			( isset( $_POST['forms_singular'] ) && $_POST['forms_singular'] !== $forms_singular_option ) ||
52
-			( isset( $_POST['forms_archives'] ) && $_POST['forms_archives'] !== $forms_archive_option )
51
+			(isset($_POST['forms_singular']) && $_POST['forms_singular'] !== $forms_singular_option) ||
52
+			(isset($_POST['forms_archives']) && $_POST['forms_archives'] !== $forms_archive_option)
53 53
 		) {
54 54
 			// If Yoast SEO or Yoast SEO Premium plugin exists, then update seo sitemap cache.
55 55
 			$yoast_sitemaps_cache = new WPSEO_Sitemaps_Cache();
56
-			if ( method_exists( $yoast_sitemaps_cache, 'clear' ) ) {
56
+			if (method_exists($yoast_sitemaps_cache, 'clear')) {
57 57
 				WPSEO_Sitemaps_Cache::clear();
58 58
 			}
59 59
 		}
60 60
 	}
61 61
 }
62 62
 
63
-add_action( 'give-settings_save_display', 'give_clear_seo_sitemap_cache_on_settings_change' );
63
+add_action('give-settings_save_display', 'give_clear_seo_sitemap_cache_on_settings_change');
Please login to merge, or discard this patch.
includes/class-give-stats.php 1 patch
Spacing   +106 added lines, -106 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
 
@@ -93,19 +93,19 @@  discard block
 block discarded – undo
93 93
 	 */
94 94
 	public function get_predefined_dates() {
95 95
 		$predefined = array(
96
-			'today'        => esc_html__( 'Today', 'give' ),
97
-			'yesterday'    => esc_html__( 'Yesterday', 'give' ),
98
-			'this_week'    => esc_html__( 'This Week', 'give' ),
99
-			'last_week'    => esc_html__( 'Last Week', 'give' ),
100
-			'this_month'   => esc_html__( 'This Month', 'give' ),
101
-			'last_month'   => esc_html__( 'Last Month', 'give' ),
102
-			'this_quarter' => esc_html__( 'This Quarter', 'give' ),
103
-			'last_quarter' => esc_html__( 'Last Quarter', 'give' ),
104
-			'this_year'    => esc_html__( 'This Year', 'give' ),
105
-			'last_year'    => esc_html__( 'Last Year', 'give' ),
96
+			'today'        => esc_html__('Today', 'give'),
97
+			'yesterday'    => esc_html__('Yesterday', 'give'),
98
+			'this_week'    => esc_html__('This Week', 'give'),
99
+			'last_week'    => esc_html__('Last Week', 'give'),
100
+			'this_month'   => esc_html__('This Month', 'give'),
101
+			'last_month'   => esc_html__('Last Month', 'give'),
102
+			'this_quarter' => esc_html__('This Quarter', 'give'),
103
+			'last_quarter' => esc_html__('Last Quarter', 'give'),
104
+			'this_year'    => esc_html__('This Year', 'give'),
105
+			'last_year'    => esc_html__('Last Year', 'give'),
106 106
 		);
107 107
 
108
-		return apply_filters( 'give_stats_predefined_dates', $predefined );
108
+		return apply_filters('give_stats_predefined_dates', $predefined);
109 109
 	}
110 110
 
111 111
 	/**
@@ -121,18 +121,18 @@  discard block
 block discarded – undo
121 121
 	 *
122 122
 	 * @return void
123 123
 	 */
124
-	public function setup_dates( $_start_date = 'this_month', $_end_date = false ) {
124
+	public function setup_dates($_start_date = 'this_month', $_end_date = false) {
125 125
 
126
-		if ( empty( $_start_date ) ) {
126
+		if (empty($_start_date)) {
127 127
 			$_start_date = 'this_month';
128 128
 		}
129 129
 
130
-		if ( empty( $_end_date ) ) {
130
+		if (empty($_end_date)) {
131 131
 			$_end_date = $_start_date;
132 132
 		}
133 133
 
134
-		$this->start_date = $this->convert_date( $_start_date );
135
-		$this->end_date   = $this->convert_date( $_end_date, true );
134
+		$this->start_date = $this->convert_date($_start_date);
135
+		$this->end_date   = $this->convert_date($_end_date, true);
136 136
 	}
137 137
 
138 138
 	/**
@@ -148,26 +148,26 @@  discard block
 block discarded – undo
148 148
 	 *
149 149
 	 * @return array|WP_Error   If the date is invalid, a WP_Error object will be returned.
150 150
 	 */
151
-	public function convert_date( $date, $end_date = false ) {
151
+	public function convert_date($date, $end_date = false) {
152 152
 
153 153
 		$this->timestamp = false;
154 154
 		$second          = $end_date ? 59 : 0;
155 155
 		$minute          = $end_date ? 59 : 0;
156 156
 		$hour            = $end_date ? 23 : 0;
157 157
 		$day             = 1;
158
-		$month           = date( 'n', current_time( 'timestamp' ) );
159
-		$year            = date( 'Y', current_time( 'timestamp' ) );
158
+		$month           = date('n', current_time('timestamp'));
159
+		$year            = date('Y', current_time('timestamp'));
160 160
 
161
-		if ( array_key_exists( (string) $date, $this->get_predefined_dates() ) ) {
161
+		if (array_key_exists((string) $date, $this->get_predefined_dates())) {
162 162
 
163 163
 			// This is a predefined date rate, such as last_week
164
-			switch ( $date ) {
164
+			switch ($date) {
165 165
 
166 166
 				case 'this_month' :
167 167
 
168
-					if ( $end_date ) {
168
+					if ($end_date) {
169 169
 
170
-						$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
170
+						$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
171 171
 						$hour   = 23;
172 172
 						$minute = 59;
173 173
 						$second = 59;
@@ -177,28 +177,28 @@  discard block
 block discarded – undo
177 177
 
178 178
 				case 'last_month' :
179 179
 
180
-					if ( $month == 1 ) {
180
+					if ($month == 1) {
181 181
 
182 182
 						$month = 12;
183
-						$year --;
183
+						$year--;
184 184
 
185 185
 					} else {
186 186
 
187
-						$month --;
187
+						$month--;
188 188
 
189 189
 					}
190 190
 
191
-					if ( $end_date ) {
192
-						$day = cal_days_in_month( CAL_GREGORIAN, $month, $year );
191
+					if ($end_date) {
192
+						$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
193 193
 					}
194 194
 
195 195
 					break;
196 196
 
197 197
 				case 'today' :
198 198
 
199
-					$day = date( 'd', current_time( 'timestamp' ) );
199
+					$day = date('d', current_time('timestamp'));
200 200
 
201
-					if ( $end_date ) {
201
+					if ($end_date) {
202 202
 						$hour   = 23;
203 203
 						$minute = 59;
204 204
 						$second = 59;
@@ -208,23 +208,23 @@  discard block
 block discarded – undo
208 208
 
209 209
 				case 'yesterday' :
210 210
 
211
-					$day = date( 'd', current_time( 'timestamp' ) ) - 1;
211
+					$day = date('d', current_time('timestamp')) - 1;
212 212
 
213 213
 					// Check if Today is the first day of the month (meaning subtracting one will get us 0)
214
-					if ( $day < 1 ) {
214
+					if ($day < 1) {
215 215
 
216 216
 						// If current month is 1
217
-						if ( 1 == $month ) {
217
+						if (1 == $month) {
218 218
 
219 219
 							$year -= 1; // Today is January 1, so skip back to last day of December
220 220
 							$month = 12;
221
-							$day   = cal_days_in_month( CAL_GREGORIAN, $month, $year );
221
+							$day   = cal_days_in_month(CAL_GREGORIAN, $month, $year);
222 222
 
223 223
 						} else {
224 224
 
225 225
 							// Go back one month and get the last day of the month
226 226
 							$month -= 1;
227
-							$day = cal_days_in_month( CAL_GREGORIAN, $month, $year );
227
+							$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
228 228
 
229 229
 						}
230 230
 					}
@@ -233,12 +233,12 @@  discard block
 block discarded – undo
233 233
 
234 234
 				case 'this_week' :
235 235
 
236
-					$days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24;
237
-					$today              = date( 'd', current_time( 'timestamp' ) ) * 60 * 60 * 24;
236
+					$days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24;
237
+					$today              = date('d', current_time('timestamp')) * 60 * 60 * 24;
238 238
 
239
-					if ( $today < $days_to_week_start ) {
239
+					if ($today < $days_to_week_start) {
240 240
 
241
-						if ( $month > 1 ) {
241
+						if ($month > 1) {
242 242
 							$month -= 1;
243 243
 						} else {
244 244
 							$month = 12;
@@ -246,19 +246,19 @@  discard block
 block discarded – undo
246 246
 
247 247
 					}
248 248
 
249
-					if ( ! $end_date ) {
249
+					if ( ! $end_date) {
250 250
 
251 251
 						// Getting the start day
252 252
 
253
-						$day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1;
254
-						$day += get_option( 'start_of_week' );
253
+						$day = date('d', current_time('timestamp') - $days_to_week_start) - 1;
254
+						$day += get_option('start_of_week');
255 255
 
256 256
 					} else {
257 257
 
258 258
 						// Getting the end day
259 259
 
260
-						$day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1;
261
-						$day += get_option( 'start_of_week' ) + 6;
260
+						$day = date('d', current_time('timestamp') - $days_to_week_start) - 1;
261
+						$day += get_option('start_of_week') + 6;
262 262
 
263 263
 					}
264 264
 
@@ -266,12 +266,12 @@  discard block
 block discarded – undo
266 266
 
267 267
 				case 'last_week' :
268 268
 
269
-					$days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24;
270
-					$today              = date( 'd', current_time( 'timestamp' ) ) * 60 * 60 * 24;
269
+					$days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24;
270
+					$today              = date('d', current_time('timestamp')) * 60 * 60 * 24;
271 271
 
272
-					if ( $today < $days_to_week_start ) {
272
+					if ($today < $days_to_week_start) {
273 273
 
274
-						if ( $month > 1 ) {
274
+						if ($month > 1) {
275 275
 							$month -= 1;
276 276
 						} else {
277 277
 							$month = 12;
@@ -279,19 +279,19 @@  discard block
 block discarded – undo
279 279
 
280 280
 					}
281 281
 
282
-					if ( ! $end_date ) {
282
+					if ( ! $end_date) {
283 283
 
284 284
 						// Getting the start day
285 285
 
286
-						$day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8;
287
-						$day += get_option( 'start_of_week' );
286
+						$day = date('d', current_time('timestamp') - $days_to_week_start) - 8;
287
+						$day += get_option('start_of_week');
288 288
 
289 289
 					} else {
290 290
 
291 291
 						// Getting the end day
292 292
 
293
-						$day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8;
294
-						$day += get_option( 'start_of_week' ) + 6;
293
+						$day = date('d', current_time('timestamp') - $days_to_week_start) - 8;
294
+						$day += get_option('start_of_week') + 6;
295 295
 
296 296
 					}
297 297
 
@@ -299,39 +299,39 @@  discard block
 block discarded – undo
299 299
 
300 300
 				case 'this_quarter' :
301 301
 
302
-					$month_now = date( 'n', current_time( 'timestamp' ) );
302
+					$month_now = date('n', current_time('timestamp'));
303 303
 
304
-					if ( $month_now <= 3 ) {
304
+					if ($month_now <= 3) {
305 305
 
306
-						if ( ! $end_date ) {
306
+						if ( ! $end_date) {
307 307
 							$month = 1;
308 308
 						} else {
309 309
 							$month  = 3;
310
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
310
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
311 311
 							$hour   = 23;
312 312
 							$minute = 59;
313 313
 							$second = 59;
314 314
 						}
315 315
 
316
-					} else if ( $month_now <= 6 ) {
316
+					} else if ($month_now <= 6) {
317 317
 
318
-						if ( ! $end_date ) {
318
+						if ( ! $end_date) {
319 319
 							$month = 4;
320 320
 						} else {
321 321
 							$month  = 6;
322
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
322
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
323 323
 							$hour   = 23;
324 324
 							$minute = 59;
325 325
 							$second = 59;
326 326
 						}
327 327
 
328
-					} else if ( $month_now <= 9 ) {
328
+					} else if ($month_now <= 9) {
329 329
 
330
-						if ( ! $end_date ) {
330
+						if ( ! $end_date) {
331 331
 							$month = 7;
332 332
 						} else {
333 333
 							$month  = 9;
334
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
334
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
335 335
 							$hour   = 23;
336 336
 							$minute = 59;
337 337
 							$second = 59;
@@ -339,11 +339,11 @@  discard block
 block discarded – undo
339 339
 
340 340
 					} else {
341 341
 
342
-						if ( ! $end_date ) {
342
+						if ( ! $end_date) {
343 343
 							$month = 10;
344 344
 						} else {
345 345
 							$month  = 12;
346
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
346
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
347 347
 							$hour   = 23;
348 348
 							$minute = 59;
349 349
 							$second = 59;
@@ -355,40 +355,40 @@  discard block
 block discarded – undo
355 355
 
356 356
 				case 'last_quarter' :
357 357
 
358
-					$month_now = date( 'n', current_time( 'timestamp' ) );
358
+					$month_now = date('n', current_time('timestamp'));
359 359
 
360
-					if ( $month_now <= 3 ) {
360
+					if ($month_now <= 3) {
361 361
 
362
-						if ( ! $end_date ) {
362
+						if ( ! $end_date) {
363 363
 							$month = 10;
364 364
 						} else {
365 365
 							$year -= 1;
366 366
 							$month  = 12;
367
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
367
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
368 368
 							$hour   = 23;
369 369
 							$minute = 59;
370 370
 							$second = 59;
371 371
 						}
372 372
 
373
-					} else if ( $month_now <= 6 ) {
373
+					} else if ($month_now <= 6) {
374 374
 
375
-						if ( ! $end_date ) {
375
+						if ( ! $end_date) {
376 376
 							$month = 1;
377 377
 						} else {
378 378
 							$month  = 3;
379
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
379
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
380 380
 							$hour   = 23;
381 381
 							$minute = 59;
382 382
 							$second = 59;
383 383
 						}
384 384
 
385
-					} else if ( $month_now <= 9 ) {
385
+					} else if ($month_now <= 9) {
386 386
 
387
-						if ( ! $end_date ) {
387
+						if ( ! $end_date) {
388 388
 							$month = 4;
389 389
 						} else {
390 390
 							$month  = 6;
391
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
391
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
392 392
 							$hour   = 23;
393 393
 							$minute = 59;
394 394
 							$second = 59;
@@ -396,11 +396,11 @@  discard block
 block discarded – undo
396 396
 
397 397
 					} else {
398 398
 
399
-						if ( ! $end_date ) {
399
+						if ( ! $end_date) {
400 400
 							$month = 7;
401 401
 						} else {
402 402
 							$month  = 9;
403
-							$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
403
+							$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
404 404
 							$hour   = 23;
405 405
 							$minute = 59;
406 406
 							$second = 59;
@@ -412,11 +412,11 @@  discard block
 block discarded – undo
412 412
 
413 413
 				case 'this_year' :
414 414
 
415
-					if ( ! $end_date ) {
415
+					if ( ! $end_date) {
416 416
 						$month = 1;
417 417
 					} else {
418 418
 						$month  = 12;
419
-						$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
419
+						$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
420 420
 						$hour   = 23;
421 421
 						$minute = 59;
422 422
 						$second = 59;
@@ -427,11 +427,11 @@  discard block
 block discarded – undo
427 427
 				case 'last_year' :
428 428
 
429 429
 					$year -= 1;
430
-					if ( ! $end_date ) {
430
+					if ( ! $end_date) {
431 431
 						$month = 1;
432 432
 					} else {
433 433
 						$month  = 12;
434
-						$day    = cal_days_in_month( CAL_GREGORIAN, $month, $year );
434
+						$day    = cal_days_in_month(CAL_GREGORIAN, $month, $year);
435 435
 						$hour   = 23;
436 436
 						$minute = 59;
437 437
 						$second = 59;
@@ -442,30 +442,30 @@  discard block
 block discarded – undo
442 442
 			}
443 443
 
444 444
 
445
-		} else if ( is_numeric( $date ) ) {
445
+		} else if (is_numeric($date)) {
446 446
 
447 447
 			// return $date unchanged since it is a timestamp
448 448
 			$this->timestamp = true;
449 449
 
450
-		} else if ( false !== strtotime( $date ) ) {
450
+		} else if (false !== strtotime($date)) {
451 451
 
452
-			$date  = strtotime( $date, current_time( 'timestamp' ) );
453
-			$year  = date( 'Y', $date );
454
-			$month = date( 'm', $date );
455
-			$day   = date( 'd', $date );
452
+			$date  = strtotime($date, current_time('timestamp'));
453
+			$year  = date('Y', $date);
454
+			$month = date('m', $date);
455
+			$day   = date('d', $date);
456 456
 
457 457
 		} else {
458 458
 
459
-			return new WP_Error( 'invalid_date', esc_html__( 'Improper date provided.', 'give' ) );
459
+			return new WP_Error('invalid_date', esc_html__('Improper date provided.', 'give'));
460 460
 
461 461
 		}
462 462
 
463
-		if ( false === $this->timestamp ) {
463
+		if (false === $this->timestamp) {
464 464
 			// Create an exact timestamp
465
-			$date = mktime( $hour, $minute, $second, $month, $day, $year );
465
+			$date = mktime($hour, $minute, $second, $month, $day, $year);
466 466
 		}
467 467
 
468
-		return apply_filters( 'give_stats_date', $date, $end_date, $this );
468
+		return apply_filters('give_stats_date', $date, $end_date, $this);
469 469
 
470 470
 	}
471 471
 
@@ -481,33 +481,33 @@  discard block
 block discarded – undo
481 481
 	 * 
482 482
 	 * @return string
483 483
 	 */
484
-	public function count_where( $where = '' ) {
484
+	public function count_where($where = '') {
485 485
 		// Only get payments in our date range
486 486
 
487 487
 		$start_where = '';
488 488
 		$end_where   = '';
489 489
 
490
-		if ( $this->start_date ) {
490
+		if ($this->start_date) {
491 491
 
492
-			if ( $this->timestamp ) {
492
+			if ($this->timestamp) {
493 493
 				$format = 'Y-m-d H:i:s';
494 494
 			} else {
495 495
 				$format = 'Y-m-d 00:00:00';
496 496
 			}
497 497
 
498
-			$start_date  = date( $format, $this->start_date );
498
+			$start_date  = date($format, $this->start_date);
499 499
 			$start_where = " AND p.post_date >= '{$start_date}'";
500 500
 		}
501 501
 
502
-		if ( $this->end_date ) {
502
+		if ($this->end_date) {
503 503
 
504
-			if ( $this->timestamp ) {
504
+			if ($this->timestamp) {
505 505
 				$format = 'Y-m-d H:i:s';
506 506
 			} else {
507 507
 				$format = 'Y-m-d 23:59:59';
508 508
 			}
509 509
 
510
-			$end_date = date( $format, $this->end_date );
510
+			$end_date = date($format, $this->end_date);
511 511
 
512 512
 			$end_where = " AND p.post_date <= '{$end_date}'";
513 513
 		}
@@ -529,34 +529,34 @@  discard block
 block discarded – undo
529 529
 	 *
530 530
 	 * @return string
531 531
 	 */
532
-	public function payments_where( $where = '' ) {
532
+	public function payments_where($where = '') {
533 533
 
534 534
 		global $wpdb;
535 535
 
536 536
 		$start_where = '';
537 537
 		$end_where   = '';
538 538
 
539
-		if ( ! is_wp_error( $this->start_date ) ) {
539
+		if ( ! is_wp_error($this->start_date)) {
540 540
 
541
-			if ( $this->timestamp ) {
541
+			if ($this->timestamp) {
542 542
 				$format = 'Y-m-d H:i:s';
543 543
 			} else {
544 544
 				$format = 'Y-m-d 00:00:00';
545 545
 			}
546 546
 
547
-			$start_date  = date( $format, $this->start_date );
547
+			$start_date  = date($format, $this->start_date);
548 548
 			$start_where = " AND $wpdb->posts.post_date >= '{$start_date}'";
549 549
 		}
550 550
 
551
-		if ( ! is_wp_error( $this->end_date ) ) {
551
+		if ( ! is_wp_error($this->end_date)) {
552 552
 
553
-			if ( $this->timestamp ) {
553
+			if ($this->timestamp) {
554 554
 				$format = 'Y-m-d H:i:s';
555 555
 			} else {
556 556
 				$format = 'Y-m-d 23:59:59';
557 557
 			}
558 558
 
559
-			$end_date = date( $format, $this->end_date );
559
+			$end_date = date($format, $this->end_date);
560 560
 
561 561
 			$end_where = " AND $wpdb->posts.post_date <= '{$end_date}'";
562 562
 		}
Please login to merge, or discard this patch.
includes/admin/tools/data/class-give-tools-delete-import-donors.php 2 patches
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 	 * Return the calculated completion percentage.
217 217
 	 *
218 218
 	 * @since 1.8.12
219
-	 * @return int
219
+	 * @return double
220 220
 	 */
221 221
 	public function get_percentage_complete() {
222 222
 		return ceil( ( 100 * $this->step_completed ) / $this->total_step );
@@ -353,6 +353,9 @@  discard block
 block discarded – undo
353 353
 		return true;
354 354
 	}
355 355
 
356
+	/**
357
+	 * @param integer $page
358
+	 */
356 359
 	public function get_delete_ids( $donation_ids, $page ) {
357 360
 		$index            = $page --;
358 361
 		$count            = count( $donation_ids );
Please login to merge, or discard this patch.
Spacing   +117 added lines, -117 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
 
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
 	/**
106 106
 	 * Constructor.
107 107
 	 */
108
-	public function __construct( $_step = 1 ) {
109
-		parent::__construct( $_step );
108
+	public function __construct($_step = 1) {
109
+		parent::__construct($_step);
110 110
 
111 111
 		$this->is_writable = true;
112 112
 	}
@@ -125,34 +125,34 @@  discard block
 block discarded – undo
125 125
 		$donor_ids    = array();
126 126
 
127 127
 		// Check if the ajax request if running for the first time.
128
-		if ( 1 === (int) $this->step ) {
128
+		if (1 === (int) $this->step) {
129 129
 			// Delete all the form ids.
130
-			$this->delete_option( $this->form_key );
130
+			$this->delete_option($this->form_key);
131 131
 			// Delete all the donation ids.
132
-			$this->delete_option( $this->donation_key );
132
+			$this->delete_option($this->donation_key);
133 133
 			// Delete all the donor ids.
134
-			$this->delete_option( $this->donor_key );
134
+			$this->delete_option($this->donor_key);
135 135
 
136 136
 			// Delete all the step and set to 'count' which if the first step in the process of deleting the donors.
137
-			$this->update_option( $this->step_key, 'count' );
137
+			$this->update_option($this->step_key, 'count');
138 138
 
139 139
 			// Delete tha page count of the step.
140
-			$this->update_option( $this->step_on_key, '0' );
140
+			$this->update_option($this->step_on_key, '0');
141 141
 		} else {
142 142
 			// Get the old donors list.
143
-			$donor_ids = $this->get_option( $this->donor_key );
143
+			$donor_ids = $this->get_option($this->donor_key);
144 144
 
145 145
 			// Get the old donation list.
146
-			$donation_ids = $this->get_option( $this->donation_key );
146
+			$donation_ids = $this->get_option($this->donation_key);
147 147
 		}
148 148
 
149 149
 		// Get the step and check for it if it's on the first step( 'count' ) or not.
150 150
 		$step = (int) $this->get_step();
151
-		if ( 1 === $step ) {
151
+		if (1 === $step) {
152 152
 			/**
153 153
 			 * Will add or update the donation and donor data by running wp query.
154 154
 			 */
155
-			$this->count( $step, $donation_ids, $donor_ids );
155
+			$this->count($step, $donation_ids, $donor_ids);
156 156
 		}
157 157
 	}
158 158
 
@@ -163,17 +163,17 @@  discard block
 block discarded – undo
163 163
 	 * @param array $donation_ids Contain the list of all the donation id's that has being add before this
164 164
 	 * @param array $donor_ids Contain the list of all the donors id's that has being add before this
165 165
 	 */
166
-	private function count( $step, $donation_ids = array(), $donor_ids = array() ) {
166
+	private function count($step, $donation_ids = array(), $donor_ids = array()) {
167 167
 
168 168
 		// Get the Page count by default it's zero.
169 169
 		$paged = (int) $this->get_step_page();
170 170
 		// Incresed the page count by one.
171
-		++ $paged;
171
+		++$paged;
172 172
 
173 173
 		/**
174 174
 		 * Filter add to alter the argument before the wp quest run
175 175
 		 */
176
-		$args = apply_filters( 'give_tools_reset_stats_total_args', array(
176
+		$args = apply_filters('give_tools_reset_stats_total_args', array(
177 177
 			'post_type'      => 'give_payment',
178 178
 			'post_status'    => 'any',
179 179
 			'posts_per_page' => $this->per_step,
@@ -181,40 +181,40 @@  discard block
 block discarded – undo
181 181
 			'meta_key'       => '_give_payment_import',
182 182
 			'meta_value_num' => 1,
183 183
 			'meta_compare'   => '=',
184
-		) );
184
+		));
185 185
 
186 186
 		// Reset the post data.
187 187
 		wp_reset_postdata();
188 188
 		// Getting the new donation.
189
-		$donation_posts = new WP_Query( $args );
189
+		$donation_posts = new WP_Query($args);
190 190
 
191 191
 		// The Loop.
192
-		if ( $donation_posts->have_posts() ) {
193
-			while ( $donation_posts->have_posts() ) {
192
+		if ($donation_posts->have_posts()) {
193
+			while ($donation_posts->have_posts()) {
194 194
 				$add_author = true;
195 195
 				$donation_posts->the_post();
196 196
 				global $post;
197 197
 				// Add the donation id in side the array.
198 198
 				$donation_ids[] = $post->ID;
199 199
 
200
-				$donor_id = (int) give_get_meta( $post->ID, '_give_payment_customer_id', true );
201
-				if ( ! empty( $donor_id ) ) {
202
-					$donor = new Give_Donor( $donor_id );
203
-					if ( ! empty( $donor->id ) ) {
204
-						if ( empty( $donor->user_id ) && ! empty( $donor->payment_ids ) ) {
200
+				$donor_id = (int) give_get_meta($post->ID, '_give_payment_customer_id', true);
201
+				if ( ! empty($donor_id)) {
202
+					$donor = new Give_Donor($donor_id);
203
+					if ( ! empty($donor->id)) {
204
+						if (empty($donor->user_id) && ! empty($donor->payment_ids)) {
205 205
 							$add_author = false;
206
-							$count      = (int) count( $donor->payment_ids );
207
-							if ( 1 === $count ) {
208
-								Give()->donors->delete( $donor->id );
206
+							$count      = (int) count($donor->payment_ids);
207
+							if (1 === $count) {
208
+								Give()->donors->delete($donor->id);
209 209
 							} else {
210
-								$donor->remove_payment( $post->ID );
210
+								$donor->remove_payment($post->ID);
211 211
 								$donor->decrease_donation_count();
212 212
 							}
213 213
 						}
214 214
 					}
215 215
 				}
216 216
 
217
-				if ( ! empty( $add_author ) ) {
217
+				if ( ! empty($add_author)) {
218 218
 					// Add the donor id in side the array.
219 219
 					$donor_ids[] = (int) $post->post_author;
220 220
 				}
@@ -229,23 +229,23 @@  discard block
 block discarded – undo
229 229
 		$max_num_pages = (int) $donation_posts->max_num_pages;
230 230
 
231 231
 		// Check current page is less then max number of page or not
232
-		if ( $paged < $max_num_pages ) {
232
+		if ($paged < $max_num_pages) {
233 233
 			// Update the curretn page virable for the next step
234
-			$this->update_option( $this->step_on_key, $paged );
234
+			$this->update_option($this->step_on_key, $paged);
235 235
 
236 236
 			// Calculating percentage.
237 237
 			$page_remain          = $max_num_pages - $paged;
238
-			$this->total_step     = (int) $max_num_pages + ( $total_donation / $this->per_step ) + ( ( $page_remain * 2 ) * count( $donor_ids ) );
238
+			$this->total_step     = (int) $max_num_pages + ($total_donation / $this->per_step) + (($page_remain * 2) * count($donor_ids));
239 239
 			$this->step_completed = $paged;
240 240
 		} else {
241
-			$donation_ids_count = count( $donor_ids );
242
-			$this->update_option( $this->step_key, 'donation' );
243
-			$this->update_option( $this->step_on_key, '0' );
241
+			$donation_ids_count = count($donor_ids);
242
+			$this->update_option($this->step_key, 'donation');
243
+			$this->update_option($this->step_on_key, '0');
244 244
 		}
245 245
 
246
-		$donor_ids = array_unique( $donor_ids );
247
-		$this->update_option( $this->donor_key, $donor_ids );
248
-		$this->update_option( $this->donation_key, $donation_ids );
246
+		$donor_ids = array_unique($donor_ids);
247
+		$this->update_option($this->donor_key, $donor_ids);
248
+		$this->update_option($this->donation_key, $donation_ids);
249 249
 
250 250
 		wp_reset_postdata();
251 251
 	}
@@ -257,33 +257,33 @@  discard block
 block discarded – undo
257 257
 	 * @return int
258 258
 	 */
259 259
 	public function get_percentage_complete() {
260
-		return ceil( ( 100 * $this->step_completed ) / $this->total_step );
260
+		return ceil((100 * $this->step_completed) / $this->total_step);
261 261
 	}
262 262
 
263 263
 	public function process_step() {
264 264
 
265
-		if ( ! $this->can_export() ) {
265
+		if ( ! $this->can_export()) {
266 266
 			wp_die(
267
-				esc_html__( 'You do not have permission to delete Import transactions.', 'give' ),
268
-				esc_html__( 'Error', 'give' ),
269
-				array( 'response' => 403 )
267
+				esc_html__('You do not have permission to delete Import transactions.', 'give'),
268
+				esc_html__('Error', 'give'),
269
+				array('response' => 403)
270 270
 			);
271 271
 		}
272 272
 
273 273
 		$had_data = $this->get_data();
274 274
 
275
-		if ( $had_data ) {
275
+		if ($had_data) {
276 276
 			$this->done = false;
277 277
 
278 278
 			return true;
279 279
 		} else {
280
-			update_option( 'give_earnings_total', give_get_total_earnings( true ) );
281
-			Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) );
280
+			update_option('give_earnings_total', give_get_total_earnings(true));
281
+			Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats'));
282 282
 
283
-			$this->delete_option( $this->donation_key );
283
+			$this->delete_option($this->donation_key);
284 284
 
285 285
 			$this->done    = true;
286
-			$this->message = __( 'Imported donor and transactions successfully deleted.', 'give' );
286
+			$this->message = __('Imported donor and transactions successfully deleted.', 'give');
287 287
 
288 288
 			return false;
289 289
 		}
@@ -301,12 +301,12 @@  discard block
 block discarded – undo
301 301
 	public function get_data() {
302 302
 
303 303
 		// Get the donation id's.
304
-		$donation_ids = $this->get_option( $this->donation_key );
304
+		$donation_ids = $this->get_option($this->donation_key);
305 305
 
306 306
 		/**
307 307
 		 * Return false id not Import donation is found.
308 308
 		 */
309
-		if ( empty( $donation_ids ) ) {
309
+		if (empty($donation_ids)) {
310 310
 			$this->is_empty   = true;
311 311
 			$this->total_step = 1;
312 312
 
@@ -317,110 +317,110 @@  discard block
 block discarded – undo
317 317
 		$step = (int) $this->get_step();
318 318
 
319 319
 		// get teh donor ids.
320
-		$donor_ids = $this->get_option( $this->donor_key );
320
+		$donor_ids = $this->get_option($this->donor_key);
321 321
 
322 322
 		// In step to we delete all the donation in loop.
323
-		if ( 2 === $step ) {
323
+		if (2 === $step) {
324 324
 			$pass_to_donor = false;
325 325
 			$page          = (int) $this->get_step_page();
326
-			$page ++;
327
-			$count = count( $donation_ids );
326
+			$page++;
327
+			$count = count($donation_ids);
328 328
 
329
-			$this->total_step     = ( ( count( $donation_ids ) / $this->per_step ) * 2 ) + count( $donor_ids );
329
+			$this->total_step     = ((count($donation_ids) / $this->per_step) * 2) + count($donor_ids);
330 330
 			$this->step_completed = $page;
331 331
 
332
-			if ( $count > $this->per_step ) {
332
+			if ($count > $this->per_step) {
333 333
 
334
-				$this->update_option( $this->step_on_key, $page );
335
-				$donation_ids = $this->get_delete_ids( $donation_ids, $page );
336
-				$current_page = (int) ceil( $count / $this->per_step );
334
+				$this->update_option($this->step_on_key, $page);
335
+				$donation_ids = $this->get_delete_ids($donation_ids, $page);
336
+				$current_page = (int) ceil($count / $this->per_step);
337 337
 
338
-				if ( $page === $current_page ) {
338
+				if ($page === $current_page) {
339 339
 					$pass_to_donor = true;
340 340
 				}
341 341
 			} else {
342 342
 				$pass_to_donor = true;
343 343
 			}
344 344
 
345
-			if ( true === $pass_to_donor ) {
346
-				$this->update_option( $this->step_key, 'donor' );
347
-				$this->update_option( $this->step_on_key, '0' );
345
+			if (true === $pass_to_donor) {
346
+				$this->update_option($this->step_key, 'donor');
347
+				$this->update_option($this->step_on_key, '0');
348 348
 			}
349 349
 
350 350
 			// Get the old form list.
351
-			$form_ids = (array) $this->get_option( $this->form_key );
351
+			$form_ids = (array) $this->get_option($this->form_key);
352 352
 
353
-			foreach ( $donation_ids as $item ) {
354
-				$form_ids[] = give_get_meta( $item, '_give_payment_form_id', true );
353
+			foreach ($donation_ids as $item) {
354
+				$form_ids[] = give_get_meta($item, '_give_payment_form_id', true);
355 355
 
356 356
 				// Delete the main payment.
357
-				give_delete_donation( absint( $item ) );
357
+				give_delete_donation(absint($item));
358 358
 			}
359 359
 
360 360
 			// update the new form list.
361
-			$this->update_option( $this->form_key, $form_ids );
361
+			$this->update_option($this->form_key, $form_ids);
362 362
 		}
363 363
 
364 364
 		// Here we delete all the donor
365
-		if ( 3 === $step ) {
365
+		if (3 === $step) {
366 366
 
367 367
 			// Get the old form list.
368
-			$form_ids = (array) $this->get_option( $this->form_key );
369
-			if ( ! empty( $form_ids ) ) {
370
-				$form_ids = array_unique( $form_ids );
371
-				foreach ( $form_ids as $form_id ) {
372
-					give_recount_form_income_donation( (int) $form_id );
368
+			$form_ids = (array) $this->get_option($this->form_key);
369
+			if ( ! empty($form_ids)) {
370
+				$form_ids = array_unique($form_ids);
371
+				foreach ($form_ids as $form_id) {
372
+					give_recount_form_income_donation((int) $form_id);
373 373
 				}
374 374
 			}
375 375
 			// update the new form list.
376
-			$this->update_option( $this->form_key, array() );
376
+			$this->update_option($this->form_key, array());
377 377
 
378 378
 			$page  = (int) $this->get_step_page();
379
-			$count = count( $donor_ids );
379
+			$count = count($donor_ids);
380 380
 
381
-			$this->total_step     = ( ( count( $donation_ids ) / $this->per_step ) * 2 ) + count( $donor_ids );
382
-			$this->step_completed = $page + ( count( $donation_ids ) / $this->per_step );
381
+			$this->total_step     = ((count($donation_ids) / $this->per_step) * 2) + count($donor_ids);
382
+			$this->step_completed = $page + (count($donation_ids) / $this->per_step);
383 383
 
384
-			if ( ! empty( $donor_ids[ $page ] ) ) {
385
-				$args = apply_filters( 'give_tools_reset_stats_total_args', array(
384
+			if ( ! empty($donor_ids[$page])) {
385
+				$args = apply_filters('give_tools_reset_stats_total_args', array(
386 386
 					'post_status'    => 'any',
387 387
 					'posts_per_page' => 1,
388
-					'author'         => $donor_ids[ $page ],
389
-				) );
388
+					'author'         => $donor_ids[$page],
389
+				));
390 390
 
391 391
 				$donations = array();
392
-				$payments  = new Give_Payments_Query( $args );
392
+				$payments  = new Give_Payments_Query($args);
393 393
 				$payments  = $payments->get_payments();
394
-				if ( empty( $payments ) ) {
395
-					Give()->donors->delete_by_user_id( $donor_ids[ $page ] );
394
+				if (empty($payments)) {
395
+					Give()->donors->delete_by_user_id($donor_ids[$page]);
396 396
 
397 397
 					/**
398 398
 					 * If Checked then delete WP user.
399 399
 					 *
400 400
 					 * @since 1.8.14
401 401
 					 */
402
-					$delete_import_donors = isset( $_REQUEST['delete-import-donors'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['delete-import-donors'] ) ) : '';
402
+					$delete_import_donors = isset($_REQUEST['delete-import-donors']) ? sanitize_text_field(wp_unslash($_REQUEST['delete-import-donors'])) : '';
403 403
 
404
-					if ( 'on' === (string) $delete_import_donors ) {
405
-						wp_delete_user( $donor_ids[ $page ] );
404
+					if ('on' === (string) $delete_import_donors) {
405
+						wp_delete_user($donor_ids[$page]);
406 406
 					}
407 407
 				} else {
408
-					foreach ( $payments as $payment ) {
408
+					foreach ($payments as $payment) {
409 409
 						$donations[] = $payment->ID;
410 410
 					}
411 411
 
412
-					$donor          = new Give_Donor( $donor_ids[ $page ], true );
412
+					$donor          = new Give_Donor($donor_ids[$page], true);
413 413
 					$data_to_update = array(
414
-						'purchase_count' => count( $donations ),
415
-						'payment_ids'    => implode( ',', $donations ),
414
+						'purchase_count' => count($donations),
415
+						'payment_ids'    => implode(',', $donations),
416 416
 					);
417
-					$donor->update( $data_to_update );
417
+					$donor->update($data_to_update);
418 418
 				}
419 419
 			}
420 420
 
421
-			$page ++;
422
-			$this->update_option( $this->step_on_key, $page );
423
-			if ( $count === $page ) {
421
+			$page++;
422
+			$this->update_option($this->step_on_key, $page);
423
+			if ($count === $page) {
424 424
 				$this->is_empty = false;
425 425
 
426 426
 				return false;
@@ -432,24 +432,24 @@  discard block
 block discarded – undo
432 432
 		return true;
433 433
 	}
434 434
 
435
-	public function get_delete_ids( $donation_ids, $page ) {
436
-		$index            = $page --;
437
-		$count            = count( $donation_ids );
435
+	public function get_delete_ids($donation_ids, $page) {
436
+		$index            = $page--;
437
+		$count            = count($donation_ids);
438 438
 		$temp             = 0;
439 439
 		$current_page     = 0;
440 440
 		$post_delete      = $this->per_step;
441 441
 		$page_donation_id = array();
442 442
 
443
-		foreach ( $donation_ids as $item ) {
444
-			$temp ++;
445
-			$page_donation_id[ $current_page ][] = $item;
446
-			if ( $temp === $post_delete ) {
447
-				$current_page ++;
443
+		foreach ($donation_ids as $item) {
444
+			$temp++;
445
+			$page_donation_id[$current_page][] = $item;
446
+			if ($temp === $post_delete) {
447
+				$current_page++;
448 448
 				$temp = 0;
449 449
 			}
450 450
 		}
451 451
 
452
-		return $page_donation_id[ $page ];
452
+		return $page_donation_id[$page];
453 453
 	}
454 454
 
455 455
 	/**
@@ -461,8 +461,8 @@  discard block
 block discarded – undo
461 461
 	 *
462 462
 	 * @return mixed       Returns the data from the database
463 463
 	 */
464
-	public function get_option( $key, $defalut_value = false ) {
465
-		return get_option( $key, $defalut_value );
464
+	public function get_option($key, $defalut_value = false) {
465
+		return get_option($key, $defalut_value);
466 466
 	}
467 467
 
468 468
 	/**
@@ -475,8 +475,8 @@  discard block
 block discarded – undo
475 475
 	 *
476 476
 	 * @return void
477 477
 	 */
478
-	public function update_option( $key, $value ) {
479
-		update_option( $key, $value, false );
478
+	public function update_option($key, $value) {
479
+		update_option($key, $value, false);
480 480
 	}
481 481
 
482 482
 	/**
@@ -488,8 +488,8 @@  discard block
 block discarded – undo
488 488
 	 *
489 489
 	 * @return void
490 490
 	 */
491
-	public function delete_option( $key ) {
492
-		delete_option( $key );
491
+	public function delete_option($key) {
492
+		delete_option($key);
493 493
 	}
494 494
 
495 495
 	/**
@@ -500,12 +500,12 @@  discard block
 block discarded – undo
500 500
 	 * @return int|string
501 501
 	 */
502 502
 	private function get_step() {
503
-		$step_key = (string) $this->get_option( $this->step_key, false );
504
-		if ( 'count' === $step_key ) {
503
+		$step_key = (string) $this->get_option($this->step_key, false);
504
+		if ('count' === $step_key) {
505 505
 			return 1;
506
-		} elseif ( 'donation' === $step_key ) {
506
+		} elseif ('donation' === $step_key) {
507 507
 			return 2;
508
-		} elseif ( 'donor' === $step_key ) {
508
+		} elseif ('donor' === $step_key) {
509 509
 			return 3;
510 510
 		} else {
511 511
 			return $step_key;
@@ -516,6 +516,6 @@  discard block
 block discarded – undo
516 516
 	 * Get the current $page value in the ajax.
517 517
 	 */
518 518
 	private function get_step_page() {
519
-		return $this->get_option( $this->step_on_key, false );
519
+		return $this->get_option($this->step_on_key, false);
520 520
 	}
521 521
 }
Please login to merge, or discard this patch.
includes/class-give-donor.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -918,7 +918,7 @@
 block discarded – undo
918 918
 	 * @access public
919 919
 	 *
920 920
 	 * @param  string $meta_key Metadata name. Default is empty.
921
-	 * @param  mixed $meta_value Optional. Metadata value. Default is empty.
921
+	 * @param  string $meta_value Optional. Metadata value. Default is empty.
922 922
 	 *
923 923
 	 * @return bool               False for failure. True for success.
924 924
 	 */
Please login to merge, or discard this patch.
Spacing   +254 added lines, -261 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
 
@@ -149,32 +149,32 @@  discard block
 block discarded – undo
149 149
 	 * @param int|bool $_id_or_email
150 150
 	 * @param bool     $by_user_id
151 151
 	 */
152
-	public function __construct( $_id_or_email = false, $by_user_id = false ) {
152
+	public function __construct($_id_or_email = false, $by_user_id = false) {
153 153
 
154 154
 		$this->db = Give()->donors;
155 155
 
156 156
 		if (
157 157
 			false === $_id_or_email
158
-			|| ( is_numeric( $_id_or_email ) && (int) $_id_or_email !== absint( $_id_or_email ) )
158
+			|| (is_numeric($_id_or_email) && (int) $_id_or_email !== absint($_id_or_email))
159 159
 		) {
160 160
 			return false;
161 161
 		}
162 162
 
163
-		$by_user_id = is_bool( $by_user_id ) ? $by_user_id : false;
163
+		$by_user_id = is_bool($by_user_id) ? $by_user_id : false;
164 164
 
165
-		if ( is_numeric( $_id_or_email ) ) {
165
+		if (is_numeric($_id_or_email)) {
166 166
 			$field = $by_user_id ? 'user_id' : 'id';
167 167
 		} else {
168 168
 			$field = 'email';
169 169
 		}
170 170
 
171
-		$donor = $this->db->get_donor_by( $field, $_id_or_email );
171
+		$donor = $this->db->get_donor_by($field, $_id_or_email);
172 172
 
173
-		if ( empty( $donor ) || ! is_object( $donor ) ) {
173
+		if (empty($donor) || ! is_object($donor)) {
174 174
 			return false;
175 175
 		}
176 176
 
177
-		$this->setup_donor( $donor );
177
+		$this->setup_donor($donor);
178 178
 
179 179
 	}
180 180
 
@@ -190,19 +190,19 @@  discard block
 block discarded – undo
190 190
 	 *
191 191
 	 * @return bool             If the setup was successful or not.
192 192
 	 */
193
-	private function setup_donor( $donor ) {
193
+	private function setup_donor($donor) {
194 194
 
195
-		if ( ! is_object( $donor ) ) {
195
+		if ( ! is_object($donor)) {
196 196
 			return false;
197 197
 		}
198 198
 
199 199
 		// Get cached donors.
200
-		$donor_vars = Give_Cache::get_group( $donor->id, 'give-donors' );
200
+		$donor_vars = Give_Cache::get_group($donor->id, 'give-donors');
201 201
 
202
-		if( is_null( $donor_vars ) ){
203
-			foreach ( $donor as $key => $value ) {
202
+		if (is_null($donor_vars)) {
203
+			foreach ($donor as $key => $value) {
204 204
 
205
-				switch ( $key ) {
205
+				switch ($key) {
206 206
 
207 207
 					case 'notes':
208 208
 						$this->$key = $this->get_notes();
@@ -216,20 +216,20 @@  discard block
 block discarded – undo
216 216
 			}
217 217
 
218 218
 			// Get donor's all email including primary email.
219
-			$this->emails = (array) $this->get_meta( 'additional_email', false );
220
-			$this->emails = array( 'primary' => $this->email ) + $this->emails;
219
+			$this->emails = (array) $this->get_meta('additional_email', false);
220
+			$this->emails = array('primary' => $this->email) + $this->emails;
221 221
 
222 222
 			$this->setup_address();
223 223
 
224
-			Give_Cache::set_group( $donor->id, get_object_vars( $this ), 'give-donors' );
225
-		} else{
226
-			foreach ( $donor_vars as $donor_var => $value ) {
224
+			Give_Cache::set_group($donor->id, get_object_vars($this), 'give-donors');
225
+		} else {
226
+			foreach ($donor_vars as $donor_var => $value) {
227 227
 				$this->$donor_var = $value;
228 228
 			}
229 229
 		}
230 230
 
231 231
 		// Donor ID and email are the only things that are necessary, make sure they exist.
232
-		if ( ! empty( $this->id ) && ! empty( $this->email ) ) {
232
+		if ( ! empty($this->id) && ! empty($this->email)) {
233 233
 			return true;
234 234
 		}
235 235
 
@@ -262,18 +262,18 @@  discard block
 block discarded – undo
262 262
 			ARRAY_N
263 263
 		);
264 264
 
265
-		if ( empty( $addresses ) ) {
265
+		if (empty($addresses)) {
266 266
 			return $this->address;
267 267
 		}
268 268
 
269
-		foreach ( $addresses as $address ) {
270
-			$address[0] = str_replace( '_give_donor_address_', '', $address[0] );
271
-			$address[0] = explode( '_', $address[0] );
269
+		foreach ($addresses as $address) {
270
+			$address[0] = str_replace('_give_donor_address_', '', $address[0]);
271
+			$address[0] = explode('_', $address[0]);
272 272
 
273
-			if ( 3 === count( $address[0] ) ) {
274
-				$this->address[ $address[0][0] ][ $address[0][2] ][ $address[0][1] ] = $address[1];
273
+			if (3 === count($address[0])) {
274
+				$this->address[$address[0][0]][$address[0][2]][$address[0][1]] = $address[1];
275 275
 			} else {
276
-				$this->address[ $address[0][0] ][ $address[0][1] ] = $address[1];
276
+				$this->address[$address[0][0]][$address[0][1]] = $address[1];
277 277
 			}
278 278
 		}
279 279
 	}
@@ -287,16 +287,16 @@  discard block
 block discarded – undo
287 287
 	 *
288 288
 	 * @return mixed|\WP_Error
289 289
 	 */
290
-	public function __get( $key ) {
290
+	public function __get($key) {
291 291
 
292
-		if ( method_exists( $this, 'get_' . $key ) ) {
292
+		if (method_exists($this, 'get_'.$key)) {
293 293
 
294
-			return call_user_func( array( $this, 'get_' . $key ) );
294
+			return call_user_func(array($this, 'get_'.$key));
295 295
 
296 296
 		} else {
297 297
 
298 298
 			/* translators: %s: property key */
299
-			return new WP_Error( 'give-donor-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) );
299
+			return new WP_Error('give-donor-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key));
300 300
 
301 301
 		}
302 302
 
@@ -312,9 +312,9 @@  discard block
 block discarded – undo
312 312
 	 *
313 313
 	 * @return bool|int    False if not a valid creation, donor ID if user is found or valid creation.
314 314
 	 */
315
-	public function create( $data = array() ) {
315
+	public function create($data = array()) {
316 316
 
317
-		if ( $this->id != 0 || empty( $data ) ) {
317
+		if ($this->id != 0 || empty($data)) {
318 318
 			return false;
319 319
 		}
320 320
 
@@ -322,15 +322,15 @@  discard block
 block discarded – undo
322 322
 			'payment_ids' => '',
323 323
 		);
324 324
 
325
-		$args = wp_parse_args( $data, $defaults );
326
-		$args = $this->sanitize_columns( $args );
325
+		$args = wp_parse_args($data, $defaults);
326
+		$args = $this->sanitize_columns($args);
327 327
 
328
-		if ( empty( $args['email'] ) || ! is_email( $args['email'] ) ) {
328
+		if (empty($args['email']) || ! is_email($args['email'])) {
329 329
 			return false;
330 330
 		}
331 331
 
332
-		if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) {
333
-			$args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) );
332
+		if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) {
333
+			$args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids'])));
334 334
 		}
335 335
 
336 336
 		/**
@@ -340,18 +340,18 @@  discard block
 block discarded – undo
340 340
 		 *
341 341
 		 * @param array $args Donor attributes.
342 342
 		 */
343
-		do_action( 'give_donor_pre_create', $args );
343
+		do_action('give_donor_pre_create', $args);
344 344
 
345 345
 		$created = false;
346 346
 
347 347
 		// The DB class 'add' implies an update if the donor being asked to be created already exists
348
-		if ( $this->db->add( $data ) ) {
348
+		if ($this->db->add($data)) {
349 349
 
350 350
 			// We've successfully added/updated the donor, reset the class vars with the new data
351
-			$donor = $this->db->get_donor_by( 'email', $args['email'] );
351
+			$donor = $this->db->get_donor_by('email', $args['email']);
352 352
 
353 353
 			// Setup the donor data with the values from DB
354
-			$this->setup_donor( $donor );
354
+			$this->setup_donor($donor);
355 355
 
356 356
 			$created = $this->id;
357 357
 		}
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
 		 * @param bool|int $created False if not a valid creation, donor ID if user is found or valid creation.
365 365
 		 * @param array $args Customer attributes.
366 366
 		 */
367
-		do_action( 'give_donor_post_create', $created, $args );
367
+		do_action('give_donor_post_create', $created, $args);
368 368
 
369 369
 		return $created;
370 370
 
@@ -380,13 +380,13 @@  discard block
 block discarded – undo
380 380
 	 *
381 381
 	 * @return bool        If the update was successful or not.
382 382
 	 */
383
-	public function update( $data = array() ) {
383
+	public function update($data = array()) {
384 384
 
385
-		if ( empty( $data ) ) {
385
+		if (empty($data)) {
386 386
 			return false;
387 387
 		}
388 388
 
389
-		$data = $this->sanitize_columns( $data );
389
+		$data = $this->sanitize_columns($data);
390 390
 
391 391
 		/**
392 392
 		 * Fires before updating donors.
@@ -396,15 +396,15 @@  discard block
 block discarded – undo
396 396
 		 * @param int $donor_id Donor id.
397 397
 		 * @param array $data Donor attributes.
398 398
 		 */
399
-		do_action( 'give_donor_pre_update', $this->id, $data );
399
+		do_action('give_donor_pre_update', $this->id, $data);
400 400
 
401 401
 		$updated = false;
402 402
 
403
-		if ( $this->db->update( $this->id, $data ) ) {
403
+		if ($this->db->update($this->id, $data)) {
404 404
 
405
-			$donor = $this->db->get_donor_by( 'id', $this->id );
405
+			$donor = $this->db->get_donor_by('id', $this->id);
406 406
 
407
-			$this->setup_donor( $donor );
407
+			$this->setup_donor($donor);
408 408
 
409 409
 			$updated = true;
410 410
 		}
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 		 * @param int $donor_id Donor id.
419 419
 		 * @param array $data Donor attributes.
420 420
 		 */
421
-		do_action( 'give_donor_post_update', $updated, $this->id, $data );
421
+		do_action('give_donor_post_update', $updated, $this->id, $data);
422 422
 
423 423
 		return $updated;
424 424
 	}
@@ -436,27 +436,27 @@  discard block
 block discarded – undo
436 436
 	 *
437 437
 	 * @return bool            If the attachment was successfully.
438 438
 	 */
439
-	public function attach_payment( $payment_id = 0, $update_stats = true ) {
439
+	public function attach_payment($payment_id = 0, $update_stats = true) {
440 440
 
441
-		if ( empty( $payment_id ) ) {
441
+		if (empty($payment_id)) {
442 442
 			return false;
443 443
 		}
444 444
 
445
-		if ( empty( $this->payment_ids ) ) {
445
+		if (empty($this->payment_ids)) {
446 446
 
447 447
 			$new_payment_ids = $payment_id;
448 448
 
449 449
 		} else {
450 450
 
451
-			$payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) );
451
+			$payment_ids = array_map('absint', explode(',', $this->payment_ids));
452 452
 
453
-			if ( in_array( $payment_id, $payment_ids ) ) {
453
+			if (in_array($payment_id, $payment_ids)) {
454 454
 				$update_stats = false;
455 455
 			}
456 456
 
457 457
 			$payment_ids[] = $payment_id;
458 458
 
459
-			$new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) );
459
+			$new_payment_ids = implode(',', array_unique(array_values($payment_ids)));
460 460
 
461 461
 		}
462 462
 
@@ -468,20 +468,20 @@  discard block
 block discarded – undo
468 468
 		 * @param int $payment_id Payment id.
469 469
 		 * @param int $donor_id Customer id.
470 470
 		 */
471
-		do_action( 'give_donor_pre_attach_payment', $payment_id, $this->id );
471
+		do_action('give_donor_pre_attach_payment', $payment_id, $this->id);
472 472
 
473
-		$payment_added = $this->update( array( 'payment_ids' => $new_payment_ids ) );
473
+		$payment_added = $this->update(array('payment_ids' => $new_payment_ids));
474 474
 
475
-		if ( $payment_added ) {
475
+		if ($payment_added) {
476 476
 
477 477
 			$this->payment_ids = $new_payment_ids;
478 478
 
479 479
 			// We added this payment successfully, increment the stats
480
-			if ( $update_stats ) {
481
-				$payment_amount = give_donation_amount( $payment_id, array( 'type' => 'stats' ) );
480
+			if ($update_stats) {
481
+				$payment_amount = give_donation_amount($payment_id, array('type' => 'stats'));
482 482
 
483
-				if ( ! empty( $payment_amount ) ) {
484
-					$this->increase_value( $payment_amount );
483
+				if ( ! empty($payment_amount)) {
484
+					$this->increase_value($payment_amount);
485 485
 				}
486 486
 
487 487
 				$this->increase_purchase_count();
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
 		 * @param int $payment_id Payment id.
498 498
 		 * @param int $donor_id Donor id.
499 499
 		 */
500
-		do_action( 'give_donor_post_attach_payment', $payment_added, $payment_id, $this->id );
500
+		do_action('give_donor_post_attach_payment', $payment_added, $payment_id, $this->id);
501 501
 
502 502
 		return $payment_added;
503 503
 	}
@@ -515,33 +515,33 @@  discard block
 block discarded – undo
515 515
 	 *
516 516
 	 * @return boolean               If the removal was successful.
517 517
 	 */
518
-	public function remove_payment( $payment_id = 0, $update_stats = true ) {
518
+	public function remove_payment($payment_id = 0, $update_stats = true) {
519 519
 
520
-		if ( empty( $payment_id ) ) {
520
+		if (empty($payment_id)) {
521 521
 			return false;
522 522
 		}
523 523
 
524
-		$payment = new Give_Payment( $payment_id );
524
+		$payment = new Give_Payment($payment_id);
525 525
 
526
-		if ( 'publish' !== $payment->status && 'revoked' !== $payment->status ) {
526
+		if ('publish' !== $payment->status && 'revoked' !== $payment->status) {
527 527
 			$update_stats = false;
528 528
 		}
529 529
 
530 530
 		$new_payment_ids = '';
531 531
 
532
-		if ( ! empty( $this->payment_ids ) ) {
532
+		if ( ! empty($this->payment_ids)) {
533 533
 
534
-			$payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) );
534
+			$payment_ids = array_map('absint', explode(',', $this->payment_ids));
535 535
 
536
-			$pos = array_search( $payment_id, $payment_ids );
537
-			if ( false === $pos ) {
536
+			$pos = array_search($payment_id, $payment_ids);
537
+			if (false === $pos) {
538 538
 				return false;
539 539
 			}
540 540
 
541
-			unset( $payment_ids[ $pos ] );
542
-			$payment_ids = array_filter( $payment_ids );
541
+			unset($payment_ids[$pos]);
542
+			$payment_ids = array_filter($payment_ids);
543 543
 
544
-			$new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) );
544
+			$new_payment_ids = implode(',', array_unique(array_values($payment_ids)));
545 545
 
546 546
 		}
547 547
 
@@ -553,20 +553,20 @@  discard block
 block discarded – undo
553 553
 		 * @param int $payment_id Payment id.
554 554
 		 * @param int $donor_id Customer id.
555 555
 		 */
556
-		do_action( 'give_donor_pre_remove_payment', $payment_id, $this->id );
556
+		do_action('give_donor_pre_remove_payment', $payment_id, $this->id);
557 557
 
558
-		$payment_removed = $this->update( array( 'payment_ids' => $new_payment_ids ) );
558
+		$payment_removed = $this->update(array('payment_ids' => $new_payment_ids));
559 559
 
560
-		if ( $payment_removed ) {
560
+		if ($payment_removed) {
561 561
 
562 562
 			$this->payment_ids = $new_payment_ids;
563 563
 
564
-			if ( $update_stats ) {
564
+			if ($update_stats) {
565 565
 				// We removed this payment successfully, decrement the stats
566
-				$payment_amount = give_donation_amount( $payment_id );
566
+				$payment_amount = give_donation_amount($payment_id);
567 567
 
568
-				if ( ! empty( $payment_amount ) ) {
569
-					$this->decrease_value( $payment_amount );
568
+				if ( ! empty($payment_amount)) {
569
+					$this->decrease_value($payment_amount);
570 570
 				}
571 571
 
572 572
 				$this->decrease_donation_count();
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
 		 * @param int $payment_id Payment id.
583 583
 		 * @param int $donor_id Donor id.
584 584
 		 */
585
-		do_action( 'give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id );
585
+		do_action('give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id);
586 586
 
587 587
 		return $payment_removed;
588 588
 
@@ -598,10 +598,10 @@  discard block
 block discarded – undo
598 598
 	 *
599 599
 	 * @return int        The donation count.
600 600
 	 */
601
-	public function increase_purchase_count( $count = 1 ) {
601
+	public function increase_purchase_count($count = 1) {
602 602
 
603 603
 		// Make sure it's numeric and not negative.
604
-		if ( ! is_numeric( $count ) || $count != absint( $count ) ) {
604
+		if ( ! is_numeric($count) || $count != absint($count)) {
605 605
 			return false;
606 606
 		}
607 607
 
@@ -615,9 +615,9 @@  discard block
 block discarded – undo
615 615
 		 * @param int $count The number to increase by.
616 616
 		 * @param int $donor_id Donor id.
617 617
 		 */
618
-		do_action( 'give_donor_pre_increase_donation_count', $count, $this->id );
618
+		do_action('give_donor_pre_increase_donation_count', $count, $this->id);
619 619
 
620
-		if ( $this->update( array( 'purchase_count' => $new_total ) ) ) {
620
+		if ($this->update(array('purchase_count' => $new_total))) {
621 621
 			$this->purchase_count = $new_total;
622 622
 		}
623 623
 
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
 		 * @param int $count The number increased by.
631 631
 		 * @param int $donor_id Donor id.
632 632
 		 */
633
-		do_action( 'give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id );
633
+		do_action('give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id);
634 634
 
635 635
 		return $this->purchase_count;
636 636
 	}
@@ -645,16 +645,16 @@  discard block
 block discarded – undo
645 645
 	 *
646 646
 	 * @return mixed      If successful, the new count, otherwise false.
647 647
 	 */
648
-	public function decrease_donation_count( $count = 1 ) {
648
+	public function decrease_donation_count($count = 1) {
649 649
 
650 650
 		// Make sure it's numeric and not negative
651
-		if ( ! is_numeric( $count ) || $count != absint( $count ) ) {
651
+		if ( ! is_numeric($count) || $count != absint($count)) {
652 652
 			return false;
653 653
 		}
654 654
 
655 655
 		$new_total = (int) $this->purchase_count - (int) $count;
656 656
 
657
-		if ( $new_total < 0 ) {
657
+		if ($new_total < 0) {
658 658
 			$new_total = 0;
659 659
 		}
660 660
 
@@ -666,9 +666,9 @@  discard block
 block discarded – undo
666 666
 		 * @param int $count The number to decrease by.
667 667
 		 * @param int $donor_id Customer id.
668 668
 		 */
669
-		do_action( 'give_donor_pre_decrease_donation_count', $count, $this->id );
669
+		do_action('give_donor_pre_decrease_donation_count', $count, $this->id);
670 670
 
671
-		if ( $this->update( array( 'purchase_count' => $new_total ) ) ) {
671
+		if ($this->update(array('purchase_count' => $new_total))) {
672 672
 			$this->purchase_count = $new_total;
673 673
 		}
674 674
 
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
 		 * @param int $count The number decreased by.
682 682
 		 * @param int $donor_id Donor id.
683 683
 		 */
684
-		do_action( 'give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id );
684
+		do_action('give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id);
685 685
 
686 686
 		return $this->purchase_count;
687 687
 	}
@@ -696,9 +696,9 @@  discard block
 block discarded – undo
696 696
 	 *
697 697
 	 * @return mixed        If successful, the new value, otherwise false.
698 698
 	 */
699
-	public function increase_value( $value = 0.00 ) {
699
+	public function increase_value($value = 0.00) {
700 700
 
701
-		$new_value = floatval( $this->purchase_value ) + $value;
701
+		$new_value = floatval($this->purchase_value) + $value;
702 702
 
703 703
 		/**
704 704
 		 * Fires before increasing donor lifetime value.
@@ -708,9 +708,9 @@  discard block
 block discarded – undo
708 708
 		 * @param float $value The value to increase by.
709 709
 		 * @param int $donor_id Customer id.
710 710
 		 */
711
-		do_action( 'give_donor_pre_increase_value', $value, $this->id );
711
+		do_action('give_donor_pre_increase_value', $value, $this->id);
712 712
 
713
-		if ( $this->update( array( 'purchase_value' => $new_value ) ) ) {
713
+		if ($this->update(array('purchase_value' => $new_value))) {
714 714
 			$this->purchase_value = $new_value;
715 715
 		}
716 716
 
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
 		 * @param float $value The value increased by.
724 724
 		 * @param int $donor_id Donor id.
725 725
 		 */
726
-		do_action( 'give_donor_post_increase_value', $this->purchase_value, $value, $this->id );
726
+		do_action('give_donor_post_increase_value', $this->purchase_value, $value, $this->id);
727 727
 
728 728
 		return $this->purchase_value;
729 729
 	}
@@ -738,11 +738,11 @@  discard block
 block discarded – undo
738 738
 	 *
739 739
 	 * @return mixed        If successful, the new value, otherwise false.
740 740
 	 */
741
-	public function decrease_value( $value = 0.00 ) {
741
+	public function decrease_value($value = 0.00) {
742 742
 
743
-		$new_value = floatval( $this->purchase_value ) - $value;
743
+		$new_value = floatval($this->purchase_value) - $value;
744 744
 
745
-		if ( $new_value < 0 ) {
745
+		if ($new_value < 0) {
746 746
 			$new_value = 0.00;
747 747
 		}
748 748
 
@@ -754,9 +754,9 @@  discard block
 block discarded – undo
754 754
 		 * @param float $value The value to decrease by.
755 755
 		 * @param int $donor_id Donor id.
756 756
 		 */
757
-		do_action( 'give_donor_pre_decrease_value', $value, $this->id );
757
+		do_action('give_donor_pre_decrease_value', $value, $this->id);
758 758
 
759
-		if ( $this->update( array( 'purchase_value' => $new_value ) ) ) {
759
+		if ($this->update(array('purchase_value' => $new_value))) {
760 760
 			$this->purchase_value = $new_value;
761 761
 		}
762 762
 
@@ -769,7 +769,7 @@  discard block
 block discarded – undo
769 769
 		 * @param float $value The value decreased by.
770 770
 		 * @param int $donor_id Donor id.
771 771
 		 */
772
-		do_action( 'give_donor_post_decrease_value', $this->purchase_value, $value, $this->id );
772
+		do_action('give_donor_post_decrease_value', $this->purchase_value, $value, $this->id);
773 773
 
774 774
 		return $this->purchase_value;
775 775
 	}
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
 	 *
789 789
 	 * @return mixed              If successful, the new donation stat value, otherwise false.
790 790
 	 */
791
-	public function update_donation_value( $curr_amount, $new_amount ) {
791
+	public function update_donation_value($curr_amount, $new_amount) {
792 792
 		/**
793 793
 		 * Payment total difference value can be:
794 794
 		 *  zero   (in case amount not change)
@@ -798,15 +798,15 @@  discard block
 block discarded – undo
798 798
 		$payment_total_diff = $new_amount - $curr_amount;
799 799
 
800 800
 		// We do not need to update donation stat if donation did not change.
801
-		if ( ! $payment_total_diff ) {
801
+		if ( ! $payment_total_diff) {
802 802
 			return false;
803 803
 		}
804 804
 
805
-		if ( $payment_total_diff > 0 ) {
806
-			$this->increase_value( $payment_total_diff );
805
+		if ($payment_total_diff > 0) {
806
+			$this->increase_value($payment_total_diff);
807 807
 		} else {
808 808
 			// Pass payment total difference as +ve value to decrease amount from user lifetime stat.
809
-			$this->decrease_value( - $payment_total_diff );
809
+			$this->decrease_value( -$payment_total_diff );
810 810
 		}
811 811
 
812 812
 		return $this->purchase_value;
@@ -823,15 +823,15 @@  discard block
 block discarded – undo
823 823
 	 *
824 824
 	 * @return array       The notes requested.
825 825
 	 */
826
-	public function get_notes( $length = 20, $paged = 1 ) {
826
+	public function get_notes($length = 20, $paged = 1) {
827 827
 
828
-		$length = is_numeric( $length ) ? $length : 20;
829
-		$offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0;
828
+		$length = is_numeric($length) ? $length : 20;
829
+		$offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0;
830 830
 
831 831
 		$all_notes   = $this->get_raw_notes();
832
-		$notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) );
832
+		$notes_array = array_reverse(array_filter(explode("\n\n", $all_notes)));
833 833
 
834
-		$desired_notes = array_slice( $notes_array, $offset, $length );
834
+		$desired_notes = array_slice($notes_array, $offset, $length);
835 835
 
836 836
 		return $desired_notes;
837 837
 
@@ -848,9 +848,9 @@  discard block
 block discarded – undo
848 848
 	public function get_notes_count() {
849 849
 
850 850
 		$all_notes   = $this->get_raw_notes();
851
-		$notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) );
851
+		$notes_array = array_reverse(array_filter(explode("\n\n", $all_notes)));
852 852
 
853
-		return count( $notes_array );
853
+		return count($notes_array);
854 854
 
855 855
 	}
856 856
 
@@ -863,7 +863,7 @@  discard block
 block discarded – undo
863 863
 	 *
864 864
 	 * @return string|float
865 865
 	 */
866
-	public function get_total_donation_amount( $args = array() ) {
866
+	public function get_total_donation_amount($args = array()) {
867 867
 
868 868
 		/**
869 869
 		 * Filter total donation amount.
@@ -874,7 +874,7 @@  discard block
 block discarded – undo
874 874
 		 * @param integer      $donor_id       Donor ID.
875 875
 		 * @param array        $args           Pass additional data.
876 876
 		 */
877
-		return apply_filters( 'give_get_total_donation_amount', $this->purchase_value, $this->id, $args );
877
+		return apply_filters('give_get_total_donation_amount', $this->purchase_value, $this->id, $args);
878 878
 	}
879 879
 
880 880
 	/**
@@ -887,22 +887,22 @@  discard block
 block discarded – undo
887 887
 	 *
888 888
 	 * @return string|boolean The new note if added successfully, false otherwise.
889 889
 	 */
890
-	public function add_note( $note = '' ) {
890
+	public function add_note($note = '') {
891 891
 
892
-		$note = trim( $note );
893
-		if ( empty( $note ) ) {
892
+		$note = trim($note);
893
+		if (empty($note)) {
894 894
 			return false;
895 895
 		}
896 896
 
897 897
 		$notes = $this->get_raw_notes();
898 898
 
899
-		if ( empty( $notes ) ) {
899
+		if (empty($notes)) {
900 900
 			$notes = '';
901 901
 		}
902 902
 
903
-		$note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note;
904
-		$new_note    = apply_filters( 'give_customer_add_note_string', $note_string );
905
-		$notes       .= "\n\n" . $new_note;
903
+		$note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')).' - '.$note;
904
+		$new_note    = apply_filters('give_customer_add_note_string', $note_string);
905
+		$notes .= "\n\n".$new_note;
906 906
 
907 907
 		/**
908 908
 		 * Fires before donor note is added.
@@ -912,11 +912,11 @@  discard block
 block discarded – undo
912 912
 		 * @param string $new_note New note to add.
913 913
 		 * @param int $donor_id Donor id.
914 914
 		 */
915
-		do_action( 'give_donor_pre_add_note', $new_note, $this->id );
915
+		do_action('give_donor_pre_add_note', $new_note, $this->id);
916 916
 
917
-		$updated = $this->update( array( 'notes' => $notes ) );
917
+		$updated = $this->update(array('notes' => $notes));
918 918
 
919
-		if ( $updated ) {
919
+		if ($updated) {
920 920
 			$this->notes = $this->get_notes();
921 921
 		}
922 922
 
@@ -929,7 +929,7 @@  discard block
 block discarded – undo
929 929
 		 * @param string $new_note New note added.
930 930
 		 * @param int $donor_id Donor id.
931 931
 		 */
932
-		do_action( 'give_donor_post_add_note', $this->notes, $new_note, $this->id );
932
+		do_action('give_donor_post_add_note', $this->notes, $new_note, $this->id);
933 933
 
934 934
 		// Return the formatted note, so we can test, as well as update any displays
935 935
 		return $new_note;
@@ -946,7 +946,7 @@  discard block
 block discarded – undo
946 946
 	 */
947 947
 	private function get_raw_notes() {
948 948
 
949
-		$all_notes = $this->db->get_column( 'notes', $this->id );
949
+		$all_notes = $this->db->get_column('notes', $this->id);
950 950
 
951 951
 		return $all_notes;
952 952
 
@@ -963,8 +963,8 @@  discard block
 block discarded – undo
963 963
 	 *
964 964
 	 * @return mixed            Will be an array if $single is false. Will be value of meta data field if $single is true.
965 965
 	 */
966
-	public function get_meta( $meta_key = '', $single = true ) {
967
-		return Give()->donor_meta->get_meta( $this->id, $meta_key, $single );
966
+	public function get_meta($meta_key = '', $single = true) {
967
+		return Give()->donor_meta->get_meta($this->id, $meta_key, $single);
968 968
 	}
969 969
 
970 970
 	/**
@@ -979,8 +979,8 @@  discard block
 block discarded – undo
979 979
 	 *
980 980
 	 * @return bool               False for failure. True for success.
981 981
 	 */
982
-	public function add_meta( $meta_key = '', $meta_value, $unique = false ) {
983
-		return Give()->donor_meta->add_meta( $this->id, $meta_key, $meta_value, $unique );
982
+	public function add_meta($meta_key = '', $meta_value, $unique = false) {
983
+		return Give()->donor_meta->add_meta($this->id, $meta_key, $meta_value, $unique);
984 984
 	}
985 985
 
986 986
 	/**
@@ -995,8 +995,8 @@  discard block
 block discarded – undo
995 995
 	 *
996 996
 	 * @return bool               False on failure, true if success.
997 997
 	 */
998
-	public function update_meta( $meta_key = '', $meta_value, $prev_value = '' ) {
999
-		return Give()->donor_meta->update_meta( $this->id, $meta_key, $meta_value, $prev_value );
998
+	public function update_meta($meta_key = '', $meta_value, $prev_value = '') {
999
+		return Give()->donor_meta->update_meta($this->id, $meta_key, $meta_value, $prev_value);
1000 1000
 	}
1001 1001
 
1002 1002
 	/**
@@ -1010,8 +1010,8 @@  discard block
 block discarded – undo
1010 1010
 	 *
1011 1011
 	 * @return bool               False for failure. True for success.
1012 1012
 	 */
1013
-	public function delete_meta( $meta_key = '', $meta_value = '' ) {
1014
-		return Give()->donor_meta->delete_meta( $this->id, $meta_key, $meta_value );
1013
+	public function delete_meta($meta_key = '', $meta_value = '') {
1014
+		return Give()->donor_meta->delete_meta($this->id, $meta_key, $meta_value);
1015 1015
 	}
1016 1016
 
1017 1017
 	/**
@@ -1024,51 +1024,51 @@  discard block
 block discarded – undo
1024 1024
 	 *
1025 1025
 	 * @return array       The sanitized data, based off column defaults.
1026 1026
 	 */
1027
-	private function sanitize_columns( $data ) {
1027
+	private function sanitize_columns($data) {
1028 1028
 
1029 1029
 		$columns        = $this->db->get_columns();
1030 1030
 		$default_values = $this->db->get_column_defaults();
1031 1031
 
1032
-		foreach ( $columns as $key => $type ) {
1032
+		foreach ($columns as $key => $type) {
1033 1033
 
1034 1034
 			// Only sanitize data that we were provided
1035
-			if ( ! array_key_exists( $key, $data ) ) {
1035
+			if ( ! array_key_exists($key, $data)) {
1036 1036
 				continue;
1037 1037
 			}
1038 1038
 
1039
-			switch ( $type ) {
1039
+			switch ($type) {
1040 1040
 
1041 1041
 				case '%s':
1042
-					if ( 'email' == $key ) {
1043
-						$data[ $key ] = sanitize_email( $data[ $key ] );
1044
-					} elseif ( 'notes' == $key ) {
1045
-						$data[ $key ] = strip_tags( $data[ $key ] );
1042
+					if ('email' == $key) {
1043
+						$data[$key] = sanitize_email($data[$key]);
1044
+					} elseif ('notes' == $key) {
1045
+						$data[$key] = strip_tags($data[$key]);
1046 1046
 					} else {
1047
-						$data[ $key ] = sanitize_text_field( $data[ $key ] );
1047
+						$data[$key] = sanitize_text_field($data[$key]);
1048 1048
 					}
1049 1049
 					break;
1050 1050
 
1051 1051
 				case '%d':
1052
-					if ( ! is_numeric( $data[ $key ] ) || (int) $data[ $key ] !== absint( $data[ $key ] ) ) {
1053
-						$data[ $key ] = $default_values[ $key ];
1052
+					if ( ! is_numeric($data[$key]) || (int) $data[$key] !== absint($data[$key])) {
1053
+						$data[$key] = $default_values[$key];
1054 1054
 					} else {
1055
-						$data[ $key ] = absint( $data[ $key ] );
1055
+						$data[$key] = absint($data[$key]);
1056 1056
 					}
1057 1057
 					break;
1058 1058
 
1059 1059
 				case '%f':
1060 1060
 					// Convert what was given to a float
1061
-					$value = floatval( $data[ $key ] );
1061
+					$value = floatval($data[$key]);
1062 1062
 
1063
-					if ( ! is_float( $value ) ) {
1064
-						$data[ $key ] = $default_values[ $key ];
1063
+					if ( ! is_float($value)) {
1064
+						$data[$key] = $default_values[$key];
1065 1065
 					} else {
1066
-						$data[ $key ] = $value;
1066
+						$data[$key] = $value;
1067 1067
 					}
1068 1068
 					break;
1069 1069
 
1070 1070
 				default:
1071
-					$data[ $key ] = sanitize_text_field( $data[ $key ] );
1071
+					$data[$key] = sanitize_text_field($data[$key]);
1072 1072
 					break;
1073 1073
 
1074 1074
 			}
@@ -1088,33 +1088,33 @@  discard block
 block discarded – undo
1088 1088
 	 *
1089 1089
 	 * @return bool            If the email was added successfully
1090 1090
 	 */
1091
-	public function add_email( $email = '', $primary = false ) {
1092
-		if ( ! is_email( $email ) ) {
1091
+	public function add_email($email = '', $primary = false) {
1092
+		if ( ! is_email($email)) {
1093 1093
 			return false;
1094 1094
 		}
1095
-		$existing = new Give_Donor( $email );
1095
+		$existing = new Give_Donor($email);
1096 1096
 
1097
-		if ( $existing->id > 0 ) {
1097
+		if ($existing->id > 0) {
1098 1098
 			// Email address already belongs to another donor
1099 1099
 			return false;
1100 1100
 		}
1101 1101
 
1102
-		if ( email_exists( $email ) ) {
1103
-			$user = get_user_by( 'email', $email );
1104
-			if ( $user->ID != $this->user_id ) {
1102
+		if (email_exists($email)) {
1103
+			$user = get_user_by('email', $email);
1104
+			if ($user->ID != $this->user_id) {
1105 1105
 				return false;
1106 1106
 			}
1107 1107
 		}
1108 1108
 
1109
-		do_action( 'give_donor_pre_add_email', $email, $this->id, $this );
1109
+		do_action('give_donor_pre_add_email', $email, $this->id, $this);
1110 1110
 
1111 1111
 		// Add is used to ensure duplicate emails are not added
1112
-		$ret = (bool) $this->add_meta( 'additional_email', $email );
1112
+		$ret = (bool) $this->add_meta('additional_email', $email);
1113 1113
 
1114
-		do_action( 'give_donor_post_add_email', $email, $this->id, $this );
1114
+		do_action('give_donor_post_add_email', $email, $this->id, $this);
1115 1115
 
1116
-		if ( $ret && true === $primary ) {
1117
-			$this->set_primary_email( $email );
1116
+		if ($ret && true === $primary) {
1117
+			$this->set_primary_email($email);
1118 1118
 		}
1119 1119
 
1120 1120
 		return $ret;
@@ -1130,16 +1130,16 @@  discard block
 block discarded – undo
1130 1130
 	 *
1131 1131
 	 * @return bool          If the email was removed successfully.
1132 1132
 	 */
1133
-	public function remove_email( $email = '' ) {
1134
-		if ( ! is_email( $email ) ) {
1133
+	public function remove_email($email = '') {
1134
+		if ( ! is_email($email)) {
1135 1135
 			return false;
1136 1136
 		}
1137 1137
 
1138
-		do_action( 'give_donor_pre_remove_email', $email, $this->id, $this );
1138
+		do_action('give_donor_pre_remove_email', $email, $this->id, $this);
1139 1139
 
1140
-		$ret = (bool) $this->delete_meta( 'additional_email', $email );
1140
+		$ret = (bool) $this->delete_meta('additional_email', $email);
1141 1141
 
1142
-		do_action( 'give_donor_post_remove_email', $email, $this->id, $this );
1142
+		do_action('give_donor_post_remove_email', $email, $this->id, $this);
1143 1143
 
1144 1144
 		return $ret;
1145 1145
 	}
@@ -1156,16 +1156,16 @@  discard block
 block discarded – undo
1156 1156
 	 *
1157 1157
 	 * @return bool                      If the email was set as primary successfully.
1158 1158
 	 */
1159
-	public function set_primary_email( $new_primary_email = '' ) {
1160
-		if ( ! is_email( $new_primary_email ) ) {
1159
+	public function set_primary_email($new_primary_email = '') {
1160
+		if ( ! is_email($new_primary_email)) {
1161 1161
 			return false;
1162 1162
 		}
1163 1163
 
1164
-		do_action( 'give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this );
1164
+		do_action('give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this);
1165 1165
 
1166
-		$existing = new Give_Donor( $new_primary_email );
1166
+		$existing = new Give_Donor($new_primary_email);
1167 1167
 
1168
-		if ( $existing->id > 0 && (int) $existing->id !== (int) $this->id ) {
1168
+		if ($existing->id > 0 && (int) $existing->id !== (int) $this->id) {
1169 1169
 			// This email belongs to another donor.
1170 1170
 			return false;
1171 1171
 		}
@@ -1173,21 +1173,21 @@  discard block
 block discarded – undo
1173 1173
 		$old_email = $this->email;
1174 1174
 
1175 1175
 		// Update donor record with new email.
1176
-		$update = $this->update( array( 'email' => $new_primary_email ) );
1176
+		$update = $this->update(array('email' => $new_primary_email));
1177 1177
 
1178 1178
 		// Remove new primary from list of additional emails.
1179
-		$remove = $this->remove_email( $new_primary_email );
1179
+		$remove = $this->remove_email($new_primary_email);
1180 1180
 
1181 1181
 		// Add old email to additional emails list.
1182
-		$add = $this->add_email( $old_email );
1182
+		$add = $this->add_email($old_email);
1183 1183
 
1184 1184
 		$ret = $update && $remove && $add;
1185 1185
 
1186
-		if ( $ret ) {
1186
+		if ($ret) {
1187 1187
 			$this->email = $new_primary_email;
1188 1188
 		}
1189 1189
 
1190
-		do_action( 'give_donor_post_set_primary_email', $new_primary_email, $this->id, $this );
1190
+		do_action('give_donor_post_set_primary_email', $new_primary_email, $this->id, $this);
1191 1191
 
1192 1192
 		return $ret;
1193 1193
 	}
@@ -1202,17 +1202,17 @@  discard block
 block discarded – undo
1202 1202
 	 *
1203 1203
 	 * @return bool
1204 1204
 	 */
1205
-	private function is_valid_address( $address ) {
1205
+	private function is_valid_address($address) {
1206 1206
 		$is_valid_address = true;
1207 1207
 		
1208 1208
 		// Address ready to process even if only one value set.
1209
-		foreach ( $address as $address_type => $value ) {
1209
+		foreach ($address as $address_type => $value) {
1210 1210
 			// @todo: Handle state field validation on basis of country.
1211
-			if( in_array( $address_type, array( 'line2', 'state' )) ) {
1211
+			if (in_array($address_type, array('line2', 'state'))) {
1212 1212
 				continue;
1213 1213
 			}
1214 1214
 
1215
-			if ( empty( $value ) ) {
1215
+			if (empty($value)) {
1216 1216
 				$is_valid_address = false;
1217 1217
 				break;
1218 1218
 			}
@@ -1239,30 +1239,27 @@  discard block
 block discarded – undo
1239 1239
 	 *
1240 1240
 	 * @return bool
1241 1241
 	 */
1242
-	public function add_address( $address_type, $address ) {
1242
+	public function add_address($address_type, $address) {
1243 1243
 		// Bailout.
1244
-		if ( empty( $address_type ) || ! $this->is_valid_address( $address ) || ! $this->id ) {
1244
+		if (empty($address_type) || ! $this->is_valid_address($address) || ! $this->id) {
1245 1245
 			return false;
1246 1246
 		}
1247 1247
 
1248 1248
 		// Check if multiple address exist or not and set params.
1249 1249
 		$multi_address_id = null;
1250
-		if( $is_multi_address = ( false !== strpos( $address_type, '[]' ) ) ) {
1251
-			$address_type  = $is_multi_address ?
1252
-				str_replace( '[]', '', $address_type ) :
1253
-				$address_type;
1254
-		} elseif ( $is_multi_address = ( false !== strpos( $address_type, '_' ) ) ){
1255
-			$multi_address_id =  $is_multi_address ?
1256
-				array_pop( explode( '_', $address_type ) ) :
1257
-				$address_type;
1258
-
1259
-			$address_type  = $is_multi_address ?
1260
-				array_shift( explode( '_', $address_type ) ) :
1261
-				$address_type;
1250
+		if ($is_multi_address = (false !== strpos($address_type, '[]'))) {
1251
+			$address_type = $is_multi_address ?
1252
+				str_replace('[]', '', $address_type) : $address_type;
1253
+		} elseif ($is_multi_address = (false !== strpos($address_type, '_'))) {
1254
+			$multi_address_id = $is_multi_address ?
1255
+				array_pop(explode('_', $address_type)) : $address_type;
1256
+
1257
+			$address_type = $is_multi_address ?
1258
+				array_shift(explode('_', $address_type)) : $address_type;
1262 1259
 		}
1263 1260
 
1264 1261
 		// Bailout: do not save duplicate orders
1265
-		if( $this->is_address_exist( $address_type, $address ) ) {
1262
+		if ($this->is_address_exist($address_type, $address)) {
1266 1263
 			return false;
1267 1264
 		}
1268 1265
 
@@ -1284,8 +1281,8 @@  discard block
 block discarded – undo
1284 1281
 		$meta_key_prefix = "_give_donor_address_{$address_type}_{address_name}";
1285 1282
 		$meta_type = Give()->donor_meta->meta_type;
1286 1283
 
1287
-		if ( $is_multi_address ) {
1288
-			if ( is_null( $multi_address_id ) ) {
1284
+		if ($is_multi_address) {
1285
+			if (is_null($multi_address_id)) {
1289 1286
 				// Get latest address key to set multi address id.
1290 1287
 				$multi_address_id = $wpdb->get_var(
1291 1288
 					$wpdb->prepare(
@@ -1302,10 +1299,10 @@  discard block
 block discarded – undo
1302 1299
 					)
1303 1300
 				);
1304 1301
 
1305
-				if( ! empty( $multi_address_id ) ) {
1306
-					$multi_address_id = absint( substr( strrchr( $multi_address_id, '_' ), 1 ) );
1302
+				if ( ! empty($multi_address_id)) {
1303
+					$multi_address_id = absint(substr(strrchr($multi_address_id, '_'), 1));
1307 1304
 					$multi_address_id++;
1308
-				} else{
1305
+				} else {
1309 1306
 					$multi_address_id = 0;
1310 1307
 				}
1311 1308
 			}
@@ -1314,9 +1311,9 @@  discard block
 block discarded – undo
1314 1311
 		}
1315 1312
 
1316 1313
 		// Save donor address.
1317
-		foreach ( $address as $type => $value ) {
1318
-			$meta_key = str_replace( '{address_name}', $type, $meta_key_prefix );
1319
-			Give()->donor_meta->update_meta( $this->id, $meta_key, $value );
1314
+		foreach ($address as $type => $value) {
1315
+			$meta_key = str_replace('{address_name}', $type, $meta_key_prefix);
1316
+			Give()->donor_meta->update_meta($this->id, $meta_key, $value);
1320 1317
 		}
1321 1318
 
1322 1319
 		$this->setup_address();
@@ -1335,23 +1332,21 @@  discard block
 block discarded – undo
1335 1332
 	 *
1336 1333
 	 * @return bool
1337 1334
 	 */
1338
-	public function remove_address( $address_id ) {
1335
+	public function remove_address($address_id) {
1339 1336
 		global $wpdb;
1340 1337
 
1341 1338
 		// Get address type.
1342
-		$is_multi_address = false !== strpos( $address_id, '_' ) ? true : false;
1339
+		$is_multi_address = false !== strpos($address_id, '_') ? true : false;
1343 1340
 
1344
-		$address_type = false !== strpos( $address_id, '_' ) ?
1345
-			array_shift( explode( '_', $address_id ) ) :
1346
-			$address_id;
1341
+		$address_type = false !== strpos($address_id, '_') ?
1342
+			array_shift(explode('_', $address_id)) : $address_id;
1347 1343
 
1348
-		$address_count = false !== strpos( $address_id, '_' ) ?
1349
-			array_pop( explode( '_', $address_id ) ) :
1350
-			null;
1344
+		$address_count = false !== strpos($address_id, '_') ?
1345
+			array_pop(explode('_', $address_id)) : null;
1351 1346
 
1352 1347
 		// Set meta key prefix.
1353 1348
 		$meta_key_prefix = "_give_donor_address_{$address_type}_%";
1354
-		if ( $is_multi_address && is_numeric( $address_count ) ) {
1349
+		if ($is_multi_address && is_numeric($address_count)) {
1355 1350
 			$meta_key_prefix .= "_{$address_count}";
1356 1351
 		}
1357 1352
 
@@ -1388,23 +1383,21 @@  discard block
 block discarded – undo
1388 1383
 	 *
1389 1384
 	 * @return bool
1390 1385
 	 */
1391
-	public function update_address( $address_id, $address ) {
1386
+	public function update_address($address_id, $address) {
1392 1387
 		global $wpdb;
1393 1388
 
1394 1389
 		// Get address type.
1395
-		$is_multi_address = false !== strpos( $address_id, '_' ) ? true : false;
1390
+		$is_multi_address = false !== strpos($address_id, '_') ? true : false;
1396 1391
 
1397
-		$address_type = false !== strpos( $address_id, '_' ) ?
1398
-			array_shift( explode( '_', $address_id ) ) :
1399
-			$address_id;
1392
+		$address_type = false !== strpos($address_id, '_') ?
1393
+			array_shift(explode('_', $address_id)) : $address_id;
1400 1394
 
1401
-		$address_count = false !== strpos( $address_id, '_' ) ?
1402
-			array_pop( explode( '_', $address_id ) ) :
1403
-			null;
1395
+		$address_count = false !== strpos($address_id, '_') ?
1396
+			array_pop(explode('_', $address_id)) : null;
1404 1397
 
1405 1398
 		// Set meta key prefix.
1406 1399
 		$meta_key_prefix = "_give_donor_address_{$address_type}_%";
1407
-		if ( $is_multi_address && is_numeric( $address_count ) ) {
1400
+		if ($is_multi_address && is_numeric($address_count)) {
1408 1401
 			$meta_key_prefix .= "_{$address_count}";
1409 1402
 		}
1410 1403
 
@@ -1425,12 +1418,12 @@  discard block
 block discarded – undo
1425 1418
 		);
1426 1419
 		
1427 1420
 		// Return result.
1428
-		if( ! count( $row_affected ) ) {
1421
+		if ( ! count($row_affected)) {
1429 1422
 			return false;
1430 1423
 		}
1431 1424
 
1432 1425
 		// Update address.
1433
-		if( ! $this->add_address( $address_id, $address ) ) {
1426
+		if ( ! $this->add_address($address_id, $address)) {
1434 1427
 			return false;
1435 1428
 		}
1436 1429
 
@@ -1449,39 +1442,39 @@  discard block
 block discarded – undo
1449 1442
 	 *
1450 1443
 	 * @return bool|null
1451 1444
 	 */
1452
-	public function is_address_exist( $current_address_type, $current_address ) {
1445
+	public function is_address_exist($current_address_type, $current_address) {
1453 1446
 		$status = false;
1454 1447
 
1455 1448
 		// Bailout.
1456
-		if( empty( $current_address_type ) || empty( $current_address ) ) {
1449
+		if (empty($current_address_type) || empty($current_address)) {
1457 1450
 			return null;
1458 1451
 		}
1459 1452
 
1460 1453
 		// Bailout.
1461
-		if( empty( $this->address ) || empty( $this->address[ $current_address_type ] ) ) {
1454
+		if (empty($this->address) || empty($this->address[$current_address_type])) {
1462 1455
 			return $status;
1463 1456
 		}
1464 1457
 
1465 1458
 		// Get address.
1466
-		$address = $this->address[ $current_address_type ];
1459
+		$address = $this->address[$current_address_type];
1467 1460
 
1468
-		switch ( true ){
1461
+		switch (true) {
1469 1462
 
1470 1463
 			// Single address.
1471
-			case is_string( end( $address ) ) :
1472
-				$status = $this->is_address_match( $current_address, $address );
1464
+			case is_string(end($address)) :
1465
+				$status = $this->is_address_match($current_address, $address);
1473 1466
 				break;
1474 1467
 
1475 1468
 			// Multi address.
1476
-			case is_array( end( $address ) ):
1469
+			case is_array(end($address)):
1477 1470
 				// Compare address.
1478
-				foreach ( $address as $saved_address ) {
1479
-					if( empty( $saved_address ) ) {
1471
+				foreach ($address as $saved_address) {
1472
+					if (empty($saved_address)) {
1480 1473
 						continue;
1481 1474
 					}
1482 1475
 
1483 1476
 					// Exit loop immediately if address exist.
1484
-					if( $status = $this->is_address_match( $current_address, $saved_address ) ) {
1477
+					if ($status = $this->is_address_match($current_address, $saved_address)) {
1485 1478
 						break;
1486 1479
 					}
1487 1480
 				}
@@ -1502,10 +1495,10 @@  discard block
 block discarded – undo
1502 1495
 	 *
1503 1496
 	 * @return bool
1504 1497
 	 */
1505
-	private function is_address_match( $address_1, $address_2 ) {
1506
-		$result = array_diff( $address_1, $address_2 );
1498
+	private function is_address_match($address_1, $address_2) {
1499
+		$result = array_diff($address_1, $address_2);
1507 1500
 
1508
-		return empty( $result );
1501
+		return empty($result);
1509 1502
 	}
1510 1503
 
1511 1504
 	/**
@@ -1515,22 +1508,22 @@  discard block
 block discarded – undo
1515 1508
 	 * @since   2.0
1516 1509
 	 * @return  object
1517 1510
 	 */
1518
-	public function split_donor_name( $id ) {
1519
-		$first_name = $last_name  = '';
1520
-		$donor      = new Give_Donor( $id );
1511
+	public function split_donor_name($id) {
1512
+		$first_name = $last_name = '';
1513
+		$donor      = new Give_Donor($id);
1521 1514
 
1522
-		$split_donor_name = explode( ' ', $donor->name, 2 );
1515
+		$split_donor_name = explode(' ', $donor->name, 2);
1523 1516
 
1524 1517
 		// Check for existence of first name after split of donor name.
1525
-		if( is_array( $split_donor_name ) && ! empty( $split_donor_name[0] ) ) {
1518
+		if (is_array($split_donor_name) && ! empty($split_donor_name[0])) {
1526 1519
 			$first_name = $split_donor_name[0];
1527 1520
 		}
1528 1521
 
1529 1522
 		// Check for existence of last name after split of donor name.
1530
-		if( is_array( $split_donor_name ) && ! empty( $split_donor_name[1] ) ) {
1523
+		if (is_array($split_donor_name) && ! empty($split_donor_name[1])) {
1531 1524
 			$last_name = $split_donor_name[1];
1532 1525
 		}
1533
-		return (object) array( 'first_name' => $first_name, 'last_name' => $last_name );
1526
+		return (object) array('first_name' => $first_name, 'last_name' => $last_name);
1534 1527
 	}
1535 1528
 
1536 1529
 	/**
@@ -1540,9 +1533,9 @@  discard block
 block discarded – undo
1540 1533
 	 * @return  string
1541 1534
 	 */
1542 1535
 	public function get_first_name() {
1543
-		$first_name = $this->get_meta( '_give_donor_first_name');
1544
-		if( ! $first_name ) {
1545
-			$first_name = $this->split_donor_name( $this->id )->first_name;
1536
+		$first_name = $this->get_meta('_give_donor_first_name');
1537
+		if ( ! $first_name) {
1538
+			$first_name = $this->split_donor_name($this->id)->first_name;
1546 1539
 		}
1547 1540
 
1548 1541
 		return $first_name;
@@ -1555,15 +1548,15 @@  discard block
 block discarded – undo
1555 1548
 	 * @return  string
1556 1549
 	 */
1557 1550
 	public function get_last_name() {
1558
-		$first_name = $this->get_meta( '_give_donor_first_name');
1559
-		$last_name = $this->get_meta( '_give_donor_last_name');
1551
+		$first_name = $this->get_meta('_give_donor_first_name');
1552
+		$last_name = $this->get_meta('_give_donor_last_name');
1560 1553
 
1561 1554
 		// This condition will prevent unnecessary splitting of donor name to fetch last name.
1562
-		if( ! $first_name && ! $last_name ) {
1563
-			$last_name = $this->split_donor_name( $this->id )->last_name;
1555
+		if ( ! $first_name && ! $last_name) {
1556
+			$last_name = $this->split_donor_name($this->id)->last_name;
1564 1557
 		}
1565 1558
 
1566
-		return ( $last_name ) ? $last_name : '';
1559
+		return ($last_name) ? $last_name : '';
1567 1560
 	}
1568 1561
 
1569 1562
 	/**
@@ -1574,7 +1567,7 @@  discard block
 block discarded – undo
1574 1567
 	 * @return  string $company_name Donor Company Name
1575 1568
 	 */
1576 1569
 	public function get_company_name() {
1577
-		$company_name = $this->get_meta( '_give_donor_company' );
1570
+		$company_name = $this->get_meta('_give_donor_company');
1578 1571
 
1579 1572
 		return $company_name;
1580 1573
 	}
Please login to merge, or discard this patch.
includes/class-give-session.php 1 patch
Spacing   +76 added lines, -76 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
 
@@ -74,57 +74,57 @@  discard block
 block discarded – undo
74 74
 	public function __construct() {
75 75
 
76 76
 		$this->use_php_sessions = $this->use_php_sessions();
77
-		$this->exp_option       = give_get_option( 'session_lifetime' );
77
+		$this->exp_option       = give_get_option('session_lifetime');
78 78
 
79 79
 		// PHP Sessions.
80
-		if ( $this->use_php_sessions ) {
80
+		if ($this->use_php_sessions) {
81 81
 
82
-			if ( is_multisite() ) {
82
+			if (is_multisite()) {
83 83
 
84
-				$this->prefix = '_' . get_current_blog_id();
84
+				$this->prefix = '_'.get_current_blog_id();
85 85
 
86 86
 			}
87 87
 
88
-			add_action( 'init', array( $this, 'maybe_start_session' ), - 2 );
88
+			add_action('init', array($this, 'maybe_start_session'), - 2);
89 89
 
90 90
 		} else {
91 91
 
92
-			if ( ! $this->should_start_session() ) {
92
+			if ( ! $this->should_start_session()) {
93 93
 				return;
94 94
 			}
95 95
 
96 96
 			// Use WP_Session.
97
-			if ( ! defined( 'WP_SESSION_COOKIE' ) ) {
98
-				define( 'WP_SESSION_COOKIE', 'give_wp_session' );
97
+			if ( ! defined('WP_SESSION_COOKIE')) {
98
+				define('WP_SESSION_COOKIE', 'give_wp_session');
99 99
 			}
100 100
 
101
-			if ( ! class_exists( 'Recursive_ArrayAccess' ) ) {
102
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-recursive-arrayaccess.php';
101
+			if ( ! class_exists('Recursive_ArrayAccess')) {
102
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-recursive-arrayaccess.php';
103 103
 			}
104 104
 
105 105
 			// Include utilities class
106
-			if ( ! class_exists( 'WP_Session_Utils' ) ) {
107
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-wp-session-utils.php';
106
+			if ( ! class_exists('WP_Session_Utils')) {
107
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-wp-session-utils.php';
108 108
 			}
109
-			if ( ! class_exists( 'WP_Session' ) ) {
110
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-wp-session.php';
111
-				require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/wp-session.php';
109
+			if ( ! class_exists('WP_Session')) {
110
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-wp-session.php';
111
+				require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/wp-session.php';
112 112
 			}
113 113
 
114
-			add_filter( 'wp_session_expiration_variant', array( $this, 'set_expiration_variant_time' ), 99999 );
115
-			add_filter( 'wp_session_expiration', array( $this, 'set_expiration_time' ), 99999 );
114
+			add_filter('wp_session_expiration_variant', array($this, 'set_expiration_variant_time'), 99999);
115
+			add_filter('wp_session_expiration', array($this, 'set_expiration_time'), 99999);
116 116
 
117 117
 		}
118 118
 
119 119
 		// Init Session.
120
-		if ( empty( $this->session ) && ! $this->use_php_sessions ) {
121
-			add_action( 'plugins_loaded', array( $this, 'init' ), 9999 );
120
+		if (empty($this->session) && ! $this->use_php_sessions) {
121
+			add_action('plugins_loaded', array($this, 'init'), 9999);
122 122
 		} else {
123
-			add_action( 'init', array( $this, 'init' ), - 1 );
123
+			add_action('init', array($this, 'init'), - 1);
124 124
 		}
125 125
 
126 126
 		// Set cookie on Donation Completion page.
127
-		add_action( 'give_pre_process_donation', array( $this, 'set_session_cookies' ) );
127
+		add_action('give_pre_process_donation', array($this, 'set_session_cookies'));
128 128
 
129 129
 	}
130 130
 
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
 	 */
141 141
 	public function init() {
142 142
 
143
-		if ( $this->use_php_sessions ) {
144
-			$this->session = isset( $_SESSION[ 'give' . $this->prefix ] ) && is_array( $_SESSION[ 'give' . $this->prefix ] ) ? $_SESSION[ 'give' . $this->prefix ] : array();
143
+		if ($this->use_php_sessions) {
144
+			$this->session = isset($_SESSION['give'.$this->prefix]) && is_array($_SESSION['give'.$this->prefix]) ? $_SESSION['give'.$this->prefix] : array();
145 145
 		} else {
146 146
 			$this->session = WP_Session::get_instance();
147 147
 		}
@@ -176,37 +176,37 @@  discard block
 block discarded – undo
176 176
 	 *
177 177
 	 * @return string|array      Session variable.
178 178
 	 */
179
-	public function get( $key ) {
180
-		$key    = sanitize_key( $key );
179
+	public function get($key) {
180
+		$key    = sanitize_key($key);
181 181
 		$return = false;
182 182
 
183
-		if ( isset( $this->session[ $key ] ) && ! empty( $this->session[ $key ] ) ) {
183
+		if (isset($this->session[$key]) && ! empty($this->session[$key])) {
184 184
 
185
-			preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $this->session[ $key ], $matches );
186
-			if ( ! empty( $matches ) ) {
187
-				$this->set( $key, null );
185
+			preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $this->session[$key], $matches);
186
+			if ( ! empty($matches)) {
187
+				$this->set($key, null);
188 188
 
189 189
 				return false;
190 190
 			}
191 191
 
192
-			if ( is_numeric( $this->session[ $key ] ) ) {
193
-				$return = $this->session[ $key ];
192
+			if (is_numeric($this->session[$key])) {
193
+				$return = $this->session[$key];
194 194
 			} else {
195 195
 
196
-				$maybe_json = json_decode( $this->session[ $key ] );
196
+				$maybe_json = json_decode($this->session[$key]);
197 197
 
198 198
 				// Since json_last_error is PHP 5.3+, we have to rely on a `null` value for failing to parse JSON.
199
-				if ( is_null( $maybe_json ) ) {
200
-					$is_serialized = is_serialized( $this->session[ $key ] );
201
-					if ( $is_serialized ) {
202
-						$value = @unserialize( $this->session[ $key ] );
203
-						$this->set( $key, (array) $value );
199
+				if (is_null($maybe_json)) {
200
+					$is_serialized = is_serialized($this->session[$key]);
201
+					if ($is_serialized) {
202
+						$value = @unserialize($this->session[$key]);
203
+						$this->set($key, (array) $value);
204 204
 						$return = $value;
205 205
 					} else {
206
-						$return = $this->session[ $key ];
206
+						$return = $this->session[$key];
207 207
 					}
208 208
 				} else {
209
-					$return = json_decode( $this->session[ $key ], true );
209
+					$return = json_decode($this->session[$key], true);
210 210
 				}
211 211
 
212 212
 			}
@@ -229,21 +229,21 @@  discard block
 block discarded – undo
229 229
 	 *
230 230
 	 * @return string        Session variable.
231 231
 	 */
232
-	public function set( $key, $value ) {
232
+	public function set($key, $value) {
233 233
 
234
-		$key = sanitize_key( $key );
234
+		$key = sanitize_key($key);
235 235
 
236
-		if ( is_array( $value ) ) {
237
-			$this->session[ $key ] = wp_json_encode( $value );
236
+		if (is_array($value)) {
237
+			$this->session[$key] = wp_json_encode($value);
238 238
 		} else {
239
-			$this->session[ $key ] = esc_attr( $value );
239
+			$this->session[$key] = esc_attr($value);
240 240
 		}
241 241
 
242
-		if ( $this->use_php_sessions ) {
243
-			$_SESSION[ 'give' . $this->prefix ] = $this->session;
242
+		if ($this->use_php_sessions) {
243
+			$_SESSION['give'.$this->prefix] = $this->session;
244 244
 		}
245 245
 
246
-		return $this->session[ $key ];
246
+		return $this->session[$key];
247 247
 	}
248 248
 
249 249
 	/**
@@ -258,10 +258,10 @@  discard block
 block discarded – undo
258 258
 	 * @hook
259 259
 	 */
260 260
 	public function set_session_cookies() {
261
-		if ( ! headers_sent() ) {
262
-			$lifetime = current_time( 'timestamp' ) + $this->set_expiration_time();
263
-			@setcookie( session_name(), session_id(), $lifetime, COOKIEPATH, COOKIE_DOMAIN, false );
264
-			@setcookie( session_name() . '_expiration', $lifetime, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false );
261
+		if ( ! headers_sent()) {
262
+			$lifetime = current_time('timestamp') + $this->set_expiration_time();
263
+			@setcookie(session_name(), session_id(), $lifetime, COOKIEPATH, COOKIE_DOMAIN, false);
264
+			@setcookie(session_name().'_expiration', $lifetime, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false);
265 265
 		}
266 266
 	}
267 267
 
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 	 */
278 278
 	public function set_expiration_variant_time() {
279 279
 
280
-		return ( ! empty( $this->exp_option ) ? ( intval( $this->exp_option ) - 3600 ) : 30 * 60 * 23 );
280
+		return ( ! empty($this->exp_option) ? (intval($this->exp_option) - 3600) : 30 * 60 * 23);
281 281
 	}
282 282
 
283 283
 	/**
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 	 */
293 293
 	public function set_expiration_time() {
294 294
 
295
-		return ( ! empty( $this->exp_option ) ? intval( $this->exp_option ) : 30 * 60 * 24 );
295
+		return ( ! empty($this->exp_option) ? intval($this->exp_option) : 30 * 60 * 24);
296 296
 	}
297 297
 
298 298
 	/**
@@ -310,21 +310,21 @@  discard block
 block discarded – undo
310 310
 		$ret = false;
311 311
 
312 312
 		// If the database variable is already set, no need to run auto detection.
313
-		$give_use_php_sessions = (bool) get_option( 'give_use_php_sessions' );
313
+		$give_use_php_sessions = (bool) get_option('give_use_php_sessions');
314 314
 
315
-		if ( ! $give_use_php_sessions ) {
315
+		if ( ! $give_use_php_sessions) {
316 316
 
317 317
 			// Attempt to detect if the server supports PHP sessions.
318
-			if ( function_exists( 'session_start' ) && ! ini_get( 'safe_mode' ) ) {
318
+			if (function_exists('session_start') && ! ini_get('safe_mode')) {
319 319
 
320
-				$this->set( 'give_use_php_sessions', 1 );
320
+				$this->set('give_use_php_sessions', 1);
321 321
 
322
-				if ( $this->get( 'give_use_php_sessions' ) ) {
322
+				if ($this->get('give_use_php_sessions')) {
323 323
 
324 324
 					$ret = true;
325 325
 
326 326
 					// Set the database option.
327
-					update_option( 'give_use_php_sessions', true );
327
+					update_option('give_use_php_sessions', true);
328 328
 
329 329
 				}
330 330
 			}
@@ -334,13 +334,13 @@  discard block
 block discarded – undo
334 334
 		}
335 335
 
336 336
 		// Enable or disable PHP Sessions based on the GIVE_USE_PHP_SESSIONS constant.
337
-		if ( defined( 'GIVE_USE_PHP_SESSIONS' ) && GIVE_USE_PHP_SESSIONS ) {
337
+		if (defined('GIVE_USE_PHP_SESSIONS') && GIVE_USE_PHP_SESSIONS) {
338 338
 			$ret = true;
339
-		} elseif ( defined( 'GIVE_USE_PHP_SESSIONS' ) && ! GIVE_USE_PHP_SESSIONS ) {
339
+		} elseif (defined('GIVE_USE_PHP_SESSIONS') && ! GIVE_USE_PHP_SESSIONS) {
340 340
 			$ret = false;
341 341
 		}
342 342
 
343
-		return (bool) apply_filters( 'give_use_php_sessions', $ret );
343
+		return (bool) apply_filters('give_use_php_sessions', $ret);
344 344
 	}
345 345
 
346 346
 	/**
@@ -357,9 +357,9 @@  discard block
 block discarded – undo
357 357
 
358 358
 		$start_session = true;
359 359
 
360
-		if ( ! empty( $_SERVER['REQUEST_URI'] ) ) {
360
+		if ( ! empty($_SERVER['REQUEST_URI'])) {
361 361
 
362
-			$blacklist = apply_filters( 'give_session_start_uri_blacklist', array(
362
+			$blacklist = apply_filters('give_session_start_uri_blacklist', array(
363 363
 				'feed',
364 364
 				'feed',
365 365
 				'feed/rss',
@@ -367,21 +367,21 @@  discard block
 block discarded – undo
367 367
 				'feed/rdf',
368 368
 				'feed/atom',
369 369
 				'comments/feed/',
370
-			) );
371
-			$uri       = ltrim( $_SERVER['REQUEST_URI'], '/' );
372
-			$uri       = untrailingslashit( $uri );
373
-			if ( in_array( $uri, $blacklist ) ) {
370
+			));
371
+			$uri       = ltrim($_SERVER['REQUEST_URI'], '/');
372
+			$uri       = untrailingslashit($uri);
373
+			if (in_array($uri, $blacklist)) {
374 374
 				$start_session = false;
375 375
 			}
376
-			if ( false !== strpos( $uri, 'feed=' ) ) {
376
+			if (false !== strpos($uri, 'feed=')) {
377 377
 				$start_session = false;
378 378
 			}
379
-			if ( is_admin() ) {
379
+			if (is_admin()) {
380 380
 				$start_session = false;
381 381
 			}
382 382
 		}
383 383
 
384
-		return apply_filters( 'give_start_session', $start_session );
384
+		return apply_filters('give_start_session', $start_session);
385 385
 	}
386 386
 
387 387
 	/**
@@ -397,11 +397,11 @@  discard block
 block discarded – undo
397 397
 	 */
398 398
 	public function maybe_start_session() {
399 399
 
400
-		if ( ! $this->should_start_session() ) {
400
+		if ( ! $this->should_start_session()) {
401 401
 			return;
402 402
 		}
403 403
 
404
-		if ( ! session_id() && ! headers_sent() ) {
404
+		if ( ! session_id() && ! headers_sent()) {
405 405
 			session_start();
406 406
 		}
407 407
 
@@ -420,9 +420,9 @@  discard block
 block discarded – undo
420 420
 
421 421
 		$expiration = false;
422 422
 
423
-		if ( session_id() && isset( $_COOKIE[ session_name() . '_expiration' ] ) ) {
423
+		if (session_id() && isset($_COOKIE[session_name().'_expiration'])) {
424 424
 
425
-			$expiration = date( 'D, d M Y h:i:s', intval( $_COOKIE[ session_name() . '_expiration' ] ) );
425
+			$expiration = date('D, d M Y h:i:s', intval($_COOKIE[session_name().'_expiration']));
426 426
 
427 427
 		}
428 428
 
Please login to merge, or discard this patch.
includes/admin/views/html-admin-settings.php 2 patches
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -95,5 +95,8 @@
 block discarded – undo
95 95
 		<?php endif; ?>
96 96
 		<?php echo $form_close_tag; ?>
97 97
 	</div>
98
-<?php else : echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>'; ?>
98
+<?php else {
99
+	: echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>';
100
+}
101
+?>
99 102
 <?php endif; ?>
100 103
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -2,12 +2,12 @@  discard block
 block discarded – undo
2 2
 /**
3 3
  * Admin View: Settings
4 4
  */
5
-if ( ! defined( 'ABSPATH' ) ) {
5
+if ( ! defined('ABSPATH')) {
6 6
 	exit;
7 7
 }
8 8
 
9 9
 // Bailout: Do not output anything if setting tab is not defined.
10
-if ( ! empty( $tabs ) && array_key_exists( give_get_current_setting_tab(), $tabs ) ) :
10
+if ( ! empty($tabs) && array_key_exists(give_get_current_setting_tab(), $tabs)) :
11 11
 	/**
12 12
 	 * Filter the form action.
13 13
 	 *
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 	 *
18 18
 	 * @since 1.8
19 19
 	 */
20
-	$form_method = apply_filters( self::$setting_filter_prefix . '_form_method_tab_' . $current_tab, 'post' );
20
+	$form_method = apply_filters(self::$setting_filter_prefix.'_form_method_tab_'.$current_tab, 'post');
21 21
 
22 22
 	/**
23 23
 	 * Filter the main form tab.
@@ -29,14 +29,14 @@  discard block
 block discarded – undo
29 29
 	 *
30 30
 	 * @since 1.8
31 31
 	 */
32
-	$form_open_tag  = apply_filters( self::$setting_filter_prefix . '_open_form', '<form method="' . $form_method . '" id="give-mainform" action="" enctype="multipart/form-data">' );
33
-	$form_close_tag = apply_filters( self::$setting_filter_prefix . '_close_form', '</form>' );
32
+	$form_open_tag  = apply_filters(self::$setting_filter_prefix.'_open_form', '<form method="'.$form_method.'" id="give-mainform" action="" enctype="multipart/form-data">');
33
+	$form_close_tag = apply_filters(self::$setting_filter_prefix.'_close_form', '</form>');
34 34
 
35
-	$wrapper_class = implode( ' ',
35
+	$wrapper_class = implode(' ',
36 36
 		array(
37
-			self::$setting_filter_prefix . '-setting-page',
38
-			self::$setting_filter_prefix . '-' . give_get_current_setting_section() . '-section',
39
-			self::$setting_filter_prefix . '-' . give_get_current_setting_tab() . '-tab',
37
+			self::$setting_filter_prefix.'-setting-page',
38
+			self::$setting_filter_prefix.'-'.give_get_current_setting_section().'-section',
39
+			self::$setting_filter_prefix.'-'.give_get_current_setting_tab().'-tab',
40 40
 		)
41 41
 	);
42 42
 	?>
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 
47 47
 		/* @var Give_Settings_Page $current_setting_obj */
48 48
 		if (
49
-			! empty( $current_setting_obj ) &&
50
-			method_exists( $current_setting_obj, 'get_heading_html' )
49
+			! empty($current_setting_obj) &&
50
+			method_exists($current_setting_obj, 'get_heading_html')
51 51
 		) {
52 52
 			echo $current_setting_obj->get_heading_html();
53 53
 		} else {
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 			// Backward compatibility.
56 56
 			echo sprintf(
57 57
 				'<h1 class="wp-heading-inline">%s</h1><hr class="wp-header-end">',
58
-				esc_html( $tabs[ $current_tab ] )
58
+				esc_html($tabs[$current_tab])
59 59
 			);
60 60
 		}
61 61
 
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
 		?>
64 64
 		<div class="nav-tab-wrapper give-nav-tab-wrapper">
65 65
 			<?php
66
-			foreach ( $tabs as $name => $label ) {
67
-				echo '<a href="' . admin_url( "edit.php?post_type=give_forms&page=" . self::$setting_filter_prefix . "&tab={$name}" ) . '" class="nav-tab ' . ( $current_tab === $name ? 'nav-tab-active' : 'give-mobile-hidden' ) . '">' . $label . '</a>';
66
+			foreach ($tabs as $name => $label) {
67
+				echo '<a href="'.admin_url("edit.php?post_type=give_forms&page=".self::$setting_filter_prefix."&tab={$name}").'" class="nav-tab '.($current_tab === $name ? 'nav-tab-active' : 'give-mobile-hidden').'">'.$label.'</a>';
68 68
 			}
69 69
 
70 70
 			/**
@@ -76,10 +76,10 @@  discard block
 block discarded – undo
76 76
 			 *
77 77
 			 * @since 1.8
78 78
 			 */
79
-			do_action( self::$setting_filter_prefix . '_tabs' );
79
+			do_action(self::$setting_filter_prefix.'_tabs');
80 80
 			?>
81 81
 			<div class="give-sub-nav-tab-wrapper">
82
-				<a href="#" id="give-show-sub-nav" class="nav-tab give-not-tab" title="<?php _e( 'View remaining setting tabs', 'give' ); ?>"><span class="dashicons dashicons-arrow-down-alt2"></span></span>
82
+				<a href="#" id="give-show-sub-nav" class="nav-tab give-not-tab" title="<?php _e('View remaining setting tabs', 'give'); ?>"><span class="dashicons dashicons-arrow-down-alt2"></span></span>
83 83
 				</a>
84 84
 				<nav class="give-sub-nav-tab give-hidden"></nav>
85 85
 			</div>
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 		 *
96 96
 		 * @since 1.8
97 97
 		 */
98
-		do_action( self::$setting_filter_prefix . "_sections_{$current_tab}_page" );
98
+		do_action(self::$setting_filter_prefix."_sections_{$current_tab}_page");
99 99
 
100 100
 		/**
101 101
 		 * Trigger Action.
@@ -106,15 +106,15 @@  discard block
 block discarded – undo
106 106
 		 *
107 107
 		 * @since 1.8
108 108
 		 */
109
-		do_action( self::$setting_filter_prefix . "_settings_{$current_tab}_page" );
109
+		do_action(self::$setting_filter_prefix."_settings_{$current_tab}_page");
110 110
 
111
-		if ( empty( $GLOBALS['give_hide_save_button'] ) ) : ?>
111
+		if (empty($GLOBALS['give_hide_save_button'])) : ?>
112 112
 			<div class="give-submit-wrap">
113
-				<?php wp_nonce_field( 'give-save-settings', '_give-save-settings' ); ?>
114
-				<input name="save" class="button-primary give-save-button" type="submit" value="<?php _e( 'Save changes', 'give' ); ?>"/>
113
+				<?php wp_nonce_field('give-save-settings', '_give-save-settings'); ?>
114
+				<input name="save" class="button-primary give-save-button" type="submit" value="<?php _e('Save changes', 'give'); ?>"/>
115 115
 			</div>
116 116
 		<?php endif; ?>
117 117
 		<?php echo $form_close_tag; ?>
118 118
 	</div>
119
-<?php else : echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>'; ?>
119
+<?php else : echo '<div class="error"><p>'.__('Oops, this settings page does not exist.', 'give').'</p></div>'; ?>
120 120
 <?php endif; ?>
121 121
\ No newline at end of file
Please login to merge, or discard this patch.