Test Failed
Pull Request — master (#2668)
by Devin
07:48
created
includes/actions.php 1 patch
Spacing   +71 added lines, -71 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,14 +58,14 @@  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
 	// Add backward compatibility to give-action param ( $_POST ).
64
-	if ( empty( $_post_action ) ) {
65
-		$_post_action = ! empty( $_POST['give-action'] ) ? $_POST['give-action'] : null;
64
+	if (empty($_post_action)) {
65
+		$_post_action = ! empty($_POST['give-action']) ? $_POST['give-action'] : null;
66 66
 	}
67 67
 
68
-	if ( isset( $_post_action ) ) {
68
+	if (isset($_post_action)) {
69 69
 		/**
70 70
 		 * Fires in WordPress init or admin init, when give_action is present in $_POST.
71 71
 		 *
@@ -73,12 +73,12 @@  discard block
 block discarded – undo
73 73
 		 *
74 74
 		 * @param array $_POST Array of HTTP POST variables.
75 75
 		 */
76
-		do_action( "give_{$_post_action}", $_POST );
76
+		do_action("give_{$_post_action}", $_POST);
77 77
 	}
78 78
 
79 79
 }
80 80
 
81
-add_action( 'init', 'give_post_actions' );
81
+add_action('init', 'give_post_actions');
82 82
 
83 83
 /**
84 84
  * Connect WordPress user with Donor.
@@ -90,17 +90,17 @@  discard block
 block discarded – undo
90 90
  *
91 91
  * @return void
92 92
  */
93
-function give_connect_donor_to_wpuser( $user_id, $user_data ) {
93
+function give_connect_donor_to_wpuser($user_id, $user_data) {
94 94
 	/* @var Give_Donor $donor */
95
-	$donor = new Give_Donor( $user_data['user_email'] );
95
+	$donor = new Give_Donor($user_data['user_email']);
96 96
 
97 97
 	// Validate donor id and check if do nor is already connect to wp user or not.
98
-	if ( $donor->id && ! $donor->user_id ) {
98
+	if ($donor->id && ! $donor->user_id) {
99 99
 
100 100
 		// Update donor user_id.
101
-		if ( $donor->update( array( 'user_id' => $user_id ) ) ) {
102
-			$donor_note = sprintf( esc_html__( 'WordPress user #%d is connected to #%d', 'give' ), $user_id, $donor->id );
103
-			$donor->add_note( $donor_note );
101
+		if ($donor->update(array('user_id' => $user_id))) {
102
+			$donor_note = sprintf(esc_html__('WordPress user #%d is connected to #%d', 'give'), $user_id, $donor->id);
103
+			$donor->add_note($donor_note);
104 104
 
105 105
 			// Update user_id meta in payments.
106 106
 			// if( ! empty( $donor->payment_ids ) && ( $donations = explode( ',', $donor->payment_ids ) ) ) {
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	}
114 114
 }
115 115
 
116
-add_action( 'give_insert_user', 'give_connect_donor_to_wpuser', 10, 2 );
116
+add_action('give_insert_user', 'give_connect_donor_to_wpuser', 10, 2);
117 117
 
118 118
 
119 119
 /**
@@ -127,45 +127,45 @@  discard block
 block discarded – undo
127 127
  */
128 128
 function give_validate_license_when_site_migrated() {
129 129
 	// Store current site address if not already stored.
130
-	$home_url_parts              = parse_url( home_url() );
131
-	$home_url                    = isset( $home_url_parts['host'] ) ? $home_url_parts['host'] : false;
132
-	$home_url                    .= isset( $home_url_parts['path'] ) ? $home_url_parts['path'] : '';
133
-	$site_address_before_migrate = get_option( 'give_site_address_before_migrate' );
130
+	$home_url_parts              = parse_url(home_url());
131
+	$home_url                    = isset($home_url_parts['host']) ? $home_url_parts['host'] : false;
132
+	$home_url .= isset($home_url_parts['path']) ? $home_url_parts['path'] : '';
133
+	$site_address_before_migrate = get_option('give_site_address_before_migrate');
134 134
 
135 135
 	// Need $home_url to proceed.
136
-	if ( ! $home_url ) {
136
+	if ( ! $home_url) {
137 137
 		return;
138 138
 	}
139 139
 
140 140
 	// Save site address.
141
-	if ( ! $site_address_before_migrate ) {
141
+	if ( ! $site_address_before_migrate) {
142 142
 		// Update site address.
143
-		update_option( 'give_site_address_before_migrate', $home_url );
143
+		update_option('give_site_address_before_migrate', $home_url);
144 144
 
145 145
 		return;
146 146
 	}
147 147
 
148 148
 	// Backwards compat. for before when we were storing URL scheme.
149
-	if ( strpos( $site_address_before_migrate, 'http' ) ) {
150
-		$site_address_before_migrate = parse_url( $site_address_before_migrate );
151
-		$site_address_before_migrate = isset( $site_address_before_migrate['host'] ) ? $site_address_before_migrate['host'] : false;
149
+	if (strpos($site_address_before_migrate, 'http')) {
150
+		$site_address_before_migrate = parse_url($site_address_before_migrate);
151
+		$site_address_before_migrate = isset($site_address_before_migrate['host']) ? $site_address_before_migrate['host'] : false;
152 152
 
153 153
 		// Add path for multisite installs.
154
-		$site_address_before_migrate .= isset( $site_address_before_migrate['path'] ) ? $site_address_before_migrate['path'] : '';
154
+		$site_address_before_migrate .= isset($site_address_before_migrate['path']) ? $site_address_before_migrate['path'] : '';
155 155
 	}
156 156
 
157 157
 	// If the two URLs don't match run CRON.
158
-	if ( $home_url !== $site_address_before_migrate ) {
158
+	if ($home_url !== $site_address_before_migrate) {
159 159
 		// Immediately run cron.
160
-		wp_schedule_single_event( time(), 'give_validate_license_when_site_migrated' );
160
+		wp_schedule_single_event(time(), 'give_validate_license_when_site_migrated');
161 161
 
162 162
 		// Update site address.
163
-		update_option( 'give_site_address_before_migrate', $home_url );
163
+		update_option('give_site_address_before_migrate', $home_url);
164 164
 	}
165 165
 
166 166
 }
167 167
 
168
-add_action( 'admin_init', 'give_validate_license_when_site_migrated' );
168
+add_action('admin_init', 'give_validate_license_when_site_migrated');
169 169
 
170 170
 
171 171
 /**
@@ -175,19 +175,19 @@  discard block
 block discarded – undo
175 175
  *
176 176
  * @param $data
177 177
  */
178
-function give_donor_batch_export_complete( $data ) {
178
+function give_donor_batch_export_complete($data) {
179 179
 	// Remove donor ids cache.
180 180
 	if (
181
-		isset( $data['class'] )
181
+		isset($data['class'])
182 182
 		&& 'Give_Batch_Donors_Export' === $data['class']
183
-		&& ! empty( $data['forms'] )
184
-		&& isset( $data['give_export_option']['query_id'] )
183
+		&& ! empty($data['forms'])
184
+		&& isset($data['give_export_option']['query_id'])
185 185
 	) {
186
-		Give_Cache::delete( Give_Cache::get_key( $data['give_export_option']['query_id'] ) );
186
+		Give_Cache::delete(Give_Cache::get_key($data['give_export_option']['query_id']));
187 187
 	}
188 188
 }
189 189
 
190
-add_action( 'give_file_export_complete', 'give_donor_batch_export_complete' );
190
+add_action('give_file_export_complete', 'give_donor_batch_export_complete');
191 191
 
192 192
 /**
193 193
  * Print css for wordpress setting pages.
@@ -198,12 +198,12 @@  discard block
 block discarded – undo
198 198
 	/* @var WP_Screen $screen */
199 199
 	$screen = get_current_screen();
200 200
 
201
-	if ( ! ( $screen instanceof WP_Screen ) ) {
201
+	if ( ! ($screen instanceof WP_Screen)) {
202 202
 		return false;
203 203
 	}
204 204
 
205
-	switch ( true ) {
206
-		case ( 'plugins' === $screen->base || 'plugins-network' === $screen->base ):
205
+	switch (true) {
206
+		case ('plugins' === $screen->base || 'plugins-network' === $screen->base):
207 207
 			?>
208 208
 			<style>
209 209
 				tr.active.update + tr.give-addon-notice-tr td {
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 	}
241 241
 }
242 242
 
243
-add_action( 'admin_head', 'give_admin_quick_css' );
243
+add_action('admin_head', 'give_admin_quick_css');
244 244
 
245 245
 
246 246
 /**
@@ -252,31 +252,31 @@  discard block
 block discarded – undo
252 252
  *
253 253
  * @return void
254 254
  */
255
-function give_set_donation_levels_max_min_amount( $form_id ) {
255
+function give_set_donation_levels_max_min_amount($form_id) {
256 256
 	if (
257
-		( 'set' === $_POST['_give_price_option'] ) ||
258
-		( in_array( '_give_donation_levels', $_POST ) && count( $_POST['_give_donation_levels'] ) <= 0 ) ||
259
-		! ( $donation_levels_amounts = wp_list_pluck( $_POST['_give_donation_levels'], '_give_amount' ) )
257
+		('set' === $_POST['_give_price_option']) ||
258
+		(in_array('_give_donation_levels', $_POST) && count($_POST['_give_donation_levels']) <= 0) ||
259
+		! ($donation_levels_amounts = wp_list_pluck($_POST['_give_donation_levels'], '_give_amount'))
260 260
 	) {
261 261
 		// Delete old meta.
262
-		give_delete_meta( $form_id, '_give_levels_minimum_amount' );
263
-		give_delete_meta( $form_id, '_give_levels_maximum_amount' );
262
+		give_delete_meta($form_id, '_give_levels_minimum_amount');
263
+		give_delete_meta($form_id, '_give_levels_maximum_amount');
264 264
 
265 265
 		return;
266 266
 	}
267 267
 
268 268
 	// Sanitize donation level amounts.
269
-	$donation_levels_amounts = array_map( 'give_maybe_sanitize_amount', $donation_levels_amounts );
269
+	$donation_levels_amounts = array_map('give_maybe_sanitize_amount', $donation_levels_amounts);
270 270
 
271
-	$min_amount = min( $donation_levels_amounts );
272
-	$max_amount = max( $donation_levels_amounts );
271
+	$min_amount = min($donation_levels_amounts);
272
+	$max_amount = max($donation_levels_amounts);
273 273
 
274 274
 	// Set Minimum and Maximum amount for Multi Level Donation Forms.
275
-	give_update_meta( $form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount_for_db( $min_amount ) : 0 );
276
-	give_update_meta( $form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount_for_db( $max_amount ) : 0 );
275
+	give_update_meta($form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount_for_db($min_amount) : 0);
276
+	give_update_meta($form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount_for_db($max_amount) : 0);
277 277
 }
278 278
 
279
-add_action( 'give_pre_process_give_forms_meta', 'give_set_donation_levels_max_min_amount', 30 );
279
+add_action('give_pre_process_give_forms_meta', 'give_set_donation_levels_max_min_amount', 30);
280 280
 
281 281
 
282 282
 /**
@@ -286,24 +286,24 @@  discard block
 block discarded – undo
286 286
  *
287 287
  * @param int $payment_id
288 288
  */
289
-function _give_save_donor_billing_address( $payment_id ) {
289
+function _give_save_donor_billing_address($payment_id) {
290 290
 	/* @var Give_Payment $donation */
291
-	$donation = new Give_Payment( $payment_id );
291
+	$donation = new Give_Payment($payment_id);
292 292
 
293 293
 	// Bailout
294
-	if ( ! $donation->customer_id ) {
294
+	if ( ! $donation->customer_id) {
295 295
 		return;
296 296
 	}
297 297
 
298 298
 
299 299
 	/* @var Give_Donor $donor */
300
-	$donor = new Give_Donor( $donation->customer_id );
300
+	$donor = new Give_Donor($donation->customer_id);
301 301
 
302 302
 	// Save address.
303
-	$donor->add_address( 'billing[]', $donation->address );
303
+	$donor->add_address('billing[]', $donation->address);
304 304
 }
305 305
 
306
-add_action( 'give_complete_donation', '_give_save_donor_billing_address', 9999 );
306
+add_action('give_complete_donation', '_give_save_donor_billing_address', 9999);
307 307
 
308 308
 
309 309
 /**
@@ -313,25 +313,25 @@  discard block
 block discarded – undo
313 313
  *
314 314
  * @param array $args
315 315
  */
316
-function give_update_log_form_id( $args ) {
317
-	$new_form_id = absint( $args[0] );
318
-	$payment_id  = absint( $args[1] );
319
-	$logs        = Give()->logs->get_logs( $payment_id );
316
+function give_update_log_form_id($args) {
317
+	$new_form_id = absint($args[0]);
318
+	$payment_id  = absint($args[1]);
319
+	$logs        = Give()->logs->get_logs($payment_id);
320 320
 
321 321
 	// Bailout.
322
-	if ( empty( $logs ) ) {
322
+	if (empty($logs)) {
323 323
 		return;
324 324
 	}
325 325
 
326 326
 	/* @var object $log */
327
-	foreach ( $logs as $log ) {
328
-		Give()->logs->logmeta_db->update_meta( $log->ID, '_give_log_form_id', $new_form_id );
327
+	foreach ($logs as $log) {
328
+		Give()->logs->logmeta_db->update_meta($log->ID, '_give_log_form_id', $new_form_id);
329 329
 	}
330 330
 
331 331
 	// Delete cache.
332 332
 	Give()->logs->delete_cache();
333 333
 }
334 334
 
335
-add_action( 'give_update_log_form_id', 'give_update_log_form_id' );
335
+add_action('give_update_log_form_id', 'give_update_log_form_id');
336 336
 
337 337
 
Please login to merge, or discard this patch.
includes/class-give-db-logs-meta.php 1 patch
Spacing   +10 added lines, -10 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
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 		/* @var WPDB $wpdb */
51 51
 		global $wpdb;
52 52
 
53
-		$wpdb->logmeta     = $this->table_name = $wpdb->prefix . 'give_logmeta';
53
+		$wpdb->logmeta     = $this->table_name = $wpdb->prefix.'give_logmeta';
54 54
 		$this->primary_key = 'meta_id';
55 55
 		$this->version     = '1.0';
56 56
 
@@ -86,18 +86,18 @@  discard block
 block discarded – undo
86 86
 	 *
87 87
 	 * @return bool
88 88
 	 */
89
-	public function delete_row( $log_id = 0 ) {
89
+	public function delete_row($log_id = 0) {
90 90
 		/* @var WPDB $wpdb */
91 91
 		global $wpdb;
92 92
 
93 93
 		// Row ID must be positive integer
94
-		$log_id = absint( $log_id );
94
+		$log_id = absint($log_id);
95 95
 
96
-		if ( empty( $log_id ) ) {
96
+		if (empty($log_id)) {
97 97
 			return false;
98 98
 		}
99 99
 
100
-		if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE log_id = %d", $log_id ) ) ) {
100
+		if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE log_id = %d", $log_id))) {
101 101
 			return false;
102 102
 		}
103 103
 
@@ -126,10 +126,10 @@  discard block
 block discarded – undo
126 126
 			KEY meta_key (meta_key)
127 127
 			) {$charset_collate};";
128 128
 
129
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
130
-		dbDelta( $sql );
129
+		require_once(ABSPATH.'wp-admin/includes/upgrade.php');
130
+		dbDelta($sql);
131 131
 
132
-		update_option( $this->table_name . '_db_version', $this->version );
132
+		update_option($this->table_name.'_db_version', $this->version);
133 133
 	}
134 134
 
135 135
 	/**
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	 *
143 143
 	 * @return bool
144 144
 	 */
145
-	protected function is_valid_post_type( $ID ) {
145
+	protected function is_valid_post_type($ID) {
146 146
 		return $ID && true;
147 147
 	}
148 148
 }
Please login to merge, or discard this patch.
includes/misc-functions.php 1 patch
Spacing   +309 added lines, -309 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
 
@@ -39,18 +39,18 @@  discard block
 block discarded – undo
39 39
 
40 40
 	global $wp;
41 41
 
42
-	if ( get_option( 'permalink_structure' ) ) {
43
-		$base = trailingslashit( home_url( $wp->request ) );
42
+	if (get_option('permalink_structure')) {
43
+		$base = trailingslashit(home_url($wp->request));
44 44
 	} else {
45
-		$base = add_query_arg( $wp->query_string, '', trailingslashit( home_url( $wp->request ) ) );
46
-		$base = remove_query_arg( array( 'post_type', 'name' ), $base );
45
+		$base = add_query_arg($wp->query_string, '', trailingslashit(home_url($wp->request)));
46
+		$base = remove_query_arg(array('post_type', 'name'), $base);
47 47
 	}
48 48
 
49 49
 	$scheme      = is_ssl() ? 'https' : 'http';
50
-	$current_uri = set_url_scheme( $base, $scheme );
50
+	$current_uri = set_url_scheme($base, $scheme);
51 51
 
52
-	if ( is_front_page() ) {
53
-		$current_uri = home_url( '/' );
52
+	if (is_front_page()) {
53
+		$current_uri = home_url('/');
54 54
 	}
55 55
 
56 56
 	/**
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	 *
61 61
 	 * @param string $current_uri
62 62
 	 */
63
-	return apply_filters( 'give_get_current_page_url', $current_uri );
63
+	return apply_filters('give_get_current_page_url', $current_uri);
64 64
 
65 65
 }
66 66
 
@@ -82,11 +82,11 @@  discard block
 block discarded – undo
82 82
 	 */
83 83
 	$gateways = give_get_enabled_payment_gateways();
84 84
 
85
-	if ( count( $gateways ) == 1 && ! isset( $gateways['paypal'] ) && ! isset( $gateways['manual'] ) ) {
85
+	if (count($gateways) == 1 && ! isset($gateways['paypal']) && ! isset($gateways['manual'])) {
86 86
 		$ret = true;
87
-	} elseif ( count( $gateways ) == 1 ) {
87
+	} elseif (count($gateways) == 1) {
88 88
 		$ret = false;
89
-	} elseif ( count( $gateways ) == 2 && isset( $gateways['paypal'] ) && isset( $gateways['manual'] ) ) {
89
+	} elseif (count($gateways) == 2 && isset($gateways['paypal']) && isset($gateways['manual'])) {
90 90
 		$ret = false;
91 91
 	}
92 92
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 *
98 98
 	 * @param bool $ret
99 99
 	 */
100
-	return (bool) apply_filters( 'give_is_cc_verify_enabled', $ret );
100
+	return (bool) apply_filters('give_is_cc_verify_enabled', $ret);
101 101
 }
102 102
 
103 103
 /**
@@ -109,26 +109,26 @@  discard block
 block discarded – undo
109 109
 function give_get_timezone_id() {
110 110
 
111 111
 	// if site timezone string exists, return it.
112
-	if ( $timezone = get_option( 'timezone_string' ) ) {
112
+	if ($timezone = get_option('timezone_string')) {
113 113
 		return $timezone;
114 114
 	}
115 115
 
116 116
 	// get UTC offset, if it isn't set return UTC.
117
-	if ( ! ( $utc_offset = 3600 * get_option( 'gmt_offset', 0 ) ) ) {
117
+	if ( ! ($utc_offset = 3600 * get_option('gmt_offset', 0))) {
118 118
 		return 'UTC';
119 119
 	}
120 120
 
121 121
 	// attempt to guess the timezone string from the UTC offset.
122
-	$timezone = timezone_name_from_abbr( '', $utc_offset );
122
+	$timezone = timezone_name_from_abbr('', $utc_offset);
123 123
 
124 124
 	// last try, guess timezone string manually.
125
-	if ( $timezone === false ) {
125
+	if ($timezone === false) {
126 126
 
127
-		$is_dst = date( 'I' );
127
+		$is_dst = date('I');
128 128
 
129
-		foreach ( timezone_abbreviations_list() as $abbr ) {
130
-			foreach ( $abbr as $city ) {
131
-				if ( $city['dst'] == $is_dst && $city['offset'] == $utc_offset ) {
129
+		foreach (timezone_abbreviations_list() as $abbr) {
130
+			foreach ($abbr as $city) {
131
+				if ($city['dst'] == $is_dst && $city['offset'] == $utc_offset) {
132 132
 					return $city['timezone_id'];
133 133
 				}
134 134
 			}
@@ -152,13 +152,13 @@  discard block
 block discarded – undo
152 152
 
153 153
 	$ip = '127.0.0.1';
154 154
 
155
-	if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
155
+	if ( ! empty($_SERVER['HTTP_CLIENT_IP'])) {
156 156
 		// check ip from share internet
157 157
 		$ip = $_SERVER['HTTP_CLIENT_IP'];
158
-	} elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
158
+	} elseif ( ! empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
159 159
 		// to check ip is pass from proxy
160 160
 		$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
161
-	} elseif ( ! empty( $_SERVER['REMOTE_ADDR'] ) ) {
161
+	} elseif ( ! empty($_SERVER['REMOTE_ADDR'])) {
162 162
 		$ip = $_SERVER['REMOTE_ADDR'];
163 163
 	}
164 164
 
@@ -167,15 +167,15 @@  discard block
 block discarded – undo
167 167
 	 *
168 168
 	 * @since 1.0
169 169
 	 */
170
-	$ip = apply_filters( 'give_get_ip', $ip );
170
+	$ip = apply_filters('give_get_ip', $ip);
171 171
 
172 172
 	// Filter empty values.
173
-	if( false !== strpos( $ip, ',' ) ) {
174
-		$ip = give_clean( explode( ',', $ip ) );
175
-		$ip = array_filter( $ip );
176
-		$ip = implode( ',', $ip );
177
-	} else{
178
-		$ip = give_clean( $ip );
173
+	if (false !== strpos($ip, ',')) {
174
+		$ip = give_clean(explode(',', $ip));
175
+		$ip = array_filter($ip);
176
+		$ip = implode(',', $ip);
177
+	} else {
178
+		$ip = give_clean($ip);
179 179
 	}
180 180
 
181 181
 	return $ip;
@@ -193,9 +193,9 @@  discard block
 block discarded – undo
193 193
  *
194 194
  * @uses  Give()->session->set()
195 195
  */
196
-function give_set_purchase_session( $purchase_data = array() ) {
197
-	Give()->session->set( 'give_purchase', $purchase_data );
198
-	Give()->session->set( 'give_email', $purchase_data['user_email'] );
196
+function give_set_purchase_session($purchase_data = array()) {
197
+	Give()->session->set('give_purchase', $purchase_data);
198
+	Give()->session->set('give_email', $purchase_data['user_email']);
199 199
 }
200 200
 
201 201
 /**
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
  * @return mixed array | false
210 210
  */
211 211
 function give_get_purchase_session() {
212
-	return Give()->session->get( 'give_purchase' );
212
+	return Give()->session->get('give_purchase');
213 213
 }
214 214
 
215 215
 /**
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
  * @return array|string
221 221
  */
222 222
 function give_get_receipt_session() {
223
-	return Give()->session->get( 'receipt_access' );
223
+	return Give()->session->get('receipt_access');
224 224
 }
225 225
 
226 226
 /**
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
  * @return array|string
232 232
  */
233 233
 function give_get_history_session() {
234
-	return (bool) Give()->session->get( 'history_access' );
234
+	return (bool) Give()->session->get('history_access');
235 235
 }
236 236
 
237 237
 /**
@@ -243,17 +243,17 @@  discard block
 block discarded – undo
243 243
  *
244 244
  * @return string By default, the name of the form. Then the price level text if any is found.
245 245
  */
246
-function give_payment_gateway_item_title( $payment_data ) {
246
+function give_payment_gateway_item_title($payment_data) {
247 247
 
248
-	$form_id   = intval( $payment_data['post_data']['give-form-id'] );
249
-	$item_name = isset( $payment_data['post_data']['give-form-title'] ) ? $payment_data['post_data']['give-form-title'] : '';
250
-	$price_id  = isset( $payment_data['post_data']['give-price-id'] ) ? $payment_data['post_data']['give-price-id'] : '';
248
+	$form_id   = intval($payment_data['post_data']['give-form-id']);
249
+	$item_name = isset($payment_data['post_data']['give-form-title']) ? $payment_data['post_data']['give-form-title'] : '';
250
+	$price_id  = isset($payment_data['post_data']['give-price-id']) ? $payment_data['post_data']['give-price-id'] : '';
251 251
 
252 252
 
253 253
 	// Verify has variable prices.
254
-	if ( give_has_variable_prices( $form_id ) && ! empty( $price_id ) ) {
254
+	if (give_has_variable_prices($form_id) && ! empty($price_id)) {
255 255
 
256
-		$item_price_level_text = give_get_price_option_name( $form_id, $price_id, 0, false );
256
+		$item_price_level_text = give_get_price_option_name($form_id, $price_id, 0, false);
257 257
 
258 258
 		/**
259 259
 		 * Output donation level text if:
@@ -263,10 +263,10 @@  discard block
 block discarded – undo
263 263
 		 */
264 264
 		if (
265 265
 			'custom' !== $price_id
266
-			&& ! empty( $item_price_level_text )
266
+			&& ! empty($item_price_level_text)
267 267
 		) {
268 268
 			// Matches a donation level - append level text.
269
-			$item_name .= ' - ' . $item_price_level_text;
269
+			$item_name .= ' - '.$item_price_level_text;
270 270
 		}
271 271
 	}
272 272
 
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 	 *
282 282
 	 * @return string
283 283
 	 */
284
-	return apply_filters( 'give_payment_gateway_item_title', $item_name, $form_id, $payment_data );
284
+	return apply_filters('give_payment_gateway_item_title', $item_name, $form_id, $payment_data);
285 285
 }
286 286
 
287 287
 /**
@@ -297,38 +297,38 @@  discard block
 block discarded – undo
297 297
  *
298 298
  * @return string
299 299
  */
300
-function give_payment_gateway_donation_summary( $donation_data, $name_and_email = true, $length = 255 ) {
300
+function give_payment_gateway_donation_summary($donation_data, $name_and_email = true, $length = 255) {
301 301
 
302
-	$form_id  = isset( $donation_data['post_data']['give-form-id'] ) ? $donation_data['post_data']['give-form-id'] : '';
303
-	$price_id = isset( $donation_data['post_data']['give-price-id'] ) ? $donation_data['post_data']['give-price-id'] : '';
302
+	$form_id  = isset($donation_data['post_data']['give-form-id']) ? $donation_data['post_data']['give-form-id'] : '';
303
+	$price_id = isset($donation_data['post_data']['give-price-id']) ? $donation_data['post_data']['give-price-id'] : '';
304 304
 
305 305
 	// Form title.
306
-	$summary = ( ! empty( $donation_data['post_data']['give-form-title'] ) ? $donation_data['post_data']['give-form-title'] : ( ! empty( $form_id ) ? wp_sprintf( __( 'Donation Form ID: %d', 'give' ), $form_id ) : __( 'Untitled donation form', 'give' ) ) );
306
+	$summary = ( ! empty($donation_data['post_data']['give-form-title']) ? $donation_data['post_data']['give-form-title'] : ( ! empty($form_id) ? wp_sprintf(__('Donation Form ID: %d', 'give'), $form_id) : __('Untitled donation form', 'give')));
307 307
 
308 308
 	// Form multilevel if applicable.
309
-	if ( ! empty( $price_id ) && 'custom' !== $price_id ) {
310
-		$summary .= ': ' . give_get_price_option_name( $form_id, $donation_data['post_data']['give-price-id'] );
309
+	if ( ! empty($price_id) && 'custom' !== $price_id) {
310
+		$summary .= ': '.give_get_price_option_name($form_id, $donation_data['post_data']['give-price-id']);
311 311
 	}
312 312
 
313 313
 	// Add Donor's name + email if requested.
314
-	if ( $name_and_email ) {
314
+	if ($name_and_email) {
315 315
 
316 316
 		// First name
317
-		if ( isset( $donation_data['user_info']['first_name'] ) && ! empty( $donation_data['user_info']['first_name'] ) ) {
318
-			$summary .= ' - ' . $donation_data['user_info']['first_name'];
317
+		if (isset($donation_data['user_info']['first_name']) && ! empty($donation_data['user_info']['first_name'])) {
318
+			$summary .= ' - '.$donation_data['user_info']['first_name'];
319 319
 		}
320 320
 
321
-		if ( isset( $donation_data['user_info']['last_name'] ) && ! empty( $donation_data['user_info']['last_name'] ) ) {
322
-			$summary .= ' ' . $donation_data['user_info']['last_name'];
321
+		if (isset($donation_data['user_info']['last_name']) && ! empty($donation_data['user_info']['last_name'])) {
322
+			$summary .= ' '.$donation_data['user_info']['last_name'];
323 323
 		}
324 324
 
325
-		$summary .= ' (' . $donation_data['user_email'] . ')';
325
+		$summary .= ' ('.$donation_data['user_email'].')';
326 326
 	}
327 327
 
328 328
 	// Cut the length
329
-	$summary = substr( $summary, 0, $length );
329
+	$summary = substr($summary, 0, $length);
330 330
 
331
-	return apply_filters( 'give_payment_gateway_donation_summary', $summary );
331
+	return apply_filters('give_payment_gateway_donation_summary', $summary);
332 332
 }
333 333
 
334 334
 
@@ -343,31 +343,31 @@  discard block
 block discarded – undo
343 343
 function give_get_host() {
344 344
 	$host = false;
345 345
 
346
-	if ( defined( 'WPE_APIKEY' ) ) {
346
+	if (defined('WPE_APIKEY')) {
347 347
 		$host = 'WP Engine';
348
-	} elseif ( defined( 'PAGELYBIN' ) ) {
348
+	} elseif (defined('PAGELYBIN')) {
349 349
 		$host = 'Pagely';
350
-	} elseif ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) {
350
+	} elseif (DB_HOST == 'localhost:/tmp/mysql5.sock') {
351 351
 		$host = 'ICDSoft';
352
-	} elseif ( DB_HOST == 'mysqlv5' ) {
352
+	} elseif (DB_HOST == 'mysqlv5') {
353 353
 		$host = 'NetworkSolutions';
354
-	} elseif ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) {
354
+	} elseif (strpos(DB_HOST, 'ipagemysql.com') !== false) {
355 355
 		$host = 'iPage';
356
-	} elseif ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) {
356
+	} elseif (strpos(DB_HOST, 'ipowermysql.com') !== false) {
357 357
 		$host = 'IPower';
358
-	} elseif ( strpos( DB_HOST, '.gridserver.com' ) !== false ) {
358
+	} elseif (strpos(DB_HOST, '.gridserver.com') !== false) {
359 359
 		$host = 'MediaTemple Grid';
360
-	} elseif ( strpos( DB_HOST, '.pair.com' ) !== false ) {
360
+	} elseif (strpos(DB_HOST, '.pair.com') !== false) {
361 361
 		$host = 'pair Networks';
362
-	} elseif ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) {
362
+	} elseif (strpos(DB_HOST, '.stabletransit.com') !== false) {
363 363
 		$host = 'Rackspace Cloud';
364
-	} elseif ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) {
364
+	} elseif (strpos(DB_HOST, '.sysfix.eu') !== false) {
365 365
 		$host = 'SysFix.eu Power Hosting';
366
-	} elseif ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) {
366
+	} elseif (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) {
367 367
 		$host = 'Flywheel';
368 368
 	} else {
369 369
 		// Adding a general fallback for data gathering
370
-		$host = 'DBH: ' . DB_HOST . ', SRV: ' . $_SERVER['SERVER_NAME'];
370
+		$host = 'DBH: '.DB_HOST.', SRV: '.$_SERVER['SERVER_NAME'];
371 371
 	}
372 372
 
373 373
 	return $host;
@@ -383,67 +383,67 @@  discard block
 block discarded – undo
383 383
  *
384 384
  * @return bool true if host matches, false if not
385 385
  */
386
-function give_is_host( $host = false ) {
386
+function give_is_host($host = false) {
387 387
 
388 388
 	$return = false;
389 389
 
390
-	if ( $host ) {
391
-		$host = str_replace( ' ', '', strtolower( $host ) );
390
+	if ($host) {
391
+		$host = str_replace(' ', '', strtolower($host));
392 392
 
393
-		switch ( $host ) {
393
+		switch ($host) {
394 394
 			case 'wpengine':
395
-				if ( defined( 'WPE_APIKEY' ) ) {
395
+				if (defined('WPE_APIKEY')) {
396 396
 					$return = true;
397 397
 				}
398 398
 				break;
399 399
 			case 'pagely':
400
-				if ( defined( 'PAGELYBIN' ) ) {
400
+				if (defined('PAGELYBIN')) {
401 401
 					$return = true;
402 402
 				}
403 403
 				break;
404 404
 			case 'icdsoft':
405
-				if ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) {
405
+				if (DB_HOST == 'localhost:/tmp/mysql5.sock') {
406 406
 					$return = true;
407 407
 				}
408 408
 				break;
409 409
 			case 'networksolutions':
410
-				if ( DB_HOST == 'mysqlv5' ) {
410
+				if (DB_HOST == 'mysqlv5') {
411 411
 					$return = true;
412 412
 				}
413 413
 				break;
414 414
 			case 'ipage':
415
-				if ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) {
415
+				if (strpos(DB_HOST, 'ipagemysql.com') !== false) {
416 416
 					$return = true;
417 417
 				}
418 418
 				break;
419 419
 			case 'ipower':
420
-				if ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) {
420
+				if (strpos(DB_HOST, 'ipowermysql.com') !== false) {
421 421
 					$return = true;
422 422
 				}
423 423
 				break;
424 424
 			case 'mediatemplegrid':
425
-				if ( strpos( DB_HOST, '.gridserver.com' ) !== false ) {
425
+				if (strpos(DB_HOST, '.gridserver.com') !== false) {
426 426
 					$return = true;
427 427
 				}
428 428
 				break;
429 429
 			case 'pairnetworks':
430
-				if ( strpos( DB_HOST, '.pair.com' ) !== false ) {
430
+				if (strpos(DB_HOST, '.pair.com') !== false) {
431 431
 					$return = true;
432 432
 				}
433 433
 				break;
434 434
 			case 'rackspacecloud':
435
-				if ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) {
435
+				if (strpos(DB_HOST, '.stabletransit.com') !== false) {
436 436
 					$return = true;
437 437
 				}
438 438
 				break;
439 439
 			case 'sysfix.eu':
440 440
 			case 'sysfix.eupowerhosting':
441
-				if ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) {
441
+				if (strpos(DB_HOST, '.sysfix.eu') !== false) {
442 442
 					$return = true;
443 443
 				}
444 444
 				break;
445 445
 			case 'flywheel':
446
-				if ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) {
446
+				if (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) {
447 447
 					$return = true;
448 448
 				}
449 449
 				break;
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
  * @param string $replacement Optional. The function that should have been called.
477 477
  * @param array  $backtrace   Optional. Contains stack backtrace of deprecated function.
478 478
  */
479
-function _give_deprecated_function( $function, $version, $replacement = null, $backtrace = null ) {
479
+function _give_deprecated_function($function, $version, $replacement = null, $backtrace = null) {
480 480
 
481 481
 	/**
482 482
 	 * Fires while give deprecated function call occurs.
@@ -489,19 +489,19 @@  discard block
 block discarded – undo
489 489
 	 * @param string $replacement Optional. The function that should have been called.
490 490
 	 * @param string $version     The plugin version that deprecated the function.
491 491
 	 */
492
-	do_action( 'give_deprecated_function_run', $function, $replacement, $version );
492
+	do_action('give_deprecated_function_run', $function, $replacement, $version);
493 493
 
494
-	$show_errors = current_user_can( 'manage_options' );
494
+	$show_errors = current_user_can('manage_options');
495 495
 
496 496
 	// Allow plugin to filter the output error trigger.
497
-	if ( WP_DEBUG && apply_filters( 'give_deprecated_function_trigger_error', $show_errors ) ) {
498
-		if ( ! is_null( $replacement ) ) {
499
-			trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give' ), $function, $version, $replacement ) );
500
-			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.
497
+	if (WP_DEBUG && apply_filters('give_deprecated_function_trigger_error', $show_errors)) {
498
+		if ( ! is_null($replacement)) {
499
+			trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give'), $function, $version, $replacement));
500
+			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.
501 501
 			// Alternatively we could dump this to a file.
502 502
 		} else {
503
-			trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give' ), $function, $version ) );
504
-			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.
503
+			trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give'), $function, $version));
504
+			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.
505 505
 			// Alternatively we could dump this to a file.
506 506
 		}
507 507
 	}
@@ -515,17 +515,17 @@  discard block
 block discarded – undo
515 515
  * @return string $post_id
516 516
  */
517 517
 function give_get_admin_post_id() {
518
-	$post_id = isset( $_REQUEST['post'] )
519
-		? absint( $_REQUEST['post'] )
518
+	$post_id = isset($_REQUEST['post'])
519
+		? absint($_REQUEST['post'])
520 520
 		: null;
521 521
 
522
-	$post_id = ! empty( $post_id )
522
+	$post_id = ! empty($post_id)
523 523
 		? $post_id
524
-		: ( isset( $_REQUEST['post_id'] ) ? absint( $_REQUEST['post_id'] ) : null );
524
+		: (isset($_REQUEST['post_id']) ? absint($_REQUEST['post_id']) : null);
525 525
 
526
-	$post_id = ! empty( $post_id )
526
+	$post_id = ! empty($post_id)
527 527
 		? $post_id
528
-		: ( isset( $_REQUEST['post_ID'] ) ? absint( $_REQUEST['post_ID'] ) : null );
528
+		: (isset($_REQUEST['post_ID']) ? absint($_REQUEST['post_ID']) : null);
529 529
 
530 530
 	return $post_id;
531 531
 }
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
  * @return string Arg separator output
538 538
  */
539 539
 function give_get_php_arg_separator_output() {
540
-	return ini_get( 'arg_separator.output' );
540
+	return ini_get('arg_separator.output');
541 541
 }
542 542
 
543 543
 
@@ -552,10 +552,10 @@  discard block
 block discarded – undo
552 552
  *
553 553
  * @return string Short month name
554 554
  */
555
-function give_month_num_to_name( $n ) {
556
-	$timestamp = mktime( 0, 0, 0, $n, 1, 2005 );
555
+function give_month_num_to_name($n) {
556
+	$timestamp = mktime(0, 0, 0, $n, 1, 2005);
557 557
 
558
-	return date_i18n( 'M', $timestamp );
558
+	return date_i18n('M', $timestamp);
559 559
 }
560 560
 
561 561
 
@@ -568,10 +568,10 @@  discard block
 block discarded – undo
568 568
  *
569 569
  * @return bool Whether or not function is disabled.
570 570
  */
571
-function give_is_func_disabled( $function ) {
572
-	$disabled = explode( ',', ini_get( 'disable_functions' ) );
571
+function give_is_func_disabled($function) {
572
+	$disabled = explode(',', ini_get('disable_functions'));
573 573
 
574
-	return in_array( $function, $disabled );
574
+	return in_array($function, $disabled);
575 575
 }
576 576
 
577 577
 
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
 function give_get_newsletter() {
584 584
 	?>
585 585
 
586
-	<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>
586
+	<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>
587 587
 
588 588
 	<div class="give-newsletter-form-wrap">
589 589
 
@@ -591,33 +591,33 @@  discard block
 block discarded – undo
591 591
 		      method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate"
592 592
 		      target="_blank" novalidate>
593 593
 			<div class="give-newsletter-confirmation">
594
-				<p><?php esc_html_e( 'Thanks for Subscribing!', 'give' ); ?> :)</p>
594
+				<p><?php esc_html_e('Thanks for Subscribing!', 'give'); ?> :)</p>
595 595
 			</div>
596 596
 
597 597
 			<table class="form-table give-newsletter-form">
598 598
 				<tr valign="middle">
599 599
 					<td>
600 600
 						<label for="mce-EMAIL"
601
-						       class="screen-reader-text"><?php esc_html_e( 'Email Address (required)', 'give' ); ?></label>
601
+						       class="screen-reader-text"><?php esc_html_e('Email Address (required)', 'give'); ?></label>
602 602
 						<input type="email" name="EMAIL" id="mce-EMAIL"
603
-						       placeholder="<?php esc_attr_e( 'Email Address (required)', 'give' ); ?>"
603
+						       placeholder="<?php esc_attr_e('Email Address (required)', 'give'); ?>"
604 604
 						       class="required email" value="">
605 605
 					</td>
606 606
 					<td>
607 607
 						<label for="mce-FNAME"
608
-						       class="screen-reader-text"><?php esc_html_e( 'First Name', 'give' ); ?></label>
608
+						       class="screen-reader-text"><?php esc_html_e('First Name', 'give'); ?></label>
609 609
 						<input type="text" name="FNAME" id="mce-FNAME"
610
-						       placeholder="<?php esc_attr_e( 'First Name', 'give' ); ?>" class="" value="">
610
+						       placeholder="<?php esc_attr_e('First Name', 'give'); ?>" class="" value="">
611 611
 					</td>
612 612
 					<td>
613 613
 						<label for="mce-LNAME"
614
-						       class="screen-reader-text"><?php esc_html_e( 'Last Name', 'give' ); ?></label>
614
+						       class="screen-reader-text"><?php esc_html_e('Last Name', 'give'); ?></label>
615 615
 						<input type="text" name="LNAME" id="mce-LNAME"
616
-						       placeholder="<?php esc_attr_e( 'Last Name', 'give' ); ?>" class="" value="">
616
+						       placeholder="<?php esc_attr_e('Last Name', 'give'); ?>" class="" value="">
617 617
 					</td>
618 618
 					<td>
619 619
 						<input type="submit" name="subscribe" id="mc-embedded-subscribe" class="button"
620
-						       value="<?php esc_attr_e( 'Subscribe', 'give' ); ?>">
620
+						       value="<?php esc_attr_e('Subscribe', 'give'); ?>">
621 621
 					</td>
622 622
 				</tr>
623 623
 			</table>
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
  *
671 671
  * @return string
672 672
  */
673
-function give_svg_icons( $icon ) {
673
+function give_svg_icons($icon) {
674 674
 
675 675
 	// Store your SVGs in an associative array
676 676
 	$svgs = array(
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
 	);
683 683
 
684 684
 	// Return the chosen icon's SVG string
685
-	return $svgs[ $icon ];
685
+	return $svgs[$icon];
686 686
 }
687 687
 
688 688
 /**
@@ -694,15 +694,15 @@  discard block
 block discarded – undo
694 694
  *
695 695
  * @return mixed
696 696
  */
697
-function modify_nav_menu_meta_box_object( $post_type ) {
698
-	if ( isset( $post_type->name ) && $post_type->name == 'give_forms' ) {
699
-		$post_type->labels->name = esc_html__( 'Donation Forms', 'give' );
697
+function modify_nav_menu_meta_box_object($post_type) {
698
+	if (isset($post_type->name) && $post_type->name == 'give_forms') {
699
+		$post_type->labels->name = esc_html__('Donation Forms', 'give');
700 700
 	}
701 701
 
702 702
 	return $post_type;
703 703
 }
704 704
 
705
-add_filter( 'nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object' );
705
+add_filter('nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object');
706 706
 
707 707
 /**
708 708
  * Show Donation Forms Post Type in Appearance > Menus by default on fresh install.
@@ -721,35 +721,35 @@  discard block
 block discarded – undo
721 721
 	// Proceed, if current screen is navigation menus.
722 722
 	if (
723 723
 		'nav-menus' === $screen->id &&
724
-		give_is_setting_enabled( give_get_option( 'forms_singular' ) ) &&
725
-		! get_user_option( 'give_is_donation_forms_menu_updated' )
724
+		give_is_setting_enabled(give_get_option('forms_singular')) &&
725
+		! get_user_option('give_is_donation_forms_menu_updated')
726 726
 	) {
727 727
 
728 728
 		// Return false, if it fails to retrieve hidden meta box list and is not admin.
729 729
 		if (
730 730
 			! is_admin() ||
731
-			( ! $hidden_meta_boxes = get_user_option( 'metaboxhidden_nav-menus' ) )
731
+			( ! $hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus'))
732 732
 		) {
733 733
 			return false;
734 734
 		}
735 735
 
736 736
 		// Return false, In case, we don't find 'Donation Form' in hidden meta box list.
737
-		if ( ! in_array( 'add-post-type-give_forms', $hidden_meta_boxes, true ) ) {
737
+		if ( ! in_array('add-post-type-give_forms', $hidden_meta_boxes, true)) {
738 738
 			return false;
739 739
 		}
740 740
 
741 741
 		// Exclude 'Donation Form' value from hidden meta box's list.
742
-		$hidden_meta_boxes = array_diff( $hidden_meta_boxes, array( 'add-post-type-give_forms' ) );
742
+		$hidden_meta_boxes = array_diff($hidden_meta_boxes, array('add-post-type-give_forms'));
743 743
 
744 744
 		// Get current user ID.
745 745
 		$user = wp_get_current_user();
746 746
 
747
-		update_user_option( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true );
748
-		update_user_option( $user->ID, 'give_is_donation_forms_menu_updated', true, true );
747
+		update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true);
748
+		update_user_option($user->ID, 'give_is_donation_forms_menu_updated', true, true);
749 749
 	}
750 750
 }
751 751
 
752
-add_action( 'current_screen', 'give_donation_metabox_menu' );
752
+add_action('current_screen', 'give_donation_metabox_menu');
753 753
 
754 754
 /**
755 755
  * Array_column backup usage
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
  * @license    https://opensource.org/licenses/MIT MIT
763 763
  */
764 764
 
765
-if ( ! function_exists( 'array_column' ) ) {
765
+if ( ! function_exists('array_column')) {
766 766
 	/**
767 767
 	 * Returns the values from a single column of the input array, identified by
768 768
 	 * the $columnKey.
@@ -781,53 +781,53 @@  discard block
 block discarded – undo
781 781
 	 *
782 782
 	 * @return array
783 783
 	 */
784
-	function array_column( $input = null, $columnKey = null, $indexKey = null ) {
784
+	function array_column($input = null, $columnKey = null, $indexKey = null) {
785 785
 		// Using func_get_args() in order to check for proper number of
786 786
 		// parameters and trigger errors exactly as the built-in array_column()
787 787
 		// does in PHP 5.5.
788 788
 		$argc   = func_num_args();
789 789
 		$params = func_get_args();
790 790
 
791
-		if ( $argc < 2 ) {
792
-			trigger_error( sprintf( esc_html__( 'array_column() expects at least 2 parameters, %s given.', 'give' ), $argc ), E_USER_WARNING );
791
+		if ($argc < 2) {
792
+			trigger_error(sprintf(esc_html__('array_column() expects at least 2 parameters, %s given.', 'give'), $argc), E_USER_WARNING);
793 793
 
794 794
 			return null;
795 795
 		}
796 796
 
797
-		if ( ! is_array( $params[0] ) ) {
798
-			trigger_error( sprintf( esc_html__( 'array_column() expects parameter 1 to be array, %s given.', 'give' ), gettype( $params[0] ) ), E_USER_WARNING );
797
+		if ( ! is_array($params[0])) {
798
+			trigger_error(sprintf(esc_html__('array_column() expects parameter 1 to be array, %s given.', 'give'), gettype($params[0])), E_USER_WARNING);
799 799
 
800 800
 			return null;
801 801
 		}
802 802
 
803
-		if ( ! is_int( $params[1] )
804
-		     && ! is_float( $params[1] )
805
-		     && ! is_string( $params[1] )
803
+		if ( ! is_int($params[1])
804
+		     && ! is_float($params[1])
805
+		     && ! is_string($params[1])
806 806
 		     && $params[1] !== null
807
-		     && ! ( is_object( $params[1] ) && method_exists( $params[1], '__toString' ) )
807
+		     && ! (is_object($params[1]) && method_exists($params[1], '__toString'))
808 808
 		) {
809
-			trigger_error( esc_html__( 'array_column(): The column key should be either a string or an integer.', 'give' ), E_USER_WARNING );
809
+			trigger_error(esc_html__('array_column(): The column key should be either a string or an integer.', 'give'), E_USER_WARNING);
810 810
 
811 811
 			return false;
812 812
 		}
813 813
 
814
-		if ( isset( $params[2] )
815
-		     && ! is_int( $params[2] )
816
-		     && ! is_float( $params[2] )
817
-		     && ! is_string( $params[2] )
818
-		     && ! ( is_object( $params[2] ) && method_exists( $params[2], '__toString' ) )
814
+		if (isset($params[2])
815
+		     && ! is_int($params[2])
816
+		     && ! is_float($params[2])
817
+		     && ! is_string($params[2])
818
+		     && ! (is_object($params[2]) && method_exists($params[2], '__toString'))
819 819
 		) {
820
-			trigger_error( esc_html__( 'array_column(): The index key should be either a string or an integer.', 'give' ), E_USER_WARNING );
820
+			trigger_error(esc_html__('array_column(): The index key should be either a string or an integer.', 'give'), E_USER_WARNING);
821 821
 
822 822
 			return false;
823 823
 		}
824 824
 
825 825
 		$paramsInput     = $params[0];
826
-		$paramsColumnKey = ( $params[1] !== null ) ? (string) $params[1] : null;
826
+		$paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null;
827 827
 
828 828
 		$paramsIndexKey = null;
829
-		if ( isset( $params[2] ) ) {
830
-			if ( is_float( $params[2] ) || is_int( $params[2] ) ) {
829
+		if (isset($params[2])) {
830
+			if (is_float($params[2]) || is_int($params[2])) {
831 831
 				$paramsIndexKey = (int) $params[2];
832 832
 			} else {
833 833
 				$paramsIndexKey = (string) $params[2];
@@ -836,26 +836,26 @@  discard block
 block discarded – undo
836 836
 
837 837
 		$resultArray = array();
838 838
 
839
-		foreach ( $paramsInput as $row ) {
839
+		foreach ($paramsInput as $row) {
840 840
 			$key    = $value = null;
841 841
 			$keySet = $valueSet = false;
842 842
 
843
-			if ( $paramsIndexKey !== null && array_key_exists( $paramsIndexKey, $row ) ) {
843
+			if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) {
844 844
 				$keySet = true;
845
-				$key    = (string) $row[ $paramsIndexKey ];
845
+				$key    = (string) $row[$paramsIndexKey];
846 846
 			}
847 847
 
848
-			if ( $paramsColumnKey === null ) {
848
+			if ($paramsColumnKey === null) {
849 849
 				$valueSet = true;
850 850
 				$value    = $row;
851
-			} elseif ( is_array( $row ) && array_key_exists( $paramsColumnKey, $row ) ) {
851
+			} elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) {
852 852
 				$valueSet = true;
853
-				$value    = $row[ $paramsColumnKey ];
853
+				$value    = $row[$paramsColumnKey];
854 854
 			}
855 855
 
856
-			if ( $valueSet ) {
857
-				if ( $keySet ) {
858
-					$resultArray[ $key ] = $value;
856
+			if ($valueSet) {
857
+				if ($keySet) {
858
+					$resultArray[$key] = $value;
859 859
 				} else {
860 860
 					$resultArray[] = $value;
861 861
 				}
@@ -875,54 +875,54 @@  discard block
 block discarded – undo
875 875
  *
876 876
  * @return bool Whether the receipt is visible or not.
877 877
  */
878
-function give_can_view_receipt( $payment_key = '' ) {
878
+function give_can_view_receipt($payment_key = '') {
879 879
 
880 880
 	$return = false;
881 881
 
882
-	if ( empty( $payment_key ) ) {
882
+	if (empty($payment_key)) {
883 883
 		return $return;
884 884
 	}
885 885
 
886 886
 	global $give_receipt_args;
887 887
 
888
-	$give_receipt_args['id'] = give_get_donation_id_by_key( $payment_key );
888
+	$give_receipt_args['id'] = give_get_donation_id_by_key($payment_key);
889 889
 
890
-	$user_id = (int) give_get_payment_user_id( $give_receipt_args['id'] );
890
+	$user_id = (int) give_get_payment_user_id($give_receipt_args['id']);
891 891
 
892
-	$payment_meta = give_get_payment_meta( $give_receipt_args['id'] );
892
+	$payment_meta = give_get_payment_meta($give_receipt_args['id']);
893 893
 
894
-	if ( is_user_logged_in() ) {
895
-		if ( $user_id === (int) get_current_user_id() ) {
894
+	if (is_user_logged_in()) {
895
+		if ($user_id === (int) get_current_user_id()) {
896 896
 			$return = true;
897
-		} elseif ( wp_get_current_user()->user_email === give_get_payment_user_email( $give_receipt_args['id'] ) ) {
897
+		} elseif (wp_get_current_user()->user_email === give_get_payment_user_email($give_receipt_args['id'])) {
898 898
 			$return = true;
899
-		} elseif ( current_user_can( 'view_give_sensitive_data' ) ) {
899
+		} elseif (current_user_can('view_give_sensitive_data')) {
900 900
 			$return = true;
901 901
 		}
902 902
 	}
903 903
 
904 904
 	// Check whether it is purchase session?
905 905
 	$purchase_session = give_get_purchase_session();
906
-	if ( ! empty( $purchase_session ) && ! is_user_logged_in() ) {
907
-		if ( $purchase_session['purchase_key'] === $payment_meta['key'] ) {
906
+	if ( ! empty($purchase_session) && ! is_user_logged_in()) {
907
+		if ($purchase_session['purchase_key'] === $payment_meta['key']) {
908 908
 			$return = true;
909 909
 		}
910 910
 	}
911 911
 
912 912
 	// Check whether it is receipt access session?
913 913
 	$receipt_session = give_get_receipt_session();
914
-	if ( ! empty( $receipt_session ) && ! is_user_logged_in() ) {
915
-		if ( $receipt_session === $payment_meta['key'] ) {
914
+	if ( ! empty($receipt_session) && ! is_user_logged_in()) {
915
+		if ($receipt_session === $payment_meta['key']) {
916 916
 			$return = true;
917 917
 		}
918 918
 	}
919 919
 
920 920
 	// Check whether it is history access session?
921
-	if ( true === give_get_history_session() ) {
921
+	if (true === give_get_history_session()) {
922 922
 		$return = true;
923 923
 	}
924 924
 
925
-	return (bool) apply_filters( 'give_can_view_receipt', $return, $payment_key );
925
+	return (bool) apply_filters('give_can_view_receipt', $return, $payment_key);
926 926
 
927 927
 }
928 928
 
@@ -931,7 +931,7 @@  discard block
 block discarded – undo
931 931
  *
932 932
  * Fallback in case the calendar extension is not loaded in PHP; Only supports Gregorian calendar
933 933
  */
934
-if ( ! function_exists( 'cal_days_in_month' ) ) {
934
+if ( ! function_exists('cal_days_in_month')) {
935 935
 	/**
936 936
 	 * cal_days_in_month
937 937
 	 *
@@ -941,8 +941,8 @@  discard block
 block discarded – undo
941 941
 	 *
942 942
 	 * @return bool|string
943 943
 	 */
944
-	function cal_days_in_month( $calendar, $month, $year ) {
945
-		return date( 't', mktime( 0, 0, 0, $month, 1, $year ) );
944
+	function cal_days_in_month($calendar, $month, $year) {
945
+		return date('t', mktime(0, 0, 0, $month, 1, $year));
946 946
 	}
947 947
 }
948 948
 
@@ -961,42 +961,42 @@  discard block
 block discarded – undo
961 961
  */
962 962
 function give_get_plugins() {
963 963
 	$plugins             = get_plugins();
964
-	$active_plugin_paths = (array) get_option( 'active_plugins', array() );
964
+	$active_plugin_paths = (array) get_option('active_plugins', array());
965 965
 
966
-	if ( is_multisite() ) {
967
-		$network_activated_plugin_paths = array_keys( get_site_option( 'active_sitewide_plugins', array() ) );
968
-		$active_plugin_paths            = array_merge( $active_plugin_paths, $network_activated_plugin_paths );
966
+	if (is_multisite()) {
967
+		$network_activated_plugin_paths = array_keys(get_site_option('active_sitewide_plugins', array()));
968
+		$active_plugin_paths            = array_merge($active_plugin_paths, $network_activated_plugin_paths);
969 969
 	}
970 970
 
971
-	foreach ( $plugins as $plugin_path => $plugin_data ) {
971
+	foreach ($plugins as $plugin_path => $plugin_data) {
972 972
 		// Is plugin active?
973
-		if ( in_array( $plugin_path, $active_plugin_paths ) ) {
974
-			$plugins[ $plugin_path ]['Status'] = 'active';
973
+		if (in_array($plugin_path, $active_plugin_paths)) {
974
+			$plugins[$plugin_path]['Status'] = 'active';
975 975
 		} else {
976
-			$plugins[ $plugin_path ]['Status'] = 'inactive';
976
+			$plugins[$plugin_path]['Status'] = 'inactive';
977 977
 		}
978 978
 
979
-		$dirname = strtolower( dirname( $plugin_path ) );
979
+		$dirname = strtolower(dirname($plugin_path));
980 980
 
981 981
 		// Is plugin a Give add-on by WordImpress?
982
-		if ( strstr( $dirname, 'give-' ) && strstr( $plugin_data['AuthorURI'], 'wordimpress.com' ) ) {
982
+		if (strstr($dirname, 'give-') && strstr($plugin_data['AuthorURI'], 'wordimpress.com')) {
983 983
 			// Plugin is a Give-addon.
984
-			$plugins[ $plugin_path ]['Type'] = 'add-on';
984
+			$plugins[$plugin_path]['Type'] = 'add-on';
985 985
 
986 986
 			// Get license info from database.
987
-			$plugin_name    = str_replace( 'Give - ', '', $plugin_data['Name'] );
988
-			$db_option      = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $plugin_name ) ) ) . '_license_active';
989
-			$license_active = get_option( $db_option );
987
+			$plugin_name    = str_replace('Give - ', '', $plugin_data['Name']);
988
+			$db_option      = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($plugin_name))).'_license_active';
989
+			$license_active = get_option($db_option);
990 990
 
991 991
 			// Does a valid license exist?
992
-			if ( ! empty( $license_active ) && 'valid' === $license_active->license ) {
993
-				$plugins[ $plugin_path ]['License'] = true;
992
+			if ( ! empty($license_active) && 'valid' === $license_active->license) {
993
+				$plugins[$plugin_path]['License'] = true;
994 994
 			} else {
995
-				$plugins[ $plugin_path ]['License'] = false;
995
+				$plugins[$plugin_path]['License'] = false;
996 996
 			}
997 997
 		} else {
998 998
 			// Plugin is not a Give add-on.
999
-			$plugins[ $plugin_path ]['Type'] = 'other';
999
+			$plugins[$plugin_path]['Type'] = 'other';
1000 1000
 		}
1001 1001
 	}
1002 1002
 
@@ -1013,16 +1013,16 @@  discard block
 block discarded – undo
1013 1013
  *
1014 1014
  * @return bool
1015 1015
  */
1016
-function give_is_terms_enabled( $form_id ) {
1017
-	$form_option = give_get_meta( $form_id, '_give_terms_option', true );
1016
+function give_is_terms_enabled($form_id) {
1017
+	$form_option = give_get_meta($form_id, '_give_terms_option', true);
1018 1018
 
1019 1019
 	if (
1020
-		give_is_setting_enabled( $form_option, 'global' )
1021
-		&& give_is_setting_enabled( give_get_option( 'terms' ) )
1020
+		give_is_setting_enabled($form_option, 'global')
1021
+		&& give_is_setting_enabled(give_get_option('terms'))
1022 1022
 	) {
1023 1023
 		return true;
1024 1024
 
1025
-	} elseif ( give_is_setting_enabled( $form_option ) ) {
1025
+	} elseif (give_is_setting_enabled($form_option)) {
1026 1026
 		return true;
1027 1027
 
1028 1028
 	} else {
@@ -1047,10 +1047,10 @@  discard block
 block discarded – undo
1047 1047
  *
1048 1048
  * @return WP_Error|bool
1049 1049
  */
1050
-function give_delete_donation_stats( $date_range = '', $args = array() ) {
1050
+function give_delete_donation_stats($date_range = '', $args = array()) {
1051 1051
 
1052 1052
 	// Delete all cache.
1053
-	$status = Give_Cache::delete( Give_Cache::get_options_like( 'give_stats' ) );
1053
+	$status = Give_Cache::delete(Give_Cache::get_options_like('give_stats'));
1054 1054
 
1055 1055
 	/**
1056 1056
 	 * Fire the action when donation stats delete.
@@ -1060,7 +1060,7 @@  discard block
 block discarded – undo
1060 1060
 	 * @param string|array $date_range
1061 1061
 	 * @param array        $args
1062 1062
 	 */
1063
-	do_action( 'give_delete_donation_stats', $status, $date_range, $args );
1063
+	do_action('give_delete_donation_stats', $status, $date_range, $args);
1064 1064
 
1065 1065
 	return $status;
1066 1066
 }
@@ -1074,7 +1074,7 @@  discard block
 block discarded – undo
1074 1074
 function give_is_add_new_form_page() {
1075 1075
 	$status = false;
1076 1076
 
1077
-	if ( false !== strpos( $_SERVER['REQUEST_URI'], '/wp-admin/post-new.php?post_type=give_forms' ) ) {
1077
+	if (false !== strpos($_SERVER['REQUEST_URI'], '/wp-admin/post-new.php?post_type=give_forms')) {
1078 1078
 		$status = true;
1079 1079
 	}
1080 1080
 
@@ -1097,7 +1097,7 @@  discard block
 block discarded – undo
1097 1097
  *
1098 1098
  * @return mixed
1099 1099
  */
1100
-function give_get_meta( $id, $meta_key = '', $single = false, $default = false ) {
1100
+function give_get_meta($id, $meta_key = '', $single = false, $default = false) {
1101 1101
 	/**
1102 1102
 	 * Filter the meta value
1103 1103
 	 *
@@ -1105,14 +1105,14 @@  discard block
 block discarded – undo
1105 1105
 	 */
1106 1106
 	$meta_value = apply_filters(
1107 1107
 		'give_get_meta',
1108
-		get_post_meta( $id, $meta_key, $single ),
1108
+		get_post_meta($id, $meta_key, $single),
1109 1109
 		$id,
1110 1110
 		$meta_key,
1111 1111
 		$default
1112 1112
 	);
1113 1113
 
1114 1114
 	if (
1115
-		( empty( $meta_key ) || empty( $meta_value ) )
1115
+		(empty($meta_key) || empty($meta_value))
1116 1116
 		&& $default
1117 1117
 	) {
1118 1118
 		$meta_value = $default;
@@ -1133,15 +1133,15 @@  discard block
 block discarded – undo
1133 1133
  *
1134 1134
  * @return mixed
1135 1135
  */
1136
-function give_update_meta( $id, $meta_key, $meta_value, $prev_value = '' ) {
1137
-	$status = update_post_meta( $id, $meta_key, $meta_value, $prev_value );
1136
+function give_update_meta($id, $meta_key, $meta_value, $prev_value = '') {
1137
+	$status = update_post_meta($id, $meta_key, $meta_value, $prev_value);
1138 1138
 
1139 1139
 	/**
1140 1140
 	 * Filter the meta value update status
1141 1141
 	 *
1142 1142
 	 * @since 1.8.8
1143 1143
 	 */
1144
-	return apply_filters( 'give_update_meta', $status, $id, $meta_key, $meta_value );
1144
+	return apply_filters('give_update_meta', $status, $id, $meta_key, $meta_value);
1145 1145
 }
1146 1146
 
1147 1147
 /**
@@ -1155,15 +1155,15 @@  discard block
 block discarded – undo
1155 1155
  *
1156 1156
  * @return mixed
1157 1157
  */
1158
-function give_delete_meta( $id, $meta_key, $meta_value = '' ) {
1159
-	$status = delete_post_meta( $id, $meta_key, $meta_value );
1158
+function give_delete_meta($id, $meta_key, $meta_value = '') {
1159
+	$status = delete_post_meta($id, $meta_key, $meta_value);
1160 1160
 
1161 1161
 	/**
1162 1162
 	 * Filter the meta value delete status
1163 1163
 	 *
1164 1164
 	 * @since 1.8.8
1165 1165
 	 */
1166
-	return apply_filters( 'give_delete_meta', $status, $id, $meta_key, $meta_value );
1166
+	return apply_filters('give_delete_meta', $status, $id, $meta_key, $meta_value);
1167 1167
 }
1168 1168
 
1169 1169
 /**
@@ -1175,23 +1175,23 @@  discard block
 block discarded – undo
1175 1175
  *
1176 1176
  * @return bool                   If the action has been added to the completed actions array
1177 1177
  */
1178
-function give_has_upgrade_completed( $upgrade_action = '' ) {
1178
+function give_has_upgrade_completed($upgrade_action = '') {
1179 1179
 	// Bailout.
1180
-	if ( empty( $upgrade_action ) ) {
1180
+	if (empty($upgrade_action)) {
1181 1181
 		return false;
1182 1182
 	}
1183 1183
 
1184 1184
 	// Fresh install?
1185 1185
 	// If fresh install then all upgrades will be consider as completed.
1186
-	$is_fresh_install = ! get_option( 'give_version' );
1187
-	if ( $is_fresh_install ) {
1186
+	$is_fresh_install = ! get_option('give_version');
1187
+	if ($is_fresh_install) {
1188 1188
 		return true;
1189 1189
 	}
1190 1190
 
1191 1191
 
1192 1192
 	$completed_upgrades = give_get_completed_upgrades();
1193 1193
 
1194
-	return in_array( $upgrade_action, $completed_upgrades );
1194
+	return in_array($upgrade_action, $completed_upgrades);
1195 1195
 
1196 1196
 }
1197 1197
 
@@ -1203,8 +1203,8 @@  discard block
 block discarded – undo
1203 1203
  * @return mixed   When nothing to resume returns false, otherwise starts the upgrade where it left off
1204 1204
  */
1205 1205
 function give_maybe_resume_upgrade() {
1206
-	$doing_upgrade = get_option( 'give_doing_upgrade', false );
1207
-	if ( empty( $doing_upgrade ) ) {
1206
+	$doing_upgrade = get_option('give_doing_upgrade', false);
1207
+	if (empty($doing_upgrade)) {
1208 1208
 		return false;
1209 1209
 	}
1210 1210
 
@@ -1220,9 +1220,9 @@  discard block
 block discarded – undo
1220 1220
  *
1221 1221
  * @return bool                   If the function was successfully added
1222 1222
  */
1223
-function give_set_upgrade_complete( $upgrade_action = '' ) {
1223
+function give_set_upgrade_complete($upgrade_action = '') {
1224 1224
 
1225
-	if ( empty( $upgrade_action ) ) {
1225
+	if (empty($upgrade_action)) {
1226 1226
 		return false;
1227 1227
 	}
1228 1228
 
@@ -1230,16 +1230,16 @@  discard block
 block discarded – undo
1230 1230
 	$completed_upgrades[] = $upgrade_action;
1231 1231
 
1232 1232
 	// Remove any blanks, and only show uniques.
1233
-	$completed_upgrades = array_unique( array_values( $completed_upgrades ) );
1233
+	$completed_upgrades = array_unique(array_values($completed_upgrades));
1234 1234
 
1235 1235
 	/**
1236 1236
 	 * Fire the action when any upgrade set to complete.
1237 1237
 	 *
1238 1238
 	 * @since 1.8.12
1239 1239
 	 */
1240
-	do_action( 'give_set_upgrade_completed', $upgrade_action, $completed_upgrades );
1240
+	do_action('give_set_upgrade_completed', $upgrade_action, $completed_upgrades);
1241 1241
 
1242
-	return update_option( 'give_completed_upgrades', $completed_upgrades );
1242
+	return update_option('give_completed_upgrades', $completed_upgrades);
1243 1243
 }
1244 1244
 
1245 1245
 /**
@@ -1249,7 +1249,7 @@  discard block
 block discarded – undo
1249 1249
  * @return array The array of completed upgrades
1250 1250
  */
1251 1251
 function give_get_completed_upgrades() {
1252
-	return (array) get_option( 'give_completed_upgrades' );
1252
+	return (array) get_option('give_completed_upgrades');
1253 1253
 }
1254 1254
 
1255 1255
 /**
@@ -1264,16 +1264,16 @@  discard block
 block discarded – undo
1264 1264
  *
1265 1265
  * @return null|array
1266 1266
  */
1267
-function __give_v20_bc_table_details( $type ) {
1267
+function __give_v20_bc_table_details($type) {
1268 1268
 	global $wpdb;
1269 1269
 	$table = array();
1270 1270
 
1271 1271
 	// Bailout.
1272
-	if ( empty( $type ) ) {
1272
+	if (empty($type)) {
1273 1273
 		return null;
1274 1274
 	}
1275 1275
 
1276
-	switch ( $type ) {
1276
+	switch ($type) {
1277 1277
 		case 'form':
1278 1278
 			$table['name']         = $wpdb->formmeta;
1279 1279
 			$table['column']['id'] = 'form_id';
@@ -1286,7 +1286,7 @@  discard block
 block discarded – undo
1286 1286
 	}
1287 1287
 
1288 1288
 	// Backward compatibility.
1289
-	if ( ! give_has_upgrade_completed( 'v20_move_metadata_into_new_table' ) ) {
1289
+	if ( ! give_has_upgrade_completed('v20_move_metadata_into_new_table')) {
1290 1290
 		$table['name']         = $wpdb->postmeta;
1291 1291
 		$table['column']['id'] = 'post_id';
1292 1292
 	}
@@ -1302,12 +1302,12 @@  discard block
 block discarded – undo
1302 1302
  *
1303 1303
  * @param WP_Query $query
1304 1304
  */
1305
-function give_remove_pages_from_search( $query ) {
1305
+function give_remove_pages_from_search($query) {
1306 1306
 
1307
-	if ( ! $query->is_admin && $query->is_search && $query->is_main_query() ) {
1307
+	if ( ! $query->is_admin && $query->is_search && $query->is_main_query()) {
1308 1308
 
1309
-		$transaction_failed = give_get_option( 'failure_page', 0 );
1310
-		$success_page       = give_get_option( 'success_page', 0 );
1309
+		$transaction_failed = give_get_option('failure_page', 0);
1310
+		$success_page       = give_get_option('success_page', 0);
1311 1311
 
1312 1312
 		$args               = apply_filters(
1313 1313
 			'give_remove_pages_from_search', array(
@@ -1315,11 +1315,11 @@  discard block
 block discarded – undo
1315 1315
 			$success_page,
1316 1316
 		), $query
1317 1317
 		);
1318
-		$query->set( 'post__not_in', $args );
1318
+		$query->set('post__not_in', $args);
1319 1319
 	}
1320 1320
 }
1321 1321
 
1322
-add_action( 'pre_get_posts', 'give_remove_pages_from_search', 10, 1 );
1322
+add_action('pre_get_posts', 'give_remove_pages_from_search', 10, 1);
1323 1323
 
1324 1324
 /**
1325 1325
  * Inserts a new key/value before a key in the array.
@@ -1335,14 +1335,14 @@  discard block
 block discarded – undo
1335 1335
  *
1336 1336
  * @see   array_insert_before()
1337 1337
  */
1338
-function give_array_insert_before( $key, array &$array, $new_key, $new_value ) {
1339
-	if ( array_key_exists( $key, $array ) ) {
1338
+function give_array_insert_before($key, array &$array, $new_key, $new_value) {
1339
+	if (array_key_exists($key, $array)) {
1340 1340
 		$new = array();
1341
-		foreach ( $array as $k => $value ) {
1342
-			if ( $k === $key ) {
1343
-				$new[ $new_key ] = $new_value;
1341
+		foreach ($array as $k => $value) {
1342
+			if ($k === $key) {
1343
+				$new[$new_key] = $new_value;
1344 1344
 			}
1345
-			$new[ $k ] = $value;
1345
+			$new[$k] = $value;
1346 1346
 		}
1347 1347
 
1348 1348
 		return $new;
@@ -1365,13 +1365,13 @@  discard block
 block discarded – undo
1365 1365
  *
1366 1366
  * @see   array_insert_before()
1367 1367
  */
1368
-function give_array_insert_after( $key, array &$array, $new_key, $new_value ) {
1369
-	if ( array_key_exists( $key, $array ) ) {
1368
+function give_array_insert_after($key, array &$array, $new_key, $new_value) {
1369
+	if (array_key_exists($key, $array)) {
1370 1370
 		$new = array();
1371
-		foreach ( $array as $k => $value ) {
1372
-			$new[ $k ] = $value;
1373
-			if ( $k === $key ) {
1374
-				$new[ $new_key ] = $new_value;
1371
+		foreach ($array as $k => $value) {
1372
+			$new[$k] = $value;
1373
+			if ($k === $key) {
1374
+				$new[$new_key] = $new_value;
1375 1375
 			}
1376 1376
 		}
1377 1377
 
@@ -1398,21 +1398,21 @@  discard block
 block discarded – undo
1398 1398
  *               corresponding to `$index_key`. If `$index_key` is null, array keys from the original
1399 1399
  *               `$list` will be preserved in the results.
1400 1400
  */
1401
-function give_list_pluck( $list, $field, $index_key = null ) {
1401
+function give_list_pluck($list, $field, $index_key = null) {
1402 1402
 
1403
-	if ( ! $index_key ) {
1403
+	if ( ! $index_key) {
1404 1404
 		/**
1405 1405
 		 * This is simple. Could at some point wrap array_column()
1406 1406
 		 * if we knew we had an array of arrays.
1407 1407
 		 */
1408
-		foreach ( $list as $key => $value ) {
1409
-			if ( is_object( $value ) ) {
1410
-				if ( isset( $value->$field ) ) {
1411
-					$list[ $key ] = $value->$field;
1408
+		foreach ($list as $key => $value) {
1409
+			if (is_object($value)) {
1410
+				if (isset($value->$field)) {
1411
+					$list[$key] = $value->$field;
1412 1412
 				}
1413 1413
 			} else {
1414
-				if ( isset( $value[ $field ] ) ) {
1415
-					$list[ $key ] = $value[ $field ];
1414
+				if (isset($value[$field])) {
1415
+					$list[$key] = $value[$field];
1416 1416
 				}
1417 1417
 			}
1418 1418
 		}
@@ -1425,18 +1425,18 @@  discard block
 block discarded – undo
1425 1425
 	 * to the end of the stack. This is how array_column() behaves.
1426 1426
 	 */
1427 1427
 	$newlist = array();
1428
-	foreach ( $list as $value ) {
1429
-		if ( is_object( $value ) ) {
1430
-			if ( isset( $value->$index_key ) ) {
1431
-				$newlist[ $value->$index_key ] = $value->$field;
1428
+	foreach ($list as $value) {
1429
+		if (is_object($value)) {
1430
+			if (isset($value->$index_key)) {
1431
+				$newlist[$value->$index_key] = $value->$field;
1432 1432
 			} else {
1433 1433
 				$newlist[] = $value->$field;
1434 1434
 			}
1435 1435
 		} else {
1436
-			if ( isset( $value[ $index_key ] ) ) {
1437
-				$newlist[ $value[ $index_key ] ] = $value[ $field ];
1436
+			if (isset($value[$index_key])) {
1437
+				$newlist[$value[$index_key]] = $value[$field];
1438 1438
 			} else {
1439
-				$newlist[] = $value[ $field ];
1439
+				$newlist[] = $value[$field];
1440 1440
 			}
1441 1441
 		}
1442 1442
 	}
@@ -1459,8 +1459,8 @@  discard block
 block discarded – undo
1459 1459
  *
1460 1460
  * @return int|false Meta ID on success, false on failure.
1461 1461
  */
1462
-function add_donor_meta( $donor_id, $meta_key, $meta_value, $unique = false ) {
1463
-	return add_metadata( 'give_customer', $donor_id, $meta_key, $meta_value, $unique );
1462
+function add_donor_meta($donor_id, $meta_key, $meta_value, $unique = false) {
1463
+	return add_metadata('give_customer', $donor_id, $meta_key, $meta_value, $unique);
1464 1464
 }
1465 1465
 
1466 1466
 /**
@@ -1478,8 +1478,8 @@  discard block
 block discarded – undo
1478 1478
  *
1479 1479
  * @return bool True on success, false on failure.
1480 1480
  */
1481
-function delete_donor_meta( $donor_id, $meta_key, $meta_value = '' ) {
1482
-	return delete_metadata( 'give_customer', $donor_id, $meta_key, $meta_value );
1481
+function delete_donor_meta($donor_id, $meta_key, $meta_value = '') {
1482
+	return delete_metadata('give_customer', $donor_id, $meta_key, $meta_value);
1483 1483
 }
1484 1484
 
1485 1485
 /**
@@ -1494,8 +1494,8 @@  discard block
 block discarded – undo
1494 1494
  * @return mixed Will be an array if $single is false. Will be value of meta data field if $single
1495 1495
  *  is true.
1496 1496
  */
1497
-function get_donor_meta( $donor_id, $key = '', $single = false ) {
1498
-	return get_metadata( 'give_customer', $donor_id, $key, $single );
1497
+function get_donor_meta($donor_id, $key = '', $single = false) {
1498
+	return get_metadata('give_customer', $donor_id, $key, $single);
1499 1499
 }
1500 1500
 
1501 1501
 /**
@@ -1512,8 +1512,8 @@  discard block
 block discarded – undo
1512 1512
  *
1513 1513
  * @return int|bool Meta ID if the key didn't exist, true on successful update, false on failure.
1514 1514
  */
1515
-function update_donor_meta( $donor_id, $meta_key, $meta_value, $prev_value = '' ) {
1516
-	return update_metadata( 'give_customer', $donor_id, $meta_key, $meta_value, $prev_value );
1515
+function update_donor_meta($donor_id, $meta_key, $meta_value, $prev_value = '') {
1516
+	return update_metadata('give_customer', $donor_id, $meta_key, $meta_value, $prev_value);
1517 1517
 }
1518 1518
 
1519 1519
 
@@ -1526,15 +1526,15 @@  discard block
 block discarded – undo
1526 1526
  *
1527 1527
  * @return void
1528 1528
  */
1529
-function give_recount_form_income_donation( $form_id = 0 ) {
1529
+function give_recount_form_income_donation($form_id = 0) {
1530 1530
 	// Check if form id is not empty.
1531
-	if ( ! empty( $form_id ) ) {
1531
+	if ( ! empty($form_id)) {
1532 1532
 		/**
1533 1533
 		 * Filter to modify payment status.
1534 1534
 		 *
1535 1535
 		 * @since 1.8.13
1536 1536
 		 */
1537
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
1537
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
1538 1538
 
1539 1539
 		/**
1540 1540
 		 * Filter to modify args of payment query before recalculating the form total
@@ -1545,7 +1545,7 @@  discard block
 block discarded – undo
1545 1545
 			'give_recount_form_stats_args', array(
1546 1546
 				'give_forms'     => $form_id,
1547 1547
 				'status'         => $accepted_statuses,
1548
-				'posts_per_page' => - 1,
1548
+				'posts_per_page' => -1,
1549 1549
 				'fields'         => 'ids',
1550 1550
 			)
1551 1551
 		);
@@ -1555,28 +1555,28 @@  discard block
 block discarded – undo
1555 1555
 			'earnings' => 0,
1556 1556
 		);
1557 1557
 
1558
-		$payments = new Give_Payments_Query( $args );
1558
+		$payments = new Give_Payments_Query($args);
1559 1559
 		$payments = $payments->get_payments();
1560 1560
 
1561
-		if ( $payments ) {
1562
-			foreach ( $payments as $payment ) {
1561
+		if ($payments) {
1562
+			foreach ($payments as $payment) {
1563 1563
 				// Ensure acceptible status only
1564
-				if ( ! in_array( $payment->post_status, $accepted_statuses ) ) {
1564
+				if ( ! in_array($payment->post_status, $accepted_statuses)) {
1565 1565
 					continue;
1566 1566
 				}
1567 1567
 
1568 1568
 				// Ensure only payments for this form are counted
1569
-				if ( $payment->form_id != $form_id ) {
1569
+				if ($payment->form_id != $form_id) {
1570 1570
 					continue;
1571 1571
 				}
1572 1572
 
1573
-				$totals['sales'] ++;
1573
+				$totals['sales']++;
1574 1574
 				$totals['earnings'] += $payment->total;
1575 1575
 
1576 1576
 			}
1577 1577
 		}
1578
-		give_update_meta( $form_id, '_give_form_sales', $totals['sales'] );
1579
-		give_update_meta( $form_id, '_give_form_earnings', give_sanitize_amount_for_db( $totals['earnings'] ) );
1578
+		give_update_meta($form_id, '_give_form_sales', $totals['sales']);
1579
+		give_update_meta($form_id, '_give_form_earnings', give_sanitize_amount_for_db($totals['earnings']));
1580 1580
 	}// End if().
1581 1581
 }
1582 1582
 
@@ -1590,18 +1590,18 @@  discard block
 block discarded – undo
1590 1590
  *
1591 1591
  * @return string
1592 1592
  */
1593
-function give_get_attribute_str( $attributes ) {
1593
+function give_get_attribute_str($attributes) {
1594 1594
 	$attribute_str = '';
1595 1595
 
1596
-	if ( empty( $attributes ) ) {
1596
+	if (empty($attributes)) {
1597 1597
 		return $attribute_str;
1598 1598
 	}
1599 1599
 
1600
-	foreach ( $attributes as $tag => $value ) {
1600
+	foreach ($attributes as $tag => $value) {
1601 1601
 		$attribute_str .= " {$tag}=\"{$value}\"";
1602 1602
 	}
1603 1603
 
1604
-	return trim( $attribute_str );
1604
+	return trim($attribute_str);
1605 1605
 }
1606 1606
 
1607 1607
 /**
@@ -1614,7 +1614,7 @@  discard block
 block discarded – undo
1614 1614
 function give_get_wp_upload_dir() {
1615 1615
 	$wp_upload_dir = wp_upload_dir();
1616 1616
 
1617
-	return ( ! empty( $wp_upload_dir['path'] ) ? $wp_upload_dir['path'] : false );
1617
+	return ( ! empty($wp_upload_dir['path']) ? $wp_upload_dir['path'] : false);
1618 1618
 }
1619 1619
 
1620 1620
 /**
@@ -1626,15 +1626,15 @@  discard block
 block discarded – undo
1626 1626
  *
1627 1627
  * @return string/bool $file_contents File content
1628 1628
  */
1629
-function give_get_core_settings_json( $file_name ) {
1629
+function give_get_core_settings_json($file_name) {
1630 1630
 	$upload_dir = give_get_wp_upload_dir();
1631
-	$file_path  = $upload_dir . '/' . $file_name;
1631
+	$file_path  = $upload_dir.'/'.$file_name;
1632 1632
 
1633
-	if ( is_wp_error( $file_path ) || empty( $file_path ) ) {
1634
-		Give_Admin_Settings::add_error( 'give-import-csv', __( 'Please upload or provide a valid JSON file.', 'give' ) );
1633
+	if (is_wp_error($file_path) || empty($file_path)) {
1634
+		Give_Admin_Settings::add_error('give-import-csv', __('Please upload or provide a valid JSON file.', 'give'));
1635 1635
 	}
1636 1636
 
1637
-	$file_contents = file_get_contents( $file_path );
1637
+	$file_contents = file_get_contents($file_path);
1638 1638
 
1639 1639
 	return $file_contents;
1640 1640
 }
@@ -1647,7 +1647,7 @@  discard block
 block discarded – undo
1647 1647
  * @return int $country The two letter country code for the site's base country
1648 1648
  */
1649 1649
 function give_get_limit_display_donations() {
1650
-	return give_get_option( 'limit_display_donations', 1 );
1650
+	return give_get_option('limit_display_donations', 1);
1651 1651
 }
1652 1652
 
1653 1653
 /**
@@ -1656,7 +1656,7 @@  discard block
 block discarded – undo
1656 1656
  * @since 1.8.17
1657 1657
  */
1658 1658
 function give_donation_history_table_end() {
1659
-	$email = Give()->session->get( 'give_email' );
1659
+	$email = Give()->session->get('give_email');
1660 1660
 	?>
1661 1661
 	<tfoot>
1662 1662
 	<tr>
@@ -1665,16 +1665,16 @@  discard block
 block discarded – undo
1665 1665
 				<div class="give-security-column give-security-description-wrap">
1666 1666
 					<?php
1667 1667
 					echo sprintf(
1668
-						__( 'For security reasons, please confirm your email address (%s) to view your complete donation history.', 'give' ),
1668
+						__('For security reasons, please confirm your email address (%s) to view your complete donation history.', 'give'),
1669 1669
 						$email
1670 1670
 					);
1671 1671
 					?>
1672 1672
 				</div>
1673 1673
 				<div class="give-security-column give-security-button-wrap">
1674 1674
 					<a href="#" data-email="<?php echo $email; ?>" id="give-confirm-email-btn" class="give-confirm-email-btn give-btn">
1675
-						<?php _e( 'Confirm Email', 'give' ); ?>
1675
+						<?php _e('Confirm Email', 'give'); ?>
1676 1676
 					</a>
1677
-					<span><?php _e( 'Email Sent!', 'give' ); ?></span>
1677
+					<span><?php _e('Email Sent!', 'give'); ?></span>
1678 1678
 				</div>
1679 1679
 			</div>
1680 1680
 		</td>
@@ -1694,10 +1694,10 @@  discard block
 block discarded – undo
1694 1694
  *
1695 1695
  * @return void
1696 1696
  */
1697
-function give_doing_it_wrong( $function, $message, $version ) {
1698
-	$message .= "\nBacktrace:" . wp_debug_backtrace_summary();
1697
+function give_doing_it_wrong($function, $message, $version) {
1698
+	$message .= "\nBacktrace:".wp_debug_backtrace_summary();
1699 1699
 
1700
-	_doing_it_wrong( $function, $message , $version );
1700
+	_doing_it_wrong($function, $message, $version);
1701 1701
 }
1702 1702
 
1703 1703
 
@@ -1706,10 +1706,10 @@  discard block
 block discarded – undo
1706 1706
  *
1707 1707
  * @since 1.8.18
1708 1708
  */
1709
-function give_ignore_user_abort(){
1710
-	ignore_user_abort( true );
1709
+function give_ignore_user_abort() {
1710
+	ignore_user_abort(true);
1711 1711
 
1712
-	if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
1713
-		set_time_limit( 0 );
1712
+	if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
1713
+		set_time_limit(0);
1714 1714
 	}
1715 1715
 }
1716 1716
\ No newline at end of file
Please login to merge, or discard this patch.
includes/formatting.php 1 patch
Spacing   +185 added lines, -189 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -23,37 +23,37 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @return mixed
25 25
  */
26
-function give_get_currency_formatting_settings( $id_or_currency_code = null ) {
26
+function give_get_currency_formatting_settings($id_or_currency_code = null) {
27 27
 	$give_options = give_get_settings();
28 28
 	$setting      = array();
29 29
 
30
-	if ( ! empty( $id_or_currency_code ) ) {
31
-		$currencies = give_get_currencies( 'all' );
30
+	if ( ! empty($id_or_currency_code)) {
31
+		$currencies = give_get_currencies('all');
32 32
 
33 33
 		// Set default formatting setting only if currency not set as global currency.
34 34
 		if (
35
-			is_string( $id_or_currency_code ) &&
36
-			! empty( $give_options['currency'] ) &&
35
+			is_string($id_or_currency_code) &&
36
+			! empty($give_options['currency']) &&
37 37
 			$id_or_currency_code !== $give_options['currency'] &&
38
-			array_key_exists( $id_or_currency_code, $currencies )
38
+			array_key_exists($id_or_currency_code, $currencies)
39 39
 		) {
40
-			$setting = $currencies[ $id_or_currency_code ]['setting'];
41
-		} elseif ( is_numeric( $id_or_currency_code ) && 'give_payment' === get_post_type( $id_or_currency_code ) ) {
42
-			$donation_meta = give_get_meta( $id_or_currency_code, '_give_payment_meta', true );
40
+			$setting = $currencies[$id_or_currency_code]['setting'];
41
+		} elseif (is_numeric($id_or_currency_code) && 'give_payment' === get_post_type($id_or_currency_code)) {
42
+			$donation_meta = give_get_meta($id_or_currency_code, '_give_payment_meta', true);
43 43
 
44 44
 			if (
45
-				! empty( $donation_meta['currency'] ) &&
45
+				! empty($donation_meta['currency']) &&
46 46
 				$give_options['currency'] !== $donation_meta['currency']
47 47
 			) {
48
-				$setting = $currencies[ $donation_meta['currency'] ]['setting'];
48
+				$setting = $currencies[$donation_meta['currency']]['setting'];
49 49
 			}
50 50
 		}
51 51
 	}
52 52
 
53
-	if ( empty( $setting ) ) {
53
+	if (empty($setting)) {
54 54
 		// Set thousand separator.
55
-		$thousand_separator = isset( $give_options['thousands_separator'] ) ? $give_options['thousands_separator'] : ',';
56
-		$thousand_separator = empty( $thousand_separator ) ? ' ' : $thousand_separator;
55
+		$thousand_separator = isset($give_options['thousands_separator']) ? $give_options['thousands_separator'] : ',';
56
+		$thousand_separator = empty($thousand_separator) ? ' ' : $thousand_separator;
57 57
 
58 58
 		// Set decimal separator.
59 59
 		$default_decimal_separators = array(
@@ -61,17 +61,16 @@  discard block
 block discarded – undo
61 61
 			',' => '.',
62 62
 		);
63 63
 
64
-		$default_decimal_separator = in_array( $thousand_separator, $default_decimal_separators ) ?
65
-			$default_decimal_separators[ $thousand_separator ] :
66
-			'.';
64
+		$default_decimal_separator = in_array($thousand_separator, $default_decimal_separators) ?
65
+			$default_decimal_separators[$thousand_separator] : '.';
67 66
 
68
-		$decimal_separator = ! empty( $give_options['decimal_separator'] ) ? $give_options['decimal_separator'] : $default_decimal_separator;
67
+		$decimal_separator = ! empty($give_options['decimal_separator']) ? $give_options['decimal_separator'] : $default_decimal_separator;
69 68
 
70 69
 		$setting = array(
71
-			'currency_position'   => give_get_option( 'currency_position', 'before' ),
70
+			'currency_position'   => give_get_option('currency_position', 'before'),
72 71
 			'thousands_separator' => $thousand_separator,
73 72
 			'decimal_separator'   => $decimal_separator,
74
-			'number_decimals'     => give_get_option( 'number_decimals', 0 ),
73
+			'number_decimals'     => give_get_option('number_decimals', 0),
75 74
 		);
76 75
 	}
77 76
 
@@ -80,7 +79,7 @@  discard block
 block discarded – undo
80 79
 	 *
81 80
 	 * @since 1.8.15
82 81
 	 */
83
-	return apply_filters( 'give_get_currency_formatting_settings', $setting, $id_or_currency_code );
82
+	return apply_filters('give_get_currency_formatting_settings', $setting, $id_or_currency_code);
84 83
 }
85 84
 
86 85
 /**
@@ -92,16 +91,16 @@  discard block
 block discarded – undo
92 91
  *
93 92
  * @return mixed
94 93
  */
95
-function give_get_price_decimals( $id_or_currency_code = null ) {
94
+function give_get_price_decimals($id_or_currency_code = null) {
96 95
 	// Set currency on basis of donation id.
97
-	if ( empty( $id_or_currency_code ) ) {
96
+	if (empty($id_or_currency_code)) {
98 97
 		$id_or_currency_code = give_get_currency();
99 98
 	}
100 99
 
101 100
 	$number_of_decimals = 0;
102 101
 
103
-	if ( ! give_is_zero_based_currency( $id_or_currency_code ) ) {
104
-		$setting            = give_get_currency_formatting_settings( $id_or_currency_code );
102
+	if ( ! give_is_zero_based_currency($id_or_currency_code)) {
103
+		$setting            = give_get_currency_formatting_settings($id_or_currency_code);
105 104
 		$number_of_decimals = $setting['number_decimals'];
106 105
 	}
107 106
 
@@ -110,7 +109,7 @@  discard block
 block discarded – undo
110 109
 	 *
111 110
 	 * @since 1.6
112 111
 	 */
113
-	return apply_filters( 'give_sanitize_amount_decimals', $number_of_decimals, $id_or_currency_code );
112
+	return apply_filters('give_sanitize_amount_decimals', $number_of_decimals, $id_or_currency_code);
114 113
 }
115 114
 
116 115
 /**
@@ -122,15 +121,15 @@  discard block
 block discarded – undo
122 121
  *
123 122
  * @return mixed
124 123
  */
125
-function give_get_price_thousand_separator( $id_or_currency_code = null ) {
126
-	$setting = give_get_currency_formatting_settings( $id_or_currency_code );
124
+function give_get_price_thousand_separator($id_or_currency_code = null) {
125
+	$setting = give_get_currency_formatting_settings($id_or_currency_code);
127 126
 
128 127
 	/**
129 128
 	 * Filter the thousand separator
130 129
 	 *
131 130
 	 * @since 1.6
132 131
 	 */
133
-	return apply_filters( 'give_get_price_thousand_separator', $setting['thousands_separator'], $id_or_currency_code );
132
+	return apply_filters('give_get_price_thousand_separator', $setting['thousands_separator'], $id_or_currency_code);
134 133
 }
135 134
 
136 135
 /**
@@ -142,15 +141,15 @@  discard block
 block discarded – undo
142 141
  *
143 142
  * @return mixed
144 143
  */
145
-function give_get_price_decimal_separator( $id_or_currency_code = null ) {
146
-	$setting = give_get_currency_formatting_settings( $id_or_currency_code );
144
+function give_get_price_decimal_separator($id_or_currency_code = null) {
145
+	$setting = give_get_currency_formatting_settings($id_or_currency_code);
147 146
 
148 147
 	/**
149 148
 	 * Filter the thousand separator
150 149
 	 *
151 150
 	 * @since 1.6
152 151
 	 */
153
-	return apply_filters( 'give_get_price_decimal_separator', $setting['decimal_separator'], $id_or_currency_code );
152
+	return apply_filters('give_get_price_decimal_separator', $setting['decimal_separator'], $id_or_currency_code);
154 153
 }
155 154
 
156 155
 
@@ -163,8 +162,8 @@  discard block
 block discarded – undo
163 162
  *
164 163
  * @return string $amount Newly sanitized amount
165 164
  */
166
-function give_sanitize_amount_for_db( $number ) {
167
-	return give_maybe_sanitize_amount( $number, array( 'number_decimals' => 6 ) );
165
+function give_sanitize_amount_for_db($number) {
166
+	return give_maybe_sanitize_amount($number, array('number_decimals' => 6));
168 167
 }
169 168
 
170 169
 /**
@@ -177,19 +176,19 @@  discard block
 block discarded – undo
177 176
  *
178 177
  * @return string $amount Newly sanitized amount
179 178
  */
180
-function give_maybe_sanitize_amount( $number, $args = array() ) {
179
+function give_maybe_sanitize_amount($number, $args = array()) {
181 180
 	// Bailout.
182
-	if ( empty( $number ) || ( ! is_numeric( $number ) && ! is_string( $number ) ) ) {
181
+	if (empty($number) || ( ! is_numeric($number) && ! is_string($number))) {
183 182
 		return $number;
184 183
 	}
185 184
 
186 185
 	$func_args = func_get_args();
187 186
 
188 187
 	// Backward compatibility.
189
-	if ( isset( $func_args[1] ) && ( is_bool( $func_args[1] ) || is_numeric( $func_args[1] ) ) ) {
188
+	if (isset($func_args[1]) && (is_bool($func_args[1]) || is_numeric($func_args[1]))) {
190 189
 		$args = array(
191 190
 			'number_decimals' => $func_args[1],
192
-			'trim_zeros'      => isset( $func_args[2] ) ? $func_args[2] : false,
191
+			'trim_zeros'      => isset($func_args[2]) ? $func_args[2] : false,
193 192
 		);
194 193
 	}
195 194
 
@@ -202,23 +201,22 @@  discard block
 block discarded – undo
202 201
 		)
203 202
 	);
204 203
 
205
-	$thousand_separator = give_get_price_thousand_separator( $args['currency'] );
206
-	$decimal_separator  = give_get_price_decimal_separator( $args['currency'] );
207
-	$number_decimals    = is_bool( $args['number_decimals'] ) ?
208
-		give_get_price_decimals() :
209
-		$args['number_decimals'];
204
+	$thousand_separator = give_get_price_thousand_separator($args['currency']);
205
+	$decimal_separator  = give_get_price_decimal_separator($args['currency']);
206
+	$number_decimals    = is_bool($args['number_decimals']) ?
207
+		give_get_price_decimals() : $args['number_decimals'];
210 208
 
211 209
 	// Explode number by . decimal separator.
212
-	$number_parts = explode( '.', $number );
210
+	$number_parts = explode('.', $number);
213 211
 
214 212
 	// Remove currency symbols from number if any.
215
-	$number = trim( str_replace( give_currency_symbols( true ), '', $number ) );
213
+	$number = trim(str_replace(give_currency_symbols(true), '', $number));
216 214
 
217 215
 	if (
218 216
 		// Non formatted number.
219 217
 		(
220
-			( false === strpos( $number, $thousand_separator ) ) &&
221
-			( false === strpos( $number, $decimal_separator ) )
218
+			(false === strpos($number, $thousand_separator)) &&
219
+			(false === strpos($number, $decimal_separator))
222 220
 		) ||
223 221
 
224 222
 		// Decimal formatted number.
@@ -228,35 +226,35 @@  discard block
 block discarded – undo
228 226
 		(
229 227
 			$number_decimals &&
230 228
 			'.' === $thousand_separator &&
231
-			false !== strpos( $number, $thousand_separator ) &&
232
-			false === strpos( $number, $decimal_separator ) &&
233
-			2 === count( $number_parts ) &&
234
-			( $number_decimals >= strlen( $number_parts[1] ) )
229
+			false !== strpos($number, $thousand_separator) &&
230
+			false === strpos($number, $decimal_separator) &&
231
+			2 === count($number_parts) &&
232
+			($number_decimals >= strlen($number_parts[1]))
235 233
 		)
236 234
 	) {
237
-		return number_format( $number, $number_decimals, '.', '' );
235
+		return number_format($number, $number_decimals, '.', '');
238 236
 	}
239 237
 
240 238
 	// Handle thousand separator as '.'
241 239
 	// Handle sanitize database values.
242
-	$is_db_sanitize_val = ( 2 === count( $number_parts ) &&
243
-							is_numeric( $number_parts[0] ) &&
244
-							is_numeric( $number_parts[1] ) &&
245
-							( 6 === strlen( $number_parts[1] ) ) );
240
+	$is_db_sanitize_val = (2 === count($number_parts) &&
241
+							is_numeric($number_parts[0]) &&
242
+							is_numeric($number_parts[1]) &&
243
+							(6 === strlen($number_parts[1])));
246 244
 
247
-	if ( $is_db_sanitize_val ) {
245
+	if ($is_db_sanitize_val) {
248 246
 		// Sanitize database value.
249
-		return number_format( $number, $number_decimals, '.', '' );
247
+		return number_format($number, $number_decimals, '.', '');
250 248
 
251 249
 	} elseif (
252 250
 		'.' === $thousand_separator &&
253
-		false !== strpos( $number, $thousand_separator )
251
+		false !== strpos($number, $thousand_separator)
254 252
 	) {
255 253
 		// Fix point thousand separator value.
256
-		$number = str_replace( '.', '', $number );
254
+		$number = str_replace('.', '', $number);
257 255
 	}
258 256
 
259
-	return give_sanitize_amount( $number, $args );
257
+	return give_sanitize_amount($number, $args);
260 258
 }
261 259
 
262 260
 /**
@@ -273,10 +271,10 @@  discard block
 block discarded – undo
273 271
  *
274 272
  * @return string $amount Newly sanitized amount
275 273
  */
276
-function give_sanitize_amount( $number, $args = array() ) {
274
+function give_sanitize_amount($number, $args = array()) {
277 275
 
278 276
 	// Bailout.
279
-	if ( empty( $number ) || ( ! is_numeric( $number ) && ! is_string( $number ) ) ) {
277
+	if (empty($number) || ( ! is_numeric($number) && ! is_string($number))) {
280 278
 		return $number;
281 279
 	}
282 280
 
@@ -284,10 +282,10 @@  discard block
 block discarded – undo
284 282
 	$func_args = func_get_args();
285 283
 
286 284
 	// Backward compatibility.
287
-	if ( isset( $func_args[1] ) && ( is_bool( $func_args[1] ) || is_numeric( $func_args[1] ) ) ) {
285
+	if (isset($func_args[1]) && (is_bool($func_args[1]) || is_numeric($func_args[1]))) {
288 286
 		$args = array(
289 287
 			'number_decimals' => $func_args[1],
290
-			'trim_zeros'      => isset( $func_args[2] ) ? $func_args[2] : false,
288
+			'trim_zeros'      => isset($func_args[2]) ? $func_args[2] : false,
291 289
 		);
292 290
 	}
293 291
 
@@ -303,58 +301,58 @@  discard block
 block discarded – undo
303 301
 	// Remove slash from amount.
304 302
 	// If thousand or decimal separator is set to ' then in $_POST or $_GET param we will get an escaped number.
305 303
 	// To prevent notices and warning remove slash from amount/number.
306
-	$number = wp_unslash( $number );
304
+	$number = wp_unslash($number);
307 305
 
308
-	$thousand_separator = give_get_price_thousand_separator( $args['currency'] );
306
+	$thousand_separator = give_get_price_thousand_separator($args['currency']);
309 307
 
310 308
 	$locale   = localeconv();
311 309
 	$decimals = array(
312
-		give_get_price_decimal_separator( $args['currency'] ),
310
+		give_get_price_decimal_separator($args['currency']),
313 311
 		$locale['decimal_point'],
314 312
 		$locale['mon_decimal_point'],
315 313
 	);
316 314
 
317 315
 	// Remove locale from string
318
-	if ( ! is_float( $number ) ) {
319
-		$number = str_replace( $decimals, '.', $number );
316
+	if ( ! is_float($number)) {
317
+		$number = str_replace($decimals, '.', $number);
320 318
 	}
321 319
 
322 320
 	// Remove thousand amount formatting if amount has.
323 321
 	// This condition use to add backward compatibility to version before 1.6, because before version 1.6 we were saving formatted amount to db.
324 322
 	// Do not replace thousand separator from price if it is same as decimal separator, because it will be already replace by above code.
325
-	if ( ! in_array( $thousand_separator, $decimals ) && ( false !== strpos( $number, $thousand_separator ) ) ) {
326
-		$number = str_replace( $thousand_separator, '', $number );
327
-	} elseif ( in_array( $thousand_separator, $decimals ) ) {
328
-		$number = preg_replace( '/\.(?=.*\.)/', '', $number );
323
+	if ( ! in_array($thousand_separator, $decimals) && (false !== strpos($number, $thousand_separator))) {
324
+		$number = str_replace($thousand_separator, '', $number);
325
+	} elseif (in_array($thousand_separator, $decimals)) {
326
+		$number = preg_replace('/\.(?=.*\.)/', '', $number);
329 327
 	}
330 328
 
331 329
 	// Remove non numeric entity before decimal separator.
332
-	$number     = preg_replace( '/[^0-9\.]/', '', $number );
333
-	$default_dp = give_get_price_decimals( $args['currency'] );
330
+	$number     = preg_replace('/[^0-9\.]/', '', $number);
331
+	$default_dp = give_get_price_decimals($args['currency']);
334 332
 
335 333
 	// Reset negative amount to zero.
336
-	if ( 0 > $number ) {
337
-		$number = number_format( 0, $default_dp, '.' );
334
+	if (0 > $number) {
335
+		$number = number_format(0, $default_dp, '.');
338 336
 	}
339 337
 
340 338
 	// If number does not have decimal then add number of decimals to it.
341 339
 	if (
342
-		false === strpos( $number, '.' )
343
-		|| ( $default_dp > strlen( substr( $number, strpos( $number, '.' ) + 1 ) ) )
340
+		false === strpos($number, '.')
341
+		|| ($default_dp > strlen(substr($number, strpos($number, '.') + 1)))
344 342
 	) {
345
-		$number = number_format( $number, $default_dp, '.', '' );
343
+		$number = number_format($number, $default_dp, '.', '');
346 344
 	}
347 345
 
348 346
 	// Format number by custom number of decimals.
349
-	if ( false !== $args['number_decimals'] ) {
350
-		$dp     = intval( is_bool( $args['number_decimals'] ) ? $default_dp : $args['number_decimals'] );
351
-		$dp     = apply_filters( 'give_sanitize_amount_decimals', $dp, $number );
352
-		$number = number_format( floatval( $number ), $dp, '.', '' );
347
+	if (false !== $args['number_decimals']) {
348
+		$dp     = intval(is_bool($args['number_decimals']) ? $default_dp : $args['number_decimals']);
349
+		$dp     = apply_filters('give_sanitize_amount_decimals', $dp, $number);
350
+		$number = number_format(floatval($number), $dp, '.', '');
353 351
 	}
354 352
 
355 353
 	// Trim zeros.
356
-	if ( $args['trim_zeros'] && strstr( $number, '.' ) ) {
357
-		$number = rtrim( rtrim( $number, '0' ), '.' );
354
+	if ($args['trim_zeros'] && strstr($number, '.')) {
355
+		$number = rtrim(rtrim($number, '0'), '.');
358 356
 	}
359 357
 
360 358
 	/**
@@ -362,7 +360,7 @@  discard block
 block discarded – undo
362 360
 	 *
363 361
 	 * @since 1.0
364 362
 	 */
365
-	return apply_filters( 'give_sanitize_amount', $number );
363
+	return apply_filters('give_sanitize_amount', $number);
366 364
 }
367 365
 
368 366
 /**
@@ -375,9 +373,9 @@  discard block
 block discarded – undo
375 373
  *
376 374
  * @return string $amount   Newly formatted amount or Price Not Available
377 375
  */
378
-function give_format_amount( $amount, $args = array() ) {
376
+function give_format_amount($amount, $args = array()) {
379 377
 	// Backward compatibility.
380
-	if ( is_bool( $args ) ) {
378
+	if (is_bool($args)) {
381 379
 		$args = array(
382 380
 			'decimal' => $args,
383 381
 		);
@@ -390,61 +388,60 @@  discard block
 block discarded – undo
390 388
 		'currency'    => '',
391 389
 	);
392 390
 
393
-	$args = wp_parse_args( $args, $default_args );
391
+	$args = wp_parse_args($args, $default_args);
394 392
 
395 393
 	// Set Currency based on donation id, if required.
396
-	if ( $args['donation_id'] && empty( $args['currency'] ) ) {
397
-		$donation_meta    = give_get_meta( $args['donation_id'], '_give_payment_meta', true );
394
+	if ($args['donation_id'] && empty($args['currency'])) {
395
+		$donation_meta    = give_get_meta($args['donation_id'], '_give_payment_meta', true);
398 396
 		$args['currency'] = $donation_meta['currency'];
399 397
 	}
400 398
 
401 399
 	$formatted     = 0;
402
-	$currency      = ! empty( $args['currency'] ) ? $args['currency'] : give_get_currency( $args['donation_id'] );
403
-	$thousands_sep = give_get_price_thousand_separator( $currency );
404
-	$decimal_sep   = give_get_price_decimal_separator( $currency );
405
-	$decimals      = ! empty( $args['decimal'] ) ? give_get_price_decimals( $currency ) : 0;
400
+	$currency      = ! empty($args['currency']) ? $args['currency'] : give_get_currency($args['donation_id']);
401
+	$thousands_sep = give_get_price_thousand_separator($currency);
402
+	$decimal_sep   = give_get_price_decimal_separator($currency);
403
+	$decimals      = ! empty($args['decimal']) ? give_get_price_decimals($currency) : 0;
406 404
 
407
-	if ( ! empty( $amount ) ) {
405
+	if ( ! empty($amount)) {
408 406
 		// Sanitize amount before formatting.
409
-		$amount = ! empty( $args['sanitize'] ) ?
410
-			give_maybe_sanitize_amount( $amount, array( 'number_decimals' => $decimals, 'currency' => $currency ) ) :
411
-			number_format( $amount, $decimals, '.', '' );
407
+		$amount = ! empty($args['sanitize']) ?
408
+			give_maybe_sanitize_amount($amount, array('number_decimals' => $decimals, 'currency' => $currency)) : number_format($amount, $decimals, '.', '');
412 409
 
413
-		switch ( $currency ) {
410
+		switch ($currency) {
414 411
 			case 'INR':
415 412
 				$decimal_amount = '';
416 413
 
417 414
 				// Extract decimals from amount
418
-				if ( ( $pos = strpos( $amount, '.' ) ) !== false ) {
419
-					if ( ! empty( $decimals ) ) {
420
-						$decimal_amount = substr( round( substr( $amount, $pos ), $decimals ), 1 );
421
-						$amount         = substr( $amount, 0, $pos );
422
-
423
-						if ( ! $decimal_amount ) {
424
-							$decimal_amount = substr( "{$decimal_sep}0000000000", 0, ( $decimals + 1 ) );
425
-						} elseif ( ( $decimals + 1 ) > strlen( $decimal_amount ) ) {
426
-							$decimal_amount = substr( "{$decimal_amount}000000000", 0, ( $decimals + 1 ) );
415
+				if (($pos = strpos($amount, '.')) !== false) {
416
+					if ( ! empty($decimals)) {
417
+						$decimal_amount = substr(round(substr($amount, $pos), $decimals), 1);
418
+						$amount         = substr($amount, 0, $pos);
419
+
420
+						if ( ! $decimal_amount) {
421
+							$decimal_amount = substr("{$decimal_sep}0000000000", 0, ($decimals + 1));
422
+						} elseif (($decimals + 1) > strlen($decimal_amount)) {
423
+							$decimal_amount = substr("{$decimal_amount}000000000", 0, ($decimals + 1));
427 424
 						}
428 425
 					} else {
429
-						$amount = number_format( $amount, $decimals, $decimal_sep, '' );
426
+						$amount = number_format($amount, $decimals, $decimal_sep, '');
430 427
 					}
431 428
 				}
432 429
 
433 430
 				// Extract last 3 from amount
434
-				$result = substr( $amount, - 3 );
435
-				$amount = substr( $amount, 0, - 3 );
431
+				$result = substr($amount, - 3);
432
+				$amount = substr($amount, 0, - 3);
436 433
 
437 434
 				// Apply digits 2 by 2
438
-				while ( strlen( $amount ) > 0 ) {
439
-					$result = substr( $amount, - 2 ) . $thousands_sep . $result;
440
-					$amount = substr( $amount, 0, - 2 );
435
+				while (strlen($amount) > 0) {
436
+					$result = substr($amount, - 2).$thousands_sep.$result;
437
+					$amount = substr($amount, 0, - 2);
441 438
 				}
442 439
 
443
-				$formatted = $result . $decimal_amount;
440
+				$formatted = $result.$decimal_amount;
444 441
 				break;
445 442
 
446 443
 			default:
447
-				$formatted = number_format( $amount, $decimals, $decimal_sep, $thousands_sep );
444
+				$formatted = number_format($amount, $decimals, $decimal_sep, $thousands_sep);
448 445
 		}
449 446
 	}
450 447
 
@@ -453,7 +450,7 @@  discard block
 block discarded – undo
453 450
 	 *
454 451
 	 * @since 1.0
455 452
 	 */
456
-	return apply_filters( 'give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $currency, $args );
453
+	return apply_filters('give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep, $currency, $args);
457 454
 }
458 455
 
459 456
 
@@ -471,17 +468,17 @@  discard block
 block discarded – undo
471 468
  *
472 469
  * @return string  formatted amount number with large number names.
473 470
  */
474
-function give_human_format_large_amount( $amount, $args = array() ) {
471
+function give_human_format_large_amount($amount, $args = array()) {
475 472
 	// Sanitize amount.
476
-	$sanitize_amount = give_maybe_sanitize_amount( $amount );
473
+	$sanitize_amount = give_maybe_sanitize_amount($amount);
477 474
 
478 475
 	// Bailout.
479
-	if ( ! floatval( $sanitize_amount ) ) {
476
+	if ( ! floatval($sanitize_amount)) {
480 477
 		return '0';
481 478
 	};
482 479
 
483 480
 	// Set default currency;
484
-	if ( empty( $args['currency'] ) ) {
481
+	if (empty($args['currency'])) {
485 482
 		$args['currency'] = give_get_currency();
486 483
 	}
487 484
 
@@ -489,37 +486,37 @@  discard block
 block discarded – undo
489 486
 	$thousands_sep = give_get_price_thousand_separator();
490 487
 
491 488
 	// Explode amount to calculate name of large numbers.
492
-	$amount_array = explode( $thousands_sep, $amount );
489
+	$amount_array = explode($thousands_sep, $amount);
493 490
 
494 491
 	// Calculate amount parts count.
495
-	$amount_count_parts = count( $amount_array );
492
+	$amount_count_parts = count($amount_array);
496 493
 
497 494
 	// Human format amount (default).
498 495
 	$human_format_amount = $amount;
499 496
 
500
-	switch ( $args['currency'] ) {
497
+	switch ($args['currency']) {
501 498
 		case 'INR':
502 499
 			// Calculate large number formatted amount.
503
-			if ( 4 < $amount_count_parts ) {
504
-				$human_format_amount = sprintf( esc_html__( '%s arab', 'give' ), round( ( $sanitize_amount / 1000000000 ), 2 ) );
505
-			} elseif ( 3 < $amount_count_parts ) {
506
-				$human_format_amount = sprintf( esc_html__( '%s crore', 'give' ), round( ( $sanitize_amount / 10000000 ), 2 ) );
507
-			} elseif ( 2 < $amount_count_parts ) {
508
-				$human_format_amount = sprintf( esc_html__( '%s lakh', 'give' ), round( ( $sanitize_amount / 100000 ), 2 ) );
500
+			if (4 < $amount_count_parts) {
501
+				$human_format_amount = sprintf(esc_html__('%s arab', 'give'), round(($sanitize_amount / 1000000000), 2));
502
+			} elseif (3 < $amount_count_parts) {
503
+				$human_format_amount = sprintf(esc_html__('%s crore', 'give'), round(($sanitize_amount / 10000000), 2));
504
+			} elseif (2 < $amount_count_parts) {
505
+				$human_format_amount = sprintf(esc_html__('%s lakh', 'give'), round(($sanitize_amount / 100000), 2));
509 506
 			}
510 507
 			break;
511 508
 		default:
512 509
 			// Calculate large number formatted amount.
513
-			if ( 4 < $amount_count_parts ) {
514
-				$human_format_amount = sprintf( esc_html__( '%s trillion', 'give' ), round( ( $sanitize_amount / 1000000000000 ), 2 ) );
515
-			} elseif ( 3 < $amount_count_parts ) {
516
-				$human_format_amount = sprintf( esc_html__( '%s billion', 'give' ), round( ( $sanitize_amount / 1000000000 ), 2 ) );
517
-			} elseif ( 2 < $amount_count_parts ) {
518
-				$human_format_amount = sprintf( esc_html__( '%s million', 'give' ), round( ( $sanitize_amount / 1000000 ), 2 ) );
510
+			if (4 < $amount_count_parts) {
511
+				$human_format_amount = sprintf(esc_html__('%s trillion', 'give'), round(($sanitize_amount / 1000000000000), 2));
512
+			} elseif (3 < $amount_count_parts) {
513
+				$human_format_amount = sprintf(esc_html__('%s billion', 'give'), round(($sanitize_amount / 1000000000), 2));
514
+			} elseif (2 < $amount_count_parts) {
515
+				$human_format_amount = sprintf(esc_html__('%s million', 'give'), round(($sanitize_amount / 1000000), 2));
519 516
 			}
520 517
 	}
521 518
 
522
-	return apply_filters( 'give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount );
519
+	return apply_filters('give_human_format_large_amount', $human_format_amount, $amount, $sanitize_amount);
523 520
 }
524 521
 
525 522
 /**
@@ -533,17 +530,16 @@  discard block
 block discarded – undo
533 530
  *
534 531
  * @return string $amount Newly formatted amount or Price Not Available
535 532
  */
536
-function give_format_decimal( $amount, $dp = false, $sanitize = true ) {
533
+function give_format_decimal($amount, $dp = false, $sanitize = true) {
537 534
 	$decimal_separator = give_get_price_decimal_separator();
538 535
 	$formatted_amount  = $sanitize ?
539
-		give_maybe_sanitize_amount( $amount, array( 'number_decimals' => $dp ) ) :
540
-		number_format( $amount, ( is_bool( $dp ) ? give_get_price_decimals() : $dp ), '.', '' );
536
+		give_maybe_sanitize_amount($amount, array('number_decimals' => $dp)) : number_format($amount, (is_bool($dp) ? give_get_price_decimals() : $dp), '.', '');
541 537
 
542
-	if ( false !== strpos( $formatted_amount, '.' ) ) {
543
-		$formatted_amount = str_replace( '.', $decimal_separator, $formatted_amount );
538
+	if (false !== strpos($formatted_amount, '.')) {
539
+		$formatted_amount = str_replace('.', $decimal_separator, $formatted_amount);
544 540
 	}
545 541
 
546
-	return apply_filters( 'give_format_decimal', $formatted_amount, $amount, $decimal_separator );
542
+	return apply_filters('give_format_decimal', $formatted_amount, $amount, $decimal_separator);
547 543
 }
548 544
 
549 545
 /**
@@ -555,7 +551,7 @@  discard block
 block discarded – undo
555 551
  *
556 552
  * @return string                  Date format string
557 553
  */
558
-function give_date_format( $date_context = '' ) {
554
+function give_date_format($date_context = '') {
559 555
 	/**
560 556
 	 * Filter the date context
561 557
 	 *
@@ -576,19 +572,19 @@  discard block
 block discarded – undo
576 572
 	 *
577 573
 	 *    }
578 574
 	 */
579
-	$date_format_contexts = apply_filters( 'give_date_format_contexts', array() );
575
+	$date_format_contexts = apply_filters('give_date_format_contexts', array());
580 576
 
581 577
 	// Set date format to default date format.
582
-	$date_format = get_option( 'date_format' );
578
+	$date_format = get_option('date_format');
583 579
 
584 580
 	// Update date format if we have non empty date format context array and non empty date format string for that context.
585
-	if ( $date_context && ! empty( $date_format_contexts ) && array_key_exists( $date_context, $date_format_contexts ) ) {
586
-		$date_format = ! empty( $date_format_contexts[ $date_context ] )
587
-			? $date_format_contexts[ $date_context ]
581
+	if ($date_context && ! empty($date_format_contexts) && array_key_exists($date_context, $date_format_contexts)) {
582
+		$date_format = ! empty($date_format_contexts[$date_context])
583
+			? $date_format_contexts[$date_context]
588 584
 			: $date_format;
589 585
 	}
590 586
 
591
-	return apply_filters( 'give_date_format', $date_format );
587
+	return apply_filters('give_date_format', $date_format);
592 588
 }
593 589
 
594 590
 /**
@@ -602,8 +598,8 @@  discard block
 block discarded – undo
602 598
  *
603 599
  * @return string
604 600
  */
605
-function give_get_cache_key( $action, $query_args ) {
606
-	return Give_Cache::get_key( $action, $query_args );
601
+function give_get_cache_key($action, $query_args) {
602
+	return Give_Cache::get_key($action, $query_args);
607 603
 }
608 604
 
609 605
 /**
@@ -616,11 +612,11 @@  discard block
 block discarded – undo
616 612
  *
617 613
  * @return string|array
618 614
  */
619
-function give_clean( $var ) {
620
-	if ( is_array( $var ) ) {
621
-		return array_map( 'give_clean', $var );
615
+function give_clean($var) {
616
+	if (is_array($var)) {
617
+		return array_map('give_clean', $var);
622 618
 	} else {
623
-		return is_scalar( $var ) ? sanitize_text_field( $var ) : $var;
619
+		return is_scalar($var) ? sanitize_text_field($var) : $var;
624 620
 	}
625 621
 }
626 622
 
@@ -633,10 +629,10 @@  discard block
 block discarded – undo
633 629
  *
634 630
  * @return int
635 631
  */
636
-function give_let_to_num( $size ) {
637
-	$l   = substr( $size, - 1 );
638
-	$ret = substr( $size, 0, - 1 );
639
-	switch ( strtoupper( $l ) ) {
632
+function give_let_to_num($size) {
633
+	$l   = substr($size, - 1);
634
+	$ret = substr($size, 0, - 1);
635
+	switch (strtoupper($l)) {
640 636
 		case 'P':
641 637
 			$ret *= 1024;
642 638
 		case 'T':
@@ -663,22 +659,22 @@  discard block
 block discarded – undo
663 659
  *
664 660
  * @return bool
665 661
  */
666
-function give_validate_nonce( $nonce, $action = - 1, $wp_die_args = array() ) {
662
+function give_validate_nonce($nonce, $action = - 1, $wp_die_args = array()) {
667 663
 
668 664
 	// Verify nonce.
669
-	$verify_nonce = wp_verify_nonce( $nonce, $action );
665
+	$verify_nonce = wp_verify_nonce($nonce, $action);
670 666
 
671 667
 	// On ajax request send nonce verification status.
672
-	if ( wp_doing_ajax() ) {
668
+	if (wp_doing_ajax()) {
673 669
 		return $verify_nonce;
674 670
 	}
675 671
 
676
-	if ( ! $verify_nonce ) {
672
+	if ( ! $verify_nonce) {
677 673
 		$wp_die_args = wp_parse_args(
678 674
 			$wp_die_args,
679 675
 			array(
680
-				'message' => __( 'Nonce verification has failed.', 'give' ),
681
-				'title'   => __( 'Error', 'give' ),
676
+				'message' => __('Nonce verification has failed.', 'give'),
677
+				'title'   => __('Error', 'give'),
682 678
 				'args'    => array(
683 679
 					'response' => 403,
684 680
 				)
@@ -704,19 +700,19 @@  discard block
 block discarded – undo
704 700
  *
705 701
  * @return bool
706 702
  */
707
-function give_verify_donation_form_nonce( $nonce = '' ) {
703
+function give_verify_donation_form_nonce($nonce = '') {
708 704
 	// Get nonce key from donation.
709
-	$nonce   = empty( $nonce ) ? give_clean( $_POST['_wpnonce'] ) : $nonce;
710
-	$form_id = isset( $_POST['give-form-id'] ) ? absint( $_POST['give-form-id'] ) : 0;
705
+	$nonce   = empty($nonce) ? give_clean($_POST['_wpnonce']) : $nonce;
706
+	$form_id = isset($_POST['give-form-id']) ? absint($_POST['give-form-id']) : 0;
711 707
 
712 708
 	// Form nonce action.
713 709
 	$nonce_action = "donation_form_nonce_{$form_id}";
714 710
 
715 711
 	// Nonce validation.
716
-	$verify_nonce = give_validate_nonce( $nonce, $nonce_action );
712
+	$verify_nonce = give_validate_nonce($nonce, $nonce_action);
717 713
 
718
-	if ( ! $verify_nonce ) {
719
-		give_set_error( 'donation_form_nonce', __( 'Nonce verification has failed.', 'give' ) );
714
+	if ( ! $verify_nonce) {
715
+		give_set_error('donation_form_nonce', __('Nonce verification has failed.', 'give'));
720 716
 	}
721 717
 
722 718
 	return $verify_nonce;
@@ -736,43 +732,43 @@  discard block
 block discarded – undo
736 732
  *
737 733
  * @return mixed
738 734
  */
739
-function give_check_variable( $variable, $conditional = '', $default = false, $array_key_name = '' ) {
735
+function give_check_variable($variable, $conditional = '', $default = false, $array_key_name = '') {
740 736
 	// Get value from array if array key non empty.
741
-	if( empty( $array_key_name ) ) {
742
-		switch ( $conditional ) {
737
+	if (empty($array_key_name)) {
738
+		switch ($conditional) {
743 739
 			case 'isset_empty':
744
-				$variable = ( isset( $variable ) && ! empty( $variable ) ) ? $variable : $default;
740
+				$variable = (isset($variable) && ! empty($variable)) ? $variable : $default;
745 741
 				break;
746 742
 
747 743
 			case 'empty':
748
-				$variable = ! empty( $variable ) ? $variable : $default;
744
+				$variable = ! empty($variable) ? $variable : $default;
749 745
 				break;
750 746
 
751 747
 			case 'null':
752
-				$variable = ! is_null( $variable ) ? $variable : $default;
748
+				$variable = ! is_null($variable) ? $variable : $default;
753 749
 				break;
754 750
 
755 751
 			default:
756
-				$variable = isset( $variable ) ? $variable : $default;
752
+				$variable = isset($variable) ? $variable : $default;
757 753
 		}
758 754
 	} else {
759
-		$isset = array_key_exists( $array_key_name, $variable );
755
+		$isset = array_key_exists($array_key_name, $variable);
760 756
 
761
-		switch ( $conditional ) {
757
+		switch ($conditional) {
762 758
 			case 'isset_empty':
763
-				$variable = ( $isset && ! empty( $variable[ $array_key_name ] ) ) ? $variable[ $array_key_name ] : $default;
759
+				$variable = ($isset && ! empty($variable[$array_key_name])) ? $variable[$array_key_name] : $default;
764 760
 				break;
765 761
 
766 762
 			case 'empty':
767
-				$variable = ! empty( $variable[ $array_key_name ] ) ? $variable[ $array_key_name ] : $default;
763
+				$variable = ! empty($variable[$array_key_name]) ? $variable[$array_key_name] : $default;
768 764
 				break;
769 765
 
770 766
 			case 'null':
771
-				$variable = $isset && ! is_null( $variable[ $array_key_name ] ) ? $variable[ $array_key_name ] : $default;
767
+				$variable = $isset && ! is_null($variable[$array_key_name]) ? $variable[$array_key_name] : $default;
772 768
 				break;
773 769
 
774 770
 			default:
775
-				$variable = $isset && isset( $variable[ $array_key_name ] ) ? $variable[ $array_key_name ] : $default;
771
+				$variable = $isset && isset($variable[$array_key_name]) ? $variable[$array_key_name] : $default;
776 772
 		}
777 773
 	}
778 774
 
Please login to merge, or discard this patch.
includes/class-give-tooltips.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	 *
21 21
 	 * @return array
22 22
 	 */
23
-	private function set_toottip_args( $args ) {
23
+	private function set_toottip_args($args) {
24 24
 		$args = wp_parse_args(
25 25
 			$args,
26 26
 			array(
@@ -62,13 +62,13 @@  discard block
 block discarded – undo
62 62
 
63 63
 		// Auto set width of tooltip.
64 64
 		if (
65
-			! empty( $args['auto_width'] ) &&
66
-			! empty( $args['label'] ) &&
67
-			empty( $args['size'] )
65
+			! empty($args['auto_width']) &&
66
+			! empty($args['label']) &&
67
+			empty($args['size'])
68 68
 		) {
69
-			if ( 15 < str_word_count( $args['label'] ) ) {
69
+			if (15 < str_word_count($args['label'])) {
70 70
 				$args['size'] = 'large';
71
-			} elseif ( 7 < str_word_count( $args['label'] ) ) {
71
+			} elseif (7 < str_word_count($args['label'])) {
72 72
 				$args['size'] = 'medium';
73 73
 			}
74 74
 		}
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
 	 *
88 88
 	 * @return string
89 89
 	 */
90
-	public function render( $args ) {
91
-		$args = $this->set_toottip_args( $args );
90
+	public function render($args) {
91
+		$args = $this->set_toottip_args($args);
92 92
 
93 93
 		$tooltip_pos = array(
94 94
 			'top'          => 'hint--top',
@@ -118,21 +118,21 @@  discard block
 block discarded – undo
118 118
 		$args['attributes']['aria-label'] = $args['label'];
119 119
 
120 120
 		// Set classes.
121
-		$args['attributes']['class'] = ! empty( $args['attributes']['class'] ) ? $args['attributes']['class'] : '';
122
-		$args['attributes']['class'] .= " {$tooltip_pos[ $args['position'] ]}";
123
-		$args['attributes']['class'] .= ! empty( $args['status'] ) ? " {$tooltip_status[ $args['status'] ]}" : '';
124
-		$args['attributes']['class'] .= ! empty( $args['size'] ) ? " {$tooltip_size[ $args['size'] ]}" : '';
121
+		$args['attributes']['class'] = ! empty($args['attributes']['class']) ? $args['attributes']['class'] : '';
122
+		$args['attributes']['class'] .= " {$tooltip_pos[$args['position']]}";
123
+		$args['attributes']['class'] .= ! empty($args['status']) ? " {$tooltip_status[$args['status']]}" : '';
124
+		$args['attributes']['class'] .= ! empty($args['size']) ? " {$tooltip_size[$args['size']]}" : '';
125 125
 		$args['attributes']['class'] .= $args['show_always'] ? ' hint--always' : '';
126 126
 		$args['attributes']['class'] .= $args['round_edges'] ? ' hint--rounded' : '';
127 127
 		$args['attributes']['class'] .= $args['animate'] ? ' hint--bounce' : ' hint--no-animate';
128
-		$args['attributes']['class'] = trim( $args['attributes']['class'] );
128
+		$args['attributes']['class'] = trim($args['attributes']['class']);
129 129
 
130 130
 		// Set link attribute in tooltip has anchor tag.
131
-		if ( 'a' === $args['tag'] && ! empty( $args['link'] ) ) {
132
-			$args['attributes']['href'] = esc_url( $args['link'] );
131
+		if ('a' === $args['tag'] && ! empty($args['link'])) {
132
+			$args['attributes']['href'] = esc_url($args['link']);
133 133
 		}
134 134
 
135
-		return sprintf( '<%1$s %2$s rel="tooltip">%3$s</%1$s>', $args['tag'], give_get_attribute_str( $args['attributes'] ), $args['tag_content'] );
135
+		return sprintf('<%1$s %2$s rel="tooltip">%3$s</%1$s>', $args['tag'], give_get_attribute_str($args['attributes']), $args['tag_content']);
136 136
 	}
137 137
 
138 138
 
@@ -146,9 +146,9 @@  discard block
 block discarded – undo
146 146
 	 *
147 147
 	 * @return string
148 148
 	 */
149
-	function render_link( $args ) {
149
+	function render_link($args) {
150 150
 		$args['tag']    = 'a';
151
-		$tooltip_markup = $this->render( $args );
151
+		$tooltip_markup = $this->render($args);
152 152
 
153 153
 		return $tooltip_markup;
154 154
 	}
@@ -163,14 +163,14 @@  discard block
 block discarded – undo
163 163
 	 *
164 164
 	 * @return string
165 165
 	 */
166
-	function render_span( $args ) {
166
+	function render_span($args) {
167 167
 		// Set tooltip args from string.
168
-		if ( is_string( $args ) ) {
169
-			$args = array( 'label' => $args );
168
+		if (is_string($args)) {
169
+			$args = array('label' => $args);
170 170
 		}
171 171
 
172 172
 		$args['tag']    = 'span';
173
-		$tooltip_markup = $this->render( $args );
173
+		$tooltip_markup = $this->render($args);
174 174
 
175 175
 		return $tooltip_markup;
176 176
 	}
@@ -185,15 +185,15 @@  discard block
 block discarded – undo
185 185
 	 *
186 186
 	 * @return string
187 187
 	 */
188
-	function render_help( $args ) {
188
+	function render_help($args) {
189 189
 		// Set tooltip args from string.
190
-		if ( is_string( $args ) ) {
191
-			$args = array( 'label' => $args );
190
+		if (is_string($args)) {
191
+			$args = array('label' => $args);
192 192
 		}
193 193
 
194 194
 		$args['tag_content']         = '<i class="give-icon give-icon-question"></i>';
195 195
 		$args['attributes']['class'] = 'give-tooltip';
196
-		$tooltip_markup              = $this->render_span( $args );
196
+		$tooltip_markup              = $this->render_span($args);
197 197
 
198 198
 		return $tooltip_markup;
199 199
 	}
Please login to merge, or discard this patch.
includes/class-give-db-logs.php 1 patch
Spacing   +71 added lines, -73 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 		/* @var WPDB $wpdb */
36 36
 		global $wpdb;
37 37
 
38
-		$this->table_name  = $wpdb->prefix . 'give_logs';
38
+		$this->table_name  = $wpdb->prefix.'give_logs';
39 39
 		$this->primary_key = 'ID';
40 40
 		$this->version     = '1.0';
41 41
 
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
 	 * @return array  Default column values.
74 74
 	 */
75 75
 	public function get_column_defaults() {
76
-		$log_create_date     = current_time( 'mysql', 0 );
77
-		$log_create_date_gmt = get_gmt_from_date( $log_create_date );
76
+		$log_create_date     = current_time('mysql', 0);
77
+		$log_create_date_gmt = get_gmt_from_date($log_create_date);
78 78
 
79 79
 		return array(
80 80
 			'ID'           => 0,
@@ -97,39 +97,39 @@  discard block
 block discarded – undo
97 97
 	 *
98 98
 	 * @return bool|int
99 99
 	 */
100
-	public function add( $data = array() ) {
100
+	public function add($data = array()) {
101 101
 		// Valid table columns.
102
-		$table_columns = array_keys( $this->get_columns() );
102
+		$table_columns = array_keys($this->get_columns());
103 103
 
104 104
 		// Filter data.
105
-		foreach ( $data as $table_column => $column_data ) {
106
-			if ( ! in_array( $table_column, $table_columns ) ) {
107
-				unset( $data[ $table_column ] );
105
+		foreach ($data as $table_column => $column_data) {
106
+			if ( ! in_array($table_column, $table_columns)) {
107
+				unset($data[$table_column]);
108 108
 			}
109 109
 		}
110 110
 
111 111
 		// Set default values.
112
-		$current_log_data = wp_parse_args( $data, $this->get_column_defaults() );
112
+		$current_log_data = wp_parse_args($data, $this->get_column_defaults());
113 113
 
114 114
 		// Log parent should be an int.
115
-		$current_log_data['log_parent'] = absint( $current_log_data['log_parent'] );
115
+		$current_log_data['log_parent'] = absint($current_log_data['log_parent']);
116 116
 
117 117
 		// Get log.
118
-		$existing_log = $this->get_log_by( $current_log_data['ID'] );
118
+		$existing_log = $this->get_log_by($current_log_data['ID']);
119 119
 
120 120
 		// Update an existing log.
121
-		if ( $existing_log ) {
121
+		if ($existing_log) {
122 122
 
123 123
 			// Create new log data from existing and new log data.
124
-			$current_log_data = array_merge( $current_log_data, $existing_log );
124
+			$current_log_data = array_merge($current_log_data, $existing_log);
125 125
 
126 126
 			// Update log data.
127
-			$this->update( $current_log_data['ID'], $current_log_data );
127
+			$this->update($current_log_data['ID'], $current_log_data);
128 128
 
129 129
 			$log_id = $current_log_data['ID'];
130 130
 
131 131
 		} else {
132
-			$log_id = $this->insert( $current_log_data, 'log' );
132
+			$log_id = $this->insert($current_log_data, 'log');
133 133
 		}
134 134
 
135 135
 		return $log_id;
@@ -147,20 +147,20 @@  discard block
 block discarded – undo
147 147
 	 *
148 148
 	 * @return bool|null|array
149 149
 	 */
150
-	public function get_log_by( $log_id = 0, $by = 'id' ) {
150
+	public function get_log_by($log_id = 0, $by = 'id') {
151 151
 		/* @var WPDB $wpdb */
152 152
 		global $wpdb;
153 153
 		$log = null;
154 154
 
155 155
 		// Make sure $log_id is int.
156
-		$log_id = absint( $log_id );
156
+		$log_id = absint($log_id);
157 157
 
158 158
 		// Bailout.
159
-		if ( empty( $log_id ) ) {
159
+		if (empty($log_id)) {
160 160
 			return null;
161 161
 		}
162 162
 
163
-		switch ( $by ) {
163
+		switch ($by) {
164 164
 			case 'id':
165 165
 				$log = $wpdb->get_row(
166 166
 					$wpdb->prepare(
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 				break;
173 173
 
174 174
 			default:
175
-				$log = apply_filters( "give_get_log_by_{$by}", $log, $log_id );
175
+				$log = apply_filters("give_get_log_by_{$by}", $log, $log_id);
176 176
 		}
177 177
 
178 178
 		return $log;
@@ -188,14 +188,14 @@  discard block
 block discarded – undo
188 188
 	 *
189 189
 	 * @return mixed
190 190
 	 */
191
-	public function get_logs( $args = array() ) {
191
+	public function get_logs($args = array()) {
192 192
 		global $wpdb;
193
-		$sql_query = $this->get_sql( $args );
193
+		$sql_query = $this->get_sql($args);
194 194
 		
195 195
 		// Get log.
196
-		if ( ! ( $logs = Give_Cache::get( 'give_logs', true, $sql_query ) ) ) {
197
-			$logs = $wpdb->get_results( $sql_query );
198
-			Give_Cache::set( 'give_logs', $logs, 3600, true, $sql_query );
196
+		if ( ! ($logs = Give_Cache::get('give_logs', true, $sql_query))) {
197
+			$logs = $wpdb->get_results($sql_query);
198
+			Give_Cache::set('give_logs', $logs, 3600, true, $sql_query);
199 199
 		}
200 200
 
201 201
 		return $logs;
@@ -212,21 +212,21 @@  discard block
 block discarded – undo
212 212
 	 *
213 213
 	 * @return int
214 214
 	 */
215
-	public function count( $args = array() ) {
215
+	public function count($args = array()) {
216 216
 		/* @var WPDB $wpdb */
217 217
 		global $wpdb;
218 218
 		$args['number'] = - 1;
219 219
 		$args['fields'] = 'ID';
220 220
 		$args['count']  = true;
221 221
 
222
-		$sql_query = $this->get_sql( $args );
222
+		$sql_query = $this->get_sql($args);
223 223
 
224
-		if ( ! ( $count = Give_Cache::get( 'give_logs_count', true, $sql_query ) ) ) {
225
-			$count = $wpdb->get_var( $sql_query );
226
-			Give_Cache::set( 'give_logs_count', $count, 3600, true, $args );
224
+		if ( ! ($count = Give_Cache::get('give_logs_count', true, $sql_query))) {
225
+			$count = $wpdb->get_var($sql_query);
226
+			Give_Cache::set('give_logs_count', $count, 3600, true, $args);
227 227
 		}
228 228
 		
229
-		return absint( $count );
229
+		return absint($count);
230 230
 	}
231 231
 
232 232
 	/**
@@ -252,10 +252,10 @@  discard block
 block discarded – undo
252 252
         PRIMARY KEY  (ID)
253 253
         ) {$charset_collate};";
254 254
 
255
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
256
-		dbDelta( $sql );
255
+		require_once(ABSPATH.'wp-admin/includes/upgrade.php');
256
+		dbDelta($sql);
257 257
 
258
-		update_option( $this->table_name . '_db_version', $this->version );
258
+		update_option($this->table_name.'_db_version', $this->version);
259 259
 	}
260 260
 
261 261
 
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 	 *
270 270
 	 * @return string
271 271
 	 */
272
-	public function get_sql( $args = array() ) {
272
+	public function get_sql($args = array()) {
273 273
 		/* @var WPDB $wpdb */
274 274
 		global $wpdb;
275 275
 
@@ -283,12 +283,12 @@  discard block
 block discarded – undo
283 283
 			'count'   => false,
284 284
 		);
285 285
 
286
-		$args = wp_parse_args( $args, $defaults );
286
+		$args = wp_parse_args($args, $defaults);
287 287
 
288 288
 		// validate params.
289
-		$this->validate_params( $args );
289
+		$this->validate_params($args);
290 290
 
291
-		if ( $args['number'] < 1 ) {
291
+		if ($args['number'] < 1) {
292 292
 			$args['number'] = 999999999999;
293 293
 		}
294 294
 
@@ -296,78 +296,78 @@  discard block
 block discarded – undo
296 296
 		$where = '';
297 297
 
298 298
 		// Get sql query for meta.
299
-		if ( ! empty( $args['meta_query'] ) ) {
300
-			$meta_query_object = new WP_Meta_Query( $args['meta_query'] );
301
-			$meta_query        = $meta_query_object->get_sql( 'log', $this->table_name, 'id' );
302
-			$where             = implode( '', $meta_query );
299
+		if ( ! empty($args['meta_query'])) {
300
+			$meta_query_object = new WP_Meta_Query($args['meta_query']);
301
+			$meta_query        = $meta_query_object->get_sql('log', $this->table_name, 'id');
302
+			$where             = implode('', $meta_query);
303 303
 		}
304 304
 
305 305
 		$where .= ' WHERE 1=1 ';
306 306
 
307 307
 		// Set offset.
308
-		if ( empty( $args['offset'] ) && ( 0 < $args['paged'] ) ) {
309
-			$args['offset'] = $args['number'] * ( $args['paged'] - 1 );
308
+		if (empty($args['offset']) && (0 < $args['paged'])) {
309
+			$args['offset'] = $args['number'] * ($args['paged'] - 1);
310 310
 		}
311 311
 
312 312
 		// Set fields.
313 313
 		$fields = "{$this->table_name}.*";
314
-		if ( is_string( $args['fields'] ) && ( 'all' !== $args['fields'] ) ) {
314
+		if (is_string($args['fields']) && ('all' !== $args['fields'])) {
315 315
 			$fields = "{$this->table_name}.{$args['fields']}";
316 316
 		}
317 317
 
318 318
 		// Set count.
319
-		if ( $args['count'] ) {
319
+		if ($args['count']) {
320 320
 			$fields = "COUNT({$fields})";
321 321
 		}
322 322
 
323 323
 		// Specific logs.
324
-		if ( ! empty( $args['ID'] ) ) {
324
+		if ( ! empty($args['ID'])) {
325 325
 
326
-			if ( ! is_array( $args['ID'] ) ) {
327
-				$args['ID'] = explode( ',', $args['ID'] );
326
+			if ( ! is_array($args['ID'])) {
327
+				$args['ID'] = explode(',', $args['ID']);
328 328
 			}
329
-			$log_ids = implode( ',', array_map( 'intval', $args['ID'] ) );
329
+			$log_ids = implode(',', array_map('intval', $args['ID']));
330 330
 
331 331
 			$where .= " AND {$this->table_name}.ID IN( {$log_ids} ) ";
332 332
 		}
333 333
 
334 334
 		// Logs created for a specific date or in a date range
335
-		if ( ! empty( $args['date_query'] ) ) {
336
-			$date_query_object = new WP_Date_Query( $args['date_query'], "{$this->table_name}.log_date" );
337
-			$where             .= $date_query_object->get_sql();
335
+		if ( ! empty($args['date_query'])) {
336
+			$date_query_object = new WP_Date_Query($args['date_query'], "{$this->table_name}.log_date");
337
+			$where .= $date_query_object->get_sql();
338 338
 		}
339 339
 
340 340
 		// Logs create for specific parent.
341
-		if ( ! empty( $args['log_parent'] ) ) {
342
-			if ( ! is_array( $args['log_parent'] ) ) {
343
-				$args['log_parent'] = explode( ',', $args['log_parent'] );
341
+		if ( ! empty($args['log_parent'])) {
342
+			if ( ! is_array($args['log_parent'])) {
343
+				$args['log_parent'] = explode(',', $args['log_parent']);
344 344
 			}
345
-			$parent_ids = implode( ',', array_map( 'intval', $args['log_parent'] ) );
345
+			$parent_ids = implode(',', array_map('intval', $args['log_parent']));
346 346
 
347 347
 			$where .= " AND {$this->table_name}.log_parent IN( {$parent_ids} ) ";
348 348
 		}
349 349
 
350 350
 		// Logs create for specific type.
351 351
 		// is_array check is for backward compatibility.
352
-		if ( ! empty( $args['log_type'] ) && ! is_array( $args['log_type'] ) ) {
353
-			if ( ! is_array( $args['log_type'] ) ) {
354
-				$args['log_type'] = explode( ',', $args['log_type'] );
352
+		if ( ! empty($args['log_type']) && ! is_array($args['log_type'])) {
353
+			if ( ! is_array($args['log_type'])) {
354
+				$args['log_type'] = explode(',', $args['log_type']);
355 355
 			}
356 356
 
357
-			$log_types = implode( '\',\'', array_map( 'trim', $args['log_type'] ) );
357
+			$log_types = implode('\',\'', array_map('trim', $args['log_type']));
358 358
 
359 359
 			$where .= " AND {$this->table_name}.log_type IN( '{$log_types}' ) ";
360 360
 		}
361 361
 
362
-		$args['orderby'] = ! array_key_exists( $args['orderby'], $this->get_columns() ) ? 'log_date' : $args['orderby'];
362
+		$args['orderby'] = ! array_key_exists($args['orderby'], $this->get_columns()) ? 'log_date' : $args['orderby'];
363 363
 
364
-		$args['orderby'] = esc_sql( $args['orderby'] );
365
-		$args['order']   = esc_sql( $args['order'] );
364
+		$args['orderby'] = esc_sql($args['orderby']);
365
+		$args['order']   = esc_sql($args['order']);
366 366
 
367 367
 		return $wpdb->prepare(
368 368
 			"SELECT {$fields} FROM {$this->table_name} {$where} ORDER BY {$this->table_name}.{$args['orderby']} {$args['order']} LIMIT %d,%d;",
369
-			absint( $args['offset'] ),
370
-			absint( $args['number'] )
369
+			absint($args['offset']),
370
+			absint($args['number'])
371 371
 		);
372 372
 	}
373 373
 
@@ -382,13 +382,11 @@  discard block
 block discarded – undo
382 382
 	 *
383 383
 	 * @return mixed
384 384
 	 */
385
-	private function validate_params( &$args ) {
385
+	private function validate_params(&$args) {
386 386
 		// fields params
387 387
 		$args['fields'] = 'ids' === $args['fields'] ?
388
-			'ID' :
389
-			$args['fields'];
390
-		$args['fields'] = array_key_exists( $args['fields'], $this->get_columns() ) ?
391
-			$args['fields'] :
392
-			'all';
388
+			'ID' : $args['fields'];
389
+		$args['fields'] = array_key_exists($args['fields'], $this->get_columns()) ?
390
+			$args['fields'] : 'all';
393 391
 	}
394 392
 }
Please login to merge, or discard this patch.
includes/ajax-functions.php 1 patch
Spacing   +132 added lines, -132 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
 
@@ -26,31 +26,31 @@  discard block
 block discarded – undo
26 26
  */
27 27
 function give_test_ajax_works() {
28 28
 	// Handle ajax.
29
-	if( doing_action( 'wp_ajax_nopriv_give_test_ajax' ) ) {
30
-		wp_die( 0, 200 );
29
+	if (doing_action('wp_ajax_nopriv_give_test_ajax')) {
30
+		wp_die(0, 200);
31 31
 	}
32 32
 
33 33
 	// Check if the Airplane Mode plugin is installed.
34
-	if ( class_exists( 'Airplane_Mode_Core' ) ) {
34
+	if (class_exists('Airplane_Mode_Core')) {
35 35
 
36 36
 		$airplane = Airplane_Mode_Core::getInstance();
37 37
 
38
-		if ( method_exists( $airplane, 'enabled' ) ) {
38
+		if (method_exists($airplane, 'enabled')) {
39 39
 
40
-			if ( $airplane->enabled() ) {
40
+			if ($airplane->enabled()) {
41 41
 				return true;
42 42
 			}
43 43
 		} else {
44 44
 
45
-			if ( 'on' === $airplane->check_status() ) {
45
+			if ('on' === $airplane->check_status()) {
46 46
 				return true;
47 47
 			}
48 48
 		}
49 49
 	}
50 50
 
51
-	add_filter( 'block_local_requests', '__return_false' );
51
+	add_filter('block_local_requests', '__return_false');
52 52
 
53
-	if ( Give_Cache::get( '_give_ajax_works', true ) ) {
53
+	if (Give_Cache::get('_give_ajax_works', true)) {
54 54
 		return true;
55 55
 	}
56 56
 
@@ -62,41 +62,41 @@  discard block
 block discarded – undo
62 62
 		),
63 63
 	);
64 64
 
65
-	$ajax = wp_remote_post( give_get_ajax_url(), $params );
65
+	$ajax = wp_remote_post(give_get_ajax_url(), $params);
66 66
 
67 67
 	$works = true;
68 68
 
69
-	if ( is_wp_error( $ajax ) ) {
69
+	if (is_wp_error($ajax)) {
70 70
 
71 71
 		$works = false;
72 72
 
73 73
 	} else {
74 74
 
75
-		if ( empty( $ajax['response'] ) ) {
75
+		if (empty($ajax['response'])) {
76 76
 			$works = false;
77 77
 		}
78 78
 
79
-		if ( empty( $ajax['response']['code'] ) || 200 !== (int) $ajax['response']['code'] ) {
79
+		if (empty($ajax['response']['code']) || 200 !== (int) $ajax['response']['code']) {
80 80
 			$works = false;
81 81
 		}
82 82
 
83
-		if ( empty( $ajax['response']['message'] ) || 'OK' !== $ajax['response']['message'] ) {
83
+		if (empty($ajax['response']['message']) || 'OK' !== $ajax['response']['message']) {
84 84
 			$works = false;
85 85
 		}
86 86
 
87
-		if ( ! isset( $ajax['body'] ) || 0 !== (int) $ajax['body'] ) {
87
+		if ( ! isset($ajax['body']) || 0 !== (int) $ajax['body']) {
88 88
 			$works = false;
89 89
 		}
90 90
 	}
91 91
 
92
-	if ( $works ) {
93
-		Give_Cache::set( '_give_ajax_works', '1', DAY_IN_SECONDS, true );
92
+	if ($works) {
93
+		Give_Cache::set('_give_ajax_works', '1', DAY_IN_SECONDS, true);
94 94
 	}
95 95
 
96 96
 	return $works;
97 97
 }
98 98
 
99
-add_action( 'wp_ajax_nopriv_give_test_ajax', 'give_test_ajax_works' );
99
+add_action('wp_ajax_nopriv_give_test_ajax', 'give_test_ajax_works');
100 100
 
101 101
 /**
102 102
  * Get AJAX URL
@@ -107,21 +107,21 @@  discard block
 block discarded – undo
107 107
  *
108 108
  * @return string
109 109
  */
110
-function give_get_ajax_url( $query = array() ) {
111
-	$scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin';
110
+function give_get_ajax_url($query = array()) {
111
+	$scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin';
112 112
 
113 113
 	$current_url = give_get_current_page_url();
114
-	$ajax_url    = admin_url( 'admin-ajax.php', $scheme );
114
+	$ajax_url    = admin_url('admin-ajax.php', $scheme);
115 115
 
116
-	if ( preg_match( '/^https/', $current_url ) && ! preg_match( '/^https/', $ajax_url ) ) {
117
-		$ajax_url = preg_replace( '/^http/', 'https', $ajax_url );
116
+	if (preg_match('/^https/', $current_url) && ! preg_match('/^https/', $ajax_url)) {
117
+		$ajax_url = preg_replace('/^http/', 'https', $ajax_url);
118 118
 	}
119 119
 
120
-	if( ! empty( $query ) ) {
121
-		$ajax_url = add_query_arg( $query, $ajax_url );
120
+	if ( ! empty($query)) {
121
+		$ajax_url = add_query_arg($query, $ajax_url);
122 122
 	}
123 123
 
124
-	return apply_filters( 'give_ajax_url', $ajax_url );
124
+	return apply_filters('give_ajax_url', $ajax_url);
125 125
 }
126 126
 
127 127
 /**
@@ -137,12 +137,12 @@  discard block
 block discarded – undo
137 137
 	 *
138 138
 	 * @since 1.7
139 139
 	 */
140
-	do_action( 'give_donation_form_login_fields' );
140
+	do_action('give_donation_form_login_fields');
141 141
 
142 142
 	give_die();
143 143
 }
144 144
 
145
-add_action( 'wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields' );
145
+add_action('wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields');
146 146
 
147 147
 /**
148 148
  * Load Checkout Fields
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
  * @return void
153 153
  */
154 154
 function give_load_checkout_fields() {
155
-	$form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : '';
155
+	$form_id = isset($_POST['form_id']) ? $_POST['form_id'] : '';
156 156
 
157 157
 	ob_start();
158 158
 
@@ -161,18 +161,18 @@  discard block
 block discarded – undo
161 161
 	 *
162 162
 	 * @since 1.7
163 163
 	 */
164
-	do_action( 'give_donation_form_register_login_fields', $form_id );
164
+	do_action('give_donation_form_register_login_fields', $form_id);
165 165
 
166 166
 	$fields = ob_get_clean();
167 167
 
168
-	wp_send_json( array(
169
-		'fields' => wp_json_encode( $fields ),
170
-		'submit' => wp_json_encode( give_get_donation_form_submit_button( $form_id ) ),
171
-	) );
168
+	wp_send_json(array(
169
+		'fields' => wp_json_encode($fields),
170
+		'submit' => wp_json_encode(give_get_donation_form_submit_button($form_id)),
171
+	));
172 172
 }
173 173
 
174
-add_action( 'wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields' );
175
-add_action( 'wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields' );
174
+add_action('wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields');
175
+add_action('wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields');
176 176
 
177 177
 /**
178 178
  * Get Form Title via AJAX (used only in WordPress Admin)
@@ -182,9 +182,9 @@  discard block
 block discarded – undo
182 182
  * @return void
183 183
  */
184 184
 function give_ajax_get_form_title() {
185
-	if ( isset( $_POST['form_id'] ) ) {
186
-		$title = get_the_title( $_POST['form_id'] );
187
-		if ( $title ) {
185
+	if (isset($_POST['form_id'])) {
186
+		$title = get_the_title($_POST['form_id']);
187
+		if ($title) {
188 188
 			echo $title;
189 189
 		} else {
190 190
 			echo 'fail';
@@ -193,8 +193,8 @@  discard block
 block discarded – undo
193 193
 	give_die();
194 194
 }
195 195
 
196
-add_action( 'wp_ajax_give_get_form_title', 'give_ajax_get_form_title' );
197
-add_action( 'wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title' );
196
+add_action('wp_ajax_give_get_form_title', 'give_ajax_get_form_title');
197
+add_action('wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title');
198 198
 
199 199
 /**
200 200
  * Retrieve a states drop down
@@ -208,41 +208,41 @@  discard block
 block discarded – undo
208 208
 	$show_field     = true;
209 209
 	$states_require = true;
210 210
 	// Get the Country code from the $_POST.
211
-	$country = sanitize_text_field( $_POST['country'] );
211
+	$country = sanitize_text_field($_POST['country']);
212 212
 
213 213
 	// Get the field name from the $_POST.
214
-	$field_name = sanitize_text_field( $_POST['field_name'] );
214
+	$field_name = sanitize_text_field($_POST['field_name']);
215 215
 
216
-	$label        = __( 'State', 'give' );
216
+	$label        = __('State', 'give');
217 217
 	$states_label = give_get_states_label();
218 218
 
219 219
 	$default_state = '';
220
-	if ( $country === give_get_country() ) {
220
+	if ($country === give_get_country()) {
221 221
 		$default_state = give_get_state();
222 222
 	}
223 223
 
224 224
 	// Check if $country code exists in the array key for states label.
225
-	if ( array_key_exists( $country, $states_label ) ) {
226
-		$label = $states_label[ $country ];
225
+	if (array_key_exists($country, $states_label)) {
226
+		$label = $states_label[$country];
227 227
 	}
228 228
 
229
-	if ( empty( $country ) ) {
229
+	if (empty($country)) {
230 230
 		$country = give_get_country();
231 231
 	}
232 232
 
233
-	$states = give_get_states( $country );
234
-	if ( ! empty( $states ) ) {
235
-		$args         = array(
233
+	$states = give_get_states($country);
234
+	if ( ! empty($states)) {
235
+		$args = array(
236 236
 			'name'             => $field_name,
237 237
 			'id'               => $field_name,
238
-			'class'            => $field_name . '  give-select',
238
+			'class'            => $field_name.'  give-select',
239 239
 			'options'          => $states,
240 240
 			'show_option_all'  => false,
241 241
 			'show_option_none' => false,
242 242
 			'placeholder'      => $label,
243 243
 			'selected'         => $default_state,
244 244
 		);
245
-		$data         = Give()->html->select( $args );
245
+		$data         = Give()->html->select($args);
246 246
 		$states_found = true;
247 247
 	} else {
248 248
 		$data = 'nostates';
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 		$no_states_country = give_no_states_country_list();
252 252
 
253 253
 		// Check if $country code exists in the array key.
254
-		if ( array_key_exists( $country, $no_states_country ) ) {
254
+		if (array_key_exists($country, $no_states_country)) {
255 255
 			$show_field = false;
256 256
 		}
257 257
 
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 		$states_not_required_country_list = give_states_not_required_country_list();
260 260
 
261 261
 		// Check if $country code exists in the array key.
262
-		if ( array_key_exists( $country, $states_not_required_country_list ) ) {
262
+		if (array_key_exists($country, $states_not_required_country_list)) {
263 263
 			$states_require = false;
264 264
 		}
265 265
 	}
@@ -272,11 +272,11 @@  discard block
 block discarded – undo
272 272
 		'data'           => $data,
273 273
 		'default_state'  => $default_state,
274 274
 	);
275
-	wp_send_json( $response );
275
+	wp_send_json($response);
276 276
 }
277 277
 
278
-add_action( 'wp_ajax_give_get_states', 'give_ajax_get_states_field' );
279
-add_action( 'wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field' );
278
+add_action('wp_ajax_give_get_states', 'give_ajax_get_states_field');
279
+add_action('wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field');
280 280
 
281 281
 /**
282 282
  * Retrieve donation forms via AJAX for chosen dropdown search field.
@@ -288,19 +288,19 @@  discard block
 block discarded – undo
288 288
 function give_ajax_form_search() {
289 289
 	global $wpdb;
290 290
 
291
-	$search   = esc_sql( sanitize_text_field( $_GET['s'] ) );
292
-	$excludes = ( isset( $_GET['current_id'] ) ? (array) $_GET['current_id'] : array() );
291
+	$search   = esc_sql(sanitize_text_field($_GET['s']));
292
+	$excludes = (isset($_GET['current_id']) ? (array) $_GET['current_id'] : array());
293 293
 
294 294
 	$results = array();
295
-	if ( current_user_can( 'edit_give_forms' ) ) {
296
-		$items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50" );
295
+	if (current_user_can('edit_give_forms')) {
296
+		$items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50");
297 297
 	} else {
298
-		$items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50" );
298
+		$items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50");
299 299
 	}
300 300
 
301
-	if ( $items ) {
301
+	if ($items) {
302 302
 
303
-		foreach ( $items as $item ) {
303
+		foreach ($items as $item) {
304 304
 
305 305
 			$results[] = array(
306 306
 				'id'   => $item->ID,
@@ -311,18 +311,18 @@  discard block
 block discarded – undo
311 311
 
312 312
 		$items[] = array(
313 313
 			'id'   => 0,
314
-			'name' => __( 'No forms found.', 'give' ),
314
+			'name' => __('No forms found.', 'give'),
315 315
 		);
316 316
 
317 317
 	}
318 318
 
319
-	echo json_encode( $results );
319
+	echo json_encode($results);
320 320
 
321 321
 	give_die();
322 322
 }
323 323
 
324
-add_action( 'wp_ajax_give_form_search', 'give_ajax_form_search' );
325
-add_action( 'wp_ajax_nopriv_give_form_search', 'give_ajax_form_search' );
324
+add_action('wp_ajax_give_form_search', 'give_ajax_form_search');
325
+add_action('wp_ajax_nopriv_give_form_search', 'give_ajax_form_search');
326 326
 
327 327
 /**
328 328
  * Search the donors database via Ajax
@@ -334,38 +334,38 @@  discard block
 block discarded – undo
334 334
 function give_ajax_donor_search() {
335 335
 	global $wpdb;
336 336
 
337
-	$search  = esc_sql( sanitize_text_field( $_GET['s'] ) );
337
+	$search  = esc_sql(sanitize_text_field($_GET['s']));
338 338
 	$results = array();
339
-	if ( ! current_user_can( 'view_give_reports' ) ) {
339
+	if ( ! current_user_can('view_give_reports')) {
340 340
 		$donors = array();
341 341
 	} else {
342
-		$donors = $wpdb->get_results( "SELECT id,name,email FROM $wpdb->donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50" );
342
+		$donors = $wpdb->get_results("SELECT id,name,email FROM $wpdb->donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50");
343 343
 	}
344 344
 
345
-	if ( $donors ) {
345
+	if ($donors) {
346 346
 
347
-		foreach ( $donors as $donor ) {
347
+		foreach ($donors as $donor) {
348 348
 
349 349
 			$results[] = array(
350 350
 				'id'   => $donor->id,
351
-				'name' => $donor->name . ' (' . $donor->email . ')',
351
+				'name' => $donor->name.' ('.$donor->email.')',
352 352
 			);
353 353
 		}
354 354
 	} else {
355 355
 
356 356
 		$donors[] = array(
357 357
 			'id'   => 0,
358
-			'name' => __( 'No donors found.', 'give' ),
358
+			'name' => __('No donors found.', 'give'),
359 359
 		);
360 360
 
361 361
 	}
362 362
 
363
-	echo json_encode( $results );
363
+	echo json_encode($results);
364 364
 
365 365
 	give_die();
366 366
 }
367 367
 
368
-add_action( 'wp_ajax_give_donor_search', 'give_ajax_donor_search' );
368
+add_action('wp_ajax_give_donor_search', 'give_ajax_donor_search');
369 369
 
370 370
 
371 371
 /**
@@ -377,39 +377,39 @@  discard block
 block discarded – undo
377 377
  */
378 378
 function give_ajax_search_users() {
379 379
 
380
-	if ( current_user_can( 'manage_give_settings' ) ) {
380
+	if (current_user_can('manage_give_settings')) {
381 381
 
382
-		$search = esc_sql( sanitize_text_field( $_GET['s'] ) );
382
+		$search = esc_sql(sanitize_text_field($_GET['s']));
383 383
 
384 384
 		$get_users_args = array(
385 385
 			'number' => 9999,
386
-			'search' => $search . '*',
386
+			'search' => $search.'*',
387 387
 		);
388 388
 
389
-		$get_users_args = apply_filters( 'give_search_users_args', $get_users_args );
389
+		$get_users_args = apply_filters('give_search_users_args', $get_users_args);
390 390
 
391
-		$found_users = apply_filters( 'give_ajax_found_users', get_users( $get_users_args ), $search );
391
+		$found_users = apply_filters('give_ajax_found_users', get_users($get_users_args), $search);
392 392
 		$results     = array();
393 393
 
394
-		if ( $found_users ) {
394
+		if ($found_users) {
395 395
 
396
-			foreach ( $found_users as $user ) {
396
+			foreach ($found_users as $user) {
397 397
 
398 398
 				$results[] = array(
399 399
 					'id'   => $user->ID,
400
-					'name' => esc_html( $user->user_login . ' (' . $user->user_email . ')' ),
400
+					'name' => esc_html($user->user_login.' ('.$user->user_email.')'),
401 401
 				);
402 402
 			}
403 403
 		} else {
404 404
 
405 405
 			$results[] = array(
406 406
 				'id'   => 0,
407
-				'name' => __( 'No users found.', 'give' ),
407
+				'name' => __('No users found.', 'give'),
408 408
 			);
409 409
 
410 410
 		}
411 411
 
412
-		echo json_encode( $results );
412
+		echo json_encode($results);
413 413
 
414 414
 	}// End if().
415 415
 
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
 
418 418
 }
419 419
 
420
-add_action( 'wp_ajax_give_user_search', 'give_ajax_search_users' );
420
+add_action('wp_ajax_give_user_search', 'give_ajax_search_users');
421 421
 
422 422
 
423 423
 /**
@@ -429,32 +429,32 @@  discard block
 block discarded – undo
429 429
  */
430 430
 function give_check_for_form_price_variations() {
431 431
 
432
-	if ( ! current_user_can( 'edit_give_forms', get_current_user_id() ) ) {
433
-		die( '-1' );
432
+	if ( ! current_user_can('edit_give_forms', get_current_user_id())) {
433
+		die('-1');
434 434
 	}
435 435
 
436
-	$form_id = intval( $_POST['form_id'] );
437
-	$form    = get_post( $form_id );
436
+	$form_id = intval($_POST['form_id']);
437
+	$form    = get_post($form_id);
438 438
 
439
-	if ( 'give_forms' != $form->post_type ) {
440
-		die( '-2' );
439
+	if ('give_forms' != $form->post_type) {
440
+		die('-2');
441 441
 	}
442 442
 
443
-	if ( give_has_variable_prices( $form_id ) ) {
444
-		$variable_prices = give_get_variable_prices( $form_id );
443
+	if (give_has_variable_prices($form_id)) {
444
+		$variable_prices = give_get_variable_prices($form_id);
445 445
 
446
-		if ( $variable_prices ) {
446
+		if ($variable_prices) {
447 447
 			$ajax_response = '<select class="give_price_options_select give-select give-select" name="give_price_option">';
448 448
 
449
-			if ( isset( $_POST['all_prices'] ) ) {
450
-				$ajax_response .= '<option value="all">' . esc_html__( 'All Levels', 'give' ) . '</option>';
449
+			if (isset($_POST['all_prices'])) {
450
+				$ajax_response .= '<option value="all">'.esc_html__('All Levels', 'give').'</option>';
451 451
 			}
452 452
 
453
-			foreach ( $variable_prices as $key => $price ) {
453
+			foreach ($variable_prices as $key => $price) {
454 454
 
455
-				$level_text = ! empty( $price['_give_text'] ) ? esc_html( $price['_give_text'] ) : give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) );
455
+				$level_text = ! empty($price['_give_text']) ? esc_html($price['_give_text']) : give_currency_filter(give_format_amount($price['_give_amount'], array('sanitize' => false)));
456 456
 
457
-				$ajax_response .= '<option value="' . esc_attr( $price['_give_id']['level_id'] ) . '">' . $level_text . '</option>';
457
+				$ajax_response .= '<option value="'.esc_attr($price['_give_id']['level_id']).'">'.$level_text.'</option>';
458 458
 			}
459 459
 			$ajax_response .= '</select>';
460 460
 			echo $ajax_response;
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
 	give_die();
465 465
 }
466 466
 
467
-add_action( 'wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations' );
467
+add_action('wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations');
468 468
 
469 469
 
470 470
 /**
@@ -475,28 +475,28 @@  discard block
 block discarded – undo
475 475
  * @return void
476 476
  */
477 477
 function give_check_for_form_price_variations_html() {
478
-	if ( ! current_user_can( 'edit_give_payments', get_current_user_id() ) ) {
478
+	if ( ! current_user_can('edit_give_payments', get_current_user_id())) {
479 479
 		wp_die();
480 480
 	}
481 481
 
482
-	$form_id    = ! empty( $_POST['form_id'] ) ? intval( $_POST['form_id'] ) : false;
483
-	$payment_id = ! empty( $_POST['payment_id'] ) ? intval( $_POST['payment_id'] ) : false;
484
-	if ( empty( $form_id ) || empty( $payment_id ) ) {
482
+	$form_id    = ! empty($_POST['form_id']) ? intval($_POST['form_id']) : false;
483
+	$payment_id = ! empty($_POST['payment_id']) ? intval($_POST['payment_id']) : false;
484
+	if (empty($form_id) || empty($payment_id)) {
485 485
 		wp_die();
486 486
 	}
487 487
 
488
-	$form = get_post( $form_id );
489
-	if ( ! empty( $form->post_type ) && 'give_forms' != $form->post_type ) {
488
+	$form = get_post($form_id);
489
+	if ( ! empty($form->post_type) && 'give_forms' != $form->post_type) {
490 490
 		wp_die();
491 491
 	}
492 492
 
493
-	if ( ! give_has_variable_prices( $form_id ) || ! $form_id ) {
494
-		esc_html_e( 'n/a', 'give' );
493
+	if ( ! give_has_variable_prices($form_id) || ! $form_id) {
494
+		esc_html_e('n/a', 'give');
495 495
 	} else {
496 496
 		$prices_atts = array();
497
-		if ( $variable_prices = give_get_variable_prices( $form_id ) ) {
498
-			foreach ( $variable_prices as $variable_price ) {
499
-				$prices_atts[ $variable_price['_give_id']['level_id'] ] = give_format_amount( $variable_price['_give_amount'], array( 'sanitize' => false ) );
497
+		if ($variable_prices = give_get_variable_prices($form_id)) {
498
+			foreach ($variable_prices as $variable_price) {
499
+				$prices_atts[$variable_price['_give_id']['level_id']] = give_format_amount($variable_price['_give_amount'], array('sanitize' => false));
500 500
 			}
501 501
 		}
502 502
 
@@ -507,12 +507,12 @@  discard block
 block discarded – undo
507 507
 			'chosen'           => true,
508 508
 			'show_option_all'  => '',
509 509
 			'show_option_none' => '',
510
-			'select_atts'      => 'data-prices=' . esc_attr( json_encode( $prices_atts ) ),
510
+			'select_atts'      => 'data-prices='.esc_attr(json_encode($prices_atts)),
511 511
 		);
512 512
 
513
-		if ( $payment_id ) {
513
+		if ($payment_id) {
514 514
 			// Payment object.
515
-			$payment = new Give_Payment( $payment_id );
515
+			$payment = new Give_Payment($payment_id);
516 516
 
517 517
 			// Payment meta.
518 518
 			$payment_meta                               = $payment->get_meta();
@@ -520,13 +520,13 @@  discard block
 block discarded – undo
520 520
 		}
521 521
 
522 522
 		// Render variable prices select tag html.
523
-		give_get_form_variable_price_dropdown( $variable_price_dropdown_option, true );
523
+		give_get_form_variable_price_dropdown($variable_price_dropdown_option, true);
524 524
 	}
525 525
 
526 526
 	give_die();
527 527
 }
528 528
 
529
-add_action( 'wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html' );
529
+add_action('wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html');
530 530
 
531 531
 /**
532 532
  * Send Confirmation Email For Complete Donation History Access.
@@ -538,24 +538,24 @@  discard block
 block discarded – undo
538 538
 function give_confirm_email_for_donation_access() {
539 539
 
540 540
 	// Verify Security using Nonce.
541
-	if ( ! check_ajax_referer( 'give_ajax_nonce', 'nonce' ) ) {
541
+	if ( ! check_ajax_referer('give_ajax_nonce', 'nonce')) {
542 542
 		return false;
543 543
 	}
544 544
 
545 545
 	// Bail Out, if email is empty.
546
-	if ( empty( $_POST['email'] ) ) {
546
+	if (empty($_POST['email'])) {
547 547
 		return false;
548 548
 	}
549 549
 
550
-	$donor = Give()->donors->get_donor_by( 'email', give_clean( $_POST['email'] ) );
551
-	if ( Give()->email_access->can_send_email( $donor->id ) ) {
550
+	$donor = Give()->donors->get_donor_by('email', give_clean($_POST['email']));
551
+	if (Give()->email_access->can_send_email($donor->id)) {
552 552
 		$return     = array();
553
-		$email_sent = Give()->email_access->send_email( $donor->id, $donor->email );
553
+		$email_sent = Give()->email_access->send_email($donor->id, $donor->email);
554 554
 
555
-		if ( ! $email_sent ) {
555
+		if ( ! $email_sent) {
556 556
 			$return['status']  = 'error';
557 557
 			$return['message'] = Give()->notices->print_frontend_notice(
558
-				__( 'Unable to send email. Please try again.', 'give' ),
558
+				__('Unable to send email. Please try again.', 'give'),
559 559
 				false,
560 560
 				'error'
561 561
 			);
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
 
564 564
 		$return['status']  = 'success';
565 565
 		$return['message'] = Give()->notices->print_frontend_notice(
566
-			__( 'Please check your email and click on the link to access your complete donation history.', 'give' ),
566
+			__('Please check your email and click on the link to access your complete donation history.', 'give'),
567 567
 			false,
568 568
 			'success'
569 569
 		);
@@ -574,16 +574,16 @@  discard block
 block discarded – undo
574 574
 		$return['status']  = 'error';
575 575
 		$return['message'] = Give()->notices->print_frontend_notice(
576 576
 			sprintf(
577
-				__( 'Too many access email requests detected. Please wait %s before requesting a new donation history access link.', 'give' ),
578
-				sprintf( _n( '%s minute', '%s minutes', $value, 'give' ), $value )
577
+				__('Too many access email requests detected. Please wait %s before requesting a new donation history access link.', 'give'),
578
+				sprintf(_n('%s minute', '%s minutes', $value, 'give'), $value)
579 579
 			),
580 580
 			false,
581 581
 			'error'
582 582
 		);
583 583
 	}
584 584
 
585
-	echo json_encode( $return );
585
+	echo json_encode($return);
586 586
 	give_die();
587 587
 }
588 588
 
589
-add_action( 'wp_ajax_nopriv_give_confirm_email_for_donations_access', 'give_confirm_email_for_donation_access' );
590 589
\ No newline at end of file
590
+add_action('wp_ajax_nopriv_give_confirm_email_for_donations_access', 'give_confirm_email_for_donation_access');
591 591
\ No newline at end of file
Please login to merge, or discard this patch.
includes/payments/class-payment-stats.php 1 patch
Spacing   +42 added lines, -42 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,39 +117,39 @@  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 += (float) give_donation_amount( $payment->ID, array( 'type' => 'stats' ) );
144
+			if ( ! empty($payments)) {
145
+				foreach ($payments as $payment) {
146
+					$earnings += (float) give_donation_amount($payment->ID, array('type' => 'stats'));
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
 		/**
@@ -163,10 +163,10 @@  discard block
 block discarded – undo
163 163
 		 * @param  string|bool $end_date   Earning end date.
164 164
 		 * @param  string|bool $gateway_id Payment gateway id.
165 165
 		 */
166
-		$earnings = apply_filters( 'give_get_earnings', $earnings, $form_id, $start_date, $end_date, $gateway_id );
166
+		$earnings = apply_filters('give_get_earnings', $earnings, $form_id, $start_date, $end_date, $gateway_id);
167 167
 
168 168
 		//return earnings
169
-		return round( $earnings, give_get_price_decimals( $form_id ) );
169
+		return round($earnings, give_get_price_decimals($form_id));
170 170
 
171 171
 	}
172 172
 
@@ -183,17 +183,17 @@  discard block
 block discarded – undo
183 183
 	 *
184 184
 	 * @return float|int                Total amount of donations based on the passed arguments.
185 185
 	 */
186
-	public function get_earnings_cache_key( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) {
186
+	public function get_earnings_cache_key($form_id = 0, $start_date = false, $end_date = false, $gateway_id = false) {
187 187
 
188
-		$this->setup_dates( $start_date, $end_date );
188
+		$this->setup_dates($start_date, $end_date);
189 189
 
190 190
 		// Make sure start date is valid
191
-		if ( is_wp_error( $this->start_date ) ) {
191
+		if (is_wp_error($this->start_date)) {
192 192
 			return $this->start_date;
193 193
 		}
194 194
 
195 195
 		// Make sure end date is valid
196
-		if ( is_wp_error( $this->end_date ) ) {
196
+		if (is_wp_error($this->end_date)) {
197 197
 			return $this->end_date;
198 198
 		}
199 199
 
@@ -203,12 +203,12 @@  discard block
 block discarded – undo
203 203
 			'start_date' => $this->start_date,
204 204
 			'end_date'   => $this->end_date,
205 205
 			'fields'     => 'ids',
206
-			'number'     => - 1,
206
+			'number'     => -1,
207 207
 		);
208 208
 
209 209
 
210 210
 		// Filter by Gateway ID meta_key
211
-		if ( $gateway_id ) {
211
+		if ($gateway_id) {
212 212
 			$args['meta_query'][] = array(
213 213
 				'key'   => '_give_payment_gateway',
214 214
 				'value' => $gateway_id,
@@ -216,19 +216,19 @@  discard block
 block discarded – undo
216 216
 		}
217 217
 
218 218
 		// Filter by Gateway ID meta_key
219
-		if ( $form_id ) {
219
+		if ($form_id) {
220 220
 			$args['meta_query'][] = array(
221 221
 				'key'   => '_give_payment_form_id',
222 222
 				'value' => $form_id,
223 223
 			);
224 224
 		}
225 225
 
226
-		if ( ! empty( $args['meta_query'] ) && 1 < count( $args['meta_query'] ) ) {
226
+		if ( ! empty($args['meta_query']) && 1 < count($args['meta_query'])) {
227 227
 			$args['meta_query']['relation'] = 'AND';
228 228
 		}
229 229
 
230
-		$args = apply_filters( 'give_stats_earnings_args', $args );
231
-		$key  = Give_Cache::get_key( 'give_stats', $args );
230
+		$args = apply_filters('give_stats_earnings_args', $args);
231
+		$key  = Give_Cache::get_key('give_stats', $args);
232 232
 
233 233
 		//return earnings
234 234
 		return $key;
@@ -246,17 +246,17 @@  discard block
 block discarded – undo
246 246
 	 *
247 247
 	 * @return array       Best selling forms
248 248
 	 */
249
-	public function get_best_selling( $number = 10 ) {
249
+	public function get_best_selling($number = 10) {
250 250
 		global $wpdb;
251 251
 
252
-		$meta_table = __give_v20_bc_table_details( 'form' );
252
+		$meta_table = __give_v20_bc_table_details('form');
253 253
 
254
-		$give_forms = $wpdb->get_results( $wpdb->prepare(
254
+		$give_forms = $wpdb->get_results($wpdb->prepare(
255 255
 			"SELECT {$meta_table['column']['id']} as form_id, max(meta_value) as sales
256 256
 				FROM {$meta_table['name']} WHERE meta_key='_give_form_sales' AND meta_value > 0
257 257
 				GROUP BY meta_value+0
258 258
 				DESC LIMIT %d;", $number
259
-		) );
259
+		));
260 260
 
261 261
 		return $give_forms;
262 262
 	}
Please login to merge, or discard this patch.
includes/payments/class-give-payment.php 1 patch
Spacing   +287 added lines, -288 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
 
@@ -395,13 +395,13 @@  discard block
 block discarded – undo
395 395
 	 *
396 396
 	 * @return mixed void|false
397 397
 	 */
398
-	public function __construct( $payment_id = false ) {
398
+	public function __construct($payment_id = false) {
399 399
 
400
-		if ( empty( $payment_id ) ) {
400
+		if (empty($payment_id)) {
401 401
 			return false;
402 402
 		}
403 403
 
404
-		$this->setup_payment( $payment_id );
404
+		$this->setup_payment($payment_id);
405 405
 	}
406 406
 
407 407
 	/**
@@ -414,11 +414,11 @@  discard block
 block discarded – undo
414 414
 	 *
415 415
 	 * @return mixed        The value.
416 416
 	 */
417
-	public function __get( $key ) {
417
+	public function __get($key) {
418 418
 
419
-		if ( method_exists( $this, 'get_' . $key ) ) {
419
+		if (method_exists($this, 'get_'.$key)) {
420 420
 
421
-			$value = call_user_func( array( $this, 'get_' . $key ) );
421
+			$value = call_user_func(array($this, 'get_'.$key));
422 422
 
423 423
 		} else {
424 424
 
@@ -440,18 +440,18 @@  discard block
 block discarded – undo
440 440
 	 * @param  string $key   The property name
441 441
 	 * @param  mixed  $value The value of the property
442 442
 	 */
443
-	public function __set( $key, $value ) {
444
-		$ignore = array( '_ID' );
443
+	public function __set($key, $value) {
444
+		$ignore = array('_ID');
445 445
 
446
-		if ( 'status' === $key ) {
446
+		if ('status' === $key) {
447 447
 			$this->old_status = $this->status;
448 448
 		}
449 449
 
450
-		if ( ! in_array( $key, $ignore ) ) {
451
-			$this->pending[ $key ] = $value;
450
+		if ( ! in_array($key, $ignore)) {
451
+			$this->pending[$key] = $value;
452 452
 		}
453 453
 
454
-		if ( '_ID' !== $key ) {
454
+		if ('_ID' !== $key) {
455 455
 			$this->$key = $value;
456 456
 		}
457 457
 	}
@@ -466,9 +466,9 @@  discard block
 block discarded – undo
466 466
 	 *
467 467
 	 * @return boolean|null       If the item is set or not
468 468
 	 */
469
-	public function __isset( $name ) {
470
-		if ( property_exists( $this, $name ) ) {
471
-			return false === empty( $this->$name );
469
+	public function __isset($name) {
470
+		if (property_exists($this, $name)) {
471
+			return false === empty($this->$name);
472 472
 		} else {
473 473
 			return null;
474 474
 		}
@@ -484,20 +484,20 @@  discard block
 block discarded – undo
484 484
 	 *
485 485
 	 * @return bool            If the setup was successful or not
486 486
 	 */
487
-	private function setup_payment( $payment_id ) {
487
+	private function setup_payment($payment_id) {
488 488
 		$this->pending = array();
489 489
 
490
-		if ( empty( $payment_id ) ) {
490
+		if (empty($payment_id)) {
491 491
 			return false;
492 492
 		}
493 493
 
494
-		$payment = get_post( absint( $payment_id ) );
494
+		$payment = get_post(absint($payment_id));
495 495
 
496
-		if ( ! $payment || is_wp_error( $payment ) ) {
496
+		if ( ! $payment || is_wp_error($payment)) {
497 497
 			return false;
498 498
 		}
499 499
 
500
-		if ( 'give_payment' !== $payment->post_type ) {
500
+		if ('give_payment' !== $payment->post_type) {
501 501
 			return false;
502 502
 		}
503 503
 
@@ -511,17 +511,17 @@  discard block
 block discarded – undo
511 511
 		 * @param Give_Payment $this       Payment object.
512 512
 		 * @param int          $payment_id The ID of the payment.
513 513
 		 */
514
-		do_action( 'give_pre_setup_payment', $this, $payment_id );
514
+		do_action('give_pre_setup_payment', $this, $payment_id);
515 515
 
516 516
 		// Get payment from cache.
517
-		$donation_vars = Give_Cache::get_group( $payment_id, 'give-donations' );
517
+		$donation_vars = Give_Cache::get_group($payment_id, 'give-donations');
518 518
 
519
-		if ( is_null( $donation_vars ) ) {
519
+		if (is_null($donation_vars)) {
520 520
 			// Primary Identifier.
521
-			$this->ID = absint( $payment_id );
521
+			$this->ID = absint($payment_id);
522 522
 
523 523
 			// Protected ID that can never be changed.
524
-			$this->_ID = absint( $payment_id );
524
+			$this->_ID = absint($payment_id);
525 525
 
526 526
 			// We have a payment, get the generic payment_meta item to reduce calls to it.
527 527
 			$this->payment_meta = $this->get_meta();
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
 			$this->parent_payment = $payment->post_parent;
538 538
 
539 539
 			$all_payment_statuses  = give_get_payment_statuses();
540
-			$this->status_nicename = array_key_exists( $this->status, $all_payment_statuses ) ? $all_payment_statuses[ $this->status ] : ucfirst( $this->status );
540
+			$this->status_nicename = array_key_exists($this->status, $all_payment_statuses) ? $all_payment_statuses[$this->status] : ucfirst($this->status);
541 541
 
542 542
 			// Currency Based.
543 543
 			$this->total    = $this->setup_total();
@@ -566,10 +566,10 @@  discard block
 block discarded – undo
566 566
 			$this->key        = $this->setup_payment_key();
567 567
 			$this->number     = $this->setup_payment_number();
568 568
 
569
-			Give_Cache::set_group( $this->ID, get_object_vars( $this ), 'give-donations' );
569
+			Give_Cache::set_group($this->ID, get_object_vars($this), 'give-donations');
570 570
 		} else {
571 571
 
572
-			foreach ( $donation_vars as $donation_var => $value ) {
572
+			foreach ($donation_vars as $donation_var => $value) {
573 573
 				$this->$donation_var = $value;
574 574
 			}
575 575
 		}
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
 		 * @param Give_Payment $this       Payment object.
585 585
 		 * @param int          $payment_id The ID of the payment.
586 586
 		 */
587
-		do_action( 'give_setup_payment', $this, $payment_id );
587
+		do_action('give_setup_payment', $this, $payment_id);
588 588
 
589 589
 		return true;
590 590
 	}
@@ -603,11 +603,11 @@  discard block
 block discarded – undo
603 603
 	 *
604 604
 	 * @return void
605 605
 	 */
606
-	public function update_payment_setup( $payment_id ) {
606
+	public function update_payment_setup($payment_id) {
607 607
 		// Delete cache.
608
-		Give_Cache::delete_group( $this->ID,'give-donations' );
608
+		Give_Cache::delete_group($this->ID, 'give-donations');
609 609
 		
610
-		$this->setup_payment( $payment_id );
610
+		$this->setup_payment($payment_id);
611 611
 	}
612 612
 
613 613
 	/**
@@ -622,24 +622,24 @@  discard block
 block discarded – undo
622 622
 
623 623
 		// Construct the payment title.
624 624
 		$payment_title = '';
625
-		if ( ! empty( $this->first_name ) && ! empty( $this->last_name ) ) {
626
-			$payment_title = $this->first_name . ' ' . $this->last_name;
627
-		} elseif ( ! empty( $this->first_name ) && empty( $this->last_name ) ) {
625
+		if ( ! empty($this->first_name) && ! empty($this->last_name)) {
626
+			$payment_title = $this->first_name.' '.$this->last_name;
627
+		} elseif ( ! empty($this->first_name) && empty($this->last_name)) {
628 628
 			$payment_title = $this->first_name;
629
-		} elseif ( ! empty( $this->email ) && is_email( $this->email ) ) {
629
+		} elseif ( ! empty($this->email) && is_email($this->email)) {
630 630
 			$payment_title = $this->email;
631 631
 		}
632 632
 
633 633
 		// Set Key.
634
-		if ( empty( $this->key ) ) {
634
+		if (empty($this->key)) {
635 635
 
636
-			$auth_key             = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
637
-			$this->key            = strtolower( md5( $this->email . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) );  // Unique key
636
+			$auth_key             = defined('AUTH_KEY') ? AUTH_KEY : '';
637
+			$this->key            = strtolower(md5($this->email.date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); // Unique key
638 638
 			$this->pending['key'] = $this->key;
639 639
 		}
640 640
 
641 641
 		// Set IP.
642
-		if ( empty( $this->ip ) ) {
642
+		if (empty($this->ip)) {
643 643
 
644 644
 			$this->ip            = give_get_ip();
645 645
 			$this->pending['ip'] = $this->ip;
@@ -668,19 +668,19 @@  discard block
 block discarded – undo
668 668
 			'status'       => $this->status,
669 669
 		);
670 670
 
671
-		$args = apply_filters( 'give_insert_payment_args', array(
671
+		$args = apply_filters('give_insert_payment_args', array(
672 672
 			'post_title'    => $payment_title,
673 673
 			'post_status'   => $this->status,
674 674
 			'post_type'     => 'give_payment',
675
-			'post_date'     => ! empty( $this->date ) ? $this->date : null,
676
-			'post_date_gmt' => ! empty( $this->date ) ? get_gmt_from_date( $this->date ) : null,
675
+			'post_date'     => ! empty($this->date) ? $this->date : null,
676
+			'post_date_gmt' => ! empty($this->date) ? get_gmt_from_date($this->date) : null,
677 677
 			'post_parent'   => $this->parent_payment,
678
-		), $payment_data );
678
+		), $payment_data);
679 679
 
680 680
 		// Create a blank payment
681
-		$payment_id = wp_insert_post( $args );
681
+		$payment_id = wp_insert_post($args);
682 682
 
683
-		if ( ! empty( $payment_id ) ) {
683
+		if ( ! empty($payment_id)) {
684 684
 
685 685
 			$this->ID  = $payment_id;
686 686
 			$this->_ID = $payment_id;
@@ -692,42 +692,42 @@  discard block
 block discarded – undo
692 692
 			 *
693 693
 			 * @since 1.8.13
694 694
 			 */
695
-			$donor = apply_filters( 'give_update_donor_information', $donor, $payment_id, $payment_data, $args );
695
+			$donor = apply_filters('give_update_donor_information', $donor, $payment_id, $payment_data, $args);
696 696
 
697
-			if ( did_action( 'give_pre_process_donation' ) && is_user_logged_in() ) {
698
-				$donor = new Give_Donor( get_current_user_id(), true );
697
+			if (did_action('give_pre_process_donation') && is_user_logged_in()) {
698
+				$donor = new Give_Donor(get_current_user_id(), true);
699 699
 
700 700
 				// Donor is logged in but used a different email to purchase with so assign to their donor record.
701
-				if ( ! empty( $donor->id ) && $this->email !== $donor->email ) {
702
-					$donor->add_email( $this->email );
701
+				if ( ! empty($donor->id) && $this->email !== $donor->email) {
702
+					$donor->add_email($this->email);
703 703
 				}
704 704
 			}
705 705
 
706
-			if ( empty( $donor->id ) ) {
707
-				$donor = new Give_Donor( $this->email );
706
+			if (empty($donor->id)) {
707
+				$donor = new Give_Donor($this->email);
708 708
 			}
709 709
 
710
-			if ( empty( $donor->id ) ) {
710
+			if (empty($donor->id)) {
711 711
 
712 712
 				$donor_data = array(
713
-					'name'    => ! is_email( $payment_title ) ? $this->first_name . ' ' . $this->last_name : '',
713
+					'name'    => ! is_email($payment_title) ? $this->first_name.' '.$this->last_name : '',
714 714
 					'email'   => $this->email,
715 715
 					'user_id' => $this->user_id,
716 716
 				);
717 717
 
718
-				$donor->create( $donor_data );
718
+				$donor->create($donor_data);
719 719
 
720 720
 			}
721 721
 
722 722
 			// Update Donor Meta once donor is created.
723
-			$donor->update_meta( '_give_donor_first_name', $this->first_name );
724
-			$donor->update_meta( '_give_donor_last_name', $this->last_name );
723
+			$donor->update_meta('_give_donor_first_name', $this->first_name);
724
+			$donor->update_meta('_give_donor_last_name', $this->last_name);
725 725
 
726 726
 			$this->customer_id            = $donor->id;
727 727
 			$this->pending['customer_id'] = $this->customer_id;
728
-			$donor->attach_payment( $this->ID, false );
728
+			$donor->attach_payment($this->ID, false);
729 729
 
730
-			$this->payment_meta = apply_filters( 'give_payment_meta', $this->payment_meta, $payment_data );
730
+			$this->payment_meta = apply_filters('give_payment_meta', $this->payment_meta, $payment_data);
731 731
 
732 732
 			$this->new = true;
733 733
 		}// End if().
@@ -749,11 +749,11 @@  discard block
 block discarded – undo
749 749
 		$saved = false;
750 750
 
751 751
 		// Must have an ID.
752
-		if ( empty( $this->ID ) ) {
752
+		if (empty($this->ID)) {
753 753
 
754 754
 			$payment_id = $this->insert_payment();
755 755
 
756
-			if ( false === $payment_id ) {
756
+			if (false === $payment_id) {
757 757
 				$saved = false;
758 758
 			} else {
759 759
 				$this->ID = $payment_id;
@@ -761,42 +761,42 @@  discard block
 block discarded – undo
761 761
 		}
762 762
 
763 763
 		// Set ID if not matching.
764
-		if ( $this->ID !== $this->_ID ) {
764
+		if ($this->ID !== $this->_ID) {
765 765
 			$this->ID = $this->_ID;
766 766
 		}
767 767
 
768 768
 		// If we have something pending, let's save it.
769
-		if ( ! empty( $this->pending ) ) {
769
+		if ( ! empty($this->pending)) {
770 770
 
771 771
 			$total_increase = 0;
772 772
 			$total_decrease = 0;
773 773
 
774
-			foreach ( $this->pending as $key => $value ) {
774
+			foreach ($this->pending as $key => $value) {
775 775
 
776
-				switch ( $key ) {
776
+				switch ($key) {
777 777
 
778 778
 					case 'donations':
779 779
 						// Update totals for pending donations.
780
-						foreach ( $this->pending[ $key ] as $item ) {
780
+						foreach ($this->pending[$key] as $item) {
781 781
 
782
-							$quantity = isset( $item['quantity'] ) ? $item['quantity'] : 1;
783
-							$price_id = isset( $item['price_id'] ) ? $item['price_id'] : 0;
782
+							$quantity = isset($item['quantity']) ? $item['quantity'] : 1;
783
+							$price_id = isset($item['price_id']) ? $item['price_id'] : 0;
784 784
 
785
-							switch ( $item['action'] ) {
785
+							switch ($item['action']) {
786 786
 
787 787
 								case 'add':
788 788
 
789 789
 									$price = $item['price'];
790 790
 
791
-									if ( 'publish' === $this->status || 'complete' === $this->status ) {
791
+									if ('publish' === $this->status || 'complete' === $this->status) {
792 792
 
793 793
 										// Add donation to logs.
794
-										$log_date = date_i18n( 'Y-m-d G:i:s', current_time( 'timestamp' ) );
795
-										give_record_donation_in_log( $item['id'], $this->ID, $price_id, $log_date );
794
+										$log_date = date_i18n('Y-m-d G:i:s', current_time('timestamp'));
795
+										give_record_donation_in_log($item['id'], $this->ID, $price_id, $log_date);
796 796
 
797
-										$form = new Give_Donate_Form( $item['id'] );
798
-										$form->increase_sales( $quantity );
799
-										$form->increase_earnings( $price );
797
+										$form = new Give_Donate_Form($item['id']);
798
+										$form->increase_sales($quantity);
799
+										$form->increase_earnings($price);
800 800
 
801 801
 										$total_increase += $price;
802 802
 									}
@@ -804,10 +804,10 @@  discard block
 block discarded – undo
804 804
 
805 805
 								case 'remove':
806 806
 									$this->delete_sales_logs();
807
-									if ( 'publish' === $this->status || 'complete' === $this->status ) {
808
-										$form = new Give_Donate_Form( $item['id'] );
809
-										$form->decrease_sales( $quantity );
810
-										$form->decrease_earnings( $item['amount'] );
807
+									if ('publish' === $this->status || 'complete' === $this->status) {
808
+										$form = new Give_Donate_Form($item['id']);
809
+										$form->decrease_sales($quantity);
810
+										$form->decrease_earnings($item['amount']);
811 811
 
812 812
 										$total_decrease += $item['amount'];
813 813
 									}
@@ -818,27 +818,27 @@  discard block
 block discarded – undo
818 818
 						break;
819 819
 
820 820
 					case 'status':
821
-						$this->update_status( $this->status );
821
+						$this->update_status($this->status);
822 822
 						break;
823 823
 
824 824
 					case 'gateway':
825
-						$this->update_meta( '_give_payment_gateway', $this->gateway );
825
+						$this->update_meta('_give_payment_gateway', $this->gateway);
826 826
 						break;
827 827
 
828 828
 					case 'mode':
829
-						$this->update_meta( '_give_payment_mode', $this->mode );
829
+						$this->update_meta('_give_payment_mode', $this->mode);
830 830
 						break;
831 831
 
832 832
 					case 'transaction_id':
833
-						$this->update_meta( '_give_payment_transaction_id', $this->transaction_id );
833
+						$this->update_meta('_give_payment_transaction_id', $this->transaction_id);
834 834
 						break;
835 835
 
836 836
 					case 'ip':
837
-						$this->update_meta( '_give_payment_donor_ip', $this->ip );
837
+						$this->update_meta('_give_payment_donor_ip', $this->ip);
838 838
 						break;
839 839
 
840 840
 					case 'customer_id':
841
-						$this->update_meta( '_give_payment_donor_id', $this->customer_id );
841
+						$this->update_meta('_give_payment_donor_id', $this->customer_id);
842 842
 						break;
843 843
 
844 844
 					// case 'user_id':
@@ -846,58 +846,58 @@  discard block
 block discarded – undo
846 846
 					// 	break;
847 847
 
848 848
 					case 'form_title':
849
-						$this->update_meta( '_give_payment_form_title', $this->form_title );
849
+						$this->update_meta('_give_payment_form_title', $this->form_title);
850 850
 						break;
851 851
 
852 852
 					case 'form_id':
853
-						$this->update_meta( '_give_payment_form_id', $this->form_id );
853
+						$this->update_meta('_give_payment_form_id', $this->form_id);
854 854
 						break;
855 855
 
856 856
 					case 'price_id':
857
-						$this->update_meta( '_give_payment_price_id', $this->price_id );
857
+						$this->update_meta('_give_payment_price_id', $this->price_id);
858 858
 						break;
859 859
 
860 860
 					case 'first_name':
861
-						$this->update_meta( '_give_donor_billing_first_name', $this->first_name );
861
+						$this->update_meta('_give_donor_billing_first_name', $this->first_name);
862 862
 						break;
863 863
 
864 864
 					case 'last_name':
865
-						$this->update_meta( '_give_donor_billing_last_name', $this->last_name );
865
+						$this->update_meta('_give_donor_billing_last_name', $this->last_name);
866 866
 						break;
867 867
 
868 868
 					case 'currency':
869
-						$this->update_meta( '_give_payment_currency', $this->currency );
869
+						$this->update_meta('_give_payment_currency', $this->currency);
870 870
 						break;
871 871
 
872 872
 					case 'address':
873
-						if ( ! empty( $this->address ) ) {
874
-							foreach ( $this->address as $address_name => $address ) {
875
-								switch ( $address_name ) {
873
+						if ( ! empty($this->address)) {
874
+							foreach ($this->address as $address_name => $address) {
875
+								switch ($address_name) {
876 876
 									case 'line1':
877
-										$this->update_meta( '_give_donor_billing_address1', $address );
877
+										$this->update_meta('_give_donor_billing_address1', $address);
878 878
 										break;
879 879
 
880 880
 									case 'line2':
881
-										$this->update_meta( '_give_donor_billing_address2', $address );
881
+										$this->update_meta('_give_donor_billing_address2', $address);
882 882
 										break;
883 883
 
884 884
 									default:
885
-										$this->update_meta( "_give_donor_billing_{$address_name}", $address );
885
+										$this->update_meta("_give_donor_billing_{$address_name}", $address);
886 886
 								}
887 887
 							}
888 888
 						}
889 889
 						break;
890 890
 
891 891
 					case 'email':
892
-						$this->update_meta( '_give_payment_donor_email', $this->email );
892
+						$this->update_meta('_give_payment_donor_email', $this->email);
893 893
 						break;
894 894
 
895 895
 					case 'key':
896
-						$this->update_meta( '_give_payment_purchase_key', $this->key );
896
+						$this->update_meta('_give_payment_purchase_key', $this->key);
897 897
 						break;
898 898
 
899 899
 					case 'number':
900
-						$this->update_meta( '_give_payment_number', $this->number );
900
+						$this->update_meta('_give_payment_number', $this->number);
901 901
 						break;
902 902
 
903 903
 					case 'date':
@@ -907,11 +907,11 @@  discard block
 block discarded – undo
907 907
 							'edit_date' => true,
908 908
 						);
909 909
 
910
-						wp_update_post( $args );
910
+						wp_update_post($args);
911 911
 						break;
912 912
 
913 913
 					case 'completed_date':
914
-						$this->update_meta( '_give_completed_date', $this->completed_date );
914
+						$this->update_meta('_give_completed_date', $this->completed_date);
915 915
 						break;
916 916
 
917 917
 					case 'parent_payment':
@@ -920,7 +920,7 @@  discard block
 block discarded – undo
920 920
 							'post_parent' => $this->parent_payment,
921 921
 						);
922 922
 
923
-						wp_update_post( $args );
923
+						wp_update_post($args);
924 924
 						break;
925 925
 
926 926
 					default:
@@ -931,40 +931,40 @@  discard block
 block discarded – undo
931 931
 						 *
932 932
 						 * @param Give_Payment $this Payment object.
933 933
 						 */
934
-						do_action( 'give_payment_save', $this, $key );
934
+						do_action('give_payment_save', $this, $key);
935 935
 						break;
936 936
 				}// End switch().
937 937
 			}// End foreach().
938 938
 
939
-			if ( 'pending' !== $this->status ) {
939
+			if ('pending' !== $this->status) {
940 940
 
941
-				$donor = new Give_Donor( $this->customer_id );
941
+				$donor = new Give_Donor($this->customer_id);
942 942
 
943 943
 				$total_change = $total_increase - $total_decrease;
944
-				if ( $total_change < 0 ) {
944
+				if ($total_change < 0) {
945 945
 
946
-					$total_change = - ( $total_change );
946
+					$total_change = - ($total_change);
947 947
 					// Decrease the donor's donation stats.
948
-					$donor->decrease_value( $total_change );
949
-					give_decrease_total_earnings( $total_change );
948
+					$donor->decrease_value($total_change);
949
+					give_decrease_total_earnings($total_change);
950 950
 
951
-				} elseif ( $total_change > 0 ) {
951
+				} elseif ($total_change > 0) {
952 952
 
953 953
 					// Increase the donor's donation stats.
954
-					$donor->increase_value( $total_change );
955
-					give_increase_total_earnings( $total_change );
954
+					$donor->increase_value($total_change);
955
+					give_increase_total_earnings($total_change);
956 956
 
957 957
 				}
958 958
 			}
959 959
 
960
-			$this->update_meta( '_give_payment_total', give_sanitize_amount_for_db( $this->total ) );
960
+			$this->update_meta('_give_payment_total', give_sanitize_amount_for_db($this->total));
961 961
 
962 962
 			$this->pending = array();
963 963
 			$saved         = true;
964 964
 		}// End if().
965 965
 
966
-		if ( true === $saved ) {
967
-			$this->setup_payment( $this->ID );
966
+		if (true === $saved) {
967
+			$this->setup_payment($this->ID);
968 968
 		}
969 969
 
970 970
 		return $saved;
@@ -982,12 +982,12 @@  discard block
 block discarded – undo
982 982
 	 *
983 983
 	 * @return bool           True when successful, false otherwise
984 984
 	 */
985
-	public function add_donation( $form_id = 0, $args = array(), $options = array() ) {
985
+	public function add_donation($form_id = 0, $args = array(), $options = array()) {
986 986
 
987
-		$donation = new Give_Donate_Form( $form_id );
987
+		$donation = new Give_Donate_Form($form_id);
988 988
 
989 989
 		// Bail if this post isn't a give donation form.
990
-		if ( ! $donation || $donation->post_type !== 'give_forms' ) {
990
+		if ( ! $donation || $donation->post_type !== 'give_forms') {
991 991
 			return false;
992 992
 		}
993 993
 
@@ -997,59 +997,59 @@  discard block
 block discarded – undo
997 997
 			'price_id' => false,
998 998
 		);
999 999
 
1000
-		$args = wp_parse_args( apply_filters( 'give_payment_add_donation_args', $args, $donation->ID ), $defaults );
1000
+		$args = wp_parse_args(apply_filters('give_payment_add_donation_args', $args, $donation->ID), $defaults);
1001 1001
 
1002 1002
 		// Allow overriding the price.
1003
-		if ( false !== $args['price'] ) {
1003
+		if (false !== $args['price']) {
1004 1004
 			$donation_amount = $args['price'];
1005 1005
 		} else {
1006 1006
 
1007 1007
 			// Deal with variable pricing.
1008
-			if ( give_has_variable_prices( $donation->ID ) ) {
1009
-				$prices          = give_get_meta( $form_id, '_give_donation_levels', true );
1008
+			if (give_has_variable_prices($donation->ID)) {
1009
+				$prices          = give_get_meta($form_id, '_give_donation_levels', true);
1010 1010
 				$donation_amount = '';
1011 1011
 				// Loop through prices.
1012
-				foreach ( $prices as $price ) {
1012
+				foreach ($prices as $price) {
1013 1013
 					// Find a match between price_id and level_id.
1014 1014
 					// First verify array keys exists THEN make the match.
1015
-					if ( ( isset( $args['price_id'] ) && isset( $price['_give_id']['level_id'] ) )
1015
+					if ((isset($args['price_id']) && isset($price['_give_id']['level_id']))
1016 1016
 					     && $args['price_id'] == $price['_give_id']['level_id']
1017 1017
 					) {
1018 1018
 						$donation_amount = $price['_give_amount'];
1019 1019
 					}
1020 1020
 				}
1021 1021
 				// Fallback to the lowest price point.
1022
-				if ( $donation_amount == '' ) {
1023
-					$donation_amount  = give_get_lowest_price_option( $donation->ID );
1024
-					$args['price_id'] = give_get_lowest_price_id( $donation->ID );
1022
+				if ($donation_amount == '') {
1023
+					$donation_amount  = give_get_lowest_price_option($donation->ID);
1024
+					$args['price_id'] = give_get_lowest_price_id($donation->ID);
1025 1025
 				}
1026 1026
 			} else {
1027 1027
 				// Simple form price.
1028
-				$donation_amount = give_get_form_price( $donation->ID );
1028
+				$donation_amount = give_get_form_price($donation->ID);
1029 1029
 			}
1030 1030
 		}
1031 1031
 
1032 1032
 		// Sanitizing the price here so we don't have a dozen calls later.
1033
-		$donation_amount = give_maybe_sanitize_amount( $donation_amount );
1034
-		$total           = round( $donation_amount, give_get_price_decimals( $this->ID ) );
1033
+		$donation_amount = give_maybe_sanitize_amount($donation_amount);
1034
+		$total           = round($donation_amount, give_get_price_decimals($this->ID));
1035 1035
 
1036 1036
 		// Add Options.
1037 1037
 		$default_options = array();
1038
-		if ( false !== $args['price_id'] ) {
1038
+		if (false !== $args['price_id']) {
1039 1039
 			$default_options['price_id'] = (int) $args['price_id'];
1040 1040
 		}
1041
-		$options = wp_parse_args( $options, $default_options );
1041
+		$options = wp_parse_args($options, $default_options);
1042 1042
 
1043 1043
 		// Do not allow totals to go negative.
1044
-		if ( $total < 0 ) {
1044
+		if ($total < 0) {
1045 1045
 			$total = 0;
1046 1046
 		}
1047 1047
 
1048 1048
 		$donation = array(
1049 1049
 			'name'     => $donation->post_title,
1050 1050
 			'id'       => $donation->ID,
1051
-			'price'    => round( $total, give_get_price_decimals( $this->ID ) ),
1052
-			'subtotal' => round( $total, give_get_price_decimals( $this->ID ) ),
1051
+			'price'    => round($total, give_get_price_decimals($this->ID)),
1052
+			'subtotal' => round($total, give_get_price_decimals($this->ID)),
1053 1053
 			'price_id' => $args['price_id'],
1054 1054
 			'action'   => 'add',
1055 1055
 			'options'  => $options,
@@ -1057,7 +1057,7 @@  discard block
 block discarded – undo
1057 1057
 
1058 1058
 		$this->pending['donations'][] = $donation;
1059 1059
 
1060
-		$this->increase_subtotal( $total );
1060
+		$this->increase_subtotal($total);
1061 1061
 
1062 1062
 		return true;
1063 1063
 
@@ -1074,7 +1074,7 @@  discard block
 block discarded – undo
1074 1074
 	 *
1075 1075
 	 * @return bool           If the item was removed or not
1076 1076
 	 */
1077
-	public function remove_donation( $form_id, $args = array() ) {
1077
+	public function remove_donation($form_id, $args = array()) {
1078 1078
 
1079 1079
 		// Set some defaults.
1080 1080
 		$defaults = array(
@@ -1082,12 +1082,12 @@  discard block
 block discarded – undo
1082 1082
 			'price'    => false,
1083 1083
 			'price_id' => false,
1084 1084
 		);
1085
-		$args     = wp_parse_args( $args, $defaults );
1085
+		$args = wp_parse_args($args, $defaults);
1086 1086
 
1087
-		$form = new Give_Donate_Form( $form_id );
1087
+		$form = new Give_Donate_Form($form_id);
1088 1088
 
1089 1089
 		// Bail if this post isn't a valid give donation form.
1090
-		if ( ! $form || $form->post_type !== 'give_forms' ) {
1090
+		if ( ! $form || $form->post_type !== 'give_forms') {
1091 1091
 			return false;
1092 1092
 		}
1093 1093
 
@@ -1100,7 +1100,7 @@  discard block
 block discarded – undo
1100 1100
 
1101 1101
 		$this->pending['donations'][] = $pending_args;
1102 1102
 
1103
-		$this->decrease_subtotal( $this->total );
1103
+		$this->decrease_subtotal($this->total);
1104 1104
 
1105 1105
 		return true;
1106 1106
 	}
@@ -1116,13 +1116,13 @@  discard block
 block discarded – undo
1116 1116
 	 *
1117 1117
 	 * @return bool           If the note was specified or not
1118 1118
 	 */
1119
-	public function add_note( $note = false ) {
1119
+	public function add_note($note = false) {
1120 1120
 		// Bail if no note specified.
1121
-		if ( ! $note ) {
1121
+		if ( ! $note) {
1122 1122
 			return false;
1123 1123
 		}
1124 1124
 
1125
-		give_insert_payment_note( $this->ID, $note );
1125
+		give_insert_payment_note($this->ID, $note);
1126 1126
 	}
1127 1127
 
1128 1128
 	/**
@@ -1135,8 +1135,8 @@  discard block
 block discarded – undo
1135 1135
 	 *
1136 1136
 	 * @return void
1137 1137
 	 */
1138
-	private function increase_subtotal( $amount = 0.00 ) {
1139
-		$amount         = (float) $amount;
1138
+	private function increase_subtotal($amount = 0.00) {
1139
+		$amount = (float) $amount;
1140 1140
 		$this->subtotal += $amount;
1141 1141
 
1142 1142
 		$this->recalculate_total();
@@ -1152,11 +1152,11 @@  discard block
 block discarded – undo
1152 1152
 	 *
1153 1153
 	 * @return void
1154 1154
 	 */
1155
-	private function decrease_subtotal( $amount = 0.00 ) {
1156
-		$amount         = (float) $amount;
1155
+	private function decrease_subtotal($amount = 0.00) {
1156
+		$amount = (float) $amount;
1157 1157
 		$this->subtotal -= $amount;
1158 1158
 
1159
-		if ( $this->subtotal < 0 ) {
1159
+		if ($this->subtotal < 0) {
1160 1160
 			$this->subtotal = 0;
1161 1161
 		}
1162 1162
 
@@ -1185,24 +1185,24 @@  discard block
 block discarded – undo
1185 1185
 	 *
1186 1186
 	 * @return bool   $updated Returns if the status was successfully updated.
1187 1187
 	 */
1188
-	public function update_status( $status = false ) {
1188
+	public function update_status($status = false) {
1189 1189
 
1190 1190
 		// standardize the 'complete(d)' status.
1191
-		if ( $status == 'completed' || $status == 'complete' ) {
1191
+		if ($status == 'completed' || $status == 'complete') {
1192 1192
 			$status = 'publish';
1193 1193
 		}
1194 1194
 
1195
-		$old_status = ! empty( $this->old_status ) ? $this->old_status : false;
1195
+		$old_status = ! empty($this->old_status) ? $this->old_status : false;
1196 1196
 
1197
-		if ( $old_status === $status ) {
1197
+		if ($old_status === $status) {
1198 1198
 			return false; // Don't permit status changes that aren't changes.
1199 1199
 		}
1200 1200
 
1201
-		$do_change = apply_filters( 'give_should_update_payment_status', true, $this->ID, $status, $old_status );
1201
+		$do_change = apply_filters('give_should_update_payment_status', true, $this->ID, $status, $old_status);
1202 1202
 
1203 1203
 		$updated = false;
1204 1204
 
1205
-		if ( $do_change ) {
1205
+		if ($do_change) {
1206 1206
 
1207 1207
 			/**
1208 1208
 			 * Fires before changing payment status.
@@ -1213,21 +1213,21 @@  discard block
 block discarded – undo
1213 1213
 			 * @param string $status     The new status.
1214 1214
 			 * @param string $old_status The old status.
1215 1215
 			 */
1216
-			do_action( 'give_before_payment_status_change', $this->ID, $status, $old_status );
1216
+			do_action('give_before_payment_status_change', $this->ID, $status, $old_status);
1217 1217
 
1218 1218
 			$update_fields = array(
1219 1219
 				'ID'          => $this->ID,
1220 1220
 				'post_status' => $status,
1221
-				'edit_date'   => current_time( 'mysql' ),
1221
+				'edit_date'   => current_time('mysql'),
1222 1222
 			);
1223 1223
 
1224
-			$updated = wp_update_post( apply_filters( 'give_update_payment_status_fields', $update_fields ) );
1224
+			$updated = wp_update_post(apply_filters('give_update_payment_status_fields', $update_fields));
1225 1225
 
1226 1226
 			$all_payment_statuses  = give_get_payment_statuses();
1227
-			$this->status_nicename = array_key_exists( $status, $all_payment_statuses ) ? $all_payment_statuses[ $status ] : ucfirst( $status );
1227
+			$this->status_nicename = array_key_exists($status, $all_payment_statuses) ? $all_payment_statuses[$status] : ucfirst($status);
1228 1228
 
1229 1229
 			// Process any specific status functions.
1230
-			switch ( $status ) {
1230
+			switch ($status) {
1231 1231
 				case 'refunded':
1232 1232
 					$this->process_refund();
1233 1233
 					break;
@@ -1254,7 +1254,7 @@  discard block
 block discarded – undo
1254 1254
 			 * @param string $status     The new status.
1255 1255
 			 * @param string $old_status The old status.
1256 1256
 			 */
1257
-			do_action( 'give_update_payment_status', $this->ID, $status, $old_status );
1257
+			do_action('give_update_payment_status', $this->ID, $status, $old_status);
1258 1258
 
1259 1259
 		}// End if().
1260 1260
 
@@ -1289,24 +1289,24 @@  discard block
 block discarded – undo
1289 1289
 	 *
1290 1290
 	 * @return mixed             The value from the post meta
1291 1291
 	 */
1292
-	public function get_meta( $meta_key = '_give_payment_meta', $single = true ) {
1293
-		if( ! has_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta' ) && ! doing_filter( 'get_post_metadata' ) ) {
1294
-			add_filter( 'get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4 );
1292
+	public function get_meta($meta_key = '_give_payment_meta', $single = true) {
1293
+		if ( ! has_filter('get_post_metadata', 'give_bc_v20_get_payment_meta') && ! doing_filter('get_post_metadata')) {
1294
+			add_filter('get_post_metadata', 'give_bc_v20_get_payment_meta', 999, 4);
1295 1295
 		}
1296 1296
 
1297
-		$meta = give_get_meta( $this->ID, $meta_key, $single );
1297
+		$meta = give_get_meta($this->ID, $meta_key, $single);
1298 1298
 
1299 1299
 		/**
1300 1300
 		 * Filter the specific meta key value.
1301 1301
 		 *
1302 1302
 		 * @since 1.5
1303 1303
 		 */
1304
-		$meta = apply_filters( "give_get_payment_meta_{$meta_key}", $meta, $this->ID );
1304
+		$meta = apply_filters("give_get_payment_meta_{$meta_key}", $meta, $this->ID);
1305 1305
 
1306 1306
 		// Security check.
1307
-		if ( is_serialized( $meta ) ) {
1308
-			preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $meta, $matches );
1309
-			if ( ! empty( $matches ) ) {
1307
+		if (is_serialized($meta)) {
1308
+			preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $meta, $matches);
1309
+			if ( ! empty($matches)) {
1310 1310
 				$meta = array();
1311 1311
 			}
1312 1312
 		}
@@ -1316,7 +1316,7 @@  discard block
 block discarded – undo
1316 1316
 		 *
1317 1317
 		 * @since 1.5
1318 1318
 		 */
1319
-		return apply_filters( 'give_get_payment_meta', $meta, $this->ID, $meta_key );
1319
+		return apply_filters('give_get_payment_meta', $meta, $this->ID, $meta_key);
1320 1320
 	}
1321 1321
 
1322 1322
 	/**
@@ -1331,8 +1331,8 @@  discard block
 block discarded – undo
1331 1331
 	 *
1332 1332
 	 * @return int|bool           Meta ID if the key didn't exist, true on successful update, false on failure
1333 1333
 	 */
1334
-	public function update_meta( $meta_key = '', $meta_value = '', $prev_value = '' ) {
1335
-		if ( empty( $meta_key ) ) {
1334
+	public function update_meta($meta_key = '', $meta_value = '', $prev_value = '') {
1335
+		if (empty($meta_key)) {
1336 1336
 			return false;
1337 1337
 		}
1338 1338
 
@@ -1342,9 +1342,9 @@  discard block
 block discarded – undo
1342 1342
 		 *
1343 1343
 		 * @since 1.5
1344 1344
 		 */
1345
-		$meta_value = apply_filters( "give_update_payment_meta_{$meta_key}", $meta_value, $this->ID );
1345
+		$meta_value = apply_filters("give_update_payment_meta_{$meta_key}", $meta_value, $this->ID);
1346 1346
 
1347
-		return give_update_meta( $this->ID, $meta_key, $meta_value, $prev_value );
1347
+		return give_update_meta($this->ID, $meta_key, $meta_value, $prev_value);
1348 1348
 	}
1349 1349
 
1350 1350
 	/**
@@ -1359,14 +1359,14 @@  discard block
 block discarded – undo
1359 1359
 		$process_refund = true;
1360 1360
 
1361 1361
 		// If the payment was not in publish or revoked status, don't decrement stats as they were never incremented.
1362
-		if ( 'publish' != $this->old_status || 'refunded' != $this->status ) {
1362
+		if ('publish' != $this->old_status || 'refunded' != $this->status) {
1363 1363
 			$process_refund = false;
1364 1364
 		}
1365 1365
 
1366 1366
 		// Allow extensions to filter for their own payment types, Example: Recurring Payments.
1367
-		$process_refund = apply_filters( 'give_should_process_refund', $process_refund, $this );
1367
+		$process_refund = apply_filters('give_should_process_refund', $process_refund, $this);
1368 1368
 
1369
-		if ( false === $process_refund ) {
1369
+		if (false === $process_refund) {
1370 1370
 			return;
1371 1371
 		}
1372 1372
 
@@ -1377,13 +1377,13 @@  discard block
 block discarded – undo
1377 1377
 		 *
1378 1378
 		 * @param Give_Payment $this Payment object.
1379 1379
 		 */
1380
-		do_action( 'give_pre_refund_payment', $this );
1380
+		do_action('give_pre_refund_payment', $this);
1381 1381
 
1382
-		$decrease_earnings       = apply_filters( 'give_decrease_store_earnings_on_refund', true, $this );
1383
-		$decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_refund', true, $this );
1384
-		$decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_refund', true, $this );
1382
+		$decrease_earnings       = apply_filters('give_decrease_store_earnings_on_refund', true, $this);
1383
+		$decrease_customer_value = apply_filters('give_decrease_customer_value_on_refund', true, $this);
1384
+		$decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_refund', true, $this);
1385 1385
 
1386
-		$this->maybe_alter_stats( $decrease_earnings, $decrease_customer_value, $decrease_purchase_count );
1386
+		$this->maybe_alter_stats($decrease_earnings, $decrease_customer_value, $decrease_purchase_count);
1387 1387
 		$this->delete_sales_logs();
1388 1388
 
1389 1389
 		// @todo: Refresh only range related stat cache
@@ -1396,7 +1396,7 @@  discard block
 block discarded – undo
1396 1396
 		 *
1397 1397
 		 * @param Give_Payment $this Payment object.
1398 1398
 		 */
1399
-		do_action( 'give_post_refund_payment', $this );
1399
+		do_action('give_post_refund_payment', $this);
1400 1400
 	}
1401 1401
 
1402 1402
 	/**
@@ -1423,26 +1423,26 @@  discard block
 block discarded – undo
1423 1423
 		$process_pending = true;
1424 1424
 
1425 1425
 		// If the payment was not in publish or revoked status, don't decrement stats as they were never incremented.
1426
-		if ( 'publish' != $this->old_status || 'pending' != $this->status ) {
1426
+		if ('publish' != $this->old_status || 'pending' != $this->status) {
1427 1427
 			$process_pending = false;
1428 1428
 		}
1429 1429
 
1430 1430
 		// Allow extensions to filter for their own payment types, Example: Recurring Payments.
1431
-		$process_pending = apply_filters( 'give_should_process_pending', $process_pending, $this );
1431
+		$process_pending = apply_filters('give_should_process_pending', $process_pending, $this);
1432 1432
 
1433
-		if ( false === $process_pending ) {
1433
+		if (false === $process_pending) {
1434 1434
 			return;
1435 1435
 		}
1436 1436
 
1437
-		$decrease_earnings       = apply_filters( 'give_decrease_earnings_on_pending', true, $this );
1438
-		$decrease_donor_value    = apply_filters( 'give_decrease_donor_value_on_pending', true, $this );
1439
-		$decrease_donation_count = apply_filters( 'give_decrease_donors_donation_count_on_pending', true, $this );
1437
+		$decrease_earnings       = apply_filters('give_decrease_earnings_on_pending', true, $this);
1438
+		$decrease_donor_value    = apply_filters('give_decrease_donor_value_on_pending', true, $this);
1439
+		$decrease_donation_count = apply_filters('give_decrease_donors_donation_count_on_pending', true, $this);
1440 1440
 
1441
-		$this->maybe_alter_stats( $decrease_earnings, $decrease_donor_value, $decrease_donation_count );
1441
+		$this->maybe_alter_stats($decrease_earnings, $decrease_donor_value, $decrease_donation_count);
1442 1442
 		$this->delete_sales_logs();
1443 1443
 
1444 1444
 		$this->completed_date = false;
1445
-		$this->update_meta( '_give_completed_date', '' );
1445
+		$this->update_meta('_give_completed_date', '');
1446 1446
 
1447 1447
 		// @todo: Refresh only range related stat cache
1448 1448
 		give_delete_donation_stats();
@@ -1460,26 +1460,26 @@  discard block
 block discarded – undo
1460 1460
 		$process_cancelled = true;
1461 1461
 
1462 1462
 		// If the payment was not in publish or revoked status, don't decrement stats as they were never incremented.
1463
-		if ( 'publish' != $this->old_status || 'cancelled' != $this->status ) {
1463
+		if ('publish' != $this->old_status || 'cancelled' != $this->status) {
1464 1464
 			$process_cancelled = false;
1465 1465
 		}
1466 1466
 
1467 1467
 		// Allow extensions to filter for their own payment types, Example: Recurring Payments.
1468
-		$process_cancelled = apply_filters( 'give_should_process_cancelled', $process_cancelled, $this );
1468
+		$process_cancelled = apply_filters('give_should_process_cancelled', $process_cancelled, $this);
1469 1469
 
1470
-		if ( false === $process_cancelled ) {
1470
+		if (false === $process_cancelled) {
1471 1471
 			return;
1472 1472
 		}
1473 1473
 
1474
-		$decrease_earnings       = apply_filters( 'give_decrease_earnings_on_cancelled', true, $this );
1475
-		$decrease_donor_value    = apply_filters( 'give_decrease_donor_value_on_cancelled', true, $this );
1476
-		$decrease_donation_count = apply_filters( 'give_decrease_donors_donation_count_on_cancelled', true, $this );
1474
+		$decrease_earnings       = apply_filters('give_decrease_earnings_on_cancelled', true, $this);
1475
+		$decrease_donor_value    = apply_filters('give_decrease_donor_value_on_cancelled', true, $this);
1476
+		$decrease_donation_count = apply_filters('give_decrease_donors_donation_count_on_cancelled', true, $this);
1477 1477
 
1478
-		$this->maybe_alter_stats( $decrease_earnings, $decrease_donor_value, $decrease_donation_count );
1478
+		$this->maybe_alter_stats($decrease_earnings, $decrease_donor_value, $decrease_donation_count);
1479 1479
 		$this->delete_sales_logs();
1480 1480
 
1481 1481
 		$this->completed_date = false;
1482
-		$this->update_meta( '_give_completed_date', '' );
1482
+		$this->update_meta('_give_completed_date', '');
1483 1483
 
1484 1484
 		// @todo: Refresh only range related stat cache
1485 1485
 		give_delete_donation_stats();
@@ -1495,26 +1495,26 @@  discard block
 block discarded – undo
1495 1495
 		$process_revoked = true;
1496 1496
 
1497 1497
 		// If the payment was not in publish, don't decrement stats as they were never incremented.
1498
-		if ( 'publish' != $this->old_status || 'revoked' != $this->status ) {
1498
+		if ('publish' != $this->old_status || 'revoked' != $this->status) {
1499 1499
 			$process_revoked = false;
1500 1500
 		}
1501 1501
 
1502 1502
 		// Allow extensions to filter for their own payment types, Example: Recurring Payments.
1503
-		$process_revoked = apply_filters( 'give_should_process_revoked', $process_revoked, $this );
1503
+		$process_revoked = apply_filters('give_should_process_revoked', $process_revoked, $this);
1504 1504
 
1505
-		if ( false === $process_revoked ) {
1505
+		if (false === $process_revoked) {
1506 1506
 			return;
1507 1507
 		}
1508 1508
 
1509
-		$decrease_earnings       = apply_filters( 'give_decrease_earnings_on_revoked', true, $this );
1510
-		$decrease_donor_value    = apply_filters( 'give_decrease_donor_value_on_revoked', true, $this );
1511
-		$decrease_donation_count = apply_filters( 'give_decrease_donors_donation_count_on_revoked', true, $this );
1509
+		$decrease_earnings       = apply_filters('give_decrease_earnings_on_revoked', true, $this);
1510
+		$decrease_donor_value    = apply_filters('give_decrease_donor_value_on_revoked', true, $this);
1511
+		$decrease_donation_count = apply_filters('give_decrease_donors_donation_count_on_revoked', true, $this);
1512 1512
 
1513
-		$this->maybe_alter_stats( $decrease_earnings, $decrease_donor_value, $decrease_donation_count );
1513
+		$this->maybe_alter_stats($decrease_earnings, $decrease_donor_value, $decrease_donation_count);
1514 1514
 		$this->delete_sales_logs();
1515 1515
 
1516 1516
 		$this->completed_date = false;
1517
-		$this->update_meta( '_give_completed_date', '' );
1517
+		$this->update_meta('_give_completed_date', '');
1518 1518
 
1519 1519
 		// @todo: Refresh only range related stat cache
1520 1520
 		give_delete_donation_stats();
@@ -1532,25 +1532,25 @@  discard block
 block discarded – undo
1532 1532
 	 *
1533 1533
 	 * @return void
1534 1534
 	 */
1535
-	private function maybe_alter_stats( $alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count ) {
1535
+	private function maybe_alter_stats($alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count) {
1536 1536
 
1537
-		give_undo_donation( $this->ID );
1537
+		give_undo_donation($this->ID);
1538 1538
 
1539 1539
 		// Decrease store earnings.
1540
-		if ( true === $alter_store_earnings ) {
1541
-			give_decrease_total_earnings( $this->total );
1540
+		if (true === $alter_store_earnings) {
1541
+			give_decrease_total_earnings($this->total);
1542 1542
 		}
1543 1543
 
1544 1544
 		// Decrement the stats for the donor.
1545
-		if ( ! empty( $this->customer_id ) ) {
1545
+		if ( ! empty($this->customer_id)) {
1546 1546
 
1547
-			$donor = new Give_Donor( $this->customer_id );
1547
+			$donor = new Give_Donor($this->customer_id);
1548 1548
 
1549
-			if ( true === $alter_customer_value ) {
1550
-				$donor->decrease_value( $this->total );
1549
+			if (true === $alter_customer_value) {
1550
+				$donor->decrease_value($this->total);
1551 1551
 			}
1552 1552
 
1553
-			if ( true === $alter_customer_purchase_count ) {
1553
+			if (true === $alter_customer_purchase_count) {
1554 1554
 				$donor->decrease_donation_count();
1555 1555
 			}
1556 1556
 		}
@@ -1567,7 +1567,7 @@  discard block
 block discarded – undo
1567 1567
 	 */
1568 1568
 	private function delete_sales_logs() {
1569 1569
 		// Remove related sale log entries.
1570
-		Give()->logs->delete_logs( $this->ID );
1570
+		Give()->logs->delete_logs($this->ID);
1571 1571
 	}
1572 1572
 
1573 1573
 	/**
@@ -1588,13 +1588,13 @@  discard block
 block discarded – undo
1588 1588
 	 * @return string The date the payment was completed
1589 1589
 	 */
1590 1590
 	private function setup_completed_date() {
1591
-		$payment = get_post( $this->ID );
1591
+		$payment = get_post($this->ID);
1592 1592
 
1593
-		if ( 'pending' == $payment->post_status || 'preapproved' == $payment->post_status ) {
1593
+		if ('pending' == $payment->post_status || 'preapproved' == $payment->post_status) {
1594 1594
 			return false; // This payment was never completed.
1595 1595
 		}
1596 1596
 
1597
-		$date = ( $date = $this->get_meta( '_give_completed_date', true ) ) ? $date : $payment->modified_date;
1597
+		$date = ($date = $this->get_meta('_give_completed_date', true)) ? $date : $payment->modified_date;
1598 1598
 
1599 1599
 		return $date;
1600 1600
 	}
@@ -1608,7 +1608,7 @@  discard block
 block discarded – undo
1608 1608
 	 * @return string The payment mode
1609 1609
 	 */
1610 1610
 	private function setup_mode() {
1611
-		return $this->get_meta( '_give_payment_mode' );
1611
+		return $this->get_meta('_give_payment_mode');
1612 1612
 	}
1613 1613
 
1614 1614
 	/**
@@ -1620,7 +1620,7 @@  discard block
 block discarded – undo
1620 1620
 	 * @return bool The payment import
1621 1621
 	 */
1622 1622
 	private function setup_import() {
1623
-		return (bool) $this->get_meta( '_give_payment_import' );
1623
+		return (bool) $this->get_meta('_give_payment_import');
1624 1624
 	}
1625 1625
 
1626 1626
 	/**
@@ -1632,9 +1632,9 @@  discard block
 block discarded – undo
1632 1632
 	 * @return float The payment total
1633 1633
 	 */
1634 1634
 	private function setup_total() {
1635
-		$amount = $this->get_meta( '_give_payment_total', true );
1635
+		$amount = $this->get_meta('_give_payment_total', true);
1636 1636
 
1637
-		return round( floatval( $amount ), give_get_price_decimals( $this->ID ) );
1637
+		return round(floatval($amount), give_get_price_decimals($this->ID));
1638 1638
 	}
1639 1639
 
1640 1640
 	/**
@@ -1661,17 +1661,16 @@  discard block
 block discarded – undo
1661 1661
 	 * @return string The currency for the payment
1662 1662
 	 */
1663 1663
 	private function setup_currency() {
1664
-		$currency = $this->get_meta( '_give_payment_currency', true );
1665
-		$currency = ! empty( $currency ) ?
1666
-			$currency :
1667
-			/**
1664
+		$currency = $this->get_meta('_give_payment_currency', true);
1665
+		$currency = ! empty($currency) ?
1666
+			$currency : /**
1668 1667
 			 * Filter the default donation currency
1669 1668
 			 *
1670 1669
 			 * @since 1.5
1671 1670
 			 */
1672 1671
 			apply_filters(
1673 1672
 				'give_payment_currency_default',
1674
-				give_get_currency( $this->form_id, $this ),
1673
+				give_get_currency($this->form_id, $this),
1675 1674
 				$this
1676 1675
 			);
1677 1676
 
@@ -1687,7 +1686,7 @@  discard block
 block discarded – undo
1687 1686
 	 * @return string The gateway
1688 1687
 	 */
1689 1688
 	private function setup_gateway() {
1690
-		$gateway = $this->get_meta( '_give_payment_gateway', true );
1689
+		$gateway = $this->get_meta('_give_payment_gateway', true);
1691 1690
 
1692 1691
 		return $gateway;
1693 1692
 	}
@@ -1701,11 +1700,11 @@  discard block
 block discarded – undo
1701 1700
 	 * @return string The donation ID
1702 1701
 	 */
1703 1702
 	private function setup_transaction_id() {
1704
-		$transaction_id = $this->get_meta( '_give_payment_transaction_id', true );
1703
+		$transaction_id = $this->get_meta('_give_payment_transaction_id', true);
1705 1704
 
1706
-		if ( empty( $transaction_id ) ) {
1705
+		if (empty($transaction_id)) {
1707 1706
 			$gateway        = $this->gateway;
1708
-			$transaction_id = apply_filters( "give_get_payment_transaction_id-{$gateway}", $this->ID );
1707
+			$transaction_id = apply_filters("give_get_payment_transaction_id-{$gateway}", $this->ID);
1709 1708
 		}
1710 1709
 
1711 1710
 		return $transaction_id;
@@ -1721,7 +1720,7 @@  discard block
 block discarded – undo
1721 1720
 	 * @return string The IP address for the payment
1722 1721
 	 */
1723 1722
 	private function setup_ip() {
1724
-		$ip = $this->get_meta( '_give_payment_donor_ip', true );
1723
+		$ip = $this->get_meta('_give_payment_donor_ip', true);
1725 1724
 
1726 1725
 		return $ip;
1727 1726
 	}
@@ -1736,7 +1735,7 @@  discard block
 block discarded – undo
1736 1735
 	 * @return int The Donor ID.
1737 1736
 	 */
1738 1737
 	private function setup_donor_id() {
1739
-		$donor_id = $this->get_meta( '_give_payment_donor_id', true );
1738
+		$donor_id = $this->get_meta('_give_payment_donor_id', true);
1740 1739
 
1741 1740
 		return $donor_id;
1742 1741
 	}
@@ -1753,8 +1752,8 @@  discard block
 block discarded – undo
1753 1752
 	 */
1754 1753
 	private function setup_user_id() {
1755 1754
 
1756
-		$donor   = Give()->customers->get_customer_by( 'id', $this->customer_id );
1757
-		$user_id = $donor ? absint( $donor->user_id ) : 0;
1755
+		$donor   = Give()->customers->get_customer_by('id', $this->customer_id);
1756
+		$user_id = $donor ? absint($donor->user_id) : 0;
1758 1757
 
1759 1758
 
1760 1759
 		return $user_id;
@@ -1771,10 +1770,10 @@  discard block
 block discarded – undo
1771 1770
 	 * @return string The email address for the payment.
1772 1771
 	 */
1773 1772
 	private function setup_email() {
1774
-		$email = $this->get_meta( '_give_payment_donor_email', true );
1773
+		$email = $this->get_meta('_give_payment_donor_email', true);
1775 1774
 
1776
-		if ( empty( $email ) && $this->customer_id ) {
1777
-			$email = Give()->donors->get_column( 'email', $this->customer_id );
1775
+		if (empty($email) && $this->customer_id) {
1776
+			$email = Give()->donors->get_column('email', $this->customer_id);
1778 1777
 		}
1779 1778
 
1780 1779
 		return $email;
@@ -1794,22 +1793,22 @@  discard block
 block discarded – undo
1794 1793
 			'last_name'  => $this->last_name,
1795 1794
 		);
1796 1795
 
1797
-		$user_info = isset( $this->payment_meta['user_info'] ) ? $this->payment_meta['user_info'] : array();
1796
+		$user_info = isset($this->payment_meta['user_info']) ? $this->payment_meta['user_info'] : array();
1798 1797
 
1799
-		if ( is_serialized( $user_info ) ) {
1800
-			preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches );
1801
-			if ( ! empty( $matches ) ) {
1798
+		if (is_serialized($user_info)) {
1799
+			preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches);
1800
+			if ( ! empty($matches)) {
1802 1801
 				$user_info = array();
1803 1802
 			}
1804 1803
 		}
1805 1804
 
1806
-		$user_info = wp_parse_args( $user_info, $defaults );
1805
+		$user_info = wp_parse_args($user_info, $defaults);
1807 1806
 
1808
-		if ( empty( $user_info ) ) {
1807
+		if (empty($user_info)) {
1809 1808
 			// Get the donor, but only if it's been created.
1810
-			$donor = new Give_Donor( $this->customer_id );
1809
+			$donor = new Give_Donor($this->customer_id);
1811 1810
 
1812
-			if ( $donor->id > 0 ) {
1811
+			if ($donor->id > 0) {
1813 1812
 				$user_info = array(
1814 1813
 					'first_name' => $donor->get_first_name(),
1815 1814
 					'last_name'  => $donor->get_last_name(),
@@ -1819,25 +1818,25 @@  discard block
 block discarded – undo
1819 1818
 			}
1820 1819
 		} else {
1821 1820
 			// Get the donor, but only if it's been created.
1822
-			$donor = new Give_Donor( $this->customer_id );
1821
+			$donor = new Give_Donor($this->customer_id);
1823 1822
 
1824
-			if ( $donor->id > 0 ) {
1825
-				foreach ( $user_info as $key => $value ) {
1826
-					if ( ! empty( $value ) ) {
1823
+			if ($donor->id > 0) {
1824
+				foreach ($user_info as $key => $value) {
1825
+					if ( ! empty($value)) {
1827 1826
 						continue;
1828 1827
 					}
1829 1828
 
1830
-					switch ( $key ) {
1829
+					switch ($key) {
1831 1830
 						case 'first_name':
1832
-							$user_info[ $key ] = $donor->get_first_name();
1831
+							$user_info[$key] = $donor->get_first_name();
1833 1832
 							break;
1834 1833
 
1835 1834
 						case 'last_name':
1836
-							$user_info[ $key ] = $donor->get_last_name();
1835
+							$user_info[$key] = $donor->get_last_name();
1837 1836
 							break;
1838 1837
 
1839 1838
 						case 'email':
1840
-							$user_info[ $key ] = $donor->email;
1839
+							$user_info[$key] = $donor->email;
1841 1840
 							break;
1842 1841
 					}
1843 1842
 				}
@@ -1857,12 +1856,12 @@  discard block
 block discarded – undo
1857 1856
 	 * @return array The Address information for the payment.
1858 1857
 	 */
1859 1858
 	private function setup_address() {
1860
-		$address['line1']   = give_get_meta( $this->ID, '_give_donor_billing_address1', true, '' );
1861
-		$address['line2']   = give_get_meta( $this->ID, '_give_donor_billing_address2', true, '' );
1862
-		$address['city']    = give_get_meta( $this->ID, '_give_donor_billing_city', true, '' );
1863
-		$address['state']   = give_get_meta( $this->ID, '_give_donor_billing_state', true, '' );
1864
-		$address['zip']     = give_get_meta( $this->ID, '_give_donor_billing_zip', true, '' );
1865
-		$address['country'] = give_get_meta( $this->ID, '_give_donor_billing_country', true, '' );
1859
+		$address['line1']   = give_get_meta($this->ID, '_give_donor_billing_address1', true, '');
1860
+		$address['line2']   = give_get_meta($this->ID, '_give_donor_billing_address2', true, '');
1861
+		$address['city']    = give_get_meta($this->ID, '_give_donor_billing_city', true, '');
1862
+		$address['state']   = give_get_meta($this->ID, '_give_donor_billing_state', true, '');
1863
+		$address['zip']     = give_get_meta($this->ID, '_give_donor_billing_zip', true, '');
1864
+		$address['country'] = give_get_meta($this->ID, '_give_donor_billing_country', true, '');
1866 1865
 
1867 1866
 		return $address;
1868 1867
 	}
@@ -1877,7 +1876,7 @@  discard block
 block discarded – undo
1877 1876
 	 */
1878 1877
 	private function setup_form_title() {
1879 1878
 
1880
-		$form_id = $this->get_meta( '_give_payment_form_title', true );
1879
+		$form_id = $this->get_meta('_give_payment_form_title', true);
1881 1880
 
1882 1881
 		return $form_id;
1883 1882
 	}
@@ -1892,7 +1891,7 @@  discard block
 block discarded – undo
1892 1891
 	 */
1893 1892
 	private function setup_form_id() {
1894 1893
 
1895
-		$form_id = $this->get_meta( '_give_payment_form_id', true );
1894
+		$form_id = $this->get_meta('_give_payment_form_id', true);
1896 1895
 
1897 1896
 		return $form_id;
1898 1897
 	}
@@ -1906,7 +1905,7 @@  discard block
 block discarded – undo
1906 1905
 	 * @return int The Form Price ID.
1907 1906
 	 */
1908 1907
 	private function setup_price_id() {
1909
-		$price_id = $this->get_meta( '_give_payment_price_id', true );
1908
+		$price_id = $this->get_meta('_give_payment_price_id', true);
1910 1909
 
1911 1910
 		return $price_id;
1912 1911
 	}
@@ -1920,7 +1919,7 @@  discard block
 block discarded – undo
1920 1919
 	 * @return string The Payment Key.
1921 1920
 	 */
1922 1921
 	private function setup_payment_key() {
1923
-		$key = $this->get_meta( '_give_payment_purchase_key', true );
1922
+		$key = $this->get_meta('_give_payment_purchase_key', true);
1924 1923
 
1925 1924
 		return $key;
1926 1925
 	}
@@ -1936,11 +1935,11 @@  discard block
 block discarded – undo
1936 1935
 	private function setup_payment_number() {
1937 1936
 		$number = $this->ID;
1938 1937
 
1939
-		if ( give_get_option( 'enable_sequential' ) ) {
1938
+		if (give_get_option('enable_sequential')) {
1940 1939
 
1941
-			$number = $this->get_meta( '_give_payment_number', true );
1940
+			$number = $this->get_meta('_give_payment_number', true);
1942 1941
 
1943
-			if ( ! $number ) {
1942
+			if ( ! $number) {
1944 1943
 
1945 1944
 				$number = $this->ID;
1946 1945
 
@@ -1958,7 +1957,7 @@  discard block
 block discarded – undo
1958 1957
 	 * @return array The payment object as an array.
1959 1958
 	 */
1960 1959
 	public function array_convert() {
1961
-		return get_object_vars( $this );
1960
+		return get_object_vars($this);
1962 1961
 	}
1963 1962
 
1964 1963
 
@@ -1971,7 +1970,7 @@  discard block
 block discarded – undo
1971 1970
 	 * @return bool
1972 1971
 	 */
1973 1972
 	public function is_completed() {
1974
-		return ( 'publish' === $this->status && $this->completed_date );
1973
+		return ('publish' === $this->status && $this->completed_date);
1975 1974
 	}
1976 1975
 
1977 1976
 	/**
@@ -1983,7 +1982,7 @@  discard block
 block discarded – undo
1983 1982
 	 * @return string Date payment was completed.
1984 1983
 	 */
1985 1984
 	private function get_completed_date() {
1986
-		return apply_filters( 'give_payment_completed_date', $this->completed_date, $this->ID, $this );
1985
+		return apply_filters('give_payment_completed_date', $this->completed_date, $this->ID, $this);
1987 1986
 	}
1988 1987
 
1989 1988
 	/**
@@ -1995,7 +1994,7 @@  discard block
 block discarded – undo
1995 1994
 	 * @return float Payment subtotal.
1996 1995
 	 */
1997 1996
 	private function get_subtotal() {
1998
-		return apply_filters( 'give_get_payment_subtotal', $this->subtotal, $this->ID, $this );
1997
+		return apply_filters('give_get_payment_subtotal', $this->subtotal, $this->ID, $this);
1999 1998
 	}
2000 1999
 
2001 2000
 	/**
@@ -2007,7 +2006,7 @@  discard block
 block discarded – undo
2007 2006
 	 * @return string Payment currency code.
2008 2007
 	 */
2009 2008
 	private function get_currency() {
2010
-		return apply_filters( 'give_payment_currency_code', $this->currency, $this->ID, $this );
2009
+		return apply_filters('give_payment_currency_code', $this->currency, $this->ID, $this);
2011 2010
 	}
2012 2011
 
2013 2012
 	/**
@@ -2019,7 +2018,7 @@  discard block
 block discarded – undo
2019 2018
 	 * @return string Gateway used.
2020 2019
 	 */
2021 2020
 	private function get_gateway() {
2022
-		return apply_filters( 'give_payment_gateway', $this->gateway, $this->ID, $this );
2021
+		return apply_filters('give_payment_gateway', $this->gateway, $this->ID, $this);
2023 2022
 	}
2024 2023
 
2025 2024
 	/**
@@ -2031,7 +2030,7 @@  discard block
 block discarded – undo
2031 2030
 	 * @return string Donation ID from merchant processor.
2032 2031
 	 */
2033 2032
 	private function get_transaction_id() {
2034
-		return apply_filters( 'give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this );
2033
+		return apply_filters('give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this);
2035 2034
 	}
2036 2035
 
2037 2036
 	/**
@@ -2043,7 +2042,7 @@  discard block
 block discarded – undo
2043 2042
 	 * @return string Payment IP address
2044 2043
 	 */
2045 2044
 	private function get_ip() {
2046
-		return apply_filters( 'give_payment_user_ip', $this->ip, $this->ID, $this );
2045
+		return apply_filters('give_payment_user_ip', $this->ip, $this->ID, $this);
2047 2046
 	}
2048 2047
 
2049 2048
 	/**
@@ -2055,7 +2054,7 @@  discard block
 block discarded – undo
2055 2054
 	 * @return int Payment donor ID.
2056 2055
 	 */
2057 2056
 	private function get_donor_id() {
2058
-		return apply_filters( 'give_payment_customer_id', $this->customer_id, $this->ID, $this );
2057
+		return apply_filters('give_payment_customer_id', $this->customer_id, $this->ID, $this);
2059 2058
 	}
2060 2059
 
2061 2060
 	/**
@@ -2067,7 +2066,7 @@  discard block
 block discarded – undo
2067 2066
 	 * @return int Payment user ID.
2068 2067
 	 */
2069 2068
 	private function get_user_id() {
2070
-		return apply_filters( 'give_payment_user_id', $this->user_id, $this->ID, $this );
2069
+		return apply_filters('give_payment_user_id', $this->user_id, $this->ID, $this);
2071 2070
 	}
2072 2071
 
2073 2072
 	/**
@@ -2079,7 +2078,7 @@  discard block
 block discarded – undo
2079 2078
 	 * @return string Payment donor email.
2080 2079
 	 */
2081 2080
 	private function get_email() {
2082
-		return apply_filters( 'give_payment_user_email', $this->email, $this->ID, $this );
2081
+		return apply_filters('give_payment_user_email', $this->email, $this->ID, $this);
2083 2082
 	}
2084 2083
 
2085 2084
 	/**
@@ -2091,7 +2090,7 @@  discard block
 block discarded – undo
2091 2090
 	 * @return array Payment user info.
2092 2091
 	 */
2093 2092
 	private function get_user_info() {
2094
-		return apply_filters( 'give_payment_meta_user_info', $this->user_info, $this->ID, $this );
2093
+		return apply_filters('give_payment_meta_user_info', $this->user_info, $this->ID, $this);
2095 2094
 	}
2096 2095
 
2097 2096
 	/**
@@ -2103,7 +2102,7 @@  discard block
 block discarded – undo
2103 2102
 	 * @return array Payment billing address.
2104 2103
 	 */
2105 2104
 	private function get_address() {
2106
-		return apply_filters( 'give_payment_address', $this->address, $this->ID, $this );
2105
+		return apply_filters('give_payment_address', $this->address, $this->ID, $this);
2107 2106
 	}
2108 2107
 
2109 2108
 	/**
@@ -2115,7 +2114,7 @@  discard block
 block discarded – undo
2115 2114
 	 * @return string Payment key.
2116 2115
 	 */
2117 2116
 	private function get_key() {
2118
-		return apply_filters( 'give_payment_key', $this->key, $this->ID, $this );
2117
+		return apply_filters('give_payment_key', $this->key, $this->ID, $this);
2119 2118
 	}
2120 2119
 
2121 2120
 	/**
@@ -2127,7 +2126,7 @@  discard block
 block discarded – undo
2127 2126
 	 * @return string Payment form id
2128 2127
 	 */
2129 2128
 	private function get_form_id() {
2130
-		return apply_filters( 'give_payment_form_id', $this->form_id, $this->ID, $this );
2129
+		return apply_filters('give_payment_form_id', $this->form_id, $this->ID, $this);
2131 2130
 	}
2132 2131
 
2133 2132
 	/**
@@ -2139,6 +2138,6 @@  discard block
 block discarded – undo
2139 2138
 	 * @return int|string Payment number
2140 2139
 	 */
2141 2140
 	private function get_number() {
2142
-		return apply_filters( 'give_payment_number', $this->number, $this->ID, $this );
2141
+		return apply_filters('give_payment_number', $this->number, $this->ID, $this);
2143 2142
 	}
2144 2143
 }
Please login to merge, or discard this patch.