Test Failed
Push — master ( 7af02d...c58786 )
by Devin
04:53
created
includes/template-functions.php 1 patch
Spacing   +81 added lines, -81 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
 
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
  * @return string
22 22
  */
23 23
 function give_get_templates_dir() {
24
-	return GIVE_PLUGIN_DIR . 'templates';
24
+	return GIVE_PLUGIN_DIR.'templates';
25 25
 }
26 26
 
27 27
 /**
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
  * @return string
32 32
  */
33 33
 function give_get_templates_url() {
34
-	return GIVE_PLUGIN_URL . 'templates';
34
+	return GIVE_PLUGIN_URL.'templates';
35 35
 }
36 36
 
37 37
 /**
@@ -44,24 +44,24 @@  discard block
 block discarded – undo
44 44
  * @param string $template_path Template file path. Default is empty.
45 45
  * @param string $default_path  Default path. Default is empty.
46 46
  */
47
-function give_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
48
-	if ( ! empty( $args ) && is_array( $args ) ) {
49
-		extract( $args );
47
+function give_get_template($template_name, $args = array(), $template_path = '', $default_path = '') {
48
+	if ( ! empty($args) && is_array($args)) {
49
+		extract($args);
50 50
 	}
51 51
 
52
-	$template_names = array( $template_name . '.php' );
52
+	$template_names = array($template_name.'.php');
53 53
 
54
-	$located = give_locate_template( $template_names, $template_path, $default_path );
54
+	$located = give_locate_template($template_names, $template_path, $default_path);
55 55
 
56
-	if ( ! file_exists( $located ) ) {
56
+	if ( ! file_exists($located)) {
57 57
 		/* translators: %s: the template */
58
-		Give()->notices->print_frontend_notice( sprintf( __( 'The %s template was not found.', 'give' ), $located ), true );
58
+		Give()->notices->print_frontend_notice(sprintf(__('The %s template was not found.', 'give'), $located), true);
59 59
 
60 60
 		return;
61 61
 	}
62 62
 
63 63
 	// Allow 3rd party plugin filter template file from their plugin.
64
-	$located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path );
64
+	$located = apply_filters('give_get_template', $located, $template_name, $args, $template_path, $default_path);
65 65
 
66 66
 	/**
67 67
 	 * Fires in give template, before the file is included.
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
 	 * @param string $located       Template file filter by 3rd party plugin.
76 76
 	 * @param array  $args          Passed arguments.
77 77
 	 */
78
-	do_action( 'give_before_template_part', $template_name, $template_path, $located, $args );
78
+	do_action('give_before_template_part', $template_name, $template_path, $located, $args);
79 79
 
80
-	include( $located );
80
+	include($located);
81 81
 
82 82
 	/**
83 83
 	 * Fires in give template, after the file is included.
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	 * @param string $located       Template file filter by 3rd party plugin.
92 92
 	 * @param array  $args          Passed arguments.
93 93
 	 */
94
-	do_action( 'give_after_template_part', $template_name, $template_path, $located, $args );
94
+	do_action('give_after_template_part', $template_name, $template_path, $located, $args);
95 95
 }
96 96
 
97 97
 /**
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
  *
108 108
  * @return string
109 109
  */
110
-function give_get_template_part( $slug, $name = null, $load = true ) {
110
+function give_get_template_part($slug, $name = null, $load = true) {
111 111
 
112 112
 	/**
113 113
 	 * Fires in give template part, before the template part is retrieved.
@@ -119,20 +119,20 @@  discard block
 block discarded – undo
119 119
 	 * @param string $slug Template part file slug {slug}.php.
120 120
 	 * @param string $name Template part file name {slug}-{name}.php.
121 121
 	 */
122
-	do_action( "get_template_part_{$slug}", $slug, $name );
122
+	do_action("get_template_part_{$slug}", $slug, $name);
123 123
 
124 124
 	// Setup possible parts
125 125
 	$templates = array();
126
-	if ( isset( $name ) ) {
127
-		$templates[] = $slug . '-' . $name . '.php';
126
+	if (isset($name)) {
127
+		$templates[] = $slug.'-'.$name.'.php';
128 128
 	}
129
-	$templates[] = $slug . '.php';
129
+	$templates[] = $slug.'.php';
130 130
 
131 131
 	// Allow template parts to be filtered
132
-	$templates = apply_filters( 'give_get_template_part', $templates, $slug, $name );
132
+	$templates = apply_filters('give_get_template_part', $templates, $slug, $name);
133 133
 
134 134
 	// Return the part that is found
135
-	return give_locate_template( $templates, $load, false );
135
+	return give_locate_template($templates, $load, false);
136 136
 }
137 137
 
138 138
 /**
@@ -153,37 +153,37 @@  discard block
 block discarded – undo
153 153
  *
154 154
  * @return string The template filename if one is located.
155 155
  */
156
-function give_locate_template( $template_names, $load = false, $require_once = true ) {
156
+function give_locate_template($template_names, $load = false, $require_once = true) {
157 157
 	// No file found yet
158 158
 	$located = false;
159 159
 
160 160
 	// Try to find a template file
161
-	foreach ( (array) $template_names as $template_name ) {
161
+	foreach ((array) $template_names as $template_name) {
162 162
 
163 163
 		// Continue if template is empty
164
-		if ( empty( $template_name ) ) {
164
+		if (empty($template_name)) {
165 165
 			continue;
166 166
 		}
167 167
 
168 168
 		// Trim off any slashes from the template name
169
-		$template_name = ltrim( $template_name, '/' );
169
+		$template_name = ltrim($template_name, '/');
170 170
 
171 171
 		// try locating this template file by looping through the template paths
172
-		foreach ( give_get_theme_template_paths() as $template_path ) {
172
+		foreach (give_get_theme_template_paths() as $template_path) {
173 173
 
174
-			if ( file_exists( $template_path . $template_name ) ) {
175
-				$located = $template_path . $template_name;
174
+			if (file_exists($template_path.$template_name)) {
175
+				$located = $template_path.$template_name;
176 176
 				break;
177 177
 			}
178 178
 		}
179 179
 
180
-		if ( $located ) {
180
+		if ($located) {
181 181
 			break;
182 182
 		}
183 183
 	}
184 184
 
185
-	if ( ( true == $load ) && ! empty( $located ) ) {
186
-		load_template( $located, $require_once );
185
+	if ((true == $load) && ! empty($located)) {
186
+		load_template($located, $require_once);
187 187
 	}
188 188
 
189 189
 	return $located;
@@ -200,17 +200,17 @@  discard block
 block discarded – undo
200 200
 	$template_dir = give_get_theme_template_dir_name();
201 201
 
202 202
 	$file_paths = array(
203
-		1   => trailingslashit( get_stylesheet_directory() ) . $template_dir,
204
-		10  => trailingslashit( get_template_directory() ) . $template_dir,
203
+		1   => trailingslashit(get_stylesheet_directory()).$template_dir,
204
+		10  => trailingslashit(get_template_directory()).$template_dir,
205 205
 		100 => give_get_templates_dir(),
206 206
 	);
207 207
 
208
-	$file_paths = apply_filters( 'give_template_paths', $file_paths );
208
+	$file_paths = apply_filters('give_template_paths', $file_paths);
209 209
 
210 210
 	// sort the file paths based on priority
211
-	ksort( $file_paths, SORT_NUMERIC );
211
+	ksort($file_paths, SORT_NUMERIC);
212 212
 
213
-	return array_map( 'trailingslashit', $file_paths );
213
+	return array_map('trailingslashit', $file_paths);
214 214
 }
215 215
 
216 216
 /**
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
  * @return string
223 223
  */
224 224
 function give_get_theme_template_dir_name() {
225
-	return trailingslashit( apply_filters( 'give_templates_dir', 'give' ) );
225
+	return trailingslashit(apply_filters('give_templates_dir', 'give'));
226 226
 }
227 227
 
228 228
 /**
@@ -232,10 +232,10 @@  discard block
 block discarded – undo
232 232
  * @return void
233 233
  */
234 234
 function give_version_in_header() {
235
-	echo '<meta name="generator" content="Give v' . GIVE_VERSION . '" />' . "\n";
235
+	echo '<meta name="generator" content="Give v'.GIVE_VERSION.'" />'."\n";
236 236
 }
237 237
 
238
-add_action( 'wp_head', 'give_version_in_header' );
238
+add_action('wp_head', 'give_version_in_header');
239 239
 
240 240
 /**
241 241
  * Determines if we're currently on the Donations History page.
@@ -245,9 +245,9 @@  discard block
 block discarded – undo
245 245
  */
246 246
 function give_is_donation_history_page() {
247 247
 
248
-	$ret = is_page( give_get_option( 'history_page' ) );
248
+	$ret = is_page(give_get_option('history_page'));
249 249
 
250
-	return apply_filters( 'give_is_donation_history_page', $ret );
250
+	return apply_filters('give_is_donation_history_page', $ret);
251 251
 }
252 252
 
253 253
 /**
@@ -259,25 +259,25 @@  discard block
 block discarded – undo
259 259
  *
260 260
  * @return array Modified array of classes
261 261
  */
262
-function give_add_body_classes( $class ) {
262
+function give_add_body_classes($class) {
263 263
 	$classes = (array) $class;
264 264
 
265
-	if ( give_is_success_page() ) {
265
+	if (give_is_success_page()) {
266 266
 		$classes[] = 'give-success';
267 267
 		$classes[] = 'give-page';
268 268
 	}
269 269
 
270
-	if ( give_is_failed_transaction_page() ) {
270
+	if (give_is_failed_transaction_page()) {
271 271
 		$classes[] = 'give-failed-transaction';
272 272
 		$classes[] = 'give-page';
273 273
 	}
274 274
 
275
-	if ( give_is_donation_history_page() ) {
275
+	if (give_is_donation_history_page()) {
276 276
 		$classes[] = 'give-donation-history';
277 277
 		$classes[] = 'give-page';
278 278
 	}
279 279
 
280
-	if ( give_is_test_mode() ) {
280
+	if (give_is_test_mode()) {
281 281
 		$classes[] = 'give-test-mode';
282 282
 		$classes[] = 'give-page';
283 283
 	}
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 	/* @var WP_Theme $current_theme */
287 287
 	$current_theme = wp_get_theme();
288 288
 
289
-	switch ( $current_theme->get_template() ) {
289
+	switch ($current_theme->get_template()) {
290 290
 
291 291
 		case 'Divi':
292 292
 			$classes[] = 'give-divi';
@@ -303,10 +303,10 @@  discard block
 block discarded – undo
303 303
 
304 304
 	}
305 305
 
306
-	return array_unique( $classes );
306
+	return array_unique($classes);
307 307
 }
308 308
 
309
-add_filter( 'body_class', 'give_add_body_classes' );
309
+add_filter('body_class', 'give_add_body_classes');
310 310
 
311 311
 
312 312
 /**
@@ -322,22 +322,22 @@  discard block
 block discarded – undo
322 322
  *
323 323
  * @return array
324 324
  */
325
-function give_add_post_class( $classes, $class = '', $post_id = '' ) {
326
-	if ( ! $post_id || 'give_forms' !== get_post_type( $post_id ) ) {
325
+function give_add_post_class($classes, $class = '', $post_id = '') {
326
+	if ( ! $post_id || 'give_forms' !== get_post_type($post_id)) {
327 327
 		return $classes;
328 328
 	}
329 329
 
330 330
 	//@TODO: Add classes for custom taxonomy and form configurations (multi vs single donations, etc).
331 331
 
332
-	if ( false !== ( $key = array_search( 'hentry', $classes ) ) ) {
333
-		unset( $classes[ $key ] );
332
+	if (false !== ($key = array_search('hentry', $classes))) {
333
+		unset($classes[$key]);
334 334
 	}
335 335
 
336 336
 	return $classes;
337 337
 }
338 338
 
339 339
 
340
-add_filter( 'post_class', 'give_add_post_class', 20, 3 );
340
+add_filter('post_class', 'give_add_post_class', 20, 3);
341 341
 
342 342
 /**
343 343
  * Get the placeholder image URL for forms etc
@@ -347,74 +347,74 @@  discard block
 block discarded – undo
347 347
  */
348 348
 function give_get_placeholder_img_src() {
349 349
 
350
-	$placeholder_url = '//placehold.it/600x600&text=' . urlencode( esc_attr__( 'Give Placeholder Image', 'give' ) );
350
+	$placeholder_url = '//placehold.it/600x600&text='.urlencode(esc_attr__('Give Placeholder Image', 'give'));
351 351
 
352
-	return apply_filters( 'give_placeholder_img_src', $placeholder_url );
352
+	return apply_filters('give_placeholder_img_src', $placeholder_url);
353 353
 }
354 354
 
355 355
 
356 356
 /**
357 357
  * Global
358 358
  */
359
-if ( ! function_exists( 'give_output_content_wrapper' ) ) {
359
+if ( ! function_exists('give_output_content_wrapper')) {
360 360
 
361 361
 	/**
362 362
 	 * Output the start of the page wrapper.
363 363
 	 */
364 364
 	function give_output_content_wrapper() {
365
-		give_get_template_part( 'global/wrapper-start' );
365
+		give_get_template_part('global/wrapper-start');
366 366
 	}
367 367
 }
368
-if ( ! function_exists( 'give_output_content_wrapper_end' ) ) {
368
+if ( ! function_exists('give_output_content_wrapper_end')) {
369 369
 
370 370
 	/**
371 371
 	 * Output the end of the page wrapper.
372 372
 	 */
373 373
 	function give_output_content_wrapper_end() {
374
-		give_get_template_part( 'global/wrapper-end' );
374
+		give_get_template_part('global/wrapper-end');
375 375
 	}
376 376
 }
377 377
 
378 378
 /**
379 379
  * Single Give Form
380 380
  */
381
-if ( ! function_exists( 'give_left_sidebar_pre_wrap' ) ) {
381
+if ( ! function_exists('give_left_sidebar_pre_wrap')) {
382 382
 	function give_left_sidebar_pre_wrap() {
383
-		echo apply_filters( 'give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">' );
383
+		echo apply_filters('give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">');
384 384
 	}
385 385
 }
386 386
 
387
-if ( ! function_exists( 'give_left_sidebar_post_wrap' ) ) {
387
+if ( ! function_exists('give_left_sidebar_post_wrap')) {
388 388
 	function give_left_sidebar_post_wrap() {
389
-		echo apply_filters( 'give_left_sidebar_post_wrap', '</div>' );
389
+		echo apply_filters('give_left_sidebar_post_wrap', '</div>');
390 390
 	}
391 391
 }
392 392
 
393
-if ( ! function_exists( 'give_get_forms_sidebar' ) ) {
393
+if ( ! function_exists('give_get_forms_sidebar')) {
394 394
 	function give_get_forms_sidebar() {
395
-		give_get_template_part( 'single-give-form/sidebar' );
395
+		give_get_template_part('single-give-form/sidebar');
396 396
 	}
397 397
 }
398 398
 
399
-if ( ! function_exists( 'give_show_form_images' ) ) {
399
+if ( ! function_exists('give_show_form_images')) {
400 400
 
401 401
 	/**
402 402
 	 * Output the donation form featured image.
403 403
 	 */
404 404
 	function give_show_form_images() {
405
-		if ( give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) {
406
-			give_get_template_part( 'single-give-form/featured-image' );
405
+		if (give_is_setting_enabled(give_get_option('form_featured_img'))) {
406
+			give_get_template_part('single-give-form/featured-image');
407 407
 		}
408 408
 	}
409 409
 }
410 410
 
411
-if ( ! function_exists( 'give_template_single_title' ) ) {
411
+if ( ! function_exists('give_template_single_title')) {
412 412
 
413 413
 	/**
414 414
 	 * Output the form title.
415 415
 	 */
416 416
 	function give_template_single_title() {
417
-		give_get_template_part( 'single-give-form/title' );
417
+		give_get_template_part('single-give-form/title');
418 418
 	}
419 419
 }
420 420
 
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
  * Conditional Functions
423 423
  */
424 424
 
425
-if ( ! function_exists( 'is_give_form' ) ) {
425
+if ( ! function_exists('is_give_form')) {
426 426
 
427 427
 	/**
428 428
 	 * is_give_form
@@ -434,11 +434,11 @@  discard block
 block discarded – undo
434 434
 	 * @return bool
435 435
 	 */
436 436
 	function is_give_form() {
437
-		return is_singular( array( 'give_form' ) );
437
+		return is_singular(array('give_form'));
438 438
 	}
439 439
 }
440 440
 
441
-if ( ! function_exists( 'is_give_category' ) ) {
441
+if ( ! function_exists('is_give_category')) {
442 442
 
443 443
 	/**
444 444
 	 * is_give_category
@@ -453,12 +453,12 @@  discard block
 block discarded – undo
453 453
 	 *
454 454
 	 * @return bool
455 455
 	 */
456
-	function is_give_category( $term = '' ) {
457
-		return is_tax( 'give_forms_category', $term );
456
+	function is_give_category($term = '') {
457
+		return is_tax('give_forms_category', $term);
458 458
 	}
459 459
 }
460 460
 
461
-if ( ! function_exists( 'is_give_tag' ) ) {
461
+if ( ! function_exists('is_give_tag')) {
462 462
 
463 463
 	/**
464 464
 	 * is_give_tag
@@ -473,12 +473,12 @@  discard block
 block discarded – undo
473 473
 	 *
474 474
 	 * @return bool
475 475
 	 */
476
-	function is_give_tag( $term = '' ) {
477
-		return is_tax( 'give_forms_tag', $term );
476
+	function is_give_tag($term = '') {
477
+		return is_tax('give_forms_tag', $term);
478 478
 	}
479 479
 }
480 480
 
481
-if ( ! function_exists( 'is_give_taxonomy' ) ) {
481
+if ( ! function_exists('is_give_taxonomy')) {
482 482
 
483 483
 	/**
484 484
 	 * is_give_taxonomy
@@ -490,6 +490,6 @@  discard block
 block discarded – undo
490 490
 	 * @return bool
491 491
 	 */
492 492
 	function is_give_taxonomy() {
493
-		return is_tax( get_object_taxonomies( 'give_form' ) );
493
+		return is_tax(get_object_taxonomies('give_form'));
494 494
 	}
495 495
 }
Please login to merge, or discard this patch.
uninstall.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -10,61 +10,61 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
13
+if ( ! defined('WP_UNINSTALL_PLUGIN')) {
14 14
 	exit;
15 15
 }
16 16
 
17 17
 // Load Give file.
18
-include_once( 'give.php' );
18
+include_once('give.php');
19 19
 
20 20
 global $wpdb, $wp_roles;
21 21
 
22 22
 
23
-if ( give_is_setting_enabled( give_get_option( 'uninstall_on_delete' ) ) ) {
23
+if (give_is_setting_enabled(give_get_option('uninstall_on_delete'))) {
24 24
 
25 25
 	// Delete All the Custom Post Types.
26
-	$give_taxonomies = array( 'form_category', 'form_tag', 'give_log_type' );
27
-	$give_post_types = array( 'give_forms', 'give_payment', 'give_log' );
28
-	foreach ( $give_post_types as $post_type ) {
26
+	$give_taxonomies = array('form_category', 'form_tag', 'give_log_type');
27
+	$give_post_types = array('give_forms', 'give_payment', 'give_log');
28
+	foreach ($give_post_types as $post_type) {
29 29
 
30
-		$give_taxonomies = array_merge( $give_taxonomies, get_object_taxonomies( $post_type ) );
31
-		$items           = get_posts( array(
30
+		$give_taxonomies = array_merge($give_taxonomies, get_object_taxonomies($post_type));
31
+		$items           = get_posts(array(
32 32
 			'post_type'   => $post_type,
33 33
 			'post_status' => 'any',
34
-			'numberposts' => - 1,
34
+			'numberposts' => -1,
35 35
 			'fields'      => 'ids',
36
-		) );
36
+		));
37 37
 
38
-		if ( $items ) {
39
-			foreach ( $items as $item ) {
40
-				wp_delete_post( $item, true );
38
+		if ($items) {
39
+			foreach ($items as $item) {
40
+				wp_delete_post($item, true);
41 41
 			}
42 42
 		}
43 43
 	}
44 44
 
45 45
 	// Delete All the Terms & Taxonomies.
46
-	foreach ( array_unique( array_filter( $give_taxonomies ) ) as $taxonomy ) {
46
+	foreach (array_unique(array_filter($give_taxonomies)) as $taxonomy) {
47 47
 
48
-		$terms = $wpdb->get_results( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('%s') ORDER BY t.name ASC", $taxonomy ) );
48
+		$terms = $wpdb->get_results($wpdb->prepare("SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('%s') ORDER BY t.name ASC", $taxonomy));
49 49
 
50 50
 		// Delete Terms.
51
-		if ( $terms ) {
52
-			foreach ( $terms as $term ) {
53
-				$wpdb->delete( $wpdb->term_taxonomy, array( 'term_taxonomy_id' => $term->term_taxonomy_id ) );
54
-				$wpdb->delete( $wpdb->terms, array( 'term_id' => $term->term_id ) );
51
+		if ($terms) {
52
+			foreach ($terms as $term) {
53
+				$wpdb->delete($wpdb->term_taxonomy, array('term_taxonomy_id' => $term->term_taxonomy_id));
54
+				$wpdb->delete($wpdb->terms, array('term_id' => $term->term_id));
55 55
 			}
56 56
 		}
57 57
 
58 58
 		// Delete Taxonomies.
59
-		$wpdb->delete( $wpdb->term_taxonomy, array( 'taxonomy' => $taxonomy ), array( '%s' ) );
59
+		$wpdb->delete($wpdb->term_taxonomy, array('taxonomy' => $taxonomy), array('%s'));
60 60
 	}
61 61
 
62 62
 	// Delete the Plugin Pages.
63
-	$give_created_pages = array( 'success_page', 'failure_page', 'history_page' );
64
-	foreach ( $give_created_pages as $p ) {
65
-		$page = give_get_option( $p, false );
66
-		if ( $page ) {
67
-			wp_delete_post( $page, true );
63
+	$give_created_pages = array('success_page', 'failure_page', 'history_page');
64
+	foreach ($give_created_pages as $p) {
65
+		$page = give_get_option($p, false);
66
+		if ($page) {
67
+			wp_delete_post($page, true);
68 68
 		}
69 69
 	}
70 70
 
@@ -73,21 +73,21 @@  discard block
 block discarded – undo
73 73
 	Give()->roles->remove_caps();
74 74
 
75 75
 	// Delete the Roles.
76
-	$give_roles = array( 'give_manager', 'give_accountant', 'give_worker', 'give_donor' );
77
-	foreach ( $give_roles as $role ) {
78
-		remove_role( $role );
76
+	$give_roles = array('give_manager', 'give_accountant', 'give_worker', 'give_donor');
77
+	foreach ($give_roles as $role) {
78
+		remove_role($role);
79 79
 	}
80 80
 
81 81
 	// Remove all database tables.
82
-	$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_donors' );
83
-	$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_customers' );
84
-	$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'give_customermeta' );
82
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_donors');
83
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_customers');
84
+	$wpdb->query('DROP TABLE IF EXISTS '.$wpdb->prefix.'give_customermeta');
85 85
 
86 86
 	// Cleanup Cron Events.
87
-	wp_clear_scheduled_hook( 'give_daily_scheduled_events' );
88
-	wp_clear_scheduled_hook( 'give_weekly_scheduled_events' );
89
-	wp_clear_scheduled_hook( 'give_daily_cron' );
90
-	wp_clear_scheduled_hook( 'give_weekly_cron' );
87
+	wp_clear_scheduled_hook('give_daily_scheduled_events');
88
+	wp_clear_scheduled_hook('give_weekly_scheduled_events');
89
+	wp_clear_scheduled_hook('give_daily_cron');
90
+	wp_clear_scheduled_hook('give_weekly_cron');
91 91
 
92 92
 	// Get all options.
93 93
 	$give_option_names = $wpdb->get_col(
@@ -97,16 +97,16 @@  discard block
 block discarded – undo
97 97
 		)
98 98
 	);
99 99
 
100
-	if ( ! empty( $give_option_names ) ) {
100
+	if ( ! empty($give_option_names)) {
101 101
 		// Convert option name to transient or option name.
102 102
 		$new_give_option_names = array();
103 103
 
104 104
 		// Delete all the Plugin Options.
105
-		foreach ( $give_option_names as $option ) {
106
-			if ( false !== strpos( $option, 'give_cache' ) ) {
107
-				Give_Cache::delete( $option );
105
+		foreach ($give_option_names as $option) {
106
+			if (false !== strpos($option, 'give_cache')) {
107
+				Give_Cache::delete($option);
108 108
 			} else {
109
-				delete_option( $option );
109
+				delete_option($option);
110 110
 			}
111 111
 		}
112 112
 	}
Please login to merge, or discard this patch.
includes/admin/reports/class-give-graph.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly.
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -81,15 +81,15 @@  discard block
 block discarded – undo
81 81
 	 * @param array $_data
82 82
 	 * @param array $options
83 83
 	 */
84
-	public function __construct( $_data, $options = array() ) {
84
+	public function __construct($_data, $options = array()) {
85 85
 
86
-		$this->data      = $_data;
86
+		$this->data = $_data;
87 87
 
88 88
 		// Generate unique ID
89
-		$this->id = md5( rand() );
89
+		$this->id = md5(rand());
90 90
 
91 91
 		// Setup default options;
92
-		$this->options = apply_filters( 'give_graph_args', array(
92
+		$this->options = apply_filters('give_graph_args', array(
93 93
 			'y_mode'          => null,
94 94
 			'x_mode'          => null,
95 95
 			'y_decimals'      => 0,
@@ -107,9 +107,9 @@  discard block
 block discarded – undo
107 107
 			'lines'           => false,
108 108
 			'points'          => true,
109 109
 			'dataType'        => array()
110
-		) );
110
+		));
111 111
 
112
-		$this->options = wp_parse_args( $options, $this->options );
112
+		$this->options = wp_parse_args($options, $this->options);
113 113
 	}
114 114
 
115 115
 	/**
@@ -120,8 +120,8 @@  discard block
 block discarded – undo
120 120
 	 *
121 121
 	 * @since 1.0
122 122
 	 */
123
-	public function set( $key, $value ) {
124
-		$this->options[ $key ] = $value;
123
+	public function set($key, $value) {
124
+		$this->options[$key] = $value;
125 125
 	}
126 126
 
127 127
 	/**
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
 	 *
132 132
 	 * @since 1.0
133 133
 	 */
134
-	public function get( $key ) {
135
-		return isset( $this->options[ $key ] ) ? $this->options[ $key ] : false;
134
+	public function get($key) {
135
+		return isset($this->options[$key]) ? $this->options[$key] : false;
136 136
 	}
137 137
 
138 138
 	/**
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 * @since 1.0
142 142
 	 */
143 143
 	public function get_data() {
144
-		return apply_filters( 'give_get_graph_data', $this->data, $this );
144
+		return apply_filters('give_get_graph_data', $this->data, $this);
145 145
 	}
146 146
 
147 147
 	/**
@@ -151,19 +151,19 @@  discard block
 block discarded – undo
151 151
 	 */
152 152
 	public function load_scripts() {
153 153
 		// Use minified libraries if SCRIPT_DEBUG is turned off
154
-		$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
154
+		$suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
155 155
 
156
-		wp_register_script( 'jquery-flot-orderbars', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot.orderBars' . $suffix . '.js', array('jquery-flot'), GIVE_VERSION );
157
-		wp_enqueue_script( 'jquery-flot-orderbars' );
156
+		wp_register_script('jquery-flot-orderbars', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot.orderBars'.$suffix.'.js', array('jquery-flot'), GIVE_VERSION);
157
+		wp_enqueue_script('jquery-flot-orderbars');
158 158
 
159
-		wp_register_script( 'jquery-flot-time', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot.time' . $suffix . '.js', array('jquery-flot'), GIVE_VERSION );
160
-		wp_enqueue_script( 'jquery-flot-time' );
159
+		wp_register_script('jquery-flot-time', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot.time'.$suffix.'.js', array('jquery-flot'), GIVE_VERSION);
160
+		wp_enqueue_script('jquery-flot-time');
161 161
 
162
-		wp_register_script( 'jquery-flot-resize', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot.resize' . $suffix . '.js', array('jquery-flot'), GIVE_VERSION );
163
-		wp_enqueue_script( 'jquery-flot-resize' );
162
+		wp_register_script('jquery-flot-resize', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot.resize'.$suffix.'.js', array('jquery-flot'), GIVE_VERSION);
163
+		wp_enqueue_script('jquery-flot-resize');
164 164
 
165
-		wp_register_script( 'jquery-flot', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot' . $suffix . '.js', false, GIVE_VERSION );
166
-		wp_enqueue_script( 'jquery-flot' );
165
+		wp_register_script('jquery-flot', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot'.$suffix.'.js', false, GIVE_VERSION);
166
+		wp_enqueue_script('jquery-flot');
167 167
 
168 168
 	}
169 169
 
@@ -190,14 +190,14 @@  discard block
 block discarded – undo
190 190
 					[
191 191
 						<?php
192 192
 							$order = 0;
193
-							foreach( $this->get_data() as $label => $data ) :
193
+							foreach ($this->get_data() as $label => $data) :
194 194
 						?>
195 195
 						{
196
-							label : "<?php echo esc_attr( $label ); ?>",
197
-							id    : "<?php echo sanitize_key( $label ); ?>",
198
-							dataType  : '<?php echo ( ! empty( $this->options['dataType'][$order] ) ? $this->options['dataType'][$order] : 'count' ); ?>',
196
+							label : "<?php echo esc_attr($label); ?>",
197
+							id    : "<?php echo sanitize_key($label); ?>",
198
+							dataType  : '<?php echo ( ! empty($this->options['dataType'][$order]) ? $this->options['dataType'][$order] : 'count'); ?>',
199 199
 							// data format is: [ point on x, value on y ]
200
-							data  : [<?php foreach( $data as $point ) { echo '[' . implode( ',', $point ) . '],'; } ?>],
200
+							data  : [<?php foreach ($data as $point) { echo '['.implode(',', $point).'],'; } ?>],
201 201
 							points: {
202 202
 								show: <?php echo $this->options['points'] ? 'true' : 'false'; ?>,
203 203
 							},
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 								fill     : true,
213 213
 								fillColor: {colors: [{opacity: 0.4}, {opacity: 0.1}]}
214 214
 							},
215
-							<?php if( $this->options[ 'multiple_y_axes' ] ) : ?>
215
+							<?php if ($this->options['multiple_y_axes']) : ?>
216 216
 							yaxis : <?php echo $yaxis_count; ?>
217 217
 							<?php endif; ?>
218 218
 
@@ -226,10 +226,10 @@  discard block
 block discarded – undo
226 226
 						grid: {
227 227
 							show           : true,
228 228
 							aboveData      : false,
229
-							color          : "<?php echo $this->options[ 'color' ]; ?>",
230
-							backgroundColor: "<?php echo $this->options[ 'bgcolor' ]; ?>",
231
-							borderColor    : "<?php echo $this->options[ 'bordercolor' ]; ?>",
232
-							borderWidth    : <?php echo absint( $this->options[ 'borderwidth' ] ); ?>,
229
+							color          : "<?php echo $this->options['color']; ?>",
230
+							backgroundColor: "<?php echo $this->options['bgcolor']; ?>",
231
+							borderColor    : "<?php echo $this->options['bordercolor']; ?>",
232
+							borderWidth    : <?php echo absint($this->options['borderwidth']); ?>,
233 233
 							clickable      : false,
234 234
 							hoverable      : true
235 235
 						},
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 							mode        : "<?php echo $this->options['x_mode']; ?>",
241 241
 							timeFormat  : "<?php echo $this->options['x_mode'] == 'time' ? $this->options['time_format'] : ''; ?>",
242 242
 							tickSize    : "<?php echo $this->options['x_mode'] == 'time' ? '' : 1; ?>",
243
-							<?php if( $this->options['x_mode'] != 'time' ) : ?>
243
+							<?php if ($this->options['x_mode'] != 'time') : ?>
244 244
 							tickDecimals: <?php echo $this->options['x_decimals']; ?>
245 245
 							<?php endif; ?>
246 246
 						},
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 							min         : 0,
250 250
 							mode        : "<?php echo $this->options['y_mode']; ?>",
251 251
 							timeFormat  : "<?php echo $this->options['y_mode'] == 'time' ? $this->options['time_format'] : ''; ?>",
252
-							<?php if( $this->options['y_mode'] != 'time' ) : ?>
252
+							<?php if ($this->options['y_mode'] != 'time') : ?>
253 253
 							tickDecimals: <?php echo $this->options['y_decimals']; ?>,
254 254
 							<?php endif; ?>
255 255
 							tickFormatter: function(val) {
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 		 *
324 324
 		 * @param Give_Graph $this Graph object.
325 325
 		 */
326
-		do_action( 'give_before_graph', $this );
326
+		do_action('give_before_graph', $this);
327 327
 
328 328
 		// Build the graph.
329 329
 		echo $this->build_graph();
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
 		 *
336 336
 		 * @param Give_Graph $this Graph object.
337 337
 		 */
338
-		do_action( 'give_after_graph', $this );
338
+		do_action('give_after_graph', $this);
339 339
 	}
340 340
 
341 341
 }
Please login to merge, or discard this patch.
includes/admin/admin-filters.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@
 block discarded – undo
64 64
  *
65 65
  * @param   string $value
66 66
  *
67
- * @return  mixed
67
+ * @return  string
68 68
  */
69 69
 function __give_validate_decimal_separator_setting_field( $value ) {
70 70
 	$thousand_separator = give_clean( $_POST['thousands_separator'] );
Please login to merge, or discard this patch.
Spacing   +58 added lines, -58 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
 
@@ -27,30 +27,30 @@  discard block
 block discarded – undo
27 27
  *
28 28
  * @return  mixed
29 29
  */
30
-function __give_sanitize_number_decimals_setting_field( $value ) {
30
+function __give_sanitize_number_decimals_setting_field($value) {
31 31
 	$value_changed = false;
32 32
 	$old_value     = $value;
33 33
 
34
-	if ( isset( $_POST['decimal_separator'] ) ) {
35
-		$value         = ! empty( $_POST['decimal_separator'] ) ? $value : 0;
34
+	if (isset($_POST['decimal_separator'])) {
35
+		$value         = ! empty($_POST['decimal_separator']) ? $value : 0;
36 36
 		$value_changed = true;
37 37
 	}
38 38
 
39
-	if ( $value_changed && ( $old_value != $value ) ) {
40
-		Give_Admin_Settings::add_error( 'give-number-decimal', __( 'The \'Number of Decimals\' option has been automatically set to zero because the \'Decimal Separator\' is not set.', 'give' ) );
39
+	if ($value_changed && ($old_value != $value)) {
40
+		Give_Admin_Settings::add_error('give-number-decimal', __('The \'Number of Decimals\' option has been automatically set to zero because the \'Decimal Separator\' is not set.', 'give'));
41 41
 	}
42 42
 
43
-	$value = absint( $value );
43
+	$value = absint($value);
44 44
 
45
-	if( 6 <= $value ) {
45
+	if (6 <= $value) {
46 46
 		$value = 5;
47
-		Give_Admin_Settings::add_error( 'give-number-decimal', __( 'The \'Number of Decimals\' option has been automatically set to 5 because you entered a number higher than the maximum allowed.', 'give' ) );
47
+		Give_Admin_Settings::add_error('give-number-decimal', __('The \'Number of Decimals\' option has been automatically set to 5 because you entered a number higher than the maximum allowed.', 'give'));
48 48
 	}
49 49
 
50
-	return absint( $value );
50
+	return absint($value);
51 51
 }
52 52
 
53
-add_filter( 'give_admin_settings_sanitize_option_number_decimals', '__give_sanitize_number_decimals_setting_field', 10 );
53
+add_filter('give_admin_settings_sanitize_option_number_decimals', '__give_sanitize_number_decimals_setting_field', 10);
54 54
 
55 55
 
56 56
 /**
@@ -66,20 +66,20 @@  discard block
 block discarded – undo
66 66
  *
67 67
  * @return  mixed
68 68
  */
69
-function __give_validate_decimal_separator_setting_field( $value ) {
70
-	$thousand_separator = give_clean( $_POST['thousands_separator'] );
71
-	$decimal_separator  = give_clean( $_POST['decimal_separator'] );
69
+function __give_validate_decimal_separator_setting_field($value) {
70
+	$thousand_separator = give_clean($_POST['thousands_separator']);
71
+	$decimal_separator  = give_clean($_POST['decimal_separator']);
72 72
 
73
-	if ( $decimal_separator === $thousand_separator ) {
73
+	if ($decimal_separator === $thousand_separator) {
74 74
 		$value                    = '';
75 75
 		$_POST['number_decimals'] = 0;
76
-		Give_Admin_Settings::add_error( 'give-decimal-separator', __( 'The \'Decimal Separator\' option has automatically been set to empty because it can not be equal to the \'Thousand Separator\'', 'give' ) );
76
+		Give_Admin_Settings::add_error('give-decimal-separator', __('The \'Decimal Separator\' option has automatically been set to empty because it can not be equal to the \'Thousand Separator\'', 'give'));
77 77
 	}
78 78
 
79 79
 	return $value;
80 80
 }
81 81
 
82
-add_filter( 'give_admin_settings_sanitize_option_decimal_separator', '__give_validate_decimal_separator_setting_field', 10 );
82
+add_filter('give_admin_settings_sanitize_option_decimal_separator', '__give_validate_decimal_separator_setting_field', 10);
83 83
 
84 84
 /**
85 85
  * Change $delimiter text to symbol.
@@ -90,16 +90,16 @@  discard block
 block discarded – undo
90 90
  *
91 91
  * @return string $delimiter.
92 92
  */
93
-function __give_import_delimiter_set_callback( $delimiter ) {
93
+function __give_import_delimiter_set_callback($delimiter) {
94 94
 	$delimite_type = array(
95 95
 		'csv'                  => ",",
96 96
 		'tab-separated-values' => "\t",
97 97
 	);
98 98
 
99
-	return ( array_key_exists( $delimiter, $delimite_type ) ? $delimite_type[ $delimiter ] : "," );
99
+	return (array_key_exists($delimiter, $delimite_type) ? $delimite_type[$delimiter] : ",");
100 100
 }
101 101
 
102
-add_filter( 'give_import_delimiter_set', '__give_import_delimiter_set_callback', 10 );
102
+add_filter('give_import_delimiter_set', '__give_import_delimiter_set_callback', 10);
103 103
 
104 104
 /**
105 105
  * Give unset the page id from the core setting data from the json files.
@@ -111,17 +111,17 @@  discard block
 block discarded – undo
111 111
  *
112 112
  * @return array $json_to_array
113 113
  */
114
-function give_import_core_settings_merge_pages( $json_to_array, $type ) {
115
-	if ( 'merge' === $type ) {
116
-		unset( $json_to_array['success_page'] );
117
-		unset( $json_to_array['failure_page'] );
118
-		unset( $json_to_array['history_page'] );
114
+function give_import_core_settings_merge_pages($json_to_array, $type) {
115
+	if ('merge' === $type) {
116
+		unset($json_to_array['success_page']);
117
+		unset($json_to_array['failure_page']);
118
+		unset($json_to_array['history_page']);
119 119
 	}
120 120
 
121 121
 	return $json_to_array;
122 122
 }
123 123
 
124
-add_filter( 'give_import_core_settings_data', 'give_import_core_settings_merge_pages', 11, 2 );
124
+add_filter('give_import_core_settings_data', 'give_import_core_settings_merge_pages', 11, 2);
125 125
 
126 126
 /**
127 127
  * Give check the image size from the core setting data from the json files.
@@ -133,14 +133,14 @@  discard block
 block discarded – undo
133 133
  *
134 134
  * @return array $json_to_array
135 135
  */
136
-function give_import_core_settings_merge_image_size( $json_to_array, $type ) {
137
-	if ( 'merge' === $type ) {
136
+function give_import_core_settings_merge_image_size($json_to_array, $type) {
137
+	if ('merge' === $type) {
138 138
 		// Featured image sizes import under Display Options > Post Types > Featured Image Size.
139
-		if ( 'enabled' === $json_to_array['form_featured_img'] ) {
139
+		if ('enabled' === $json_to_array['form_featured_img']) {
140 140
 			$images_sizes = get_intermediate_image_sizes();
141 141
 
142
-			if ( ! in_array( $json_to_array['featured_image_size'], $images_sizes ) ) {
143
-				unset( $json_to_array['featured_image_size'] );
142
+			if ( ! in_array($json_to_array['featured_image_size'], $images_sizes)) {
143
+				unset($json_to_array['featured_image_size']);
144 144
 			}
145 145
 		}
146 146
 	}
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 	return $json_to_array;
149 149
 }
150 150
 
151
-add_filter( 'give_import_core_settings_data', 'give_import_core_settings_merge_image_size', 12, 2 );
151
+add_filter('give_import_core_settings_data', 'give_import_core_settings_merge_image_size', 12, 2);
152 152
 
153 153
 /**
154 154
  * Give upload the image logo from the core setting data from the json files.
@@ -160,24 +160,24 @@  discard block
 block discarded – undo
160 160
  *
161 161
  * @return array $json_to_array
162 162
  */
163
-function give_import_core_settings_merge_upload_image( $json_to_array, $type ) {
164
-	if ( 'merge' === $type ) {
163
+function give_import_core_settings_merge_upload_image($json_to_array, $type) {
164
+	if ('merge' === $type) {
165 165
 		// Emails > Email Settings > Logo.
166
-		if ( ! empty( $json_to_array['email_logo'] ) ) {
166
+		if ( ! empty($json_to_array['email_logo'])) {
167 167
 
168 168
 			// Need to require these files.
169
-			if ( ! function_exists( 'media_handle_upload' ) ) {
170
-				require_once( ABSPATH . 'wp-admin/includes/image.php' );
171
-				require_once( ABSPATH . 'wp-admin/includes/file.php' );
172
-				require_once( ABSPATH . 'wp-admin/includes/media.php' );
169
+			if ( ! function_exists('media_handle_upload')) {
170
+				require_once(ABSPATH.'wp-admin/includes/image.php');
171
+				require_once(ABSPATH.'wp-admin/includes/file.php');
172
+				require_once(ABSPATH.'wp-admin/includes/media.php');
173 173
 			}
174 174
 
175 175
 			$url     = $json_to_array['email_logo'];
176
-			$new_url = media_sideload_image( $url, 0, null, 'src' );
177
-			if ( ! is_wp_error( $new_url ) ) {
176
+			$new_url = media_sideload_image($url, 0, null, 'src');
177
+			if ( ! is_wp_error($new_url)) {
178 178
 				$json_to_array['email_logo'] = $new_url;
179 179
 			} else {
180
-				unset( $json_to_array['email_logo'] );
180
+				unset($json_to_array['email_logo']);
181 181
 			}
182 182
 		}
183 183
 	}
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 	return $json_to_array;
186 186
 }
187 187
 
188
-add_filter( 'give_import_core_settings_data', 'give_import_core_settings_merge_upload_image', 13, 2 );
188
+add_filter('give_import_core_settings_data', 'give_import_core_settings_merge_upload_image', 13, 2);
189 189
 
190 190
 /**
191 191
  * Give unset the license key from the core setting data from the json files.
@@ -197,12 +197,12 @@  discard block
 block discarded – undo
197 197
  *
198 198
  * @return array $json_to_array
199 199
  */
200
-function give_import_core_settings_merge_license_key( $json_to_array, $type ) {
201
-	if ( 'merge' === $type ) {
202
-		foreach ( $json_to_array as $key => $value ) {
203
-			$is_license_key = strpos( '_license_key', $key );
204
-			if ( ! empty( $is_license_key ) ) {
205
-				unset( $json_to_array[ $key ] );
200
+function give_import_core_settings_merge_license_key($json_to_array, $type) {
201
+	if ('merge' === $type) {
202
+		foreach ($json_to_array as $key => $value) {
203
+			$is_license_key = strpos('_license_key', $key);
204
+			if ( ! empty($is_license_key)) {
205
+				unset($json_to_array[$key]);
206 206
 			}
207 207
 		}
208 208
 	}
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 	return $json_to_array;
211 211
 }
212 212
 
213
-add_filter( 'give_import_core_settings_data', 'give_import_core_settings_merge_license_key', 14, 2 );
213
+add_filter('give_import_core_settings_data', 'give_import_core_settings_merge_license_key', 14, 2);
214 214
 
215 215
 /**
216 216
  * Give merge the json data and setting data.
@@ -223,16 +223,16 @@  discard block
 block discarded – undo
223 223
  *
224 224
  * @return array $json_to_array
225 225
  */
226
-function give_import_core_settings_merge_data( $json_to_array, $type, $host_give_options ) {
227
-	if ( 'merge' === $type ) {
228
-		$json_to_array_merge = array_merge( $host_give_options, $json_to_array );
226
+function give_import_core_settings_merge_data($json_to_array, $type, $host_give_options) {
227
+	if ('merge' === $type) {
228
+		$json_to_array_merge = array_merge($host_give_options, $json_to_array);
229 229
 		$json_to_array       = $json_to_array_merge;
230 230
 	}
231 231
 
232 232
 	return $json_to_array;
233 233
 }
234 234
 
235
-add_filter( 'give_import_core_settings_data', 'give_import_core_settings_merge_data', 1000, 3 );
235
+add_filter('give_import_core_settings_data', 'give_import_core_settings_merge_data', 1000, 3);
236 236
 
237 237
 /**
238 238
  * Backward Compatibility - Cleanup User Roles.
@@ -243,11 +243,11 @@  discard block
 block discarded – undo
243 243
  *
244 244
  * @return mixed
245 245
  */
246
-function give_bc_1817_cleanup_user_roles( $caps ){
246
+function give_bc_1817_cleanup_user_roles($caps) {
247 247
 
248 248
 	if (
249
-		! give_has_upgrade_completed( 'v1817_cleanup_user_roles' ) &&
250
-		! isset( $caps['view_give_payments'] )
249
+		! give_has_upgrade_completed('v1817_cleanup_user_roles') &&
250
+		! isset($caps['view_give_payments'])
251 251
 	) {
252 252
 		give_v1817_process_cleanup_user_roles();
253 253
 	}
@@ -255,4 +255,4 @@  discard block
 block discarded – undo
255 255
 	return $caps;
256 256
 }
257 257
 
258
-add_filter( 'user_has_cap', 'give_bc_1817_cleanup_user_roles' );
259 258
\ No newline at end of file
259
+add_filter('user_has_cap', 'give_bc_1817_cleanup_user_roles');
260 260
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/tools/import/class-give-import-donations.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 
455 455
 		/**
456 456
 		 * @param $option_value
457
-		 * @param $value
457
+		 * @param boolean $value
458 458
 		 *
459 459
 		 * @return string
460 460
 		 */
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
 		 *
545 545
 		 * @since 1.8.14
546 546
 		 *
547
-		 * @param $file_id
547
+		 * @param integer $file_id
548 548
 		 *
549 549
 		 * @return bool|int
550 550
 		 */
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -871,8 +871,8 @@
 block discarded – undo
871 871
 		 */
872 872
 		private function is_donations_import_page() {
873 873
 			return 'import' === give_get_current_setting_tab() &&
874
-			       isset( $_GET['importer-type'] ) &&
875
-			       $this->importer_type === give_clean( $_GET['importer-type'] );
874
+				   isset( $_GET['importer-type'] ) &&
875
+				   $this->importer_type === give_clean( $_GET['importer-type'] );
876 876
 		}
877 877
 	}
878 878
 
Please login to merge, or discard this patch.
Spacing   +189 added lines, -195 removed lines patch added patch discarded remove patch
@@ -11,11 +11,11 @@  discard block
 block discarded – undo
11 11
  * @since       1.8.14
12 12
  */
13 13
 
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit; // Exit if accessed directly
16 16
 }
17 17
 
18
-if ( ! class_exists( 'Give_Import_Donations' ) ) {
18
+if ( ! class_exists('Give_Import_Donations')) {
19 19
 
20 20
 	/**
21 21
 	 * Give_Import_Donations.
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		 * @access private
58 58
 		 */
59 59
 		private function __construct() {
60
-			self::$per_page  = ! empty( $_GET['per_page'] ) ? absint( $_GET['per_page'] ) : self::$per_page;
60
+			self::$per_page = ! empty($_GET['per_page']) ? absint($_GET['per_page']) : self::$per_page;
61 61
 		}
62 62
 
63 63
 		/**
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 		 * @return static
70 70
 		 */
71 71
 		public static function get_instance() {
72
-			if ( null === static::$instance ) {
72
+			if (null === static::$instance) {
73 73
 				self::$instance = new static();
74 74
 			}
75 75
 
@@ -96,27 +96,27 @@  discard block
 block discarded – undo
96 96
 		 * @return void
97 97
 		 */
98 98
 		private function setup_hooks() {
99
-			if ( ! $this->is_donations_import_page() ) {
99
+			if ( ! $this->is_donations_import_page()) {
100 100
 				return;
101 101
 			}
102 102
 
103 103
 			// Do not render main import tools page.
104
-			remove_action( 'give_admin_field_tools_import', array( 'Give_Settings_Import', 'render_import_field', ) );
104
+			remove_action('give_admin_field_tools_import', array('Give_Settings_Import', 'render_import_field',));
105 105
 
106 106
 
107 107
 			// Render donation import page
108
-			add_action( 'give_admin_field_tools_import', array( $this, 'render_page' ) );
108
+			add_action('give_admin_field_tools_import', array($this, 'render_page'));
109 109
 
110 110
 			// Print the HTML.
111
-			add_action( 'give_tools_import_donations_form_start', array( $this, 'html' ), 10 );
111
+			add_action('give_tools_import_donations_form_start', array($this, 'html'), 10);
112 112
 
113 113
 			// Run when form submit.
114
-			add_action( 'give-tools_save_import', array( $this, 'save' ) );
114
+			add_action('give-tools_save_import', array($this, 'save'));
115 115
 
116
-			add_action( 'give-tools_update_notices', array( $this, 'update_notices' ), 11, 1 );
116
+			add_action('give-tools_update_notices', array($this, 'update_notices'), 11, 1);
117 117
 
118 118
 			// Used to add submit button.
119
-			add_action( 'give_tools_import_donations_form_end', array( $this, 'submit' ), 10 );
119
+			add_action('give_tools_import_donations_form_end', array($this, 'submit'), 10);
120 120
 		}
121 121
 
122 122
 		/**
@@ -128,9 +128,9 @@  discard block
 block discarded – undo
128 128
 		 *
129 129
 		 * @return mixed
130 130
 		 */
131
-		public function update_notices( $messages ) {
132
-			if ( ! empty( $_GET['tab'] ) && 'import' === give_clean( $_GET['tab'] ) ) {
133
-				unset( $messages['give-setting-updated'] );
131
+		public function update_notices($messages) {
132
+			if ( ! empty($_GET['tab']) && 'import' === give_clean($_GET['tab'])) {
133
+				unset($messages['give-setting-updated']);
134 134
 			}
135 135
 
136 136
 			return $messages;
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 		 * @since 1.8.14
143 143
 		 */
144 144
 		public function submit() {
145
-			wp_nonce_field( 'give-save-settings', '_give-save-settings' );
145
+			wp_nonce_field('give-save-settings', '_give-save-settings');
146 146
 			?>
147 147
 			<input type="hidden" class="import-step" id="import-step" name="step" value="<?php echo $this->get_step(); ?>"/>
148 148
 			<input type="hidden" class="importer-type" value="<?php echo $this->importer_type; ?>"/>
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 				<table class="widefat export-options-table give-table <?php echo "step-{$step}"; ?>" id="<?php echo "step-{$step}"; ?>">
165 165
 					<tbody>
166 166
 						<?php
167
-						switch ( $this->get_step() ) {
167
+						switch ($this->get_step()) {
168 168
 							case 1:
169 169
 								$this->render_media_csv();
170 170
 								break;
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 								$this->import_success();
182 182
 						}
183 183
 
184
-						if ( false === $this->check_for_dropdown_or_import() ) {
184
+						if (false === $this->check_for_dropdown_or_import()) {
185 185
 							?>
186 186
 							<tr valign="top">
187 187
 								<th></th>
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 									<input type="submit"
190 190
 										   class="button button-primary button-large button-secondary <?php echo "step-{$step}"; ?>"
191 191
 										   id="recount-stats-submit"
192
-										   value="<?php esc_attr_e( 'Submit', 'give' ); ?>"/>
192
+										   value="<?php esc_attr_e('Submit', 'give'); ?>"/>
193 193
 								</th>
194 194
 							</tr>
195 195
 							<?php
@@ -208,56 +208,56 @@  discard block
 block discarded – undo
208 208
 		 */
209 209
 		public function import_success() {
210 210
 
211
-			$delete_csv = ( ! empty( $_GET['delete_csv'] ) ? absint( $_GET['delete_csv'] ) : false );
212
-			$csv        = ( ! empty( $_GET['csv'] ) ? absint( $_GET['csv'] ) : false );
213
-			if ( ! empty( $delete_csv ) && ! empty( $csv ) ) {
214
-				wp_delete_attachment( $csv, true );
211
+			$delete_csv = ( ! empty($_GET['delete_csv']) ? absint($_GET['delete_csv']) : false);
212
+			$csv        = ( ! empty($_GET['csv']) ? absint($_GET['csv']) : false);
213
+			if ( ! empty($delete_csv) && ! empty($csv)) {
214
+				wp_delete_attachment($csv, true);
215 215
 			}
216 216
 
217 217
 			$report      = give_import_donation_report();
218 218
 			$report_html = array(
219 219
 				'duplicate_donor'    => array(
220
-					__( '%s duplicate %s detected', 'give' ),
221
-					__( 'donor', 'give' ),
222
-					__( 'donors', 'give' ),
220
+					__('%s duplicate %s detected', 'give'),
221
+					__('donor', 'give'),
222
+					__('donors', 'give'),
223 223
 				),
224 224
 				'create_donor'       => array(
225
-					__( '%s %s created', 'give' ),
226
-					__( 'donor', 'give' ),
227
-					__( 'donors', 'give' ),
225
+					__('%s %s created', 'give'),
226
+					__('donor', 'give'),
227
+					__('donors', 'give'),
228 228
 				),
229 229
 				'create_form'        => array(
230
-					__( '%s donation %s created', 'give' ),
231
-					__( 'form', 'give' ),
232
-					__( 'forms', 'give' ),
230
+					__('%s donation %s created', 'give'),
231
+					__('form', 'give'),
232
+					__('forms', 'give'),
233 233
 				),
234 234
 				'duplicate_donation' => array(
235
-					__( '%s duplicate %s detected', 'give' ),
236
-					__( 'donation', 'give' ),
237
-					__( 'donations', 'give' ),
235
+					__('%s duplicate %s detected', 'give'),
236
+					__('donation', 'give'),
237
+					__('donations', 'give'),
238 238
 				),
239 239
 				'create_donation'    => array(
240
-					__( '%s %s imported', 'give' ),
241
-					__( 'donation', 'give' ),
242
-					__( 'donations', 'give' ),
240
+					__('%s %s imported', 'give'),
241
+					__('donation', 'give'),
242
+					__('donations', 'give'),
243 243
 				),
244 244
 			);
245
-			$total       = (int) $_GET['total'];
246
-			-- $total;
245
+			$total = (int) $_GET['total'];
246
+			--$total;
247 247
 			$success = (bool) $_GET['success'];
248 248
 			?>
249 249
 			<tr valign="top" class="give-import-dropdown">
250 250
 				<th colspan="2">
251 251
 					<h2>
252 252
 						<?php
253
-						if ( $success ) {
253
+						if ($success) {
254 254
 							echo sprintf(
255
-								__( 'Import complete! %s donations processed', 'give' ),
255
+								__('Import complete! %s donations processed', 'give'),
256 256
 								"<strong>{$total}</strong>"
257 257
 							);
258 258
 						} else {
259 259
 							echo sprintf(
260
-								__( 'Failed to import %s donations', 'give' ),
260
+								__('Failed to import %s donations', 'give'),
261 261
 								"<strong>{$total}</strong>"
262 262
 							);
263 263
 						}
@@ -265,25 +265,25 @@  discard block
 block discarded – undo
265 265
 					</h2>
266 266
 
267 267
 					<?php
268
-					$text      = __( 'Import Donation', 'give' );
268
+					$text      = __('Import Donation', 'give');
269 269
 					$query_arg = array(
270 270
 						'post_type' => 'give_forms',
271 271
 						'page'      => 'give-tools',
272 272
 						'tab'       => 'import',
273 273
 					);
274
-					if ( $success ) {
274
+					if ($success) {
275 275
 						$query_arg = array(
276 276
 							'post_type' => 'give_forms',
277 277
 							'page'      => 'give-payment-history',
278 278
 						);
279
-						$text      = __( 'View Donations', 'give' );
279
+						$text = __('View Donations', 'give');
280 280
 					}
281 281
 
282
-					foreach ( $report as $key => $value ) {
283
-						if ( array_key_exists( $key, $report_html ) && ! empty( $value ) ) {
282
+					foreach ($report as $key => $value) {
283
+						if (array_key_exists($key, $report_html) && ! empty($value)) {
284 284
 							?>
285 285
 							<p>
286
-								<?php echo esc_html( wp_sprintf( $report_html[ $key ][0], $value, _n( $report_html[ $key ][1], $report_html[ $key ][2], $value, 'give' ) ) ); ?>
286
+								<?php echo esc_html(wp_sprintf($report_html[$key][0], $value, _n($report_html[$key][1], $report_html[$key][2], $value, 'give'))); ?>
287 287
 							</p>
288 288
 							<?php
289 289
 						}
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 					?>
292 292
 
293 293
 					<p>
294
-						<a class="button button-large button-secondary" href="<?php echo add_query_arg( $query_arg, admin_url( 'edit.php' ) ); ?>"><?php echo $text; ?></a>
294
+						<a class="button button-large button-secondary" href="<?php echo add_query_arg($query_arg, admin_url('edit.php')); ?>"><?php echo $text; ?></a>
295 295
 					</p>
296 296
 				</th>
297 297
 			</tr>
@@ -308,26 +308,26 @@  discard block
 block discarded – undo
308 308
 			give_import_donation_report_reset();
309 309
 
310 310
 			$csv         = (int) $_REQUEST['csv'];
311
-			$delimiter   = ( ! empty( $_REQUEST['delimiter'] ) ? give_clean( $_REQUEST['delimiter'] ) : 'csv' );
311
+			$delimiter   = ( ! empty($_REQUEST['delimiter']) ? give_clean($_REQUEST['delimiter']) : 'csv');
312 312
 			$index_start = 1;
313 313
 			$index_end   = 1;
314 314
 			$next        = true;
315
-			$total       = self::get_csv_total( $csv );
316
-			if ( self::$per_page < $total ) {
317
-				$total_ajax = ceil( $total / self::$per_page );
315
+			$total       = self::get_csv_total($csv);
316
+			if (self::$per_page < $total) {
317
+				$total_ajax = ceil($total / self::$per_page);
318 318
 				$index_end  = self::$per_page;
319 319
 			} else {
320 320
 				$total_ajax = 1;
321 321
 				$index_end  = $total;
322 322
 				$next       = false;
323 323
 			}
324
-			$current_percentage = 100 / ( $total_ajax + 1 );
324
+			$current_percentage = 100 / ($total_ajax + 1);
325 325
 
326 326
 			?>
327 327
 			<tr valign="top" class="give-import-dropdown">
328 328
 				<th colspan="2">
329
-					<h2 id="give-import-title"><?php esc_html_e( 'Importing', 'give' ) ?></h2>
330
-					<p class="give-field-description"><?php esc_html_e( 'Your donations are now being imported...', 'give' ) ?></p>
329
+					<h2 id="give-import-title"><?php esc_html_e('Importing', 'give') ?></h2>
330
+					<p class="give-field-description"><?php esc_html_e('Your donations are now being imported...', 'give') ?></p>
331 331
 				</th>
332 332
 			</tr>
333 333
 
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
 						<div style="width: <?php echo $current_percentage; ?>%"></div>
347 347
 					</div>
348 348
 					<input type="hidden" value="3" name="step">
349
-					<input type="hidden" value='<?php echo maybe_serialize( $_REQUEST['mapto'] ); ?>' name="mapto"
349
+					<input type="hidden" value='<?php echo maybe_serialize($_REQUEST['mapto']); ?>' name="mapto"
350 350
 						   class="mapto">
351 351
 					<input type="hidden" value="<?php echo $_REQUEST['csv']; ?>" name="csv" class="csv">
352 352
 					<input type="hidden" value="<?php echo $_REQUEST['mode']; ?>" name="mode" class="mode">
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 					<input type="hidden" value="<?php echo $_REQUEST['delete_csv']; ?>" name="delete_csv"
356 356
 						   class="delete_csv">
357 357
 					<input type="hidden" value="<?php echo $delimiter; ?>" name="delimiter">
358
-					<input type="hidden" value='<?php echo maybe_serialize( self::get_importer( $csv, 0, $delimiter ) ); ?>'
358
+					<input type="hidden" value='<?php echo maybe_serialize(self::get_importer($csv, 0, $delimiter)); ?>'
359 359
 						   name="main_key"
360 360
 						   class="main_key">
361 361
 				</th>
@@ -376,20 +376,20 @@  discard block
 block discarded – undo
376 376
 		 */
377 377
 		public function check_for_dropdown_or_import() {
378 378
 			$return = true;
379
-			if ( isset( $_REQUEST['mapto'] ) ) {
379
+			if (isset($_REQUEST['mapto'])) {
380 380
 				$mapto = (array) $_REQUEST['mapto'];
381
-				if ( false === in_array( 'form_title', $mapto ) && false === in_array( 'form_id', $mapto ) ) {
382
-					Give_Admin_Settings::add_error( 'give-import-csv-form', __( 'In order to import donations, a column must be mapped to either the "Donation Form Title" or "Donation Form ID" field. Please map a column to one of those fields.', 'give' ) );
381
+				if (false === in_array('form_title', $mapto) && false === in_array('form_id', $mapto)) {
382
+					Give_Admin_Settings::add_error('give-import-csv-form', __('In order to import donations, a column must be mapped to either the "Donation Form Title" or "Donation Form ID" field. Please map a column to one of those fields.', 'give'));
383 383
 					$return = false;
384 384
 				}
385 385
 
386
-				if ( false === in_array( 'amount', $mapto ) ) {
387
-					Give_Admin_Settings::add_error( 'give-import-csv-amount', __( 'In order to import donations, a column must be mapped to the "Amount" field. Please map a column to that field.', 'give' ) );
386
+				if (false === in_array('amount', $mapto)) {
387
+					Give_Admin_Settings::add_error('give-import-csv-amount', __('In order to import donations, a column must be mapped to the "Amount" field. Please map a column to that field.', 'give'));
388 388
 					$return = false;
389 389
 				}
390 390
 
391
-				if ( false === in_array( 'email', $mapto ) && false === in_array( 'donor_id', $mapto ) ) {
392
-					Give_Admin_Settings::add_error( 'give-import-csv-donor', __( 'In order to import donations, a column must be mapped to either the "Donor Email" or "Donor ID" field. Please map a column to that field.', 'give' ) );
391
+				if (false === in_array('email', $mapto) && false === in_array('donor_id', $mapto)) {
392
+					Give_Admin_Settings::add_error('give-import-csv-donor', __('In order to import donations, a column must be mapped to either the "Donor Email" or "Donor ID" field. Please map a column to that field.', 'give'));
393 393
 					$return = false;
394 394
 				}
395 395
 			} else {
@@ -406,10 +406,10 @@  discard block
 block discarded – undo
406 406
 		 */
407 407
 		public function render_dropdown() {
408 408
 			$csv       = (int) $_GET['csv'];
409
-			$delimiter = ( ! empty( $_GET['delimiter'] ) ? give_clean( $_GET['delimiter'] ) : 'csv' );
409
+			$delimiter = ( ! empty($_GET['delimiter']) ? give_clean($_GET['delimiter']) : 'csv');
410 410
 
411 411
 			// TO check if the CSV files that is being add is valid or not if not then redirect to first step again
412
-			if ( ! $this->is_valid_csv( $csv ) ) {
412
+			if ( ! $this->is_valid_csv($csv)) {
413 413
 				$url = give_import_page_url();
414 414
 				?>
415 415
 				<script type="text/javascript">
@@ -420,27 +420,27 @@  discard block
 block discarded – undo
420 420
 				?>
421 421
 				<tr valign="top" class="give-import-dropdown">
422 422
 					<th colspan="2">
423
-						<h2 id="give-import-title"><?php esc_html_e( 'Map CSV fields to donations', 'give' ) ?></h2>
424
-						<p class="give-field-description"><?php esc_html_e( 'Select fields from your CSV file to map against donations fields or to ignore during import.', 'give' ) ?></p>
423
+						<h2 id="give-import-title"><?php esc_html_e('Map CSV fields to donations', 'give') ?></h2>
424
+						<p class="give-field-description"><?php esc_html_e('Select fields from your CSV file to map against donations fields or to ignore during import.', 'give') ?></p>
425 425
 					</th>
426 426
 				</tr>
427 427
 
428 428
 				<tr valign="top" class="give-import-dropdown">
429
-					<th><b><?php esc_html_e( 'Column name', 'give' ); ?></b></th>
430
-					<th><b><?php esc_html_e( 'Map to field', 'give' ); ?></b></th>
429
+					<th><b><?php esc_html_e('Column name', 'give'); ?></b></th>
430
+					<th><b><?php esc_html_e('Map to field', 'give'); ?></b></th>
431 431
 				</tr>
432 432
 
433 433
 				<?php
434
-				$raw_key   = $this->get_importer( $csv, 0, $delimiter );
435
-				$mapto     = (array) ( isset( $_REQUEST['mapto'] ) ? $_REQUEST['mapto'] : array() );
434
+				$raw_key   = $this->get_importer($csv, 0, $delimiter);
435
+				$mapto     = (array) (isset($_REQUEST['mapto']) ? $_REQUEST['mapto'] : array());
436 436
 
437
-				foreach ( $raw_key as $index => $value ) {
437
+				foreach ($raw_key as $index => $value) {
438 438
 					?>
439 439
 					<tr valign="top" class="give-import-option">
440 440
 						<th><?php echo $value; ?></th>
441 441
 						<th>
442 442
 							<?php
443
-							$this->get_columns( $index, $value, $mapto );
443
+							$this->get_columns($index, $value, $mapto);
444 444
 							?>
445 445
 						</th>
446 446
 					</tr>
@@ -455,14 +455,14 @@  discard block
 block discarded – undo
455 455
 		 *
456 456
 		 * @return string
457 457
 		 */
458
-		public function selected( $option_value, $value ) {
459
-			$option_value = strtolower( $option_value );
460
-			$value = strtolower( $value );
458
+		public function selected($option_value, $value) {
459
+			$option_value = strtolower($option_value);
460
+			$value = strtolower($value);
461 461
 
462 462
 			$selected = '';
463
-			if ( stristr( $value, $option_value ) ) {
463
+			if (stristr($value, $option_value)) {
464 464
 				$selected = 'selected';
465
-			} elseif ( strrpos( $value, '_' ) && stristr( $option_value, __( 'Import as Meta', 'give' ) ) ) {
465
+			} elseif (strrpos($value, '_') && stristr($option_value, __('Import as Meta', 'give'))) {
466 466
 				$selected = 'selected';
467 467
 			}
468 468
 
@@ -481,28 +481,28 @@  discard block
 block discarded – undo
481 481
 		 *
482 482
 		 * @return void
483 483
 		 */
484
-		private function get_columns( $index, $value = false, $mapto = array() ) {
484
+		private function get_columns($index, $value = false, $mapto = array()) {
485 485
 			$default       = give_import_default_options();
486
-			$current_mapto = (string) ( ! empty( $mapto[ $index ] ) ? $mapto[ $index ] : '' );
486
+			$current_mapto = (string) ( ! empty($mapto[$index]) ? $mapto[$index] : '');
487 487
 			?>
488 488
 			<select name="mapto[<?php echo $index; ?>]">
489
-				<?php $this->get_dropdown_option_html( $default, $current_mapto, $value ); ?>
489
+				<?php $this->get_dropdown_option_html($default, $current_mapto, $value); ?>
490 490
 
491
-				<optgroup label="<?php _e( 'Donations', 'give' ); ?>">
491
+				<optgroup label="<?php _e('Donations', 'give'); ?>">
492 492
 					<?php
493
-					$this->get_dropdown_option_html( give_import_donations_options(), $current_mapto, $value );
493
+					$this->get_dropdown_option_html(give_import_donations_options(), $current_mapto, $value);
494 494
 					?>
495 495
 				</optgroup>
496 496
 
497
-				<optgroup label="<?php _e( 'Donors', 'give' ); ?>">
497
+				<optgroup label="<?php _e('Donors', 'give'); ?>">
498 498
 					<?php
499
-					$this->get_dropdown_option_html( give_import_donor_options(), $current_mapto, $value );
499
+					$this->get_dropdown_option_html(give_import_donor_options(), $current_mapto, $value);
500 500
 					?>
501 501
 				</optgroup>
502 502
 
503
-				<optgroup label="<?php _e( 'Forms', 'give' ); ?>">
503
+				<optgroup label="<?php _e('Forms', 'give'); ?>">
504 504
 					<?php
505
-					$this->get_dropdown_option_html( give_import_donation_form_options(), $current_mapto, $value );
505
+					$this->get_dropdown_option_html(give_import_donation_form_options(), $current_mapto, $value);
506 506
 					?>
507 507
 				</optgroup>
508 508
 
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
 				 *
514 514
 				 * @since 1.8.15
515 515
 				 */
516
-				do_action( 'give_import_dropdown_option', $index, $value, $mapto, $current_mapto );
516
+				do_action('give_import_dropdown_option', $index, $value, $mapto, $current_mapto);
517 517
 				?>
518 518
 			</select>
519 519
 			<?php
@@ -531,16 +531,16 @@  discard block
 block discarded – undo
531 531
 		 *
532 532
 		 * @return void
533 533
 		 */
534
-		public function get_dropdown_option_html( $options, $current_mapto, $value = false ) {
535
-			foreach ( $options as $option => $option_value ) {
534
+		public function get_dropdown_option_html($options, $current_mapto, $value = false) {
535
+			foreach ($options as $option => $option_value) {
536 536
 				$option_value_texts = (array) $option_value;
537 537
 				$option_text = $option_value_texts[0];
538 538
 
539
-				$checked = ( ( $current_mapto === $option ) ? 'selected' : false );
540
-				if ( empty( $checked ) ) {
541
-					foreach ( $option_value_texts as $option_value_text ) {
542
-						$checked = $this->selected( $option_value_text, $value );
543
-						if ( $checked ) {
539
+				$checked = (($current_mapto === $option) ? 'selected' : false);
540
+				if (empty($checked)) {
541
+					foreach ($option_value_texts as $option_value_text) {
542
+						$checked = $this->selected($option_value_text, $value);
543
+						if ($checked) {
544 544
 							break;
545 545
 						}
546 546
 					}
@@ -564,13 +564,13 @@  discard block
 block discarded – undo
564 564
 		 *
565 565
 		 * @return bool|int
566 566
 		 */
567
-		public function get_csv_total( $file_id ) {
567
+		public function get_csv_total($file_id) {
568 568
 			$total = false;
569
-			if ( $file_id ) {
570
-				$file_dir = get_attached_file( $file_id );
571
-				if ( $file_dir ) {
572
-					$file = new SplFileObject( $file_dir, 'r' );
573
-					$file->seek( PHP_INT_MAX );
569
+			if ($file_id) {
570
+				$file_dir = get_attached_file($file_id);
571
+				if ($file_dir) {
572
+					$file = new SplFileObject($file_dir, 'r');
573
+					$file->seek(PHP_INT_MAX);
574 574
 					$total = $file->key() + 1;
575 575
 				}
576 576
 			}
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
 		 *
590 590
 		 * @return array|bool $raw_data title of the CSV file fields
591 591
 		 */
592
-		public function get_importer( $file_id, $index = 0, $delimiter = 'csv' ) {
592
+		public function get_importer($file_id, $index = 0, $delimiter = 'csv') {
593 593
 			/**
594 594
 			 * Filter to modify delimiter of Import.
595 595
 			 *
@@ -597,16 +597,16 @@  discard block
 block discarded – undo
597 597
 			 *
598 598
 			 * Return string $delimiter.
599 599
 			 */
600
-			$delimiter = (string) apply_filters( 'give_import_delimiter_set', $delimiter );
600
+			$delimiter = (string) apply_filters('give_import_delimiter_set', $delimiter);
601 601
 
602 602
 			$raw_data = false;
603
-			$file_dir = get_attached_file( $file_id );
604
-			if ( $file_dir ) {
605
-				if ( false !== ( $handle = fopen( $file_dir, 'r' ) ) ) {
606
-					$raw_data = fgetcsv( $handle, $index, $delimiter );
603
+			$file_dir = get_attached_file($file_id);
604
+			if ($file_dir) {
605
+				if (false !== ($handle = fopen($file_dir, 'r'))) {
606
+					$raw_data = fgetcsv($handle, $index, $delimiter);
607 607
 					// Remove BOM signature from the first item.
608
-					if ( isset( $raw_data[0] ) ) {
609
-						$raw_data[0] = $this->remove_utf8_bom( $raw_data[0] );
608
+					if (isset($raw_data[0])) {
609
+						$raw_data[0] = $this->remove_utf8_bom($raw_data[0]);
610 610
 					}
611 611
 				}
612 612
 			}
@@ -623,9 +623,9 @@  discard block
 block discarded – undo
623 623
 		 *
624 624
 		 * @return string
625 625
 		 */
626
-		public function remove_utf8_bom( $string ) {
627
-			if ( 'efbbbf' === substr( bin2hex( $string ), 0, 6 ) ) {
628
-				$string = substr( $string, 3 );
626
+		public function remove_utf8_bom($string) {
627
+			if ('efbbbf' === substr(bin2hex($string), 0, 6)) {
628
+				$string = substr($string, 3);
629 629
 			}
630 630
 
631 631
 			return $string;
@@ -641,17 +641,17 @@  discard block
 block discarded – undo
641 641
 			$step = $this->get_step();
642 642
 			?>
643 643
 			<ol class="give-progress-steps">
644
-				<li class="<?php echo( 1 === $step ? 'active' : '' ); ?>">
645
-					<?php esc_html_e( 'Upload CSV file', 'give' ); ?>
644
+				<li class="<?php echo(1 === $step ? 'active' : ''); ?>">
645
+					<?php esc_html_e('Upload CSV file', 'give'); ?>
646 646
 				</li>
647
-				<li class="<?php echo( 2 === $step ? 'active' : '' ); ?>">
648
-					<?php esc_html_e( 'Column mapping', 'give' ); ?>
647
+				<li class="<?php echo(2 === $step ? 'active' : ''); ?>">
648
+					<?php esc_html_e('Column mapping', 'give'); ?>
649 649
 				</li>
650
-				<li class="<?php echo( 3 === $step ? 'active' : '' ); ?>">
651
-					<?php esc_html_e( 'Import', 'give' ); ?>
650
+				<li class="<?php echo(3 === $step ? 'active' : ''); ?>">
651
+					<?php esc_html_e('Import', 'give'); ?>
652 652
 				</li>
653
-				<li class="<?php echo( 4 === $step ? 'active' : '' ); ?>">
654
-					<?php esc_html_e( 'Done!', 'give' ); ?>
653
+				<li class="<?php echo(4 === $step ? 'active' : ''); ?>">
654
+					<?php esc_html_e('Done!', 'give'); ?>
655 655
 				</li>
656 656
 			</ol>
657 657
 			<?php
@@ -665,16 +665,16 @@  discard block
 block discarded – undo
665 665
 		 * @return int $step on which step doest the import is on.
666 666
 		 */
667 667
 		public function get_step() {
668
-			$step    = (int) ( isset( $_REQUEST['step'] ) ? give_clean( $_REQUEST['step'] ) : 0 );
668
+			$step    = (int) (isset($_REQUEST['step']) ? give_clean($_REQUEST['step']) : 0);
669 669
 			$on_step = 1;
670 670
 
671
-			if ( empty( $step ) || 1 === $step ) {
671
+			if (empty($step) || 1 === $step) {
672 672
 				$on_step = 1;
673
-			} elseif ( $this->check_for_dropdown_or_import() ) {
673
+			} elseif ($this->check_for_dropdown_or_import()) {
674 674
 				$on_step = 3;
675
-			} elseif ( 2 === $step ) {
675
+			} elseif (2 === $step) {
676 676
 				$on_step = 2;
677
-			} elseif ( 4 === $step ) {
677
+			} elseif (4 === $step) {
678 678
 				$on_step = 4;
679 679
 			}
680 680
 
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
 		 * @since 1.8.14
688 688
 		 */
689 689
 		public function render_page() {
690
-			include_once GIVE_PLUGIN_DIR . 'includes/admin/tools/views/html-admin-page-import-donations.php';
690
+			include_once GIVE_PLUGIN_DIR.'includes/admin/tools/views/html-admin-page-import-donations.php';
691 691
 		}
692 692
 
693 693
 		/**
@@ -702,37 +702,34 @@  discard block
 block discarded – undo
702 702
 			?>
703 703
 			<tr valign="top">
704 704
 				<th colspan="2">
705
-					<h2 id="give-import-title"><?php esc_html_e( 'Import donations from a CSV file', 'give' ) ?></h2>
706
-					<p class="give-field-description"><?php esc_html_e( 'This tool allows you to import or add donation data to your give form(s) via a CSV file.', 'give' ) ?></p>
705
+					<h2 id="give-import-title"><?php esc_html_e('Import donations from a CSV file', 'give') ?></h2>
706
+					<p class="give-field-description"><?php esc_html_e('This tool allows you to import or add donation data to your give form(s) via a CSV file.', 'give') ?></p>
707 707
 				</th>
708 708
 			</tr>
709 709
 			<?php
710
-			$csv         = ( isset( $_POST['csv'] ) ? give_clean( $_POST['csv'] ) : '' );
711
-			$csv_id      = ( isset( $_POST['csv_id'] ) ? give_clean( $_POST['csv_id'] ) : '' );
712
-			$delimiter   = ( isset( $_POST['delimiter'] ) ? give_clean( $_POST['delimiter'] ) : 'csv' );
713
-			$mode        = empty( $_POST['mode'] ) ?
714
-				'disabled' :
715
-				( give_is_setting_enabled( give_clean( $_POST['mode'] ) ) ? 'enabled' : 'disabled' );
716
-			$create_user = empty( $_POST['create_user'] ) ?
717
-				'enabled' :
718
-				( give_is_setting_enabled( give_clean( $_POST['create_user'] ) ) ? 'enabled' : 'disabled' );
719
-			$delete_csv  = empty( $_POST['delete_csv'] ) ?
720
-				'enabled' :
721
-				( give_is_setting_enabled( give_clean( $_POST['delete_csv'] ) ) ? 'enabled' : 'disabled' );
710
+			$csv         = (isset($_POST['csv']) ? give_clean($_POST['csv']) : '');
711
+			$csv_id      = (isset($_POST['csv_id']) ? give_clean($_POST['csv_id']) : '');
712
+			$delimiter   = (isset($_POST['delimiter']) ? give_clean($_POST['delimiter']) : 'csv');
713
+			$mode        = empty($_POST['mode']) ?
714
+				'disabled' : (give_is_setting_enabled(give_clean($_POST['mode'])) ? 'enabled' : 'disabled');
715
+			$create_user = empty($_POST['create_user']) ?
716
+				'enabled' : (give_is_setting_enabled(give_clean($_POST['create_user'])) ? 'enabled' : 'disabled');
717
+			$delete_csv  = empty($_POST['delete_csv']) ?
718
+				'enabled' : (give_is_setting_enabled(give_clean($_POST['delete_csv'])) ? 'enabled' : 'disabled');
722 719
 
723 720
 			// Reset csv and csv_id if csv
724
-			if ( empty( $csv_id ) || ! $this->is_valid_csv( $csv_id, $csv ) ) {
721
+			if (empty($csv_id) || ! $this->is_valid_csv($csv_id, $csv)) {
725 722
 				$csv_id = $csv = '';
726 723
 			}
727
-			$per_page = isset( $_POST['per_page'] ) ? absint( $_POST['per_page'] ) : self::$per_page;
724
+			$per_page = isset($_POST['per_page']) ? absint($_POST['per_page']) : self::$per_page;
728 725
 
729 726
 			$settings = array(
730 727
 				array(
731 728
 					'id'          => 'csv',
732
-					'name'        => __( 'Choose a CSV file:', 'give' ),
729
+					'name'        => __('Choose a CSV file:', 'give'),
733 730
 					'type'        => 'file',
734
-					'attributes'  => array( 'editing' => 'false', 'library' => 'text' ),
735
-					'description' => __( 'The file must be a Comma Seperated Version (CSV) file type only.', 'give' ),
731
+					'attributes'  => array('editing' => 'false', 'library' => 'text'),
732
+					'description' => __('The file must be a Comma Seperated Version (CSV) file type only.', 'give'),
736 733
 					'fvalue'      => 'url',
737 734
 					'default'     => $csv,
738 735
 				),
@@ -743,61 +740,61 @@  discard block
 block discarded – undo
743 740
 				),
744 741
 				array(
745 742
 					'id'          => 'delimiter',
746
-					'name'        => __( 'CSV Delimiter:', 'give' ),
747
-					'description' => __( 'In case your CSV file supports a different type of separator (or delimiter) -- like a tab or space -- you can set that here.', 'give' ),
743
+					'name'        => __('CSV Delimiter:', 'give'),
744
+					'description' => __('In case your CSV file supports a different type of separator (or delimiter) -- like a tab or space -- you can set that here.', 'give'),
748 745
 					'default'     => $delimiter,
749 746
 					'type'        => 'select',
750 747
 					'options'     => array(
751
-						'csv'                  => esc_html__( 'Comma', 'give' ),
752
-						'tab-separated-values' => esc_html__( 'Tab', 'give' ),
748
+						'csv'                  => esc_html__('Comma', 'give'),
749
+						'tab-separated-values' => esc_html__('Tab', 'give'),
753 750
 					),
754 751
 				),
755 752
 				array(
756 753
 					'id'          => 'mode',
757
-					'name'        => __( 'Test Mode:', 'give' ),
758
-					'description' => __( 'Test mode allows you to preview what this import would look like without making any actual changes to your site or your database.', 'give' ),
754
+					'name'        => __('Test Mode:', 'give'),
755
+					'description' => __('Test mode allows you to preview what this import would look like without making any actual changes to your site or your database.', 'give'),
759 756
 					'default'     => $mode,
760 757
 					'type'        => 'radio_inline',
761 758
 					'options'     => array(
762
-						'enabled'  => __( 'Enabled', 'give' ),
763
-						'disabled' => __( 'Disabled', 'give' ),
759
+						'enabled'  => __('Enabled', 'give'),
760
+						'disabled' => __('Disabled', 'give'),
764 761
 					),
765 762
 				),
766 763
 				array(
767 764
 					'id'          => 'create_user',
768
-					'name'        => __( 'Create WP users for new donors:', 'give' ),
769
-					'description' => __( 'The importer can create WordPress user accounts based on the names and email addresses of the donations in your CSV file. Enable this option if you\'d like the importer to do that.', 'give' ),
765
+					'name'        => __('Create WP users for new donors:', 'give'),
766
+					'description' => __('The importer can create WordPress user accounts based on the names and email addresses of the donations in your CSV file. Enable this option if you\'d like the importer to do that.', 'give'),
770 767
 					'default'     => $create_user,
771 768
 					'type'        => 'radio_inline',
772 769
 					'options'     => array(
773
-						'enabled'  => __( 'Enabled', 'give' ),
774
-						'disabled' => __( 'Disabled', 'give' ),
770
+						'enabled'  => __('Enabled', 'give'),
771
+						'disabled' => __('Disabled', 'give'),
775 772
 					),
776 773
 				),
777 774
 				array(
778 775
 					'id'          => 'delete_csv',
779
-					'name'        => __( 'Delete CSV after import:', 'give' ),
780
-					'description' => __( 'Your CSV file will be uploaded via the WordPress Media Library. It\'s a good idea to delete it after the import is finished so that your sensitive data is not accessible on the web. Disable this only if you plan to delete the file manually later.', 'give' ),
776
+					'name'        => __('Delete CSV after import:', 'give'),
777
+					'description' => __('Your CSV file will be uploaded via the WordPress Media Library. It\'s a good idea to delete it after the import is finished so that your sensitive data is not accessible on the web. Disable this only if you plan to delete the file manually later.', 'give'),
781 778
 					'default'     => $delete_csv,
782 779
 					'type'        => 'radio_inline',
783 780
 					'options'     => array(
784
-						'enabled'  => __( 'Enabled', 'give' ),
785
-						'disabled' => __( 'Disabled', 'give' ),
781
+						'enabled'  => __('Enabled', 'give'),
782
+						'disabled' => __('Disabled', 'give'),
786 783
 					),
787 784
 				),
788 785
 				array(
789 786
 					'id'          => 'per_page',
790
-					'name'        => __( 'Process Rows Per Batch:', 'give' ),
787
+					'name'        => __('Process Rows Per Batch:', 'give'),
791 788
 					'type'        => 'number',
792
-					'description' => __( 'Determine how many rows you would like to import per cycle.', 'give' ),
789
+					'description' => __('Determine how many rows you would like to import per cycle.', 'give'),
793 790
 					'default'     => $per_page,
794 791
 					'class'       => 'give-text-small',
795 792
 				),
796 793
 			);
797 794
 
798
-			$settings = apply_filters( 'give_import_file_upload_html', $settings );
795
+			$settings = apply_filters('give_import_file_upload_html', $settings);
799 796
 
800
-			Give_Admin_Settings::output_fields( $settings, 'give_settings' );
797
+			Give_Admin_Settings::output_fields($settings, 'give_settings');
801 798
 		}
802 799
 
803 800
 		/**
@@ -810,27 +807,24 @@  discard block
 block discarded – undo
810 807
 			$step = $this->get_step();
811 808
 
812 809
 			// Validation for first step.
813
-			if ( 1 === $step ) {
814
-				$csv_id = absint( $_POST['csv_id'] );
810
+			if (1 === $step) {
811
+				$csv_id = absint($_POST['csv_id']);
815 812
 
816
-				if ( $this->is_valid_csv( $csv_id, esc_url( $_POST['csv'] ) ) ) {
813
+				if ($this->is_valid_csv($csv_id, esc_url($_POST['csv']))) {
817 814
 
818
-					$url = give_import_page_url( (array) apply_filters( 'give_import_step_two_url', array(
815
+					$url = give_import_page_url((array) apply_filters('give_import_step_two_url', array(
819 816
 						'step'          => '2',
820 817
 						'importer-type' => $this->importer_type,
821 818
 						'csv'           => $csv_id,
822
-						'delimiter'     => isset( $_REQUEST['delimiter'] ) ? give_clean( $_REQUEST['delimiter'] ) : 'csv',
823
-						'mode'          => empty( $_POST['mode'] ) ?
824
-							'0' :
825
-							( give_is_setting_enabled( give_clean( $_POST['mode'] ) ) ? '1' : '0' ),
826
-						'create_user'   => empty( $_POST['create_user'] ) ?
827
-							'0' :
828
-							( give_is_setting_enabled( give_clean( $_POST['create_user'] ) ) ? '1' : '0' ),
829
-						'delete_csv'    => empty( $_POST['delete_csv'] ) ?
830
-							'1' :
831
-							( give_is_setting_enabled( give_clean( $_POST['delete_csv'] ) ) ? '1' : '0' ),
832
-						'per_page'      => isset( $_POST['per_page'] ) ? absint( $_POST['per_page'] ) : self::$per_page,
833
-					) ) );
819
+						'delimiter'     => isset($_REQUEST['delimiter']) ? give_clean($_REQUEST['delimiter']) : 'csv',
820
+						'mode'          => empty($_POST['mode']) ?
821
+							'0' : (give_is_setting_enabled(give_clean($_POST['mode'])) ? '1' : '0'),
822
+						'create_user'   => empty($_POST['create_user']) ?
823
+							'0' : (give_is_setting_enabled(give_clean($_POST['create_user'])) ? '1' : '0'),
824
+						'delete_csv'    => empty($_POST['delete_csv']) ?
825
+							'1' : (give_is_setting_enabled(give_clean($_POST['delete_csv'])) ? '1' : '0'),
826
+						'per_page'      => isset($_POST['per_page']) ? absint($_POST['per_page']) : self::$per_page,
827
+					)));
834 828
 					?>
835 829
 					<script type="text/javascript">
836 830
 						window.location = "<?php echo $url; ?>"
@@ -851,25 +845,25 @@  discard block
 block discarded – undo
851 845
 		 *
852 846
 		 * @return bool $has_error CSV is valid or not.
853 847
 		 */
854
-		private function is_valid_csv( $csv = false, $match_url = '' ) {
848
+		private function is_valid_csv($csv = false, $match_url = '') {
855 849
 			$is_valid_csv = true;
856 850
 
857
-			if ( $csv ) {
858
-				$csv_url = wp_get_attachment_url( $csv );
851
+			if ($csv) {
852
+				$csv_url = wp_get_attachment_url($csv);
859 853
 
860
-				$delimiter = ( ! empty( $_REQUEST['delimiter'] ) ? give_clean( $_REQUEST['delimiter'] ) : 'csv' );
854
+				$delimiter = ( ! empty($_REQUEST['delimiter']) ? give_clean($_REQUEST['delimiter']) : 'csv');
861 855
 
862 856
 				if (
863 857
 					! $csv_url ||
864
-					( ! empty( $match_url ) && ( $csv_url !== $match_url ) ) ||
865
-					( ( $mime_type = get_post_mime_type( $csv ) ) && ! strpos( $mime_type, $delimiter ) )
858
+					( ! empty($match_url) && ($csv_url !== $match_url)) ||
859
+					(($mime_type = get_post_mime_type($csv)) && ! strpos($mime_type, $delimiter))
866 860
 				) {
867 861
 					$is_valid_csv = false;
868
-					Give_Admin_Settings::add_error( 'give-import-csv', __( 'Please upload or provide a valid CSV file.', 'give' ) );
862
+					Give_Admin_Settings::add_error('give-import-csv', __('Please upload or provide a valid CSV file.', 'give'));
869 863
 				}
870 864
 			} else {
871 865
 				$is_valid_csv = false;
872
-				Give_Admin_Settings::add_error( 'give-import-csv', __( 'Please upload or provide a valid CSV file.', 'give' ) );
866
+				Give_Admin_Settings::add_error('give-import-csv', __('Please upload or provide a valid CSV file.', 'give'));
873 867
 			}
874 868
 
875 869
 			return $is_valid_csv;
@@ -885,8 +879,8 @@  discard block
 block discarded – undo
885 879
 		 * @param $field
886 880
 		 * @param $option_value
887 881
 		 */
888
-		public function render_import_field( $field, $option_value ) {
889
-			include_once GIVE_PLUGIN_DIR . 'includes/admin/tools/views/html-admin-page-imports.php';
882
+		public function render_import_field($field, $option_value) {
883
+			include_once GIVE_PLUGIN_DIR.'includes/admin/tools/views/html-admin-page-imports.php';
890 884
 		}
891 885
 
892 886
 		/**
@@ -897,8 +891,8 @@  discard block
 block discarded – undo
897 891
 		 */
898 892
 		private function is_donations_import_page() {
899 893
 			return 'import' === give_get_current_setting_tab() &&
900
-			       isset( $_GET['importer-type'] ) &&
901
-			       $this->importer_type === give_clean( $_GET['importer-type'] );
894
+			       isset($_GET['importer-type']) &&
895
+			       $this->importer_type === give_clean($_GET['importer-type']);
902 896
 		}
903 897
 	}
904 898
 
Please login to merge, or discard this patch.
includes/class-give-donor.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -902,7 +902,7 @@  discard block
 block discarded – undo
902 902
 	 * @access public
903 903
 	 *
904 904
 	 * @param  string $meta_key Metadata key. Default is empty.
905
-	 * @param  mixed $meta_value Metadata value.
905
+	 * @param  integer $meta_value Metadata value.
906 906
 	 * @param  mixed $prev_value Optional. Previous value to check before removing. Default is empty.
907 907
 	 *
908 908
 	 * @return bool               False on failure, true if success.
@@ -918,7 +918,7 @@  discard block
 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   +172 added lines, -172 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
 
@@ -139,32 +139,32 @@  discard block
 block discarded – undo
139 139
 	 * @param bool $_id_or_email
140 140
 	 * @param bool $by_user_id
141 141
 	 */
142
-	public function __construct( $_id_or_email = false, $by_user_id = false ) {
142
+	public function __construct($_id_or_email = false, $by_user_id = false) {
143 143
 
144 144
 		$this->db = Give()->donors;
145 145
 
146 146
 		if (
147 147
 			false === $_id_or_email
148
-			|| ( is_numeric( $_id_or_email ) && (int) $_id_or_email !== absint( $_id_or_email ) )
148
+			|| (is_numeric($_id_or_email) && (int) $_id_or_email !== absint($_id_or_email))
149 149
 		) {
150 150
 			return false;
151 151
 		}
152 152
 
153
-		$by_user_id = is_bool( $by_user_id ) ? $by_user_id : false;
153
+		$by_user_id = is_bool($by_user_id) ? $by_user_id : false;
154 154
 
155
-		if ( is_numeric( $_id_or_email ) ) {
155
+		if (is_numeric($_id_or_email)) {
156 156
 			$field = $by_user_id ? 'user_id' : 'id';
157 157
 		} else {
158 158
 			$field = 'email';
159 159
 		}
160 160
 
161
-		$donor = $this->db->get_donor_by( $field, $_id_or_email );
161
+		$donor = $this->db->get_donor_by($field, $_id_or_email);
162 162
 
163
-		if ( empty( $donor ) || ! is_object( $donor ) ) {
163
+		if (empty($donor) || ! is_object($donor)) {
164 164
 			return false;
165 165
 		}
166 166
 
167
-		$this->setup_donor( $donor );
167
+		$this->setup_donor($donor);
168 168
 
169 169
 	}
170 170
 
@@ -180,15 +180,15 @@  discard block
 block discarded – undo
180 180
 	 *
181 181
 	 * @return bool             If the setup was successful or not.
182 182
 	 */
183
-	private function setup_donor( $donor ) {
183
+	private function setup_donor($donor) {
184 184
 
185
-		if ( ! is_object( $donor ) ) {
185
+		if ( ! is_object($donor)) {
186 186
 			return false;
187 187
 		}
188 188
 
189
-		foreach ( $donor as $key => $value ) {
189
+		foreach ($donor as $key => $value) {
190 190
 
191
-			switch ( $key ) {
191
+			switch ($key) {
192 192
 
193 193
 				case 'notes':
194 194
 					$this->$key = $this->get_notes();
@@ -202,11 +202,11 @@  discard block
 block discarded – undo
202 202
 		}
203 203
 
204 204
 		// Get donor's all email including primary email.
205
-		$this->emails = (array) $this->get_meta( 'additional_email', false );
206
-		$this->emails = array( 'primary' => $this->email ) + $this->emails;
205
+		$this->emails = (array) $this->get_meta('additional_email', false);
206
+		$this->emails = array('primary' => $this->email) + $this->emails;
207 207
 
208 208
 		// Donor ID and email are the only things that are necessary, make sure they exist.
209
-		if ( ! empty( $this->id ) && ! empty( $this->email ) ) {
209
+		if ( ! empty($this->id) && ! empty($this->email)) {
210 210
 			return true;
211 211
 		}
212 212
 
@@ -223,16 +223,16 @@  discard block
 block discarded – undo
223 223
 	 *
224 224
 	 * @return mixed|\WP_Error
225 225
 	 */
226
-	public function __get( $key ) {
226
+	public function __get($key) {
227 227
 
228
-		if ( method_exists( $this, 'get_' . $key ) ) {
228
+		if (method_exists($this, 'get_'.$key)) {
229 229
 
230
-			return call_user_func( array( $this, 'get_' . $key ) );
230
+			return call_user_func(array($this, 'get_'.$key));
231 231
 
232 232
 		} else {
233 233
 
234 234
 			/* translators: %s: property key */
235
-			return new WP_Error( 'give-donor-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) );
235
+			return new WP_Error('give-donor-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key));
236 236
 
237 237
 		}
238 238
 
@@ -248,9 +248,9 @@  discard block
 block discarded – undo
248 248
 	 *
249 249
 	 * @return bool|int    False if not a valid creation, donor ID if user is found or valid creation.
250 250
 	 */
251
-	public function create( $data = array() ) {
251
+	public function create($data = array()) {
252 252
 
253
-		if ( $this->id != 0 || empty( $data ) ) {
253
+		if ($this->id != 0 || empty($data)) {
254 254
 			return false;
255 255
 		}
256 256
 
@@ -258,15 +258,15 @@  discard block
 block discarded – undo
258 258
 			'payment_ids' => '',
259 259
 		);
260 260
 
261
-		$args = wp_parse_args( $data, $defaults );
262
-		$args = $this->sanitize_columns( $args );
261
+		$args = wp_parse_args($data, $defaults);
262
+		$args = $this->sanitize_columns($args);
263 263
 
264
-		if ( empty( $args['email'] ) || ! is_email( $args['email'] ) ) {
264
+		if (empty($args['email']) || ! is_email($args['email'])) {
265 265
 			return false;
266 266
 		}
267 267
 
268
-		if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) {
269
-			$args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) );
268
+		if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) {
269
+			$args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids'])));
270 270
 		}
271 271
 
272 272
 		/**
@@ -276,18 +276,18 @@  discard block
 block discarded – undo
276 276
 		 *
277 277
 		 * @param array $args Donor attributes.
278 278
 		 */
279
-		do_action( 'give_donor_pre_create', $args );
279
+		do_action('give_donor_pre_create', $args);
280 280
 
281 281
 		$created = false;
282 282
 
283 283
 		// The DB class 'add' implies an update if the donor being asked to be created already exists
284
-		if ( $this->db->add( $data ) ) {
284
+		if ($this->db->add($data)) {
285 285
 
286 286
 			// We've successfully added/updated the donor, reset the class vars with the new data
287
-			$donor = $this->db->get_donor_by( 'email', $args['email'] );
287
+			$donor = $this->db->get_donor_by('email', $args['email']);
288 288
 
289 289
 			// Setup the donor data with the values from DB
290
-			$this->setup_donor( $donor );
290
+			$this->setup_donor($donor);
291 291
 
292 292
 			$created = $this->id;
293 293
 		}
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 		 * @param bool|int $created False if not a valid creation, donor ID if user is found or valid creation.
301 301
 		 * @param array $args Customer attributes.
302 302
 		 */
303
-		do_action( 'give_donor_post_create', $created, $args );
303
+		do_action('give_donor_post_create', $created, $args);
304 304
 
305 305
 		return $created;
306 306
 
@@ -316,13 +316,13 @@  discard block
 block discarded – undo
316 316
 	 *
317 317
 	 * @return bool        If the update was successful or not.
318 318
 	 */
319
-	public function update( $data = array() ) {
319
+	public function update($data = array()) {
320 320
 
321
-		if ( empty( $data ) ) {
321
+		if (empty($data)) {
322 322
 			return false;
323 323
 		}
324 324
 
325
-		$data = $this->sanitize_columns( $data );
325
+		$data = $this->sanitize_columns($data);
326 326
 
327 327
 		/**
328 328
 		 * Fires before updating donors.
@@ -332,14 +332,14 @@  discard block
 block discarded – undo
332 332
 		 * @param int $donor_id Donor id.
333 333
 		 * @param array $data Donor attributes.
334 334
 		 */
335
-		do_action( 'give_donor_pre_update', $this->id, $data );
335
+		do_action('give_donor_pre_update', $this->id, $data);
336 336
 
337 337
 		$updated = false;
338 338
 
339
-		if ( $this->db->update( $this->id, $data ) ) {
339
+		if ($this->db->update($this->id, $data)) {
340 340
 
341
-			$donor = $this->db->get_donor_by( 'id', $this->id );
342
-			$this->setup_donor( $donor );
341
+			$donor = $this->db->get_donor_by('id', $this->id);
342
+			$this->setup_donor($donor);
343 343
 
344 344
 			$updated = true;
345 345
 		}
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 		 * @param int $donor_id Donor id.
354 354
 		 * @param array $data Donor attributes.
355 355
 		 */
356
-		do_action( 'give_donor_post_update', $updated, $this->id, $data );
356
+		do_action('give_donor_post_update', $updated, $this->id, $data);
357 357
 
358 358
 		return $updated;
359 359
 	}
@@ -371,27 +371,27 @@  discard block
 block discarded – undo
371 371
 	 *
372 372
 	 * @return bool            If the attachment was successfully.
373 373
 	 */
374
-	public function attach_payment( $payment_id = 0, $update_stats = true ) {
374
+	public function attach_payment($payment_id = 0, $update_stats = true) {
375 375
 
376
-		if ( empty( $payment_id ) ) {
376
+		if (empty($payment_id)) {
377 377
 			return false;
378 378
 		}
379 379
 
380
-		if ( empty( $this->payment_ids ) ) {
380
+		if (empty($this->payment_ids)) {
381 381
 
382 382
 			$new_payment_ids = $payment_id;
383 383
 
384 384
 		} else {
385 385
 
386
-			$payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) );
386
+			$payment_ids = array_map('absint', explode(',', $this->payment_ids));
387 387
 
388
-			if ( in_array( $payment_id, $payment_ids ) ) {
388
+			if (in_array($payment_id, $payment_ids)) {
389 389
 				$update_stats = false;
390 390
 			}
391 391
 
392 392
 			$payment_ids[] = $payment_id;
393 393
 
394
-			$new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) );
394
+			$new_payment_ids = implode(',', array_unique(array_values($payment_ids)));
395 395
 
396 396
 		}
397 397
 
@@ -403,20 +403,20 @@  discard block
 block discarded – undo
403 403
 		 * @param int $payment_id Payment id.
404 404
 		 * @param int $donor_id Customer id.
405 405
 		 */
406
-		do_action( 'give_donor_pre_attach_payment', $payment_id, $this->id );
406
+		do_action('give_donor_pre_attach_payment', $payment_id, $this->id);
407 407
 
408
-		$payment_added = $this->update( array( 'payment_ids' => $new_payment_ids ) );
408
+		$payment_added = $this->update(array('payment_ids' => $new_payment_ids));
409 409
 
410
-		if ( $payment_added ) {
410
+		if ($payment_added) {
411 411
 
412 412
 			$this->payment_ids = $new_payment_ids;
413 413
 
414 414
 			// We added this payment successfully, increment the stats
415
-			if ( $update_stats ) {
416
-				$payment_amount = give_donation_amount( $payment_id, array( 'type' => 'stats' ) );
415
+			if ($update_stats) {
416
+				$payment_amount = give_donation_amount($payment_id, array('type' => 'stats'));
417 417
 
418
-				if ( ! empty( $payment_amount ) ) {
419
-					$this->increase_value( $payment_amount );
418
+				if ( ! empty($payment_amount)) {
419
+					$this->increase_value($payment_amount);
420 420
 				}
421 421
 
422 422
 				$this->increase_purchase_count();
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 		 * @param int $payment_id Payment id.
433 433
 		 * @param int $donor_id Donor id.
434 434
 		 */
435
-		do_action( 'give_donor_post_attach_payment', $payment_added, $payment_id, $this->id );
435
+		do_action('give_donor_post_attach_payment', $payment_added, $payment_id, $this->id);
436 436
 
437 437
 		return $payment_added;
438 438
 	}
@@ -450,33 +450,33 @@  discard block
 block discarded – undo
450 450
 	 *
451 451
 	 * @return boolean               If the removal was successful.
452 452
 	 */
453
-	public function remove_payment( $payment_id = 0, $update_stats = true ) {
453
+	public function remove_payment($payment_id = 0, $update_stats = true) {
454 454
 
455
-		if ( empty( $payment_id ) ) {
455
+		if (empty($payment_id)) {
456 456
 			return false;
457 457
 		}
458 458
 
459
-		$payment = new Give_Payment( $payment_id );
459
+		$payment = new Give_Payment($payment_id);
460 460
 
461
-		if ( 'publish' !== $payment->status && 'revoked' !== $payment->status ) {
461
+		if ('publish' !== $payment->status && 'revoked' !== $payment->status) {
462 462
 			$update_stats = false;
463 463
 		}
464 464
 
465 465
 		$new_payment_ids = '';
466 466
 
467
-		if ( ! empty( $this->payment_ids ) ) {
467
+		if ( ! empty($this->payment_ids)) {
468 468
 
469
-			$payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) );
469
+			$payment_ids = array_map('absint', explode(',', $this->payment_ids));
470 470
 
471
-			$pos = array_search( $payment_id, $payment_ids );
472
-			if ( false === $pos ) {
471
+			$pos = array_search($payment_id, $payment_ids);
472
+			if (false === $pos) {
473 473
 				return false;
474 474
 			}
475 475
 
476
-			unset( $payment_ids[ $pos ] );
477
-			$payment_ids = array_filter( $payment_ids );
476
+			unset($payment_ids[$pos]);
477
+			$payment_ids = array_filter($payment_ids);
478 478
 
479
-			$new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) );
479
+			$new_payment_ids = implode(',', array_unique(array_values($payment_ids)));
480 480
 
481 481
 		}
482 482
 
@@ -488,20 +488,20 @@  discard block
 block discarded – undo
488 488
 		 * @param int $payment_id Payment id.
489 489
 		 * @param int $donor_id Customer id.
490 490
 		 */
491
-		do_action( 'give_donor_pre_remove_payment', $payment_id, $this->id );
491
+		do_action('give_donor_pre_remove_payment', $payment_id, $this->id);
492 492
 
493
-		$payment_removed = $this->update( array( 'payment_ids' => $new_payment_ids ) );
493
+		$payment_removed = $this->update(array('payment_ids' => $new_payment_ids));
494 494
 
495
-		if ( $payment_removed ) {
495
+		if ($payment_removed) {
496 496
 
497 497
 			$this->payment_ids = $new_payment_ids;
498 498
 
499
-			if ( $update_stats ) {
499
+			if ($update_stats) {
500 500
 				// We removed this payment successfully, decrement the stats
501
-				$payment_amount = give_donation_amount( $payment_id );
501
+				$payment_amount = give_donation_amount($payment_id);
502 502
 
503
-				if ( ! empty( $payment_amount ) ) {
504
-					$this->decrease_value( $payment_amount );
503
+				if ( ! empty($payment_amount)) {
504
+					$this->decrease_value($payment_amount);
505 505
 				}
506 506
 
507 507
 				$this->decrease_donation_count();
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
 		 * @param int $payment_id Payment id.
518 518
 		 * @param int $donor_id Donor id.
519 519
 		 */
520
-		do_action( 'give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id );
520
+		do_action('give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id);
521 521
 
522 522
 		return $payment_removed;
523 523
 
@@ -533,10 +533,10 @@  discard block
 block discarded – undo
533 533
 	 *
534 534
 	 * @return int        The donation count.
535 535
 	 */
536
-	public function increase_purchase_count( $count = 1 ) {
536
+	public function increase_purchase_count($count = 1) {
537 537
 
538 538
 		// Make sure it's numeric and not negative.
539
-		if ( ! is_numeric( $count ) || $count != absint( $count ) ) {
539
+		if ( ! is_numeric($count) || $count != absint($count)) {
540 540
 			return false;
541 541
 		}
542 542
 
@@ -550,9 +550,9 @@  discard block
 block discarded – undo
550 550
 		 * @param int $count The number to increase by.
551 551
 		 * @param int $donor_id Donor id.
552 552
 		 */
553
-		do_action( 'give_donor_pre_increase_donation_count', $count, $this->id );
553
+		do_action('give_donor_pre_increase_donation_count', $count, $this->id);
554 554
 
555
-		if ( $this->update( array( 'purchase_count' => $new_total ) ) ) {
555
+		if ($this->update(array('purchase_count' => $new_total))) {
556 556
 			$this->purchase_count = $new_total;
557 557
 		}
558 558
 
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
 		 * @param int $count The number increased by.
566 566
 		 * @param int $donor_id Donor id.
567 567
 		 */
568
-		do_action( 'give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id );
568
+		do_action('give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id);
569 569
 
570 570
 		return $this->purchase_count;
571 571
 	}
@@ -580,16 +580,16 @@  discard block
 block discarded – undo
580 580
 	 *
581 581
 	 * @return mixed      If successful, the new count, otherwise false.
582 582
 	 */
583
-	public function decrease_donation_count( $count = 1 ) {
583
+	public function decrease_donation_count($count = 1) {
584 584
 
585 585
 		// Make sure it's numeric and not negative
586
-		if ( ! is_numeric( $count ) || $count != absint( $count ) ) {
586
+		if ( ! is_numeric($count) || $count != absint($count)) {
587 587
 			return false;
588 588
 		}
589 589
 
590 590
 		$new_total = (int) $this->purchase_count - (int) $count;
591 591
 
592
-		if ( $new_total < 0 ) {
592
+		if ($new_total < 0) {
593 593
 			$new_total = 0;
594 594
 		}
595 595
 
@@ -601,9 +601,9 @@  discard block
 block discarded – undo
601 601
 		 * @param int $count The number to decrease by.
602 602
 		 * @param int $donor_id Customer id.
603 603
 		 */
604
-		do_action( 'give_donor_pre_decrease_donation_count', $count, $this->id );
604
+		do_action('give_donor_pre_decrease_donation_count', $count, $this->id);
605 605
 
606
-		if ( $this->update( array( 'purchase_count' => $new_total ) ) ) {
606
+		if ($this->update(array('purchase_count' => $new_total))) {
607 607
 			$this->purchase_count = $new_total;
608 608
 		}
609 609
 
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
 		 * @param int $count The number decreased by.
617 617
 		 * @param int $donor_id Donor id.
618 618
 		 */
619
-		do_action( 'give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id );
619
+		do_action('give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id);
620 620
 
621 621
 		return $this->purchase_count;
622 622
 	}
@@ -631,9 +631,9 @@  discard block
 block discarded – undo
631 631
 	 *
632 632
 	 * @return mixed        If successful, the new value, otherwise false.
633 633
 	 */
634
-	public function increase_value( $value = 0.00 ) {
634
+	public function increase_value($value = 0.00) {
635 635
 
636
-		$new_value = floatval( $this->purchase_value ) + $value;
636
+		$new_value = floatval($this->purchase_value) + $value;
637 637
 
638 638
 		/**
639 639
 		 * Fires before increasing donor lifetime value.
@@ -643,9 +643,9 @@  discard block
 block discarded – undo
643 643
 		 * @param float $value The value to increase by.
644 644
 		 * @param int $donor_id Customer id.
645 645
 		 */
646
-		do_action( 'give_donor_pre_increase_value', $value, $this->id );
646
+		do_action('give_donor_pre_increase_value', $value, $this->id);
647 647
 
648
-		if ( $this->update( array( 'purchase_value' => $new_value ) ) ) {
648
+		if ($this->update(array('purchase_value' => $new_value))) {
649 649
 			$this->purchase_value = $new_value;
650 650
 		}
651 651
 
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
 		 * @param float $value The value increased by.
659 659
 		 * @param int $donor_id Donor id.
660 660
 		 */
661
-		do_action( 'give_donor_post_increase_value', $this->purchase_value, $value, $this->id );
661
+		do_action('give_donor_post_increase_value', $this->purchase_value, $value, $this->id);
662 662
 
663 663
 		return $this->purchase_value;
664 664
 	}
@@ -673,11 +673,11 @@  discard block
 block discarded – undo
673 673
 	 *
674 674
 	 * @return mixed        If successful, the new value, otherwise false.
675 675
 	 */
676
-	public function decrease_value( $value = 0.00 ) {
676
+	public function decrease_value($value = 0.00) {
677 677
 
678
-		$new_value = floatval( $this->purchase_value ) - $value;
678
+		$new_value = floatval($this->purchase_value) - $value;
679 679
 
680
-		if ( $new_value < 0 ) {
680
+		if ($new_value < 0) {
681 681
 			$new_value = 0.00;
682 682
 		}
683 683
 
@@ -689,9 +689,9 @@  discard block
 block discarded – undo
689 689
 		 * @param float $value The value to decrease by.
690 690
 		 * @param int $donor_id Donor id.
691 691
 		 */
692
-		do_action( 'give_donor_pre_decrease_value', $value, $this->id );
692
+		do_action('give_donor_pre_decrease_value', $value, $this->id);
693 693
 
694
-		if ( $this->update( array( 'purchase_value' => $new_value ) ) ) {
694
+		if ($this->update(array('purchase_value' => $new_value))) {
695 695
 			$this->purchase_value = $new_value;
696 696
 		}
697 697
 
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
 		 * @param float $value The value decreased by.
705 705
 		 * @param int $donor_id Donor id.
706 706
 		 */
707
-		do_action( 'give_donor_post_decrease_value', $this->purchase_value, $value, $this->id );
707
+		do_action('give_donor_post_decrease_value', $this->purchase_value, $value, $this->id);
708 708
 
709 709
 		return $this->purchase_value;
710 710
 	}
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
 	 *
724 724
 	 * @return mixed              If successful, the new donation stat value, otherwise false.
725 725
 	 */
726
-	public function update_donation_value( $curr_amount, $new_amount ) {
726
+	public function update_donation_value($curr_amount, $new_amount) {
727 727
 		/**
728 728
 		 * Payment total difference value can be:
729 729
 		 *  zero   (in case amount not change)
@@ -733,15 +733,15 @@  discard block
 block discarded – undo
733 733
 		$payment_total_diff = $new_amount - $curr_amount;
734 734
 
735 735
 		// We do not need to update donation stat if donation did not change.
736
-		if ( ! $payment_total_diff ) {
736
+		if ( ! $payment_total_diff) {
737 737
 			return false;
738 738
 		}
739 739
 
740
-		if ( $payment_total_diff > 0 ) {
741
-			$this->increase_value( $payment_total_diff );
740
+		if ($payment_total_diff > 0) {
741
+			$this->increase_value($payment_total_diff);
742 742
 		} else {
743 743
 			// Pass payment total difference as +ve value to decrease amount from user lifetime stat.
744
-			$this->decrease_value( - $payment_total_diff );
744
+			$this->decrease_value( -$payment_total_diff );
745 745
 		}
746 746
 
747 747
 		return $this->purchase_value;
@@ -758,15 +758,15 @@  discard block
 block discarded – undo
758 758
 	 *
759 759
 	 * @return array       The notes requested.
760 760
 	 */
761
-	public function get_notes( $length = 20, $paged = 1 ) {
761
+	public function get_notes($length = 20, $paged = 1) {
762 762
 
763
-		$length = is_numeric( $length ) ? $length : 20;
764
-		$offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0;
763
+		$length = is_numeric($length) ? $length : 20;
764
+		$offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0;
765 765
 
766 766
 		$all_notes   = $this->get_raw_notes();
767
-		$notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) );
767
+		$notes_array = array_reverse(array_filter(explode("\n\n", $all_notes)));
768 768
 
769
-		$desired_notes = array_slice( $notes_array, $offset, $length );
769
+		$desired_notes = array_slice($notes_array, $offset, $length);
770 770
 
771 771
 		return $desired_notes;
772 772
 
@@ -783,9 +783,9 @@  discard block
 block discarded – undo
783 783
 	public function get_notes_count() {
784 784
 
785 785
 		$all_notes   = $this->get_raw_notes();
786
-		$notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) );
786
+		$notes_array = array_reverse(array_filter(explode("\n\n", $all_notes)));
787 787
 
788
-		return count( $notes_array );
788
+		return count($notes_array);
789 789
 
790 790
 	}
791 791
 
@@ -798,7 +798,7 @@  discard block
 block discarded – undo
798 798
 	 *
799 799
 	 * @return string|float
800 800
 	 */
801
-	public function get_total_donation_amount( $args = array() ) {
801
+	public function get_total_donation_amount($args = array()) {
802 802
 
803 803
 		/**
804 804
 		 * Filter total donation amount.
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
 		 * @param integer      $donor_id       Donor ID.
810 810
 		 * @param array        $args           Pass additional data.
811 811
 		 */
812
-		return apply_filters( 'give_get_total_donation_amount', $this->purchase_value, $this->id, $args );
812
+		return apply_filters('give_get_total_donation_amount', $this->purchase_value, $this->id, $args);
813 813
 	}
814 814
 
815 815
 	/**
@@ -822,22 +822,22 @@  discard block
 block discarded – undo
822 822
 	 *
823 823
 	 * @return string|boolean The new note if added successfully, false otherwise.
824 824
 	 */
825
-	public function add_note( $note = '' ) {
825
+	public function add_note($note = '') {
826 826
 
827
-		$note = trim( $note );
828
-		if ( empty( $note ) ) {
827
+		$note = trim($note);
828
+		if (empty($note)) {
829 829
 			return false;
830 830
 		}
831 831
 
832 832
 		$notes = $this->get_raw_notes();
833 833
 
834
-		if ( empty( $notes ) ) {
834
+		if (empty($notes)) {
835 835
 			$notes = '';
836 836
 		}
837 837
 
838
-		$note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note;
839
-		$new_note    = apply_filters( 'give_customer_add_note_string', $note_string );
840
-		$notes       .= "\n\n" . $new_note;
838
+		$note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')).' - '.$note;
839
+		$new_note    = apply_filters('give_customer_add_note_string', $note_string);
840
+		$notes .= "\n\n".$new_note;
841 841
 
842 842
 		/**
843 843
 		 * Fires before donor note is added.
@@ -847,11 +847,11 @@  discard block
 block discarded – undo
847 847
 		 * @param string $new_note New note to add.
848 848
 		 * @param int $donor_id Donor id.
849 849
 		 */
850
-		do_action( 'give_donor_pre_add_note', $new_note, $this->id );
850
+		do_action('give_donor_pre_add_note', $new_note, $this->id);
851 851
 
852
-		$updated = $this->update( array( 'notes' => $notes ) );
852
+		$updated = $this->update(array('notes' => $notes));
853 853
 
854
-		if ( $updated ) {
854
+		if ($updated) {
855 855
 			$this->notes = $this->get_notes();
856 856
 		}
857 857
 
@@ -864,7 +864,7 @@  discard block
 block discarded – undo
864 864
 		 * @param string $new_note New note added.
865 865
 		 * @param int $donor_id Donor id.
866 866
 		 */
867
-		do_action( 'give_donor_post_add_note', $this->notes, $new_note, $this->id );
867
+		do_action('give_donor_post_add_note', $this->notes, $new_note, $this->id);
868 868
 
869 869
 		// Return the formatted note, so we can test, as well as update any displays
870 870
 		return $new_note;
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
 	 */
882 882
 	private function get_raw_notes() {
883 883
 
884
-		$all_notes = $this->db->get_column( 'notes', $this->id );
884
+		$all_notes = $this->db->get_column('notes', $this->id);
885 885
 
886 886
 		return $all_notes;
887 887
 
@@ -898,8 +898,8 @@  discard block
 block discarded – undo
898 898
 	 *
899 899
 	 * @return mixed            Will be an array if $single is false. Will be value of meta data field if $single is true.
900 900
 	 */
901
-	public function get_meta( $meta_key = '', $single = true ) {
902
-		return Give()->donor_meta->get_meta( $this->id, $meta_key, $single );
901
+	public function get_meta($meta_key = '', $single = true) {
902
+		return Give()->donor_meta->get_meta($this->id, $meta_key, $single);
903 903
 	}
904 904
 
905 905
 	/**
@@ -914,8 +914,8 @@  discard block
 block discarded – undo
914 914
 	 *
915 915
 	 * @return bool               False for failure. True for success.
916 916
 	 */
917
-	public function add_meta( $meta_key = '', $meta_value, $unique = false ) {
918
-		return Give()->donor_meta->add_meta( $this->id, $meta_key, $meta_value, $unique );
917
+	public function add_meta($meta_key = '', $meta_value, $unique = false) {
918
+		return Give()->donor_meta->add_meta($this->id, $meta_key, $meta_value, $unique);
919 919
 	}
920 920
 
921 921
 	/**
@@ -930,8 +930,8 @@  discard block
 block discarded – undo
930 930
 	 *
931 931
 	 * @return bool               False on failure, true if success.
932 932
 	 */
933
-	public function update_meta( $meta_key = '', $meta_value, $prev_value = '' ) {
934
-		return Give()->donor_meta->update_meta( $this->id, $meta_key, $meta_value, $prev_value );
933
+	public function update_meta($meta_key = '', $meta_value, $prev_value = '') {
934
+		return Give()->donor_meta->update_meta($this->id, $meta_key, $meta_value, $prev_value);
935 935
 	}
936 936
 
937 937
 	/**
@@ -945,8 +945,8 @@  discard block
 block discarded – undo
945 945
 	 *
946 946
 	 * @return bool               False for failure. True for success.
947 947
 	 */
948
-	public function delete_meta( $meta_key = '', $meta_value = '' ) {
949
-		return Give()->donor_meta->delete_meta( $this->id, $meta_key, $meta_value );
948
+	public function delete_meta($meta_key = '', $meta_value = '') {
949
+		return Give()->donor_meta->delete_meta($this->id, $meta_key, $meta_value);
950 950
 	}
951 951
 
952 952
 	/**
@@ -959,51 +959,51 @@  discard block
 block discarded – undo
959 959
 	 *
960 960
 	 * @return array       The sanitized data, based off column defaults.
961 961
 	 */
962
-	private function sanitize_columns( $data ) {
962
+	private function sanitize_columns($data) {
963 963
 
964 964
 		$columns        = $this->db->get_columns();
965 965
 		$default_values = $this->db->get_column_defaults();
966 966
 
967
-		foreach ( $columns as $key => $type ) {
967
+		foreach ($columns as $key => $type) {
968 968
 
969 969
 			// Only sanitize data that we were provided
970
-			if ( ! array_key_exists( $key, $data ) ) {
970
+			if ( ! array_key_exists($key, $data)) {
971 971
 				continue;
972 972
 			}
973 973
 
974
-			switch ( $type ) {
974
+			switch ($type) {
975 975
 
976 976
 				case '%s':
977
-					if ( 'email' == $key ) {
978
-						$data[ $key ] = sanitize_email( $data[ $key ] );
979
-					} elseif ( 'notes' == $key ) {
980
-						$data[ $key ] = strip_tags( $data[ $key ] );
977
+					if ('email' == $key) {
978
+						$data[$key] = sanitize_email($data[$key]);
979
+					} elseif ('notes' == $key) {
980
+						$data[$key] = strip_tags($data[$key]);
981 981
 					} else {
982
-						$data[ $key ] = sanitize_text_field( $data[ $key ] );
982
+						$data[$key] = sanitize_text_field($data[$key]);
983 983
 					}
984 984
 					break;
985 985
 
986 986
 				case '%d':
987
-					if ( ! is_numeric( $data[ $key ] ) || (int) $data[ $key ] !== absint( $data[ $key ] ) ) {
988
-						$data[ $key ] = $default_values[ $key ];
987
+					if ( ! is_numeric($data[$key]) || (int) $data[$key] !== absint($data[$key])) {
988
+						$data[$key] = $default_values[$key];
989 989
 					} else {
990
-						$data[ $key ] = absint( $data[ $key ] );
990
+						$data[$key] = absint($data[$key]);
991 991
 					}
992 992
 					break;
993 993
 
994 994
 				case '%f':
995 995
 					// Convert what was given to a float
996
-					$value = floatval( $data[ $key ] );
996
+					$value = floatval($data[$key]);
997 997
 
998
-					if ( ! is_float( $value ) ) {
999
-						$data[ $key ] = $default_values[ $key ];
998
+					if ( ! is_float($value)) {
999
+						$data[$key] = $default_values[$key];
1000 1000
 					} else {
1001
-						$data[ $key ] = $value;
1001
+						$data[$key] = $value;
1002 1002
 					}
1003 1003
 					break;
1004 1004
 
1005 1005
 				default:
1006
-					$data[ $key ] = sanitize_text_field( $data[ $key ] );
1006
+					$data[$key] = sanitize_text_field($data[$key]);
1007 1007
 					break;
1008 1008
 
1009 1009
 			}
@@ -1023,33 +1023,33 @@  discard block
 block discarded – undo
1023 1023
 	 *
1024 1024
 	 * @return bool            If the email was added successfully
1025 1025
 	 */
1026
-	public function add_email( $email = '', $primary = false ) {
1027
-		if ( ! is_email( $email ) ) {
1026
+	public function add_email($email = '', $primary = false) {
1027
+		if ( ! is_email($email)) {
1028 1028
 			return false;
1029 1029
 		}
1030
-		$existing = new Give_Donor( $email );
1030
+		$existing = new Give_Donor($email);
1031 1031
 
1032
-		if ( $existing->id > 0 ) {
1032
+		if ($existing->id > 0) {
1033 1033
 			// Email address already belongs to another donor
1034 1034
 			return false;
1035 1035
 		}
1036 1036
 
1037
-		if ( email_exists( $email ) ) {
1038
-			$user = get_user_by( 'email', $email );
1039
-			if ( $user->ID != $this->user_id ) {
1037
+		if (email_exists($email)) {
1038
+			$user = get_user_by('email', $email);
1039
+			if ($user->ID != $this->user_id) {
1040 1040
 				return false;
1041 1041
 			}
1042 1042
 		}
1043 1043
 
1044
-		do_action( 'give_donor_pre_add_email', $email, $this->id, $this );
1044
+		do_action('give_donor_pre_add_email', $email, $this->id, $this);
1045 1045
 
1046 1046
 		// Add is used to ensure duplicate emails are not added
1047
-		$ret = (bool) $this->add_meta( 'additional_email', $email );
1047
+		$ret = (bool) $this->add_meta('additional_email', $email);
1048 1048
 
1049
-		do_action( 'give_donor_post_add_email', $email, $this->id, $this );
1049
+		do_action('give_donor_post_add_email', $email, $this->id, $this);
1050 1050
 
1051
-		if ( $ret && true === $primary ) {
1052
-			$this->set_primary_email( $email );
1051
+		if ($ret && true === $primary) {
1052
+			$this->set_primary_email($email);
1053 1053
 		}
1054 1054
 
1055 1055
 		return $ret;
@@ -1065,16 +1065,16 @@  discard block
 block discarded – undo
1065 1065
 	 *
1066 1066
 	 * @return bool          If the email was removed successfully.
1067 1067
 	 */
1068
-	public function remove_email( $email = '' ) {
1069
-		if ( ! is_email( $email ) ) {
1068
+	public function remove_email($email = '') {
1069
+		if ( ! is_email($email)) {
1070 1070
 			return false;
1071 1071
 		}
1072 1072
 
1073
-		do_action( 'give_donor_pre_remove_email', $email, $this->id, $this );
1073
+		do_action('give_donor_pre_remove_email', $email, $this->id, $this);
1074 1074
 
1075
-		$ret = (bool) $this->delete_meta( 'additional_email', $email );
1075
+		$ret = (bool) $this->delete_meta('additional_email', $email);
1076 1076
 
1077
-		do_action( 'give_donor_post_remove_email', $email, $this->id, $this );
1077
+		do_action('give_donor_post_remove_email', $email, $this->id, $this);
1078 1078
 
1079 1079
 		return $ret;
1080 1080
 	}
@@ -1091,16 +1091,16 @@  discard block
 block discarded – undo
1091 1091
 	 *
1092 1092
 	 * @return bool                      If the email was set as primary successfully.
1093 1093
 	 */
1094
-	public function set_primary_email( $new_primary_email = '' ) {
1095
-		if ( ! is_email( $new_primary_email ) ) {
1094
+	public function set_primary_email($new_primary_email = '') {
1095
+		if ( ! is_email($new_primary_email)) {
1096 1096
 			return false;
1097 1097
 		}
1098 1098
 
1099
-		do_action( 'give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this );
1099
+		do_action('give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this);
1100 1100
 
1101
-		$existing = new Give_Donor( $new_primary_email );
1101
+		$existing = new Give_Donor($new_primary_email);
1102 1102
 
1103
-		if ( $existing->id > 0 && (int) $existing->id !== (int) $this->id ) {
1103
+		if ($existing->id > 0 && (int) $existing->id !== (int) $this->id) {
1104 1104
 			// This email belongs to another donor.
1105 1105
 			return false;
1106 1106
 		}
@@ -1108,21 +1108,21 @@  discard block
 block discarded – undo
1108 1108
 		$old_email = $this->email;
1109 1109
 
1110 1110
 		// Update donor record with new email.
1111
-		$update = $this->update( array( 'email' => $new_primary_email ) );
1111
+		$update = $this->update(array('email' => $new_primary_email));
1112 1112
 
1113 1113
 		// Remove new primary from list of additional emails.
1114
-		$remove = $this->remove_email( $new_primary_email );
1114
+		$remove = $this->remove_email($new_primary_email);
1115 1115
 
1116 1116
 		// Add old email to additional emails list.
1117
-		$add = $this->add_email( $old_email );
1117
+		$add = $this->add_email($old_email);
1118 1118
 
1119 1119
 		$ret = $update && $remove && $add;
1120 1120
 
1121
-		if ( $ret ) {
1121
+		if ($ret) {
1122 1122
 			$this->email = $new_primary_email;
1123 1123
 		}
1124 1124
 
1125
-		do_action( 'give_donor_post_set_primary_email', $new_primary_email, $this->id, $this );
1125
+		do_action('give_donor_post_set_primary_email', $new_primary_email, $this->id, $this);
1126 1126
 
1127 1127
 		return $ret;
1128 1128
 	}
Please login to merge, or discard this patch.
includes/admin/donors/donor-functions.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @return array        The altered list of views.
25 25
  */
26
-function give_register_default_donor_views( $views ) {
26
+function give_register_default_donor_views($views) {
27 27
 
28 28
 	$default_views = array(
29 29
 		'overview' => 'give_donor_view',
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
 		'notes'    => 'give_donor_notes_view',
32 32
 	);
33 33
 
34
-	return array_merge( $views, $default_views );
34
+	return array_merge($views, $default_views);
35 35
 
36 36
 }
37 37
 
38
-add_filter( 'give_donor_views', 'give_register_default_donor_views', 1, 1 );
38
+add_filter('give_donor_views', 'give_register_default_donor_views', 1, 1);
39 39
 
40 40
 /**
41 41
  * Register a tab for the single donor view.
@@ -46,23 +46,23 @@  discard block
 block discarded – undo
46 46
  *
47 47
  * @return array       The altered list of tabs
48 48
  */
49
-function give_register_default_donor_tabs( $tabs ) {
49
+function give_register_default_donor_tabs($tabs) {
50 50
 
51 51
 	$default_tabs = array(
52 52
 		'overview' => array(
53 53
 			'dashicon' => 'dashicons-admin-users',
54
-			'title' => __( 'Donor Profile', 'give' ),
54
+			'title' => __('Donor Profile', 'give'),
55 55
 		),
56 56
 		'notes'    => array(
57 57
 			'dashicon' => 'dashicons-admin-comments',
58
-			'title' => __( 'Donor Notes', 'give' ),
58
+			'title' => __('Donor Notes', 'give'),
59 59
 		),
60 60
 	);
61 61
 
62
-	return array_merge( $tabs, $default_tabs );
62
+	return array_merge($tabs, $default_tabs);
63 63
 }
64 64
 
65
-add_filter( 'give_donor_tabs', 'give_register_default_donor_tabs', 1, 1 );
65
+add_filter('give_donor_tabs', 'give_register_default_donor_tabs', 1, 1);
66 66
 
67 67
 /**
68 68
  * Register the Delete icon as late as possible so it's at the bottom.
@@ -73,17 +73,17 @@  discard block
 block discarded – undo
73 73
  *
74 74
  * @return array       The altered list of tabs, with 'delete' at the bottom.
75 75
  */
76
-function give_register_delete_donor_tab( $tabs ) {
76
+function give_register_delete_donor_tab($tabs) {
77 77
 
78 78
 	$tabs['delete'] = array(
79 79
 		'dashicon' => 'dashicons-trash',
80
-		'title'    => __( 'Delete Donor', 'give' ),
80
+		'title'    => __('Delete Donor', 'give'),
81 81
 	);
82 82
 
83 83
 	return $tabs;
84 84
 }
85 85
 
86
-add_filter( 'give_donor_tabs', 'give_register_delete_donor_tab', PHP_INT_MAX, 1 );
86
+add_filter('give_donor_tabs', 'give_register_delete_donor_tab', PHP_INT_MAX, 1);
87 87
 
88 88
 /**
89 89
  * Connect and Reconnect Donor with User profile.
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
  *
97 97
  * @return array
98 98
  */
99
-function give_connect_user_donor_profile( $donor, $donor_data, $address ) {
99
+function give_connect_user_donor_profile($donor, $donor_data, $address) {
100 100
 
101 101
 	$donor_id         = $donor->id;
102 102
 	$previous_user_id = $donor->user_id;
@@ -110,40 +110,40 @@  discard block
 block discarded – undo
110 110
 	 *
111 111
 	 * @since 1.0
112 112
 	 */
113
-	do_action( 'give_pre_edit_donor', $donor_id, $donor_data, $address );
113
+	do_action('give_pre_edit_donor', $donor_id, $donor_data, $address);
114 114
 
115 115
 	$output = array();
116 116
 
117
-	if ( $donor->update( $donor_data ) ) {
117
+	if ($donor->update($donor_data)) {
118 118
 
119
-		if ( ! empty( $donor->user_id ) && $donor->user_id > 0 ) {
120
-			update_user_meta( $donor->user_id, '_give_user_address', $address );
119
+		if ( ! empty($donor->user_id) && $donor->user_id > 0) {
120
+			update_user_meta($donor->user_id, '_give_user_address', $address);
121 121
 		}
122 122
 
123 123
 		// Update some donation meta if we need to.
124
-		$payments_array = explode( ',', $donor->payment_ids );
124
+		$payments_array = explode(',', $donor->payment_ids);
125 125
 
126
-		if ( $donor->user_id !== $previous_user_id ) {
127
-			foreach ( $payments_array as $payment_id ) {
128
-				give_update_payment_meta( $payment_id, '_give_payment_user_id', $donor->user_id );
126
+		if ($donor->user_id !== $previous_user_id) {
127
+			foreach ($payments_array as $payment_id) {
128
+				give_update_payment_meta($payment_id, '_give_payment_user_id', $donor->user_id);
129 129
 			}
130 130
 		}
131 131
 
132 132
 		// Fetch disconnected user id, if exists.
133
-		$disconnected_user_id = $donor->get_meta( '_give_disconnected_user_id', true );
133
+		$disconnected_user_id = $donor->get_meta('_give_disconnected_user_id', true);
134 134
 
135 135
 		// Flag User and Donor Disconnection.
136
-		delete_user_meta( $disconnected_user_id, '_give_is_donor_disconnected' );
136
+		delete_user_meta($disconnected_user_id, '_give_is_donor_disconnected');
137 137
 
138 138
 		// Check whether the disconnected user id and the reconnected user id are same or not.
139 139
 		// If both are same then delete user id store in donor meta.
140
-		if( $donor_data['user_id'] === $disconnected_user_id ) {
141
-			delete_user_meta( $disconnected_user_id, '_give_disconnected_donor_id' );
142
-			$donor->delete_meta( '_give_disconnected_user_id' );
140
+		if ($donor_data['user_id'] === $disconnected_user_id) {
141
+			delete_user_meta($disconnected_user_id, '_give_disconnected_donor_id');
142
+			$donor->delete_meta('_give_disconnected_user_id');
143 143
 		}
144 144
 
145 145
 		$output['success']       = true;
146
-		$donor_data              = array_merge( $donor_data, $address );
146
+		$donor_data              = array_merge($donor_data, $address);
147 147
 		$output['customer_info'] = $donor_data;
148 148
 
149 149
 	} else {
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 	 *
161 161
 	 * @since 1.0
162 162
 	 */
163
-	do_action( 'give_post_edit_donor', $donor_id, $donor_data );
163
+	do_action('give_post_edit_donor', $donor_id, $donor_data);
164 164
 
165 165
 
166 166
 	return $output;
Please login to merge, or discard this patch.
includes/admin/upgrades/views/upgrades.php 1 patch
Spacing   +14 added lines, -14 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
 
@@ -18,33 +18,33 @@  discard block
 block discarded – undo
18 18
 ?>
19 19
 <div class="wrap" id="poststuff">
20 20
 	<div id="give-updates">
21
-		<h1 id="give-updates-h1"><?php esc_html_e( 'Give - Updates', 'give' ); ?></h1>
21
+		<h1 id="give-updates-h1"><?php esc_html_e('Give - Updates', 'give'); ?></h1>
22 22
 		<hr class="wp-header-end">
23 23
 
24 24
 		<div class="give-update-panel-content">
25
-			<p><?php printf( __( 'Give regularly receives new features, bug fixes, and enhancements. It is important to always stay up-to-date with latest version of Give core and its add-ons.  Please create a backup of your site before updating. To update add-ons be sure your <a href="%1$s">license keys</a> are activated.', 'give' ), 'https://givewp.com/my-account/' ); ?></p>
25
+			<p><?php printf(__('Give regularly receives new features, bug fixes, and enhancements. It is important to always stay up-to-date with latest version of Give core and its add-ons.  Please create a backup of your site before updating. To update add-ons be sure your <a href="%1$s">license keys</a> are activated.', 'give'), 'https://givewp.com/my-account/'); ?></p>
26 26
 		</div>
27 27
 
28 28
 		<?php $update_counter = 1; ?>
29 29
 
30 30
 		<?php $db_updates = $give_updates->get_db_update_count(); ?>
31
-		<?php if ( ! empty( $db_updates ) ) : ?>
32
-			<?php $db_update_url = add_query_arg( array(
31
+		<?php if ( ! empty($db_updates)) : ?>
32
+			<?php $db_update_url = add_query_arg(array(
33 33
 				'type' => 'database',
34
-			) ); ?>
34
+			)); ?>
35 35
 			<div id="give-db-updates">
36 36
 				<div class="postbox-container">
37 37
 					<div class="postbox">
38
-						<h2 class="hndle"><?php _e( 'Database Updates', 'give' ); ?></h2>
38
+						<h2 class="hndle"><?php _e('Database Updates', 'give'); ?></h2>
39 39
 						<div class="inside">
40 40
 							<div class="panel-content">
41
-								<p class="give-update-button"><?php echo sprintf( __( 'Give needs to update the database. <a href="%s">Update now</a>', 'give' ), $db_update_url ); ?></p>
41
+								<p class="give-update-button"><?php echo sprintf(__('Give needs to update the database. <a href="%s">Update now</a>', 'give'), $db_update_url); ?></p>
42 42
 							</div>
43 43
 							<div class="progress-container give-hidden">
44 44
 								<p class="update-message"
45 45
 								   data-update-count="<?php echo $db_updates; ?>"
46 46
 								   data-resume-update="<?php echo $give_updates->resume_updates(); ?>">
47
-									<strong><?php echo sprintf( __( 'Update 1 of %s', 'give' ), $db_updates ); ?></strong>
47
+									<strong><?php echo sprintf(__('Update 1 of %s', 'give'), $db_updates); ?></strong>
48 48
 								</p>
49 49
 								<div class="progress-content"></div>
50 50
 							</div>
@@ -61,17 +61,17 @@  discard block
 block discarded – undo
61 61
 		<?php endif; ?>
62 62
 
63 63
 		<?php $plugin_updates = $give_updates->get_plugin_update_count(); ?>
64
-		<?php if ( ! empty( $plugin_updates ) ) : ?>
65
-			<?php $plugin_update_url = add_query_arg( array(
64
+		<?php if ( ! empty($plugin_updates)) : ?>
65
+			<?php $plugin_update_url = add_query_arg(array(
66 66
 				's' => 'Give',
67
-			), admin_url( '/plugins.php' ) ); ?>
67
+			), admin_url('/plugins.php')); ?>
68 68
 			<div id="give-plugin-updates">
69 69
 				<div class="postbox-container">
70 70
 					<div class="postbox">
71
-						<h2 class="hndle"><?php _e( 'Add-on Updates', 'give' ); ?></h2>
71
+						<h2 class="hndle"><?php _e('Add-on Updates', 'give'); ?></h2>
72 72
 						<div class="inside">
73 73
 							<div class="panel-content">
74
-								<p><?php echo sprintf( __( 'There %1$s %2$s Give %3$s that %4$s to be updated. <a href="%5$s">Update now</a>', 'give' ), _n( 'is', 'are', $plugin_updates, 'give' ), $plugin_updates, _n( 'add-on', 'add-ons', $plugin_updates, 'give' ), _n( 'needs', 'need', $plugin_updates, 'give' ), $plugin_update_url  ); ?></p>
74
+								<p><?php echo sprintf(__('There %1$s %2$s Give %3$s that %4$s to be updated. <a href="%5$s">Update now</a>', 'give'), _n('is', 'are', $plugin_updates, 'give'), $plugin_updates, _n('add-on', 'add-ons', $plugin_updates, 'give'), _n('needs', 'need', $plugin_updates, 'give'), $plugin_update_url); ?></p>
75 75
 								<?php include_once 'plugins-update-section.php'; ?>
76 76
 							</div>
77 77
 						</div>
Please login to merge, or discard this patch.
includes/admin/payments/payments-history.php 1 patch
Spacing   +22 added lines, -22 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
 
@@ -25,12 +25,12 @@  discard block
 block discarded – undo
25 25
 */
26 26
 function give_payment_history_page() {
27 27
 
28
-	$give_payment = get_post_type_object( 'give_payment' );
28
+	$give_payment = get_post_type_object('give_payment');
29 29
 
30
-	if ( isset( $_GET['view'] ) && 'view-payment-details' == $_GET['view'] ) {
31
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/view-payment-details.php';
30
+	if (isset($_GET['view']) && 'view-payment-details' == $_GET['view']) {
31
+		require_once GIVE_PLUGIN_DIR.'includes/admin/payments/view-payment-details.php';
32 32
 	} else {
33
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/payments/class-payments-table.php';
33
+		require_once GIVE_PLUGIN_DIR.'includes/admin/payments/class-payments-table.php';
34 34
 		$payments_table = new Give_Payment_History_Table();
35 35
 		$payments_table->prepare_items();
36 36
 	?>
@@ -44,18 +44,18 @@  discard block
 block discarded – undo
44 44
 		 *
45 45
 		 * @since 1.7
46 46
 		 */
47
-		do_action( 'give_payments_page_top' );
47
+		do_action('give_payments_page_top');
48 48
 		?>
49 49
 		<hr class="wp-header-end">
50 50
 
51
-		<form id="give-payments-advanced-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); ?>">
51
+		<form id="give-payments-advanced-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history'); ?>">
52 52
 			<input type="hidden" name="post_type" value="give_forms" />
53 53
 			<input type="hidden" name="page" value="give-payment-history" />
54 54
 			<?php $payments_table->views() ?>
55 55
 			<?php $payments_table->advanced_filters(); ?>
56 56
 		</form>
57 57
 
58
-		<form id="give-payments-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); ?>">
58
+		<form id="give-payments-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history'); ?>">
59 59
 			<input type="hidden" name="post_type" value="give_forms" />
60 60
 			<input type="hidden" name="page" value="give-payment-history" />
61 61
 			<?php $payments_table->display() ?>
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 		 *
68 68
 		 * @since 1.7
69 69
 		 */
70
-		do_action( 'give_payments_page_bottom' );
70
+		do_action('give_payments_page_bottom');
71 71
 		?>
72 72
 
73 73
 	</div>
@@ -84,29 +84,29 @@  discard block
 block discarded – undo
84 84
  * @param $title
85 85
  * @return string
86 86
  */
87
-function give_view_order_details_title( $admin_title, $title ) {
87
+function give_view_order_details_title($admin_title, $title) {
88 88
 
89
-	if ( 'give_forms_page_give-payment-history' != get_current_screen()->base ) {
89
+	if ('give_forms_page_give-payment-history' != get_current_screen()->base) {
90 90
 		return $admin_title;
91 91
 	}
92 92
 
93
-	if( ! isset( $_GET['give-action'] ) ) {
93
+	if ( ! isset($_GET['give-action'])) {
94 94
 		return $admin_title;
95 95
 	}
96 96
 
97
-	switch( $_GET['give-action'] ) :
97
+	switch ($_GET['give-action']) :
98 98
 
99 99
 		case 'view-payment-details' :
100 100
 			$title = sprintf(
101 101
 				/* translators: %s: admin title */
102
-				esc_html__( 'View Donation Details - %s', 'give' ),
102
+				esc_html__('View Donation Details - %s', 'give'),
103 103
 				$admin_title
104 104
 			);
105 105
 			break;
106 106
 		case 'edit-payment' :
107 107
 			$title = sprintf(
108 108
 				/* translators: %s: admin title */
109
-				esc_html__( 'Edit Donation - %s', 'give' ),
109
+				esc_html__('Edit Donation - %s', 'give'),
110 110
 				$admin_title
111 111
 			);
112 112
 			break;
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 
118 118
 	return $title;
119 119
 }
120
-add_filter( 'admin_title', 'give_view_order_details_title', 10, 2 );
120
+add_filter('admin_title', 'give_view_order_details_title', 10, 2);
121 121
 
122 122
 /**
123 123
  * Intercept default Edit post links for Give payments and rewrite them to the View Order Details screen.
@@ -129,20 +129,20 @@  discard block
 block discarded – undo
129 129
  * @param $context
130 130
  * @return string
131 131
  */
132
-function give_override_edit_post_for_payment_link( $url, $post_id = 0, $context ) {
132
+function give_override_edit_post_for_payment_link($url, $post_id = 0, $context) {
133 133
 
134
-	$post = get_post( $post_id );
134
+	$post = get_post($post_id);
135 135
 
136
-	if( ! $post ) {
136
+	if ( ! $post) {
137 137
 		return $url;
138 138
 	}
139 139
 
140
-	if( 'give_payment' != $post->post_type ) {
140
+	if ('give_payment' != $post->post_type) {
141 141
 		return $url;
142 142
 	}
143 143
 
144
-	$url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $post_id );
144
+	$url = admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id='.$post_id);
145 145
 
146 146
 	return $url;
147 147
 }
148
-add_filter( 'get_edit_post_link', 'give_override_edit_post_for_payment_link', 10, 3 );
148
+add_filter('get_edit_post_link', 'give_override_edit_post_for_payment_link', 10, 3);
Please login to merge, or discard this patch.