Test Failed
Pull Request — master (#1942)
by Devin
05:03
created
includes/install.php 1 patch
Spacing   +62 added lines, -62 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
 
@@ -26,15 +26,15 @@  discard block
 block discarded – undo
26 26
  * @global     $wpdb
27 27
  * @return void
28 28
  */
29
-function give_install( $network_wide = false ) {
29
+function give_install($network_wide = false) {
30 30
 
31 31
 	global $wpdb;
32 32
 
33
-	if ( is_multisite() && $network_wide ) {
33
+	if (is_multisite() && $network_wide) {
34 34
 
35
-		foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs LIMIT 100" ) as $blog_id ) {
35
+		foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs LIMIT 100") as $blog_id) {
36 36
 
37
-			switch_to_blog( $blog_id );
37
+			switch_to_blog($blog_id);
38 38
 			give_run_install();
39 39
 			restore_current_blog();
40 40
 
@@ -62,34 +62,34 @@  discard block
 block discarded – undo
62 62
 	give_setup_post_types();
63 63
 
64 64
 	// Clear the permalinks.
65
-	flush_rewrite_rules( false );
65
+	flush_rewrite_rules(false);
66 66
 
67 67
 	// Add Upgraded From Option.
68
-	$current_version = get_option( 'give_version' );
69
-	if ( $current_version ) {
70
-		update_option( 'give_version_upgraded_from', $current_version );
68
+	$current_version = get_option('give_version');
69
+	if ($current_version) {
70
+		update_option('give_version_upgraded_from', $current_version);
71 71
 	}
72 72
 
73 73
 	// Setup some default options.
74 74
 	$options = array();
75 75
 
76 76
 	//Fresh Install? Setup Test Mode, Base Country (US), Test Gateway, Currency.
77
-	if ( empty( $current_version ) ) {
78
-		$options = array_merge( $options, give_get_default_settings() );
77
+	if (empty($current_version)) {
78
+		$options = array_merge($options, give_get_default_settings());
79 79
 	}
80 80
 
81 81
 	// Populate the default values.
82
-	update_option( 'give_settings', array_merge( $give_options, $options ) );
82
+	update_option('give_settings', array_merge($give_options, $options));
83 83
 
84 84
 	/**
85 85
 	 * Run plugin upgrades.
86 86
 	 *
87 87
 	 * @since 1.8
88 88
 	 */
89
-	do_action( 'give_upgrades' );
89
+	do_action('give_upgrades');
90 90
 
91
-	if ( GIVE_VERSION !== get_option( 'give_version' ) ) {
92
-		update_option( 'give_version', GIVE_VERSION );
91
+	if (GIVE_VERSION !== get_option('give_version')) {
92
+		update_option('give_version', GIVE_VERSION);
93 93
 	}
94 94
 
95 95
 	// Create Give roles.
@@ -98,18 +98,18 @@  discard block
 block discarded – undo
98 98
 	$roles->add_caps();
99 99
 
100 100
 	$api = new Give_API();
101
-	update_option( 'give_default_api_version', 'v' . $api->get_version() );
101
+	update_option('give_default_api_version', 'v'.$api->get_version());
102 102
 
103 103
 	// Check for PHP Session support, and enable if available.
104 104
 	$give_sessions = new Give_Session();
105 105
 	$give_sessions->use_php_sessions();
106 106
 
107 107
 	// Add a temporary option to note that Give pages have been created.
108
-	Give_Cache::set( '_give_installed', $options, 30, true );
108
+	Give_Cache::set('_give_installed', $options, 30, true);
109 109
 
110
-	if ( ! $current_version ) {
110
+	if ( ! $current_version) {
111 111
 
112
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php';
112
+		require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php';
113 113
 
114 114
 		// When new upgrade routines are added, mark them as complete on fresh install.
115 115
 		$upgrade_routines = array(
@@ -123,18 +123,18 @@  discard block
 block discarded – undo
123 123
 			'v1812_update_donor_purchase_values'
124 124
 		);
125 125
 
126
-		foreach ( $upgrade_routines as $upgrade ) {
127
-			give_set_upgrade_complete( $upgrade );
126
+		foreach ($upgrade_routines as $upgrade) {
127
+			give_set_upgrade_complete($upgrade);
128 128
 		}
129 129
 	}
130 130
 
131 131
 	// Bail if activating from network, or bulk.
132
-	if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
132
+	if (is_network_admin() || isset($_GET['activate-multi'])) {
133 133
 		return;
134 134
 	}
135 135
 
136 136
 	// Add the transient to redirect.
137
-	Give_Cache::set( '_give_activation_redirect', true, 30, true );
137
+	Give_Cache::set('_give_activation_redirect', true, 30, true);
138 138
 
139 139
 	// Set 'Donation Form' meta box enabled by default.
140 140
 	give_nav_donation_metabox_enabled();
@@ -154,11 +154,11 @@  discard block
 block discarded – undo
154 154
  * @param  int $site_id The Site ID.
155 155
  * @param  array $meta Blog Meta.
156 156
  */
157
-function give_on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
157
+function give_on_create_blog($blog_id, $user_id, $domain, $path, $site_id, $meta) {
158 158
 
159
-	if ( is_plugin_active_for_network( GIVE_PLUGIN_BASENAME ) ) {
159
+	if (is_plugin_active_for_network(GIVE_PLUGIN_BASENAME)) {
160 160
 
161
-		switch_to_blog( $blog_id );
161
+		switch_to_blog($blog_id);
162 162
 		give_install();
163 163
 		restore_current_blog();
164 164
 
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 
167 167
 }
168 168
 
169
-add_action( 'wpmu_new_blog', 'give_on_create_blog', 10, 6 );
169
+add_action('wpmu_new_blog', 'give_on_create_blog', 10, 6);
170 170
 
171 171
 
172 172
 /**
@@ -179,13 +179,13 @@  discard block
 block discarded – undo
179 179
  *
180 180
  * @return array          The tables to drop.
181 181
  */
182
-function give_wpmu_drop_tables( $tables, $blog_id ) {
182
+function give_wpmu_drop_tables($tables, $blog_id) {
183 183
 
184
-	switch_to_blog( $blog_id );
184
+	switch_to_blog($blog_id);
185 185
 	$donors_db     = new Give_DB_Donors();
186 186
 	$donor_meta_db = new Give_DB_Donor_Meta();
187 187
 
188
-	if ( $donors_db->installed() ) {
188
+	if ($donors_db->installed()) {
189 189
 		$tables[] = $donors_db->table_name;
190 190
 		$tables[] = $donor_meta_db->table_name;
191 191
 	}
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 
196 196
 }
197 197
 
198
-add_filter( 'wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2 );
198
+add_filter('wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2);
199 199
 
200 200
 /**
201 201
  * Post-installation
@@ -207,16 +207,16 @@  discard block
 block discarded – undo
207 207
  */
208 208
 function give_after_install() {
209 209
 
210
-	if ( ! is_admin() ) {
210
+	if ( ! is_admin()) {
211 211
 		return;
212 212
 	}
213 213
 
214
-	$give_options     = Give_Cache::get( '_give_installed', true );
215
-	$give_table_check = get_option( '_give_table_check', false );
214
+	$give_options     = Give_Cache::get('_give_installed', true);
215
+	$give_table_check = get_option('_give_table_check', false);
216 216
 
217
-	if ( false === $give_table_check || current_time( 'timestamp' ) > $give_table_check ) {
217
+	if (false === $give_table_check || current_time('timestamp') > $give_table_check) {
218 218
 
219
-		if ( ! @Give()->donor_meta->installed() ) {
219
+		if ( ! @Give()->donor_meta->installed()) {
220 220
 
221 221
 			// Create the donor meta database.
222 222
 			// (this ensures it creates it on multisite instances where it is network activated).
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 
225 225
 		}
226 226
 
227
-		if ( ! @Give()->donors->installed() ) {
227
+		if ( ! @Give()->donors->installed()) {
228 228
 			// Create the donor database.
229 229
 			// (this ensures it creates it on multisite instances where it is network activated).
230 230
 			@Give()->donors->create_table();
@@ -236,22 +236,22 @@  discard block
 block discarded – undo
236 236
 			 *
237 237
 			 * @param array $give_options Give plugin options.
238 238
 			 */
239
-			do_action( 'give_after_install', $give_options );
239
+			do_action('give_after_install', $give_options);
240 240
 		}
241 241
 
242
-		update_option( '_give_table_check', ( current_time( 'timestamp' ) + WEEK_IN_SECONDS ) );
242
+		update_option('_give_table_check', (current_time('timestamp') + WEEK_IN_SECONDS));
243 243
 
244 244
 	}
245 245
 
246 246
 	// Delete the transient
247
-	if ( false !== $give_options ) {
248
-		Give_Cache::delete( Give_Cache::get_key( '_give_installed' ) );
247
+	if (false !== $give_options) {
248
+		Give_Cache::delete(Give_Cache::get_key('_give_installed'));
249 249
 	}
250 250
 
251 251
 
252 252
 }
253 253
 
254
-add_action( 'admin_init', 'give_after_install' );
254
+add_action('admin_init', 'give_after_install');
255 255
 
256 256
 
257 257
 /**
@@ -266,11 +266,11 @@  discard block
 block discarded – undo
266 266
 
267 267
 	global $wp_roles;
268 268
 
269
-	if ( ! is_object( $wp_roles ) ) {
269
+	if ( ! is_object($wp_roles)) {
270 270
 		return;
271 271
 	}
272 272
 
273
-	if ( ! array_key_exists( 'give_manager', $wp_roles->roles ) ) {
273
+	if ( ! array_key_exists('give_manager', $wp_roles->roles)) {
274 274
 
275 275
 		// Create Give plugin roles
276 276
 		$roles = new Give_Roles();
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 
282 282
 }
283 283
 
284
-add_action( 'admin_init', 'give_install_roles_on_network' );
284
+add_action('admin_init', 'give_install_roles_on_network');
285 285
 
286 286
 /**
287 287
  * Default core setting values.
@@ -317,14 +317,14 @@  discard block
 block discarded – undo
317 317
 		'uninstall_on_delete'                         => 'disabled',
318 318
 		'the_content_filter'                          => 'enabled',
319 319
 		'scripts_footer'                              => 'disabled',
320
-		'agree_to_terms_label'                        => __( 'Agree to Terms?', 'give' ),
320
+		'agree_to_terms_label'                        => __('Agree to Terms?', 'give'),
321 321
 		'agreement_text'                              => give_get_default_agreement_text(),
322 322
 
323 323
 		// Paypal IPN verification.
324 324
 		'paypal_verification'                         => 'enabled',
325 325
 
326 326
 		// Default is manual gateway.
327
-		'gateways'                                    => array( 'manual' => 1, 'offline' => 1 ),
327
+		'gateways'                                    => array('manual' => 1, 'offline' => 1),
328 328
 		'default_gateway'                             => 'manual',
329 329
 
330 330
 		// Offline gateway setup.
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
  */
350 350
 function give_get_default_agreement_text() {
351 351
 
352
-	$org_name = get_bloginfo( 'name' );
352
+	$org_name = get_bloginfo('name');
353 353
 
354 354
 	$agreement = sprintf(
355 355
 		'<p>Acceptance of any contribution, gift or grant is at the discretion of the %1$s. The  %1$s will not accept any gift unless it can be used or expended consistently with the purpose and mission of the  %1$s.</p>
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 		$org_name
364 364
 	);
365 365
 
366
-	return apply_filters( 'give_get_default_agreement_text', $agreement, $org_name );
366
+	return apply_filters('give_get_default_agreement_text', $agreement, $org_name);
367 367
 }
368 368
 
369 369
 
@@ -372,22 +372,22 @@  discard block
 block discarded – undo
372 372
  *
373 373
  * @since 1.8.11
374 374
  */
375
-function give_create_pages(){
375
+function give_create_pages() {
376 376
 
377 377
 	// Bailout if pages already created.
378
-	if( get_option( 'give_install_pages_created') ) {
378
+	if (get_option('give_install_pages_created')) {
379 379
 		return false;
380 380
 	}
381 381
 
382 382
 	$options = array();
383 383
 
384 384
 	// Checks if the Success Page option exists AND that the page exists.
385
-	if ( ! get_post( give_get_option( 'success_page' ) ) ) {
385
+	if ( ! get_post(give_get_option('success_page'))) {
386 386
 
387 387
 		// Donation Confirmation (Success) Page
388 388
 		$success = wp_insert_post(
389 389
 			array(
390
-				'post_title'     => esc_html__( 'Donation Confirmation', 'give' ),
390
+				'post_title'     => esc_html__('Donation Confirmation', 'give'),
391 391
 				'post_content'   => '[give_receipt]',
392 392
 				'post_status'    => 'publish',
393 393
 				'post_author'    => 1,
@@ -401,13 +401,13 @@  discard block
 block discarded – undo
401 401
 	}
402 402
 
403 403
 	// Checks if the Failure Page option exists AND that the page exists.
404
-	if ( ! get_post( give_get_option( 'failure_page' ) ) ) {
404
+	if ( ! get_post(give_get_option('failure_page'))) {
405 405
 
406 406
 		// Failed Donation Page
407 407
 		$failed = wp_insert_post(
408 408
 			array(
409
-				'post_title'     => esc_html__( 'Donation Failed', 'give' ),
410
-				'post_content'   => esc_html__( 'We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give' ),
409
+				'post_title'     => esc_html__('Donation Failed', 'give'),
410
+				'post_content'   => esc_html__('We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give'),
411 411
 				'post_status'    => 'publish',
412 412
 				'post_author'    => 1,
413 413
 				'post_type'      => 'page',
@@ -419,11 +419,11 @@  discard block
 block discarded – undo
419 419
 	}
420 420
 
421 421
 	// Checks if the History Page option exists AND that the page exists.
422
-	if ( ! get_post( give_get_option( 'history_page' ) ) ) {
422
+	if ( ! get_post(give_get_option('history_page'))) {
423 423
 		// Donation History Page
424 424
 		$history = wp_insert_post(
425 425
 			array(
426
-				'post_title'     => esc_html__( 'Donation History', 'give' ),
426
+				'post_title'     => esc_html__('Donation History', 'give'),
427 427
 				'post_content'   => '[donation_history]',
428 428
 				'post_status'    => 'publish',
429 429
 				'post_author'    => 1,
@@ -435,10 +435,10 @@  discard block
 block discarded – undo
435 435
 		$options['history_page'] = $history;
436 436
 	}
437 437
 
438
-	if( ! empty( $options ) ) {
439
-		update_option( 'give_settings', array_merge( give_get_settings(), $options ) );
438
+	if ( ! empty($options)) {
439
+		update_option('give_settings', array_merge(give_get_settings(), $options));
440 440
 	}
441 441
 
442
-	add_option( 'give_install_pages_created', 1, '', 'no' );
442
+	add_option('give_install_pages_created', 1, '', 'no');
443 443
 }
444
-add_action( 'admin_init', 'give_create_pages', -1 );
444
+add_action('admin_init', 'give_create_pages', -1);
Please login to merge, or discard this patch.
includes/process-donation.php 1 patch
Spacing   +248 added lines, -249 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
 
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @since 1.0
32 32
 	 */
33
-	do_action( 'give_pre_process_donation' );
33
+	do_action('give_pre_process_donation');
34 34
 
35 35
 	// Validate the form $_POST data
36 36
 	$valid_data = give_donation_form_validate_fields();
@@ -45,26 +45,26 @@  discard block
 block discarded – undo
45 45
 	 * @param bool|array $valid_data Validate fields.
46 46
 	 * @param array $_POST Array of variables passed via the HTTP POST.
47 47
 	 */
48
-	do_action( 'give_checkout_error_checks', $valid_data, $_POST );
48
+	do_action('give_checkout_error_checks', $valid_data, $_POST);
49 49
 
50
-	$is_ajax = isset( $_POST['give_ajax'] );
50
+	$is_ajax = isset($_POST['give_ajax']);
51 51
 
52 52
 	// Process the login form
53
-	if ( isset( $_POST['give_login_submit'] ) ) {
53
+	if (isset($_POST['give_login_submit'])) {
54 54
 		give_process_form_login();
55 55
 	}
56 56
 
57 57
 	// Validate the user
58
-	$user = give_get_donation_form_user( $valid_data );
58
+	$user = give_get_donation_form_user($valid_data);
59 59
 
60
-	if ( false === $valid_data || give_get_errors() || ! $user ) {
61
-		if ( $is_ajax ) {
60
+	if (false === $valid_data || give_get_errors() || ! $user) {
61
+		if ($is_ajax) {
62 62
 			/**
63 63
 			 * Fires when AJAX sends back errors from the donation form.
64 64
 			 *
65 65
 			 * @since 1.0
66 66
 			 */
67
-			do_action( 'give_ajax_donation_errors' );
67
+			do_action('give_ajax_donation_errors');
68 68
 			give_die();
69 69
 		} else {
70 70
 			return false;
@@ -72,17 +72,17 @@  discard block
 block discarded – undo
72 72
 	}
73 73
 
74 74
 	// If AJAX send back success to proceed with form submission
75
-	if ( $is_ajax ) {
75
+	if ($is_ajax) {
76 76
 		echo 'success';
77 77
 		give_die();
78 78
 	}
79 79
 
80 80
 	// After AJAX: Setup session if not using php_sessions
81
-	if ( ! Give()->session->use_php_sessions() ) {
81
+	if ( ! Give()->session->use_php_sessions()) {
82 82
 		// Double-check that set_cookie is publicly accessible;
83 83
 		// we're using a slightly modified class-wp-sessions.php
84
-		$session_reflection = new ReflectionMethod( 'WP_Session', 'set_cookie' );
85
-		if ( $session_reflection->isPublic() ) {
84
+		$session_reflection = new ReflectionMethod('WP_Session', 'set_cookie');
85
+		if ($session_reflection->isPublic()) {
86 86
 			// Manually set the cookie.
87 87
 			Give()->session->init()->set_cookie();
88 88
 		}
@@ -97,20 +97,19 @@  discard block
 block discarded – undo
97 97
 		'address'    => $user['address'],
98 98
 	);
99 99
 
100
-	$auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
100
+	$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
101 101
 
102
-	$price        = isset( $_POST['give-amount'] ) ?
103
-		(float) apply_filters( 'give_donation_total', give_maybe_sanitize_amount( $_POST['give-amount'] ) ) :
104
-		'0.00';
105
-	$purchase_key = strtolower( md5( $user['user_email'] . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) );
102
+	$price        = isset($_POST['give-amount']) ?
103
+		(float) apply_filters('give_donation_total', give_maybe_sanitize_amount($_POST['give-amount'])) : '0.00';
104
+	$purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true)));
106 105
 
107 106
 	// Setup donation information
108 107
 	$donation_data = array(
109 108
 		'price'        => $price,
110 109
 		'purchase_key' => $purchase_key,
111 110
 		'user_email'   => $user['user_email'],
112
-		'date'         => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ),
113
-		'user_info'    => stripslashes_deep( $user_info ),
111
+		'date'         => date('Y-m-d H:i:s', current_time('timestamp')),
112
+		'user_info'    => stripslashes_deep($user_info),
114 113
 		'post_data'    => $_POST,
115 114
 		'gateway'      => $valid_data['gateway'],
116 115
 		'card_info'    => $valid_data['cc_info'],
@@ -130,10 +129,10 @@  discard block
 block discarded – undo
130 129
 	 * @param array $user_info Array containing basic user information.
131 130
 	 * @param bool|array $valid_data Validate fields.
132 131
 	 */
133
-	do_action( 'give_checkout_before_gateway', $_POST, $user_info, $valid_data );
132
+	do_action('give_checkout_before_gateway', $_POST, $user_info, $valid_data);
134 133
 
135 134
 	// Sanity check for price
136
-	if ( ! $donation_data['price'] ) {
135
+	if ( ! $donation_data['price']) {
137 136
 		// Revert to manual
138 137
 		$donation_data['gateway'] = 'manual';
139 138
 		$_POST['give-gateway']    = 'manual';
@@ -144,27 +143,27 @@  discard block
 block discarded – undo
144 143
 	 *
145 144
 	 * @since 1.7
146 145
 	 */
147
-	$donation_data = apply_filters( 'give_donation_data_before_gateway', $donation_data, $valid_data );
146
+	$donation_data = apply_filters('give_donation_data_before_gateway', $donation_data, $valid_data);
148 147
 
149 148
 	// Setup the data we're storing in the donation session
150 149
 	$session_data = $donation_data;
151 150
 
152 151
 	// Make sure credit card numbers are never stored in sessions
153
-	unset( $session_data['card_info']['card_number'] );
154
-	unset( $session_data['post_data']['card_number'] );
152
+	unset($session_data['card_info']['card_number']);
153
+	unset($session_data['post_data']['card_number']);
155 154
 
156 155
 	// Used for showing data to non logged-in users after donation, and for other plugins needing donation data.
157
-	give_set_purchase_session( $session_data );
156
+	give_set_purchase_session($session_data);
158 157
 
159 158
 	// Send info to the gateway for payment processing
160
-	give_send_to_gateway( $donation_data['gateway'], $donation_data );
159
+	give_send_to_gateway($donation_data['gateway'], $donation_data);
161 160
 	give_die();
162 161
 
163 162
 }
164 163
 
165
-add_action( 'give_purchase', 'give_process_donation_form' );
166
-add_action( 'wp_ajax_give_process_donation', 'give_process_donation_form' );
167
-add_action( 'wp_ajax_nopriv_give_process_donation', 'give_process_donation_form' );
164
+add_action('give_purchase', 'give_process_donation_form');
165
+add_action('wp_ajax_give_process_donation', 'give_process_donation_form');
166
+add_action('wp_ajax_nopriv_give_process_donation', 'give_process_donation_form');
168 167
 
169 168
 
170 169
 /**
@@ -177,29 +176,29 @@  discard block
 block discarded – undo
177 176
  *
178 177
  * @return void
179 178
  */
180
-function give_check_logged_in_user_for_existing_email( $valid_data, $post ) {
179
+function give_check_logged_in_user_for_existing_email($valid_data, $post) {
181 180
 
182 181
 	// Verify that the email address belongs to this customer.
183
-	if ( is_user_logged_in() ) {
182
+	if (is_user_logged_in()) {
184 183
 
185
-		$submitted_email    = $valid_data['logged_in_user']['user_email'];
186
-		$customer = new Give_Donor( get_current_user_id(), true );
184
+		$submitted_email = $valid_data['logged_in_user']['user_email'];
185
+		$customer = new Give_Donor(get_current_user_id(), true);
187 186
 
188 187
 		// If this email address is not registered with this customer, see if it belongs to any other customer
189 188
 		if (
190 189
 			$submitted_email !== $customer->email
191
-			&& ( is_array( $customer->emails ) && ! in_array( $submitted_email, $customer->emails ) )
190
+			&& (is_array($customer->emails) && ! in_array($submitted_email, $customer->emails))
192 191
 		) {
193
-			$found_customer = new Give_Donor( $submitted_email );
192
+			$found_customer = new Give_Donor($submitted_email);
194 193
 
195
-			if ( $found_customer->id > 0 ) {
196
-				give_set_error( 'give-customer-email-exists', sprintf( __( 'You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.' ,'give' ), $customer->email, $submitted_email ) );
194
+			if ($found_customer->id > 0) {
195
+				give_set_error('give-customer-email-exists', sprintf(__('You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.', 'give'), $customer->email, $submitted_email));
197 196
 			}
198 197
 		}
199 198
 	}
200 199
 }
201 200
 
202
-add_action( 'give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 2 );
201
+add_action('give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 2);
203 202
 
204 203
 /**
205 204
  * Process the checkout login form
@@ -209,49 +208,49 @@  discard block
 block discarded – undo
209 208
  * @return      void
210 209
  */
211 210
 function give_process_form_login() {
212
-	$is_ajax = isset( $_POST['give_ajax'] );
211
+	$is_ajax = isset($_POST['give_ajax']);
213 212
 
214 213
 	$user_data = give_donation_form_validate_user_login();
215 214
 
216
-	if ( give_get_errors() || $user_data['user_id'] < 1 ) {
217
-		if ( $is_ajax ) {
215
+	if (give_get_errors() || $user_data['user_id'] < 1) {
216
+		if ($is_ajax) {
218 217
 			/**
219 218
 			 * Fires when AJAX sends back errors from the donation form.
220 219
 			 *
221 220
 			 * @since 1.0
222 221
 			 */
223 222
 			ob_start();
224
-				do_action( 'give_ajax_donation_errors' );
223
+				do_action('give_ajax_donation_errors');
225 224
 				$message = ob_get_contents();
226 225
 			ob_end_clean();
227
-			wp_send_json_error( $message );
226
+			wp_send_json_error($message);
228 227
 		} else {
229
-			wp_redirect( $_SERVER['HTTP_REFERER'] );
228
+			wp_redirect($_SERVER['HTTP_REFERER']);
230 229
 			exit;
231 230
 		}
232 231
 	}
233 232
 
234
-	give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] );
233
+	give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']);
235 234
 
236
-	if ( $is_ajax ) {
235
+	if ($is_ajax) {
237 236
 		$message = Give()->notices->print_frontend_notice(
238 237
 			sprintf(
239 238
 				/* translators: %s: user first name */
240
-				esc_html__( 'Welcome %s! You have successfully logged into your account.', 'give' ),
241
-				( ! empty( $user_data['user_first'] ) ) ? $user_data['user_first'] : $user_data['user_login']
239
+				esc_html__('Welcome %s! You have successfully logged into your account.', 'give'),
240
+				( ! empty($user_data['user_first'])) ? $user_data['user_first'] : $user_data['user_login']
242 241
 			),
243 242
 			false,
244 243
 			'success'
245 244
 		);
246 245
 
247
-		wp_send_json_success( $message );
246
+		wp_send_json_success($message);
248 247
 	} else {
249
-		wp_redirect( $_SERVER['HTTP_REFERER'] );
248
+		wp_redirect($_SERVER['HTTP_REFERER']);
250 249
 	}
251 250
 }
252 251
 
253
-add_action( 'wp_ajax_give_process_donation_login', 'give_process_form_login' );
254
-add_action( 'wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login' );
252
+add_action('wp_ajax_give_process_donation_login', 'give_process_form_login');
253
+add_action('wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login');
255 254
 
256 255
 /**
257 256
  * Donation Form Validate Fields.
@@ -263,55 +262,55 @@  discard block
 block discarded – undo
263 262
 function give_donation_form_validate_fields() {
264 263
 
265 264
 	// Check if there is $_POST
266
-	if ( empty( $_POST ) ) {
265
+	if (empty($_POST)) {
267 266
 		return false;
268 267
 	}
269 268
 
270
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
269
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
271 270
 
272 271
 	// Start an array to collect valid data
273 272
 	$valid_data = array(
274 273
 		'gateway'          => give_donation_form_validate_gateway(), // Gateway fallback (amount is validated here)
275
-		'need_new_user'    => false,     // New user flag
276
-		'need_user_login'  => false,     // Login user flag
277
-		'logged_user_data' => array(),   // Logged user collected data
278
-		'new_user_data'    => array(),   // New user collected data
279
-		'login_user_data'  => array(),   // Login user collected data
280
-		'guest_user_data'  => array(),   // Guest user collected data
281
-		'cc_info'          => give_donation_form_validate_cc(),// Credit card info
274
+		'need_new_user'    => false, // New user flag
275
+		'need_user_login'  => false, // Login user flag
276
+		'logged_user_data' => array(), // Logged user collected data
277
+		'new_user_data'    => array(), // New user collected data
278
+		'login_user_data'  => array(), // Login user collected data
279
+		'guest_user_data'  => array(), // Guest user collected data
280
+		'cc_info'          => give_donation_form_validate_cc(), // Credit card info
282 281
 	);
283 282
 
284 283
 	// Validate Honeypot First
285
-	if ( ! empty( $_POST['give-honeypot'] ) ) {
286
-		give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) );
284
+	if ( ! empty($_POST['give-honeypot'])) {
285
+		give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give'));
287 286
 	}
288 287
 
289 288
 	// Validate agree to terms
290
-	if ( give_is_terms_enabled( $form_id ) ) {
289
+	if (give_is_terms_enabled($form_id)) {
291 290
 		give_donation_form_validate_agree_to_terms();
292 291
 	}
293 292
 
294 293
 	// Stop processing donor registration, if donor registration is optional and donor can do guest checkout.
295 294
 	// If registration form username field is empty that means donor do not want to registration instead want guest checkout.
296 295
 	if (
297
-		! give_logged_in_only( $form_id )
298
-		&& isset( $_POST['give-purchase-var'] )
296
+		! give_logged_in_only($form_id)
297
+		&& isset($_POST['give-purchase-var'])
299 298
 		&& $_POST['give-purchase-var'] == 'needs-to-register'
300
-		&& empty( $_POST['give_user_login'] )
299
+		&& empty($_POST['give_user_login'])
301 300
 	) {
302
-		unset( $_POST['give-purchase-var'] );
301
+		unset($_POST['give-purchase-var']);
303 302
 	}
304 303
 
305
-	if ( is_user_logged_in() ) {
304
+	if (is_user_logged_in()) {
306 305
 		// Collect logged in user data.
307 306
 		$valid_data['logged_in_user'] = give_donation_form_validate_logged_in_user();
308
-	} elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' ) {
307
+	} elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register') {
309 308
 		// Set new user registration as required.
310 309
 		$valid_data['need_new_user'] = true;
311 310
 		// Validate new user data.
312 311
 		$valid_data['new_user_data'] = give_donation_form_validate_new_user();
313 312
 		// Check if login validation is needed.
314
-	} elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) {
313
+	} elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') {
315 314
 		// Set user login as required.
316 315
 		$valid_data['need_user_login'] = true;
317 316
 		// Validate users login info.
@@ -336,41 +335,41 @@  discard block
 block discarded – undo
336 335
  */
337 336
 function give_donation_form_validate_gateway() {
338 337
 
339
-	$form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0;
340
-	$amount  = isset( $_REQUEST['give-amount'] ) ? give_maybe_sanitize_amount( $_REQUEST['give-amount'] ) : 0;
341
-	$gateway = give_get_default_gateway( $form_id );
338
+	$form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;
339
+	$amount  = isset($_REQUEST['give-amount']) ? give_maybe_sanitize_amount($_REQUEST['give-amount']) : 0;
340
+	$gateway = give_get_default_gateway($form_id);
342 341
 
343 342
 	// Check if a gateway value is present.
344
-	if ( ! empty( $_REQUEST['give-gateway'] ) ) {
343
+	if ( ! empty($_REQUEST['give-gateway'])) {
345 344
 
346
-		$gateway = sanitize_text_field( $_REQUEST['give-gateway'] );
345
+		$gateway = sanitize_text_field($_REQUEST['give-gateway']);
347 346
 
348 347
 		// Is amount being donated in LIVE mode 0.00? If so, error:
349
-		if ( $amount == 0 && ! give_is_test_mode() ) {
348
+		if ($amount == 0 && ! give_is_test_mode()) {
350 349
 
351
-			give_set_error( 'invalid_donation_amount', __( 'Please insert a valid donation amount.', 'give' ) );
350
+			give_set_error('invalid_donation_amount', __('Please insert a valid donation amount.', 'give'));
352 351
 
353 352
 		} // End if().
354
-		elseif ( ! give_verify_minimum_price() ) {
353
+		elseif ( ! give_verify_minimum_price()) {
355 354
 			// translators: %s: minimum donation amount.
356 355
 			give_set_error(
357 356
 				'invalid_donation_minimum',
358 357
 				sprintf(
359 358
 					/* translators: %s: minimum donation amount */
360
-					__( 'This form has a minimum donation amount of %s.', 'give' ),
361
-					give_currency_filter( give_format_amount( give_get_form_minimum_price( $form_id ), array( 'sanitize' => false ) ) )
359
+					__('This form has a minimum donation amount of %s.', 'give'),
360
+					give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id), array('sanitize' => false)))
362 361
 				)
363 362
 			);
364 363
 
365 364
 		} //Is this test mode zero donation? Let it through but set to manual gateway.
366
-		elseif ( $amount == 0 && give_is_test_mode() ) {
365
+		elseif ($amount == 0 && give_is_test_mode()) {
367 366
 
368 367
 			$gateway = 'manual';
369 368
 
370 369
 		} //Check if this gateway is active.
371
-		elseif ( ! give_is_gateway_active( $gateway ) ) {
370
+		elseif ( ! give_is_gateway_active($gateway)) {
372 371
 
373
-			give_set_error( 'invalid_gateway', __( 'The selected payment gateway is not enabled.', 'give' ) );
372
+			give_set_error('invalid_gateway', __('The selected payment gateway is not enabled.', 'give'));
374 373
 
375 374
 		}
376 375
 	}
@@ -388,21 +387,21 @@  discard block
 block discarded – undo
388 387
  */
389 388
 function give_verify_minimum_price() {
390 389
 
391
-	$amount          = give_maybe_sanitize_amount( $_REQUEST['give-amount'] );
392
-	$form_id         = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0;
393
-	$price_id        = isset( $_REQUEST['give-price-id'] ) ? $_REQUEST['give-price-id'] : null;
394
-	$variable_prices = give_has_variable_prices( $form_id );
390
+	$amount          = give_maybe_sanitize_amount($_REQUEST['give-amount']);
391
+	$form_id         = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0;
392
+	$price_id        = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : null;
393
+	$variable_prices = give_has_variable_prices($form_id);
395 394
 
396
-	if ( $variable_prices && in_array( $price_id, give_get_variable_price_ids( $form_id ) ) ) {
395
+	if ($variable_prices && in_array($price_id, give_get_variable_price_ids($form_id))) {
397 396
 
398
-		$price_level_amount = give_get_price_option_amount( $form_id, $price_id );
397
+		$price_level_amount = give_get_price_option_amount($form_id, $price_id);
399 398
 
400
-		if ( $price_level_amount == $amount ) {
399
+		if ($price_level_amount == $amount) {
401 400
 			return true;
402 401
 		}
403 402
 	}
404 403
 
405
-	if ( give_get_form_minimum_price( $form_id ) > $amount ) {
404
+	if (give_get_form_minimum_price($form_id) > $amount) {
406 405
 		return false;
407 406
 	}
408 407
 
@@ -418,9 +417,9 @@  discard block
 block discarded – undo
418 417
  */
419 418
 function give_donation_form_validate_agree_to_terms() {
420 419
 	// Validate agree to terms.
421
-	if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) {
420
+	if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) {
422 421
 		// User did not agree.
423
-		give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', __( 'You must agree to the terms and conditions.', 'give' ) ) );
422
+		give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', __('You must agree to the terms and conditions.', 'give')));
424 423
 	}
425 424
 }
426 425
 
@@ -434,59 +433,59 @@  discard block
 block discarded – undo
434 433
  *
435 434
  * @return      array
436 435
  */
437
-function give_get_required_fields( $form_id ) {
436
+function give_get_required_fields($form_id) {
438 437
 
439
-	$payment_mode = give_get_chosen_gateway( $form_id );
438
+	$payment_mode = give_get_chosen_gateway($form_id);
440 439
 
441 440
 	$required_fields = array(
442 441
 		'give_email' => array(
443 442
 			'error_id'      => 'invalid_email',
444
-			'error_message' => __( 'Please enter a valid email address.', 'give' ),
443
+			'error_message' => __('Please enter a valid email address.', 'give'),
445 444
 		),
446 445
 		'give_first' => array(
447 446
 			'error_id'      => 'invalid_first_name',
448
-			'error_message' => __( 'Please enter your first name.', 'give' ),
447
+			'error_message' => __('Please enter your first name.', 'give'),
449 448
 		),
450 449
 	);
451 450
 
452
-	$require_address = give_require_billing_address( $payment_mode );
451
+	$require_address = give_require_billing_address($payment_mode);
453 452
 
454
-	if ( $require_address ) {
455
-		$required_fields['card_address']    = array(
453
+	if ($require_address) {
454
+		$required_fields['card_address'] = array(
456 455
 			'error_id'      => 'invalid_card_address',
457
-			'error_message' => __( 'Please enter your primary billing address.', 'give' ),
456
+			'error_message' => __('Please enter your primary billing address.', 'give'),
458 457
 		);
459
-		$required_fields['card_zip']        = array(
458
+		$required_fields['card_zip'] = array(
460 459
 			'error_id'      => 'invalid_zip_code',
461
-			'error_message' => __( 'Please enter your zip / postal code.', 'give' ),
460
+			'error_message' => __('Please enter your zip / postal code.', 'give'),
462 461
 		);
463
-		$required_fields['card_city']       = array(
462
+		$required_fields['card_city'] = array(
464 463
 			'error_id'      => 'invalid_city',
465
-			'error_message' => __( 'Please enter your billing city.', 'give' ),
464
+			'error_message' => __('Please enter your billing city.', 'give'),
466 465
 		);
467 466
 		$required_fields['billing_country'] = array(
468 467
 			'error_id'      => 'invalid_country',
469
-			'error_message' => __( 'Please select your billing country.', 'give' ),
468
+			'error_message' => __('Please select your billing country.', 'give'),
470 469
 		);
471 470
 
472 471
 
473
-		$required_fields['card_state']      = array(
472
+		$required_fields['card_state'] = array(
474 473
 			'error_id'      => 'invalid_state',
475
-			'error_message' => __( 'Please enter billing state / province / County.', 'give' ),
474
+			'error_message' => __('Please enter billing state / province / County.', 'give'),
476 475
 		);
477 476
 
478 477
 		// Check if billing country alredy exists.
479
-		if ( ! empty( $_POST['billing_country'] ) ) {
478
+		if ( ! empty($_POST['billing_country'])) {
480 479
 			// Get the value from $_POST.
481
-			$country = sanitize_text_field( $_POST['billing_country'] );
480
+			$country = sanitize_text_field($_POST['billing_country']);
482 481
 
483 482
 			// Get the country list that does not required any states init.
484 483
 			$states_country = give_states_not_required_country_list();
485 484
 
486 485
 			// Check if states is empty or not.
487
-			if ( array_key_exists( $country, $states_country ) ) {
486
+			if (array_key_exists($country, $states_country)) {
488 487
 				// If states is empty remove the required feilds of state in billing cart.
489
-				unset( $required_fields['card_state'] );
488
+				unset($required_fields['card_state']);
490 489
 			}
491 490
 		}
492 491
 	}
@@ -496,7 +495,7 @@  discard block
 block discarded – undo
496 495
 	 *
497 496
 	 * @since 1.7
498 497
 	 */
499
-	$required_fields = apply_filters( 'give_donation_form_required_fields', $required_fields, $form_id );
498
+	$required_fields = apply_filters('give_donation_form_required_fields', $required_fields, $form_id);
500 499
 
501 500
 	return $required_fields;
502 501
 
@@ -511,16 +510,16 @@  discard block
 block discarded – undo
511 510
  *
512 511
  * @return bool
513 512
  */
514
-function give_require_billing_address( $payment_mode ) {
513
+function give_require_billing_address($payment_mode) {
515 514
 
516 515
 	$return = false;
517 516
 
518
-	if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) {
517
+	if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) {
519 518
 		$return = true;
520 519
 	}
521 520
 
522 521
 	// Let payment gateways and other extensions determine if address fields should be required.
523
-	return apply_filters( 'give_require_billing_address', $return );
522
+	return apply_filters('give_require_billing_address', $return);
524 523
 
525 524
 }
526 525
 
@@ -534,42 +533,42 @@  discard block
 block discarded – undo
534 533
 function give_donation_form_validate_logged_in_user() {
535 534
 	global $user_ID;
536 535
 
537
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
536
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
538 537
 
539 538
 	// Start empty array to collect valid user data.
540 539
 	$valid_user_data = array(
541 540
 		// Assume there will be errors.
542
-		'user_id' => - 1,
541
+		'user_id' => -1,
543 542
 	);
544 543
 
545 544
 	// Verify there is a user_ID.
546
-	if ( $user_ID > 0 ) {
545
+	if ($user_ID > 0) {
547 546
 		// Get the logged in user data.
548
-		$user_data = get_userdata( $user_ID );
547
+		$user_data = get_userdata($user_ID);
549 548
 
550 549
 		// Loop through required fields and show error messages.
551
-		foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) {
552
-			if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
553
-				give_set_error( $value['error_id'], $value['error_message'] );
550
+		foreach (give_get_required_fields($form_id) as $field_name => $value) {
551
+			if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) {
552
+				give_set_error($value['error_id'], $value['error_message']);
554 553
 			}
555 554
 		}
556 555
 
557 556
 		// Verify data.
558
-		if ( $user_data ) {
557
+		if ($user_data) {
559 558
 			// Collected logged in user data.
560 559
 			$valid_user_data = array(
561 560
 				'user_id'    => $user_ID,
562
-				'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email,
563
-				'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name,
564
-				'user_last'  => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name,
561
+				'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email,
562
+				'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name,
563
+				'user_last'  => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name,
565 564
 			);
566 565
 
567
-			if ( ! is_email( $valid_user_data['user_email'] ) ) {
568
-				give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
566
+			if ( ! is_email($valid_user_data['user_email'])) {
567
+				give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
569 568
 			}
570 569
 		} else {
571 570
 			// Set invalid user error.
572
-			give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) );
571
+			give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give'));
573 572
 		}
574 573
 	}
575 574
 
@@ -588,7 +587,7 @@  discard block
 block discarded – undo
588 587
 	// Default user data.
589 588
 	$default_user_data = array(
590 589
 		'give-form-id'           => '',
591
-		'user_id'                => - 1, // Assume there will be errors.
590
+		'user_id'                => -1, // Assume there will be errors.
592 591
 		'user_first'             => '',
593 592
 		'user_last'              => '',
594 593
 		'give_user_login'        => false,
@@ -598,14 +597,14 @@  discard block
 block discarded – undo
598 597
 	);
599 598
 
600 599
 	// Get user data.
601
-	$user_data            = wp_parse_args( array_map( 'trim', give_clean( $_POST ) ), $default_user_data );
600
+	$user_data            = wp_parse_args(array_map('trim', give_clean($_POST)), $default_user_data);
602 601
 	$registering_new_user = false;
603
-	$form_id              = absint( $user_data['give-form-id'] );
602
+	$form_id              = absint($user_data['give-form-id']);
604 603
 
605 604
 	// Start an empty array to collect valid user data.
606 605
 	$valid_user_data = array(
607 606
 		// Assume there will be errors.
608
-		'user_id'    => - 1,
607
+		'user_id'    => -1,
609 608
 
610 609
 		// Get first name.
611 610
 		'user_first' => $user_data['give_first'],
@@ -615,25 +614,25 @@  discard block
 block discarded – undo
615 614
 	);
616 615
 
617 616
 	// Loop through required fields and show error messages.
618
-	foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) {
619
-		if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
620
-			give_set_error( $value['error_id'], $value['error_message'] );
617
+	foreach (give_get_required_fields($form_id) as $field_name => $value) {
618
+		if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) {
619
+			give_set_error($value['error_id'], $value['error_message']);
621 620
 		}
622 621
 	}
623 622
 
624 623
 	// Check if we have an username to register.
625
-	if ( give_validate_username( $user_data['give_user_login'] ) ) {
624
+	if (give_validate_username($user_data['give_user_login'])) {
626 625
 		$registering_new_user          = true;
627 626
 		$valid_user_data['user_login'] = $user_data['give_user_login'];
628 627
 	}
629 628
 
630 629
 	// Check if we have an email to verify.
631
-	if ( give_validate_user_email( $user_data['give_email'], $registering_new_user ) ) {
630
+	if (give_validate_user_email($user_data['give_email'], $registering_new_user)) {
632 631
 		$valid_user_data['user_email'] = $user_data['give_email'];
633 632
 	}
634 633
 
635 634
 	// Check password.
636
-	if ( give_validate_user_password( $user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user ) ) {
635
+	if (give_validate_user_password($user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user)) {
637 636
 		// All is good to go.
638 637
 		$valid_user_data['user_pass'] = $user_data['give_user_pass'];
639 638
 	}
@@ -653,36 +652,36 @@  discard block
 block discarded – undo
653 652
 	// Start an array to collect valid user data.
654 653
 	$valid_user_data = array(
655 654
 		// Assume there will be errors.
656
-		'user_id' => - 1,
655
+		'user_id' => -1,
657 656
 	);
658 657
 
659 658
 	// Username.
660
-	if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) {
661
-		give_set_error( 'must_log_in', __( 'You must register or login to complete your donation.', 'give' ) );
659
+	if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') {
660
+		give_set_error('must_log_in', __('You must register or login to complete your donation.', 'give'));
662 661
 
663 662
 		return $valid_user_data;
664 663
 	}
665 664
 
666 665
 	// Get the user by login.
667
-	$user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) );
666
+	$user_data = get_user_by('login', strip_tags($_POST['give_user_login']));
668 667
 
669 668
 	// Check if user exists.
670
-	if ( $user_data ) {
669
+	if ($user_data) {
671 670
 		// Get password.
672
-		$user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false;
671
+		$user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false;
673 672
 
674 673
 		// Check user_pass.
675
-		if ( $user_pass ) {
674
+		if ($user_pass) {
676 675
 			// Check if password is valid.
677
-			if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) {
676
+			if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) {
678 677
 				// Incorrect password.
679 678
 				give_set_error(
680 679
 					'password_incorrect',
681 680
 					sprintf(
682 681
 						'%1$s <a href="%2$s">%3$s</a>',
683
-						__( 'The password you entered is incorrect.', 'give' ),
684
-						wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ),
685
-						__( 'Reset Password', 'give' )
682
+						__('The password you entered is incorrect.', 'give'),
683
+						wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"),
684
+						__('Reset Password', 'give')
686 685
 					)
687 686
 				);
688 687
 				// All is correct.
@@ -699,11 +698,11 @@  discard block
 block discarded – undo
699 698
 			}
700 699
 		} else {
701 700
 			// Empty password.
702
-			give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) );
701
+			give_set_error('password_empty', __('Enter a password.', 'give'));
703 702
 		}
704 703
 	} else {
705 704
 		// No username.
706
-		give_set_error( 'username_incorrect', __( 'The username you entered does not exist.', 'give' ) );
705
+		give_set_error('username_incorrect', __('The username you entered does not exist.', 'give'));
707 706
 	}// End if().
708 707
 
709 708
 	return $valid_user_data;
@@ -718,7 +717,7 @@  discard block
 block discarded – undo
718 717
  */
719 718
 function give_donation_form_validate_guest_user() {
720 719
 
721
-	$form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : '';
720
+	$form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : '';
722 721
 
723 722
 	// Start an array to collect valid user data.
724 723
 	$valid_user_data = array(
@@ -727,38 +726,38 @@  discard block
 block discarded – undo
727 726
 	);
728 727
 
729 728
 	// Show error message if user must be logged in.
730
-	if ( give_logged_in_only( $form_id ) ) {
731
-		give_set_error( 'logged_in_only', __( 'You must be logged in to donate.', 'give' ) );
729
+	if (give_logged_in_only($form_id)) {
730
+		give_set_error('logged_in_only', __('You must be logged in to donate.', 'give'));
732 731
 	}
733 732
 
734 733
 	// Get the guest email.
735
-	$guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false;
734
+	$guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false;
736 735
 
737 736
 	// Check email.
738
-	if ( $guest_email && strlen( $guest_email ) > 0 ) {
737
+	if ($guest_email && strlen($guest_email) > 0) {
739 738
 		// Validate email.
740
-		if ( ! is_email( $guest_email ) ) {
739
+		if ( ! is_email($guest_email)) {
741 740
 			// Invalid email.
742
-			give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) );
741
+			give_set_error('email_invalid', __('Invalid email.', 'give'));
743 742
 		} else {
744 743
 			// All is good to go.
745 744
 			$valid_user_data['user_email'] = $guest_email;
746 745
 
747 746
 			// Get user_id from donor if exist.
748
-			$donor = new Give_Donor( $guest_email );
749
-			if ( $donor->id && $donor->user_id ) {
747
+			$donor = new Give_Donor($guest_email);
748
+			if ($donor->id && $donor->user_id) {
750 749
 				$valid_user_data['user_id'] = $donor->user_id;
751 750
 			}
752 751
 		}
753 752
 	} else {
754 753
 		// No email.
755
-		give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) );
754
+		give_set_error('email_empty', __('Enter an email.', 'give'));
756 755
 	}
757 756
 
758 757
 	// Loop through required fields and show error messages.
759
-	foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) {
760
-		if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) {
761
-			give_set_error( $value['error_id'], $value['error_message'] );
758
+	foreach (give_get_required_fields($form_id) as $field_name => $value) {
759
+		if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) {
760
+			give_set_error($value['error_id'], $value['error_message']);
762 761
 		}
763 762
 	}
764 763
 
@@ -774,36 +773,36 @@  discard block
 block discarded – undo
774 773
  * @since   1.0
775 774
  * @return  integer
776 775
  */
777
-function give_register_and_login_new_user( $user_data = array() ) {
776
+function give_register_and_login_new_user($user_data = array()) {
778 777
 	// Verify the array.
779
-	if ( empty( $user_data ) ) {
780
-		return - 1;
778
+	if (empty($user_data)) {
779
+		return -1;
781 780
 	}
782 781
 
783
-	if ( give_get_errors() ) {
784
-		return - 1;
782
+	if (give_get_errors()) {
783
+		return -1;
785 784
 	}
786 785
 
787
-	$user_args = apply_filters( 'give_insert_user_args', array(
788
-		'user_login'      => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '',
789
-		'user_pass'       => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '',
790
-		'user_email'      => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '',
791
-		'first_name'      => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '',
792
-		'last_name'       => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '',
793
-		'user_registered' => date( 'Y-m-d H:i:s' ),
794
-		'role'            => get_option( 'default_role' ),
795
-	), $user_data );
786
+	$user_args = apply_filters('give_insert_user_args', array(
787
+		'user_login'      => isset($user_data['user_login']) ? $user_data['user_login'] : '',
788
+		'user_pass'       => isset($user_data['user_pass']) ? $user_data['user_pass'] : '',
789
+		'user_email'      => isset($user_data['user_email']) ? $user_data['user_email'] : '',
790
+		'first_name'      => isset($user_data['user_first']) ? $user_data['user_first'] : '',
791
+		'last_name'       => isset($user_data['user_last']) ? $user_data['user_last'] : '',
792
+		'user_registered' => date('Y-m-d H:i:s'),
793
+		'role'            => get_option('default_role'),
794
+	), $user_data);
796 795
 
797 796
 	// Insert new user.
798
-	$user_id = wp_insert_user( $user_args );
797
+	$user_id = wp_insert_user($user_args);
799 798
 
800 799
 	// Validate inserted user.
801
-	if ( is_wp_error( $user_id ) ) {
802
-		return - 1;
800
+	if (is_wp_error($user_id)) {
801
+		return -1;
803 802
 	}
804 803
 
805 804
 	// Allow themes and plugins to filter the user data.
806
-	$user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args );
805
+	$user_data = apply_filters('give_insert_user_data', $user_data, $user_args);
807 806
 
808 807
 	/**
809 808
 	 * Fires after inserting user.
@@ -813,10 +812,10 @@  discard block
 block discarded – undo
813 812
 	 * @param int $user_id User id.
814 813
 	 * @param array $user_data Array containing user data.
815 814
 	 */
816
-	do_action( 'give_insert_user', $user_id, $user_data );
815
+	do_action('give_insert_user', $user_id, $user_data);
817 816
 
818 817
 	// Login new user.
819
-	give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] );
818
+	give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']);
820 819
 
821 820
 	// Return user id.
822 821
 	return $user_id;
@@ -831,27 +830,27 @@  discard block
 block discarded – undo
831 830
  * @since   1.0
832 831
  * @return  array|bool
833 832
  */
834
-function give_get_donation_form_user( $valid_data = array() ) {
833
+function give_get_donation_form_user($valid_data = array()) {
835 834
 
836 835
 	// Initialize user.
837 836
 	$user    = false;
838
-	$is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
837
+	$is_ajax = defined('DOING_AJAX') && DOING_AJAX;
839 838
 
840
-	if ( $is_ajax ) {
839
+	if ($is_ajax) {
841 840
 		// Do not create or login the user during the ajax submission (check for errors only).
842 841
 		return true;
843
-	} elseif ( is_user_logged_in() ) {
842
+	} elseif (is_user_logged_in()) {
844 843
 		// Set the valid user as the logged in collected data.
845 844
 		$user = $valid_data['logged_in_user'];
846
-	} elseif ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) {
845
+	} elseif ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) {
847 846
 		// New user registration.
848
-		if ( $valid_data['need_new_user'] === true ) {
847
+		if ($valid_data['need_new_user'] === true) {
849 848
 			// Set user.
850 849
 			$user = $valid_data['new_user_data'];
851 850
 			// Register and login new user.
852
-			$user['user_id'] = give_register_and_login_new_user( $user );
851
+			$user['user_id'] = give_register_and_login_new_user($user);
853 852
 			// User login
854
-		} elseif ( $valid_data['need_user_login'] === true && ! $is_ajax ) {
853
+		} elseif ($valid_data['need_user_login'] === true && ! $is_ajax) {
855 854
 
856 855
 			/**
857 856
 			 * The login form is now processed in the give_process_donation_login() function.
@@ -863,48 +862,48 @@  discard block
 block discarded – undo
863 862
 			// Set user.
864 863
 			$user = $valid_data['login_user_data'];
865 864
 			// Login user.
866
-			give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] );
865
+			give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']);
867 866
 		}
868 867
 	}
869 868
 
870 869
 	// Check guest checkout.
871
-	if ( false === $user && false === give_logged_in_only( $_POST['give-form-id'] ) ) {
870
+	if (false === $user && false === give_logged_in_only($_POST['give-form-id'])) {
872 871
 		// Set user
873 872
 		$user = $valid_data['guest_user_data'];
874 873
 	}
875 874
 
876 875
 	// Verify we have an user.
877
-	if ( false === $user || empty( $user ) ) {
876
+	if (false === $user || empty($user)) {
878 877
 		// Return false.
879 878
 		return false;
880 879
 	}
881 880
 
882 881
 	// Get user first name.
883
-	if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) {
884
-		$user['user_first'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : '';
882
+	if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) {
883
+		$user['user_first'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : '';
885 884
 	}
886 885
 
887 886
 	// Get user last name.
888
-	if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) {
889
-		$user['user_last'] = isset( $_POST['give_last'] ) ? strip_tags( trim( $_POST['give_last'] ) ) : '';
887
+	if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) {
888
+		$user['user_last'] = isset($_POST['give_last']) ? strip_tags(trim($_POST['give_last'])) : '';
890 889
 	}
891 890
 
892 891
 	// Get the user's billing address details.
893 892
 	$user['address']            = array();
894
-	$user['address']['line1']   = ! empty( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : false;
895
-	$user['address']['line2']   = ! empty( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : false;
896
-	$user['address']['city']    = ! empty( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : false;
897
-	$user['address']['state']   = ! empty( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : false;
898
-	$user['address']['country'] = ! empty( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : false;
899
-	$user['address']['zip']     = ! empty( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : false;
900
-
901
-	if ( empty( $user['address']['country'] ) ) {
893
+	$user['address']['line1']   = ! empty($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : false;
894
+	$user['address']['line2']   = ! empty($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : false;
895
+	$user['address']['city']    = ! empty($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : false;
896
+	$user['address']['state']   = ! empty($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : false;
897
+	$user['address']['country'] = ! empty($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : false;
898
+	$user['address']['zip']     = ! empty($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : false;
899
+
900
+	if (empty($user['address']['country'])) {
902 901
 		$user['address'] = false;
903 902
 	} // End if().
904 903
 
905
-	if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) {
904
+	if ( ! empty($user['user_id']) && $user['user_id'] > 0 && ! empty($user['address'])) {
906 905
 		// Store the address in the user's meta so the donation form can be pre-populated with it on return donation.
907
-		update_user_meta( $user['user_id'], '_give_user_address', $user['address'] );
906
+		update_user_meta($user['user_id'], '_give_user_address', $user['address']);
908 907
 	}
909 908
 
910 909
 	// Return valid user.
@@ -923,16 +922,16 @@  discard block
 block discarded – undo
923 922
 	$card_data = give_get_donation_cc_info();
924 923
 
925 924
 	// Validate the card zip.
926
-	if ( ! empty( $card_data['card_zip'] ) ) {
927
-		if ( ! give_donation_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) {
928
-			give_set_error( 'invalid_cc_zip', __( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) );
925
+	if ( ! empty($card_data['card_zip'])) {
926
+		if ( ! give_donation_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) {
927
+			give_set_error('invalid_cc_zip', __('The zip / postal code you entered for your billing address is invalid.', 'give'));
929 928
 		}
930 929
 	}
931 930
 
932 931
 	// Ensure no spaces.
933
-	if ( ! empty( $card_data['card_number'] ) ) {
934
-		$card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); // no "+" signs
935
-		$card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces
932
+	if ( ! empty($card_data['card_number'])) {
933
+		$card_data['card_number'] = str_replace('+', '', $card_data['card_number']); // no "+" signs
934
+		$card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces
936 935
 	}
937 936
 
938 937
 	// This should validate card numbers at some point too.
@@ -949,17 +948,17 @@  discard block
 block discarded – undo
949 948
 function give_get_donation_cc_info() {
950 949
 
951 950
 	$cc_info                   = array();
952
-	$cc_info['card_name']      = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : '';
953
-	$cc_info['card_number']    = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : '';
954
-	$cc_info['card_cvc']       = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : '';
955
-	$cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : '';
956
-	$cc_info['card_exp_year']  = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : '';
957
-	$cc_info['card_address']   = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : '';
958
-	$cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : '';
959
-	$cc_info['card_city']      = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : '';
960
-	$cc_info['card_state']     = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : '';
961
-	$cc_info['card_country']   = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : '';
962
-	$cc_info['card_zip']       = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : '';
951
+	$cc_info['card_name']      = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : '';
952
+	$cc_info['card_number']    = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : '';
953
+	$cc_info['card_cvc']       = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : '';
954
+	$cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : '';
955
+	$cc_info['card_exp_year']  = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : '';
956
+	$cc_info['card_address']   = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : '';
957
+	$cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : '';
958
+	$cc_info['card_city']      = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : '';
959
+	$cc_info['card_state']     = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : '';
960
+	$cc_info['card_country']   = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : '';
961
+	$cc_info['card_zip']       = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : '';
963 962
 
964 963
 	// Return cc info.
965 964
 	return $cc_info;
@@ -975,14 +974,14 @@  discard block
 block discarded – undo
975 974
  *
976 975
  * @return bool|mixed
977 976
  */
978
-function give_donation_form_validate_cc_zip( $zip = 0, $country_code = '' ) {
977
+function give_donation_form_validate_cc_zip($zip = 0, $country_code = '') {
979 978
 	$ret = false;
980 979
 
981
-	if ( empty( $zip ) || empty( $country_code ) ) {
980
+	if (empty($zip) || empty($country_code)) {
982 981
 		return $ret;
983 982
 	}
984 983
 
985
-	$country_code = strtoupper( $country_code );
984
+	$country_code = strtoupper($country_code);
986 985
 
987 986
 	$zip_regex = array(
988 987
 		'AD' => 'AD\d{3}',
@@ -1142,11 +1141,11 @@  discard block
 block discarded – undo
1142 1141
 		'ZM' => '\d{5}',
1143 1142
 	);
1144 1143
 
1145
-	if ( ! isset( $zip_regex[ $country_code ] ) || preg_match( '/' . $zip_regex[ $country_code ] . '/i', $zip ) ) {
1144
+	if ( ! isset($zip_regex[$country_code]) || preg_match('/'.$zip_regex[$country_code].'/i', $zip)) {
1146 1145
 		$ret = true;
1147 1146
 	}
1148 1147
 
1149
-	return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code );
1148
+	return apply_filters('give_is_zip_valid', $ret, $zip, $country_code);
1150 1149
 }
1151 1150
 
1152 1151
 
@@ -1160,33 +1159,33 @@  discard block
 block discarded – undo
1160 1159
  *
1161 1160
  * @return bool
1162 1161
  */
1163
-function give_validate_multi_donation_form_level( $valid_data, $data ) {
1162
+function give_validate_multi_donation_form_level($valid_data, $data) {
1164 1163
 	/* @var Give_Donate_Form $form */
1165
-	$form = new Give_Donate_Form( $data['give-form-id'] );
1164
+	$form = new Give_Donate_Form($data['give-form-id']);
1166 1165
 
1167 1166
 	$donation_level_matched = false;
1168 1167
 
1169
-	if ( $form->is_multi_type_donation_form() ) {
1168
+	if ($form->is_multi_type_donation_form()) {
1170 1169
 
1171 1170
 		// Bailout.
1172
-		if ( ! ( $variable_prices = $form->get_prices() ) ) {
1171
+		if ( ! ($variable_prices = $form->get_prices())) {
1173 1172
 			return false;
1174 1173
 		}
1175 1174
 
1176 1175
 		// Sanitize donation amount.
1177
-		$data['give-amount'] = give_maybe_sanitize_amount( $data['give-amount'] );
1176
+		$data['give-amount'] = give_maybe_sanitize_amount($data['give-amount']);
1178 1177
 
1179
-		if ( $data['give-amount'] === give_maybe_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ) ) ) {
1178
+		if ($data['give-amount'] === give_maybe_sanitize_amount(give_get_price_option_amount($data['give-form-id'], $data['give-price-id']))) {
1180 1179
 			return true;
1181 1180
 		}
1182 1181
 
1183 1182
 		// Find correct donation level from all donation levels.
1184
-		foreach ( $variable_prices as $variable_price ) {
1183
+		foreach ($variable_prices as $variable_price) {
1185 1184
 			// Sanitize level amount.
1186
-			$variable_price['_give_amount'] = give_maybe_sanitize_amount( $variable_price['_give_amount'] );
1185
+			$variable_price['_give_amount'] = give_maybe_sanitize_amount($variable_price['_give_amount']);
1187 1186
 
1188 1187
 			// Set first match donation level ID.
1189
-			if ( $data['give-amount'] === $variable_price['_give_amount'] ) {
1188
+			if ($data['give-amount'] === $variable_price['_give_amount']) {
1190 1189
 				$_POST['give-price-id'] = $variable_price['_give_id']['level_id'];
1191 1190
 				$donation_level_matched = true;
1192 1191
 				break;
@@ -1197,19 +1196,19 @@  discard block
 block discarded – undo
1197 1196
 		// If yes then set price id to custom if amount is greater then custom minimum amount (if any).
1198 1197
 		if (
1199 1198
 			! $donation_level_matched
1200
-			&& ( give_is_setting_enabled( give_get_meta( $data['give-form-id'], '_give_custom_amount', true ) ) )
1199
+			&& (give_is_setting_enabled(give_get_meta($data['give-form-id'], '_give_custom_amount', true)))
1201 1200
 		) {
1202 1201
 			// Sanitize custom minimum amount.
1203
-			$custom_minimum_amount = give_maybe_sanitize_amount( give_get_meta( $data['give-form-id'], '_give_custom_amount_minimum', true ) );
1202
+			$custom_minimum_amount = give_maybe_sanitize_amount(give_get_meta($data['give-form-id'], '_give_custom_amount_minimum', true));
1204 1203
 
1205
-			if ( $data['give-amount'] >= $custom_minimum_amount ) {
1204
+			if ($data['give-amount'] >= $custom_minimum_amount) {
1206 1205
 				$_POST['give-price-id'] = 'custom';
1207 1206
 				$donation_level_matched = true;
1208 1207
 			}
1209 1208
 		}
1210 1209
 	}// End if().
1211 1210
 
1212
-	return ( $donation_level_matched ? true : false );
1211
+	return ($donation_level_matched ? true : false);
1213 1212
 }
1214 1213
 
1215
-add_action( 'give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2 );
1214
+add_action('give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2);
Please login to merge, or discard this patch.
includes/actions.php 1 patch
Spacing   +52 added lines, -52 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,14 +25,14 @@  discard block
 block discarded – undo
25 25
  */
26 26
 function give_get_actions() {
27 27
 
28
-	$_get_action = ! empty( $_GET['give_action'] ) ? $_GET['give_action'] : null;
28
+	$_get_action = ! empty($_GET['give_action']) ? $_GET['give_action'] : null;
29 29
 
30 30
 	// Add backward compatibility to give-action param ( $_GET )
31
-	if(  empty( $_get_action ) ) {
32
-		$_get_action = ! empty( $_GET['give-action'] ) ? $_GET['give-action'] : null;
31
+	if (empty($_get_action)) {
32
+		$_get_action = ! empty($_GET['give-action']) ? $_GET['give-action'] : null;
33 33
 	}
34 34
 
35
-	if ( isset( $_get_action ) ) {
35
+	if (isset($_get_action)) {
36 36
 		/**
37 37
 		 * Fires in WordPress init or admin init, when give_action is present in $_GET.
38 38
 		 *
@@ -40,12 +40,12 @@  discard block
 block discarded – undo
40 40
 		 *
41 41
 		 * @param array $_GET Array of HTTP GET variables.
42 42
 		 */
43
-		do_action( "give_{$_get_action}", $_GET );
43
+		do_action("give_{$_get_action}", $_GET);
44 44
 	}
45 45
 
46 46
 }
47 47
 
48
-add_action( 'init', 'give_get_actions' );
48
+add_action('init', 'give_get_actions');
49 49
 
50 50
 /**
51 51
  * Hooks Give actions, when present in the $_POST super global. Every give_action
@@ -58,15 +58,15 @@  discard block
 block discarded – undo
58 58
  */
59 59
 function give_post_actions() {
60 60
 
61
-	$_post_action = ! empty( $_POST['give_action'] ) ? $_POST['give_action'] : null;
61
+	$_post_action = ! empty($_POST['give_action']) ? $_POST['give_action'] : null;
62 62
 
63 63
 
64 64
 	// Add backward compatibility to give-action param ( $_POST ).
65
-	if(  empty( $_post_action ) ) {
66
-		$_post_action = ! empty( $_POST['give-action'] ) ? $_POST['give-action'] : null;
65
+	if (empty($_post_action)) {
66
+		$_post_action = ! empty($_POST['give-action']) ? $_POST['give-action'] : null;
67 67
 	}
68 68
 
69
-	if ( isset( $_post_action ) ) {
69
+	if (isset($_post_action)) {
70 70
 		/**
71 71
 		 * Fires in WordPress init or admin init, when give_action is present in $_POST.
72 72
 		 *
@@ -74,12 +74,12 @@  discard block
 block discarded – undo
74 74
 		 *
75 75
 		 * @param array $_POST Array of HTTP POST variables.
76 76
 		 */
77
-		do_action( "give_{$_post_action}", $_POST );
77
+		do_action("give_{$_post_action}", $_POST);
78 78
 	}
79 79
 
80 80
 }
81 81
 
82
-add_action( 'init', 'give_post_actions' );
82
+add_action('init', 'give_post_actions');
83 83
 
84 84
 /**
85 85
  * Connect WordPress user with Donor.
@@ -89,28 +89,28 @@  discard block
 block discarded – undo
89 89
  * @param  array $user_data User Data
90 90
  * @return void
91 91
  */
92
-function give_connect_donor_to_wpuser( $user_id, $user_data ){
92
+function give_connect_donor_to_wpuser($user_id, $user_data) {
93 93
 	/* @var Give_Donor $donor */
94
-	$donor = new Give_Donor( $user_data['user_email'] );
94
+	$donor = new Give_Donor($user_data['user_email']);
95 95
 
96 96
 	// Validate donor id and check if do nor is already connect to wp user or not.
97
-	if( $donor->id && ! $donor->user_id ) {
97
+	if ($donor->id && ! $donor->user_id) {
98 98
 
99 99
 		// Update donor user_id.
100
-		if( $donor->update( array( 'user_id' => $user_id ) ) ) {
101
-			$donor_note = sprintf( esc_html__( 'WordPress user #%d is connected to #%d', 'give' ), $user_id, $donor->id );
102
-			$donor->add_note( $donor_note );
100
+		if ($donor->update(array('user_id' => $user_id))) {
101
+			$donor_note = sprintf(esc_html__('WordPress user #%d is connected to #%d', 'give'), $user_id, $donor->id);
102
+			$donor->add_note($donor_note);
103 103
 
104 104
 			// Update user_id meta in payments.
105
-			if( ! empty( $donor->payment_ids ) && ( $donations = explode( ',', $donor->payment_ids ) ) ) {
106
-				foreach ( $donations as $donation  ) {
107
-					give_update_meta( $donation, '_give_payment_user_id', $user_id );
105
+			if ( ! empty($donor->payment_ids) && ($donations = explode(',', $donor->payment_ids))) {
106
+				foreach ($donations as $donation) {
107
+					give_update_meta($donation, '_give_payment_user_id', $user_id);
108 108
 				}
109 109
 			}
110 110
 		}
111 111
 	}
112 112
 }
113
-add_action( 'give_insert_user', 'give_connect_donor_to_wpuser', 10, 2 );
113
+add_action('give_insert_user', 'give_connect_donor_to_wpuser', 10, 2);
114 114
 
115 115
 
116 116
 /**
@@ -124,24 +124,24 @@  discard block
 block discarded – undo
124 124
 function give_validate_license_when_site_migrated() {
125 125
 	// Store current site address if not already stored.
126 126
 	$homeurl = home_url();
127
-	if( ! get_option( 'give_site_address_before_migrate' ) ) {
127
+	if ( ! get_option('give_site_address_before_migrate')) {
128 128
 		// Update site address.
129
-		update_option( 'give_site_address_before_migrate', $homeurl );
129
+		update_option('give_site_address_before_migrate', $homeurl);
130 130
 
131 131
 		return;
132 132
 	}
133 133
 
134
-	if( $homeurl !== get_option( 'give_site_address_before_migrate' ) ) {
134
+	if ($homeurl !== get_option('give_site_address_before_migrate')) {
135 135
 		// Immediately run cron.
136
-		wp_schedule_single_event( time() , 'give_validate_license_when_site_migrated' );
136
+		wp_schedule_single_event(time(), 'give_validate_license_when_site_migrated');
137 137
 
138 138
 		// Update site address.
139
-		update_option( 'give_site_address_before_migrate', home_url() );
139
+		update_option('give_site_address_before_migrate', home_url());
140 140
 	}
141 141
 
142 142
 }
143
-add_action( 'init', 'give_validate_license_when_site_migrated' );
144
-add_action( 'admin_init', 'give_validate_license_when_site_migrated' );
143
+add_action('init', 'give_validate_license_when_site_migrated');
144
+add_action('admin_init', 'give_validate_license_when_site_migrated');
145 145
 
146 146
 
147 147
 /**
@@ -150,18 +150,18 @@  discard block
 block discarded – undo
150 150
  * @since 1.8
151 151
  * @param $data
152 152
  */
153
-function give_donor_batch_export_complete( $data ) {
153
+function give_donor_batch_export_complete($data) {
154 154
 	// Remove donor ids cache.
155
-	if(
156
-		isset( $data['class'] )
155
+	if (
156
+		isset($data['class'])
157 157
 		&& 'Give_Batch_Donors_Export' === $data['class']
158
-		&& ! empty( $data['forms'] )
159
-		&& isset( $data['give_export_option']['query_id'] )
158
+		&& ! empty($data['forms'])
159
+		&& isset($data['give_export_option']['query_id'])
160 160
 	) {
161
-		Give_Cache::delete( Give_Cache::get_key( $data['give_export_option']['query_id'] ) );
161
+		Give_Cache::delete(Give_Cache::get_key($data['give_export_option']['query_id']));
162 162
 	}
163 163
 }
164
-add_action('give_file_export_complete', 'give_donor_batch_export_complete' );
164
+add_action('give_file_export_complete', 'give_donor_batch_export_complete');
165 165
 
166 166
 /**
167 167
  * Print css for wordpress setting pages.
@@ -172,12 +172,12 @@  discard block
 block discarded – undo
172 172
 	/* @var WP_Screen $screen */
173 173
 	$screen = get_current_screen();
174 174
 
175
-	if( ! ( $screen instanceof WP_Screen ) ) {
175
+	if ( ! ($screen instanceof WP_Screen)) {
176 176
 		return false;
177 177
 	}
178 178
 
179
-	switch ( true ) {
180
-		case ( 'plugins' === $screen->base || 'plugins-network' === $screen->base ):
179
+	switch (true) {
180
+		case ('plugins' === $screen->base || 'plugins-network' === $screen->base):
181 181
 			?>
182 182
 			<style>
183 183
 				tr.active.update + tr.give-addon-notice-tr td{
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 			<?php
211 211
 	}
212 212
 }
213
-add_action( 'admin_head', 'give_admin_quick_css' );
213
+add_action('admin_head', 'give_admin_quick_css');
214 214
 
215 215
 
216 216
 /**
@@ -223,25 +223,25 @@  discard block
 block discarded – undo
223 223
  *
224 224
  * @return void
225 225
  */
226
-function give_set_donation_levels_max_min_amount( $form_id ) {
226
+function give_set_donation_levels_max_min_amount($form_id) {
227 227
 	if (
228
-		( 'set' === $_POST['_give_price_option'] ) ||
229
-		( in_array( '_give_donation_levels', $_POST ) && count( $_POST['_give_donation_levels'] ) <= 0 ) ||
230
-		! ( $donation_levels_amounts = wp_list_pluck( $_POST['_give_donation_levels'], '_give_amount' ) )
228
+		('set' === $_POST['_give_price_option']) ||
229
+		(in_array('_give_donation_levels', $_POST) && count($_POST['_give_donation_levels']) <= 0) ||
230
+		! ($donation_levels_amounts = wp_list_pluck($_POST['_give_donation_levels'], '_give_amount'))
231 231
 	) {
232 232
 		// Delete old meta.
233
-		give_delete_meta( $form_id, '_give_levels_minimum_amount' );
234
-		give_delete_meta( $form_id, '_give_levels_maximum_amount' );
233
+		give_delete_meta($form_id, '_give_levels_minimum_amount');
234
+		give_delete_meta($form_id, '_give_levels_maximum_amount');
235 235
 
236 236
 		return;
237 237
 	}
238 238
 
239
-	$min_amount = min( $donation_levels_amounts );
240
-	$max_amount = max( $donation_levels_amounts );
239
+	$min_amount = min($donation_levels_amounts);
240
+	$max_amount = max($donation_levels_amounts);
241 241
 
242 242
 	// Set Minimum and Maximum amount for Multi Level Donation Forms
243
-	give_update_meta( $form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount_for_db( $min_amount ) : 0 );
244
-	give_update_meta( $form_id, '_give_levels_maximum_amount', $max_amount? give_sanitize_amount_for_db( $max_amount ) : 0 );
243
+	give_update_meta($form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount_for_db($min_amount) : 0);
244
+	give_update_meta($form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount_for_db($max_amount) : 0);
245 245
 }
246 246
 
247
-add_action( 'give_pre_process_give_forms_meta', 'give_set_donation_levels_max_min_amount', 30 );
248 247
\ No newline at end of file
248
+add_action('give_pre_process_give_forms_meta', 'give_set_donation_levels_max_min_amount', 30);
249 249
\ No newline at end of file
Please login to merge, or discard this patch.
includes/misc-functions.php 1 patch
Spacing   +243 added lines, -243 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,9 +23,9 @@  discard block
 block discarded – undo
23 23
  */
24 24
 function give_is_test_mode() {
25 25
 
26
-	$ret = give_is_setting_enabled( give_get_option( 'test_mode' ) );
26
+	$ret = give_is_setting_enabled(give_get_option('test_mode'));
27 27
 
28
-	return (bool) apply_filters( 'give_is_test_mode', $ret );
28
+	return (bool) apply_filters('give_is_test_mode', $ret);
29 29
 
30 30
 }
31 31
 
@@ -37,9 +37,9 @@  discard block
 block discarded – undo
37 37
  */
38 38
 function give_get_currency() {
39 39
 
40
-	$currency = give_get_option( 'currency', 'USD' );
40
+	$currency = give_get_option('currency', 'USD');
41 41
 
42
-	return apply_filters( 'give_currency', $currency );
42
+	return apply_filters('give_currency', $currency);
43 43
 }
44 44
 
45 45
 /**
@@ -51,9 +51,9 @@  discard block
 block discarded – undo
51 51
  */
52 52
 function give_get_currency_position() {
53 53
 
54
-	$currency_pos = give_get_option( 'currency_position', 'before' );
54
+	$currency_pos = give_get_option('currency_position', 'before');
55 55
 
56
-	return apply_filters( 'give_currency_position', $currency_pos );
56
+	return apply_filters('give_currency_position', $currency_pos);
57 57
 }
58 58
 
59 59
 
@@ -66,39 +66,39 @@  discard block
 block discarded – undo
66 66
 
67 67
 function give_get_currencies() {
68 68
 	$currencies = array(
69
-		'USD'  => __( 'US Dollars ($)', 'give' ),
70
-		'EUR'  => __( 'Euros (€)', 'give' ),
71
-		'GBP'  => __( 'Pounds Sterling (£)', 'give' ),
72
-		'AUD'  => __( 'Australian Dollars ($)', 'give' ),
73
-		'BRL'  => __( 'Brazilian Real (R$)', 'give' ),
74
-		'CAD'  => __( 'Canadian Dollars ($)', 'give' ),
75
-		'CZK'  => __( 'Czech Koruna (Kč)', 'give' ),
76
-		'DKK'  => __( 'Danish Krone (kr.)', 'give' ),
77
-		'HKD'  => __( 'Hong Kong Dollar ($)', 'give' ),
78
-		'HUF'  => __( 'Hungarian Forint (Ft)', 'give' ),
79
-		'ILS'  => __( 'Israeli Shekel (₪)', 'give' ),
80
-		'JPY'  => __( 'Japanese Yen (¥)', 'give' ),
81
-		'MYR'  => __( 'Malaysian Ringgits (RM)', 'give' ),
82
-		'MXN'  => __( 'Mexican Peso ($)', 'give' ),
83
-		'MAD'  => __( 'Moroccan Dirham (&#x2e;&#x62f;&#x2e;&#x645;)', 'give' ),
84
-		'NZD'  => __( 'New Zealand Dollar ($)', 'give' ),
85
-		'NOK'  => __( 'Norwegian Krone (Kr.)', 'give' ),
86
-		'PHP'  => __( 'Philippine Pesos (₱)', 'give' ),
87
-		'PLN'  => __( 'Polish Zloty (zł)', 'give' ),
88
-		'SGD'  => __( 'Singapore Dollar ($)', 'give' ),
89
-		'KRW'  => __( 'South Korean Won (₩)', 'give' ),
90
-		'ZAR'  => __( 'South African Rand (R)', 'give' ),
91
-		'SEK'  => __( 'Swedish Krona (kr)', 'give' ),
92
-		'CHF'  => __( 'Swiss Franc (CHF)', 'give' ),
93
-		'TWD'  => __( 'Taiwan New Dollars (NT$)', 'give' ),
94
-		'THB'  => __( 'Thai Baht (฿)', 'give' ),
95
-		'INR'  => __( 'Indian Rupee (₹)', 'give' ),
96
-		'TRY'  => __( 'Turkish Lira (₺)', 'give' ),
97
-		'RIAL' => __( 'Iranian Rial (﷼)', 'give' ),
98
-		'RUB'  => __( 'Russian Rubles (руб)', 'give' ),
69
+		'USD'  => __('US Dollars ($)', 'give'),
70
+		'EUR'  => __('Euros (€)', 'give'),
71
+		'GBP'  => __('Pounds Sterling (£)', 'give'),
72
+		'AUD'  => __('Australian Dollars ($)', 'give'),
73
+		'BRL'  => __('Brazilian Real (R$)', 'give'),
74
+		'CAD'  => __('Canadian Dollars ($)', 'give'),
75
+		'CZK'  => __('Czech Koruna (Kč)', 'give'),
76
+		'DKK'  => __('Danish Krone (kr.)', 'give'),
77
+		'HKD'  => __('Hong Kong Dollar ($)', 'give'),
78
+		'HUF'  => __('Hungarian Forint (Ft)', 'give'),
79
+		'ILS'  => __('Israeli Shekel (₪)', 'give'),
80
+		'JPY'  => __('Japanese Yen (¥)', 'give'),
81
+		'MYR'  => __('Malaysian Ringgits (RM)', 'give'),
82
+		'MXN'  => __('Mexican Peso ($)', 'give'),
83
+		'MAD'  => __('Moroccan Dirham (&#x2e;&#x62f;&#x2e;&#x645;)', 'give'),
84
+		'NZD'  => __('New Zealand Dollar ($)', 'give'),
85
+		'NOK'  => __('Norwegian Krone (Kr.)', 'give'),
86
+		'PHP'  => __('Philippine Pesos (₱)', 'give'),
87
+		'PLN'  => __('Polish Zloty (zł)', 'give'),
88
+		'SGD'  => __('Singapore Dollar ($)', 'give'),
89
+		'KRW'  => __('South Korean Won (₩)', 'give'),
90
+		'ZAR'  => __('South African Rand (R)', 'give'),
91
+		'SEK'  => __('Swedish Krona (kr)', 'give'),
92
+		'CHF'  => __('Swiss Franc (CHF)', 'give'),
93
+		'TWD'  => __('Taiwan New Dollars (NT$)', 'give'),
94
+		'THB'  => __('Thai Baht (฿)', 'give'),
95
+		'INR'  => __('Indian Rupee (₹)', 'give'),
96
+		'TRY'  => __('Turkish Lira (₺)', 'give'),
97
+		'RIAL' => __('Iranian Rial (﷼)', 'give'),
98
+		'RUB'  => __('Russian Rubles (руб)', 'give'),
99 99
 	);
100 100
 
101
-	return apply_filters( 'give_currencies', $currencies );
101
+	return apply_filters('give_currencies', $currencies);
102 102
 }
103 103
 
104 104
 
@@ -115,12 +115,12 @@  discard block
 block discarded – undo
115 115
  *
116 116
  * @return string           The symbol to use for the currency
117 117
  */
118
-function give_currency_symbol( $currency = '', $decode_currency = false ) {
118
+function give_currency_symbol($currency = '', $decode_currency = false) {
119 119
 
120
-	if ( empty( $currency ) ) {
120
+	if (empty($currency)) {
121 121
 		$currency = give_get_currency();
122 122
 	}
123
-	switch ( $currency ) :
123
+	switch ($currency) :
124 124
 		case 'GBP' :
125 125
 			$symbol = '&pound;';
126 126
 			break;
@@ -198,9 +198,9 @@  discard block
 block discarded – undo
198 198
 			break;
199 199
 	endswitch;
200 200
 
201
-	$symbol = ( ! $decode_currency ? $symbol : html_entity_decode( $symbol ) );
201
+	$symbol = ( ! $decode_currency ? $symbol : html_entity_decode($symbol));
202 202
 
203
-	return apply_filters( 'give_currency_symbol', $symbol, $currency );
203
+	return apply_filters('give_currency_symbol', $symbol, $currency);
204 204
 }
205 205
 
206 206
 
@@ -213,16 +213,16 @@  discard block
 block discarded – undo
213 213
  *
214 214
  * @return string
215 215
  */
216
-function give_get_currency_name( $currency_code ) {
216
+function give_get_currency_name($currency_code) {
217 217
 	$currency_name  = '';
218 218
 	$currency_names = give_get_currencies();
219 219
 
220
-	if ( $currency_code && array_key_exists( $currency_code, $currency_names ) ) {
221
-		$currency_name = explode( '(', $currency_names[ $currency_code ] );
222
-		$currency_name = trim( current( $currency_name ) );
220
+	if ($currency_code && array_key_exists($currency_code, $currency_names)) {
221
+		$currency_name = explode('(', $currency_names[$currency_code]);
222
+		$currency_name = trim(current($currency_name));
223 223
 	}
224 224
 
225
-	return apply_filters( 'give_currency_name', $currency_name, $currency_code );
225
+	return apply_filters('give_currency_name', $currency_name, $currency_code);
226 226
 }
227 227
 
228 228
 
@@ -236,21 +236,21 @@  discard block
 block discarded – undo
236 236
 
237 237
 	global $wp;
238 238
 
239
-	if ( get_option( 'permalink_structure' ) ) {
240
-		$base = trailingslashit( home_url( $wp->request ) );
239
+	if (get_option('permalink_structure')) {
240
+		$base = trailingslashit(home_url($wp->request));
241 241
 	} else {
242
-		$base = add_query_arg( $wp->query_string, '', trailingslashit( home_url( $wp->request ) ) );
243
-		$base = remove_query_arg( array( 'post_type', 'name' ), $base );
242
+		$base = add_query_arg($wp->query_string, '', trailingslashit(home_url($wp->request)));
243
+		$base = remove_query_arg(array('post_type', 'name'), $base);
244 244
 	}
245 245
 
246 246
 	$scheme      = is_ssl() ? 'https' : 'http';
247
-	$current_uri = set_url_scheme( $base, $scheme );
247
+	$current_uri = set_url_scheme($base, $scheme);
248 248
 
249
-	if ( is_front_page() ) {
250
-		$current_uri = home_url( '/' );
249
+	if (is_front_page()) {
250
+		$current_uri = home_url('/');
251 251
 	}
252 252
 
253
-	return apply_filters( 'give_get_current_page_url', $current_uri );
253
+	return apply_filters('give_get_current_page_url', $current_uri);
254 254
 
255 255
 }
256 256
 
@@ -272,15 +272,15 @@  discard block
 block discarded – undo
272 272
 	 */
273 273
 	$gateways = give_get_enabled_payment_gateways();
274 274
 
275
-	if ( count( $gateways ) == 1 && ! isset( $gateways['paypal'] ) && ! isset( $gateways['manual'] ) ) {
275
+	if (count($gateways) == 1 && ! isset($gateways['paypal']) && ! isset($gateways['manual'])) {
276 276
 		$ret = true;
277
-	} elseif ( count( $gateways ) == 1 ) {
277
+	} elseif (count($gateways) == 1) {
278 278
 		$ret = false;
279
-	} elseif ( count( $gateways ) == 2 && isset( $gateways['paypal'] ) && isset( $gateways['manual'] ) ) {
279
+	} elseif (count($gateways) == 2 && isset($gateways['paypal']) && isset($gateways['manual'])) {
280 280
 		$ret = false;
281 281
 	}
282 282
 
283
-	return (bool) apply_filters( 'give_verify_credit_cards', $ret );
283
+	return (bool) apply_filters('give_verify_credit_cards', $ret);
284 284
 }
285 285
 
286 286
 /**
@@ -292,26 +292,26 @@  discard block
 block discarded – undo
292 292
 function give_get_timezone_id() {
293 293
 
294 294
 	// if site timezone string exists, return it.
295
-	if ( $timezone = get_option( 'timezone_string' ) ) {
295
+	if ($timezone = get_option('timezone_string')) {
296 296
 		return $timezone;
297 297
 	}
298 298
 
299 299
 	// get UTC offset, if it isn't set return UTC.
300
-	if ( ! ( $utc_offset = 3600 * get_option( 'gmt_offset', 0 ) ) ) {
300
+	if ( ! ($utc_offset = 3600 * get_option('gmt_offset', 0))) {
301 301
 		return 'UTC';
302 302
 	}
303 303
 
304 304
 	// attempt to guess the timezone string from the UTC offset.
305
-	$timezone = timezone_name_from_abbr( '', $utc_offset );
305
+	$timezone = timezone_name_from_abbr('', $utc_offset);
306 306
 
307 307
 	// last try, guess timezone string manually.
308
-	if ( $timezone === false ) {
308
+	if ($timezone === false) {
309 309
 
310
-		$is_dst = date( 'I' );
310
+		$is_dst = date('I');
311 311
 
312
-		foreach ( timezone_abbreviations_list() as $abbr ) {
313
-			foreach ( $abbr as $city ) {
314
-				if ( $city['dst'] == $is_dst && $city['offset'] == $utc_offset ) {
312
+		foreach (timezone_abbreviations_list() as $abbr) {
313
+			foreach ($abbr as $city) {
314
+				if ($city['dst'] == $is_dst && $city['offset'] == $utc_offset) {
315 315
 					return $city['timezone_id'];
316 316
 				}
317 317
 			}
@@ -335,17 +335,17 @@  discard block
 block discarded – undo
335 335
 
336 336
 	$ip = '127.0.0.1';
337 337
 
338
-	if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
338
+	if ( ! empty($_SERVER['HTTP_CLIENT_IP'])) {
339 339
 		// check ip from share internet
340 340
 		$ip = $_SERVER['HTTP_CLIENT_IP'];
341
-	} elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
341
+	} elseif ( ! empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
342 342
 		// to check ip is pass from proxy
343 343
 		$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
344
-	} elseif ( ! empty( $_SERVER['REMOTE_ADDR'] ) ) {
344
+	} elseif ( ! empty($_SERVER['REMOTE_ADDR'])) {
345 345
 		$ip = $_SERVER['REMOTE_ADDR'];
346 346
 	}
347 347
 
348
-	return apply_filters( 'give_get_ip', $ip );
348
+	return apply_filters('give_get_ip', $ip);
349 349
 }
350 350
 
351 351
 
@@ -360,9 +360,9 @@  discard block
 block discarded – undo
360 360
  *
361 361
  * @uses  Give()->session->set()
362 362
  */
363
-function give_set_purchase_session( $purchase_data = array() ) {
364
-	Give()->session->set( 'give_purchase', $purchase_data );
365
-	Give()->session->set( 'give_email', $purchase_data['user_email'] );
363
+function give_set_purchase_session($purchase_data = array()) {
364
+	Give()->session->set('give_purchase', $purchase_data);
365
+	Give()->session->set('give_email', $purchase_data['user_email']);
366 366
 }
367 367
 
368 368
 /**
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
  * @return mixed array | false
377 377
  */
378 378
 function give_get_purchase_session() {
379
-	return Give()->session->get( 'give_purchase' );
379
+	return Give()->session->get('give_purchase');
380 380
 }
381 381
 
382 382
 /**
@@ -392,40 +392,40 @@  discard block
 block discarded – undo
392 392
  *
393 393
  * @return string
394 394
  */
395
-function give_payment_gateway_donation_summary( $donation_data, $name_and_email = true, $length = 255 ) {
395
+function give_payment_gateway_donation_summary($donation_data, $name_and_email = true, $length = 255) {
396 396
 
397 397
 	$summary = '';
398 398
 
399
-	$form_id = isset( $donation_data['post_data']['give-form-id'] ) ? $donation_data['post_data']['give-form-id'] : '';
399
+	$form_id = isset($donation_data['post_data']['give-form-id']) ? $donation_data['post_data']['give-form-id'] : '';
400 400
 
401 401
 	// Form title.
402
-	if ( isset( $donation_data['post_data']['give-form-title'] ) ) {
402
+	if (isset($donation_data['post_data']['give-form-title'])) {
403 403
 		$summary .= $donation_data['post_data']['give-form-title'];
404 404
 	}
405 405
 	// Form multilevel if applicable.
406
-	if ( isset( $donation_data['post_data']['give-price-id'] ) ) {
407
-		$summary .= ': ' . give_get_price_option_name( $form_id, $donation_data['post_data']['give-price-id'] );
406
+	if (isset($donation_data['post_data']['give-price-id'])) {
407
+		$summary .= ': '.give_get_price_option_name($form_id, $donation_data['post_data']['give-price-id']);
408 408
 	}
409 409
 
410 410
 	// Add Donor's name + email if requested.
411
-	if ( $name_and_email ) {
411
+	if ($name_and_email) {
412 412
 
413 413
 		// First name
414
-		if ( isset( $donation_data['user_info']['first_name'] ) && ! empty( $donation_data['user_info']['first_name'] ) ) {
415
-			$summary .= ' - ' . $donation_data['user_info']['first_name'];
414
+		if (isset($donation_data['user_info']['first_name']) && ! empty($donation_data['user_info']['first_name'])) {
415
+			$summary .= ' - '.$donation_data['user_info']['first_name'];
416 416
 		}
417 417
 
418
-		if ( isset( $donation_data['user_info']['last_name'] ) && ! empty( $donation_data['user_info']['last_name'] ) ) {
419
-			$summary .= ' ' . $donation_data['user_info']['last_name'];
418
+		if (isset($donation_data['user_info']['last_name']) && ! empty($donation_data['user_info']['last_name'])) {
419
+			$summary .= ' '.$donation_data['user_info']['last_name'];
420 420
 		}
421 421
 
422
-		$summary .= ' (' . $donation_data['user_email'] . ')';
422
+		$summary .= ' ('.$donation_data['user_email'].')';
423 423
 	}
424 424
 
425 425
 	// Cut the length
426
-	$summary = substr( $summary, 0, $length );
426
+	$summary = substr($summary, 0, $length);
427 427
 
428
-	return apply_filters( 'give_payment_gateway_donation_summary', $summary );
428
+	return apply_filters('give_payment_gateway_donation_summary', $summary);
429 429
 }
430 430
 
431 431
 
@@ -440,31 +440,31 @@  discard block
 block discarded – undo
440 440
 function give_get_host() {
441 441
 	$host = false;
442 442
 
443
-	if ( defined( 'WPE_APIKEY' ) ) {
443
+	if (defined('WPE_APIKEY')) {
444 444
 		$host = 'WP Engine';
445
-	} elseif ( defined( 'PAGELYBIN' ) ) {
445
+	} elseif (defined('PAGELYBIN')) {
446 446
 		$host = 'Pagely';
447
-	} elseif ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) {
447
+	} elseif (DB_HOST == 'localhost:/tmp/mysql5.sock') {
448 448
 		$host = 'ICDSoft';
449
-	} elseif ( DB_HOST == 'mysqlv5' ) {
449
+	} elseif (DB_HOST == 'mysqlv5') {
450 450
 		$host = 'NetworkSolutions';
451
-	} elseif ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) {
451
+	} elseif (strpos(DB_HOST, 'ipagemysql.com') !== false) {
452 452
 		$host = 'iPage';
453
-	} elseif ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) {
453
+	} elseif (strpos(DB_HOST, 'ipowermysql.com') !== false) {
454 454
 		$host = 'IPower';
455
-	} elseif ( strpos( DB_HOST, '.gridserver.com' ) !== false ) {
455
+	} elseif (strpos(DB_HOST, '.gridserver.com') !== false) {
456 456
 		$host = 'MediaTemple Grid';
457
-	} elseif ( strpos( DB_HOST, '.pair.com' ) !== false ) {
457
+	} elseif (strpos(DB_HOST, '.pair.com') !== false) {
458 458
 		$host = 'pair Networks';
459
-	} elseif ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) {
459
+	} elseif (strpos(DB_HOST, '.stabletransit.com') !== false) {
460 460
 		$host = 'Rackspace Cloud';
461
-	} elseif ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) {
461
+	} elseif (strpos(DB_HOST, '.sysfix.eu') !== false) {
462 462
 		$host = 'SysFix.eu Power Hosting';
463
-	} elseif ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) {
463
+	} elseif (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) {
464 464
 		$host = 'Flywheel';
465 465
 	} else {
466 466
 		// Adding a general fallback for data gathering
467
-		$host = 'DBH: ' . DB_HOST . ', SRV: ' . $_SERVER['SERVER_NAME'];
467
+		$host = 'DBH: '.DB_HOST.', SRV: '.$_SERVER['SERVER_NAME'];
468 468
 	}
469 469
 
470 470
 	return $host;
@@ -480,67 +480,67 @@  discard block
 block discarded – undo
480 480
  *
481 481
  * @return bool true if host matches, false if not
482 482
  */
483
-function give_is_host( $host = false ) {
483
+function give_is_host($host = false) {
484 484
 
485 485
 	$return = false;
486 486
 
487
-	if ( $host ) {
488
-		$host = str_replace( ' ', '', strtolower( $host ) );
487
+	if ($host) {
488
+		$host = str_replace(' ', '', strtolower($host));
489 489
 
490
-		switch ( $host ) {
490
+		switch ($host) {
491 491
 			case 'wpengine':
492
-				if ( defined( 'WPE_APIKEY' ) ) {
492
+				if (defined('WPE_APIKEY')) {
493 493
 					$return = true;
494 494
 				}
495 495
 				break;
496 496
 			case 'pagely':
497
-				if ( defined( 'PAGELYBIN' ) ) {
497
+				if (defined('PAGELYBIN')) {
498 498
 					$return = true;
499 499
 				}
500 500
 				break;
501 501
 			case 'icdsoft':
502
-				if ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) {
502
+				if (DB_HOST == 'localhost:/tmp/mysql5.sock') {
503 503
 					$return = true;
504 504
 				}
505 505
 				break;
506 506
 			case 'networksolutions':
507
-				if ( DB_HOST == 'mysqlv5' ) {
507
+				if (DB_HOST == 'mysqlv5') {
508 508
 					$return = true;
509 509
 				}
510 510
 				break;
511 511
 			case 'ipage':
512
-				if ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) {
512
+				if (strpos(DB_HOST, 'ipagemysql.com') !== false) {
513 513
 					$return = true;
514 514
 				}
515 515
 				break;
516 516
 			case 'ipower':
517
-				if ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) {
517
+				if (strpos(DB_HOST, 'ipowermysql.com') !== false) {
518 518
 					$return = true;
519 519
 				}
520 520
 				break;
521 521
 			case 'mediatemplegrid':
522
-				if ( strpos( DB_HOST, '.gridserver.com' ) !== false ) {
522
+				if (strpos(DB_HOST, '.gridserver.com') !== false) {
523 523
 					$return = true;
524 524
 				}
525 525
 				break;
526 526
 			case 'pairnetworks':
527
-				if ( strpos( DB_HOST, '.pair.com' ) !== false ) {
527
+				if (strpos(DB_HOST, '.pair.com') !== false) {
528 528
 					$return = true;
529 529
 				}
530 530
 				break;
531 531
 			case 'rackspacecloud':
532
-				if ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) {
532
+				if (strpos(DB_HOST, '.stabletransit.com') !== false) {
533 533
 					$return = true;
534 534
 				}
535 535
 				break;
536 536
 			case 'sysfix.eu':
537 537
 			case 'sysfix.eupowerhosting':
538
-				if ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) {
538
+				if (strpos(DB_HOST, '.sysfix.eu') !== false) {
539 539
 					$return = true;
540 540
 				}
541 541
 				break;
542 542
 			case 'flywheel':
543
-				if ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) {
543
+				if (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) {
544 544
 					$return = true;
545 545
 				}
546 546
 				break;
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
  * @param string $replacement Optional. The function that should have been called.
574 574
  * @param array  $backtrace   Optional. Contains stack backtrace of deprecated function.
575 575
  */
576
-function _give_deprecated_function( $function, $version, $replacement = null, $backtrace = null ) {
576
+function _give_deprecated_function($function, $version, $replacement = null, $backtrace = null) {
577 577
 
578 578
 	/**
579 579
 	 * Fires while give deprecated function call occurs.
@@ -586,19 +586,19 @@  discard block
 block discarded – undo
586 586
 	 * @param string $replacement Optional. The function that should have been called.
587 587
 	 * @param string $version     The plugin version that deprecated the function.
588 588
 	 */
589
-	do_action( 'give_deprecated_function_run', $function, $replacement, $version );
589
+	do_action('give_deprecated_function_run', $function, $replacement, $version);
590 590
 
591
-	$show_errors = current_user_can( 'manage_options' );
591
+	$show_errors = current_user_can('manage_options');
592 592
 
593 593
 	// Allow plugin to filter the output error trigger.
594
-	if ( WP_DEBUG && apply_filters( 'give_deprecated_function_trigger_error', $show_errors ) ) {
595
-		if ( ! is_null( $replacement ) ) {
596
-			trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give' ), $function, $version, $replacement ) );
597
-			trigger_error( print_r( $backtrace, 1 ) ); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine.
594
+	if (WP_DEBUG && apply_filters('give_deprecated_function_trigger_error', $show_errors)) {
595
+		if ( ! is_null($replacement)) {
596
+			trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give'), $function, $version, $replacement));
597
+			trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine.
598 598
 			// Alternatively we could dump this to a file.
599 599
 		} else {
600
-			trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give' ), $function, $version ) );
601
-			trigger_error( print_r( $backtrace, 1 ) );// Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine.
600
+			trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give'), $function, $version));
601
+			trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine.
602 602
 			// Alternatively we could dump this to a file.
603 603
 		}
604 604
 	}
@@ -612,8 +612,8 @@  discard block
 block discarded – undo
612 612
  * @return string $post_id
613 613
  */
614 614
 function give_get_admin_post_id() {
615
-	$post_id = isset( $_GET['post'] ) ? $_GET['post'] : null;
616
-	if ( ! $post_id && isset( $_POST['post_id'] ) ) {
615
+	$post_id = isset($_GET['post']) ? $_GET['post'] : null;
616
+	if ( ! $post_id && isset($_POST['post_id'])) {
617 617
 		$post_id = $_POST['post_id'];
618 618
 	}
619 619
 
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
  * @return string Arg separator output
628 628
  */
629 629
 function give_get_php_arg_separator_output() {
630
-	return ini_get( 'arg_separator.output' );
630
+	return ini_get('arg_separator.output');
631 631
 }
632 632
 
633 633
 
@@ -642,10 +642,10 @@  discard block
 block discarded – undo
642 642
  *
643 643
  * @return string Short month name
644 644
  */
645
-function give_month_num_to_name( $n ) {
646
-	$timestamp = mktime( 0, 0, 0, $n, 1, 2005 );
645
+function give_month_num_to_name($n) {
646
+	$timestamp = mktime(0, 0, 0, $n, 1, 2005);
647 647
 
648
-	return date_i18n( 'M', $timestamp );
648
+	return date_i18n('M', $timestamp);
649 649
 }
650 650
 
651 651
 
@@ -658,10 +658,10 @@  discard block
 block discarded – undo
658 658
  *
659 659
  * @return bool Whether or not function is disabled.
660 660
  */
661
-function give_is_func_disabled( $function ) {
662
-	$disabled = explode( ',', ini_get( 'disable_functions' ) );
661
+function give_is_func_disabled($function) {
662
+	$disabled = explode(',', ini_get('disable_functions'));
663 663
 
664
-	return in_array( $function, $disabled );
664
+	return in_array($function, $disabled);
665 665
 }
666 666
 
667 667
 
@@ -673,7 +673,7 @@  discard block
 block discarded – undo
673 673
 function give_get_newsletter() {
674 674
 	?>
675 675
 
676
-	<p class="newsletter-intro"><?php esc_html_e( 'Be sure to sign up for the Give newsletter below to stay informed of important updates and news.', 'give' ); ?></p>
676
+	<p class="newsletter-intro"><?php esc_html_e('Be sure to sign up for the Give newsletter below to stay informed of important updates and news.', 'give'); ?></p>
677 677
 
678 678
 	<div class="give-newsletter-form-wrap">
679 679
 
@@ -681,33 +681,33 @@  discard block
 block discarded – undo
681 681
 		      method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate"
682 682
 		      target="_blank" novalidate>
683 683
 			<div class="give-newsletter-confirmation">
684
-				<p><?php esc_html_e( 'Thanks for Subscribing!', 'give' ); ?> :)</p>
684
+				<p><?php esc_html_e('Thanks for Subscribing!', 'give'); ?> :)</p>
685 685
 			</div>
686 686
 
687 687
 			<table class="form-table give-newsletter-form">
688 688
 				<tr valign="middle">
689 689
 					<td>
690 690
 						<label for="mce-EMAIL"
691
-						       class="screen-reader-text"><?php esc_html_e( 'Email Address (required)', 'give' ); ?></label>
691
+						       class="screen-reader-text"><?php esc_html_e('Email Address (required)', 'give'); ?></label>
692 692
 						<input type="email" name="EMAIL" id="mce-EMAIL"
693
-						       placeholder="<?php esc_attr_e( 'Email Address (required)', 'give' ); ?>"
693
+						       placeholder="<?php esc_attr_e('Email Address (required)', 'give'); ?>"
694 694
 						       class="required email" value="">
695 695
 					</td>
696 696
 					<td>
697 697
 						<label for="mce-FNAME"
698
-						       class="screen-reader-text"><?php esc_html_e( 'First Name', 'give' ); ?></label>
698
+						       class="screen-reader-text"><?php esc_html_e('First Name', 'give'); ?></label>
699 699
 						<input type="text" name="FNAME" id="mce-FNAME"
700
-						       placeholder="<?php esc_attr_e( 'First Name', 'give' ); ?>" class="" value="">
700
+						       placeholder="<?php esc_attr_e('First Name', 'give'); ?>" class="" value="">
701 701
 					</td>
702 702
 					<td>
703 703
 						<label for="mce-LNAME"
704
-						       class="screen-reader-text"><?php esc_html_e( 'Last Name', 'give' ); ?></label>
704
+						       class="screen-reader-text"><?php esc_html_e('Last Name', 'give'); ?></label>
705 705
 						<input type="text" name="LNAME" id="mce-LNAME"
706
-						       placeholder="<?php esc_attr_e( 'Last Name', 'give' ); ?>" class="" value="">
706
+						       placeholder="<?php esc_attr_e('Last Name', 'give'); ?>" class="" value="">
707 707
 					</td>
708 708
 					<td>
709 709
 						<input type="submit" name="subscribe" id="mc-embedded-subscribe" class="button"
710
-						       value="<?php esc_attr_e( 'Subscribe', 'give' ); ?>">
710
+						       value="<?php esc_attr_e('Subscribe', 'give'); ?>">
711 711
 					</td>
712 712
 				</tr>
713 713
 			</table>
@@ -759,7 +759,7 @@  discard block
 block discarded – undo
759 759
  *
760 760
  * @return string
761 761
  */
762
-function give_svg_icons( $icon ) {
762
+function give_svg_icons($icon) {
763 763
 
764 764
 	// Store your SVGs in an associative array
765 765
 	$svgs = array(
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
 	);
772 772
 
773 773
 	// Return the chosen icon's SVG string
774
-	return $svgs[ $icon ];
774
+	return $svgs[$icon];
775 775
 }
776 776
 
777 777
 /**
@@ -783,15 +783,15 @@  discard block
 block discarded – undo
783 783
  *
784 784
  * @return mixed
785 785
  */
786
-function modify_nav_menu_meta_box_object( $post_type ) {
787
-	if ( isset( $post_type->name ) && $post_type->name == 'give_forms' ) {
788
-		$post_type->labels->name = esc_html__( 'Donation Forms', 'give' );
786
+function modify_nav_menu_meta_box_object($post_type) {
787
+	if (isset($post_type->name) && $post_type->name == 'give_forms') {
788
+		$post_type->labels->name = esc_html__('Donation Forms', 'give');
789 789
 	}
790 790
 
791 791
 	return $post_type;
792 792
 }
793 793
 
794
-add_filter( 'nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object' );
794
+add_filter('nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object');
795 795
 
796 796
 /**
797 797
  * Enable 'Donation Form' meta enabled by default on Menu page.
@@ -801,22 +801,22 @@  discard block
 block discarded – undo
801 801
 function give_nav_donation_metabox_enabled() {
802 802
 
803 803
 	// Return false, if it fails to retrieve hidden meta box list and is not admin.
804
-	if ( ( ! $hidden_meta_boxes = get_user_option( 'metaboxhidden_nav-menus' ) ) || ! is_admin() ) {
804
+	if (( ! $hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus')) || ! is_admin()) {
805 805
 		return false;
806 806
 	}
807 807
 
808 808
 	// Return false, In case, we don't find 'Donation Form' in hidden meta box list.
809
-	if ( ! in_array( 'add-post-type-give_forms', $hidden_meta_boxes, true ) ) {
809
+	if ( ! in_array('add-post-type-give_forms', $hidden_meta_boxes, true)) {
810 810
 		return false;
811 811
 	}
812 812
 
813 813
 	// Exclude 'Donation Form' value from hidden meta box's list.
814
-	$hidden_meta_boxes = array_diff( $hidden_meta_boxes, array( 'add-post-type-give_forms' ) );
814
+	$hidden_meta_boxes = array_diff($hidden_meta_boxes, array('add-post-type-give_forms'));
815 815
 
816 816
 	// Get current user ID.
817 817
 	$user = wp_get_current_user();
818 818
 
819
-	update_user_option( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true );
819
+	update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true);
820 820
 }
821 821
 
822 822
 /**
@@ -830,7 +830,7 @@  discard block
 block discarded – undo
830 830
  * @license    https://opensource.org/licenses/MIT MIT
831 831
  */
832 832
 
833
-if ( ! function_exists( 'array_column' ) ) {
833
+if ( ! function_exists('array_column')) {
834 834
 	/**
835 835
 	 * Returns the values from a single column of the input array, identified by
836 836
 	 * the $columnKey.
@@ -849,53 +849,53 @@  discard block
 block discarded – undo
849 849
 	 *
850 850
 	 * @return array
851 851
 	 */
852
-	function array_column( $input = null, $columnKey = null, $indexKey = null ) {
852
+	function array_column($input = null, $columnKey = null, $indexKey = null) {
853 853
 		// Using func_get_args() in order to check for proper number of
854 854
 		// parameters and trigger errors exactly as the built-in array_column()
855 855
 		// does in PHP 5.5.
856 856
 		$argc   = func_num_args();
857 857
 		$params = func_get_args();
858 858
 
859
-		if ( $argc < 2 ) {
860
-			trigger_error( sprintf( esc_html__( 'array_column() expects at least 2 parameters, %s given.', 'give' ), $argc ), E_USER_WARNING );
859
+		if ($argc < 2) {
860
+			trigger_error(sprintf(esc_html__('array_column() expects at least 2 parameters, %s given.', 'give'), $argc), E_USER_WARNING);
861 861
 
862 862
 			return null;
863 863
 		}
864 864
 
865
-		if ( ! is_array( $params[0] ) ) {
866
-			trigger_error( sprintf( esc_html__( 'array_column() expects parameter 1 to be array, %s given.', 'give' ), gettype( $params[0] ) ), E_USER_WARNING );
865
+		if ( ! is_array($params[0])) {
866
+			trigger_error(sprintf(esc_html__('array_column() expects parameter 1 to be array, %s given.', 'give'), gettype($params[0])), E_USER_WARNING);
867 867
 
868 868
 			return null;
869 869
 		}
870 870
 
871
-		if ( ! is_int( $params[1] )
872
-		     && ! is_float( $params[1] )
873
-		     && ! is_string( $params[1] )
871
+		if ( ! is_int($params[1])
872
+		     && ! is_float($params[1])
873
+		     && ! is_string($params[1])
874 874
 		     && $params[1] !== null
875
-		     && ! ( is_object( $params[1] ) && method_exists( $params[1], '__toString' ) )
875
+		     && ! (is_object($params[1]) && method_exists($params[1], '__toString'))
876 876
 		) {
877
-			trigger_error( esc_html__( 'array_column(): The column key should be either a string or an integer.', 'give' ), E_USER_WARNING );
877
+			trigger_error(esc_html__('array_column(): The column key should be either a string or an integer.', 'give'), E_USER_WARNING);
878 878
 
879 879
 			return false;
880 880
 		}
881 881
 
882
-		if ( isset( $params[2] )
883
-		     && ! is_int( $params[2] )
884
-		     && ! is_float( $params[2] )
885
-		     && ! is_string( $params[2] )
886
-		     && ! ( is_object( $params[2] ) && method_exists( $params[2], '__toString' ) )
882
+		if (isset($params[2])
883
+		     && ! is_int($params[2])
884
+		     && ! is_float($params[2])
885
+		     && ! is_string($params[2])
886
+		     && ! (is_object($params[2]) && method_exists($params[2], '__toString'))
887 887
 		) {
888
-			trigger_error( esc_html__( 'array_column(): The index key should be either a string or an integer.', 'give' ), E_USER_WARNING );
888
+			trigger_error(esc_html__('array_column(): The index key should be either a string or an integer.', 'give'), E_USER_WARNING);
889 889
 
890 890
 			return false;
891 891
 		}
892 892
 
893 893
 		$paramsInput     = $params[0];
894
-		$paramsColumnKey = ( $params[1] !== null ) ? (string) $params[1] : null;
894
+		$paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null;
895 895
 
896 896
 		$paramsIndexKey = null;
897
-		if ( isset( $params[2] ) ) {
898
-			if ( is_float( $params[2] ) || is_int( $params[2] ) ) {
897
+		if (isset($params[2])) {
898
+			if (is_float($params[2]) || is_int($params[2])) {
899 899
 				$paramsIndexKey = (int) $params[2];
900 900
 			} else {
901 901
 				$paramsIndexKey = (string) $params[2];
@@ -904,26 +904,26 @@  discard block
 block discarded – undo
904 904
 
905 905
 		$resultArray = array();
906 906
 
907
-		foreach ( $paramsInput as $row ) {
907
+		foreach ($paramsInput as $row) {
908 908
 			$key    = $value = null;
909 909
 			$keySet = $valueSet = false;
910 910
 
911
-			if ( $paramsIndexKey !== null && array_key_exists( $paramsIndexKey, $row ) ) {
911
+			if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) {
912 912
 				$keySet = true;
913
-				$key    = (string) $row[ $paramsIndexKey ];
913
+				$key    = (string) $row[$paramsIndexKey];
914 914
 			}
915 915
 
916
-			if ( $paramsColumnKey === null ) {
916
+			if ($paramsColumnKey === null) {
917 917
 				$valueSet = true;
918 918
 				$value    = $row;
919
-			} elseif ( is_array( $row ) && array_key_exists( $paramsColumnKey, $row ) ) {
919
+			} elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) {
920 920
 				$valueSet = true;
921
-				$value    = $row[ $paramsColumnKey ];
921
+				$value    = $row[$paramsColumnKey];
922 922
 			}
923 923
 
924
-			if ( $valueSet ) {
925
-				if ( $keySet ) {
926
-					$resultArray[ $key ] = $value;
924
+			if ($valueSet) {
925
+				if ($keySet) {
926
+					$resultArray[$key] = $value;
927 927
 				} else {
928 928
 					$resultArray[] = $value;
929 929
 				}
@@ -943,40 +943,40 @@  discard block
 block discarded – undo
943 943
  *
944 944
  * @return bool Whether the receipt is visible or not.
945 945
  */
946
-function give_can_view_receipt( $payment_key = '' ) {
946
+function give_can_view_receipt($payment_key = '') {
947 947
 
948 948
 	$return = false;
949 949
 
950
-	if ( empty( $payment_key ) ) {
950
+	if (empty($payment_key)) {
951 951
 		return $return;
952 952
 	}
953 953
 
954 954
 	global $give_receipt_args;
955 955
 
956
-	$give_receipt_args['id'] = give_get_purchase_id_by_key( $payment_key );
956
+	$give_receipt_args['id'] = give_get_purchase_id_by_key($payment_key);
957 957
 
958
-	$user_id = (int) give_get_payment_user_id( $give_receipt_args['id'] );
958
+	$user_id = (int) give_get_payment_user_id($give_receipt_args['id']);
959 959
 
960
-	$payment_meta = give_get_payment_meta( $give_receipt_args['id'] );
960
+	$payment_meta = give_get_payment_meta($give_receipt_args['id']);
961 961
 
962
-	if ( is_user_logged_in() ) {
963
-		if ( $user_id === (int) get_current_user_id() ) {
962
+	if (is_user_logged_in()) {
963
+		if ($user_id === (int) get_current_user_id()) {
964 964
 			$return = true;
965
-		} elseif ( wp_get_current_user()->user_email === give_get_payment_user_email( $give_receipt_args['id'] ) ) {
965
+		} elseif (wp_get_current_user()->user_email === give_get_payment_user_email($give_receipt_args['id'])) {
966 966
 			$return = true;
967
-		} elseif ( current_user_can( 'view_give_sensitive_data' ) ) {
967
+		} elseif (current_user_can('view_give_sensitive_data')) {
968 968
 			$return = true;
969 969
 		}
970 970
 	}
971 971
 
972 972
 	$session = give_get_purchase_session();
973
-	if ( ! empty( $session ) && ! is_user_logged_in() ) {
974
-		if ( $session['purchase_key'] === $payment_meta['key'] ) {
973
+	if ( ! empty($session) && ! is_user_logged_in()) {
974
+		if ($session['purchase_key'] === $payment_meta['key']) {
975 975
 			$return = true;
976 976
 		}
977 977
 	}
978 978
 
979
-	return (bool) apply_filters( 'give_can_view_receipt', $return, $payment_key );
979
+	return (bool) apply_filters('give_can_view_receipt', $return, $payment_key);
980 980
 
981 981
 }
982 982
 
@@ -985,7 +985,7 @@  discard block
 block discarded – undo
985 985
  *
986 986
  * Fallback in case the calendar extension is not loaded in PHP; Only supports Gregorian calendar
987 987
  */
988
-if ( ! function_exists( 'cal_days_in_month' ) ) {
988
+if ( ! function_exists('cal_days_in_month')) {
989 989
 	/**
990 990
 	 * cal_days_in_month
991 991
 	 *
@@ -995,8 +995,8 @@  discard block
 block discarded – undo
995 995
 	 *
996 996
 	 * @return bool|string
997 997
 	 */
998
-	function cal_days_in_month( $calendar, $month, $year ) {
999
-		return date( 't', mktime( 0, 0, 0, $month, 1, $year ) );
998
+	function cal_days_in_month($calendar, $month, $year) {
999
+		return date('t', mktime(0, 0, 0, $month, 1, $year));
1000 1000
 	}
1001 1001
 }
1002 1002
 
@@ -1015,42 +1015,42 @@  discard block
 block discarded – undo
1015 1015
  */
1016 1016
 function give_get_plugins() {
1017 1017
 	$plugins             = get_plugins();
1018
-	$active_plugin_paths = (array) get_option( 'active_plugins', array() );
1018
+	$active_plugin_paths = (array) get_option('active_plugins', array());
1019 1019
 
1020
-	if ( is_multisite() ) {
1021
-		$network_activated_plugin_paths = array_keys( get_site_option( 'active_sitewide_plugins', array() ) );
1022
-		$active_plugin_paths            = array_merge( $active_plugin_paths, $network_activated_plugin_paths );
1020
+	if (is_multisite()) {
1021
+		$network_activated_plugin_paths = array_keys(get_site_option('active_sitewide_plugins', array()));
1022
+		$active_plugin_paths            = array_merge($active_plugin_paths, $network_activated_plugin_paths);
1023 1023
 	}
1024 1024
 
1025
-	foreach ( $plugins as $plugin_path => $plugin_data ) {
1025
+	foreach ($plugins as $plugin_path => $plugin_data) {
1026 1026
 		// Is plugin active?
1027
-		if ( in_array( $plugin_path, $active_plugin_paths ) ) {
1028
-			$plugins[ $plugin_path ]['Status'] = 'active';
1027
+		if (in_array($plugin_path, $active_plugin_paths)) {
1028
+			$plugins[$plugin_path]['Status'] = 'active';
1029 1029
 		} else {
1030
-			$plugins[ $plugin_path ]['Status'] = 'inactive';
1030
+			$plugins[$plugin_path]['Status'] = 'inactive';
1031 1031
 		}
1032 1032
 
1033
-		$dirname = strtolower( dirname( $plugin_path ) );
1033
+		$dirname = strtolower(dirname($plugin_path));
1034 1034
 
1035 1035
 		// Is plugin a Give add-on by WordImpress?
1036
-		if ( strstr( $dirname, 'give-' ) && strstr( $plugin_data['AuthorURI'], 'wordimpress.com' ) ) {
1036
+		if (strstr($dirname, 'give-') && strstr($plugin_data['AuthorURI'], 'wordimpress.com')) {
1037 1037
 			// Plugin is a Give-addon.
1038
-			$plugins[ $plugin_path ]['Type'] = 'add-on';
1038
+			$plugins[$plugin_path]['Type'] = 'add-on';
1039 1039
 
1040 1040
 			// Get license info from database.
1041
-			$plugin_name    = str_replace( 'Give - ', '', $plugin_data['Name'] );
1042
-			$db_option      = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $plugin_name ) ) ) . '_license_active';
1043
-			$license_active = get_option( $db_option );
1041
+			$plugin_name    = str_replace('Give - ', '', $plugin_data['Name']);
1042
+			$db_option      = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($plugin_name))).'_license_active';
1043
+			$license_active = get_option($db_option);
1044 1044
 
1045 1045
 			// Does a valid license exist?
1046
-			if ( ! empty( $license_active ) && 'valid' === $license_active->license ) {
1047
-				$plugins[ $plugin_path ]['License'] = true;
1046
+			if ( ! empty($license_active) && 'valid' === $license_active->license) {
1047
+				$plugins[$plugin_path]['License'] = true;
1048 1048
 			} else {
1049
-				$plugins[ $plugin_path ]['License'] = false;
1049
+				$plugins[$plugin_path]['License'] = false;
1050 1050
 			}
1051 1051
 		} else {
1052 1052
 			// Plugin is not a Give add-on.
1053
-			$plugins[ $plugin_path ]['Type'] = 'other';
1053
+			$plugins[$plugin_path]['Type'] = 'other';
1054 1054
 		}
1055 1055
 	}
1056 1056
 
@@ -1067,16 +1067,16 @@  discard block
 block discarded – undo
1067 1067
  *
1068 1068
  * @return bool
1069 1069
  */
1070
-function give_is_terms_enabled( $form_id ) {
1071
-	$form_option = give_get_meta( $form_id, '_give_terms_option', true );
1070
+function give_is_terms_enabled($form_id) {
1071
+	$form_option = give_get_meta($form_id, '_give_terms_option', true);
1072 1072
 
1073 1073
 	if (
1074
-		give_is_setting_enabled( $form_option, 'global' )
1075
-		&& give_is_setting_enabled( give_get_option( 'terms' ) )
1074
+		give_is_setting_enabled($form_option, 'global')
1075
+		&& give_is_setting_enabled(give_get_option('terms'))
1076 1076
 	) {
1077 1077
 		return true;
1078 1078
 
1079
-	} elseif ( give_is_setting_enabled( $form_option ) ) {
1079
+	} elseif (give_is_setting_enabled($form_option)) {
1080 1080
 		return true;
1081 1081
 
1082 1082
 	} else {
@@ -1100,9 +1100,9 @@  discard block
 block discarded – undo
1100 1100
  *
1101 1101
  * @return WP_Error|bool
1102 1102
  */
1103
-function give_delete_donation_stats( $date_range = '', $args = array() ) {
1103
+function give_delete_donation_stats($date_range = '', $args = array()) {
1104 1104
 	// Delete all cache.
1105
-	$status = Give_Cache::delete( Give_Cache::get_options_like( 'give_stats' ) );
1105
+	$status = Give_Cache::delete(Give_Cache::get_options_like('give_stats'));
1106 1106
 
1107 1107
 	/**
1108 1108
 	 * Fire the action when donation stats delete.
@@ -1112,7 +1112,7 @@  discard block
 block discarded – undo
1112 1112
 	 * @param string|array $date_range
1113 1113
 	 * @param array        $args
1114 1114
 	 */
1115
-	do_action( 'give_delete_donation_stats', $status, $date_range, $args );
1115
+	do_action('give_delete_donation_stats', $status, $date_range, $args);
1116 1116
 
1117 1117
 	return $status;
1118 1118
 }
@@ -1130,7 +1130,7 @@  discard block
 block discarded – undo
1130 1130
  *
1131 1131
  * @return mixed
1132 1132
  */
1133
-function give_get_meta( $id, $meta_key, $single = false, $default = false ) {
1133
+function give_get_meta($id, $meta_key, $single = false, $default = false) {
1134 1134
 	/**
1135 1135
 	 * Filter the meta value
1136 1136
 	 *
@@ -1138,14 +1138,14 @@  discard block
 block discarded – undo
1138 1138
 	 */
1139 1139
 	$meta_value = apply_filters(
1140 1140
 		'give_get_meta',
1141
-		get_post_meta( $id, $meta_key, $single ),
1141
+		get_post_meta($id, $meta_key, $single),
1142 1142
 		$id,
1143 1143
 		$meta_key,
1144 1144
 		$default
1145 1145
 	);
1146 1146
 
1147 1147
 	if (
1148
-		( empty( $meta_key ) || empty( $meta_value ) )
1148
+		(empty($meta_key) || empty($meta_value))
1149 1149
 		&& $default
1150 1150
 	) {
1151 1151
 		$meta_value = $default;
@@ -1166,15 +1166,15 @@  discard block
 block discarded – undo
1166 1166
  *
1167 1167
  * @return mixed
1168 1168
  */
1169
-function give_update_meta( $id, $meta_key, $meta_value, $prev_value = '' ) {
1170
-	$status = update_post_meta( $id, $meta_key, $meta_value, $prev_value );
1169
+function give_update_meta($id, $meta_key, $meta_value, $prev_value = '') {
1170
+	$status = update_post_meta($id, $meta_key, $meta_value, $prev_value);
1171 1171
 
1172 1172
 	/**
1173 1173
 	 * Filter the meta value update status
1174 1174
 	 *
1175 1175
 	 * @since 1.8.8
1176 1176
 	 */
1177
-	return apply_filters( 'give_update_meta', $status, $id, $meta_key, $meta_value );
1177
+	return apply_filters('give_update_meta', $status, $id, $meta_key, $meta_value);
1178 1178
 }
1179 1179
 
1180 1180
 /**
@@ -1188,15 +1188,15 @@  discard block
 block discarded – undo
1188 1188
  *
1189 1189
  * @return mixed
1190 1190
  */
1191
-function give_delete_meta( $id, $meta_key, $meta_value = '' ) {
1192
-	$status = delete_post_meta( $id, $meta_key, $meta_value );
1191
+function give_delete_meta($id, $meta_key, $meta_value = '') {
1192
+	$status = delete_post_meta($id, $meta_key, $meta_value);
1193 1193
 
1194 1194
 	/**
1195 1195
 	 * Filter the meta value delete status
1196 1196
 	 *
1197 1197
 	 * @since 1.8.8
1198 1198
 	 */
1199
-	return apply_filters( 'give_delete_meta', $status, $id, $meta_key, $meta_value );
1199
+	return apply_filters('give_delete_meta', $status, $id, $meta_key, $meta_value);
1200 1200
 }
1201 1201
 
1202 1202
 /**
@@ -1208,15 +1208,15 @@  discard block
 block discarded – undo
1208 1208
  *
1209 1209
  * @return bool                   If the action has been added to the completed actions array
1210 1210
  */
1211
-function give_has_upgrade_completed( $upgrade_action = '' ) {
1211
+function give_has_upgrade_completed($upgrade_action = '') {
1212 1212
 
1213
-	if ( empty( $upgrade_action ) ) {
1213
+	if (empty($upgrade_action)) {
1214 1214
 		return false;
1215 1215
 	}
1216 1216
 
1217 1217
 	$completed_upgrades = give_get_completed_upgrades();
1218 1218
 
1219
-	return in_array( $upgrade_action, $completed_upgrades );
1219
+	return in_array($upgrade_action, $completed_upgrades);
1220 1220
 
1221 1221
 }
1222 1222
 
@@ -1228,8 +1228,8 @@  discard block
 block discarded – undo
1228 1228
  * @return mixed   When nothing to resume returns false, otherwise starts the upgrade where it left off
1229 1229
  */
1230 1230
 function give_maybe_resume_upgrade() {
1231
-	$doing_upgrade = get_option( 'give_doing_upgrade', false );
1232
-	if ( empty( $doing_upgrade ) ) {
1231
+	$doing_upgrade = get_option('give_doing_upgrade', false);
1232
+	if (empty($doing_upgrade)) {
1233 1233
 		return false;
1234 1234
 	}
1235 1235
 
@@ -1245,9 +1245,9 @@  discard block
 block discarded – undo
1245 1245
  *
1246 1246
  * @return bool                   If the function was successfully added
1247 1247
  */
1248
-function give_set_upgrade_complete( $upgrade_action = '' ) {
1248
+function give_set_upgrade_complete($upgrade_action = '') {
1249 1249
 
1250
-	if ( empty( $upgrade_action ) ) {
1250
+	if (empty($upgrade_action)) {
1251 1251
 		return false;
1252 1252
 	}
1253 1253
 
@@ -1255,16 +1255,16 @@  discard block
 block discarded – undo
1255 1255
 	$completed_upgrades[] = $upgrade_action;
1256 1256
 
1257 1257
 	// Remove any blanks, and only show uniques.
1258
-	$completed_upgrades = array_unique( array_values( $completed_upgrades ) );
1258
+	$completed_upgrades = array_unique(array_values($completed_upgrades));
1259 1259
 
1260 1260
 	/**
1261 1261
 	 * Fire the action when any upgrade set to complete.
1262 1262
 	 *
1263 1263
 	 * @since 1.8.12
1264 1264
 	 */
1265
-	do_action( 'give_set_upgrade_completed', $upgrade_action, $completed_upgrades );
1265
+	do_action('give_set_upgrade_completed', $upgrade_action, $completed_upgrades);
1266 1266
 
1267
-	return update_option( 'give_completed_upgrades', $completed_upgrades );
1267
+	return update_option('give_completed_upgrades', $completed_upgrades);
1268 1268
 }
1269 1269
 
1270 1270
 /**
@@ -1275,7 +1275,7 @@  discard block
 block discarded – undo
1275 1275
  */
1276 1276
 function give_get_completed_upgrades() {
1277 1277
 
1278
-	return (array) get_option( 'give_completed_upgrades' );
1278
+	return (array) get_option('give_completed_upgrades');
1279 1279
 
1280 1280
 }
1281 1281
 
Please login to merge, or discard this patch.
includes/user-functions.php 1 patch
Spacing   +143 added lines, -143 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
 
@@ -30,54 +30,54 @@  discard block
 block discarded – undo
30 30
  *
31 31
  * @return bool|array List of all user donations.
32 32
  */
33
-function give_get_users_donations( $user = 0, $number = 20, $pagination = false, $status = 'complete' ) {
33
+function give_get_users_donations($user = 0, $number = 20, $pagination = false, $status = 'complete') {
34 34
 
35
-	if ( empty( $user ) ) {
35
+	if (empty($user)) {
36 36
 		$user = get_current_user_id();
37 37
 	}
38 38
 
39
-	if ( 0 === $user && ! Give()->email_access->token_exists ) {
39
+	if (0 === $user && ! Give()->email_access->token_exists) {
40 40
 		return false;
41 41
 	}
42 42
 
43 43
 	$status = $status === 'complete' ? 'publish' : $status;
44 44
 	$paged = 1;
45 45
 
46
-	if ( $pagination ) {
47
-		if ( get_query_var( 'paged' ) ) {
48
-			$paged = get_query_var( 'paged' );
49
-		} elseif ( get_query_var( 'page' ) ) {
50
-			$paged = get_query_var( 'page' );
46
+	if ($pagination) {
47
+		if (get_query_var('paged')) {
48
+			$paged = get_query_var('paged');
49
+		} elseif (get_query_var('page')) {
50
+			$paged = get_query_var('page');
51 51
 		}
52 52
 	}
53 53
 
54
-	$args = apply_filters( 'give_get_users_donations_args', array(
54
+	$args = apply_filters('give_get_users_donations_args', array(
55 55
 		'user'    => $user,
56 56
 		'number'  => $number,
57 57
 		'status'  => $status,
58 58
 		'orderby' => 'date',
59
-	) );
59
+	));
60 60
 
61
-	if ( $pagination ) {
61
+	if ($pagination) {
62 62
 		$args['page'] = $paged;
63 63
 	} else {
64 64
 		$args['nopaging'] = true;
65 65
 	}
66 66
 
67
-	$by_user_id = is_numeric( $user ) ? true : false;
68
-	$donor   = new Give_Donor( $user, $by_user_id );
67
+	$by_user_id = is_numeric($user) ? true : false;
68
+	$donor = new Give_Donor($user, $by_user_id);
69 69
 
70
-	if ( ! empty( $donor->payment_ids ) ) {
70
+	if ( ! empty($donor->payment_ids)) {
71 71
 
72
-		unset( $args['user'] );
73
-		$args['post__in'] = array_map( 'absint', explode( ',', $donor->payment_ids ) );
72
+		unset($args['user']);
73
+		$args['post__in'] = array_map('absint', explode(',', $donor->payment_ids));
74 74
 
75 75
 	}
76 76
 
77
-	$donations = give_get_payments( apply_filters( 'give_get_users_donations_args', $args ) );
77
+	$donations = give_get_payments(apply_filters('give_get_users_donations_args', $args));
78 78
 
79 79
 	// No donations
80
-	if ( ! $donations ) {
80
+	if ( ! $donations) {
81 81
 		return false;
82 82
 	}
83 83
 
@@ -96,65 +96,65 @@  discard block
 block discarded – undo
96 96
  *
97 97
  * @return bool|object List of unique forms donated by user
98 98
  */
99
-function give_get_users_completed_donations( $user = 0, $status = 'complete' ) {
100
-	if ( empty( $user ) ) {
99
+function give_get_users_completed_donations($user = 0, $status = 'complete') {
100
+	if (empty($user)) {
101 101
 		$user = get_current_user_id();
102 102
 	}
103 103
 
104
-	if ( empty( $user ) ) {
104
+	if (empty($user)) {
105 105
 		return false;
106 106
 	}
107 107
 
108
-	$by_user_id = is_numeric( $user ) ? true : false;
108
+	$by_user_id = is_numeric($user) ? true : false;
109 109
 
110
-	$donor = new Give_Donor( $user, $by_user_id );
110
+	$donor = new Give_Donor($user, $by_user_id);
111 111
 
112
-	if ( empty( $donor->payment_ids ) ) {
112
+	if (empty($donor->payment_ids)) {
113 113
 		return false;
114 114
 	}
115 115
 
116 116
 	// Get all the items donated.
117
-	$payment_ids    = array_reverse( explode( ',', $donor->payment_ids ) );
118
-	$limit_payments = apply_filters( 'give_users_completed_donations_payments', 50 );
119
-	if ( ! empty( $limit_payments ) ) {
120
-		$payment_ids = array_slice( $payment_ids, 0, $limit_payments );
117
+	$payment_ids    = array_reverse(explode(',', $donor->payment_ids));
118
+	$limit_payments = apply_filters('give_users_completed_donations_payments', 50);
119
+	if ( ! empty($limit_payments)) {
120
+		$payment_ids = array_slice($payment_ids, 0, $limit_payments);
121 121
 	}
122 122
 	$donation_data = array();
123
-	foreach ( $payment_ids as $payment_id ) {
124
-		$donation_data[] = give_get_payment_meta( $payment_id );
123
+	foreach ($payment_ids as $payment_id) {
124
+		$donation_data[] = give_get_payment_meta($payment_id);
125 125
 	}
126 126
 
127
-	if ( empty( $donation_data ) ) {
127
+	if (empty($donation_data)) {
128 128
 		return false;
129 129
 	}
130 130
 
131 131
 	// Grab only the post ids "form_id" of the forms donated on this order
132 132
 	$completed_donations_ids = array();
133
-	foreach ( $donation_data as $donation_meta ) {
134
-		$completed_donations_ids[] = isset( $donation_meta['form_id'] ) ? $donation_meta['form_id'] : '';
133
+	foreach ($donation_data as $donation_meta) {
134
+		$completed_donations_ids[] = isset($donation_meta['form_id']) ? $donation_meta['form_id'] : '';
135 135
 	}
136 136
 
137
-	if ( empty( $completed_donations_ids ) ) {
137
+	if (empty($completed_donations_ids)) {
138 138
 		return false;
139 139
 	}
140 140
 
141 141
 	// Only include each donation once
142
-	$form_ids = array_unique( $completed_donations_ids );
142
+	$form_ids = array_unique($completed_donations_ids);
143 143
 
144 144
 	// Make sure we still have some products and a first item
145
-	if ( empty( $form_ids ) || ! isset( $form_ids[0] ) ) {
145
+	if (empty($form_ids) || ! isset($form_ids[0])) {
146 146
 		return false;
147 147
 	}
148 148
 
149
-	$post_type = get_post_type( $form_ids[0] );
149
+	$post_type = get_post_type($form_ids[0]);
150 150
 
151
-	$args = apply_filters( 'give_get_users_completed_donations_args', array(
151
+	$args = apply_filters('give_get_users_completed_donations_args', array(
152 152
 		'include'        => $form_ids,
153 153
 		'post_type'      => $post_type,
154
-		'posts_per_page' => - 1,
155
-	) );
154
+		'posts_per_page' => -1,
155
+	));
156 156
 
157
-	return apply_filters( 'give_users_completed_donations_list', get_posts( $args ) );
157
+	return apply_filters('give_users_completed_donations_list', get_posts($args));
158 158
 }
159 159
 
160 160
 
@@ -170,12 +170,12 @@  discard block
 block discarded – undo
170 170
  *
171 171
  * @return      bool True if has donated, false other wise.
172 172
  */
173
-function give_has_donations( $user_id = null ) {
174
-	if ( empty( $user_id ) ) {
173
+function give_has_donations($user_id = null) {
174
+	if (empty($user_id)) {
175 175
 		$user_id = get_current_user_id();
176 176
 	}
177 177
 
178
-	if ( give_get_users_donations( $user_id, 1 ) ) {
178
+	if (give_get_users_donations($user_id, 1)) {
179 179
 		return true; // User has at least one donation.
180 180
 	}
181 181
 
@@ -196,23 +196,23 @@  discard block
 block discarded – undo
196 196
  *
197 197
  * @return      array
198 198
  */
199
-function give_get_donation_stats_by_user( $user = '' ) {
199
+function give_get_donation_stats_by_user($user = '') {
200 200
 
201 201
 	$field = '';
202 202
 
203
-	if ( is_email( $user ) ) {
203
+	if (is_email($user)) {
204 204
 		$field = 'email';
205
-	} elseif ( is_numeric( $user ) ) {
205
+	} elseif (is_numeric($user)) {
206 206
 		$field = 'user_id';
207 207
 	}
208 208
 
209
-	$stats    = array();
210
-	$donor = Give()->donors->get_donor_by( $field, $user );
209
+	$stats = array();
210
+	$donor = Give()->donors->get_donor_by($field, $user);
211 211
 
212
-	if ( $donor ) {
213
-		$donor = new Give_Donor( $donor->id );
214
-		$stats['purchases']   = absint( $donor->purchase_count );
215
-		$stats['total_spent'] = give_maybe_sanitize_amount( $donor->purchase_value );
212
+	if ($donor) {
213
+		$donor = new Give_Donor($donor->id);
214
+		$stats['purchases']   = absint($donor->purchase_count);
215
+		$stats['total_spent'] = give_maybe_sanitize_amount($donor->purchase_value);
216 216
 	}
217 217
 
218 218
 	/**
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 	 *
221 221
 	 * @since 1.7
222 222
 	 */
223
-	$stats = (array) apply_filters( 'give_donation_stats_by_user', $stats, $user );
223
+	$stats = (array) apply_filters('give_donation_stats_by_user', $stats, $user);
224 224
 
225 225
 	return $stats;
226 226
 }
@@ -238,21 +238,21 @@  discard block
 block discarded – undo
238 238
  *
239 239
  * @return      int The total number of donations.
240 240
  */
241
-function give_count_donations_of_donor( $user = null ) {
241
+function give_count_donations_of_donor($user = null) {
242 242
 
243 243
 	// Logged in?
244
-	if ( empty( $user ) ) {
244
+	if (empty($user)) {
245 245
 		$user = get_current_user_id();
246 246
 	}
247 247
 
248 248
 	// Email access?
249
-	if ( empty( $user ) && Give()->email_access->token_email ) {
249
+	if (empty($user) && Give()->email_access->token_email) {
250 250
 		$user = Give()->email_access->token_email;
251 251
 	}
252 252
 
253
-	$stats = ! empty( $user ) ? give_get_donation_stats_by_user( $user ) : false;
253
+	$stats = ! empty($user) ? give_get_donation_stats_by_user($user) : false;
254 254
 
255
-	return isset( $stats['purchases'] ) ? $stats['purchases'] : 0;
255
+	return isset($stats['purchases']) ? $stats['purchases'] : 0;
256 256
 }
257 257
 
258 258
 /**
@@ -265,9 +265,9 @@  discard block
 block discarded – undo
265 265
  *
266 266
  * @return      float The total amount the user has spent
267 267
  */
268
-function give_donation_total_of_user( $user = null ) {
268
+function give_donation_total_of_user($user = null) {
269 269
 
270
-	$stats = give_get_donation_stats_by_user( $user );
270
+	$stats = give_get_donation_stats_by_user($user);
271 271
 
272 272
 	return $stats['total_spent'];
273 273
 }
@@ -283,40 +283,40 @@  discard block
 block discarded – undo
283 283
  *
284 284
  * @return bool
285 285
  */
286
-function give_validate_username( $username, $form_id = 0 ) {
286
+function give_validate_username($username, $form_id = 0) {
287 287
 	$valid = true;
288 288
 
289 289
 	// Validate username.
290
-	if ( ! empty( $username ) ) {
290
+	if ( ! empty($username)) {
291 291
 
292 292
 		// Sanitize username.
293
-		$sanitized_user_name = sanitize_user( $username, false );
293
+		$sanitized_user_name = sanitize_user($username, false);
294 294
 
295 295
 		// We have an user name, check if it already exists.
296
-		if ( username_exists( $username ) ) {
296
+		if (username_exists($username)) {
297 297
 			// Username already registered.
298
-			give_set_error( 'username_unavailable', __( 'Username already taken.', 'give' ) );
298
+			give_set_error('username_unavailable', __('Username already taken.', 'give'));
299 299
 			$valid = false;
300 300
 
301 301
 			// Check if it's valid.
302
-		} elseif ( $sanitized_user_name !== $username ) {
302
+		} elseif ($sanitized_user_name !== $username) {
303 303
 			// Invalid username.
304
-			if ( is_multisite() ) {
305
-				give_set_error( 'username_invalid', __( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ) );
304
+			if (is_multisite()) {
305
+				give_set_error('username_invalid', __('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give'));
306 306
 				$valid = false;
307 307
 			} else {
308
-				give_set_error( 'username_invalid', __( 'Invalid username.', 'give' ) );
308
+				give_set_error('username_invalid', __('Invalid username.', 'give'));
309 309
 				$valid = false;
310 310
 			}
311 311
 		}
312 312
 	} else {
313 313
 		// Username is empty.
314
-		give_set_error( 'username_empty', __( 'Enter a username.', 'give' ) );
314
+		give_set_error('username_empty', __('Enter a username.', 'give'));
315 315
 		$valid = false;
316 316
 
317 317
 		// Check if guest checkout is disable for form.
318
-		if ( $form_id && give_logged_in_only( $form_id ) ) {
319
-			give_set_error( 'registration_required', __( 'You must register or login to complete your donation.', 'give' ) );
318
+		if ($form_id && give_logged_in_only($form_id)) {
319
+			give_set_error('registration_required', __('You must register or login to complete your donation.', 'give'));
320 320
 			$valid = false;
321 321
 		}
322 322
 	}
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 	 * @param string $username
331 331
 	 * @param bool   $form_id
332 332
 	 */
333
-	$valid = (bool) apply_filters( 'give_validate_username', $valid, $username, $form_id );
333
+	$valid = (bool) apply_filters('give_validate_username', $valid, $username, $form_id);
334 334
 
335 335
 	return $valid;
336 336
 }
@@ -346,22 +346,22 @@  discard block
 block discarded – undo
346 346
  *
347 347
  * @return bool
348 348
  */
349
-function give_validate_user_email( $email, $registering_new_user = false ) {
349
+function give_validate_user_email($email, $registering_new_user = false) {
350 350
 	$valid = true;
351 351
 
352
-	if ( empty( $email ) ) {
352
+	if (empty($email)) {
353 353
 		// No email.
354
-		give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) );
354
+		give_set_error('email_empty', __('Enter an email.', 'give'));
355 355
 		$valid = false;
356 356
 
357
-	} elseif ( ! is_email( $email ) ) {
357
+	} elseif ( ! is_email($email)) {
358 358
 		// Validate email.
359
-		give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) );
359
+		give_set_error('email_invalid', __('Invalid email.', 'give'));
360 360
 		$valid = false;
361 361
 
362
-	} elseif ( $registering_new_user && ( give_donor_email_exists( $email ) || email_exists( $email ) ) ) {
362
+	} elseif ($registering_new_user && (give_donor_email_exists($email) || email_exists($email))) {
363 363
 		// Check if email exists.
364
-		give_set_error( 'email_used', __( 'The email address provided is already active for another user.', 'give' ) );
364
+		give_set_error('email_used', __('The email address provided is already active for another user.', 'give'));
365 365
 		$valid = false;
366 366
 	}
367 367
 
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 	 * @param string $email
375 375
 	 * @param bool   $registering_new_user
376 376
 	 */
377
-	$valid = (bool) apply_filters( 'give_validate_user_email', $valid, $email, $registering_new_user );
377
+	$valid = (bool) apply_filters('give_validate_user_email', $valid, $email, $registering_new_user);
378 378
 
379 379
 	return $valid;
380 380
 }
@@ -390,34 +390,34 @@  discard block
 block discarded – undo
390 390
  *
391 391
  * @return bool
392 392
  */
393
-function give_validate_user_password( $password = '', $confirm_password = '', $registering_new_user = false ) {
393
+function give_validate_user_password($password = '', $confirm_password = '', $registering_new_user = false) {
394 394
 	$valid = true;
395 395
 
396 396
 	// Passwords Validation For New Donors Only
397
-	if ( $registering_new_user ) {
397
+	if ($registering_new_user) {
398 398
 		// Password or confirmation missing.
399
-		if ( ! $password ) {
399
+		if ( ! $password) {
400 400
 			// The password is invalid.
401
-			give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) );
401
+			give_set_error('password_empty', __('Enter a password.', 'give'));
402 402
 			$valid = false;
403
-		} elseif ( ! $confirm_password ) {
403
+		} elseif ( ! $confirm_password) {
404 404
 			// Confirmation password is invalid.
405
-			give_set_error( 'confirmation_empty', __( 'Enter the password confirmation.', 'give' ) );
405
+			give_set_error('confirmation_empty', __('Enter the password confirmation.', 'give'));
406 406
 			$valid = false;
407 407
 		}
408 408
 	}
409 409
 	// Passwords Validation For New Donors as well as Existing Donors
410
-	if( $password || $confirm_password ) {
411
-		if ( strlen( $password ) < 6 || strlen( $confirm_password ) < 6 ) {
410
+	if ($password || $confirm_password) {
411
+		if (strlen($password) < 6 || strlen($confirm_password) < 6) {
412 412
 			// Seems Weak Password
413
-			give_set_error( 'password_weak', __( 'Passwords should have atleast 6 characters.', 'give' ) );
413
+			give_set_error('password_weak', __('Passwords should have atleast 6 characters.', 'give'));
414 414
 			$valid = false;
415 415
 		}
416
-		if ( $password && $confirm_password ) {
416
+		if ($password && $confirm_password) {
417 417
 			// Verify confirmation matches.
418
-			if ( $password != $confirm_password ) {
418
+			if ($password != $confirm_password) {
419 419
 				// Passwords do not match
420
-				give_set_error( 'password_mismatch', __( 'Passwords you entered do not match. Please try again.', 'give' ) );
420
+				give_set_error('password_mismatch', __('Passwords you entered do not match. Please try again.', 'give'));
421 421
 				$valid = false;
422 422
 			}
423 423
 		}
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 	 * @param string $confirm_password
434 434
 	 * @param bool   $registering_new_user
435 435
 	 */
436
-	$valid = (bool) apply_filters( 'give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user );
436
+	$valid = (bool) apply_filters('give_validate_user_email', $valid, $password, $confirm_password, $registering_new_user);
437 437
 
438 438
 	return $valid;
439 439
 }
@@ -451,33 +451,33 @@  discard block
 block discarded – undo
451 451
  *
452 452
  * @return      void
453 453
  */
454
-function give_add_past_donations_to_new_user( $user_id ) {
454
+function give_add_past_donations_to_new_user($user_id) {
455 455
 
456
-	$email = get_the_author_meta( 'user_email', $user_id );
456
+	$email = get_the_author_meta('user_email', $user_id);
457 457
 
458
-	$payments = give_get_payments( array(
458
+	$payments = give_get_payments(array(
459 459
 		's' => $email,
460
-	) );
460
+	));
461 461
 
462
-	if ( $payments ) {
463
-		foreach ( $payments as $payment ) {
464
-			if ( intval( give_get_payment_user_id( $payment->ID ) ) > 0 ) {
462
+	if ($payments) {
463
+		foreach ($payments as $payment) {
464
+			if (intval(give_get_payment_user_id($payment->ID)) > 0) {
465 465
 				continue;
466 466
 			} // End if().
467 467
 
468
-			$meta                    = give_get_payment_meta( $payment->ID );
469
-			$meta['user_info']       = maybe_unserialize( $meta['user_info'] );
468
+			$meta                    = give_get_payment_meta($payment->ID);
469
+			$meta['user_info']       = maybe_unserialize($meta['user_info']);
470 470
 			$meta['user_info']['id'] = $user_id;
471 471
 
472 472
 			// Store the updated user ID in the payment meta.
473
-			give_update_payment_meta( $payment->ID, '_give_payment_meta', $meta );
474
-			give_update_payment_meta( $payment->ID, '_give_payment_user_id', $user_id );
473
+			give_update_payment_meta($payment->ID, '_give_payment_meta', $meta);
474
+			give_update_payment_meta($payment->ID, '_give_payment_user_id', $user_id);
475 475
 		}
476 476
 	}
477 477
 
478 478
 }
479 479
 
480
-add_action( 'user_register', 'give_add_past_donations_to_new_user' );
480
+add_action('user_register', 'give_add_past_donations_to_new_user');
481 481
 
482 482
 
483 483
 /**
@@ -503,34 +503,34 @@  discard block
 block discarded – undo
503 503
  *
504 504
  * @return        array The donor's address, if any
505 505
  */
506
-function give_get_donor_address( $user_id = 0 ) {
507
-	if ( empty( $user_id ) ) {
506
+function give_get_donor_address($user_id = 0) {
507
+	if (empty($user_id)) {
508 508
 		$user_id = get_current_user_id();
509 509
 	}
510 510
 
511
-	$address = get_user_meta( $user_id, '_give_user_address', true );
511
+	$address = get_user_meta($user_id, '_give_user_address', true);
512 512
 
513
-	if ( ! isset( $address['line1'] ) ) {
513
+	if ( ! isset($address['line1'])) {
514 514
 		$address['line1'] = '';
515 515
 	}
516 516
 
517
-	if ( ! isset( $address['line2'] ) ) {
517
+	if ( ! isset($address['line2'])) {
518 518
 		$address['line2'] = '';
519 519
 	}
520 520
 
521
-	if ( ! isset( $address['city'] ) ) {
521
+	if ( ! isset($address['city'])) {
522 522
 		$address['city'] = '';
523 523
 	}
524 524
 
525
-	if ( ! isset( $address['zip'] ) ) {
525
+	if ( ! isset($address['zip'])) {
526 526
 		$address['zip'] = '';
527 527
 	}
528 528
 
529
-	if ( ! isset( $address['country'] ) ) {
529
+	if ( ! isset($address['country'])) {
530 530
 		$address['country'] = '';
531 531
 	}
532 532
 
533
-	if ( ! isset( $address['state'] ) ) {
533
+	if ( ! isset($address['state'])) {
534 534
 		$address['state'] = '';
535 535
 	}
536 536
 
@@ -550,32 +550,32 @@  discard block
 block discarded – undo
550 550
  *
551 551
  * @return        void
552 552
  */
553
-function give_new_user_notification( $user_id = 0, $user_data = array() ) {
553
+function give_new_user_notification($user_id = 0, $user_data = array()) {
554 554
 
555
-	if ( empty( $user_id ) || empty( $user_data ) ) {
555
+	if (empty($user_id) || empty($user_data)) {
556 556
 		return;
557 557
 	}
558
-	$blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
558
+	$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
559 559
 
560 560
 
561 561
 	// New User Registration: Email sends to the site admin.
562 562
 	$emails = Give()->emails;
563
-	$emails->__set( 'heading', esc_html__( 'New User Registration', 'give' ) );
563
+	$emails->__set('heading', esc_html__('New User Registration', 'give'));
564 564
 
565 565
 	/* translators: %s: site name */
566
-	$message = sprintf( esc_attr__( 'A new user has registered on %s:', 'give' ), $blogname ) . "\r\n\r\n";
566
+	$message = sprintf(esc_attr__('A new user has registered on %s:', 'give'), $blogname)."\r\n\r\n";
567 567
 	/* translators: %s: user login */
568
-	$message .= '<strong>' . esc_attr__( 'Username:', 'give' ) . '</strong> ' . $user_data['user_login'] . "\r\n";
568
+	$message .= '<strong>'.esc_attr__('Username:', 'give').'</strong> '.$user_data['user_login']."\r\n";
569 569
 	/* translators: %s: user email */
570
-	$message .= '<strong>' . esc_attr__( 'E-mail:', 'give' ) . '</strong> ' . $user_data['user_email']  . "\r\n\r\n";
570
+	$message .= '<strong>'.esc_attr__('E-mail:', 'give').'</strong> '.$user_data['user_email']."\r\n\r\n";
571 571
 
572
-	$message .= '<a href="' . admin_url('user-edit.php?user_id=' . $user_id) . '" target="_blank"> ' . esc_attr__( 'Click here to view &raquo;', 'give' ) . '</a>' . "\r\n";
572
+	$message .= '<a href="'.admin_url('user-edit.php?user_id='.$user_id).'" target="_blank"> '.esc_attr__('Click here to view &raquo;', 'give').'</a>'."\r\n";
573 573
 
574 574
 	$emails->send(
575
-		get_option( 'admin_email' ),
575
+		get_option('admin_email'),
576 576
 		sprintf(
577 577
 			/* translators: %s: site name */
578
-			esc_attr__( '[%s] New User Registration', 'give' ),
578
+			esc_attr__('[%s] New User Registration', 'give'),
579 579
 			$blogname
580 580
 		),
581 581
 		$message
@@ -583,22 +583,22 @@  discard block
 block discarded – undo
583 583
 
584 584
 
585 585
 	// Account Information: Email sends to donor who registered.
586
-	$emails->__set( 'heading', esc_html__( 'Account Information', 'give' ) );
586
+	$emails->__set('heading', esc_html__('Account Information', 'give'));
587 587
 
588
-	$message = sprintf( esc_attr__( 'The following email contains your account information for %s:', 'give' ), $blogname ) . "\r\n\r\n";
588
+	$message = sprintf(esc_attr__('The following email contains your account information for %s:', 'give'), $blogname)."\r\n\r\n";
589 589
 
590 590
 	/* translators: %s: user login */
591
-	$message .=  '<strong>' . esc_attr__( 'Username:', 'give' ) . '</strong> ' .  $user_data['user_login'] . "\r\n";
591
+	$message .= '<strong>'.esc_attr__('Username:', 'give').'</strong> '.$user_data['user_login']."\r\n";
592 592
 	/* translators: %s: password */
593
-	$message .=  '<strong>' . esc_attr__( 'Password:', 'give' ) . '</strong> ' . esc_attr__( '[Password entered during donation]', 'give' ) . "\r\n\r\n";
593
+	$message .= '<strong>'.esc_attr__('Password:', 'give').'</strong> '.esc_attr__('[Password entered during donation]', 'give')."\r\n\r\n";
594 594
 
595
-	$message .= '<a href="' . wp_login_url() . '" target="_blank"> ' . esc_attr__( 'Click here to login &raquo;', 'give' ) . '</a>' . "\r\n";
595
+	$message .= '<a href="'.wp_login_url().'" target="_blank"> '.esc_attr__('Click here to login &raquo;', 'give').'</a>'."\r\n";
596 596
 
597 597
 	$emails->send(
598 598
 		$user_data['user_email'],
599 599
 		sprintf(
600 600
 			/* translators: %s: site name */
601
-			esc_attr__( '[%s] Your username and password', 'give' ),
601
+			esc_attr__('[%s] Your username and password', 'give'),
602 602
 			$blogname
603 603
 		),
604 604
 		$message
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
 
607 607
 }
608 608
 
609
-add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 );
609
+add_action('give_insert_user', 'give_new_user_notification', 10, 2);
610 610
 
611 611
 
612 612
 /**
@@ -622,34 +622,34 @@  discard block
 block discarded – undo
622 622
  *
623 623
  * @return      string
624 624
  */
625
-function give_get_donor_name_by( $id = 0, $from = 'donation' ) {
625
+function give_get_donor_name_by($id = 0, $from = 'donation') {
626 626
 
627 627
 	// ID shouldn't be empty
628
-	if ( empty( $id ) ) {
628
+	if (empty($id)) {
629 629
 		return;
630 630
 	}
631 631
 
632 632
 	$name = '';
633 633
 
634
-	switch ( $from ) {
634
+	switch ($from) {
635 635
 
636 636
 		case 'donation':
637 637
 
638
-			$user_info = give_get_payment_meta_user_info( $id );
639
-			$name = $user_info['first_name'] . ' ' . $user_info['last_name'];
638
+			$user_info = give_get_payment_meta_user_info($id);
639
+			$name = $user_info['first_name'].' '.$user_info['last_name'];
640 640
 
641 641
 		break;
642 642
 
643 643
 		case 'donor':
644 644
 
645
-			$donor = new Give_Donor( $id );
645
+			$donor = new Give_Donor($id);
646 646
 			$name = $donor->name;
647 647
 
648 648
 		break;
649 649
 
650 650
 	}
651 651
 
652
-	return trim( $name );
652
+	return trim($name);
653 653
 
654 654
 }
655 655
 
@@ -661,8 +661,8 @@  discard block
 block discarded – undo
661 661
  * @param  string   $email Donor Email.
662 662
  * @return boolean  The user's ID on success, and false on failure.
663 663
  */
664
-function give_donor_email_exists( $email ) {
665
-	if ( Give()->donors->get_donor_by( 'email', $email ) ) {
664
+function give_donor_email_exists($email) {
665
+	if (Give()->donors->get_donor_by('email', $email)) {
666 666
 		return true;
667 667
 	}
668 668
 	return false;
Please login to merge, or discard this patch.
includes/payments/class-give-payment.php 1 patch
Spacing   +281 added lines, -281 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
 
@@ -371,13 +371,13 @@  discard block
 block discarded – undo
371 371
 	 *
372 372
 	 * @return mixed void|false
373 373
 	 */
374
-	public function __construct( $payment_id = false ) {
374
+	public function __construct($payment_id = false) {
375 375
 
376
-		if ( empty( $payment_id ) ) {
376
+		if (empty($payment_id)) {
377 377
 			return false;
378 378
 		}
379 379
 
380
-		$this->setup_payment( $payment_id );
380
+		$this->setup_payment($payment_id);
381 381
 	}
382 382
 
383 383
 	/**
@@ -390,11 +390,11 @@  discard block
 block discarded – undo
390 390
 	 *
391 391
 	 * @return mixed        The value.
392 392
 	 */
393
-	public function __get( $key ) {
393
+	public function __get($key) {
394 394
 
395
-		if ( method_exists( $this, 'get_' . $key ) ) {
395
+		if (method_exists($this, 'get_'.$key)) {
396 396
 
397
-			$value = call_user_func( array( $this, 'get_' . $key ) );
397
+			$value = call_user_func(array($this, 'get_'.$key));
398 398
 
399 399
 		} else {
400 400
 
@@ -416,18 +416,18 @@  discard block
 block discarded – undo
416 416
 	 * @param  string $key The property name
417 417
 	 * @param  mixed  $value The value of the property
418 418
 	 */
419
-	public function __set( $key, $value ) {
420
-		$ignore = array( '_ID' );
419
+	public function __set($key, $value) {
420
+		$ignore = array('_ID');
421 421
 
422
-		if ( $key === 'status' ) {
422
+		if ($key === 'status') {
423 423
 			$this->old_status = $this->status;
424 424
 		}
425 425
 
426
-		if ( ! in_array( $key, $ignore ) ) {
427
-			$this->pending[ $key ] = $value;
426
+		if ( ! in_array($key, $ignore)) {
427
+			$this->pending[$key] = $value;
428 428
 		}
429 429
 
430
-		if ( '_ID' !== $key ) {
430
+		if ('_ID' !== $key) {
431 431
 			$this->$key = $value;
432 432
 		}
433 433
 	}
@@ -442,9 +442,9 @@  discard block
 block discarded – undo
442 442
 	 *
443 443
 	 * @return boolean       If the item is set or not
444 444
 	 */
445
-	public function __isset( $name ) {
446
-		if ( property_exists( $this, $name ) ) {
447
-			return false === empty( $this->$name );
445
+	public function __isset($name) {
446
+		if (property_exists($this, $name)) {
447
+			return false === empty($this->$name);
448 448
 		} else {
449 449
 			return null;
450 450
 		}
@@ -460,20 +460,20 @@  discard block
 block discarded – undo
460 460
 	 *
461 461
 	 * @return bool            If the setup was successful or not
462 462
 	 */
463
-	private function setup_payment( $payment_id ) {
463
+	private function setup_payment($payment_id) {
464 464
 		$this->pending = array();
465 465
 
466
-		if ( empty( $payment_id ) ) {
466
+		if (empty($payment_id)) {
467 467
 			return false;
468 468
 		}
469 469
 
470
-		$payment = get_post( $payment_id );
470
+		$payment = get_post($payment_id);
471 471
 
472
-		if ( ! $payment || is_wp_error( $payment ) ) {
472
+		if ( ! $payment || is_wp_error($payment)) {
473 473
 			return false;
474 474
 		}
475 475
 
476
-		if ( 'give_payment' !== $payment->post_type ) {
476
+		if ('give_payment' !== $payment->post_type) {
477 477
 			return false;
478 478
 		}
479 479
 
@@ -487,13 +487,13 @@  discard block
 block discarded – undo
487 487
 		 * @param Give_Payment $this Payment object.
488 488
 		 * @param int $payment_id The ID of the payment.
489 489
 		 */
490
-		do_action( 'give_pre_setup_payment', $this, $payment_id );
490
+		do_action('give_pre_setup_payment', $this, $payment_id);
491 491
 
492 492
 		// Primary Identifier.
493
-		$this->ID = absint( $payment_id );
493
+		$this->ID = absint($payment_id);
494 494
 
495 495
 		// Protected ID that can never be changed.
496
-		$this->_ID = absint( $payment_id );
496
+		$this->_ID = absint($payment_id);
497 497
 
498 498
 		// We have a payment, get the generic payment_meta item to reduce calls to it.
499 499
 		$this->payment_meta = $this->get_meta();
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
 		$this->parent_payment = $payment->post_parent;
509 509
 
510 510
 		$all_payment_statuses  = give_get_payment_statuses();
511
-		$this->status_nicename = array_key_exists( $this->status, $all_payment_statuses ) ? $all_payment_statuses[ $this->status ] : ucfirst( $this->status );
511
+		$this->status_nicename = array_key_exists($this->status, $all_payment_statuses) ? $all_payment_statuses[$this->status] : ucfirst($this->status);
512 512
 
513 513
 		// Currency Based.
514 514
 		$this->total      = $this->setup_total();
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
 		 * @param Give_Payment $this Payment object.
547 547
 		 * @param int $payment_id The ID of the payment.
548 548
 		 */
549
-		do_action( 'give_setup_payment', $this, $payment_id );
549
+		do_action('give_setup_payment', $this, $payment_id);
550 550
 
551 551
 		return true;
552 552
 	}
@@ -564,8 +564,8 @@  discard block
 block discarded – undo
564 564
 	 *
565 565
 	 * @return void
566 566
 	 */
567
-	public function update_payment_setup( $payment_id ) {
568
-		$this->setup_payment( $payment_id );
567
+	public function update_payment_setup($payment_id) {
568
+		$this->setup_payment($payment_id);
569 569
 	}
570 570
 
571 571
 	/**
@@ -580,24 +580,24 @@  discard block
 block discarded – undo
580 580
 
581 581
 		// Construct the payment title.
582 582
 		$payment_title = '';
583
-		if ( ! empty( $this->first_name ) && ! empty( $this->last_name ) ) {
584
-			$payment_title = $this->first_name . ' ' . $this->last_name;
585
-		} elseif ( ! empty( $this->first_name ) && empty( $this->last_name ) ) {
583
+		if ( ! empty($this->first_name) && ! empty($this->last_name)) {
584
+			$payment_title = $this->first_name.' '.$this->last_name;
585
+		} elseif ( ! empty($this->first_name) && empty($this->last_name)) {
586 586
 			$payment_title = $this->first_name;
587
-		} elseif ( ! empty( $this->email ) && is_email( $this->email ) ) {
587
+		} elseif ( ! empty($this->email) && is_email($this->email)) {
588 588
 			$payment_title = $this->email;
589 589
 		}
590 590
 
591 591
 		// Set Key.
592
-		if ( empty( $this->key ) ) {
592
+		if (empty($this->key)) {
593 593
 
594
-			$auth_key             = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
595
-			$this->key            = strtolower( md5( $this->email . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) );  // Unique key
594
+			$auth_key             = defined('AUTH_KEY') ? AUTH_KEY : '';
595
+			$this->key            = strtolower(md5($this->email.date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); // Unique key
596 596
 			$this->pending['key'] = $this->key;
597 597
 		}
598 598
 
599 599
 		// Set IP.
600
-		if ( empty( $this->ip ) ) {
600
+		if (empty($this->ip)) {
601 601
 
602 602
 			$this->ip            = give_get_ip();
603 603
 			$this->pending['ip'] = $this->ip;
@@ -623,57 +623,57 @@  discard block
 block discarded – undo
623 623
 			'status'       => $this->status,
624 624
 		);
625 625
 
626
-		$args = apply_filters( 'give_insert_payment_args', array(
626
+		$args = apply_filters('give_insert_payment_args', array(
627 627
 			'post_title'    => $payment_title,
628 628
 			'post_status'   => $this->status,
629 629
 			'post_type'     => 'give_payment',
630
-			'post_date'     => ! empty( $this->date ) ? $this->date : null,
631
-			'post_date_gmt' => ! empty( $this->date ) ? get_gmt_from_date( $this->date ) : null,
630
+			'post_date'     => ! empty($this->date) ? $this->date : null,
631
+			'post_date_gmt' => ! empty($this->date) ? get_gmt_from_date($this->date) : null,
632 632
 			'post_parent'   => $this->parent_payment,
633
-		), $payment_data );
633
+		), $payment_data);
634 634
 
635 635
 		// Create a blank payment
636
-		$payment_id = wp_insert_post( $args );
636
+		$payment_id = wp_insert_post($args);
637 637
 
638
-		if ( ! empty( $payment_id ) ) {
638
+		if ( ! empty($payment_id)) {
639 639
 
640 640
 			$this->ID  = $payment_id;
641 641
 			$this->_ID = $payment_id;
642 642
 
643 643
 			$donor = new stdClass;
644 644
 
645
-			if ( did_action( 'give_pre_process_donation' ) && is_user_logged_in() ) {
646
-				$donor = new Give_Donor( get_current_user_id(), true );
645
+			if (did_action('give_pre_process_donation') && is_user_logged_in()) {
646
+				$donor = new Give_Donor(get_current_user_id(), true);
647 647
 
648 648
 				// Donor is logged in but used a different email to purchase with so assign to their donor record.
649
-				if ( ! empty( $donor->id ) && $this->email != $donor->email ) {
650
-					$donor->add_email( $this->email );
649
+				if ( ! empty($donor->id) && $this->email != $donor->email) {
650
+					$donor->add_email($this->email);
651 651
 				}
652 652
 			}
653 653
 
654
-			if ( empty( $donor->id ) ) {
655
-				$donor = new Give_Donor( $this->email );
654
+			if (empty($donor->id)) {
655
+				$donor = new Give_Donor($this->email);
656 656
 			}
657 657
 
658
-			if ( empty( $donor->id ) ) {
658
+			if (empty($donor->id)) {
659 659
 
660 660
 				$donor_data = array(
661
-					'name'    => ! is_email( $payment_title ) ? $this->first_name . ' ' . $this->last_name : '',
661
+					'name'    => ! is_email($payment_title) ? $this->first_name.' '.$this->last_name : '',
662 662
 					'email'   => $this->email,
663 663
 					'user_id' => $this->user_id,
664 664
 				);
665 665
 
666
-				$donor->create( $donor_data );
666
+				$donor->create($donor_data);
667 667
 
668 668
 			}
669 669
 
670 670
 			$this->customer_id            = $donor->id;
671 671
 			$this->pending['customer_id'] = $this->customer_id;
672
-			$donor->attach_payment( $this->ID, false );
672
+			$donor->attach_payment($this->ID, false);
673 673
 
674
-			$this->payment_meta = apply_filters( 'give_payment_meta', $this->payment_meta, $payment_data );
674
+			$this->payment_meta = apply_filters('give_payment_meta', $this->payment_meta, $payment_data);
675 675
 
676
-			$this->update_meta( '_give_payment_meta', $this->payment_meta );
676
+			$this->update_meta('_give_payment_meta', $this->payment_meta);
677 677
 			$this->new = true;
678 678
 		}// End if().
679 679
 
@@ -695,11 +695,11 @@  discard block
 block discarded – undo
695 695
 		$saved = false;
696 696
 
697 697
 		// Must have an ID.
698
-		if ( empty( $this->ID ) ) {
698
+		if (empty($this->ID)) {
699 699
 
700 700
 			$payment_id = $this->insert_payment();
701 701
 
702
-			if ( false === $payment_id ) {
702
+			if (false === $payment_id) {
703 703
 				$saved = false;
704 704
 			} else {
705 705
 				$this->ID = $payment_id;
@@ -707,48 +707,48 @@  discard block
 block discarded – undo
707 707
 		}
708 708
 
709 709
 		// Set ID if not matching.
710
-		if ( $this->ID !== $this->_ID ) {
710
+		if ($this->ID !== $this->_ID) {
711 711
 			$this->ID = $this->_ID;
712 712
 		}
713 713
 
714 714
 		// If we have something pending, let's save it.
715
-		if ( ! empty( $this->pending ) ) {
715
+		if ( ! empty($this->pending)) {
716 716
 
717 717
 			$total_increase = 0;
718 718
 			$total_decrease = 0;
719 719
 
720
-			foreach ( $this->pending as $key => $value ) {
720
+			foreach ($this->pending as $key => $value) {
721 721
 
722
-				switch ( $key ) {
722
+				switch ($key) {
723 723
 
724 724
 					case 'donations':
725 725
 						// Update totals for pending donations.
726
-						foreach ( $this->pending[ $key ] as $item ) {
726
+						foreach ($this->pending[$key] as $item) {
727 727
 
728
-							$quantity = isset( $item['quantity'] ) ? $item['quantity'] : 1;
729
-							$price_id = isset( $item['price_id'] ) ? $item['price_id'] : 0;
728
+							$quantity = isset($item['quantity']) ? $item['quantity'] : 1;
729
+							$price_id = isset($item['price_id']) ? $item['price_id'] : 0;
730 730
 
731
-							switch ( $item['action'] ) {
731
+							switch ($item['action']) {
732 732
 
733 733
 								case 'add':
734 734
 
735 735
 									$price = $item['price'];
736 736
 
737
-									if ( 'publish' === $this->status || 'complete' === $this->status ) {
737
+									if ('publish' === $this->status || 'complete' === $this->status) {
738 738
 
739 739
 										// Add sales logs.
740
-										$log_date = date_i18n( 'Y-m-d G:i:s', current_time( 'timestamp' ) );
740
+										$log_date = date_i18n('Y-m-d G:i:s', current_time('timestamp'));
741 741
 
742 742
 										$y = 0;
743
-										while ( $y < $quantity ) {
743
+										while ($y < $quantity) {
744 744
 
745
-											give_record_donation_in_log( $item['id'], $this->ID, $price_id, $log_date );
746
-											$y ++;
745
+											give_record_donation_in_log($item['id'], $this->ID, $price_id, $log_date);
746
+											$y++;
747 747
 										}
748 748
 
749
-										$form = new Give_Donate_Form( $item['id'] );
750
-										$form->increase_sales( $quantity );
751
-										$form->increase_earnings( $price );
749
+										$form = new Give_Donate_Form($item['id']);
750
+										$form->increase_sales($quantity);
751
+										$form->increase_earnings($price);
752 752
 
753 753
 										$total_increase += $price;
754 754
 									}
@@ -773,15 +773,15 @@  discard block
 block discarded – undo
773 773
 										),
774 774
 									);
775 775
 
776
-									$found_logs = get_posts( $log_args );
777
-									foreach ( $found_logs as $log ) {
778
-										wp_delete_post( $log->ID, true );
776
+									$found_logs = get_posts($log_args);
777
+									foreach ($found_logs as $log) {
778
+										wp_delete_post($log->ID, true);
779 779
 									}
780 780
 
781
-									if ( 'publish' === $this->status || 'complete' === $this->status ) {
782
-										$form = new Give_Donate_Form( $item['id'] );
783
-										$form->decrease_sales( $quantity );
784
-										$form->decrease_earnings( $item['amount'] );
781
+									if ('publish' === $this->status || 'complete' === $this->status) {
782
+										$form = new Give_Donate_Form($item['id']);
783
+										$form->decrease_sales($quantity);
784
+										$form->decrease_earnings($item['amount']);
785 785
 
786 786
 										$total_decrease += $item['amount'];
787 787
 									}
@@ -792,43 +792,43 @@  discard block
 block discarded – undo
792 792
 						break;
793 793
 
794 794
 					case 'status':
795
-						$this->update_status( $this->status );
795
+						$this->update_status($this->status);
796 796
 						break;
797 797
 
798 798
 					case 'gateway':
799
-						$this->update_meta( '_give_payment_gateway', $this->gateway );
799
+						$this->update_meta('_give_payment_gateway', $this->gateway);
800 800
 						break;
801 801
 
802 802
 					case 'mode':
803
-						$this->update_meta( '_give_payment_mode', $this->mode );
803
+						$this->update_meta('_give_payment_mode', $this->mode);
804 804
 						break;
805 805
 
806 806
 					case 'transaction_id':
807
-						$this->update_meta( '_give_payment_transaction_id', $this->transaction_id );
807
+						$this->update_meta('_give_payment_transaction_id', $this->transaction_id);
808 808
 						break;
809 809
 
810 810
 					case 'ip':
811
-						$this->update_meta( '_give_payment_user_ip', $this->ip );
811
+						$this->update_meta('_give_payment_user_ip', $this->ip);
812 812
 						break;
813 813
 
814 814
 					case 'customer_id':
815
-						$this->update_meta( '_give_payment_customer_id', $this->customer_id );
815
+						$this->update_meta('_give_payment_customer_id', $this->customer_id);
816 816
 						break;
817 817
 
818 818
 					case 'user_id':
819
-						$this->update_meta( '_give_payment_user_id', $this->user_id );
819
+						$this->update_meta('_give_payment_user_id', $this->user_id);
820 820
 						break;
821 821
 
822 822
 					case 'form_title':
823
-						$this->update_meta( '_give_payment_form_title', $this->form_title );
823
+						$this->update_meta('_give_payment_form_title', $this->form_title);
824 824
 						break;
825 825
 
826 826
 					case 'form_id':
827
-						$this->update_meta( '_give_payment_form_id', $this->form_id );
827
+						$this->update_meta('_give_payment_form_id', $this->form_id);
828 828
 						break;
829 829
 
830 830
 					case 'price_id':
831
-						$this->update_meta( '_give_payment_price_id', $this->price_id );
831
+						$this->update_meta('_give_payment_price_id', $this->price_id);
832 832
 						break;
833 833
 
834 834
 					case 'first_name':
@@ -844,15 +844,15 @@  discard block
 block discarded – undo
844 844
 						break;
845 845
 
846 846
 					case 'email':
847
-						$this->update_meta( '_give_payment_user_email', $this->email );
847
+						$this->update_meta('_give_payment_user_email', $this->email);
848 848
 						break;
849 849
 
850 850
 					case 'key':
851
-						$this->update_meta( '_give_payment_purchase_key', $this->key );
851
+						$this->update_meta('_give_payment_purchase_key', $this->key);
852 852
 						break;
853 853
 
854 854
 					case 'number':
855
-						$this->update_meta( '_give_payment_number', $this->number );
855
+						$this->update_meta('_give_payment_number', $this->number);
856 856
 						break;
857 857
 
858 858
 					case 'date':
@@ -862,11 +862,11 @@  discard block
 block discarded – undo
862 862
 							'edit_date' => true,
863 863
 						);
864 864
 
865
-						wp_update_post( $args );
865
+						wp_update_post($args);
866 866
 						break;
867 867
 
868 868
 					case 'completed_date':
869
-						$this->update_meta( '_give_completed_date', $this->completed_date );
869
+						$this->update_meta('_give_completed_date', $this->completed_date);
870 870
 						break;
871 871
 
872 872
 					case 'parent_payment':
@@ -875,7 +875,7 @@  discard block
 block discarded – undo
875 875
 							'post_parent' => $this->parent_payment,
876 876
 						);
877 877
 
878
-						wp_update_post( $args );
878
+						wp_update_post($args);
879 879
 						break;
880 880
 
881 881
 					default:
@@ -886,33 +886,33 @@  discard block
 block discarded – undo
886 886
 						 *
887 887
 						 * @param Give_Payment $this Payment object.
888 888
 						 */
889
-						do_action( 'give_payment_save', $this, $key );
889
+						do_action('give_payment_save', $this, $key);
890 890
 						break;
891 891
 				}// End switch().
892 892
 			}// End foreach().
893 893
 
894
-			if ( 'pending' !== $this->status ) {
894
+			if ('pending' !== $this->status) {
895 895
 
896
-				$donor = new Give_Donor( $this->customer_id );
896
+				$donor = new Give_Donor($this->customer_id);
897 897
 
898 898
 				$total_change = $total_increase - $total_decrease;
899
-				if ( $total_change < 0 ) {
899
+				if ($total_change < 0) {
900 900
 
901
-					$total_change = - ( $total_change );
901
+					$total_change = - ($total_change);
902 902
 					// Decrease the donor's donation stats.
903
-					$donor->decrease_value( $total_change );
904
-					give_decrease_total_earnings( $total_change );
903
+					$donor->decrease_value($total_change);
904
+					give_decrease_total_earnings($total_change);
905 905
 
906
-				} elseif ( $total_change > 0 ) {
906
+				} elseif ($total_change > 0) {
907 907
 
908 908
 					// Increase the donor's donation stats.
909
-					$donor->increase_value( $total_change );
910
-					give_increase_total_earnings( $total_change );
909
+					$donor->increase_value($total_change);
910
+					give_increase_total_earnings($total_change);
911 911
 
912 912
 				}
913 913
 			}
914 914
 
915
-			$this->update_meta( '_give_payment_total', give_sanitize_amount_for_db( $this->total ) );
915
+			$this->update_meta('_give_payment_total', give_sanitize_amount_for_db($this->total));
916 916
 
917 917
 			$new_meta = array(
918 918
 				'form_title' => $this->form_title,
@@ -923,12 +923,12 @@  discard block
 block discarded – undo
923 923
 			);
924 924
 
925 925
 			$meta        = $this->get_meta();
926
-			$merged_meta = array_merge( $meta, $new_meta );
926
+			$merged_meta = array_merge($meta, $new_meta);
927 927
 
928 928
 			// Only save the payment meta if it's changed.
929
-			if ( md5( serialize( $meta ) ) !== md5( serialize( $merged_meta ) ) ) {
930
-				$updated = $this->update_meta( '_give_payment_meta', $merged_meta );
931
-				if ( false !== $updated ) {
929
+			if (md5(serialize($meta)) !== md5(serialize($merged_meta))) {
930
+				$updated = $this->update_meta('_give_payment_meta', $merged_meta);
931
+				if (false !== $updated) {
932 932
 					$saved = true;
933 933
 				}
934 934
 			}
@@ -937,8 +937,8 @@  discard block
 block discarded – undo
937 937
 			$saved         = true;
938 938
 		}// End if().
939 939
 
940
-		if ( true === $saved ) {
941
-			$this->setup_payment( $this->ID );
940
+		if (true === $saved) {
941
+			$this->setup_payment($this->ID);
942 942
 		}
943 943
 
944 944
 		return $saved;
@@ -956,12 +956,12 @@  discard block
 block discarded – undo
956 956
 	 *
957 957
 	 * @return bool           True when successful, false otherwise
958 958
 	 */
959
-	public function add_donation( $form_id = 0, $args = array(), $options = array() ) {
959
+	public function add_donation($form_id = 0, $args = array(), $options = array()) {
960 960
 
961
-		$donation = new Give_Donate_Form( $form_id );
961
+		$donation = new Give_Donate_Form($form_id);
962 962
 
963 963
 		// Bail if this post isn't a give donation form.
964
-		if ( ! $donation || $donation->post_type !== 'give_forms' ) {
964
+		if ( ! $donation || $donation->post_type !== 'give_forms') {
965 965
 			return false;
966 966
 		}
967 967
 
@@ -971,59 +971,59 @@  discard block
 block discarded – undo
971 971
 			'price_id' => false,
972 972
 		);
973 973
 
974
-		$args = wp_parse_args( apply_filters( 'give_payment_add_donation_args', $args, $donation->ID ), $defaults );
974
+		$args = wp_parse_args(apply_filters('give_payment_add_donation_args', $args, $donation->ID), $defaults);
975 975
 
976 976
 		// Allow overriding the price.
977
-		if ( false !== $args['price'] ) {
977
+		if (false !== $args['price']) {
978 978
 			$item_price = $args['price'];
979 979
 		} else {
980 980
 
981 981
 			// Deal with variable pricing.
982
-			if ( give_has_variable_prices( $donation->ID ) ) {
983
-				$prices     = maybe_unserialize( give_get_meta( $form_id, '_give_donation_levels', true ) );
982
+			if (give_has_variable_prices($donation->ID)) {
983
+				$prices     = maybe_unserialize(give_get_meta($form_id, '_give_donation_levels', true));
984 984
 				$item_price = '';
985 985
 				// Loop through prices.
986
-				foreach ( $prices as $price ) {
986
+				foreach ($prices as $price) {
987 987
 					// Find a match between price_id and level_id.
988 988
 					// First verify array keys exists THEN make the match.
989
-					if ( ( isset( $args['price_id'] ) && isset( $price['_give_id']['level_id'] ) )
989
+					if ((isset($args['price_id']) && isset($price['_give_id']['level_id']))
990 990
 					     && $args['price_id'] == $price['_give_id']['level_id']
991 991
 					) {
992 992
 						$item_price = $price['_give_amount'];
993 993
 					}
994 994
 				}
995 995
 				// Fallback to the lowest price point.
996
-				if ( $item_price == '' ) {
997
-					$item_price       = give_get_lowest_price_option( $donation->ID );
998
-					$args['price_id'] = give_get_lowest_price_id( $donation->ID );
996
+				if ($item_price == '') {
997
+					$item_price       = give_get_lowest_price_option($donation->ID);
998
+					$args['price_id'] = give_get_lowest_price_id($donation->ID);
999 999
 				}
1000 1000
 			} else {
1001 1001
 				// Simple form price.
1002
-				$item_price = give_get_form_price( $donation->ID );
1002
+				$item_price = give_get_form_price($donation->ID);
1003 1003
 			}
1004 1004
 		}
1005 1005
 
1006 1006
 		// Sanitizing the price here so we don't have a dozen calls later.
1007
-		$item_price = give_maybe_sanitize_amount( $item_price );
1008
-		$total      = round( $item_price, give_currency_decimal_filter() );
1007
+		$item_price = give_maybe_sanitize_amount($item_price);
1008
+		$total      = round($item_price, give_currency_decimal_filter());
1009 1009
 
1010 1010
 		// Add Options.
1011 1011
 		$default_options = array();
1012
-		if ( false !== $args['price_id'] ) {
1012
+		if (false !== $args['price_id']) {
1013 1013
 			$default_options['price_id'] = (int) $args['price_id'];
1014 1014
 		}
1015
-		$options = wp_parse_args( $options, $default_options );
1015
+		$options = wp_parse_args($options, $default_options);
1016 1016
 
1017 1017
 		// Do not allow totals to go negative.
1018
-		if ( $total < 0 ) {
1018
+		if ($total < 0) {
1019 1019
 			$total = 0;
1020 1020
 		}
1021 1021
 
1022 1022
 		$donation = array(
1023 1023
 			'name'     => $donation->post_title,
1024 1024
 			'id'       => $donation->ID,
1025
-			'price'    => round( $total, give_currency_decimal_filter() ),
1026
-			'subtotal' => round( $total, give_currency_decimal_filter() ),
1025
+			'price'    => round($total, give_currency_decimal_filter()),
1026
+			'subtotal' => round($total, give_currency_decimal_filter()),
1027 1027
 			'price_id' => $args['price_id'],
1028 1028
 			'action'   => 'add',
1029 1029
 			'options'  => $options,
@@ -1031,7 +1031,7 @@  discard block
 block discarded – undo
1031 1031
 
1032 1032
 		$this->pending['donations'][] = $donation;
1033 1033
 
1034
-		$this->increase_subtotal( $total );
1034
+		$this->increase_subtotal($total);
1035 1035
 
1036 1036
 		return true;
1037 1037
 
@@ -1048,7 +1048,7 @@  discard block
 block discarded – undo
1048 1048
 	 *
1049 1049
 	 * @return bool           If the item was removed or not
1050 1050
 	 */
1051
-	public function remove_donation( $form_id, $args = array() ) {
1051
+	public function remove_donation($form_id, $args = array()) {
1052 1052
 
1053 1053
 		// Set some defaults.
1054 1054
 		$defaults = array(
@@ -1056,12 +1056,12 @@  discard block
 block discarded – undo
1056 1056
 			'price'    => false,
1057 1057
 			'price_id' => false,
1058 1058
 		);
1059
-		$args     = wp_parse_args( $args, $defaults );
1059
+		$args = wp_parse_args($args, $defaults);
1060 1060
 
1061
-		$form = new Give_Donate_Form( $form_id );
1061
+		$form = new Give_Donate_Form($form_id);
1062 1062
 
1063 1063
 		// Bail if this post isn't a valid give donation form.
1064
-		if ( ! $form || $form->post_type !== 'give_forms' ) {
1064
+		if ( ! $form || $form->post_type !== 'give_forms') {
1065 1065
 			return false;
1066 1066
 		}
1067 1067
 
@@ -1074,7 +1074,7 @@  discard block
 block discarded – undo
1074 1074
 
1075 1075
 		$this->pending['donations'][] = $pending_args;
1076 1076
 
1077
-		$this->decrease_subtotal( $this->total );
1077
+		$this->decrease_subtotal($this->total);
1078 1078
 
1079 1079
 		return true;
1080 1080
 	}
@@ -1090,13 +1090,13 @@  discard block
 block discarded – undo
1090 1090
 	 *
1091 1091
 	 * @return void
1092 1092
 	 */
1093
-	public function add_note( $note = false ) {
1093
+	public function add_note($note = false) {
1094 1094
 		// Bail if no note specified.
1095
-		if ( ! $note ) {
1095
+		if ( ! $note) {
1096 1096
 			return false;
1097 1097
 		}
1098 1098
 
1099
-		give_insert_payment_note( $this->ID, $note );
1099
+		give_insert_payment_note($this->ID, $note);
1100 1100
 	}
1101 1101
 
1102 1102
 	/**
@@ -1109,8 +1109,8 @@  discard block
 block discarded – undo
1109 1109
 	 *
1110 1110
 	 * @return void
1111 1111
 	 */
1112
-	private function increase_subtotal( $amount = 0.00 ) {
1113
-		$amount         = (float) $amount;
1112
+	private function increase_subtotal($amount = 0.00) {
1113
+		$amount = (float) $amount;
1114 1114
 		$this->subtotal += $amount;
1115 1115
 
1116 1116
 		$this->recalculate_total();
@@ -1126,11 +1126,11 @@  discard block
 block discarded – undo
1126 1126
 	 *
1127 1127
 	 * @return void
1128 1128
 	 */
1129
-	private function decrease_subtotal( $amount = 0.00 ) {
1130
-		$amount         = (float) $amount;
1129
+	private function decrease_subtotal($amount = 0.00) {
1130
+		$amount = (float) $amount;
1131 1131
 		$this->subtotal -= $amount;
1132 1132
 
1133
-		if ( $this->subtotal < 0 ) {
1133
+		if ($this->subtotal < 0) {
1134 1134
 			$this->subtotal = 0;
1135 1135
 		}
1136 1136
 
@@ -1159,24 +1159,24 @@  discard block
 block discarded – undo
1159 1159
 	 *
1160 1160
 	 * @return bool   $updated Returns if the status was successfully updated.
1161 1161
 	 */
1162
-	public function update_status( $status = false ) {
1162
+	public function update_status($status = false) {
1163 1163
 
1164 1164
 		// standardize the 'complete(d)' status.
1165
-		if ( $status == 'completed' || $status == 'complete' ) {
1165
+		if ($status == 'completed' || $status == 'complete') {
1166 1166
 			$status = 'publish';
1167 1167
 		}
1168 1168
 
1169
-		$old_status = ! empty( $this->old_status ) ? $this->old_status : false;
1169
+		$old_status = ! empty($this->old_status) ? $this->old_status : false;
1170 1170
 
1171
-		if ( $old_status === $status ) {
1171
+		if ($old_status === $status) {
1172 1172
 			return false; // Don't permit status changes that aren't changes.
1173 1173
 		}
1174 1174
 
1175
-		$do_change = apply_filters( 'give_should_update_payment_status', true, $this->ID, $status, $old_status );
1175
+		$do_change = apply_filters('give_should_update_payment_status', true, $this->ID, $status, $old_status);
1176 1176
 
1177 1177
 		$updated = false;
1178 1178
 
1179
-		if ( $do_change ) {
1179
+		if ($do_change) {
1180 1180
 
1181 1181
 			/**
1182 1182
 			 * Fires before changing payment status.
@@ -1187,21 +1187,21 @@  discard block
 block discarded – undo
1187 1187
 			 * @param string $status The new status.
1188 1188
 			 * @param string $old_status The old status.
1189 1189
 			 */
1190
-			do_action( 'give_before_payment_status_change', $this->ID, $status, $old_status );
1190
+			do_action('give_before_payment_status_change', $this->ID, $status, $old_status);
1191 1191
 
1192 1192
 			$update_fields = array(
1193 1193
 				'ID'          => $this->ID,
1194 1194
 				'post_status' => $status,
1195
-				'edit_date'   => current_time( 'mysql' ),
1195
+				'edit_date'   => current_time('mysql'),
1196 1196
 			);
1197 1197
 
1198
-			$updated = wp_update_post( apply_filters( 'give_update_payment_status_fields', $update_fields ) );
1198
+			$updated = wp_update_post(apply_filters('give_update_payment_status_fields', $update_fields));
1199 1199
 
1200 1200
 			$all_payment_statuses  = give_get_payment_statuses();
1201
-			$this->status_nicename = array_key_exists( $status, $all_payment_statuses ) ? $all_payment_statuses[ $status ] : ucfirst( $status );
1201
+			$this->status_nicename = array_key_exists($status, $all_payment_statuses) ? $all_payment_statuses[$status] : ucfirst($status);
1202 1202
 
1203 1203
 			// Process any specific status functions.
1204
-			switch ( $status ) {
1204
+			switch ($status) {
1205 1205
 				case 'refunded':
1206 1206
 					$this->process_refund();
1207 1207
 					break;
@@ -1228,7 +1228,7 @@  discard block
 block discarded – undo
1228 1228
 			 * @param string $status The new status.
1229 1229
 			 * @param string $old_status The old status.
1230 1230
 			 */
1231
-			do_action( 'give_update_payment_status', $this->ID, $status, $old_status );
1231
+			do_action('give_update_payment_status', $this->ID, $status, $old_status);
1232 1232
 
1233 1233
 		}// End if().
1234 1234
 
@@ -1263,33 +1263,33 @@  discard block
 block discarded – undo
1263 1263
 	 *
1264 1264
 	 * @return mixed             The value from the post meta
1265 1265
 	 */
1266
-	public function get_meta( $meta_key = '_give_payment_meta', $single = true ) {
1266
+	public function get_meta($meta_key = '_give_payment_meta', $single = true) {
1267 1267
 
1268
-		$meta = give_get_meta( $this->ID, $meta_key, $single );
1268
+		$meta = give_get_meta($this->ID, $meta_key, $single);
1269 1269
 
1270
-		if ( $meta_key === '_give_payment_meta' ) {
1270
+		if ($meta_key === '_give_payment_meta') {
1271 1271
 			$meta = (array) $meta;
1272 1272
 
1273
-			if ( empty( $meta['key'] ) ) {
1273
+			if (empty($meta['key'])) {
1274 1274
 				$meta['key'] = $this->setup_payment_key();
1275 1275
 			}
1276 1276
 
1277
-			if ( empty( $meta['form_title'] ) ) {
1277
+			if (empty($meta['form_title'])) {
1278 1278
 				$meta['form_title'] = $this->setup_form_title();
1279 1279
 			}
1280 1280
 
1281
-			if ( empty( $meta['email'] ) ) {
1281
+			if (empty($meta['email'])) {
1282 1282
 				$meta['email'] = $this->setup_email();
1283 1283
 			}
1284 1284
 
1285
-			if ( empty( $meta['date'] ) ) {
1286
-				$meta['date'] = get_post_field( 'post_date', $this->ID );
1285
+			if (empty($meta['date'])) {
1286
+				$meta['date'] = get_post_field('post_date', $this->ID);
1287 1287
 			}
1288 1288
 		}
1289 1289
 
1290
-		$meta = apply_filters( "give_get_payment_meta_{$meta_key}", $meta, $this->ID );
1290
+		$meta = apply_filters("give_get_payment_meta_{$meta_key}", $meta, $this->ID);
1291 1291
 
1292
-		return apply_filters( 'give_get_payment_meta', $meta, $this->ID, $meta_key );
1292
+		return apply_filters('give_get_payment_meta', $meta, $this->ID, $meta_key);
1293 1293
 	}
1294 1294
 
1295 1295
 	/**
@@ -1304,23 +1304,23 @@  discard block
 block discarded – undo
1304 1304
 	 *
1305 1305
 	 * @return int|bool           Meta ID if the key didn't exist, true on successful update, false on failure
1306 1306
 	 */
1307
-	public function update_meta( $meta_key = '', $meta_value = '', $prev_value = '' ) {
1308
-		if ( empty( $meta_key ) ) {
1307
+	public function update_meta($meta_key = '', $meta_value = '', $prev_value = '') {
1308
+		if (empty($meta_key)) {
1309 1309
 			return false;
1310 1310
 		}
1311 1311
 
1312
-		if ( $meta_key == 'key' || $meta_key == 'date' ) {
1312
+		if ($meta_key == 'key' || $meta_key == 'date') {
1313 1313
 
1314 1314
 			$current_meta              = $this->get_meta();
1315
-			$current_meta[ $meta_key ] = $meta_value;
1315
+			$current_meta[$meta_key] = $meta_value;
1316 1316
 
1317 1317
 			$meta_key   = '_give_payment_meta';
1318 1318
 			$meta_value = $current_meta;
1319 1319
 
1320
-		} elseif ( $meta_key == 'email' || $meta_key == '_give_payment_user_email' ) {
1320
+		} elseif ($meta_key == 'email' || $meta_key == '_give_payment_user_email') {
1321 1321
 
1322
-			$meta_value = apply_filters( "give_update_payment_meta_{$meta_key}", $meta_value, $this->ID );
1323
-			give_update_meta( $this->ID, '_give_payment_user_email', $meta_value );
1322
+			$meta_value = apply_filters("give_update_payment_meta_{$meta_key}", $meta_value, $this->ID);
1323
+			give_update_meta($this->ID, '_give_payment_user_email', $meta_value);
1324 1324
 
1325 1325
 			$current_meta                       = $this->get_meta();
1326 1326
 			$current_meta['user_info']['email'] = $meta_value;
@@ -1330,9 +1330,9 @@  discard block
 block discarded – undo
1330 1330
 
1331 1331
 		}
1332 1332
 
1333
-		$meta_value = apply_filters( "give_update_payment_meta_{$meta_key}", $meta_value, $this->ID );
1333
+		$meta_value = apply_filters("give_update_payment_meta_{$meta_key}", $meta_value, $this->ID);
1334 1334
 
1335
-		return give_update_meta( $this->ID, $meta_key, $meta_value, $prev_value );
1335
+		return give_update_meta($this->ID, $meta_key, $meta_value, $prev_value);
1336 1336
 	}
1337 1337
 
1338 1338
 	/**
@@ -1347,14 +1347,14 @@  discard block
 block discarded – undo
1347 1347
 		$process_refund = true;
1348 1348
 
1349 1349
 		// If the payment was not in publish or revoked status, don't decrement stats as they were never incremented.
1350
-		if ( 'publish' != $this->old_status || 'refunded' != $this->status ) {
1350
+		if ('publish' != $this->old_status || 'refunded' != $this->status) {
1351 1351
 			$process_refund = false;
1352 1352
 		}
1353 1353
 
1354 1354
 		// Allow extensions to filter for their own payment types, Example: Recurring Payments.
1355
-		$process_refund = apply_filters( 'give_should_process_refund', $process_refund, $this );
1355
+		$process_refund = apply_filters('give_should_process_refund', $process_refund, $this);
1356 1356
 
1357
-		if ( false === $process_refund ) {
1357
+		if (false === $process_refund) {
1358 1358
 			return;
1359 1359
 		}
1360 1360
 
@@ -1365,13 +1365,13 @@  discard block
 block discarded – undo
1365 1365
 		 *
1366 1366
 		 * @param Give_Payment $this Payment object.
1367 1367
 		 */
1368
-		do_action( 'give_pre_refund_payment', $this );
1368
+		do_action('give_pre_refund_payment', $this);
1369 1369
 
1370
-		$decrease_earnings       = apply_filters( 'give_decrease_store_earnings_on_refund', true, $this );
1371
-		$decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_refund', true, $this );
1372
-		$decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_refund', true, $this );
1370
+		$decrease_earnings       = apply_filters('give_decrease_store_earnings_on_refund', true, $this);
1371
+		$decrease_customer_value = apply_filters('give_decrease_customer_value_on_refund', true, $this);
1372
+		$decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_refund', true, $this);
1373 1373
 
1374
-		$this->maybe_alter_stats( $decrease_earnings, $decrease_customer_value, $decrease_purchase_count );
1374
+		$this->maybe_alter_stats($decrease_earnings, $decrease_customer_value, $decrease_purchase_count);
1375 1375
 		$this->delete_sales_logs();
1376 1376
 
1377 1377
 		// @todo: Refresh only range related stat cache
@@ -1384,7 +1384,7 @@  discard block
 block discarded – undo
1384 1384
 		 *
1385 1385
 		 * @param Give_Payment $this Payment object.
1386 1386
 		 */
1387
-		do_action( 'give_post_refund_payment', $this );
1387
+		do_action('give_post_refund_payment', $this);
1388 1388
 	}
1389 1389
 
1390 1390
 	/**
@@ -1411,26 +1411,26 @@  discard block
 block discarded – undo
1411 1411
 		$process_pending = true;
1412 1412
 
1413 1413
 		// If the payment was not in publish or revoked status, don't decrement stats as they were never incremented.
1414
-		if ( 'publish' != $this->old_status || 'pending' != $this->status ) {
1414
+		if ('publish' != $this->old_status || 'pending' != $this->status) {
1415 1415
 			$process_pending = false;
1416 1416
 		}
1417 1417
 
1418 1418
 		// Allow extensions to filter for their own payment types, Example: Recurring Payments.
1419
-		$process_pending = apply_filters( 'give_should_process_pending', $process_pending, $this );
1419
+		$process_pending = apply_filters('give_should_process_pending', $process_pending, $this);
1420 1420
 
1421
-		if ( false === $process_pending ) {
1421
+		if (false === $process_pending) {
1422 1422
 			return;
1423 1423
 		}
1424 1424
 
1425
-		$decrease_earnings       = apply_filters( 'give_decrease_earnings_on_pending', true, $this );
1426
-		$decrease_donor_value    = apply_filters( 'give_decrease_donor_value_on_pending', true, $this );
1427
-		$decrease_donation_count = apply_filters( 'give_decrease_donors_donation_count_on_pending', true, $this );
1425
+		$decrease_earnings       = apply_filters('give_decrease_earnings_on_pending', true, $this);
1426
+		$decrease_donor_value    = apply_filters('give_decrease_donor_value_on_pending', true, $this);
1427
+		$decrease_donation_count = apply_filters('give_decrease_donors_donation_count_on_pending', true, $this);
1428 1428
 
1429
-		$this->maybe_alter_stats( $decrease_earnings, $decrease_donor_value, $decrease_donation_count );
1429
+		$this->maybe_alter_stats($decrease_earnings, $decrease_donor_value, $decrease_donation_count);
1430 1430
 		$this->delete_sales_logs();
1431 1431
 
1432 1432
 		$this->completed_date = false;
1433
-		$this->update_meta( '_give_completed_date', '' );
1433
+		$this->update_meta('_give_completed_date', '');
1434 1434
 
1435 1435
 		// @todo: Refresh only range related stat cache
1436 1436
 		give_delete_donation_stats();
@@ -1448,26 +1448,26 @@  discard block
 block discarded – undo
1448 1448
 		$process_cancelled = true;
1449 1449
 
1450 1450
 		// If the payment was not in publish or revoked status, don't decrement stats as they were never incremented.
1451
-		if ( 'publish' != $this->old_status || 'cancelled' != $this->status ) {
1451
+		if ('publish' != $this->old_status || 'cancelled' != $this->status) {
1452 1452
 			$process_cancelled = false;
1453 1453
 		}
1454 1454
 
1455 1455
 		// Allow extensions to filter for their own payment types, Example: Recurring Payments.
1456
-		$process_cancelled = apply_filters( 'give_should_process_cancelled', $process_cancelled, $this );
1456
+		$process_cancelled = apply_filters('give_should_process_cancelled', $process_cancelled, $this);
1457 1457
 
1458
-		if ( false === $process_cancelled ) {
1458
+		if (false === $process_cancelled) {
1459 1459
 			return;
1460 1460
 		}
1461 1461
 
1462
-		$decrease_earnings       = apply_filters( 'give_decrease_earnings_on_cancelled', true, $this );
1463
-		$decrease_donor_value    = apply_filters( 'give_decrease_donor_value_on_cancelled', true, $this );
1464
-		$decrease_donation_count = apply_filters( 'give_decrease_donors_donation_count_on_cancelled', true, $this );
1462
+		$decrease_earnings       = apply_filters('give_decrease_earnings_on_cancelled', true, $this);
1463
+		$decrease_donor_value    = apply_filters('give_decrease_donor_value_on_cancelled', true, $this);
1464
+		$decrease_donation_count = apply_filters('give_decrease_donors_donation_count_on_cancelled', true, $this);
1465 1465
 
1466
-		$this->maybe_alter_stats( $decrease_earnings, $decrease_donor_value, $decrease_donation_count );
1466
+		$this->maybe_alter_stats($decrease_earnings, $decrease_donor_value, $decrease_donation_count);
1467 1467
 		$this->delete_sales_logs();
1468 1468
 
1469 1469
 		$this->completed_date = false;
1470
-		$this->update_meta( '_give_completed_date', '' );
1470
+		$this->update_meta('_give_completed_date', '');
1471 1471
 
1472 1472
 		// @todo: Refresh only range related stat cache
1473 1473
 		give_delete_donation_stats();
@@ -1483,26 +1483,26 @@  discard block
 block discarded – undo
1483 1483
 		$process_revoked = true;
1484 1484
 
1485 1485
 		// If the payment was not in publish, don't decrement stats as they were never incremented.
1486
-		if ( 'publish' != $this->old_status || 'revoked' != $this->status ) {
1486
+		if ('publish' != $this->old_status || 'revoked' != $this->status) {
1487 1487
 			$process_revoked = false;
1488 1488
 		}
1489 1489
 
1490 1490
 		// Allow extensions to filter for their own payment types, Example: Recurring Payments.
1491
-		$process_revoked = apply_filters( 'give_should_process_revoked', $process_revoked, $this );
1491
+		$process_revoked = apply_filters('give_should_process_revoked', $process_revoked, $this);
1492 1492
 
1493
-		if ( false === $process_revoked ) {
1493
+		if (false === $process_revoked) {
1494 1494
 			return;
1495 1495
 		}
1496 1496
 
1497
-		$decrease_earnings       = apply_filters( 'give_decrease_earnings_on_revoked', true, $this );
1498
-		$decrease_donor_value    = apply_filters( 'give_decrease_donor_value_on_revoked', true, $this );
1499
-		$decrease_donation_count = apply_filters( 'give_decrease_donors_donation_count_on_revoked', true, $this );
1497
+		$decrease_earnings       = apply_filters('give_decrease_earnings_on_revoked', true, $this);
1498
+		$decrease_donor_value    = apply_filters('give_decrease_donor_value_on_revoked', true, $this);
1499
+		$decrease_donation_count = apply_filters('give_decrease_donors_donation_count_on_revoked', true, $this);
1500 1500
 
1501
-		$this->maybe_alter_stats( $decrease_earnings, $decrease_donor_value, $decrease_donation_count );
1501
+		$this->maybe_alter_stats($decrease_earnings, $decrease_donor_value, $decrease_donation_count);
1502 1502
 		$this->delete_sales_logs();
1503 1503
 
1504 1504
 		$this->completed_date = false;
1505
-		$this->update_meta( '_give_completed_date', '' );
1505
+		$this->update_meta('_give_completed_date', '');
1506 1506
 
1507 1507
 		// @todo: Refresh only range related stat cache
1508 1508
 		give_delete_donation_stats();
@@ -1520,25 +1520,25 @@  discard block
 block discarded – undo
1520 1520
 	 *
1521 1521
 	 * @return void
1522 1522
 	 */
1523
-	private function maybe_alter_stats( $alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count ) {
1523
+	private function maybe_alter_stats($alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count) {
1524 1524
 
1525
-		give_undo_donation( $this->ID );
1525
+		give_undo_donation($this->ID);
1526 1526
 
1527 1527
 		// Decrease store earnings.
1528
-		if ( true === $alter_store_earnings ) {
1529
-			give_decrease_total_earnings( $this->total );
1528
+		if (true === $alter_store_earnings) {
1529
+			give_decrease_total_earnings($this->total);
1530 1530
 		}
1531 1531
 
1532 1532
 		// Decrement the stats for the donor.
1533
-		if ( ! empty( $this->customer_id ) ) {
1533
+		if ( ! empty($this->customer_id)) {
1534 1534
 
1535
-			$donor = new Give_Donor( $this->customer_id );
1535
+			$donor = new Give_Donor($this->customer_id);
1536 1536
 
1537
-			if ( true === $alter_customer_value ) {
1538
-				$donor->decrease_value( $this->total );
1537
+			if (true === $alter_customer_value) {
1538
+				$donor->decrease_value($this->total);
1539 1539
 			}
1540 1540
 
1541
-			if ( true === $alter_customer_purchase_count ) {
1541
+			if (true === $alter_customer_purchase_count) {
1542 1542
 				$donor->decrease_donation_count();
1543 1543
 			}
1544 1544
 		}
@@ -1587,13 +1587,13 @@  discard block
 block discarded – undo
1587 1587
 	 * @return string The date the payment was completed
1588 1588
 	 */
1589 1589
 	private function setup_completed_date() {
1590
-		$payment = get_post( $this->ID );
1590
+		$payment = get_post($this->ID);
1591 1591
 
1592
-		if ( 'pending' == $payment->post_status || 'preapproved' == $payment->post_status ) {
1592
+		if ('pending' == $payment->post_status || 'preapproved' == $payment->post_status) {
1593 1593
 			return false; // This payment was never completed.
1594 1594
 		}
1595 1595
 
1596
-		$date = ( $date = $this->get_meta( '_give_completed_date', true ) ) ? $date : $payment->modified_date;
1596
+		$date = ($date = $this->get_meta('_give_completed_date', true)) ? $date : $payment->modified_date;
1597 1597
 
1598 1598
 		return $date;
1599 1599
 	}
@@ -1607,7 +1607,7 @@  discard block
 block discarded – undo
1607 1607
 	 * @return string The payment mode
1608 1608
 	 */
1609 1609
 	private function setup_mode() {
1610
-		return $this->get_meta( '_give_payment_mode' );
1610
+		return $this->get_meta('_give_payment_mode');
1611 1611
 	}
1612 1612
 
1613 1613
 	/**
@@ -1619,18 +1619,18 @@  discard block
 block discarded – undo
1619 1619
 	 * @return float The payment total
1620 1620
 	 */
1621 1621
 	private function setup_total() {
1622
-		$amount = $this->get_meta( '_give_payment_total', true );
1622
+		$amount = $this->get_meta('_give_payment_total', true);
1623 1623
 
1624
-		if ( empty( $amount ) && '0.00' != $amount ) {
1625
-			$meta = $this->get_meta( '_give_payment_meta', true );
1626
-			$meta = maybe_unserialize( $meta );
1624
+		if (empty($amount) && '0.00' != $amount) {
1625
+			$meta = $this->get_meta('_give_payment_meta', true);
1626
+			$meta = maybe_unserialize($meta);
1627 1627
 
1628
-			if ( isset( $meta['amount'] ) ) {
1628
+			if (isset($meta['amount'])) {
1629 1629
 				$amount = $meta['amount'];
1630 1630
 			}
1631 1631
 		}
1632 1632
 
1633
-		return round( floatval( $amount ), give_currency_decimal_filter() );
1633
+		return round(floatval($amount), give_currency_decimal_filter());
1634 1634
 	}
1635 1635
 
1636 1636
 	/**
@@ -1656,7 +1656,7 @@  discard block
 block discarded – undo
1656 1656
 	 * @return string The currency for the payment
1657 1657
 	 */
1658 1658
 	private function setup_currency() {
1659
-		$currency = isset( $this->payment_meta['currency'] ) ? $this->payment_meta['currency'] : apply_filters( 'give_payment_currency_default', give_get_currency(), $this );
1659
+		$currency = isset($this->payment_meta['currency']) ? $this->payment_meta['currency'] : apply_filters('give_payment_currency_default', give_get_currency(), $this);
1660 1660
 
1661 1661
 		return $currency;
1662 1662
 	}
@@ -1670,7 +1670,7 @@  discard block
 block discarded – undo
1670 1670
 	 * @return string The gateway
1671 1671
 	 */
1672 1672
 	private function setup_gateway() {
1673
-		$gateway = $this->get_meta( '_give_payment_gateway', true );
1673
+		$gateway = $this->get_meta('_give_payment_gateway', true);
1674 1674
 
1675 1675
 		return $gateway;
1676 1676
 	}
@@ -1684,11 +1684,11 @@  discard block
 block discarded – undo
1684 1684
 	 * @return string The donation ID
1685 1685
 	 */
1686 1686
 	private function setup_transaction_id() {
1687
-		$transaction_id = $this->get_meta( '_give_payment_transaction_id', true );
1687
+		$transaction_id = $this->get_meta('_give_payment_transaction_id', true);
1688 1688
 
1689
-		if ( empty( $transaction_id ) ) {
1689
+		if (empty($transaction_id)) {
1690 1690
 			$gateway        = $this->gateway;
1691
-			$transaction_id = apply_filters( "give_get_payment_transaction_id-{$gateway}", $this->ID );
1691
+			$transaction_id = apply_filters("give_get_payment_transaction_id-{$gateway}", $this->ID);
1692 1692
 		}
1693 1693
 
1694 1694
 		return $transaction_id;
@@ -1703,7 +1703,7 @@  discard block
 block discarded – undo
1703 1703
 	 * @return string The IP address for the payment
1704 1704
 	 */
1705 1705
 	private function setup_ip() {
1706
-		$ip = $this->get_meta( '_give_payment_user_ip', true );
1706
+		$ip = $this->get_meta('_give_payment_user_ip', true);
1707 1707
 
1708 1708
 		return $ip;
1709 1709
 	}
@@ -1717,7 +1717,7 @@  discard block
 block discarded – undo
1717 1717
 	 * @return int The Donor ID.
1718 1718
 	 */
1719 1719
 	private function setup_donor_id() {
1720
-		$customer_id = $this->get_meta( '_give_payment_customer_id', true );
1720
+		$customer_id = $this->get_meta('_give_payment_customer_id', true);
1721 1721
 
1722 1722
 		return $customer_id;
1723 1723
 	}
@@ -1731,7 +1731,7 @@  discard block
 block discarded – undo
1731 1731
 	 * @return int The User ID
1732 1732
 	 */
1733 1733
 	private function setup_user_id() {
1734
-		$user_id = $this->get_meta( '_give_payment_user_id', true );
1734
+		$user_id = $this->get_meta('_give_payment_user_id', true);
1735 1735
 
1736 1736
 		return $user_id;
1737 1737
 	}
@@ -1745,10 +1745,10 @@  discard block
 block discarded – undo
1745 1745
 	 * @return string The email address for the payment.
1746 1746
 	 */
1747 1747
 	private function setup_email() {
1748
-		$email = $this->get_meta( '_give_payment_user_email', true );
1748
+		$email = $this->get_meta('_give_payment_user_email', true);
1749 1749
 
1750
-		if ( empty( $email ) && $this->customer_id ) {
1751
-			$email = Give()->donors->get_column( 'email', $this->customer_id );
1750
+		if (empty($email) && $this->customer_id) {
1751
+			$email = Give()->donors->get_column('email', $this->customer_id);
1752 1752
 		}
1753 1753
 
1754 1754
 		return $email;
@@ -1768,15 +1768,15 @@  discard block
 block discarded – undo
1768 1768
 			'last_name'  => $this->last_name,
1769 1769
 		);
1770 1770
 
1771
-		$user_info = isset( $this->payment_meta['user_info'] ) ? maybe_unserialize( $this->payment_meta['user_info'] ) : array();
1772
-		$user_info = wp_parse_args( $user_info, $defaults );
1771
+		$user_info = isset($this->payment_meta['user_info']) ? maybe_unserialize($this->payment_meta['user_info']) : array();
1772
+		$user_info = wp_parse_args($user_info, $defaults);
1773 1773
 
1774
-		if ( empty( $user_info ) ) {
1774
+		if (empty($user_info)) {
1775 1775
 			// Get the donor, but only if it's been created.
1776
-			$donor = new Give_Donor( $this->customer_id );
1776
+			$donor = new Give_Donor($this->customer_id);
1777 1777
 
1778
-			if ( $donor->id > 0 ) {
1779
-				$name      = explode( ' ', $donor->name, 2 );
1778
+			if ($donor->id > 0) {
1779
+				$name      = explode(' ', $donor->name, 2);
1780 1780
 				$user_info = array(
1781 1781
 					'first_name' => $name[0],
1782 1782
 					'last_name'  => $name[1],
@@ -1786,29 +1786,29 @@  discard block
 block discarded – undo
1786 1786
 			}
1787 1787
 		} else {
1788 1788
 			// Get the donor, but only if it's been created.
1789
-			$donor = new Give_Donor( $this->customer_id );
1790
-			if ( $donor->id > 0 ) {
1791
-				foreach ( $user_info as $key => $value ) {
1792
-					if ( ! empty( $value ) ) {
1789
+			$donor = new Give_Donor($this->customer_id);
1790
+			if ($donor->id > 0) {
1791
+				foreach ($user_info as $key => $value) {
1792
+					if ( ! empty($value)) {
1793 1793
 						continue;
1794 1794
 					}
1795 1795
 
1796
-					switch ( $key ) {
1796
+					switch ($key) {
1797 1797
 						case 'first_name':
1798
-							$name = explode( ' ', $donor->name, 2 );
1798
+							$name = explode(' ', $donor->name, 2);
1799 1799
 
1800
-							$user_info[ $key ] = $name[0];
1800
+							$user_info[$key] = $name[0];
1801 1801
 							break;
1802 1802
 
1803 1803
 						case 'last_name':
1804
-							$name      = explode( ' ', $donor->name, 2 );
1805
-							$last_name = ! empty( $name[1] ) ? $name[1] : '';
1804
+							$name      = explode(' ', $donor->name, 2);
1805
+							$last_name = ! empty($name[1]) ? $name[1] : '';
1806 1806
 
1807
-							$user_info[ $key ] = $last_name;
1807
+							$user_info[$key] = $last_name;
1808 1808
 							break;
1809 1809
 
1810 1810
 						case 'email':
1811
-							$user_info[ $key ] = $donor->email;
1811
+							$user_info[$key] = $donor->email;
1812 1812
 							break;
1813 1813
 					}
1814 1814
 				}
@@ -1829,7 +1829,7 @@  discard block
 block discarded – undo
1829 1829
 	 */
1830 1830
 	private function setup_address() {
1831 1831
 
1832
-		$address = ! empty( $this->payment_meta['user_info']['address'] ) ? $this->payment_meta['user_info']['address'] : array(
1832
+		$address = ! empty($this->payment_meta['user_info']['address']) ? $this->payment_meta['user_info']['address'] : array(
1833 1833
 			'line1'   => '',
1834 1834
 			'line2'   => '',
1835 1835
 			'city'    => '',
@@ -1851,7 +1851,7 @@  discard block
 block discarded – undo
1851 1851
 	 */
1852 1852
 	private function setup_form_title() {
1853 1853
 
1854
-		$form_id = $this->get_meta( '_give_payment_form_title', true );
1854
+		$form_id = $this->get_meta('_give_payment_form_title', true);
1855 1855
 
1856 1856
 		return $form_id;
1857 1857
 	}
@@ -1866,7 +1866,7 @@  discard block
 block discarded – undo
1866 1866
 	 */
1867 1867
 	private function setup_form_id() {
1868 1868
 
1869
-		$form_id = $this->get_meta( '_give_payment_form_id', true );
1869
+		$form_id = $this->get_meta('_give_payment_form_id', true);
1870 1870
 
1871 1871
 		return $form_id;
1872 1872
 	}
@@ -1880,7 +1880,7 @@  discard block
 block discarded – undo
1880 1880
 	 * @return int The Form Price ID.
1881 1881
 	 */
1882 1882
 	private function setup_price_id() {
1883
-		$price_id = $this->get_meta( '_give_payment_price_id', true );
1883
+		$price_id = $this->get_meta('_give_payment_price_id', true);
1884 1884
 
1885 1885
 		return $price_id;
1886 1886
 	}
@@ -1894,7 +1894,7 @@  discard block
 block discarded – undo
1894 1894
 	 * @return string The Payment Key.
1895 1895
 	 */
1896 1896
 	private function setup_payment_key() {
1897
-		$key = $this->get_meta( '_give_payment_purchase_key', true );
1897
+		$key = $this->get_meta('_give_payment_purchase_key', true);
1898 1898
 
1899 1899
 		return $key;
1900 1900
 	}
@@ -1910,11 +1910,11 @@  discard block
 block discarded – undo
1910 1910
 	private function setup_payment_number() {
1911 1911
 		$number = $this->ID;
1912 1912
 
1913
-		if ( give_get_option( 'enable_sequential' ) ) {
1913
+		if (give_get_option('enable_sequential')) {
1914 1914
 
1915
-			$number = $this->get_meta( '_give_payment_number', true );
1915
+			$number = $this->get_meta('_give_payment_number', true);
1916 1916
 
1917
-			if ( ! $number ) {
1917
+			if ( ! $number) {
1918 1918
 
1919 1919
 				$number = $this->ID;
1920 1920
 
@@ -1932,7 +1932,7 @@  discard block
 block discarded – undo
1932 1932
 	 * @return array The payment object as an array.
1933 1933
 	 */
1934 1934
 	public function array_convert() {
1935
-		return get_object_vars( $this );
1935
+		return get_object_vars($this);
1936 1936
 	}
1937 1937
 
1938 1938
 
@@ -1945,7 +1945,7 @@  discard block
 block discarded – undo
1945 1945
 	 * @return bool
1946 1946
 	 */
1947 1947
 	public function is_completed() {
1948
-		return ( 'publish' === $this->status && $this->completed_date );
1948
+		return ('publish' === $this->status && $this->completed_date);
1949 1949
 	}
1950 1950
 
1951 1951
 	/**
@@ -1957,7 +1957,7 @@  discard block
 block discarded – undo
1957 1957
 	 * @return string Date payment was completed.
1958 1958
 	 */
1959 1959
 	private function get_completed_date() {
1960
-		return apply_filters( 'give_payment_completed_date', $this->completed_date, $this->ID, $this );
1960
+		return apply_filters('give_payment_completed_date', $this->completed_date, $this->ID, $this);
1961 1961
 	}
1962 1962
 
1963 1963
 	/**
@@ -1969,7 +1969,7 @@  discard block
 block discarded – undo
1969 1969
 	 * @return float Payment subtotal.
1970 1970
 	 */
1971 1971
 	private function get_subtotal() {
1972
-		return apply_filters( 'give_get_payment_subtotal', $this->subtotal, $this->ID, $this );
1972
+		return apply_filters('give_get_payment_subtotal', $this->subtotal, $this->ID, $this);
1973 1973
 	}
1974 1974
 
1975 1975
 	/**
@@ -1981,7 +1981,7 @@  discard block
 block discarded – undo
1981 1981
 	 * @return string Payment currency code.
1982 1982
 	 */
1983 1983
 	private function get_currency() {
1984
-		return apply_filters( 'give_payment_currency_code', $this->currency, $this->ID, $this );
1984
+		return apply_filters('give_payment_currency_code', $this->currency, $this->ID, $this);
1985 1985
 	}
1986 1986
 
1987 1987
 	/**
@@ -1993,7 +1993,7 @@  discard block
 block discarded – undo
1993 1993
 	 * @return string Gateway used.
1994 1994
 	 */
1995 1995
 	private function get_gateway() {
1996
-		return apply_filters( 'give_payment_gateway', $this->gateway, $this->ID, $this );
1996
+		return apply_filters('give_payment_gateway', $this->gateway, $this->ID, $this);
1997 1997
 	}
1998 1998
 
1999 1999
 	/**
@@ -2005,7 +2005,7 @@  discard block
 block discarded – undo
2005 2005
 	 * @return string Donation ID from merchant processor.
2006 2006
 	 */
2007 2007
 	private function get_transaction_id() {
2008
-		return apply_filters( 'give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this );
2008
+		return apply_filters('give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this);
2009 2009
 	}
2010 2010
 
2011 2011
 	/**
@@ -2017,7 +2017,7 @@  discard block
 block discarded – undo
2017 2017
 	 * @return string Payment IP address
2018 2018
 	 */
2019 2019
 	private function get_ip() {
2020
-		return apply_filters( 'give_payment_user_ip', $this->ip, $this->ID, $this );
2020
+		return apply_filters('give_payment_user_ip', $this->ip, $this->ID, $this);
2021 2021
 	}
2022 2022
 
2023 2023
 	/**
@@ -2029,7 +2029,7 @@  discard block
 block discarded – undo
2029 2029
 	 * @return int Payment donor ID.
2030 2030
 	 */
2031 2031
 	private function get_donor_id() {
2032
-		return apply_filters( 'give_payment_customer_id', $this->customer_id, $this->ID, $this );
2032
+		return apply_filters('give_payment_customer_id', $this->customer_id, $this->ID, $this);
2033 2033
 	}
2034 2034
 
2035 2035
 	/**
@@ -2041,7 +2041,7 @@  discard block
 block discarded – undo
2041 2041
 	 * @return int Payment user ID.
2042 2042
 	 */
2043 2043
 	private function get_user_id() {
2044
-		return apply_filters( 'give_payment_user_id', $this->user_id, $this->ID, $this );
2044
+		return apply_filters('give_payment_user_id', $this->user_id, $this->ID, $this);
2045 2045
 	}
2046 2046
 
2047 2047
 	/**
@@ -2053,7 +2053,7 @@  discard block
 block discarded – undo
2053 2053
 	 * @return string Payment donor email.
2054 2054
 	 */
2055 2055
 	private function get_email() {
2056
-		return apply_filters( 'give_payment_user_email', $this->email, $this->ID, $this );
2056
+		return apply_filters('give_payment_user_email', $this->email, $this->ID, $this);
2057 2057
 	}
2058 2058
 
2059 2059
 	/**
@@ -2065,7 +2065,7 @@  discard block
 block discarded – undo
2065 2065
 	 * @return array Payment user info.
2066 2066
 	 */
2067 2067
 	private function get_user_info() {
2068
-		return apply_filters( 'give_payment_meta_user_info', $this->user_info, $this->ID, $this );
2068
+		return apply_filters('give_payment_meta_user_info', $this->user_info, $this->ID, $this);
2069 2069
 	}
2070 2070
 
2071 2071
 	/**
@@ -2077,7 +2077,7 @@  discard block
 block discarded – undo
2077 2077
 	 * @return array Payment billing address.
2078 2078
 	 */
2079 2079
 	private function get_address() {
2080
-		return apply_filters( 'give_payment_address', $this->address, $this->ID, $this );
2080
+		return apply_filters('give_payment_address', $this->address, $this->ID, $this);
2081 2081
 	}
2082 2082
 
2083 2083
 	/**
@@ -2089,7 +2089,7 @@  discard block
 block discarded – undo
2089 2089
 	 * @return string Payment key.
2090 2090
 	 */
2091 2091
 	private function get_key() {
2092
-		return apply_filters( 'give_payment_key', $this->key, $this->ID, $this );
2092
+		return apply_filters('give_payment_key', $this->key, $this->ID, $this);
2093 2093
 	}
2094 2094
 
2095 2095
 	/**
@@ -2101,7 +2101,7 @@  discard block
 block discarded – undo
2101 2101
 	 * @return string Payment form id
2102 2102
 	 */
2103 2103
 	private function get_form_id() {
2104
-		return apply_filters( 'give_payment_form_id', $this->form_id, $this->ID, $this );
2104
+		return apply_filters('give_payment_form_id', $this->form_id, $this->ID, $this);
2105 2105
 	}
2106 2106
 
2107 2107
 	/**
@@ -2113,7 +2113,7 @@  discard block
 block discarded – undo
2113 2113
 	 * @return int|string Payment number
2114 2114
 	 */
2115 2115
 	private function get_number() {
2116
-		return apply_filters( 'give_payment_number', $this->number, $this->ID, $this );
2116
+		return apply_filters('give_payment_number', $this->number, $this->ID, $this);
2117 2117
 	}
2118 2118
 
2119 2119
 }
Please login to merge, or discard this patch.
includes/payments/functions.php 1 patch
Spacing   +408 added lines, -408 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
 
@@ -43,15 +43,15 @@  discard block
 block discarded – undo
43 43
  *
44 44
  * @return array $payments Payments retrieved from the database
45 45
  */
46
-function give_get_payments( $args = array() ) {
46
+function give_get_payments($args = array()) {
47 47
 
48 48
 	// Fallback to post objects to ensure backwards compatibility.
49
-	if ( ! isset( $args['output'] ) ) {
49
+	if ( ! isset($args['output'])) {
50 50
 		$args['output'] = 'posts';
51 51
 	}
52 52
 
53
-	$args     = apply_filters( 'give_get_payments_args', $args );
54
-	$payments = new Give_Payments_Query( $args );
53
+	$args     = apply_filters('give_get_payments_args', $args);
54
+	$payments = new Give_Payments_Query($args);
55 55
 
56 56
 	return $payments->get_payments();
57 57
 }
@@ -66,48 +66,48 @@  discard block
 block discarded – undo
66 66
  *
67 67
  * @return mixed
68 68
  */
69
-function give_get_payment_by( $field = '', $value = '' ) {
69
+function give_get_payment_by($field = '', $value = '') {
70 70
 
71
-	if ( empty( $field ) || empty( $value ) ) {
71
+	if (empty($field) || empty($value)) {
72 72
 		return false;
73 73
 	}
74 74
 
75
-	switch ( strtolower( $field ) ) {
75
+	switch (strtolower($field)) {
76 76
 
77 77
 		case 'id':
78
-			$payment = new Give_Payment( $value );
78
+			$payment = new Give_Payment($value);
79 79
 			$id      = $payment->ID;
80 80
 
81
-			if ( empty( $id ) ) {
81
+			if (empty($id)) {
82 82
 				return false;
83 83
 			}
84 84
 
85 85
 			break;
86 86
 
87 87
 		case 'key':
88
-			$payment = give_get_payments( array(
88
+			$payment = give_get_payments(array(
89 89
 				'meta_key'       => '_give_payment_purchase_key',
90 90
 				'meta_value'     => $value,
91 91
 				'posts_per_page' => 1,
92 92
 				'fields'         => 'ids',
93
-			) );
93
+			));
94 94
 
95
-			if ( $payment ) {
96
-				$payment = new Give_Payment( $payment[0] );
95
+			if ($payment) {
96
+				$payment = new Give_Payment($payment[0]);
97 97
 			}
98 98
 
99 99
 			break;
100 100
 
101 101
 		case 'payment_number':
102
-			$payment = give_get_payments( array(
102
+			$payment = give_get_payments(array(
103 103
 				'meta_key'       => '_give_payment_number',
104 104
 				'meta_value'     => $value,
105 105
 				'posts_per_page' => 1,
106 106
 				'fields'         => 'ids',
107
-			) );
107
+			));
108 108
 
109
-			if ( $payment ) {
110
-				$payment = new Give_Payment( $payment[0] );
109
+			if ($payment) {
110
+				$payment = new Give_Payment($payment[0]);
111 111
 			}
112 112
 
113 113
 			break;
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 			return false;
117 117
 	}// End switch().
118 118
 
119
-	if ( $payment ) {
119
+	if ($payment) {
120 120
 		return $payment;
121 121
 	}
122 122
 
@@ -132,23 +132,23 @@  discard block
 block discarded – undo
132 132
  *
133 133
  * @return int|bool Payment ID if payment is inserted, false otherwise.
134 134
  */
135
-function give_insert_payment( $payment_data = array() ) {
135
+function give_insert_payment($payment_data = array()) {
136 136
 
137
-	if ( empty( $payment_data ) ) {
137
+	if (empty($payment_data)) {
138 138
 		return false;
139 139
 	}
140 140
 
141 141
 	$payment    = new Give_Payment();
142
-	$gateway    = ! empty( $payment_data['gateway'] ) ? $payment_data['gateway'] : '';
143
-	$gateway    = empty( $gateway ) && isset( $_POST['give-gateway'] ) ? $_POST['give-gateway'] : $gateway;
144
-	$form_id    = isset( $payment_data['give_form_id'] ) ? $payment_data['give_form_id'] : 0;
145
-	$price_id   = give_get_payment_meta_price_id( $payment_data );
146
-	$form_title = isset( $payment_data['give_form_title'] ) ? $payment_data['give_form_title'] : get_the_title( $form_id );
142
+	$gateway    = ! empty($payment_data['gateway']) ? $payment_data['gateway'] : '';
143
+	$gateway    = empty($gateway) && isset($_POST['give-gateway']) ? $_POST['give-gateway'] : $gateway;
144
+	$form_id    = isset($payment_data['give_form_id']) ? $payment_data['give_form_id'] : 0;
145
+	$price_id   = give_get_payment_meta_price_id($payment_data);
146
+	$form_title = isset($payment_data['give_form_title']) ? $payment_data['give_form_title'] : get_the_title($form_id);
147 147
 
148 148
 	// Set properties.
149 149
 	$payment->total          = $payment_data['price'];
150
-	$payment->status         = ! empty( $payment_data['status'] ) ? $payment_data['status'] : 'pending';
151
-	$payment->currency       = ! empty( $payment_data['currency'] ) ? $payment_data['currency'] : give_get_currency();
150
+	$payment->status         = ! empty($payment_data['status']) ? $payment_data['status'] : 'pending';
151
+	$payment->currency       = ! empty($payment_data['currency']) ? $payment_data['currency'] : give_get_currency();
152 152
 	$payment->user_info      = $payment_data['user_info'];
153 153
 	$payment->gateway        = $gateway;
154 154
 	$payment->form_title     = $form_title;
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 	$payment->ip             = give_get_ip();
163 163
 	$payment->key            = $payment_data['purchase_key'];
164 164
 	$payment->mode           = give_is_test_mode() ? 'test' : 'live';
165
-	$payment->parent_payment = ! empty( $payment_data['parent'] ) ? absint( $payment_data['parent'] ) : '';
165
+	$payment->parent_payment = ! empty($payment_data['parent']) ? absint($payment_data['parent']) : '';
166 166
 
167 167
 	// Add the donation.
168 168
 	$args = array(
@@ -170,22 +170,22 @@  discard block
 block discarded – undo
170 170
 		'price_id' => $payment->price_id,
171 171
 	);
172 172
 
173
-	$payment->add_donation( $payment->form_id, $args );
173
+	$payment->add_donation($payment->form_id, $args);
174 174
 
175 175
 	// Set date if present.
176
-	if ( isset( $payment_data['post_date'] ) ) {
176
+	if (isset($payment_data['post_date'])) {
177 177
 		$payment->date = $payment_data['post_date'];
178 178
 	}
179 179
 
180 180
 	// Handle sequential payments.
181
-	if ( give_get_option( 'enable_sequential' ) ) {
181
+	if (give_get_option('enable_sequential')) {
182 182
 		$number          = give_get_next_payment_number();
183
-		$payment->number = give_format_payment_number( $number );
184
-		update_option( 'give_last_payment_number', $number );
183
+		$payment->number = give_format_payment_number($number);
184
+		update_option('give_last_payment_number', $number);
185 185
 	}
186 186
 
187 187
 	// Clear the user's donation cache.
188
-	delete_transient( 'give_user_' . $payment_data['user_info']['id'] . '_purchases' );
188
+	delete_transient('give_user_'.$payment_data['user_info']['id'].'_purchases');
189 189
 
190 190
 	// Save payment.
191 191
 	$payment->save();
@@ -198,10 +198,10 @@  discard block
 block discarded – undo
198 198
 	 * @param int   $payment_id   The payment ID.
199 199
 	 * @param array $payment_data Arguments passed.
200 200
 	 */
201
-	do_action( 'give_insert_payment', $payment->ID, $payment_data );
201
+	do_action('give_insert_payment', $payment->ID, $payment_data);
202 202
 
203 203
 	// Return payment ID upon success.
204
-	if ( ! empty( $payment->ID ) ) {
204
+	if ( ! empty($payment->ID)) {
205 205
 		return $payment->ID;
206 206
 	}
207 207
 
@@ -217,10 +217,10 @@  discard block
 block discarded – undo
217 217
  *
218 218
  * @return bool|int
219 219
  */
220
-function give_create_payment( $payment_data ) {
220
+function give_create_payment($payment_data) {
221 221
 
222
-	$form_id  = intval( $payment_data['post_data']['give-form-id'] );
223
-	$price_id = isset( $payment_data['post_data']['give-price-id'] ) ? $payment_data['post_data']['give-price-id'] : '';
222
+	$form_id  = intval($payment_data['post_data']['give-form-id']);
223
+	$price_id = isset($payment_data['post_data']['give-price-id']) ? $payment_data['post_data']['give-price-id'] : '';
224 224
 
225 225
 	// Collect payment data.
226 226
 	$insert_payment_data = array(
@@ -244,10 +244,10 @@  discard block
 block discarded – undo
244 244
 	 *
245 245
 	 * @param array $insert_payment_data
246 246
 	 */
247
-	$insert_payment_data = apply_filters( 'give_create_payment', $insert_payment_data );
247
+	$insert_payment_data = apply_filters('give_create_payment', $insert_payment_data);
248 248
 
249 249
 	// Record the pending payment.
250
-	return give_insert_payment( $insert_payment_data );
250
+	return give_insert_payment($insert_payment_data);
251 251
 }
252 252
 
253 253
 /**
@@ -260,9 +260,9 @@  discard block
 block discarded – undo
260 260
  *
261 261
  * @return bool
262 262
  */
263
-function give_update_payment_status( $payment_id, $new_status = 'publish' ) {
263
+function give_update_payment_status($payment_id, $new_status = 'publish') {
264 264
 
265
-	$payment         = new Give_Payment( $payment_id );
265
+	$payment         = new Give_Payment($payment_id);
266 266
 	$payment->status = $new_status;
267 267
 	$updated         = $payment->save();
268 268
 
@@ -281,38 +281,38 @@  discard block
 block discarded – undo
281 281
  *
282 282
  * @return void
283 283
  */
284
-function give_delete_donation( $payment_id = 0, $update_donor = true ) {
284
+function give_delete_donation($payment_id = 0, $update_donor = true) {
285 285
 	global $give_logs;
286 286
 
287
-	$payment  = new Give_Payment( $payment_id );
288
-	$amount   = give_get_payment_amount( $payment_id );
287
+	$payment  = new Give_Payment($payment_id);
288
+	$amount   = give_get_payment_amount($payment_id);
289 289
 	$status   = $payment->post_status;
290
-	$donor_id = give_get_payment_donor_id( $payment_id );
291
-	$donor    = new Give_Donor( $donor_id );
290
+	$donor_id = give_get_payment_donor_id($payment_id);
291
+	$donor    = new Give_Donor($donor_id);
292 292
 
293 293
 	// Only undo donations that aren't these statuses.
294
-	$dont_undo_statuses = apply_filters( 'give_undo_donation_statuses', array(
294
+	$dont_undo_statuses = apply_filters('give_undo_donation_statuses', array(
295 295
 		'pending',
296 296
 		'cancelled',
297
-	) );
297
+	));
298 298
 
299
-	if ( ! in_array( $status, $dont_undo_statuses ) ) {
300
-		give_undo_donation( $payment_id );
299
+	if ( ! in_array($status, $dont_undo_statuses)) {
300
+		give_undo_donation($payment_id);
301 301
 	}
302 302
 
303
-	if ( $status == 'publish' ) {
303
+	if ($status == 'publish') {
304 304
 
305 305
 		// Only decrease earnings if they haven't already been decreased (or were never increased for this payment).
306
-		give_decrease_total_earnings( $amount );
306
+		give_decrease_total_earnings($amount);
307 307
 
308 308
 		// @todo: Refresh only range related stat cache
309 309
 		give_delete_donation_stats();
310 310
 
311
-		if ( $donor->id && $update_donor ) {
311
+		if ($donor->id && $update_donor) {
312 312
 
313 313
 			// Decrement the stats for the donor.
314 314
 			$donor->decrease_donation_count();
315
-			$donor->decrease_value( $amount );
315
+			$donor->decrease_value($amount);
316 316
 
317 317
 		}
318 318
 	}
@@ -324,25 +324,25 @@  discard block
 block discarded – undo
324 324
 	 *
325 325
 	 * @param int $payment_id Payment ID.
326 326
 	 */
327
-	do_action( 'give_payment_delete', $payment_id );
327
+	do_action('give_payment_delete', $payment_id);
328 328
 
329
-	if ( $donor->id && $update_donor ) {
329
+	if ($donor->id && $update_donor) {
330 330
 
331 331
 		// Remove the payment ID from the donor.
332
-		$donor->remove_payment( $payment_id );
332
+		$donor->remove_payment($payment_id);
333 333
 
334 334
 	}
335 335
 
336 336
 	// Remove the payment.
337
-	wp_delete_post( $payment_id, true );
337
+	wp_delete_post($payment_id, true);
338 338
 
339 339
 	// Remove related sale log entries.
340
-	$give_logs->delete_logs( null, 'sale', array(
340
+	$give_logs->delete_logs(null, 'sale', array(
341 341
 		array(
342 342
 			'key'   => '_give_log_payment_id',
343 343
 			'value' => $payment_id,
344 344
 		),
345
-	) );
345
+	));
346 346
 
347 347
 	/**
348 348
 	 * Fires after payment deleted.
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 	 *
352 352
 	 * @param int $payment_id Payment ID.
353 353
 	 */
354
-	do_action( 'give_payment_deleted', $payment_id );
354
+	do_action('give_payment_deleted', $payment_id);
355 355
 }
356 356
 
357 357
 /**
@@ -366,20 +366,20 @@  discard block
 block discarded – undo
366 366
  *
367 367
  * @return void
368 368
  */
369
-function give_undo_donation( $payment_id ) {
369
+function give_undo_donation($payment_id) {
370 370
 
371
-	$payment = new Give_Payment( $payment_id );
371
+	$payment = new Give_Payment($payment_id);
372 372
 
373
-	$maybe_decrease_earnings = apply_filters( 'give_decrease_earnings_on_undo', true, $payment, $payment->form_id );
374
-	if ( true === $maybe_decrease_earnings ) {
373
+	$maybe_decrease_earnings = apply_filters('give_decrease_earnings_on_undo', true, $payment, $payment->form_id);
374
+	if (true === $maybe_decrease_earnings) {
375 375
 		// Decrease earnings.
376
-		give_decrease_earnings( $payment->form_id, $payment->total );
376
+		give_decrease_earnings($payment->form_id, $payment->total);
377 377
 	}
378 378
 
379
-	$maybe_decrease_donations = apply_filters( 'give_decrease_donations_on_undo', true, $payment, $payment->form_id );
380
-	if ( true === $maybe_decrease_donations ) {
379
+	$maybe_decrease_donations = apply_filters('give_decrease_donations_on_undo', true, $payment, $payment->form_id);
380
+	if (true === $maybe_decrease_donations) {
381 381
 		// Decrease donation count.
382
-		give_decrease_donation_count( $payment->form_id );
382
+		give_decrease_donation_count($payment->form_id);
383 383
 	}
384 384
 
385 385
 }
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
  *
397 397
  * @return object $stats Contains the number of payments per payment status.
398 398
  */
399
-function give_count_payments( $args = array() ) {
399
+function give_count_payments($args = array()) {
400 400
 
401 401
 	global $wpdb;
402 402
 
@@ -408,18 +408,18 @@  discard block
 block discarded – undo
408 408
 		'form_id'    => null,
409 409
 	);
410 410
 
411
-	$args = wp_parse_args( $args, $defaults );
411
+	$args = wp_parse_args($args, $defaults);
412 412
 
413 413
 	$select = 'SELECT p.post_status,count( * ) AS num_posts';
414 414
 	$join   = '';
415 415
 	$where  = "WHERE p.post_type = 'give_payment'";
416 416
 
417 417
 	// Count payments for a specific user.
418
-	if ( ! empty( $args['user'] ) ) {
418
+	if ( ! empty($args['user'])) {
419 419
 
420
-		if ( is_email( $args['user'] ) ) {
420
+		if (is_email($args['user'])) {
421 421
 			$field = 'email';
422
-		} elseif ( is_numeric( $args['user'] ) ) {
422
+		} elseif (is_numeric($args['user'])) {
423 423
 			$field = 'id';
424 424
 		} else {
425 425
 			$field = '';
@@ -427,107 +427,107 @@  discard block
 block discarded – undo
427 427
 
428 428
 		$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
429 429
 
430
-		if ( ! empty( $field ) ) {
430
+		if ( ! empty($field)) {
431 431
 			$where .= "
432 432
 				AND m.meta_key = '_give_payment_user_{$field}'
433 433
 				AND m.meta_value = '{$args['user']}'";
434 434
 		}
435
-	} elseif ( ! empty( $args['donor'] ) ) {
435
+	} elseif ( ! empty($args['donor'])) {
436 436
 
437
-		$join  = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
437
+		$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
438 438
 		$where .= "
439 439
 			AND m.meta_key = '_give_payment_customer_id'
440 440
 			AND m.meta_value = '{$args['donor']}'";
441 441
 
442 442
 		// Count payments for a search.
443
-	} elseif ( ! empty( $args['s'] ) ) {
443
+	} elseif ( ! empty($args['s'])) {
444 444
 
445
-		if ( is_email( $args['s'] ) || strlen( $args['s'] ) == 32 ) {
445
+		if (is_email($args['s']) || strlen($args['s']) == 32) {
446 446
 
447
-			if ( is_email( $args['s'] ) ) {
447
+			if (is_email($args['s'])) {
448 448
 				$field = '_give_payment_user_email';
449 449
 			} else {
450 450
 				$field = '_give_payment_purchase_key';
451 451
 			}
452 452
 
453
-			$join  = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
454
-			$where .= $wpdb->prepare( '
453
+			$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
454
+			$where .= $wpdb->prepare('
455 455
                 AND m.meta_key = %s
456
-                AND m.meta_value = %s', $field, $args['s'] );
456
+                AND m.meta_value = %s', $field, $args['s']);
457 457
 
458
-		} elseif ( '#' == substr( $args['s'], 0, 1 ) ) {
458
+		} elseif ('#' == substr($args['s'], 0, 1)) {
459 459
 
460
-			$search = str_replace( '#:', '', $args['s'] );
461
-			$search = str_replace( '#', '', $search );
460
+			$search = str_replace('#:', '', $args['s']);
461
+			$search = str_replace('#', '', $search);
462 462
 
463 463
 			$select = 'SELECT p.post_status,count( * ) AS num_posts ';
464 464
 			$join   = '';
465
-			$where  = $wpdb->prepare( 'WHERE p.post_type=%s  AND p.ID = %d ', 'give_payment', $search );
465
+			$where  = $wpdb->prepare('WHERE p.post_type=%s  AND p.ID = %d ', 'give_payment', $search);
466 466
 
467
-		} elseif ( is_numeric( $args['s'] ) ) {
467
+		} elseif (is_numeric($args['s'])) {
468 468
 
469
-			$join  = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
470
-			$where .= $wpdb->prepare( "
469
+			$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
470
+			$where .= $wpdb->prepare("
471 471
 				AND m.meta_key = '_give_payment_user_id'
472
-				AND m.meta_value = %d", $args['s'] );
472
+				AND m.meta_value = %d", $args['s']);
473 473
 
474 474
 		} else {
475
-			$search = $wpdb->esc_like( $args['s'] );
476
-			$search = '%' . $search . '%';
475
+			$search = $wpdb->esc_like($args['s']);
476
+			$search = '%'.$search.'%';
477 477
 
478
-			$where .= $wpdb->prepare( 'AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search );
478
+			$where .= $wpdb->prepare('AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search);
479 479
 		}// End if().
480 480
 	}// End if().
481 481
 
482
-	if ( ! empty( $args['form_id'] ) && is_numeric( $args['form_id'] ) ) {
482
+	if ( ! empty($args['form_id']) && is_numeric($args['form_id'])) {
483 483
 
484
-		$join  = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
485
-		$where .= $wpdb->prepare( '
484
+		$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
485
+		$where .= $wpdb->prepare('
486 486
                 AND m.meta_key = %s
487
-                AND m.meta_value = %s', '_give_payment_form_id', $args['form_id'] );
487
+                AND m.meta_value = %s', '_give_payment_form_id', $args['form_id']);
488 488
 	}
489 489
 
490 490
 	// Limit payments count by date.
491
-	if ( ! empty( $args['start-date'] ) && false !== strpos( $args['start-date'], '/' ) ) {
491
+	if ( ! empty($args['start-date']) && false !== strpos($args['start-date'], '/')) {
492 492
 
493
-		$date_parts = explode( '/', $args['start-date'] );
494
-		$month      = ! empty( $date_parts[0] ) && is_numeric( $date_parts[0] ) ? $date_parts[0] : 0;
495
-		$day        = ! empty( $date_parts[1] ) && is_numeric( $date_parts[1] ) ? $date_parts[1] : 0;
496
-		$year       = ! empty( $date_parts[2] ) && is_numeric( $date_parts[2] ) ? $date_parts[2] : 0;
493
+		$date_parts = explode('/', $args['start-date']);
494
+		$month      = ! empty($date_parts[0]) && is_numeric($date_parts[0]) ? $date_parts[0] : 0;
495
+		$day        = ! empty($date_parts[1]) && is_numeric($date_parts[1]) ? $date_parts[1] : 0;
496
+		$year       = ! empty($date_parts[2]) && is_numeric($date_parts[2]) ? $date_parts[2] : 0;
497 497
 
498
-		$is_date = checkdate( $month, $day, $year );
499
-		if ( false !== $is_date ) {
498
+		$is_date = checkdate($month, $day, $year);
499
+		if (false !== $is_date) {
500 500
 
501
-			$date  = new DateTime( $args['start-date'] );
502
-			$where .= $wpdb->prepare( " AND p.post_date >= '%s'", $date->format( 'Y-m-d' ) );
501
+			$date = new DateTime($args['start-date']);
502
+			$where .= $wpdb->prepare(" AND p.post_date >= '%s'", $date->format('Y-m-d'));
503 503
 
504 504
 		}
505 505
 
506 506
 		// Fixes an issue with the payments list table counts when no end date is specified (with stats class).
507
-		if ( empty( $args['end-date'] ) ) {
507
+		if (empty($args['end-date'])) {
508 508
 			$args['end-date'] = $args['start-date'];
509 509
 		}
510 510
 	}
511 511
 
512
-	if ( ! empty( $args['end-date'] ) && false !== strpos( $args['end-date'], '/' ) ) {
512
+	if ( ! empty($args['end-date']) && false !== strpos($args['end-date'], '/')) {
513 513
 
514
-		$date_parts = explode( '/', $args['end-date'] );
514
+		$date_parts = explode('/', $args['end-date']);
515 515
 
516
-		$month = ! empty( $date_parts[0] ) ? $date_parts[0] : 0;
517
-		$day   = ! empty( $date_parts[1] ) ? $date_parts[1] : 0;
518
-		$year  = ! empty( $date_parts[2] ) ? $date_parts[2] : 0;
516
+		$month = ! empty($date_parts[0]) ? $date_parts[0] : 0;
517
+		$day   = ! empty($date_parts[1]) ? $date_parts[1] : 0;
518
+		$year  = ! empty($date_parts[2]) ? $date_parts[2] : 0;
519 519
 
520
-		$is_date = checkdate( $month, $day, $year );
521
-		if ( false !== $is_date ) {
520
+		$is_date = checkdate($month, $day, $year);
521
+		if (false !== $is_date) {
522 522
 
523
-			$date  = new DateTime( $args['end-date'] );
524
-			$where .= $wpdb->prepare( " AND p.post_date <= '%s'", $date->format( 'Y-m-d' ) );
523
+			$date = new DateTime($args['end-date']);
524
+			$where .= $wpdb->prepare(" AND p.post_date <= '%s'", $date->format('Y-m-d'));
525 525
 
526 526
 		}
527 527
 	}
528 528
 
529
-	$where = apply_filters( 'give_count_payments_where', $where );
530
-	$join  = apply_filters( 'give_count_payments_join', $join );
529
+	$where = apply_filters('give_count_payments_where', $where);
530
+	$join  = apply_filters('give_count_payments_join', $join);
531 531
 
532 532
 	$query = "$select
533 533
 		FROM $wpdb->posts p
@@ -536,36 +536,36 @@  discard block
 block discarded – undo
536 536
 		GROUP BY p.post_status
537 537
 	";
538 538
 
539
-	$cache_key = md5( $query );
539
+	$cache_key = md5($query);
540 540
 
541
-	$count = wp_cache_get( $cache_key, 'counts' );
542
-	if ( false !== $count ) {
541
+	$count = wp_cache_get($cache_key, 'counts');
542
+	if (false !== $count) {
543 543
 		return $count;
544 544
 	}
545 545
 
546
-	$count = $wpdb->get_results( $query, ARRAY_A );
546
+	$count = $wpdb->get_results($query, ARRAY_A);
547 547
 
548 548
 	$stats    = array();
549 549
 	$statuses = get_post_stati();
550
-	if ( isset( $statuses['private'] ) && empty( $args['s'] ) ) {
551
-		unset( $statuses['private'] );
550
+	if (isset($statuses['private']) && empty($args['s'])) {
551
+		unset($statuses['private']);
552 552
 	}
553 553
 
554
-	foreach ( $statuses as $state ) {
555
-		$stats[ $state ] = 0;
554
+	foreach ($statuses as $state) {
555
+		$stats[$state] = 0;
556 556
 	}
557 557
 
558
-	foreach ( (array) $count as $row ) {
558
+	foreach ((array) $count as $row) {
559 559
 
560
-		if ( 'private' == $row['post_status'] && empty( $args['s'] ) ) {
560
+		if ('private' == $row['post_status'] && empty($args['s'])) {
561 561
 			continue;
562 562
 		}
563 563
 
564
-		$stats[ $row['post_status'] ] = $row['num_posts'];
564
+		$stats[$row['post_status']] = $row['num_posts'];
565 565
 	}
566 566
 
567 567
 	$stats = (object) $stats;
568
-	wp_cache_set( $cache_key, $stats, 'counts' );
568
+	wp_cache_set($cache_key, $stats, 'counts');
569 569
 
570 570
 	return $stats;
571 571
 }
@@ -580,11 +580,11 @@  discard block
 block discarded – undo
580 580
  *
581 581
  * @return bool $exists True if payment exists, false otherwise.
582 582
  */
583
-function give_check_for_existing_payment( $payment_id ) {
583
+function give_check_for_existing_payment($payment_id) {
584 584
 	$exists  = false;
585
-	$payment = new Give_Payment( $payment_id );
585
+	$payment = new Give_Payment($payment_id);
586 586
 
587
-	if ( $payment_id === $payment->ID && 'publish' === $payment->status ) {
587
+	if ($payment_id === $payment->ID && 'publish' === $payment->status) {
588 588
 		$exists = true;
589 589
 	}
590 590
 
@@ -602,31 +602,31 @@  discard block
 block discarded – undo
602 602
  *
603 603
  * @return bool|mixed True if payment status exists, false otherwise.
604 604
  */
605
-function give_get_payment_status( $payment, $return_label = false ) {
605
+function give_get_payment_status($payment, $return_label = false) {
606 606
 
607
-	if ( ! is_object( $payment ) || ! isset( $payment->post_status ) ) {
607
+	if ( ! is_object($payment) || ! isset($payment->post_status)) {
608 608
 		return false;
609 609
 	}
610 610
 
611 611
 	$statuses = give_get_payment_statuses();
612 612
 
613
-	if ( ! is_array( $statuses ) || empty( $statuses ) ) {
613
+	if ( ! is_array($statuses) || empty($statuses)) {
614 614
 		return false;
615 615
 	}
616 616
 
617 617
 	// Get payment object if no already given.
618
-	$payment = $payment instanceof Give_Payment ? $payment : new Give_Payment( $payment->ID );
618
+	$payment = $payment instanceof Give_Payment ? $payment : new Give_Payment($payment->ID);
619 619
 
620
-	if ( array_key_exists( $payment->status, $statuses ) ) {
621
-		if ( true === $return_label ) {
620
+	if (array_key_exists($payment->status, $statuses)) {
621
+		if (true === $return_label) {
622 622
 			// Return translated status label.
623
-			return $statuses[ $payment->status ];
623
+			return $statuses[$payment->status];
624 624
 		} else {
625 625
 			// Account that our 'publish' status is labeled 'Complete'
626 626
 			$post_status = 'publish' == $payment->status ? 'Complete' : $payment->post_status;
627 627
 
628 628
 			// Make sure we're matching cases, since they matter
629
-			return array_search( strtolower( $post_status ), array_map( 'strtolower', $statuses ) );
629
+			return array_search(strtolower($post_status), array_map('strtolower', $statuses));
630 630
 		}
631 631
 	}
632 632
 
@@ -642,18 +642,18 @@  discard block
 block discarded – undo
642 642
  */
643 643
 function give_get_payment_statuses() {
644 644
 	$payment_statuses = array(
645
-		'pending'     => __( 'Pending', 'give' ),
646
-		'publish'     => __( 'Complete', 'give' ),
647
-		'refunded'    => __( 'Refunded', 'give' ),
648
-		'failed'      => __( 'Failed', 'give' ),
649
-		'cancelled'   => __( 'Cancelled', 'give' ),
650
-		'abandoned'   => __( 'Abandoned', 'give' ),
651
-		'preapproval' => __( 'Pre-Approved', 'give' ),
652
-		'processing'  => __( 'Processing', 'give' ),
653
-		'revoked'     => __( 'Revoked', 'give' ),
645
+		'pending'     => __('Pending', 'give'),
646
+		'publish'     => __('Complete', 'give'),
647
+		'refunded'    => __('Refunded', 'give'),
648
+		'failed'      => __('Failed', 'give'),
649
+		'cancelled'   => __('Cancelled', 'give'),
650
+		'abandoned'   => __('Abandoned', 'give'),
651
+		'preapproval' => __('Pre-Approved', 'give'),
652
+		'processing'  => __('Processing', 'give'),
653
+		'revoked'     => __('Revoked', 'give'),
654 654
 	);
655 655
 
656
-	return apply_filters( 'give_payment_statuses', $payment_statuses );
656
+	return apply_filters('give_payment_statuses', $payment_statuses);
657 657
 }
658 658
 
659 659
 /**
@@ -666,10 +666,10 @@  discard block
 block discarded – undo
666 666
  * @return array $payment_status All the available payment statuses.
667 667
  */
668 668
 function give_get_payment_status_keys() {
669
-	$statuses = array_keys( give_get_payment_statuses() );
670
-	asort( $statuses );
669
+	$statuses = array_keys(give_get_payment_statuses());
670
+	asort($statuses);
671 671
 
672
-	return array_values( $statuses );
672
+	return array_values($statuses);
673 673
 }
674 674
 
675 675
 /**
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
  *
685 685
  * @return int $earnings  Earnings
686 686
  */
687
-function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) {
687
+function give_get_earnings_by_date($day = null, $month_num, $year = null, $hour = null) {
688 688
 
689 689
 	// This is getting deprecated soon. Use Give_Payment_Stats with the get_earnings() method instead.
690 690
 	global $wpdb;
@@ -694,41 +694,41 @@  discard block
 block discarded – undo
694 694
 		'nopaging'               => true,
695 695
 		'year'                   => $year,
696 696
 		'monthnum'               => $month_num,
697
-		'post_status'            => array( 'publish' ),
697
+		'post_status'            => array('publish'),
698 698
 		'fields'                 => 'ids',
699 699
 		'update_post_term_cache' => false,
700 700
 	);
701
-	if ( ! empty( $day ) ) {
701
+	if ( ! empty($day)) {
702 702
 		$args['day'] = $day;
703 703
 	}
704 704
 
705
-	if ( ! empty( $hour ) ) {
705
+	if ( ! empty($hour)) {
706 706
 		$args['hour'] = $hour;
707 707
 	}
708 708
 
709
-	$args = apply_filters( 'give_get_earnings_by_date_args', $args );
710
-	$key  = Give_Cache::get_key( 'give_stats', $args );
709
+	$args = apply_filters('give_get_earnings_by_date_args', $args);
710
+	$key  = Give_Cache::get_key('give_stats', $args);
711 711
 
712
-	if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) {
712
+	if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) {
713 713
 		$earnings = false;
714 714
 	} else {
715
-		$earnings = Give_Cache::get( $key );
715
+		$earnings = Give_Cache::get($key);
716 716
 	}
717 717
 
718
-	if ( false === $earnings ) {
719
-		$donations = get_posts( $args );
718
+	if (false === $earnings) {
719
+		$donations = get_posts($args);
720 720
 		$earnings  = 0;
721
-		if ( $donations ) {
722
-			$donations = implode( ',', $donations );
721
+		if ($donations) {
722
+			$donations = implode(',', $donations);
723 723
 
724
-			$earnings = $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$donations})" );
724
+			$earnings = $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$donations})");
725 725
 
726 726
 		}
727 727
 		// Cache the results for one hour.
728
-		Give_Cache::set( $key, $earnings, HOUR_IN_SECONDS );
728
+		Give_Cache::set($key, $earnings, HOUR_IN_SECONDS);
729 729
 	}
730 730
 
731
-	return round( $earnings, 2 );
731
+	return round($earnings, 2);
732 732
 }
733 733
 
734 734
 /**
@@ -743,7 +743,7 @@  discard block
 block discarded – undo
743 743
  *
744 744
  * @return int $count     Sales
745 745
  */
746
-function give_get_sales_by_date( $day = null, $month_num = null, $year = null, $hour = null ) {
746
+function give_get_sales_by_date($day = null, $month_num = null, $year = null, $hour = null) {
747 747
 
748 748
 	// This is getting deprecated soon. Use Give_Payment_Stats with the get_sales() method instead.
749 749
 	$args = array(
@@ -751,14 +751,14 @@  discard block
 block discarded – undo
751 751
 		'nopaging'               => true,
752 752
 		'year'                   => $year,
753 753
 		'fields'                 => 'ids',
754
-		'post_status'            => array( 'publish' ),
754
+		'post_status'            => array('publish'),
755 755
 		'update_post_meta_cache' => false,
756 756
 		'update_post_term_cache' => false,
757 757
 	);
758 758
 
759
-	$show_free = apply_filters( 'give_sales_by_date_show_free', true, $args );
759
+	$show_free = apply_filters('give_sales_by_date_show_free', true, $args);
760 760
 
761
-	if ( false === $show_free ) {
761
+	if (false === $show_free) {
762 762
 		$args['meta_query'] = array(
763 763
 			array(
764 764
 				'key'     => '_give_payment_total',
@@ -769,33 +769,33 @@  discard block
 block discarded – undo
769 769
 		);
770 770
 	}
771 771
 
772
-	if ( ! empty( $month_num ) ) {
772
+	if ( ! empty($month_num)) {
773 773
 		$args['monthnum'] = $month_num;
774 774
 	}
775 775
 
776
-	if ( ! empty( $day ) ) {
776
+	if ( ! empty($day)) {
777 777
 		$args['day'] = $day;
778 778
 	}
779 779
 
780
-	if ( ! empty( $hour ) ) {
780
+	if ( ! empty($hour)) {
781 781
 		$args['hour'] = $hour;
782 782
 	}
783 783
 
784
-	$args = apply_filters( 'give_get_sales_by_date_args', $args );
784
+	$args = apply_filters('give_get_sales_by_date_args', $args);
785 785
 
786
-	$key = Give_Cache::get_key( 'give_stats', $args );
786
+	$key = Give_Cache::get_key('give_stats', $args);
787 787
 
788
-	if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) {
788
+	if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) {
789 789
 		$count = false;
790 790
 	} else {
791
-		$count = Give_Cache::get( $key );
791
+		$count = Give_Cache::get($key);
792 792
 	}
793 793
 
794
-	if ( false === $count ) {
795
-		$donations = new WP_Query( $args );
794
+	if (false === $count) {
795
+		$donations = new WP_Query($args);
796 796
 		$count     = (int) $donations->post_count;
797 797
 		// Cache the results for one hour.
798
-		Give_Cache::set( $key, $count, HOUR_IN_SECONDS );
798
+		Give_Cache::set($key, $count, HOUR_IN_SECONDS);
799 799
 	}
800 800
 
801 801
 	return $count;
@@ -810,19 +810,19 @@  discard block
 block discarded – undo
810 810
  *
811 811
  * @return bool $ret True if complete, false otherwise.
812 812
  */
813
-function give_is_payment_complete( $payment_id ) {
814
-	$payment = new Give_Payment( $payment_id );
813
+function give_is_payment_complete($payment_id) {
814
+	$payment = new Give_Payment($payment_id);
815 815
 
816 816
 	$ret = false;
817 817
 
818
-	if ( $payment->ID > 0 ) {
818
+	if ($payment->ID > 0) {
819 819
 
820
-		if ( (int) $payment_id === (int) $payment->ID && 'publish' == $payment->status ) {
820
+		if ((int) $payment_id === (int) $payment->ID && 'publish' == $payment->status) {
821 821
 			$ret = true;
822 822
 		}
823 823
 	}
824 824
 
825
-	return apply_filters( 'give_is_payment_complete', $ret, $payment_id, $payment->post_status );
825
+	return apply_filters('give_is_payment_complete', $ret, $payment_id, $payment->post_status);
826 826
 }
827 827
 
828 828
 /**
@@ -848,49 +848,49 @@  discard block
 block discarded – undo
848 848
  *
849 849
  * @return float $total Total earnings.
850 850
  */
851
-function give_get_total_earnings( $recalculate = false ) {
851
+function give_get_total_earnings($recalculate = false) {
852 852
 
853
-	$total = get_option( 'give_earnings_total', 0 );
853
+	$total = get_option('give_earnings_total', 0);
854 854
 
855 855
 	// Calculate total earnings.
856
-	if ( ! $total || $recalculate ) {
856
+	if ( ! $total || $recalculate) {
857 857
 		global $wpdb;
858 858
 
859 859
 		$total = (float) 0;
860 860
 
861
-		$args = apply_filters( 'give_get_total_earnings_args', array(
861
+		$args = apply_filters('give_get_total_earnings_args', array(
862 862
 			'offset' => 0,
863
-			'number' => - 1,
864
-			'status' => array( 'publish' ),
863
+			'number' => -1,
864
+			'status' => array('publish'),
865 865
 			'fields' => 'ids',
866
-		) );
866
+		));
867 867
 
868
-		$payments = give_get_payments( $args );
869
-		if ( $payments ) {
868
+		$payments = give_get_payments($args);
869
+		if ($payments) {
870 870
 
871 871
 			/**
872 872
 			 * If performing a donation, we need to skip the very last payment in the database,
873 873
 			 * since it calls give_increase_total_earnings() on completion,
874 874
 			 * which results in duplicated earnings for the very first donation.
875 875
 			 */
876
-			if ( did_action( 'give_update_payment_status' ) ) {
877
-				array_pop( $payments );
876
+			if (did_action('give_update_payment_status')) {
877
+				array_pop($payments);
878 878
 			}
879 879
 
880
-			if ( ! empty( $payments ) ) {
881
-				$payments = implode( ',', $payments );
882
-				$total    += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})" );
880
+			if ( ! empty($payments)) {
881
+				$payments = implode(',', $payments);
882
+				$total += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})");
883 883
 			}
884 884
 		}
885 885
 
886
-		update_option( 'give_earnings_total', $total, 'no' );
886
+		update_option('give_earnings_total', $total, 'no');
887 887
 	}
888 888
 
889
-	if ( $total < 0 ) {
889
+	if ($total < 0) {
890 890
 		$total = 0; // Don't ever show negative earnings.
891 891
 	}
892 892
 
893
-	return apply_filters( 'give_total_earnings', round( $total, give_currency_decimal_filter() ) );
893
+	return apply_filters('give_total_earnings', round($total, give_currency_decimal_filter()));
894 894
 }
895 895
 
896 896
 /**
@@ -903,10 +903,10 @@  discard block
 block discarded – undo
903 903
  *
904 904
  * @return float $total  Total earnings.
905 905
  */
906
-function give_increase_total_earnings( $amount = 0 ) {
906
+function give_increase_total_earnings($amount = 0) {
907 907
 	$total = give_get_total_earnings();
908 908
 	$total += $amount;
909
-	update_option( 'give_earnings_total', $total );
909
+	update_option('give_earnings_total', $total);
910 910
 
911 911
 	return $total;
912 912
 }
@@ -920,13 +920,13 @@  discard block
 block discarded – undo
920 920
  *
921 921
  * @return float $total Total earnings.
922 922
  */
923
-function give_decrease_total_earnings( $amount = 0 ) {
923
+function give_decrease_total_earnings($amount = 0) {
924 924
 	$total = give_get_total_earnings();
925 925
 	$total -= $amount;
926
-	if ( $total < 0 ) {
926
+	if ($total < 0) {
927 927
 		$total = 0;
928 928
 	}
929
-	update_option( 'give_earnings_total', $total );
929
+	update_option('give_earnings_total', $total);
930 930
 
931 931
 	return $total;
932 932
 }
@@ -942,10 +942,10 @@  discard block
 block discarded – undo
942 942
  *
943 943
  * @return mixed $meta Payment Meta.
944 944
  */
945
-function give_get_payment_meta( $payment_id = 0, $meta_key = '_give_payment_meta', $single = true ) {
946
-	$payment = new Give_Payment( $payment_id );
945
+function give_get_payment_meta($payment_id = 0, $meta_key = '_give_payment_meta', $single = true) {
946
+	$payment = new Give_Payment($payment_id);
947 947
 
948
-	return $payment->get_meta( $meta_key, $single );
948
+	return $payment->get_meta($meta_key, $single);
949 949
 }
950 950
 
951 951
 /**
@@ -958,10 +958,10 @@  discard block
 block discarded – undo
958 958
  *
959 959
  * @return mixed Meta ID if successful, false if unsuccessful.
960 960
  */
961
-function give_update_payment_meta( $payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '' ) {
962
-	$payment = new Give_Payment( $payment_id );
961
+function give_update_payment_meta($payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '') {
962
+	$payment = new Give_Payment($payment_id);
963 963
 
964
-	return $payment->update_meta( $meta_key, $meta_value, $prev_value );
964
+	return $payment->update_meta($meta_key, $meta_value, $prev_value);
965 965
 }
966 966
 
967 967
 /**
@@ -973,8 +973,8 @@  discard block
 block discarded – undo
973 973
  *
974 974
  * @return array $user_info User Info Meta Values.
975 975
  */
976
-function give_get_payment_meta_user_info( $payment_id ) {
977
-	$payment = new Give_Payment( $payment_id );
976
+function give_get_payment_meta_user_info($payment_id) {
977
+	$payment = new Give_Payment($payment_id);
978 978
 
979 979
 	return $payment->user_info;
980 980
 }
@@ -990,8 +990,8 @@  discard block
 block discarded – undo
990 990
  *
991 991
  * @return int $form_id Form ID.
992 992
  */
993
-function give_get_payment_form_id( $payment_id ) {
994
-	$payment = new Give_Payment( $payment_id );
993
+function give_get_payment_form_id($payment_id) {
994
+	$payment = new Give_Payment($payment_id);
995 995
 
996 996
 	return $payment->form_id;
997 997
 }
@@ -1005,8 +1005,8 @@  discard block
 block discarded – undo
1005 1005
  *
1006 1006
  * @return string $email User email.
1007 1007
  */
1008
-function give_get_payment_user_email( $payment_id ) {
1009
-	$payment = new Give_Payment( $payment_id );
1008
+function give_get_payment_user_email($payment_id) {
1009
+	$payment = new Give_Payment($payment_id);
1010 1010
 
1011 1011
 	return $payment->email;
1012 1012
 }
@@ -1020,11 +1020,11 @@  discard block
 block discarded – undo
1020 1020
  *
1021 1021
  * @return bool $is_guest_payment If the payment is associated with a user (false) or not (true)
1022 1022
  */
1023
-function give_is_guest_payment( $payment_id ) {
1024
-	$payment_user_id  = give_get_payment_user_id( $payment_id );
1025
-	$is_guest_payment = ! empty( $payment_user_id ) && $payment_user_id > 0 ? false : true;
1023
+function give_is_guest_payment($payment_id) {
1024
+	$payment_user_id  = give_get_payment_user_id($payment_id);
1025
+	$is_guest_payment = ! empty($payment_user_id) && $payment_user_id > 0 ? false : true;
1026 1026
 
1027
-	return (bool) apply_filters( 'give_is_guest_payment', $is_guest_payment, $payment_id );
1027
+	return (bool) apply_filters('give_is_guest_payment', $is_guest_payment, $payment_id);
1028 1028
 }
1029 1029
 
1030 1030
 /**
@@ -1036,8 +1036,8 @@  discard block
 block discarded – undo
1036 1036
  *
1037 1037
  * @return int $user_id User ID.
1038 1038
  */
1039
-function give_get_payment_user_id( $payment_id ) {
1040
-	$payment = new Give_Payment( $payment_id );
1039
+function give_get_payment_user_id($payment_id) {
1040
+	$payment = new Give_Payment($payment_id);
1041 1041
 
1042 1042
 	return $payment->user_id;
1043 1043
 }
@@ -1051,8 +1051,8 @@  discard block
 block discarded – undo
1051 1051
  *
1052 1052
  * @return int $payment->customer_id Donor ID.
1053 1053
  */
1054
-function give_get_payment_donor_id( $payment_id ) {
1055
-	$payment = new Give_Payment( $payment_id );
1054
+function give_get_payment_donor_id($payment_id) {
1055
+	$payment = new Give_Payment($payment_id);
1056 1056
 
1057 1057
 	return $payment->customer_id;
1058 1058
 }
@@ -1066,8 +1066,8 @@  discard block
 block discarded – undo
1066 1066
  *
1067 1067
  * @return string $ip User IP.
1068 1068
  */
1069
-function give_get_payment_user_ip( $payment_id ) {
1070
-	$payment = new Give_Payment( $payment_id );
1069
+function give_get_payment_user_ip($payment_id) {
1070
+	$payment = new Give_Payment($payment_id);
1071 1071
 
1072 1072
 	return $payment->ip;
1073 1073
 }
@@ -1081,8 +1081,8 @@  discard block
 block discarded – undo
1081 1081
  *
1082 1082
  * @return string $date The date the payment was completed.
1083 1083
  */
1084
-function give_get_payment_completed_date( $payment_id = 0 ) {
1085
-	$payment = new Give_Payment( $payment_id );
1084
+function give_get_payment_completed_date($payment_id = 0) {
1085
+	$payment = new Give_Payment($payment_id);
1086 1086
 
1087 1087
 	return $payment->completed_date;
1088 1088
 }
@@ -1096,8 +1096,8 @@  discard block
 block discarded – undo
1096 1096
  *
1097 1097
  * @return string $gateway Gateway.
1098 1098
  */
1099
-function give_get_payment_gateway( $payment_id ) {
1100
-	$payment = new Give_Payment( $payment_id );
1099
+function give_get_payment_gateway($payment_id) {
1100
+	$payment = new Give_Payment($payment_id);
1101 1101
 
1102 1102
 	return $payment->gateway;
1103 1103
 }
@@ -1111,8 +1111,8 @@  discard block
 block discarded – undo
1111 1111
  *
1112 1112
  * @return string $currency The currency code.
1113 1113
  */
1114
-function give_get_payment_currency_code( $payment_id = 0 ) {
1115
-	$payment = new Give_Payment( $payment_id );
1114
+function give_get_payment_currency_code($payment_id = 0) {
1115
+	$payment = new Give_Payment($payment_id);
1116 1116
 
1117 1117
 	return $payment->currency;
1118 1118
 }
@@ -1126,10 +1126,10 @@  discard block
 block discarded – undo
1126 1126
  *
1127 1127
  * @return string $currency The currency name.
1128 1128
  */
1129
-function give_get_payment_currency( $payment_id = 0 ) {
1130
-	$currency = give_get_payment_currency_code( $payment_id );
1129
+function give_get_payment_currency($payment_id = 0) {
1130
+	$currency = give_get_payment_currency_code($payment_id);
1131 1131
 
1132
-	return apply_filters( 'give_payment_currency', give_get_currency_name( $currency ), $payment_id );
1132
+	return apply_filters('give_payment_currency', give_get_currency_name($currency), $payment_id);
1133 1133
 }
1134 1134
 
1135 1135
 /**
@@ -1141,8 +1141,8 @@  discard block
 block discarded – undo
1141 1141
  *
1142 1142
  * @return string $key Donation key.
1143 1143
  */
1144
-function give_get_payment_key( $payment_id = 0 ) {
1145
-	$payment = new Give_Payment( $payment_id );
1144
+function give_get_payment_key($payment_id = 0) {
1145
+	$payment = new Give_Payment($payment_id);
1146 1146
 
1147 1147
 	return $payment->key;
1148 1148
 }
@@ -1158,8 +1158,8 @@  discard block
 block discarded – undo
1158 1158
  *
1159 1159
  * @return string $number Payment order number.
1160 1160
  */
1161
-function give_get_payment_number( $payment_id = 0 ) {
1162
-	$payment = new Give_Payment( $payment_id );
1161
+function give_get_payment_number($payment_id = 0) {
1162
+	$payment = new Give_Payment($payment_id);
1163 1163
 
1164 1164
 	return $payment->number;
1165 1165
 }
@@ -1173,23 +1173,23 @@  discard block
 block discarded – undo
1173 1173
  *
1174 1174
  * @return string      The formatted payment number.
1175 1175
  */
1176
-function give_format_payment_number( $number ) {
1176
+function give_format_payment_number($number) {
1177 1177
 
1178
-	if ( ! give_get_option( 'enable_sequential' ) ) {
1178
+	if ( ! give_get_option('enable_sequential')) {
1179 1179
 		return $number;
1180 1180
 	}
1181 1181
 
1182
-	if ( ! is_numeric( $number ) ) {
1182
+	if ( ! is_numeric($number)) {
1183 1183
 		return $number;
1184 1184
 	}
1185 1185
 
1186
-	$prefix  = give_get_option( 'sequential_prefix' );
1187
-	$number  = absint( $number );
1188
-	$postfix = give_get_option( 'sequential_postfix' );
1186
+	$prefix  = give_get_option('sequential_prefix');
1187
+	$number  = absint($number);
1188
+	$postfix = give_get_option('sequential_postfix');
1189 1189
 
1190
-	$formatted_number = $prefix . $number . $postfix;
1190
+	$formatted_number = $prefix.$number.$postfix;
1191 1191
 
1192
-	return apply_filters( 'give_format_payment_number', $formatted_number, $prefix, $number, $postfix );
1192
+	return apply_filters('give_format_payment_number', $formatted_number, $prefix, $number, $postfix);
1193 1193
 }
1194 1194
 
1195 1195
 /**
@@ -1202,17 +1202,17 @@  discard block
 block discarded – undo
1202 1202
  */
1203 1203
 function give_get_next_payment_number() {
1204 1204
 
1205
-	if ( ! give_get_option( 'enable_sequential' ) ) {
1205
+	if ( ! give_get_option('enable_sequential')) {
1206 1206
 		return false;
1207 1207
 	}
1208 1208
 
1209
-	$number           = get_option( 'give_last_payment_number' );
1210
-	$start            = give_get_option( 'sequential_start', 1 );
1209
+	$number           = get_option('give_last_payment_number');
1210
+	$start            = give_get_option('sequential_start', 1);
1211 1211
 	$increment_number = true;
1212 1212
 
1213
-	if ( false !== $number ) {
1213
+	if (false !== $number) {
1214 1214
 
1215
-		if ( empty( $number ) ) {
1215
+		if (empty($number)) {
1216 1216
 
1217 1217
 			$number           = $start;
1218 1218
 			$increment_number = false;
@@ -1221,24 +1221,24 @@  discard block
 block discarded – undo
1221 1221
 	} else {
1222 1222
 
1223 1223
 		// This case handles the first addition of the new option, as well as if it get's deleted for any reason.
1224
-		$payments     = new Give_Payments_Query( array(
1224
+		$payments = new Give_Payments_Query(array(
1225 1225
 			'number'  => 1,
1226 1226
 			'order'   => 'DESC',
1227 1227
 			'orderby' => 'ID',
1228 1228
 			'output'  => 'posts',
1229 1229
 			'fields'  => 'ids',
1230
-		) );
1230
+		));
1231 1231
 		$last_payment = $payments->get_payments();
1232 1232
 
1233
-		if ( ! empty( $last_payment ) ) {
1233
+		if ( ! empty($last_payment)) {
1234 1234
 
1235
-			$number = give_get_payment_number( $last_payment[0] );
1235
+			$number = give_get_payment_number($last_payment[0]);
1236 1236
 
1237 1237
 		}
1238 1238
 
1239
-		if ( ! empty( $number ) && $number !== (int) $last_payment[0] ) {
1239
+		if ( ! empty($number) && $number !== (int) $last_payment[0]) {
1240 1240
 
1241
-			$number = give_remove_payment_prefix_postfix( $number );
1241
+			$number = give_remove_payment_prefix_postfix($number);
1242 1242
 
1243 1243
 		} else {
1244 1244
 
@@ -1247,13 +1247,13 @@  discard block
 block discarded – undo
1247 1247
 		}
1248 1248
 	}// End if().
1249 1249
 
1250
-	$increment_number = apply_filters( 'give_increment_payment_number', $increment_number, $number );
1250
+	$increment_number = apply_filters('give_increment_payment_number', $increment_number, $number);
1251 1251
 
1252
-	if ( $increment_number ) {
1253
-		$number ++;
1252
+	if ($increment_number) {
1253
+		$number++;
1254 1254
 	}
1255 1255
 
1256
-	return apply_filters( 'give_get_next_payment_number', $number );
1256
+	return apply_filters('give_get_next_payment_number', $number);
1257 1257
 }
1258 1258
 
1259 1259
 /**
@@ -1265,25 +1265,25 @@  discard block
 block discarded – undo
1265 1265
  *
1266 1266
  * @return string The new Payment number without prefix and postfix.
1267 1267
  */
1268
-function give_remove_payment_prefix_postfix( $number ) {
1268
+function give_remove_payment_prefix_postfix($number) {
1269 1269
 
1270
-	$prefix  = give_get_option( 'sequential_prefix' );
1271
-	$postfix = give_get_option( 'sequential_postfix' );
1270
+	$prefix  = give_get_option('sequential_prefix');
1271
+	$postfix = give_get_option('sequential_postfix');
1272 1272
 
1273 1273
 	// Remove prefix.
1274
-	$number = preg_replace( '/' . $prefix . '/', '', $number, 1 );
1274
+	$number = preg_replace('/'.$prefix.'/', '', $number, 1);
1275 1275
 
1276 1276
 	// Remove the postfix.
1277
-	$length      = strlen( $number );
1278
-	$postfix_pos = strrpos( $number, $postfix );
1279
-	if ( false !== $postfix_pos ) {
1280
-		$number = substr_replace( $number, '', $postfix_pos, $length );
1277
+	$length      = strlen($number);
1278
+	$postfix_pos = strrpos($number, $postfix);
1279
+	if (false !== $postfix_pos) {
1280
+		$number = substr_replace($number, '', $postfix_pos, $length);
1281 1281
 	}
1282 1282
 
1283 1283
 	// Ensure it's a whole number.
1284
-	$number = intval( $number );
1284
+	$number = intval($number);
1285 1285
 
1286
-	return apply_filters( 'give_remove_payment_prefix_postfix', $number, $prefix, $postfix );
1286
+	return apply_filters('give_remove_payment_prefix_postfix', $number, $prefix, $postfix);
1287 1287
 
1288 1288
 }
1289 1289
 
@@ -1300,10 +1300,10 @@  discard block
 block discarded – undo
1300 1300
  *
1301 1301
  * @return string $amount Fully formatted payment amount.
1302 1302
  */
1303
-function give_payment_amount( $payment_id = 0 ) {
1304
-	$amount = give_get_payment_amount( $payment_id );
1303
+function give_payment_amount($payment_id = 0) {
1304
+	$amount = give_get_payment_amount($payment_id);
1305 1305
 
1306
-	return give_currency_filter( give_format_amount( $amount, array( 'sanitize' => false ) ), give_get_payment_currency_code( $payment_id ) );
1306
+	return give_currency_filter(give_format_amount($amount, array('sanitize' => false)), give_get_payment_currency_code($payment_id));
1307 1307
 }
1308 1308
 
1309 1309
 /**
@@ -1316,11 +1316,11 @@  discard block
 block discarded – undo
1316 1316
  *
1317 1317
  * @return mixed
1318 1318
  */
1319
-function give_get_payment_amount( $payment_id ) {
1319
+function give_get_payment_amount($payment_id) {
1320 1320
 
1321
-	$payment = new Give_Payment( $payment_id );
1321
+	$payment = new Give_Payment($payment_id);
1322 1322
 
1323
-	return apply_filters( 'give_payment_amount', floatval( $payment->total ), $payment_id );
1323
+	return apply_filters('give_payment_amount', floatval($payment->total), $payment_id);
1324 1324
 }
1325 1325
 
1326 1326
 /**
@@ -1337,10 +1337,10 @@  discard block
 block discarded – undo
1337 1337
  *
1338 1338
  * @return array Fully formatted payment subtotal.
1339 1339
  */
1340
-function give_payment_subtotal( $payment_id = 0 ) {
1341
-	$subtotal = give_get_payment_subtotal( $payment_id );
1340
+function give_payment_subtotal($payment_id = 0) {
1341
+	$subtotal = give_get_payment_subtotal($payment_id);
1342 1342
 
1343
-	return give_currency_filter( give_format_amount( $subtotal , array( 'sanitize' => false ) ), give_get_payment_currency_code( $payment_id ) );
1343
+	return give_currency_filter(give_format_amount($subtotal, array('sanitize' => false)), give_get_payment_currency_code($payment_id));
1344 1344
 }
1345 1345
 
1346 1346
 /**
@@ -1354,8 +1354,8 @@  discard block
 block discarded – undo
1354 1354
  *
1355 1355
  * @return float $subtotal Subtotal for payment (non formatted).
1356 1356
  */
1357
-function give_get_payment_subtotal( $payment_id = 0 ) {
1358
-	$payment = new Give_Payment( $payment_id );
1357
+function give_get_payment_subtotal($payment_id = 0) {
1358
+	$payment = new Give_Payment($payment_id);
1359 1359
 
1360 1360
 	return $payment->subtotal;
1361 1361
 }
@@ -1369,8 +1369,8 @@  discard block
 block discarded – undo
1369 1369
  *
1370 1370
  * @return string The donation ID.
1371 1371
  */
1372
-function give_get_payment_transaction_id( $payment_id = 0 ) {
1373
-	$payment = new Give_Payment( $payment_id );
1372
+function give_get_payment_transaction_id($payment_id = 0) {
1373
+	$payment = new Give_Payment($payment_id);
1374 1374
 
1375 1375
 	return $payment->transaction_id;
1376 1376
 }
@@ -1385,15 +1385,15 @@  discard block
 block discarded – undo
1385 1385
  *
1386 1386
  * @return bool|mixed
1387 1387
  */
1388
-function give_set_payment_transaction_id( $payment_id = 0, $transaction_id = '' ) {
1388
+function give_set_payment_transaction_id($payment_id = 0, $transaction_id = '') {
1389 1389
 
1390
-	if ( empty( $payment_id ) || empty( $transaction_id ) ) {
1390
+	if (empty($payment_id) || empty($transaction_id)) {
1391 1391
 		return false;
1392 1392
 	}
1393 1393
 
1394
-	$transaction_id = apply_filters( 'give_set_payment_transaction_id', $transaction_id, $payment_id );
1394
+	$transaction_id = apply_filters('give_set_payment_transaction_id', $transaction_id, $payment_id);
1395 1395
 
1396
-	return give_update_payment_meta( $payment_id, '_give_payment_transaction_id', $transaction_id );
1396
+	return give_update_payment_meta($payment_id, '_give_payment_transaction_id', $transaction_id);
1397 1397
 }
1398 1398
 
1399 1399
 /**
@@ -1406,12 +1406,12 @@  discard block
 block discarded – undo
1406 1406
  *
1407 1407
  * @return int $purchase Donation ID.
1408 1408
  */
1409
-function give_get_purchase_id_by_key( $key ) {
1409
+function give_get_purchase_id_by_key($key) {
1410 1410
 	global $wpdb;
1411 1411
 
1412
-	$purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key ) );
1412
+	$purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key));
1413 1413
 
1414
-	if ( $purchase != null ) {
1414
+	if ($purchase != null) {
1415 1415
 		return $purchase;
1416 1416
 	}
1417 1417
 
@@ -1429,12 +1429,12 @@  discard block
 block discarded – undo
1429 1429
  *
1430 1430
  * @return int $purchase Donation ID.
1431 1431
  */
1432
-function give_get_purchase_id_by_transaction_id( $key ) {
1432
+function give_get_purchase_id_by_transaction_id($key) {
1433 1433
 	global $wpdb;
1434 1434
 
1435
-	$purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key ) );
1435
+	$purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key));
1436 1436
 
1437
-	if ( $purchase != null ) {
1437
+	if ($purchase != null) {
1438 1438
 		return $purchase;
1439 1439
 	}
1440 1440
 
@@ -1451,23 +1451,23 @@  discard block
 block discarded – undo
1451 1451
  *
1452 1452
  * @return array $notes Donation Notes
1453 1453
  */
1454
-function give_get_payment_notes( $payment_id = 0, $search = '' ) {
1454
+function give_get_payment_notes($payment_id = 0, $search = '') {
1455 1455
 
1456
-	if ( empty( $payment_id ) && empty( $search ) ) {
1456
+	if (empty($payment_id) && empty($search)) {
1457 1457
 		return false;
1458 1458
 	}
1459 1459
 
1460
-	remove_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1461
-	remove_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10 );
1460
+	remove_action('pre_get_comments', 'give_hide_payment_notes', 10);
1461
+	remove_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10);
1462 1462
 
1463
-	$notes = get_comments( array(
1463
+	$notes = get_comments(array(
1464 1464
 		'post_id' => $payment_id,
1465 1465
 		'order' => 'ASC',
1466 1466
 		'search' => $search,
1467
-	) );
1467
+	));
1468 1468
 
1469
-	add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1470
-	add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 );
1469
+	add_action('pre_get_comments', 'give_hide_payment_notes', 10);
1470
+	add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2);
1471 1471
 
1472 1472
 	return $notes;
1473 1473
 }
@@ -1483,8 +1483,8 @@  discard block
 block discarded – undo
1483 1483
  *
1484 1484
  * @return int The new note ID
1485 1485
  */
1486
-function give_insert_payment_note( $payment_id = 0, $note = '' ) {
1487
-	if ( empty( $payment_id ) ) {
1486
+function give_insert_payment_note($payment_id = 0, $note = '') {
1487
+	if (empty($payment_id)) {
1488 1488
 		return false;
1489 1489
 	}
1490 1490
 
@@ -1496,14 +1496,14 @@  discard block
 block discarded – undo
1496 1496
 	 * @param int    $payment_id Payment ID.
1497 1497
 	 * @param string $note       The note.
1498 1498
 	 */
1499
-	do_action( 'give_pre_insert_payment_note', $payment_id, $note );
1499
+	do_action('give_pre_insert_payment_note', $payment_id, $note);
1500 1500
 
1501
-	$note_id = wp_insert_comment( wp_filter_comment( array(
1501
+	$note_id = wp_insert_comment(wp_filter_comment(array(
1502 1502
 		'comment_post_ID'      => $payment_id,
1503 1503
 		'comment_content'      => $note,
1504 1504
 		'user_id'              => is_admin() ? get_current_user_id() : 0,
1505
-		'comment_date'         => current_time( 'mysql' ),
1506
-		'comment_date_gmt'     => current_time( 'mysql', 1 ),
1505
+		'comment_date'         => current_time('mysql'),
1506
+		'comment_date_gmt'     => current_time('mysql', 1),
1507 1507
 		'comment_approved'     => 1,
1508 1508
 		'comment_parent'       => 0,
1509 1509
 		'comment_author'       => '',
@@ -1512,7 +1512,7 @@  discard block
 block discarded – undo
1512 1512
 		'comment_author_email' => '',
1513 1513
 		'comment_type'         => 'give_payment_note',
1514 1514
 
1515
-	) ) );
1515
+	)));
1516 1516
 
1517 1517
 	/**
1518 1518
 	 * Fires after payment note inserted.
@@ -1523,7 +1523,7 @@  discard block
 block discarded – undo
1523 1523
 	 * @param int    $payment_id Payment ID.
1524 1524
 	 * @param string $note       The note.
1525 1525
 	 */
1526
-	do_action( 'give_insert_payment_note', $note_id, $payment_id, $note );
1526
+	do_action('give_insert_payment_note', $note_id, $payment_id, $note);
1527 1527
 
1528 1528
 	return $note_id;
1529 1529
 }
@@ -1538,8 +1538,8 @@  discard block
 block discarded – undo
1538 1538
  *
1539 1539
  * @return bool True on success, false otherwise.
1540 1540
  */
1541
-function give_delete_payment_note( $comment_id = 0, $payment_id = 0 ) {
1542
-	if ( empty( $comment_id ) ) {
1541
+function give_delete_payment_note($comment_id = 0, $payment_id = 0) {
1542
+	if (empty($comment_id)) {
1543 1543
 		return false;
1544 1544
 	}
1545 1545
 
@@ -1551,9 +1551,9 @@  discard block
 block discarded – undo
1551 1551
 	 * @param int $comment_id Note ID.
1552 1552
 	 * @param int $payment_id Payment ID.
1553 1553
 	 */
1554
-	do_action( 'give_pre_delete_payment_note', $comment_id, $payment_id );
1554
+	do_action('give_pre_delete_payment_note', $comment_id, $payment_id);
1555 1555
 
1556
-	$ret = wp_delete_comment( $comment_id, true );
1556
+	$ret = wp_delete_comment($comment_id, true);
1557 1557
 
1558 1558
 	/**
1559 1559
 	 * Fires after donation note deleted.
@@ -1563,7 +1563,7 @@  discard block
 block discarded – undo
1563 1563
 	 * @param int $comment_id Note ID.
1564 1564
 	 * @param int $payment_id Payment ID.
1565 1565
 	 */
1566
-	do_action( 'give_post_delete_payment_note', $comment_id, $payment_id );
1566
+	do_action('give_post_delete_payment_note', $comment_id, $payment_id);
1567 1567
 
1568 1568
 	return $ret;
1569 1569
 }
@@ -1578,32 +1578,32 @@  discard block
 block discarded – undo
1578 1578
  *
1579 1579
  * @return string
1580 1580
  */
1581
-function give_get_payment_note_html( $note, $payment_id = 0 ) {
1581
+function give_get_payment_note_html($note, $payment_id = 0) {
1582 1582
 
1583
-	if ( is_numeric( $note ) ) {
1584
-		$note = get_comment( $note );
1583
+	if (is_numeric($note)) {
1584
+		$note = get_comment($note);
1585 1585
 	}
1586 1586
 
1587
-	if ( ! empty( $note->user_id ) ) {
1588
-		$user = get_userdata( $note->user_id );
1587
+	if ( ! empty($note->user_id)) {
1588
+		$user = get_userdata($note->user_id);
1589 1589
 		$user = $user->display_name;
1590 1590
 	} else {
1591
-		$user = esc_html__( 'System', 'give' );
1591
+		$user = esc_html__('System', 'give');
1592 1592
 	}
1593 1593
 
1594
-	$date_format = give_date_format() . ', ' . get_option( 'time_format' );
1594
+	$date_format = give_date_format().', '.get_option('time_format');
1595 1595
 
1596
-	$delete_note_url = wp_nonce_url( add_query_arg( array(
1596
+	$delete_note_url = wp_nonce_url(add_query_arg(array(
1597 1597
 		'give-action' => 'delete_payment_note',
1598 1598
 		'note_id'     => $note->comment_ID,
1599 1599
 		'payment_id'  => $payment_id,
1600
-	) ), 'give_delete_payment_note_' . $note->comment_ID );
1600
+	)), 'give_delete_payment_note_'.$note->comment_ID);
1601 1601
 
1602
-	$note_html = '<div class="give-payment-note" id="give-payment-note-' . $note->comment_ID . '">';
1602
+	$note_html = '<div class="give-payment-note" id="give-payment-note-'.$note->comment_ID.'">';
1603 1603
 	$note_html .= '<p>';
1604
-	$note_html .= '<strong>' . $user . '</strong>&nbsp;&ndash;&nbsp;<span style="color:#aaa;font-style:italic;">' . date_i18n( $date_format, strtotime( $note->comment_date ) ) . '</span><br/>';
1604
+	$note_html .= '<strong>'.$user.'</strong>&nbsp;&ndash;&nbsp;<span style="color:#aaa;font-style:italic;">'.date_i18n($date_format, strtotime($note->comment_date)).'</span><br/>';
1605 1605
 	$note_html .= $note->comment_content;
1606
-	$note_html .= '&nbsp;&ndash;&nbsp;<a href="' . esc_url( $delete_note_url ) . '" class="give-delete-payment-note" data-note-id="' . absint( $note->comment_ID ) . '" data-payment-id="' . absint( $payment_id ) . '" aria-label="' . esc_attr__( 'Delete this donation note.', 'give' ) . '">' . esc_html__( 'Delete', 'give' ) . '</a>';
1606
+	$note_html .= '&nbsp;&ndash;&nbsp;<a href="'.esc_url($delete_note_url).'" class="give-delete-payment-note" data-note-id="'.absint($note->comment_ID).'" data-payment-id="'.absint($payment_id).'" aria-label="'.esc_attr__('Delete this donation note.', 'give').'">'.esc_html__('Delete', 'give').'</a>';
1607 1607
 	$note_html .= '</p>';
1608 1608
 	$note_html .= '</div>';
1609 1609
 
@@ -1621,18 +1621,18 @@  discard block
 block discarded – undo
1621 1621
  *
1622 1622
  * @return void
1623 1623
  */
1624
-function give_hide_payment_notes( $query ) {
1625
-	if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '>=' ) ) {
1626
-		$types = isset( $query->query_vars['type__not_in'] ) ? $query->query_vars['type__not_in'] : array();
1627
-		if ( ! is_array( $types ) ) {
1628
-			$types = array( $types );
1624
+function give_hide_payment_notes($query) {
1625
+	if (version_compare(floatval(get_bloginfo('version')), '4.1', '>=')) {
1626
+		$types = isset($query->query_vars['type__not_in']) ? $query->query_vars['type__not_in'] : array();
1627
+		if ( ! is_array($types)) {
1628
+			$types = array($types);
1629 1629
 		}
1630 1630
 		$types[]                           = 'give_payment_note';
1631 1631
 		$query->query_vars['type__not_in'] = $types;
1632 1632
 	}
1633 1633
 }
1634 1634
 
1635
-add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1635
+add_action('pre_get_comments', 'give_hide_payment_notes', 10);
1636 1636
 
1637 1637
 /**
1638 1638
  * Exclude notes (comments) on give_payment post type from showing in Recent Comments widgets
@@ -1644,15 +1644,15 @@  discard block
 block discarded – undo
1644 1644
  *
1645 1645
  * @return array $clauses Updated comment clauses.
1646 1646
  */
1647
-function give_hide_payment_notes_pre_41( $clauses, $wp_comment_query ) {
1648
-	if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '<' ) ) {
1647
+function give_hide_payment_notes_pre_41($clauses, $wp_comment_query) {
1648
+	if (version_compare(floatval(get_bloginfo('version')), '4.1', '<')) {
1649 1649
 		$clauses['where'] .= ' AND comment_type != "give_payment_note"';
1650 1650
 	}
1651 1651
 
1652 1652
 	return $clauses;
1653 1653
 }
1654 1654
 
1655
-add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 );
1655
+add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2);
1656 1656
 
1657 1657
 
1658 1658
 /**
@@ -1665,15 +1665,15 @@  discard block
 block discarded – undo
1665 1665
  *
1666 1666
  * @return string $where
1667 1667
  */
1668
-function give_hide_payment_notes_from_feeds( $where, $wp_comment_query ) {
1668
+function give_hide_payment_notes_from_feeds($where, $wp_comment_query) {
1669 1669
 	global $wpdb;
1670 1670
 
1671
-	$where .= $wpdb->prepare( ' AND comment_type != %s', 'give_payment_note' );
1671
+	$where .= $wpdb->prepare(' AND comment_type != %s', 'give_payment_note');
1672 1672
 
1673 1673
 	return $where;
1674 1674
 }
1675 1675
 
1676
-add_filter( 'comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2 );
1676
+add_filter('comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2);
1677 1677
 
1678 1678
 
1679 1679
 /**
@@ -1687,32 +1687,32 @@  discard block
 block discarded – undo
1687 1687
  *
1688 1688
  * @return array Array of comment counts.
1689 1689
  */
1690
-function give_remove_payment_notes_in_comment_counts( $stats, $post_id ) {
1690
+function give_remove_payment_notes_in_comment_counts($stats, $post_id) {
1691 1691
 	global $wpdb, $pagenow;
1692 1692
 
1693
-	if ( 'index.php' != $pagenow ) {
1693
+	if ('index.php' != $pagenow) {
1694 1694
 		return $stats;
1695 1695
 	}
1696 1696
 
1697 1697
 	$post_id = (int) $post_id;
1698 1698
 
1699
-	if ( apply_filters( 'give_count_payment_notes_in_comments', false ) ) {
1699
+	if (apply_filters('give_count_payment_notes_in_comments', false)) {
1700 1700
 		return $stats;
1701 1701
 	}
1702 1702
 
1703
-	$stats = wp_cache_get( "comments-{$post_id}", 'counts' );
1703
+	$stats = wp_cache_get("comments-{$post_id}", 'counts');
1704 1704
 
1705
-	if ( false !== $stats ) {
1705
+	if (false !== $stats) {
1706 1706
 		return $stats;
1707 1707
 	}
1708 1708
 
1709 1709
 	$where = 'WHERE comment_type != "give_payment_note"';
1710 1710
 
1711
-	if ( $post_id > 0 ) {
1712
-		$where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id );
1711
+	if ($post_id > 0) {
1712
+		$where .= $wpdb->prepare(' AND comment_post_ID = %d', $post_id);
1713 1713
 	}
1714 1714
 
1715
-	$count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A );
1715
+	$count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A);
1716 1716
 
1717 1717
 	$total    = 0;
1718 1718
 	$approved = array(
@@ -1722,30 +1722,30 @@  discard block
 block discarded – undo
1722 1722
 		'trash'        => 'trash',
1723 1723
 		'post-trashed' => 'post-trashed',
1724 1724
 	);
1725
-	foreach ( (array) $count as $row ) {
1725
+	foreach ((array) $count as $row) {
1726 1726
 		// Don't count post-trashed toward totals.
1727
-		if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) {
1727
+		if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) {
1728 1728
 			$total += $row['num_comments'];
1729 1729
 		}
1730
-		if ( isset( $approved[ $row['comment_approved'] ] ) ) {
1731
-			$stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments'];
1730
+		if (isset($approved[$row['comment_approved']])) {
1731
+			$stats[$approved[$row['comment_approved']]] = $row['num_comments'];
1732 1732
 		}
1733 1733
 	}
1734 1734
 
1735 1735
 	$stats['total_comments'] = $total;
1736
-	foreach ( $approved as $key ) {
1737
-		if ( empty( $stats[ $key ] ) ) {
1738
-			$stats[ $key ] = 0;
1736
+	foreach ($approved as $key) {
1737
+		if (empty($stats[$key])) {
1738
+			$stats[$key] = 0;
1739 1739
 		}
1740 1740
 	}
1741 1741
 
1742 1742
 	$stats = (object) $stats;
1743
-	wp_cache_set( "comments-{$post_id}", $stats, 'counts' );
1743
+	wp_cache_set("comments-{$post_id}", $stats, 'counts');
1744 1744
 
1745 1745
 	return $stats;
1746 1746
 }
1747 1747
 
1748
-add_filter( 'wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2 );
1748
+add_filter('wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2);
1749 1749
 
1750 1750
 
1751 1751
 /**
@@ -1758,9 +1758,9 @@  discard block
 block discarded – undo
1758 1758
  *
1759 1759
  * @return string $where Modified where clause.
1760 1760
  */
1761
-function give_filter_where_older_than_week( $where = '' ) {
1761
+function give_filter_where_older_than_week($where = '') {
1762 1762
 	// Payments older than one week.
1763
-	$start = date( 'Y-m-d', strtotime( '-7 days' ) );
1763
+	$start = date('Y-m-d', strtotime('-7 days'));
1764 1764
 	$where .= " AND post_date <= '{$start}'";
1765 1765
 
1766 1766
 	return $where;
@@ -1780,38 +1780,38 @@  discard block
 block discarded – undo
1780 1780
  *
1781 1781
  * @return string $form_title Returns the full title if $only_level is false, otherwise returns the levels title.
1782 1782
  */
1783
-function give_get_payment_form_title( $payment_meta, $only_level = false, $separator = '' ) {
1783
+function give_get_payment_form_title($payment_meta, $only_level = false, $separator = '') {
1784 1784
 
1785
-	$form_id    = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0;
1786
-	$price_id   = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null;
1787
-	$form_title = isset( $payment_meta['form_title'] ) ? $payment_meta['form_title'] : '';
1785
+	$form_id    = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0;
1786
+	$price_id   = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null;
1787
+	$form_title = isset($payment_meta['form_title']) ? $payment_meta['form_title'] : '';
1788 1788
 
1789
-	if ( $only_level == true ) {
1789
+	if ($only_level == true) {
1790 1790
 		$form_title = '';
1791 1791
 	}
1792 1792
 
1793 1793
 	// If multi-level, append to the form title.
1794
-	if ( give_has_variable_prices( $form_id ) ) {
1794
+	if (give_has_variable_prices($form_id)) {
1795 1795
 
1796 1796
 		// Only add separator if there is a form title.
1797
-		if ( ! empty( $form_title ) ) {
1798
-			$form_title .= ' ' . $separator . ' ';
1797
+		if ( ! empty($form_title)) {
1798
+			$form_title .= ' '.$separator.' ';
1799 1799
 		}
1800 1800
 
1801 1801
 		$form_title .= '<span class="donation-level-text-wrap">';
1802 1802
 
1803
-		if ( $price_id == 'custom' ) {
1804
-			$custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true );
1805
-			$form_title         .= ! empty( $custom_amount_text ) ? $custom_amount_text : __( 'Custom Amount', 'give' );
1803
+		if ($price_id == 'custom') {
1804
+			$custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true);
1805
+			$form_title .= ! empty($custom_amount_text) ? $custom_amount_text : __('Custom Amount', 'give');
1806 1806
 		} else {
1807
-			$form_title .= give_get_price_option_name( $form_id, $price_id );
1807
+			$form_title .= give_get_price_option_name($form_id, $price_id);
1808 1808
 		}
1809 1809
 
1810 1810
 		$form_title .= '</span>';
1811 1811
 
1812 1812
 	}
1813 1813
 
1814
-	return apply_filters( 'give_get_payment_form_title', $form_title, $payment_meta );
1814
+	return apply_filters('give_get_payment_form_title', $form_title, $payment_meta);
1815 1815
 
1816 1816
 }
1817 1817
 
@@ -1825,20 +1825,20 @@  discard block
 block discarded – undo
1825 1825
  *
1826 1826
  * @return string $price_id
1827 1827
  */
1828
-function give_get_price_id( $form_id, $price ) {
1828
+function give_get_price_id($form_id, $price) {
1829 1829
 
1830 1830
 	$price_id = 0;
1831 1831
 
1832
-	if ( give_has_variable_prices( $form_id ) ) {
1832
+	if (give_has_variable_prices($form_id)) {
1833 1833
 
1834
-		$levels = maybe_unserialize( give_get_meta( $form_id, '_give_donation_levels', true ) );
1834
+		$levels = maybe_unserialize(give_get_meta($form_id, '_give_donation_levels', true));
1835 1835
 
1836
-		foreach ( $levels as $level ) {
1836
+		foreach ($levels as $level) {
1837 1837
 
1838
-			$level_amount = (float) give_maybe_sanitize_amount( $level['_give_amount'] );
1838
+			$level_amount = (float) give_maybe_sanitize_amount($level['_give_amount']);
1839 1839
 
1840 1840
 			// Check that this indeed the recurring price.
1841
-			if ( $level_amount == $price ) {
1841
+			if ($level_amount == $price) {
1842 1842
 
1843 1843
 				$price_id = $level['_give_id']['level_id'];
1844 1844
 
@@ -1863,10 +1863,10 @@  discard block
 block discarded – undo
1863 1863
  *
1864 1864
  * @return string
1865 1865
  */
1866
-function give_get_form_dropdown( $args = array(), $echo = false ) {
1867
-	$form_dropdown_html = Give()->html->forms_dropdown( $args );
1866
+function give_get_form_dropdown($args = array(), $echo = false) {
1867
+	$form_dropdown_html = Give()->html->forms_dropdown($args);
1868 1868
 
1869
-	if ( ! $echo ) {
1869
+	if ( ! $echo) {
1870 1870
 		return $form_dropdown_html;
1871 1871
 	}
1872 1872
 
@@ -1883,17 +1883,17 @@  discard block
 block discarded – undo
1883 1883
  *
1884 1884
  * @return string|bool
1885 1885
  */
1886
-function give_get_form_variable_price_dropdown( $args = array(), $echo = false ) {
1886
+function give_get_form_variable_price_dropdown($args = array(), $echo = false) {
1887 1887
 
1888 1888
 	// Check for give form id.
1889
-	if ( empty( $args['id'] ) ) {
1889
+	if (empty($args['id'])) {
1890 1890
 		return false;
1891 1891
 	}
1892 1892
 
1893
-	$form = new Give_Donate_Form( $args['id'] );
1893
+	$form = new Give_Donate_Form($args['id']);
1894 1894
 
1895 1895
 	// Check if form has variable prices or not.
1896
-	if ( ! $form->ID || ! $form->has_variable_prices() ) {
1896
+	if ( ! $form->ID || ! $form->has_variable_prices()) {
1897 1897
 		return false;
1898 1898
 	}
1899 1899
 
@@ -1901,24 +1901,24 @@  discard block
 block discarded – undo
1901 1901
 	$variable_price_options = array();
1902 1902
 
1903 1903
 	// Check if multi donation form support custom donation or not.
1904
-	if ( $form->is_custom_price_mode() ) {
1905
-		$variable_price_options['custom'] = _x( 'Custom', 'custom donation dropdown item', 'give' );
1904
+	if ($form->is_custom_price_mode()) {
1905
+		$variable_price_options['custom'] = _x('Custom', 'custom donation dropdown item', 'give');
1906 1906
 	}
1907 1907
 
1908 1908
 	// Get variable price and ID from variable price array.
1909
-	foreach ( $variable_prices as $variable_price ) {
1910
-		$variable_price_options[ $variable_price['_give_id']['level_id'] ] = ! empty( $variable_price['_give_text'] ) ? $variable_price['_give_text'] : give_currency_filter( give_format_amount( $variable_price['_give_amount'], array( 'sanitize' => false ) ) );
1909
+	foreach ($variable_prices as $variable_price) {
1910
+		$variable_price_options[$variable_price['_give_id']['level_id']] = ! empty($variable_price['_give_text']) ? $variable_price['_give_text'] : give_currency_filter(give_format_amount($variable_price['_give_amount'], array('sanitize' => false)));
1911 1911
 	}
1912 1912
 
1913 1913
 	// Update options.
1914
-	$args = array_merge( $args, array(
1914
+	$args = array_merge($args, array(
1915 1915
 		'options' => $variable_price_options,
1916
-	) );
1916
+	));
1917 1917
 
1918 1918
 	// Generate select html.
1919
-	$form_dropdown_html = Give()->html->select( $args );
1919
+	$form_dropdown_html = Give()->html->select($args);
1920 1920
 
1921
-	if ( ! $echo ) {
1921
+	if ( ! $echo) {
1922 1922
 		return $form_dropdown_html;
1923 1923
 	}
1924 1924
 
@@ -1937,16 +1937,16 @@  discard block
 block discarded – undo
1937 1937
  *
1938 1938
  * @return string
1939 1939
  */
1940
-function give_get_payment_meta_price_id( $payment_meta ) {
1940
+function give_get_payment_meta_price_id($payment_meta) {
1941 1941
 
1942
-	if ( isset( $payment_meta['give_price_id'] ) ) {
1942
+	if (isset($payment_meta['give_price_id'])) {
1943 1943
 		$price_id = $payment_meta['give_price_id'];
1944
-	} elseif ( isset( $payment_meta['price_id'] ) ) {
1944
+	} elseif (isset($payment_meta['price_id'])) {
1945 1945
 		$price_id = $payment_meta['price_id'];
1946 1946
 	} else {
1947
-		$price_id = give_get_price_id( $payment_meta['give_form_id'], $payment_meta['price'] );
1947
+		$price_id = give_get_price_id($payment_meta['give_form_id'], $payment_meta['price']);
1948 1948
 	}
1949 1949
 
1950
-	return apply_filters( 'give_get_payment_meta_price_id', $price_id );
1950
+	return apply_filters('give_get_payment_meta_price_id', $price_id);
1951 1951
 
1952 1952
 }
Please login to merge, or discard this patch.
includes/payments/class-payment-stats.php 1 patch
Spacing   +40 added lines, -40 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
 
@@ -38,17 +38,17 @@  discard block
 block discarded – undo
38 38
 	 *
39 39
 	 * @return float|int                Total amount of donations based on the passed arguments.
40 40
 	 */
41
-	public function get_sales( $form_id = 0, $start_date = false, $end_date = false, $status = 'publish' ) {
41
+	public function get_sales($form_id = 0, $start_date = false, $end_date = false, $status = 'publish') {
42 42
 
43
-		$this->setup_dates( $start_date, $end_date );
43
+		$this->setup_dates($start_date, $end_date);
44 44
 
45 45
 		// Make sure start date is valid
46
-		if ( is_wp_error( $this->start_date ) ) {
46
+		if (is_wp_error($this->start_date)) {
47 47
 			return $this->start_date;
48 48
 		}
49 49
 
50 50
 		// Make sure end date is valid
51
-		if ( is_wp_error( $this->end_date ) ) {
51
+		if (is_wp_error($this->end_date)) {
52 52
 			return $this->end_date;
53 53
 		}
54 54
 
@@ -57,18 +57,18 @@  discard block
 block discarded – undo
57 57
 			'start_date' => $this->start_date,
58 58
 			'end_date'   => $this->end_date,
59 59
 			'fields'     => 'ids',
60
-			'number'     => - 1,
60
+			'number'     => -1,
61 61
 		);
62 62
 
63
-		if ( ! empty( $form_id ) ) {
63
+		if ( ! empty($form_id)) {
64 64
 			$args['give_forms'] = $form_id;
65 65
 		}
66 66
 
67 67
 		/* @var Give_Payments_Query $payments */
68
-		$payments = new Give_Payments_Query( $args );
68
+		$payments = new Give_Payments_Query($args);
69 69
 		$payments = $payments->get_payments();
70 70
 
71
-		return count( $payments );
71
+		return count($payments);
72 72
 	}
73 73
 
74 74
 
@@ -85,16 +85,16 @@  discard block
 block discarded – undo
85 85
 	 *
86 86
 	 * @return float|int                Total amount of donations based on the passed arguments.
87 87
 	 */
88
-	public function get_earnings( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) {
89
-		$this->setup_dates( $start_date, $end_date );
88
+	public function get_earnings($form_id = 0, $start_date = false, $end_date = false, $gateway_id = false) {
89
+		$this->setup_dates($start_date, $end_date);
90 90
 
91 91
 		// Make sure start date is valid
92
-		if ( is_wp_error( $this->start_date ) ) {
92
+		if (is_wp_error($this->start_date)) {
93 93
 			return $this->start_date;
94 94
 		}
95 95
 
96 96
 		// Make sure end date is valid
97
-		if ( is_wp_error( $this->end_date ) ) {
97
+		if (is_wp_error($this->end_date)) {
98 98
 			return $this->end_date;
99 99
 		}
100 100
 
@@ -104,12 +104,12 @@  discard block
 block discarded – undo
104 104
 			'start_date' => $this->start_date,
105 105
 			'end_date'   => $this->end_date,
106 106
 			'fields'     => 'ids',
107
-			'number'     => - 1,
107
+			'number'     => -1,
108 108
 		);
109 109
 
110 110
 
111 111
 		// Filter by Gateway ID meta_key
112
-		if ( $gateway_id ) {
112
+		if ($gateway_id) {
113 113
 			$args['meta_query'][] = array(
114 114
 				'key'   => '_give_payment_gateway',
115 115
 				'value' => $gateway_id,
@@ -117,43 +117,43 @@  discard block
 block discarded – undo
117 117
 		}
118 118
 
119 119
 		// Filter by Gateway ID meta_key
120
-		if ( $form_id ) {
120
+		if ($form_id) {
121 121
 			$args['meta_query'][] = array(
122 122
 				'key'   => '_give_payment_form_id',
123 123
 				'value' => $form_id,
124 124
 			);
125 125
 		}
126 126
 
127
-		if ( ! empty( $args['meta_query'] ) && 1 < count( $args['meta_query'] ) ) {
127
+		if ( ! empty($args['meta_query']) && 1 < count($args['meta_query'])) {
128 128
 			$args['meta_query']['relation'] = 'AND';
129 129
 		}
130 130
 
131
-		$args = apply_filters( 'give_stats_earnings_args', $args );
132
-		$key  = Give_Cache::get_key( 'give_stats', $args );
131
+		$args = apply_filters('give_stats_earnings_args', $args);
132
+		$key  = Give_Cache::get_key('give_stats', $args);
133 133
 
134 134
 		//Set transient for faster stats
135
-		$earnings = Give_Cache::get( $key );
135
+		$earnings = Give_Cache::get($key);
136 136
 
137
-		if ( false === $earnings ) {
137
+		if (false === $earnings) {
138 138
 
139 139
 			$this->timestamp = false;
140
-			$payments        = new Give_Payments_Query( $args );
140
+			$payments        = new Give_Payments_Query($args);
141 141
 			$payments        = $payments->get_payments();
142 142
 			$earnings        = 0;
143 143
 
144
-			if ( ! empty( $payments ) ) {
145
-				foreach ( $payments as $payment ) {
146
-					$earnings += give_get_payment_amount( $payment->ID );
144
+			if ( ! empty($payments)) {
145
+				foreach ($payments as $payment) {
146
+					$earnings += give_get_payment_amount($payment->ID);
147 147
 				}
148 148
 
149 149
 			}
150 150
 
151 151
 			// Cache the results for one hour
152
-			Give_Cache::set( $key, give_sanitize_amount_for_db( $earnings ), 60 * 60 );
152
+			Give_Cache::set($key, give_sanitize_amount_for_db($earnings), 60 * 60);
153 153
 		}
154 154
 
155 155
 		//return earnings
156
-		return round( $earnings, give_currency_decimal_filter() );
156
+		return round($earnings, give_currency_decimal_filter());
157 157
 
158 158
 	}
159 159
 
@@ -170,17 +170,17 @@  discard block
 block discarded – undo
170 170
 	 *
171 171
 	 * @return float|int                Total amount of donations based on the passed arguments.
172 172
 	 */
173
-	public function get_earnings_cache_key( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) {
173
+	public function get_earnings_cache_key($form_id = 0, $start_date = false, $end_date = false, $gateway_id = false) {
174 174
 
175
-		$this->setup_dates( $start_date, $end_date );
175
+		$this->setup_dates($start_date, $end_date);
176 176
 
177 177
 		// Make sure start date is valid
178
-		if ( is_wp_error( $this->start_date ) ) {
178
+		if (is_wp_error($this->start_date)) {
179 179
 			return $this->start_date;
180 180
 		}
181 181
 
182 182
 		// Make sure end date is valid
183
-		if ( is_wp_error( $this->end_date ) ) {
183
+		if (is_wp_error($this->end_date)) {
184 184
 			return $this->end_date;
185 185
 		}
186 186
 
@@ -190,12 +190,12 @@  discard block
 block discarded – undo
190 190
 			'start_date' => $this->start_date,
191 191
 			'end_date'   => $this->end_date,
192 192
 			'fields'     => 'ids',
193
-			'number'     => - 1,
193
+			'number'     => -1,
194 194
 		);
195 195
 
196 196
 
197 197
 		// Filter by Gateway ID meta_key
198
-		if ( $gateway_id ) {
198
+		if ($gateway_id) {
199 199
 			$args['meta_query'][] = array(
200 200
 				'key'   => '_give_payment_gateway',
201 201
 				'value' => $gateway_id,
@@ -203,19 +203,19 @@  discard block
 block discarded – undo
203 203
 		}
204 204
 
205 205
 		// Filter by Gateway ID meta_key
206
-		if ( $form_id ) {
206
+		if ($form_id) {
207 207
 			$args['meta_query'][] = array(
208 208
 				'key'   => '_give_payment_form_id',
209 209
 				'value' => $form_id,
210 210
 			);
211 211
 		}
212 212
 
213
-		if ( ! empty( $args['meta_query'] ) && 1 < count( $args['meta_query'] ) ) {
213
+		if ( ! empty($args['meta_query']) && 1 < count($args['meta_query'])) {
214 214
 			$args['meta_query']['relation'] = 'AND';
215 215
 		}
216 216
 
217
-		$args = apply_filters( 'give_stats_earnings_args', $args );
218
-		$key  = Give_Cache::get_key( 'give_stats', $args );
217
+		$args = apply_filters('give_stats_earnings_args', $args);
218
+		$key  = Give_Cache::get_key('give_stats', $args);
219 219
 
220 220
 		//return earnings
221 221
 		return $key;
@@ -232,16 +232,16 @@  discard block
 block discarded – undo
232 232
 	 *
233 233
 	 * @return array       Best selling forms
234 234
 	 */
235
-	public function get_best_selling( $number = 10 ) {
235
+	public function get_best_selling($number = 10) {
236 236
 
237 237
 		global $wpdb;
238 238
 
239
-		$give_forms = $wpdb->get_results( $wpdb->prepare(
239
+		$give_forms = $wpdb->get_results($wpdb->prepare(
240 240
 			"SELECT post_id as form_id, max(meta_value) as sales
241 241
 				FROM $wpdb->postmeta WHERE meta_key='_give_form_sales' AND meta_value > 0
242 242
 				GROUP BY meta_value+0
243 243
 				DESC LIMIT %d;", $number
244
-		) );
244
+		));
245 245
 
246 246
 		return $give_forms;
247 247
 	}
Please login to merge, or discard this patch.
includes/admin/give-metabox-functions.php 1 patch
Spacing   +310 added lines, -310 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
9 9
  * @since       1.8
10 10
  */
11
-if ( ! defined( 'ABSPATH' ) ) {
11
+if ( ! defined('ABSPATH')) {
12 12
 	exit; // Exit if accessed directly
13 13
 }
14 14
 
@@ -22,8 +22,8 @@  discard block
 block discarded – undo
22 22
  *
23 23
  * @return bool|string
24 24
  */
25
-function give_is_field_callback_exist( $field ) {
26
-	return ( give_get_field_callback( $field ) ? true : false );
25
+function give_is_field_callback_exist($field) {
26
+	return (give_get_field_callback($field) ? true : false);
27 27
 }
28 28
 
29 29
 /**
@@ -35,12 +35,12 @@  discard block
 block discarded – undo
35 35
  *
36 36
  * @return bool|string
37 37
  */
38
-function give_get_field_callback( $field ) {
38
+function give_get_field_callback($field) {
39 39
 	$func_name_prefix = 'give';
40 40
 	$func_name        = '';
41 41
 
42 42
 	// Set callback function on basis of cmb2 field name.
43
-	switch ( $field['type'] ) {
43
+	switch ($field['type']) {
44 44
 		case 'radio_inline':
45 45
 			$func_name = "{$func_name_prefix}_radio";
46 46
 			break;
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
 		default:
77 77
 
78 78
 			if (
79
-				array_key_exists( 'callback', $field )
80
-				&& ! empty( $field['callback'] )
79
+				array_key_exists('callback', $field)
80
+				&& ! empty($field['callback'])
81 81
 			) {
82 82
 				$func_name = $field['callback'];
83 83
 			} else {
@@ -90,15 +90,15 @@  discard block
 block discarded – undo
90 90
 	 *
91 91
 	 * @since 1.8
92 92
 	 */
93
-	$func_name = apply_filters( 'give_get_field_callback', $func_name, $field );
93
+	$func_name = apply_filters('give_get_field_callback', $func_name, $field);
94 94
 
95 95
 	// Exit if not any function exist.
96 96
 	// Check if render callback exist or not.
97
-	if ( empty( $func_name ) ) {
97
+	if (empty($func_name)) {
98 98
 		return false;
99
-	} elseif ( is_string( $func_name ) && ! function_exists( "$func_name" ) ) {
99
+	} elseif (is_string($func_name) && ! function_exists("$func_name")) {
100 100
 		return false;
101
-	} elseif ( is_array( $func_name ) && ! method_exists( $func_name[0], "$func_name[1]" ) ) {
101
+	} elseif (is_array($func_name) && ! method_exists($func_name[0], "$func_name[1]")) {
102 102
 		return false;
103 103
 	}
104 104
 
@@ -114,35 +114,35 @@  discard block
 block discarded – undo
114 114
  *
115 115
  * @return bool
116 116
  */
117
-function give_render_field( $field ) {
117
+function give_render_field($field) {
118 118
 
119 119
 	// Check if render callback exist or not.
120
-	if ( ! ( $func_name = give_get_field_callback( $field ) ) ) {
120
+	if ( ! ($func_name = give_get_field_callback($field))) {
121 121
 		return false;
122 122
 	}
123 123
 
124 124
 	// CMB2 compatibility: Push all classes to attributes's class key
125
-	if ( empty( $field['class'] ) ) {
125
+	if (empty($field['class'])) {
126 126
 		$field['class'] = '';
127 127
 	}
128 128
 
129
-	if ( empty( $field['attributes']['class'] ) ) {
129
+	if (empty($field['attributes']['class'])) {
130 130
 		$field['attributes']['class'] = '';
131 131
 	}
132 132
 
133
-	$field['attributes']['class'] = trim( "give-field {$field['attributes']['class']} give-{$field['type']} {$field['class']}" );
134
-	unset( $field['class'] );
133
+	$field['attributes']['class'] = trim("give-field {$field['attributes']['class']} give-{$field['type']} {$field['class']}");
134
+	unset($field['class']);
135 135
 
136 136
 	// CMB2 compatibility: Set wrapper class if any.
137
-	if ( ! empty( $field['row_classes'] ) ) {
137
+	if ( ! empty($field['row_classes'])) {
138 138
 		$field['wrapper_class'] = $field['row_classes'];
139
-		unset( $field['row_classes'] );
139
+		unset($field['row_classes']);
140 140
 	}
141 141
 
142 142
 	// Set field params on basis of cmb2 field name.
143
-	switch ( $field['type'] ) {
143
+	switch ($field['type']) {
144 144
 		case 'radio_inline':
145
-			if ( empty( $field['wrapper_class'] ) ) {
145
+			if (empty($field['wrapper_class'])) {
146 146
 				$field['wrapper_class'] = '';
147 147
 			}
148 148
 			$field['wrapper_class'] .= ' give-inline-radio-fields';
@@ -155,15 +155,15 @@  discard block
 block discarded – undo
155 155
 		case 'text-small' :
156 156
 		case 'text_small' :
157 157
 			// CMB2 compatibility: Set field type to text.
158
-			$field['type'] = isset( $field['attributes']['type'] ) ? $field['attributes']['type'] : 'text';
158
+			$field['type'] = isset($field['attributes']['type']) ? $field['attributes']['type'] : 'text';
159 159
 
160 160
 			// CMB2 compatibility: Set data type to price.
161 161
 			if (
162
-				empty( $field['data_type'] )
163
-				&& ! empty( $field['attributes']['class'] )
162
+				empty($field['data_type'])
163
+				&& ! empty($field['attributes']['class'])
164 164
 				&& (
165
-					false !== strpos( $field['attributes']['class'], 'money' )
166
-					|| false !== strpos( $field['attributes']['class'], 'amount' )
165
+					false !== strpos($field['attributes']['class'], 'money')
166
+					|| false !== strpos($field['attributes']['class'], 'amount')
167 167
 				)
168 168
 			) {
169 169
 				$field['data_type'] = 'decimal';
@@ -182,22 +182,22 @@  discard block
 block discarded – undo
182 182
 		case 'give_default_radio_inline':
183 183
 			$field['type']    = 'radio';
184 184
 			$field['options'] = array(
185
-				'default' => __( 'Default' ),
185
+				'default' => __('Default'),
186 186
 			);
187 187
 			break;
188 188
 	}
189 189
 
190 190
 	// CMB2 compatibility: Add support to define field description by desc & description param.
191 191
 	// We encourage you to use description param.
192
-	$field['description'] = ( ! empty( $field['description'] )
192
+	$field['description'] = ( ! empty($field['description'])
193 193
 		? $field['description']
194
-		: ( ! empty( $field['desc'] ) ? $field['desc'] : '' ) );
194
+		: ( ! empty($field['desc']) ? $field['desc'] : ''));
195 195
 
196 196
 	// Call render function.
197
-	if ( is_array( $func_name ) ) {
198
-		$func_name[0]->{$func_name[1]}( $field );
197
+	if (is_array($func_name)) {
198
+		$func_name[0]->{$func_name[1]}($field);
199 199
 	} else {
200
-		$func_name( $field );
200
+		$func_name($field);
201 201
 	}
202 202
 
203 203
 	return true;
@@ -227,29 +227,29 @@  discard block
 block discarded – undo
227 227
  * }
228 228
  * @return void
229 229
  */
230
-function give_text_input( $field ) {
230
+function give_text_input($field) {
231 231
 	global $thepostid, $post;
232 232
 
233
-	$thepostid              = empty( $thepostid ) ? $post->ID : $thepostid;
234
-	$field['style']         = isset( $field['style'] ) ? $field['style'] : '';
235
-	$field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
236
-	$field['value']         = give_get_field_value( $field, $thepostid );
237
-	$field['type']          = isset( $field['type'] ) ? $field['type'] : 'text';
233
+	$thepostid              = empty($thepostid) ? $post->ID : $thepostid;
234
+	$field['style']         = isset($field['style']) ? $field['style'] : '';
235
+	$field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : '';
236
+	$field['value']         = give_get_field_value($field, $thepostid);
237
+	$field['type']          = isset($field['type']) ? $field['type'] : 'text';
238 238
 	$field['before_field']  = '';
239 239
 	$field['after_field']   = '';
240
-	$data_type              = empty( $field['data_type'] ) ? '' : $field['data_type'];
240
+	$data_type              = empty($field['data_type']) ? '' : $field['data_type'];
241 241
 
242
-	switch ( $data_type ) {
242
+	switch ($data_type) {
243 243
 		case 'price' :
244
-			$field['value'] = ( ! empty( $field['value'] ) ? give_format_amount( give_maybe_sanitize_amount( $field['value'] ), array( 'sanitize' => false ) ) : $field['value'] );
244
+			$field['value'] = ( ! empty($field['value']) ? give_format_amount(give_maybe_sanitize_amount($field['value']), array('sanitize' => false)) : $field['value']);
245 245
 
246
-			$field['before_field'] = ! empty( $field['before_field'] ) ? $field['before_field'] : ( give_get_option( 'currency_position', 'before' ) == 'before' ? '<span class="give-money-symbol give-money-symbol-before">' . give_currency_symbol() . '</span>' : '' );
247
-			$field['after_field']  = ! empty( $field['after_field'] ) ? $field['after_field'] : ( give_get_option( 'currency_position', 'before' ) == 'after' ? '<span class="give-money-symbol give-money-symbol-after">' . give_currency_symbol() . '</span>' : '' );
246
+			$field['before_field'] = ! empty($field['before_field']) ? $field['before_field'] : (give_get_option('currency_position', 'before') == 'before' ? '<span class="give-money-symbol give-money-symbol-before">'.give_currency_symbol().'</span>' : '');
247
+			$field['after_field']  = ! empty($field['after_field']) ? $field['after_field'] : (give_get_option('currency_position', 'before') == 'after' ? '<span class="give-money-symbol give-money-symbol-after">'.give_currency_symbol().'</span>' : '');
248 248
 			break;
249 249
 
250 250
 		case 'decimal' :
251 251
 			$field['attributes']['class'] .= ' give_input_decimal';
252
-			$field['value'] = ( ! empty( $field['value'] ) ? give_format_decimal( give_maybe_sanitize_amount( $field['value'] ), false, false ) : $field['value'] );
252
+			$field['value'] = ( ! empty($field['value']) ? give_format_decimal(give_maybe_sanitize_amount($field['value']), false, false) : $field['value']);
253 253
 			break;
254 254
 
255 255
 		default :
@@ -257,20 +257,20 @@  discard block
 block discarded – undo
257 257
 	}
258 258
 
259 259
 	?>
260
-	<p class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>">
261
-	<label for="<?php echo give_get_field_name( $field ); ?>"><?php echo wp_kses_post( $field['name'] ); ?></label>
260
+	<p class="give-field-wrap <?php echo esc_attr($field['id']); ?>_field <?php echo esc_attr($field['wrapper_class']); ?>">
261
+	<label for="<?php echo give_get_field_name($field); ?>"><?php echo wp_kses_post($field['name']); ?></label>
262 262
 	<?php echo $field['before_field']; ?>
263 263
 	<input
264
-			type="<?php echo esc_attr( $field['type'] ); ?>"
265
-			style="<?php echo esc_attr( $field['style'] ); ?>"
266
-			name="<?php echo give_get_field_name( $field ); ?>"
267
-			id="<?php echo esc_attr( $field['id'] ); ?>"
268
-			value="<?php echo esc_attr( $field['value'] ); ?>"
269
-		<?php echo give_get_custom_attributes( $field ); ?>
264
+			type="<?php echo esc_attr($field['type']); ?>"
265
+			style="<?php echo esc_attr($field['style']); ?>"
266
+			name="<?php echo give_get_field_name($field); ?>"
267
+			id="<?php echo esc_attr($field['id']); ?>"
268
+			value="<?php echo esc_attr($field['value']); ?>"
269
+		<?php echo give_get_custom_attributes($field); ?>
270 270
 	/>
271 271
 	<?php echo $field['after_field']; ?>
272 272
 	<?php
273
-	echo give_get_field_description( $field );
273
+	echo give_get_field_description($field);
274 274
 	echo '</p>';
275 275
 }
276 276
 
@@ -292,29 +292,29 @@  discard block
 block discarded – undo
292 292
  * }
293 293
  * @return void
294 294
  */
295
-function give_hidden_input( $field ) {
295
+function give_hidden_input($field) {
296 296
 	global $thepostid, $post;
297 297
 
298
-	$thepostid      = empty( $thepostid ) ? $post->ID : $thepostid;
299
-	$field['value'] = give_get_field_value( $field, $thepostid );
298
+	$thepostid      = empty($thepostid) ? $post->ID : $thepostid;
299
+	$field['value'] = give_get_field_value($field, $thepostid);
300 300
 
301 301
 	// Custom attribute handling
302 302
 	$custom_attributes = array();
303 303
 
304
-	if ( ! empty( $field['attributes'] ) && is_array( $field['attributes'] ) ) {
304
+	if ( ! empty($field['attributes']) && is_array($field['attributes'])) {
305 305
 
306
-		foreach ( $field['attributes'] as $attribute => $value ) {
307
-			$custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $value ) . '"';
306
+		foreach ($field['attributes'] as $attribute => $value) {
307
+			$custom_attributes[] = esc_attr($attribute).'="'.esc_attr($value).'"';
308 308
 		}
309 309
 	}
310 310
 	?>
311 311
 
312 312
 	<input
313 313
 			type="hidden"
314
-			name="<?php echo give_get_field_name( $field ); ?>"
315
-			id="<?php echo esc_attr( $field['id'] ); ?>"
316
-			value="<?php echo esc_attr( $field['value'] ); ?>"
317
-		<?php echo give_get_custom_attributes( $field ); ?>
314
+			name="<?php echo give_get_field_name($field); ?>"
315
+			id="<?php echo esc_attr($field['id']); ?>"
316
+			value="<?php echo esc_attr($field['value']); ?>"
317
+		<?php echo give_get_custom_attributes($field); ?>
318 318
 	/>
319 319
 	<?php
320 320
 }
@@ -340,27 +340,27 @@  discard block
 block discarded – undo
340 340
  * }
341 341
  * @return void
342 342
  */
343
-function give_textarea_input( $field ) {
343
+function give_textarea_input($field) {
344 344
 	global $thepostid, $post;
345 345
 
346
-	$thepostid              = empty( $thepostid ) ? $post->ID : $thepostid;
347
-	$field['style']         = isset( $field['style'] ) ? $field['style'] : '';
348
-	$field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
349
-	$field['value']         = give_get_field_value( $field, $thepostid );
346
+	$thepostid              = empty($thepostid) ? $post->ID : $thepostid;
347
+	$field['style']         = isset($field['style']) ? $field['style'] : '';
348
+	$field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : '';
349
+	$field['value']         = give_get_field_value($field, $thepostid);
350 350
 
351 351
 	?>
352
-	<p class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>">
353
-	<label for="<?php echo give_get_field_name( $field ); ?>"><?php echo wp_kses_post( $field['name'] ); ?></label>
352
+	<p class="give-field-wrap <?php echo esc_attr($field['id']); ?>_field <?php echo esc_attr($field['wrapper_class']); ?>">
353
+	<label for="<?php echo give_get_field_name($field); ?>"><?php echo wp_kses_post($field['name']); ?></label>
354 354
 	<textarea
355
-			style="<?php echo esc_attr( $field['style'] ); ?>"
356
-			name="<?php echo give_get_field_name( $field ); ?>"
357
-			id="<?php echo esc_attr( $field['id'] ); ?>"
355
+			style="<?php echo esc_attr($field['style']); ?>"
356
+			name="<?php echo give_get_field_name($field); ?>"
357
+			id="<?php echo esc_attr($field['id']); ?>"
358 358
 			rows="10"
359 359
 			cols="20"
360
-		<?php echo give_get_custom_attributes( $field ); ?>
361
-	><?php echo esc_textarea( $field['value'] ); ?></textarea>
360
+		<?php echo give_get_custom_attributes($field); ?>
361
+	><?php echo esc_textarea($field['value']); ?></textarea>
362 362
 	<?php
363
-	echo give_get_field_description( $field );
363
+	echo give_get_field_description($field);
364 364
 	echo '</p>';
365 365
 }
366 366
 
@@ -384,29 +384,29 @@  discard block
 block discarded – undo
384 384
  * }
385 385
  * @return void
386 386
  */
387
-function give_wysiwyg( $field ) {
387
+function give_wysiwyg($field) {
388 388
 	global $thepostid, $post;
389 389
 
390
-	$thepostid              = empty( $thepostid ) ? $post->ID : $thepostid;
391
-	$field['value']         = give_get_field_value( $field, $thepostid );
392
-	$field['style']         = isset( $field['style'] ) ? $field['style'] : '';
393
-	$field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
390
+	$thepostid              = empty($thepostid) ? $post->ID : $thepostid;
391
+	$field['value']         = give_get_field_value($field, $thepostid);
392
+	$field['style']         = isset($field['style']) ? $field['style'] : '';
393
+	$field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : '';
394 394
 
395
-	$field['unique_field_id'] = give_get_field_name( $field );
395
+	$field['unique_field_id'] = give_get_field_name($field);
396 396
 	$editor_attributes        = array(
397
-		'textarea_name' => isset( $field['repeatable_field_id'] ) ? $field['repeatable_field_id'] : $field['id'],
397
+		'textarea_name' => isset($field['repeatable_field_id']) ? $field['repeatable_field_id'] : $field['id'],
398 398
 		'textarea_rows' => '10',
399
-		'editor_css'    => esc_attr( $field['style'] ),
399
+		'editor_css'    => esc_attr($field['style']),
400 400
 		'editor_class'  => $field['attributes']['class'],
401 401
 	);
402
-	$data_wp_editor           = ' data-wp-editor="' . base64_encode( json_encode( array(
402
+	$data_wp_editor = ' data-wp-editor="'.base64_encode(json_encode(array(
403 403
 			$field['value'],
404 404
 			$field['unique_field_id'],
405 405
 			$editor_attributes,
406
-	) ) ) . '"';
407
-	$data_wp_editor           = isset( $field['repeatable_field_id'] ) ? $data_wp_editor : '';
406
+	))).'"';
407
+	$data_wp_editor = isset($field['repeatable_field_id']) ? $data_wp_editor : '';
408 408
 
409
-	echo '<div class="give-field-wrap ' . $field['unique_field_id'] . '_field ' . esc_attr( $field['wrapper_class'] ) . '"' . $data_wp_editor . '><label for="' . $field['unique_field_id'] . '">' . wp_kses_post( $field['name'] ) . '</label>';
409
+	echo '<div class="give-field-wrap '.$field['unique_field_id'].'_field '.esc_attr($field['wrapper_class']).'"'.$data_wp_editor.'><label for="'.$field['unique_field_id'].'">'.wp_kses_post($field['name']).'</label>';
410 410
 
411 411
 	wp_editor(
412 412
 		$field['value'],
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 		$editor_attributes
415 415
 	);
416 416
 
417
-	echo give_get_field_description( $field );
417
+	echo give_get_field_description($field);
418 418
 	echo '</div>';
419 419
 }
420 420
 
@@ -439,29 +439,29 @@  discard block
 block discarded – undo
439 439
  * }
440 440
  * @return void
441 441
  */
442
-function give_checkbox( $field ) {
442
+function give_checkbox($field) {
443 443
 	global $thepostid, $post;
444 444
 
445
-	$thepostid              = empty( $thepostid ) ? $post->ID : $thepostid;
446
-	$field['style']         = isset( $field['style'] ) ? $field['style'] : '';
447
-	$field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
448
-	$field['value']         = give_get_field_value( $field, $thepostid );
449
-	$field['cbvalue']       = isset( $field['cbvalue'] ) ? $field['cbvalue'] : 'on';
450
-	$field['name']          = isset( $field['name'] ) ? $field['name'] : $field['id'];
445
+	$thepostid              = empty($thepostid) ? $post->ID : $thepostid;
446
+	$field['style']         = isset($field['style']) ? $field['style'] : '';
447
+	$field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : '';
448
+	$field['value']         = give_get_field_value($field, $thepostid);
449
+	$field['cbvalue']       = isset($field['cbvalue']) ? $field['cbvalue'] : 'on';
450
+	$field['name']          = isset($field['name']) ? $field['name'] : $field['id'];
451 451
 	?>
452
-	<p class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>">
453
-	<label for="<?php echo give_get_field_name( $field ); ?>"><?php echo wp_kses_post( $field['name'] ); ?></label>
452
+	<p class="give-field-wrap <?php echo esc_attr($field['id']); ?>_field <?php echo esc_attr($field['wrapper_class']); ?>">
453
+	<label for="<?php echo give_get_field_name($field); ?>"><?php echo wp_kses_post($field['name']); ?></label>
454 454
 	<input
455 455
 			type="checkbox"
456
-			style="<?php echo esc_attr( $field['style'] ); ?>"
457
-			name="<?php echo give_get_field_name( $field ); ?>"
458
-			id="<?php echo esc_attr( $field['id'] ); ?>"
459
-			value="<?php echo esc_attr( $field['cbvalue'] ); ?>"
460
-		<?php echo checked( $field['value'], $field['cbvalue'], false ); ?>
461
-		<?php echo give_get_custom_attributes( $field ); ?>
456
+			style="<?php echo esc_attr($field['style']); ?>"
457
+			name="<?php echo give_get_field_name($field); ?>"
458
+			id="<?php echo esc_attr($field['id']); ?>"
459
+			value="<?php echo esc_attr($field['cbvalue']); ?>"
460
+		<?php echo checked($field['value'], $field['cbvalue'], false); ?>
461
+		<?php echo give_get_custom_attributes($field); ?>
462 462
 	/>
463 463
 	<?php
464
-	echo give_get_field_description( $field );
464
+	echo give_get_field_description($field);
465 465
 	echo '</p>';
466 466
 }
467 467
 
@@ -487,29 +487,29 @@  discard block
 block discarded – undo
487 487
  * }
488 488
  * @return void
489 489
  */
490
-function give_select( $field ) {
490
+function give_select($field) {
491 491
 	global $thepostid, $post;
492 492
 
493
-	$thepostid              = empty( $thepostid ) ? $post->ID : $thepostid;
494
-	$field['style']         = isset( $field['style'] ) ? $field['style'] : '';
495
-	$field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
496
-	$field['value']         = give_get_field_value( $field, $thepostid );
497
-	$field['name']          = isset( $field['name'] ) ? $field['name'] : $field['id'];
493
+	$thepostid              = empty($thepostid) ? $post->ID : $thepostid;
494
+	$field['style']         = isset($field['style']) ? $field['style'] : '';
495
+	$field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : '';
496
+	$field['value']         = give_get_field_value($field, $thepostid);
497
+	$field['name']          = isset($field['name']) ? $field['name'] : $field['id'];
498 498
 	?>
499
-	<p class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>">
500
-	<label for="<?php echo give_get_field_name( $field ); ?>"><?php echo wp_kses_post( $field['name'] ); ?></label>
499
+	<p class="give-field-wrap <?php echo esc_attr($field['id']); ?>_field <?php echo esc_attr($field['wrapper_class']); ?>">
500
+	<label for="<?php echo give_get_field_name($field); ?>"><?php echo wp_kses_post($field['name']); ?></label>
501 501
 	<select
502
-	id="<?php echo esc_attr( $field['id'] ); ?>"
503
-	name="<?php echo give_get_field_name( $field ); ?>"
504
-	style="<?php echo esc_attr( $field['style'] ) ?>"
505
-	<?php echo give_get_custom_attributes( $field ); ?>
502
+	id="<?php echo esc_attr($field['id']); ?>"
503
+	name="<?php echo give_get_field_name($field); ?>"
504
+	style="<?php echo esc_attr($field['style']) ?>"
505
+	<?php echo give_get_custom_attributes($field); ?>
506 506
 	>
507 507
 	<?php
508
-	foreach ( $field['options'] as $key => $value ) {
509
-		echo '<option value="' . esc_attr( $key ) . '" ' . selected( esc_attr( $field['value'] ), esc_attr( $key ), false ) . '>' . esc_html( $value ) . '</option>';
508
+	foreach ($field['options'] as $key => $value) {
509
+		echo '<option value="'.esc_attr($key).'" '.selected(esc_attr($field['value']), esc_attr($key), false).'>'.esc_html($value).'</option>';
510 510
 	}
511 511
 	echo '</select>';
512
-	echo give_get_field_description( $field );
512
+	echo give_get_field_description($field);
513 513
 	echo '</p>';
514 514
 }
515 515
 
@@ -536,32 +536,32 @@  discard block
 block discarded – undo
536 536
  * }
537 537
  * @return void
538 538
  */
539
-function give_radio( $field ) {
539
+function give_radio($field) {
540 540
 	global $thepostid, $post;
541 541
 
542
-	$thepostid              = empty( $thepostid ) ? $post->ID : $thepostid;
543
-	$field['style']         = isset( $field['style'] ) ? $field['style'] : '';
544
-	$field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
545
-	$field['value']         = give_get_field_value( $field, $thepostid );
546
-	$field['name']          = isset( $field['name'] ) ? $field['name'] : $field['id'];
542
+	$thepostid              = empty($thepostid) ? $post->ID : $thepostid;
543
+	$field['style']         = isset($field['style']) ? $field['style'] : '';
544
+	$field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : '';
545
+	$field['value']         = give_get_field_value($field, $thepostid);
546
+	$field['name']          = isset($field['name']) ? $field['name'] : $field['id'];
547 547
 
548
-	echo '<fieldset class="give-field-wrap ' . esc_attr( $field['id'] ) . '_field ' . esc_attr( $field['wrapper_class'] ) . '"><span class="give-field-label">' . wp_kses_post( $field['name'] ) . '</span><legend class="screen-reader-text">' . wp_kses_post( $field['name'] ) . '</legend><ul class="give-radios">';
548
+	echo '<fieldset class="give-field-wrap '.esc_attr($field['id']).'_field '.esc_attr($field['wrapper_class']).'"><span class="give-field-label">'.wp_kses_post($field['name']).'</span><legend class="screen-reader-text">'.wp_kses_post($field['name']).'</legend><ul class="give-radios">';
549 549
 
550
-	foreach ( $field['options'] as $key => $value ) {
550
+	foreach ($field['options'] as $key => $value) {
551 551
 
552 552
 		echo '<li><label><input
553
-				name="' . give_get_field_name( $field ) . '"
554
-				value="' . esc_attr( $key ) . '"
553
+				name="' . give_get_field_name($field).'"
554
+				value="' . esc_attr($key).'"
555 555
 				type="radio"
556
-				style="' . esc_attr( $field['style'] ) . '"
557
-				' . checked( esc_attr( $field['value'] ), esc_attr( $key ), false ) . ' '
558
-		     . give_get_custom_attributes( $field ) . '
559
-				/> ' . esc_html( $value ) . '</label>
556
+				style="' . esc_attr($field['style']).'"
557
+				' . checked(esc_attr($field['value']), esc_attr($key), false).' '
558
+		     . give_get_custom_attributes($field).'
559
+				/> ' . esc_html($value).'</label>
560 560
 		</li>';
561 561
 	}
562 562
 	echo '</ul>';
563 563
 
564
-	echo give_get_field_description( $field );
564
+	echo give_get_field_description($field);
565 565
 	echo '</fieldset>';
566 566
 }
567 567
 
@@ -585,27 +585,27 @@  discard block
 block discarded – undo
585 585
  * }
586 586
  * @return void
587 587
  */
588
-function give_colorpicker( $field ) {
588
+function give_colorpicker($field) {
589 589
 	global $thepostid, $post;
590 590
 
591
-	$thepostid              = empty( $thepostid ) ? $post->ID : $thepostid;
592
-	$field['style']         = isset( $field['style'] ) ? $field['style'] : '';
593
-	$field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
594
-	$field['value']         = give_get_field_value( $field, $thepostid );
595
-	$field['name']          = isset( $field['name'] ) ? $field['name'] : $field['id'];
591
+	$thepostid              = empty($thepostid) ? $post->ID : $thepostid;
592
+	$field['style']         = isset($field['style']) ? $field['style'] : '';
593
+	$field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : '';
594
+	$field['value']         = give_get_field_value($field, $thepostid);
595
+	$field['name']          = isset($field['name']) ? $field['name'] : $field['id'];
596 596
 	$field['type']          = 'text';
597 597
 	?>
598
-	<p class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>">
599
-	<label for="<?php echo give_get_field_name( $field ); ?>"><?php echo wp_kses_post( $field['name'] ); ?></label>
598
+	<p class="give-field-wrap <?php echo esc_attr($field['id']); ?>_field <?php echo esc_attr($field['wrapper_class']); ?>">
599
+	<label for="<?php echo give_get_field_name($field); ?>"><?php echo wp_kses_post($field['name']); ?></label>
600 600
 	<input
601
-			type="<?php echo esc_attr( $field['type'] ); ?>"
602
-			style="<?php echo esc_attr( $field['style'] ); ?>"
603
-			name="<?php echo give_get_field_name( $field ); ?>"
604
-			id="' . esc_attr( $field['id'] ) . '" value="<?php echo esc_attr( $field['value'] ); ?>"
605
-		<?php echo give_get_custom_attributes( $field ); ?>
601
+			type="<?php echo esc_attr($field['type']); ?>"
602
+			style="<?php echo esc_attr($field['style']); ?>"
603
+			name="<?php echo give_get_field_name($field); ?>"
604
+			id="' . esc_attr( $field['id'] ) . '" value="<?php echo esc_attr($field['value']); ?>"
605
+		<?php echo give_get_custom_attributes($field); ?>
606 606
 	/>
607 607
 	<?php
608
-	echo give_get_field_description( $field );
608
+	echo give_get_field_description($field);
609 609
 	echo '</p>';
610 610
 }
611 611
 
@@ -616,8 +616,8 @@  discard block
 block discarded – undo
616 616
  *
617 617
  * @param array $field
618 618
  */
619
-function give_file( $field ) {
620
-	give_media( $field );
619
+function give_file($field) {
620
+	give_media($field);
621 621
 }
622 622
 
623 623
 
@@ -628,40 +628,40 @@  discard block
 block discarded – undo
628 628
  *
629 629
  * @param array $field
630 630
  */
631
-function give_media( $field ) {
631
+function give_media($field) {
632 632
 	global $thepostid, $post;
633 633
 
634
-	$thepostid    = empty( $thepostid ) ? $post->ID : $thepostid;
635
-	$button_label = esc_html__( sprintf( 'Add or Upload %s', ( 'file' === $field['type'] ? 'File' : 'Image' ) ), 'give' );
634
+	$thepostid    = empty($thepostid) ? $post->ID : $thepostid;
635
+	$button_label = esc_html__(sprintf('Add or Upload %s', ('file' === $field['type'] ? 'File' : 'Image')), 'give');
636 636
 
637
-	$field['style']               = isset( $field['style'] ) ? $field['style'] : '';
638
-	$field['wrapper_class']       = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
639
-	$field['value']               = give_get_field_value( $field, $thepostid );
640
-	$field['name']                = isset( $field['name'] ) ? $field['name'] : $field['id'];
637
+	$field['style']               = isset($field['style']) ? $field['style'] : '';
638
+	$field['wrapper_class']       = isset($field['wrapper_class']) ? $field['wrapper_class'] : '';
639
+	$field['value']               = give_get_field_value($field, $thepostid);
640
+	$field['name']                = isset($field['name']) ? $field['name'] : $field['id'];
641 641
 	$field['attributes']['class'] = "{$field['attributes']['class']} give-text-medium";
642 642
 
643 643
 	// Allow developer to save attachment ID or attachment url as metadata.
644
-	$field['fvalue'] = isset( $field['fvalue'] ) ? $field['fvalue'] : 'url';
644
+	$field['fvalue'] = isset($field['fvalue']) ? $field['fvalue'] : 'url';
645 645
 
646
-	$allow_media_preview_tags = array( 'jpg', 'jpeg', 'png', 'gif', 'ico' );
647
-	$preview_image_src        = $field['value'] ? ( 'id' === $field['fvalue'] ? wp_get_attachment_url( $field['value'] ) : $field['value'] ) : '#';
648
-	$preview_image_extension  = $preview_image_src ? pathinfo( $preview_image_src, PATHINFO_EXTENSION ) : '';
649
-	$is_show_preview = in_array( $preview_image_extension, $allow_media_preview_tags );
646
+	$allow_media_preview_tags = array('jpg', 'jpeg', 'png', 'gif', 'ico');
647
+	$preview_image_src        = $field['value'] ? ('id' === $field['fvalue'] ? wp_get_attachment_url($field['value']) : $field['value']) : '#';
648
+	$preview_image_extension  = $preview_image_src ? pathinfo($preview_image_src, PATHINFO_EXTENSION) : '';
649
+	$is_show_preview = in_array($preview_image_extension, $allow_media_preview_tags);
650 650
 	?>
651
-	<fieldset class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>">
652
-		<label for="<?php echo give_get_field_name( $field ) ?>"><?php echo wp_kses_post( $field['name'] ); ?></label>
651
+	<fieldset class="give-field-wrap <?php echo esc_attr($field['id']); ?>_field <?php echo esc_attr($field['wrapper_class']); ?>">
652
+		<label for="<?php echo give_get_field_name($field) ?>"><?php echo wp_kses_post($field['name']); ?></label>
653 653
 		<input
654
-				name="<?php echo give_get_field_name( $field ); ?>"
655
-				id="<?php echo esc_attr( $field['id'] ); ?>"
654
+				name="<?php echo give_get_field_name($field); ?>"
655
+				id="<?php echo esc_attr($field['id']); ?>"
656 656
 				type="text"
657 657
 				value="<?php echo $field['value']; ?>"
658
-				style="<?php echo esc_attr( $field['style'] ); ?>"
659
-			<?php echo give_get_custom_attributes( $field ); ?>
658
+				style="<?php echo esc_attr($field['style']); ?>"
659
+			<?php echo give_get_custom_attributes($field); ?>
660 660
 		/>&nbsp;&nbsp;&nbsp;&nbsp;<input class="give-upload-button button" type="button" value="<?php echo $button_label; ?>" data-fvalue="<?php echo $field['fvalue']; ?>" data-field-type="<?php echo $field['type']; ?>">
661
-		<?php echo give_get_field_description( $field ); ?>
661
+		<?php echo give_get_field_description($field); ?>
662 662
 		<div class="give-image-thumb<?php echo ! $field['value'] || ! $is_show_preview ? ' give-hidden' : ''; ?>">
663 663
 			<span class="give-delete-image-thumb dashicons dashicons-no-alt"></span>
664
-			<img src="<?php echo $preview_image_src ; ?>" alt="">
664
+			<img src="<?php echo $preview_image_src; ?>" alt="">
665 665
 		</div>
666 666
 	</fieldset>
667 667
 	<?php
@@ -676,27 +676,27 @@  discard block
 block discarded – undo
676 676
  *
677 677
  * @return void
678 678
  */
679
-function give_default_gateway( $field ) {
679
+function give_default_gateway($field) {
680 680
 	global $thepostid, $post;
681 681
 
682 682
 	// get all active payment gateways.
683
-	$gateways         = give_get_enabled_payment_gateways( $thepostid );
683
+	$gateways         = give_get_enabled_payment_gateways($thepostid);
684 684
 	$field['options'] = array();
685 685
 
686 686
 	// Set field option value.
687
-	if ( ! empty( $gateways ) ) {
688
-		foreach ( $gateways as $key => $option ) {
689
-			$field['options'][ $key ] = $option['admin_label'];
687
+	if ( ! empty($gateways)) {
688
+		foreach ($gateways as $key => $option) {
689
+			$field['options'][$key] = $option['admin_label'];
690 690
 		}
691 691
 	}
692 692
 
693 693
 	// Add a field to the Give Form admin single post view of this field
694
-	if ( is_object( $post ) && 'give_forms' === $post->post_type ) {
695
-		$field['options'] = array_merge( array( 'global' => esc_html__( 'Global Default', 'give' ) ), $field['options'] );
694
+	if (is_object($post) && 'give_forms' === $post->post_type) {
695
+		$field['options'] = array_merge(array('global' => esc_html__('Global Default', 'give')), $field['options']);
696 696
 	}
697 697
 
698 698
 	// Render select field.
699
-	give_select( $field );
699
+	give_select($field);
700 700
 }
701 701
 
702 702
 /**
@@ -718,13 +718,13 @@  discard block
 block discarded – undo
718 718
  * @return void
719 719
  */
720 720
 
721
-function give_docs_link( $field ) {
722
-	$field['url']   = isset( $field['url'] ) ? $field['url'] : 'https://givewp.com/documentation';
723
-	$field['title'] = isset( $field['title'] ) ? $field['title'] : 'Documentation';
721
+function give_docs_link($field) {
722
+	$field['url']   = isset($field['url']) ? $field['url'] : 'https://givewp.com/documentation';
723
+	$field['title'] = isset($field['title']) ? $field['title'] : 'Documentation';
724 724
 
725
-	echo '<p class="give-docs-link"><a href="' . esc_url( $field['url'] )
725
+	echo '<p class="give-docs-link"><a href="'.esc_url($field['url'])
726 726
 	     . '" target="_blank">'
727
-	     . sprintf( esc_html__( 'Need Help? See docs on "%s"', 'give' ), $field['title'] )
727
+	     . sprintf(esc_html__('Need Help? See docs on "%s"', 'give'), $field['title'])
728 728
 	     . '<span class="dashicons dashicons-editor-help"></span></a></p>';
729 729
 }
730 730
 
@@ -740,13 +740,13 @@  discard block
 block discarded – undo
740 740
  *
741 741
  * @return mixed
742 742
  */
743
-function give_get_field_value( $field, $postid ) {
744
-	if ( isset( $field['attributes']['value'] ) ) {
743
+function give_get_field_value($field, $postid) {
744
+	if (isset($field['attributes']['value'])) {
745 745
 		return $field['attributes']['value'];
746 746
 	}
747 747
 
748 748
 	// Get value from db.
749
-	$field_value = give_get_meta( $postid, $field['id'], true );
749
+	$field_value = give_get_meta($postid, $field['id'], true);
750 750
 
751 751
 	/**
752 752
 	 * Filter the field value before apply default value.
@@ -755,10 +755,10 @@  discard block
 block discarded – undo
755 755
 	 *
756 756
 	 * @param mixed $field_value Field value.
757 757
 	 */
758
-	$field_value = apply_filters( "{$field['id']}_field_value", $field_value, $field, $postid );
758
+	$field_value = apply_filters("{$field['id']}_field_value", $field_value, $field, $postid);
759 759
 
760 760
 	// Set default value if no any data saved to db.
761
-	if ( ! $field_value && isset( $field['default'] ) ) {
761
+	if ( ! $field_value && isset($field['default'])) {
762 762
 		$field_value = $field['default'];
763 763
 	}
764 764
 
@@ -775,20 +775,20 @@  discard block
 block discarded – undo
775 775
  *
776 776
  * @return string
777 777
  */
778
-function give_get_field_description( $field ) {
778
+function give_get_field_description($field) {
779 779
 	$field_desc_html = '';
780 780
 	$description     = '';
781 781
 
782 782
 	// Check for both `description` and `desc`.
783
-	if ( isset( $field['description'] ) ) {
783
+	if (isset($field['description'])) {
784 784
 		$description = $field['description'];
785
-	} elseif ( isset( $field['desc'] ) ) {
785
+	} elseif (isset($field['desc'])) {
786 786
 		$description = $field['desc'];
787 787
 	}
788 788
 
789 789
 	// Set if there is a description.
790
-	if ( ! empty( $description ) ) {
791
-		$field_desc_html = '<span class="give-field-description">' . wp_kses_post( $description ) . '</span>';
790
+	if ( ! empty($description)) {
791
+		$field_desc_html = '<span class="give-field-description">'.wp_kses_post($description).'</span>';
792 792
 	}
793 793
 
794 794
 	return $field_desc_html;
@@ -804,18 +804,18 @@  discard block
 block discarded – undo
804 804
  *
805 805
  * @return string
806 806
  */
807
-function give_get_custom_attributes( $field ) {
807
+function give_get_custom_attributes($field) {
808 808
 	// Custom attribute handling
809 809
 	$custom_attributes = array();
810 810
 
811
-	if ( ! empty( $field['attributes'] ) && is_array( $field['attributes'] ) ) {
811
+	if ( ! empty($field['attributes']) && is_array($field['attributes'])) {
812 812
 
813
-		foreach ( $field['attributes'] as $attribute => $value ) {
814
-			$custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $value ) . '"';
813
+		foreach ($field['attributes'] as $attribute => $value) {
814
+			$custom_attributes[] = esc_attr($attribute).'="'.esc_attr($value).'"';
815 815
 		}
816 816
 	}
817 817
 
818
-	return implode( ' ', $custom_attributes );
818
+	return implode(' ', $custom_attributes);
819 819
 }
820 820
 
821 821
 /**
@@ -831,8 +831,8 @@  discard block
 block discarded – undo
831 831
  *
832 832
  * @return string
833 833
  */
834
-function give_get_repeater_field_value( $field, $field_group, $fields ) {
835
-	$field_value = ( isset( $field_group[ $field['id'] ] ) ? $field_group[ $field['id'] ] : '' );
834
+function give_get_repeater_field_value($field, $field_group, $fields) {
835
+	$field_value = (isset($field_group[$field['id']]) ? $field_group[$field['id']] : '');
836 836
 
837 837
 	/**
838 838
 	 * Filter the specific repeater field value
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
 	 *
842 842
 	 * @param string $field_id
843 843
 	 */
844
-	$field_value = apply_filters( "give_get_repeater_field_{$field['id']}_value", $field_value, $field, $field_group, $fields );
844
+	$field_value = apply_filters("give_get_repeater_field_{$field['id']}_value", $field_value, $field, $field_group, $fields);
845 845
 
846 846
 	/**
847 847
 	 * Filter the repeater field value
@@ -850,7 +850,7 @@  discard block
 block discarded – undo
850 850
 	 *
851 851
 	 * @param string $field_id
852 852
 	 */
853
-	$field_value = apply_filters( 'give_get_repeater_field_value', $field_value, $field, $field_group, $fields );
853
+	$field_value = apply_filters('give_get_repeater_field_value', $field_value, $field, $field_group, $fields);
854 854
 
855 855
 	return $field_value;
856 856
 }
@@ -868,7 +868,7 @@  discard block
 block discarded – undo
868 868
  *
869 869
  * @return string
870 870
  */
871
-function give_get_repeater_field_id( $field, $fields, $default = false ) {
871
+function give_get_repeater_field_id($field, $fields, $default = false) {
872 872
 	$row_placeholder = false !== $default ? $default : '{{row-count-placeholder}}';
873 873
 
874 874
 	// Get field id.
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
 	 *
882 882
 	 * @param string $field_id
883 883
 	 */
884
-	$field_id = apply_filters( "give_get_repeater_field_{$field['id']}_id", $field_id, $field, $fields, $default );
884
+	$field_id = apply_filters("give_get_repeater_field_{$field['id']}_id", $field_id, $field, $fields, $default);
885 885
 
886 886
 	/**
887 887
 	 * Filter the repeater field id
@@ -890,7 +890,7 @@  discard block
 block discarded – undo
890 890
 	 *
891 891
 	 * @param string $field_id
892 892
 	 */
893
-	$field_id = apply_filters( 'give_get_repeater_field_id', $field_id, $field, $fields, $default );
893
+	$field_id = apply_filters('give_get_repeater_field_id', $field_id, $field, $fields, $default);
894 894
 
895 895
 	return $field_id;
896 896
 }
@@ -905,8 +905,8 @@  discard block
 block discarded – undo
905 905
  *
906 906
  * @return string
907 907
  */
908
-function give_get_field_name( $field ) {
909
-	$field_name = esc_attr( empty( $field['repeat'] ) ? $field['id'] : $field['repeatable_field_id'] );
908
+function give_get_field_name($field) {
909
+	$field_name = esc_attr(empty($field['repeat']) ? $field['id'] : $field['repeatable_field_id']);
910 910
 
911 911
 	/**
912 912
 	 * Filter the field name.
@@ -915,7 +915,7 @@  discard block
 block discarded – undo
915 915
 	 *
916 916
 	 * @param string $field_name
917 917
 	 */
918
-	$field_name = apply_filters( 'give_get_field_name', $field_name, $field );
918
+	$field_name = apply_filters('give_get_field_name', $field_name, $field);
919 919
 
920 920
 	return $field_name;
921 921
 }
@@ -932,39 +932,39 @@  discard block
 block discarded – undo
932 932
  *
933 933
  * @return void
934 934
  */
935
-function _give_metabox_form_data_repeater_fields( $fields ) {
935
+function _give_metabox_form_data_repeater_fields($fields) {
936 936
 	global $thepostid, $post;
937 937
 
938 938
 	// Bailout.
939
-	if ( ! isset( $fields['fields'] ) || empty( $fields['fields'] ) ) {
939
+	if ( ! isset($fields['fields']) || empty($fields['fields'])) {
940 940
 		return;
941 941
 	}
942 942
 
943
-	$group_numbering = isset( $fields['options']['group_numbering'] ) ? (int) $fields['options']['group_numbering'] : 0;
944
-	$close_tabs      = isset( $fields['options']['close_tabs'] ) ? (int) $fields['options']['close_tabs'] : 0;
943
+	$group_numbering = isset($fields['options']['group_numbering']) ? (int) $fields['options']['group_numbering'] : 0;
944
+	$close_tabs      = isset($fields['options']['close_tabs']) ? (int) $fields['options']['close_tabs'] : 0;
945 945
 	?>
946 946
 	<div class="give-repeatable-field-section" id="<?php echo "{$fields['id']}_field"; ?>"
947 947
 		 data-group-numbering="<?php echo $group_numbering; ?>" data-close-tabs="<?php echo $close_tabs; ?>">
948
-		<?php if ( ! empty( $fields['name'] ) ) : ?>
948
+		<?php if ( ! empty($fields['name'])) : ?>
949 949
 			<p class="give-repeater-field-name"><?php echo $fields['name']; ?></p>
950 950
 		<?php endif; ?>
951 951
 
952
-		<?php if ( ! empty( $fields['description'] ) ) : ?>
952
+		<?php if ( ! empty($fields['description'])) : ?>
953 953
 			<p class="give-repeater-field-description"><?php echo $fields['description']; ?></p>
954 954
 		<?php endif; ?>
955 955
 
956 956
 		<table class="give-repeatable-fields-section-wrapper" cellspacing="0">
957 957
 			<?php
958
-			$repeater_field_values = give_get_meta( $thepostid, $fields['id'], true );
959
-			$header_title          = isset( $fields['options']['header_title'] )
958
+			$repeater_field_values = give_get_meta($thepostid, $fields['id'], true);
959
+			$header_title          = isset($fields['options']['header_title'])
960 960
 				? $fields['options']['header_title']
961
-				: esc_attr__( 'Group', 'give' );
961
+				: esc_attr__('Group', 'give');
962 962
 
963 963
 			$add_default_donation_field = false;
964 964
 
965 965
 			// Check if level is not created or we have to add default level.
966
-			if ( is_array( $repeater_field_values ) && ( $fields_count = count( $repeater_field_values ) ) ) {
967
-				$repeater_field_values = array_values( $repeater_field_values );
966
+			if (is_array($repeater_field_values) && ($fields_count = count($repeater_field_values))) {
967
+				$repeater_field_values = array_values($repeater_field_values);
968 968
 			} else {
969 969
 				$fields_count               = 1;
970 970
 				$add_default_donation_field = true;
@@ -977,59 +977,59 @@  discard block
 block discarded – undo
977 977
 					<div class="give-row-head give-move">
978 978
 						<button type="button" class="handlediv button-link"><span class="toggle-indicator"></span>
979 979
 						</button>
980
-						<span class="give-remove" title="<?php esc_html_e( 'Remove Group', 'give' ); ?>">-</span>
980
+						<span class="give-remove" title="<?php esc_html_e('Remove Group', 'give'); ?>">-</span>
981 981
 						<h2>
982 982
 							<span data-header-title="<?php echo $header_title; ?>"><?php echo $header_title; ?></span>
983 983
 						</h2>
984 984
 					</div>
985 985
 					<div class="give-row-body">
986
-						<?php foreach ( $fields['fields'] as $field ) : ?>
987
-							<?php if ( ! give_is_field_callback_exist( $field ) ) {
986
+						<?php foreach ($fields['fields'] as $field) : ?>
987
+							<?php if ( ! give_is_field_callback_exist($field)) {
988 988
 								continue;
989 989
 } ?>
990 990
 							<?php
991 991
 							$field['repeat']              = true;
992
-							$field['repeatable_field_id'] = give_get_repeater_field_id( $field, $fields );
993
-							$field['id']                  = str_replace( array( '[', ']' ), array(
992
+							$field['repeatable_field_id'] = give_get_repeater_field_id($field, $fields);
993
+							$field['id']                  = str_replace(array('[', ']'), array(
994 994
 								'_',
995 995
 								'',
996
-							), $field['repeatable_field_id'] );
996
+							), $field['repeatable_field_id']);
997 997
 							?>
998
-							<?php give_render_field( $field ); ?>
998
+							<?php give_render_field($field); ?>
999 999
 						<?php endforeach; ?>
1000 1000
 					</div>
1001 1001
 				</td>
1002 1002
 			</tr>
1003 1003
 
1004
-			<?php if ( ! empty( $repeater_field_values ) ) : ?>
1004
+			<?php if ( ! empty($repeater_field_values)) : ?>
1005 1005
 				<!--Stored repeater field group-->
1006
-				<?php foreach ( $repeater_field_values as $index => $field_group ) : ?>
1006
+				<?php foreach ($repeater_field_values as $index => $field_group) : ?>
1007 1007
 					<tr class="give-row">
1008 1008
 						<td class="give-repeater-field-wrap give-column" colspan="2">
1009 1009
 							<div class="give-row-head give-move">
1010 1010
 								<button type="button" class="handlediv button-link">
1011 1011
 									<span class="toggle-indicator"></span></button>
1012
-								<span class="give-remove" title="<?php esc_html_e( 'Remove Group', 'give' ); ?>">-
1012
+								<span class="give-remove" title="<?php esc_html_e('Remove Group', 'give'); ?>">-
1013 1013
 								</span>
1014 1014
 								<h2>
1015 1015
 									<span data-header-title="<?php echo $header_title; ?>"><?php echo $header_title; ?></span>
1016 1016
 								</h2>
1017 1017
 							</div>
1018 1018
 							<div class="give-row-body">
1019
-								<?php foreach ( $fields['fields'] as $field ) : ?>
1020
-									<?php if ( ! give_is_field_callback_exist( $field ) ) {
1019
+								<?php foreach ($fields['fields'] as $field) : ?>
1020
+									<?php if ( ! give_is_field_callback_exist($field)) {
1021 1021
 										continue;
1022 1022
 } ?>
1023 1023
 									<?php
1024 1024
 									$field['repeat']              = true;
1025
-									$field['repeatable_field_id'] = give_get_repeater_field_id( $field, $fields, $index );
1026
-									$field['attributes']['value'] = give_get_repeater_field_value( $field, $field_group, $fields );
1027
-									$field['id']                  = str_replace( array( '[', ']' ), array(
1025
+									$field['repeatable_field_id'] = give_get_repeater_field_id($field, $fields, $index);
1026
+									$field['attributes']['value'] = give_get_repeater_field_value($field, $field_group, $fields);
1027
+									$field['id']                  = str_replace(array('[', ']'), array(
1028 1028
 										'_',
1029 1029
 										'',
1030
-									), $field['repeatable_field_id'] );
1030
+									), $field['repeatable_field_id']);
1031 1031
 									?>
1032
-									<?php give_render_field( $field ); ?>
1032
+									<?php give_render_field($field); ?>
1033 1033
 								<?php endforeach; ?>
1034 1034
 							</div>
1035 1035
 						</td>
@@ -1037,14 +1037,14 @@  discard block
 block discarded – undo
1037 1037
 				<?php endforeach;
1038 1038
 ; ?>
1039 1039
 
1040
-			<?php elseif ( $add_default_donation_field ) : ?>
1040
+			<?php elseif ($add_default_donation_field) : ?>
1041 1041
 				<!--Default repeater field group-->
1042 1042
 				<tr class="give-row">
1043 1043
 					<td class="give-repeater-field-wrap give-column" colspan="2">
1044 1044
 						<div class="give-row-head give-move">
1045 1045
 							<button type="button" class="handlediv button-link">
1046 1046
 								<span class="toggle-indicator"></span></button>
1047
-							<span class="give-remove" title="<?php esc_html_e( 'Remove Group', 'give' ); ?>">-
1047
+							<span class="give-remove" title="<?php esc_html_e('Remove Group', 'give'); ?>">-
1048 1048
 							</span>
1049 1049
 							<h2>
1050 1050
 								<span data-header-title="<?php echo $header_title; ?>"><?php echo $header_title; ?></span>
@@ -1052,19 +1052,19 @@  discard block
 block discarded – undo
1052 1052
 						</div>
1053 1053
 						<div class="give-row-body">
1054 1054
 							<?php
1055
-							foreach ( $fields['fields'] as $field ) :
1056
-								if ( ! give_is_field_callback_exist( $field ) ) {
1055
+							foreach ($fields['fields'] as $field) :
1056
+								if ( ! give_is_field_callback_exist($field)) {
1057 1057
 									continue;
1058 1058
 								}
1059 1059
 
1060 1060
 								$field['repeat']              = true;
1061
-								$field['repeatable_field_id'] = give_get_repeater_field_id( $field, $fields, 0 );
1062
-								$field['attributes']['value'] = apply_filters( "give_default_field_group_field_{$field['id']}_value", ( ! empty( $field['default'] ) ? $field['default'] : '' ), $field );
1063
-								$field['id']                  = str_replace( array( '[', ']' ), array(
1061
+								$field['repeatable_field_id'] = give_get_repeater_field_id($field, $fields, 0);
1062
+								$field['attributes']['value'] = apply_filters("give_default_field_group_field_{$field['id']}_value", ( ! empty($field['default']) ? $field['default'] : ''), $field);
1063
+								$field['id']                  = str_replace(array('[', ']'), array(
1064 1064
 									'_',
1065 1065
 									'',
1066
-								), $field['repeatable_field_id'] );
1067
-								give_render_field( $field );
1066
+								), $field['repeatable_field_id']);
1067
+								give_render_field($field);
1068 1068
 							endforeach;
1069 1069
 							?>
1070 1070
 						</div>
@@ -1075,9 +1075,9 @@  discard block
 block discarded – undo
1075 1075
 			<tfoot>
1076 1076
 			<tr>
1077 1077
 				<?php
1078
-				$add_row_btn_title = isset( $fields['options']['add_button'] )
1078
+				$add_row_btn_title = isset($fields['options']['add_button'])
1079 1079
 					? $add_row_btn_title = $fields['options']['add_button']
1080
-					: esc_html__( 'Add Row', 'give' );
1080
+					: esc_html__('Add Row', 'give');
1081 1081
 				?>
1082 1082
 				<td colspan="2" class="give-add-repeater-field-section-row-wrap">
1083 1083
 					<span class="button button-primary give-add-repeater-field-section-row"><?php echo $add_row_btn_title; ?></span>
@@ -1107,10 +1107,10 @@  discard block
 block discarded – undo
1107 1107
 	 *
1108 1108
 	 * @param string
1109 1109
 	 */
1110
-	$default_current_tab = apply_filters( "give_default_setting_tab_{$current_setting_page}", 'general' );
1110
+	$default_current_tab = apply_filters("give_default_setting_tab_{$current_setting_page}", 'general');
1111 1111
 
1112 1112
 	// Get current tab.
1113
-	$current_tab = empty( $_GET['tab'] ) ? $default_current_tab : urldecode( $_GET['tab'] );
1113
+	$current_tab = empty($_GET['tab']) ? $default_current_tab : urldecode($_GET['tab']);
1114 1114
 
1115 1115
 	// Output.
1116 1116
 	return $current_tab;
@@ -1134,10 +1134,10 @@  discard block
 block discarded – undo
1134 1134
 	 *
1135 1135
 	 * @param string
1136 1136
 	 */
1137
-	$default_current_section = apply_filters( "give_default_setting_tab_section_{$current_tab}", '' );
1137
+	$default_current_section = apply_filters("give_default_setting_tab_section_{$current_tab}", '');
1138 1138
 
1139 1139
 	// Get current section.
1140
-	$current_section = empty( $_REQUEST['section'] ) ? $default_current_section : urldecode( $_REQUEST['section'] );
1140
+	$current_section = empty($_REQUEST['section']) ? $default_current_section : urldecode($_REQUEST['section']);
1141 1141
 
1142 1142
 	// Output.
1143 1143
 	return $current_section;
@@ -1151,7 +1151,7 @@  discard block
 block discarded – undo
1151 1151
  */
1152 1152
 function give_get_current_setting_page() {
1153 1153
 	// Get current page.
1154
-	$setting_page = ! empty( $_GET['page'] ) ? urldecode( $_GET['page'] ) : '';
1154
+	$setting_page = ! empty($_GET['page']) ? urldecode($_GET['page']) : '';
1155 1155
 
1156 1156
 	// Output.
1157 1157
 	return $setting_page;
@@ -1171,13 +1171,13 @@  discard block
 block discarded – undo
1171 1171
  *
1172 1172
  * @return string
1173 1173
  */
1174
-function _give_display_content_field_value( $field_value, $field, $postid ) {
1175
-	$show_content = give_get_meta( $postid, '_give_content_option', true );
1174
+function _give_display_content_field_value($field_value, $field, $postid) {
1175
+	$show_content = give_get_meta($postid, '_give_content_option', true);
1176 1176
 
1177 1177
 	if (
1178
-		! give_get_meta( $postid, '_give_display_content', true )
1178
+		! give_get_meta($postid, '_give_display_content', true)
1179 1179
 		&& $show_content
1180
-		&& ( 'none' !== $show_content )
1180
+		&& ('none' !== $show_content)
1181 1181
 	) {
1182 1182
 		$field_value = 'enabled';
1183 1183
 	}
@@ -1185,7 +1185,7 @@  discard block
 block discarded – undo
1185 1185
 	return $field_value;
1186 1186
 }
1187 1187
 
1188
-add_filter( '_give_display_content_field_value', '_give_display_content_field_value', 10, 3 );
1188
+add_filter('_give_display_content_field_value', '_give_display_content_field_value', 10, 3);
1189 1189
 
1190 1190
 
1191 1191
 /**
@@ -1202,12 +1202,12 @@  discard block
 block discarded – undo
1202 1202
  *
1203 1203
  * @return string
1204 1204
  */
1205
-function _give_content_placement_field_value( $field_value, $field, $postid ) {
1206
-	$show_content = give_get_meta( $postid, '_give_content_option', true );
1205
+function _give_content_placement_field_value($field_value, $field, $postid) {
1206
+	$show_content = give_get_meta($postid, '_give_content_option', true);
1207 1207
 
1208 1208
 	if (
1209
-		! give_get_meta( $postid, '_give_content_placement', true )
1210
-		&& ( 'none' !== $show_content )
1209
+		! give_get_meta($postid, '_give_content_placement', true)
1210
+		&& ('none' !== $show_content)
1211 1211
 	) {
1212 1212
 		$field_value = $show_content;
1213 1213
 	}
@@ -1215,7 +1215,7 @@  discard block
 block discarded – undo
1215 1215
 	return $field_value;
1216 1216
 }
1217 1217
 
1218
-add_filter( '_give_content_placement_field_value', '_give_content_placement_field_value', 10, 3 );
1218
+add_filter('_give_content_placement_field_value', '_give_content_placement_field_value', 10, 3);
1219 1219
 
1220 1220
 
1221 1221
 /**
@@ -1231,17 +1231,17 @@  discard block
 block discarded – undo
1231 1231
  *
1232 1232
  * @return string
1233 1233
  */
1234
-function _give_terms_option_field_value( $field_value, $field, $postid ) {
1235
-	$term_option = give_get_meta( $postid, '_give_terms_option', true );
1234
+function _give_terms_option_field_value($field_value, $field, $postid) {
1235
+	$term_option = give_get_meta($postid, '_give_terms_option', true);
1236 1236
 
1237
-	if ( in_array( $term_option, array( 'none', 'yes' ) ) ) {
1238
-		$field_value = ( 'yes' === $term_option ? 'enabled' : 'disabled' );
1237
+	if (in_array($term_option, array('none', 'yes'))) {
1238
+		$field_value = ('yes' === $term_option ? 'enabled' : 'disabled');
1239 1239
 	}
1240 1240
 
1241 1241
 	return $field_value;
1242 1242
 }
1243 1243
 
1244
-add_filter( '_give_terms_option_field_value', '_give_terms_option_field_value', 10, 3 );
1244
+add_filter('_give_terms_option_field_value', '_give_terms_option_field_value', 10, 3);
1245 1245
 
1246 1246
 
1247 1247
 /**
@@ -1258,17 +1258,17 @@  discard block
 block discarded – undo
1258 1258
  *
1259 1259
  * @return string
1260 1260
  */
1261
-function _give_offline_donation_enable_billing_fields_single_field_value( $field_value, $field, $postid ) {
1262
-	$offline_donation = give_get_meta( $postid, '_give_offline_donation_enable_billing_fields_single', true );
1261
+function _give_offline_donation_enable_billing_fields_single_field_value($field_value, $field, $postid) {
1262
+	$offline_donation = give_get_meta($postid, '_give_offline_donation_enable_billing_fields_single', true);
1263 1263
 
1264
-	if ( 'on' === $offline_donation ) {
1264
+	if ('on' === $offline_donation) {
1265 1265
 		$field_value = 'enabled';
1266 1266
 	}
1267 1267
 
1268 1268
 	return $field_value;
1269 1269
 }
1270 1270
 
1271
-add_filter( '_give_offline_donation_enable_billing_fields_single_field_value', '_give_offline_donation_enable_billing_fields_single_field_value', 10, 3 );
1271
+add_filter('_give_offline_donation_enable_billing_fields_single_field_value', '_give_offline_donation_enable_billing_fields_single_field_value', 10, 3);
1272 1272
 
1273 1273
 
1274 1274
 /**
@@ -1284,17 +1284,17 @@  discard block
 block discarded – undo
1284 1284
  *
1285 1285
  * @return string
1286 1286
  */
1287
-function _give_custom_amount_field_value( $field_value, $field, $postid ) {
1288
-	$custom_amount = give_get_meta( $postid, '_give_custom_amount', true );
1287
+function _give_custom_amount_field_value($field_value, $field, $postid) {
1288
+	$custom_amount = give_get_meta($postid, '_give_custom_amount', true);
1289 1289
 
1290
-	if ( in_array( $custom_amount, array( 'yes', 'no' ) ) ) {
1291
-		$field_value = ( 'yes' === $custom_amount ? 'enabled' : 'disabled' );
1290
+	if (in_array($custom_amount, array('yes', 'no'))) {
1291
+		$field_value = ('yes' === $custom_amount ? 'enabled' : 'disabled');
1292 1292
 	}
1293 1293
 
1294 1294
 	return $field_value;
1295 1295
 }
1296 1296
 
1297
-add_filter( '_give_custom_amount_field_value', '_give_custom_amount_field_value', 10, 3 );
1297
+add_filter('_give_custom_amount_field_value', '_give_custom_amount_field_value', 10, 3);
1298 1298
 
1299 1299
 
1300 1300
 /**
@@ -1310,17 +1310,17 @@  discard block
 block discarded – undo
1310 1310
  *
1311 1311
  * @return string
1312 1312
  */
1313
-function _give_goal_option_field_value( $field_value, $field, $postid ) {
1314
-	$goal_option = give_get_meta( $postid, '_give_goal_option', true );
1313
+function _give_goal_option_field_value($field_value, $field, $postid) {
1314
+	$goal_option = give_get_meta($postid, '_give_goal_option', true);
1315 1315
 
1316
-	if ( in_array( $goal_option, array( 'yes', 'no' ) ) ) {
1317
-		$field_value = ( 'yes' === $goal_option ? 'enabled' : 'disabled' );
1316
+	if (in_array($goal_option, array('yes', 'no'))) {
1317
+		$field_value = ('yes' === $goal_option ? 'enabled' : 'disabled');
1318 1318
 	}
1319 1319
 
1320 1320
 	return $field_value;
1321 1321
 }
1322 1322
 
1323
-add_filter( '_give_goal_option_field_value', '_give_goal_option_field_value', 10, 3 );
1323
+add_filter('_give_goal_option_field_value', '_give_goal_option_field_value', 10, 3);
1324 1324
 
1325 1325
 /**
1326 1326
  * Set value for Donation Goal --> close Form.
@@ -1336,17 +1336,17 @@  discard block
 block discarded – undo
1336 1336
  *
1337 1337
  * @return string
1338 1338
  */
1339
-function _give_close_form_when_goal_achieved_value( $field_value, $field, $postid ) {
1340
-	$close_form = give_get_meta( $postid, '_give_close_form_when_goal_achieved', true );
1339
+function _give_close_form_when_goal_achieved_value($field_value, $field, $postid) {
1340
+	$close_form = give_get_meta($postid, '_give_close_form_when_goal_achieved', true);
1341 1341
 
1342
-	if ( in_array( $close_form, array( 'yes', 'no' ) ) ) {
1343
-		$field_value = ( 'yes' === $close_form ? 'enabled' : 'disabled' );
1342
+	if (in_array($close_form, array('yes', 'no'))) {
1343
+		$field_value = ('yes' === $close_form ? 'enabled' : 'disabled');
1344 1344
 	}
1345 1345
 
1346 1346
 	return $field_value;
1347 1347
 }
1348 1348
 
1349
-add_filter( '_give_close_form_when_goal_achieved_field_value', '_give_close_form_when_goal_achieved_value', 10, 3 );
1349
+add_filter('_give_close_form_when_goal_achieved_field_value', '_give_close_form_when_goal_achieved_value', 10, 3);
1350 1350
 
1351 1351
 
1352 1352
 /**
@@ -1362,17 +1362,17 @@  discard block
 block discarded – undo
1362 1362
  *
1363 1363
  * @return string
1364 1364
  */
1365
-function _give_logged_in_only_value( $field_value, $field, $postid ) {
1366
-	$guest_donation = give_get_meta( $postid, '_give_logged_in_only', true );
1365
+function _give_logged_in_only_value($field_value, $field, $postid) {
1366
+	$guest_donation = give_get_meta($postid, '_give_logged_in_only', true);
1367 1367
 
1368
-	if ( in_array( $guest_donation, array( 'yes', 'no' ) ) ) {
1369
-		$field_value = ( 'yes' === $guest_donation ? 'enabled' : 'disabled' );
1368
+	if (in_array($guest_donation, array('yes', 'no'))) {
1369
+		$field_value = ('yes' === $guest_donation ? 'enabled' : 'disabled');
1370 1370
 	}
1371 1371
 
1372 1372
 	return $field_value;
1373 1373
 }
1374 1374
 
1375
-add_filter( '_give_logged_in_only_field_value', '_give_logged_in_only_value', 10, 3 );
1375
+add_filter('_give_logged_in_only_field_value', '_give_logged_in_only_value', 10, 3);
1376 1376
 
1377 1377
 /**
1378 1378
  * Set value for Offline Donations --> Offline Donations.
@@ -1388,17 +1388,17 @@  discard block
 block discarded – undo
1388 1388
  *
1389 1389
  * @return string
1390 1390
  */
1391
-function _give_customize_offline_donations_value( $field_value, $field, $postid ) {
1392
-	$customize_offline_text = give_get_meta( $postid, '_give_customize_offline_donations', true );
1391
+function _give_customize_offline_donations_value($field_value, $field, $postid) {
1392
+	$customize_offline_text = give_get_meta($postid, '_give_customize_offline_donations', true);
1393 1393
 
1394
-	if ( in_array( $customize_offline_text, array( 'yes', 'no' ) ) ) {
1395
-		$field_value = ( 'yes' === $customize_offline_text ? 'enabled' : 'disabled' );
1394
+	if (in_array($customize_offline_text, array('yes', 'no'))) {
1395
+		$field_value = ('yes' === $customize_offline_text ? 'enabled' : 'disabled');
1396 1396
 	}
1397 1397
 
1398 1398
 	return $field_value;
1399 1399
 }
1400 1400
 
1401
-add_filter( '_give_customize_offline_donations_field_value', '_give_customize_offline_donations_value', 10, 3 );
1401
+add_filter('_give_customize_offline_donations_field_value', '_give_customize_offline_donations_value', 10, 3);
1402 1402
 
1403 1403
 
1404 1404
 /**
@@ -1413,14 +1413,14 @@  discard block
 block discarded – undo
1413 1413
  *
1414 1414
  * @return mixed
1415 1415
  */
1416
-function _give_set_multi_level_repeater_field_id( $field_id, $field, $fields, $default ) {
1416
+function _give_set_multi_level_repeater_field_id($field_id, $field, $fields, $default) {
1417 1417
 	$row_placeholder = false !== $default ? $default : '{{row-count-placeholder}}';
1418 1418
 	$field_id        = "{$fields['id']}[{$row_placeholder}][{$field['id']}][level_id]";
1419 1419
 
1420 1420
 	return $field_id;
1421 1421
 }
1422 1422
 
1423
-add_filter( 'give_get_repeater_field__give_id_id', '_give_set_multi_level_repeater_field_id', 10, 4 );
1423
+add_filter('give_get_repeater_field__give_id_id', '_give_set_multi_level_repeater_field_id', 10, 4);
1424 1424
 
1425 1425
 /**
1426 1426
  * Set repeater field value for multi donation form.
@@ -1434,13 +1434,13 @@  discard block
 block discarded – undo
1434 1434
  *
1435 1435
  * @return mixed
1436 1436
  */
1437
-function _give_set_multi_level_repeater_field_value( $field_value, $field, $field_group, $fields ) {
1438
-	$field_value = $field_group[ $field['id'] ]['level_id'];
1437
+function _give_set_multi_level_repeater_field_value($field_value, $field, $field_group, $fields) {
1438
+	$field_value = $field_group[$field['id']]['level_id'];
1439 1439
 
1440 1440
 	return $field_value;
1441 1441
 }
1442 1442
 
1443
-add_filter( 'give_get_repeater_field__give_id_value', '_give_set_multi_level_repeater_field_value', 10, 4 );
1443
+add_filter('give_get_repeater_field__give_id_value', '_give_set_multi_level_repeater_field_value', 10, 4);
1444 1444
 
1445 1445
 /**
1446 1446
  * Set default value for _give_id field.
@@ -1451,11 +1451,11 @@  discard block
 block discarded – undo
1451 1451
  *
1452 1452
  * @return string
1453 1453
  */
1454
-function _give_set_field_give_id_default_value( $field ) {
1454
+function _give_set_field_give_id_default_value($field) {
1455 1455
 	return 0;
1456 1456
 }
1457 1457
 
1458
-add_filter( 'give_default_field_group_field__give_id_value', '_give_set_field_give_id_default_value' );
1458
+add_filter('give_default_field_group_field__give_id_value', '_give_set_field_give_id_default_value');
1459 1459
 
1460 1460
 /**
1461 1461
  * Set default value for _give_default field.
@@ -1466,11 +1466,11 @@  discard block
 block discarded – undo
1466 1466
  *
1467 1467
  * @return string
1468 1468
  */
1469
-function _give_set_field_give_default_default_value( $field ) {
1469
+function _give_set_field_give_default_default_value($field) {
1470 1470
 	return 'default';
1471 1471
 }
1472 1472
 
1473
-add_filter( 'give_default_field_group_field__give_default_value', '_give_set_field_give_default_default_value' );
1473
+add_filter('give_default_field_group_field__give_default_value', '_give_set_field_give_default_default_value');
1474 1474
 
1475 1475
 /**
1476 1476
  * Set repeater field editor id for field type wysiwyg.
@@ -1482,12 +1482,12 @@  discard block
 block discarded – undo
1482 1482
  *
1483 1483
  * @return string
1484 1484
  */
1485
-function give_repeater_field_set_editor_id( $field_name, $field ) {
1486
-	if ( isset( $field['repeatable_field_id'] ) && 'wysiwyg' == $field['type'] ) {
1487
-		$field_name = '_give_repeater_' . uniqid() . '_wysiwyg';
1485
+function give_repeater_field_set_editor_id($field_name, $field) {
1486
+	if (isset($field['repeatable_field_id']) && 'wysiwyg' == $field['type']) {
1487
+		$field_name = '_give_repeater_'.uniqid().'_wysiwyg';
1488 1488
 	}
1489 1489
 
1490 1490
 	return $field_name;
1491 1491
 }
1492 1492
 
1493
-add_filter( 'give_get_field_name', 'give_repeater_field_set_editor_id', 10, 2 );
1493
+add_filter('give_get_field_name', 'give_repeater_field_set_editor_id', 10, 2);
Please login to merge, or discard this patch.